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