aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-08-04 20:27:47 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-08-04 20:27:47 -0400
commit98a96f202203fecad65b44449077c695686ad4db (patch)
treee3544d5323fcf570607c180d6395b2113b54e007
parent5637a2a3e99375a04189ee0896aae985582a2290 (diff)
parent53b884ac3745353de220d92ef792515c3ae692f0 (diff)
Merge branch 'x86-vdso-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 vdso updates from Ingo Molnar: "Further simplifications and improvements to the VDSO code, by Andy Lutomirski" * 'x86-vdso-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86_64/vsyscall: Fix warn_bad_vsyscall log output x86/vdso: Set VM_MAYREAD for the vvar vma x86, vdso: Get rid of the fake section mechanism x86, vdso: Move the vvar area before the vdso text
-rw-r--r--arch/x86/include/asm/vdso.h18
-rw-r--r--arch/x86/kernel/vsyscall_64.c8
-rw-r--r--arch/x86/vdso/Makefile16
-rw-r--r--arch/x86/vdso/vdso-fakesections.c21
-rw-r--r--arch/x86/vdso/vdso-layout.lds.S44
-rw-r--r--arch/x86/vdso/vdso2c.c128
-rw-r--r--arch/x86/vdso/vdso2c.h227
-rw-r--r--arch/x86/vdso/vma.c22
8 files changed, 193 insertions, 291 deletions
diff --git a/arch/x86/include/asm/vdso.h b/arch/x86/include/asm/vdso.h
index 30be253dd283..8021bd28c0f1 100644
--- a/arch/x86/include/asm/vdso.h
+++ b/arch/x86/include/asm/vdso.h
@@ -18,15 +18,15 @@ struct vdso_image {
18 18
19 unsigned long alt, alt_len; 19 unsigned long alt, alt_len;
20 20
21 unsigned long sym_end_mapping; /* Total size of the mapping */ 21 long sym_vvar_start; /* Negative offset to the vvar area */
22 22
23 unsigned long sym_vvar_page; 23 long sym_vvar_page;
24 unsigned long sym_hpet_page; 24 long sym_hpet_page;
25 unsigned long sym_VDSO32_NOTE_MASK; 25 long sym_VDSO32_NOTE_MASK;
26 unsigned long sym___kernel_sigreturn; 26 long sym___kernel_sigreturn;
27 unsigned long sym___kernel_rt_sigreturn; 27 long sym___kernel_rt_sigreturn;
28 unsigned long sym___kernel_vsyscall; 28 long sym___kernel_vsyscall;
29 unsigned long sym_VDSO32_SYSENTER_RETURN; 29 long sym_VDSO32_SYSENTER_RETURN;
30}; 30};
31 31
32#ifdef CONFIG_X86_64 32#ifdef CONFIG_X86_64
diff --git a/arch/x86/kernel/vsyscall_64.c b/arch/x86/kernel/vsyscall_64.c
index ea5b5709aa76..e1e1e80fc6a6 100644
--- a/arch/x86/kernel/vsyscall_64.c
+++ b/arch/x86/kernel/vsyscall_64.c
@@ -81,10 +81,10 @@ static void warn_bad_vsyscall(const char *level, struct pt_regs *regs,
81 if (!show_unhandled_signals) 81 if (!show_unhandled_signals)
82 return; 82 return;
83 83
84 pr_notice_ratelimited("%s%s[%d] %s ip:%lx cs:%lx sp:%lx ax:%lx si:%lx di:%lx\n", 84 printk_ratelimited("%s%s[%d] %s ip:%lx cs:%lx sp:%lx ax:%lx si:%lx di:%lx\n",
85 level, current->comm, task_pid_nr(current), 85 level, current->comm, task_pid_nr(current),
86 message, regs->ip, regs->cs, 86 message, regs->ip, regs->cs,
87 regs->sp, regs->ax, regs->si, regs->di); 87 regs->sp, regs->ax, regs->si, regs->di);
88} 88}
89 89
90static int addr_to_vsyscall_nr(unsigned long addr) 90static int addr_to_vsyscall_nr(unsigned long addr)
diff --git a/arch/x86/vdso/Makefile b/arch/x86/vdso/Makefile
index 61b04fe36e66..5a4affe025e8 100644
--- a/arch/x86/vdso/Makefile
+++ b/arch/x86/vdso/Makefile
@@ -10,7 +10,7 @@ VDSO32-$(CONFIG_X86_32) := y
10VDSO32-$(CONFIG_COMPAT) := y 10VDSO32-$(CONFIG_COMPAT) := y
11 11
12# files to link into the vdso 12# files to link into the vdso
13vobjs-y := vdso-note.o vclock_gettime.o vgetcpu.o vdso-fakesections.o 13vobjs-y := vdso-note.o vclock_gettime.o vgetcpu.o
14 14
15# files to link into kernel 15# files to link into kernel
16obj-y += vma.o 16obj-y += vma.o
@@ -37,7 +37,8 @@ vdso_img_sodbg := $(vdso_img-y:%=vdso%.so.dbg)
37obj-y += $(vdso_img_objs) 37obj-y += $(vdso_img_objs)
38targets += $(vdso_img_cfiles) 38targets += $(vdso_img_cfiles)
39targets += $(vdso_img_sodbg) 39targets += $(vdso_img_sodbg)
40.SECONDARY: $(vdso_img-y:%=$(obj)/vdso-image-%.c) 40.SECONDARY: $(vdso_img-y:%=$(obj)/vdso-image-%.c) \
41 $(vdso_img-y:%=$(obj)/vdso%.so)
41 42
42export CPPFLAGS_vdso.lds += -P -C 43export CPPFLAGS_vdso.lds += -P -C
43 44
@@ -54,10 +55,10 @@ hostprogs-y += vdso2c
54 55
55quiet_cmd_vdso2c = VDSO2C $@ 56quiet_cmd_vdso2c = VDSO2C $@
56define cmd_vdso2c 57define cmd_vdso2c
57 $(obj)/vdso2c $< $@ 58 $(obj)/vdso2c $< $(<:%.dbg=%) $@
58endef 59endef
59 60
60$(obj)/vdso-image-%.c: $(obj)/vdso%.so.dbg $(obj)/vdso2c FORCE 61$(obj)/vdso-image-%.c: $(obj)/vdso%.so.dbg $(obj)/vdso%.so $(obj)/vdso2c FORCE
61 $(call if_changed,vdso2c) 62 $(call if_changed,vdso2c)
62 63
63# 64#
@@ -113,6 +114,10 @@ $(obj)/%-x32.o: $(obj)/%.o FORCE
113 114
114targets += vdsox32.lds $(vobjx32s-y) 115targets += vdsox32.lds $(vobjx32s-y)
115 116
117$(obj)/%.so: OBJCOPYFLAGS := -S
118$(obj)/%.so: $(obj)/%.so.dbg
119 $(call if_changed,objcopy)
120
116$(obj)/vdsox32.so.dbg: $(src)/vdsox32.lds $(vobjx32s) FORCE 121$(obj)/vdsox32.so.dbg: $(src)/vdsox32.lds $(vobjx32s) FORCE
117 $(call if_changed,vdso) 122 $(call if_changed,vdso)
118 123
@@ -134,7 +139,7 @@ override obj-dirs = $(dir $(obj)) $(obj)/vdso32/
134 139
135targets += vdso32/vdso32.lds 140targets += vdso32/vdso32.lds
136targets += vdso32/note.o vdso32/vclock_gettime.o $(vdso32.so-y:%=vdso32/%.o) 141targets += vdso32/note.o vdso32/vclock_gettime.o $(vdso32.so-y:%=vdso32/%.o)
137targets += vdso32/vclock_gettime.o vdso32/vdso-fakesections.o 142targets += vdso32/vclock_gettime.o
138 143
139$(obj)/vdso32.o: $(vdso32-images:%=$(obj)/%) 144$(obj)/vdso32.o: $(vdso32-images:%=$(obj)/%)
140 145
@@ -156,7 +161,6 @@ $(vdso32-images:%=$(obj)/%.dbg): KBUILD_CFLAGS = $(KBUILD_CFLAGS_32)
156$(vdso32-images:%=$(obj)/%.dbg): $(obj)/vdso32-%.so.dbg: FORCE \ 161$(vdso32-images:%=$(obj)/%.dbg): $(obj)/vdso32-%.so.dbg: FORCE \
157 $(obj)/vdso32/vdso32.lds \ 162 $(obj)/vdso32/vdso32.lds \
158 $(obj)/vdso32/vclock_gettime.o \ 163 $(obj)/vdso32/vclock_gettime.o \
159 $(obj)/vdso32/vdso-fakesections.o \
160 $(obj)/vdso32/note.o \ 164 $(obj)/vdso32/note.o \
161 $(obj)/vdso32/%.o 165 $(obj)/vdso32/%.o
162 $(call if_changed,vdso) 166 $(call if_changed,vdso)
diff --git a/arch/x86/vdso/vdso-fakesections.c b/arch/x86/vdso/vdso-fakesections.c
deleted file mode 100644
index aa5fbfab20a5..000000000000
--- a/arch/x86/vdso/vdso-fakesections.c
+++ /dev/null
@@ -1,21 +0,0 @@
1/*
2 * Copyright 2014 Andy Lutomirski
3 * Subject to the GNU Public License, v.2
4 *
5 * String table for loadable section headers. See vdso2c.h for why
6 * this exists.
7 */
8
9const char fake_shstrtab[] __attribute__((section(".fake_shstrtab"))) =
10 ".hash\0"
11 ".dynsym\0"
12 ".dynstr\0"
13 ".gnu.version\0"
14 ".gnu.version_d\0"
15 ".dynamic\0"
16 ".rodata\0"
17 ".fake_shstrtab\0" /* Yay, self-referential code. */
18 ".note\0"
19 ".eh_frame_hdr\0"
20 ".eh_frame\0"
21 ".text";
diff --git a/arch/x86/vdso/vdso-layout.lds.S b/arch/x86/vdso/vdso-layout.lds.S
index 9197544eea9a..de2c921025f5 100644
--- a/arch/x86/vdso/vdso-layout.lds.S
+++ b/arch/x86/vdso/vdso-layout.lds.S
@@ -18,6 +18,25 @@
18 18
19SECTIONS 19SECTIONS
20{ 20{
21 /*
22 * User/kernel shared data is before the vDSO. This may be a little
23 * uglier than putting it after the vDSO, but it avoids issues with
24 * non-allocatable things that dangle past the end of the PT_LOAD
25 * segment.
26 */
27
28 vvar_start = . - 2 * PAGE_SIZE;
29 vvar_page = vvar_start;
30
31 /* Place all vvars at the offsets in asm/vvar.h. */
32#define EMIT_VVAR(name, offset) vvar_ ## name = vvar_page + offset;
33#define __VVAR_KERNEL_LDS
34#include <asm/vvar.h>
35#undef __VVAR_KERNEL_LDS
36#undef EMIT_VVAR
37
38 hpet_page = vvar_start + PAGE_SIZE;
39
21 . = SIZEOF_HEADERS; 40 . = SIZEOF_HEADERS;
22 41
23 .hash : { *(.hash) } :text 42 .hash : { *(.hash) } :text
@@ -74,31 +93,6 @@ SECTIONS
74 .altinstructions : { *(.altinstructions) } :text 93 .altinstructions : { *(.altinstructions) } :text
75 .altinstr_replacement : { *(.altinstr_replacement) } :text 94 .altinstr_replacement : { *(.altinstr_replacement) } :text
76 95
77 /*
78 * The remainder of the vDSO consists of special pages that are
79 * shared between the kernel and userspace. It needs to be at the
80 * end so that it doesn't overlap the mapping of the actual
81 * vDSO image.
82 */
83
84 . = ALIGN(PAGE_SIZE);
85 vvar_page = .;
86
87 /* Place all vvars at the offsets in asm/vvar.h. */
88#define EMIT_VVAR(name, offset) vvar_ ## name = vvar_page + offset;
89#define __VVAR_KERNEL_LDS
90#include <asm/vvar.h>
91#undef __VVAR_KERNEL_LDS
92#undef EMIT_VVAR
93