mem_32.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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/page.h>
  10. #include <asm/mman.h>
  11. static struct vm_area_struct gate_vma;
  12. static int __init gate_vma_init(void)
  13. {
  14. if (!FIXADDR_USER_START)
  15. return 0;
  16. gate_vma.vm_mm = NULL;
  17. gate_vma.vm_start = FIXADDR_USER_START;
  18. gate_vma.vm_end = FIXADDR_USER_END;
  19. gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
  20. gate_vma.vm_page_prot = __P101;
  21. return 0;
  22. }
  23. __initcall(gate_vma_init);
  24. struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
  25. {
  26. return FIXADDR_USER_START ? &gate_vma : NULL;
  27. }
  28. int in_gate_area_no_mm(unsigned long addr)
  29. {
  30. if (!FIXADDR_USER_START)
  31. return 0;
  32. if ((addr >= FIXADDR_USER_START) && (addr < FIXADDR_USER_END))
  33. return 1;
  34. return 0;
  35. }
  36. int in_gate_area(struct mm_struct *mm, unsigned long addr)
  37. {
  38. struct vm_area_struct *vma = get_gate_vma(mm);
  39. if (!vma)
  40. return 0;
  41. return (addr >= vma->vm_start) && (addr < vma->vm_end);
  42. }