mem_32.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * Copyright (C) 2011 Richard Weinberger <richrd@nod.at>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 as
  6. * published by the Free Software Foundation.
  7. */
  8. #include <linux/mm.h>
  9. #include <asm/elf.h>
  10. static struct vm_area_struct gate_vma;
  11. static int __init gate_vma_init(void)
  12. {
  13. if (!FIXADDR_USER_START)
  14. return 0;
  15. gate_vma.vm_mm = NULL;
  16. gate_vma.vm_start = FIXADDR_USER_START;
  17. gate_vma.vm_end = FIXADDR_USER_END;
  18. gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
  19. gate_vma.vm_page_prot = __P101;
  20. return 0;
  21. }
  22. __initcall(gate_vma_init);
  23. struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
  24. {
  25. return FIXADDR_USER_START ? &gate_vma : NULL;
  26. }
  27. int in_gate_area_no_mm(unsigned long addr)
  28. {
  29. if (!FIXADDR_USER_START)
  30. return 0;
  31. if ((addr >= FIXADDR_USER_START) && (addr < FIXADDR_USER_END))
  32. return 1;
  33. return 0;
  34. }
  35. int in_gate_area(struct mm_struct *mm, unsigned long addr)
  36. {
  37. struct vm_area_struct *vma = get_gate_vma(mm);
  38. if (!vma)
  39. return 0;
  40. return (addr >= vma->vm_start) && (addr < vma->vm_end);
  41. }