xref: /linux/arch/x86/um/mem_32.c (revision f2ee442115c9b6219083c019939a9cc0c9abb2f8)
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 
13 static struct vm_area_struct gate_vma;
14 
15 static 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 	/*
27 	 * Make sure the vDSO gets into every core dump.
28 	 * Dumping its contents makes post-mortem fully interpretable later
29 	 * without matching up the same kernel and hardware config to see
30 	 * what PC values meant.
31 	 */
32 	gate_vma.vm_flags |= VM_ALWAYSDUMP;
33 
34 	return 0;
35 }
36 __initcall(gate_vma_init);
37 
38 struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
39 {
40 	return FIXADDR_USER_START ? &gate_vma : NULL;
41 }
42 
43 int in_gate_area_no_mm(unsigned long addr)
44 {
45 	if (!FIXADDR_USER_START)
46 		return 0;
47 
48 	if ((addr >= FIXADDR_USER_START) && (addr < FIXADDR_USER_END))
49 		return 1;
50 
51 	return 0;
52 }
53 
54 int in_gate_area(struct mm_struct *mm, unsigned long addr)
55 {
56 	struct vm_area_struct *vma = get_gate_vma(mm);
57 
58 	if (!vma)
59 		return 0;
60 
61 	return (addr >= vma->vm_start) && (addr < vma->vm_end);
62 }
63