Commit 548f0a4e02f6fa33278e77a2a6477cdeb512317f
Committed by
Linus Torvalds
1 parent
b743ac54e5
Exists in
master
and in
4 other branches
um: Set __HAVE_ARCH_GATE_AREA for i386
When UML is unable to reuse the host's vDSO FIXADDR_USER_START is zero. To handle this special case correclty we have to implement custom gate area helper methods. Signed-off-by: Richard Weinberger <richard@nod.at> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Showing 3 changed files with 65 additions and 1 deletions Side-by-side Diff
arch/um/sys-i386/Makefile
... | ... | @@ -4,7 +4,7 @@ |
4 | 4 | |
5 | 5 | obj-y = bug.o bugs.o checksum.o delay.o fault.o ksyms.o ldt.o ptrace.o \ |
6 | 6 | ptrace_user.o setjmp.o signal.o stub.o stub_segv.o syscalls.o sysrq.o \ |
7 | - sys_call_table.o tls.o atomic64_cx8_32.o | |
7 | + sys_call_table.o tls.o atomic64_cx8_32.o mem.o | |
8 | 8 | |
9 | 9 | obj-$(CONFIG_BINFMT_ELF) += elfcore.o |
10 | 10 |
arch/um/sys-i386/asm/elf.h
... | ... | @@ -105,6 +105,8 @@ |
105 | 105 | #define FIXADDR_USER_START VSYSCALL_BASE |
106 | 106 | #define FIXADDR_USER_END VSYSCALL_END |
107 | 107 | |
108 | +#define __HAVE_ARCH_GATE_AREA 1 | |
109 | + | |
108 | 110 | /* |
109 | 111 | * Architecture-neutral AT_ values in 0-17, leave some room |
110 | 112 | * for more of them, start the x86-specific ones at 32. |
arch/um/sys-i386/mem.c
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 | +} |