aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86
diff options
context:
space:
mode:
authorRoland McGrath <roland@redhat.com>2008-01-30 07:30:42 -0500
committerIngo Molnar <mingo@elte.hu>2008-01-30 07:30:42 -0500
commit6c3652efcafa6a6d795093362cb4290c84994b5c (patch)
tree1587379f45a7145a64c3103b40e12b01c46ea559 /arch/x86
parent0249c9c1e7505c2b020bcc6deaf1e0415de9943e (diff)
x86 vDSO: i386 vdso32
This makes the i386 kernel use the new vDSO build in arch/x86/vdso/vdso32/ to replace the old one from arch/x86/kernel/. Signed-off-by: Roland McGrath <roland@redhat.com> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'arch/x86')
-rw-r--r--arch/x86/Makefile_323
-rw-r--r--arch/x86/kernel/Makefile_3243
-rw-r--r--arch/x86/kernel/asm-offsets_32.c2
-rw-r--r--arch/x86/kernel/signal_32.c5
-rw-r--r--arch/x86/kernel/sysenter_32.c6
-rw-r--r--arch/x86/kernel/vsyscall_32.lds.S67
-rw-r--r--arch/x86/vdso/Makefile8
-rw-r--r--arch/x86/vdso/vdso32.S (renamed from arch/x86/kernel/vsyscall_32.S)4
-rw-r--r--arch/x86/vdso/vdso32/note.S3
-rw-r--r--arch/x86/vdso/vdso32/sysenter.S3
-rw-r--r--arch/x86/xen/setup.c5
11 files changed, 20 insertions, 129 deletions
diff --git a/arch/x86/Makefile_32 b/arch/x86/Makefile_32
index b152db71d5b5..9214224773ed 100644
--- a/arch/x86/Makefile_32
+++ b/arch/x86/Makefile_32
@@ -110,7 +110,8 @@ libs-y += arch/x86/lib/
110core-y += arch/x86/kernel/ \ 110core-y += arch/x86/kernel/ \
111 arch/x86/mm/ \ 111 arch/x86/mm/ \
112 $(mcore-y)/ \ 112 $(mcore-y)/ \
113 arch/x86/crypto/ 113 arch/x86/crypto/ \
114 arch/x86/vdso/
114drivers-$(CONFIG_MATH_EMULATION) += arch/x86/math-emu/ 115drivers-$(CONFIG_MATH_EMULATION) += arch/x86/math-emu/
115drivers-$(CONFIG_PCI) += arch/x86/pci/ 116drivers-$(CONFIG_PCI) += arch/x86/pci/
116# must be linked after kernel/ 117# must be linked after kernel/
diff --git a/arch/x86/kernel/Makefile_32 b/arch/x86/kernel/Makefile_32
index f7c1c1c88dda..0eef8226753b 100644
--- a/arch/x86/kernel/Makefile_32
+++ b/arch/x86/kernel/Makefile_32
@@ -33,7 +33,7 @@ obj-$(CONFIG_X86_NUMAQ) += numaq_32.o
33obj-$(CONFIG_X86_SUMMIT_NUMA) += summit_32.o 33obj-$(CONFIG_X86_SUMMIT_NUMA) += summit_32.o
34obj-$(CONFIG_KPROBES) += kprobes_32.o 34obj-$(CONFIG_KPROBES) += kprobes_32.o
35obj-$(CONFIG_MODULES) += module_32.o 35obj-$(CONFIG_MODULES) += module_32.o
36obj-y += sysenter_32.o vsyscall_32.o 36obj-y += sysenter_32.o
37obj-$(CONFIG_ACPI_SRAT) += srat_32.o 37obj-$(CONFIG_ACPI_SRAT) += srat_32.o
38obj-$(CONFIG_EFI) += efi_32.o efi_stub_32.o 38obj-$(CONFIG_EFI) += efi_32.o efi_stub_32.o
39obj-$(CONFIG_DOUBLEFAULT) += doublefault_32.o 39obj-$(CONFIG_DOUBLEFAULT) += doublefault_32.o
@@ -48,44 +48,3 @@ obj-$(CONFIG_PARAVIRT) += paravirt_32.o
48obj-y += pcspeaker.o 48obj-y += pcspeaker.o
49 49
50obj-$(CONFIG_SCx200) += scx200_32.o 50obj-$(CONFIG_SCx200) += scx200_32.o
51
52# vsyscall_32.o contains the vsyscall DSO images as __initdata.
53# We must build both images before we can assemble it.
54# Note: kbuild does not track this dependency due to usage of .incbin
55$(obj)/vsyscall_32.o: $(obj)/vsyscall-int80_32.so $(obj)/vsyscall-sysenter_32.so
56targets += $(foreach F,int80 sysenter,vsyscall-$F_32.o vsyscall-$F_32.so)
57targets += vsyscall-note_32.o vsyscall_32.lds
58
59$(obj)/vsyscall-%_32.o: $(src)/../vdso/vdso32/%.S
60 $(call if_changed_dep,as_o_S)
61
62# The DSO images are built using a special linker script.
63quiet_cmd_syscall = SYSCALL $@
64 cmd_syscall = $(CC) -m elf_i386 -nostdlib $(SYSCFLAGS_$(@F)) \
65 -Wl,-T,$(filter-out FORCE,$^) -o $@
66
67export CPPFLAGS_vsyscall_32.lds += -P -C -Ui386
68
69vsyscall-flags = -shared -s -Wl,-soname=linux-gate.so.1 \
70 $(call ld-option, -Wl$(comma)--hash-style=sysv)
71SYSCFLAGS_vsyscall-sysenter_32.so = $(vsyscall-flags)
72SYSCFLAGS_vsyscall-int80_32.so = $(vsyscall-flags)
73
74$(obj)/vsyscall-int80_32.so $(obj)/vsyscall-sysenter_32.so: \
75$(obj)/vsyscall-%.so: $(src)/vsyscall_32.lds \
76 $(obj)/vsyscall-%.o $(obj)/vsyscall-note_32.o FORCE
77 $(call if_changed,syscall)
78
79# We also create a special relocatable object that should mirror the symbol
80# table and layout of the linked DSO. With ld -R we can then refer to
81# these symbols in the kernel code rather than hand-coded addresses.
82extra-y += vsyscall-syms.o
83$(obj)/built-in.o: $(obj)/vsyscall-syms.o
84$(obj)/built-in.o: ld_flags += -R $(obj)/vsyscall-syms.o
85
86SYSCFLAGS_vsyscall-syms.o = -r
87$(obj)/vsyscall-syms.o: $(src)/vsyscall_32.lds \
88 $(obj)/vsyscall-sysenter_32.o $(obj)/vsyscall-note_32.o FORCE
89 $(call if_changed,syscall)
90
91
diff --git a/arch/x86/kernel/asm-offsets_32.c b/arch/x86/kernel/asm-offsets_32.c
index 4f750ec810f6..fd7464d23339 100644
--- a/arch/x86/kernel/asm-offsets_32.c
+++ b/arch/x86/kernel/asm-offsets_32.c
@@ -111,8 +111,6 @@ void foo(void)
111 DEFINE(PTRS_PER_PMD, PTRS_PER_PMD); 111 DEFINE(PTRS_PER_PMD, PTRS_PER_PMD);
112 DEFINE(PTRS_PER_PGD, PTRS_PER_PGD); 112 DEFINE(PTRS_PER_PGD, PTRS_PER_PGD);
113 113
114 DEFINE(VDSO_PRELINK_asm, VDSO_PRELINK);
115
116 OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx); 114 OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx);
117 115
118#ifdef CONFIG_PARAVIRT 116#ifdef CONFIG_PARAVIRT
diff --git a/arch/x86/kernel/signal_32.c b/arch/x86/kernel/signal_32.c
index 5c6170c44b00..1ac53e9a0859 100644
--- a/arch/x86/kernel/signal_32.c
+++ b/arch/x86/kernel/signal_32.c
@@ -23,6 +23,7 @@
23#include <asm/ucontext.h> 23#include <asm/ucontext.h>
24#include <asm/uaccess.h> 24#include <asm/uaccess.h>
25#include <asm/i387.h> 25#include <asm/i387.h>
26#include <asm/vdso.h>
26#include "sigframe_32.h" 27#include "sigframe_32.h"
27 28
28#define DEBUG_SIG 0 29#define DEBUG_SIG 0
@@ -362,7 +363,7 @@ static int setup_frame(int sig, struct k_sigaction *ka,
362 } 363 }
363 364
364 if (current->binfmt->hasvdso) 365 if (current->binfmt->hasvdso)
365 restorer = (void *)VDSO_SYM(&__kernel_sigreturn); 366 restorer = VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
366 else 367 else
367 restorer = (void *)&frame->retcode; 368 restorer = (void *)&frame->retcode;
368 if (ka->sa.sa_flags & SA_RESTORER) 369 if (ka->sa.sa_flags & SA_RESTORER)
@@ -459,7 +460,7 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
459 goto give_sigsegv; 460 goto give_sigsegv;
460 461
461 /* Set up to return from userspace. */ 462 /* Set up to return from userspace. */
462 restorer = (void *)VDSO_SYM(&__kernel_rt_sigreturn); 463 restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
463 if (ka->sa.sa_flags & SA_RESTORER) 464 if (ka->sa.sa_flags & SA_RESTORER)
464 restorer = ka->sa.sa_restorer; 465 restorer = ka->sa.sa_restorer;
465 err |= __put_user(restorer, &frame->pretcode); 466 err |= __put_user(restorer, &frame->pretcode);
diff --git a/arch/x86/kernel/sysenter_32.c b/arch/x86/kernel/sysenter_32.c
index 5a2d951e2608..85c52d23ee40 100644
--- a/arch/x86/kernel/sysenter_32.c
+++ b/arch/x86/kernel/sysenter_32.c
@@ -23,6 +23,7 @@
23#include <asm/unistd.h> 23#include <asm/unistd.h>
24#include <asm/elf.h> 24#include <asm/elf.h>
25#include <asm/tlbflush.h> 25#include <asm/tlbflush.h>
26#include <asm/vdso.h>
26 27
27enum { 28enum {
28 VDSO_DISABLED = 0, 29 VDSO_DISABLED = 0,
@@ -259,9 +260,6 @@ int __init sysenter_setup(void)
259 return 0; 260 return 0;
260} 261}
261 262
262/* Defined in vsyscall-sysenter.S */
263extern void SYSENTER_RETURN;
264
265/* Setup a VMA at program startup for the vsyscall page */ 263/* Setup a VMA at program startup for the vsyscall page */
266int arch_setup_additional_pages(struct linux_binprm *bprm, int exstack) 264int arch_setup_additional_pages(struct linux_binprm *bprm, int exstack)
267{ 265{
@@ -308,7 +306,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int exstack)
308 306
309 current->mm->context.vdso = (void *)addr; 307 current->mm->context.vdso = (void *)addr;
310 current_thread_info()->sysenter_return = 308 current_thread_info()->sysenter_return =
311 (void *)VDSO_SYM(&SYSENTER_RETURN); 309 VDSO32_SYMBOL(addr, SYSENTER_RETURN);
312 310
313 up_fail: 311 up_fail:
314 up_write(&mm->mmap_sem); 312 up_write(&mm->mmap_sem);
diff --git a/arch/x86/kernel/vsyscall_32.lds.S b/arch/x86/kernel/vsyscall_32.lds.S
deleted file mode 100644
index 4a8b0ed9b8fb..000000000000
--- a/arch/x86/kernel/vsyscall_32.lds.S
+++ /dev/null
@@ -1,67 +0,0 @@
1/*
2 * Linker script for vsyscall DSO. The vsyscall page is an ELF shared
3 * object prelinked to its virtual address, and with only one read-only
4 * segment (that fits in one page). This script controls its layout.
5 */
6#include <asm/asm-offsets.h>
7
8SECTIONS
9{
10 . = VDSO_PRELINK_asm + SIZEOF_HEADERS;
11
12 .hash : { *(.hash) } :text
13 .gnu.hash : { *(.gnu.hash) }
14 .dynsym : { *(.dynsym) }
15 .dynstr : { *(.dynstr) }
16 .gnu.version : { *(.gnu.version) }
17 .gnu.version_d : { *(.gnu.version_d) }
18 .gnu.version_r : { *(.gnu.version_r) }
19
20 /* This linker script is used both with -r and with -shared.
21 For the layouts to match, we need to skip more than enough
22 space for the dynamic symbol table et al. If this amount
23 is insufficient, ld -shared will barf. Just increase it here. */
24 . = VDSO_PRELINK_asm + 0x400;
25
26 .text : { *(.text) } :text =0x90909090
27 .note : { *(.note.*) } :text :note
28 .eh_frame_hdr : { *(.eh_frame_hdr) } :text :eh_frame_hdr
29 .eh_frame : { KEEP (*(.eh_frame)) } :text
30 .dynamic : { *(.dynamic) } :text :dynamic
31 .useless : {
32 *(.got.plt) *(.got)
33 *(.data .data.* .gnu.linkonce.d.*)
34 *(.dynbss)
35 *(.bss .bss.* .gnu.linkonce.b.*)
36 } :text
37}
38
39/*
40 * We must supply the ELF program headers explicitly to get just one
41 * PT_LOAD segment, and set the flags explicitly to make segments read-only.
42 */
43PHDRS
44{
45 text PT_LOAD FILEHDR PHDRS FLAGS(5); /* PF_R|PF_X */
46 dynamic PT_DYNAMIC FLAGS(4); /* PF_R */
47 note PT_NOTE FLAGS(4); /* PF_R */
48 eh_frame_hdr 0x6474e550; /* PT_GNU_EH_FRAME, but ld doesn't match the name */
49}
50
51/*
52 * This controls what symbols we export from the DSO.
53 */
54VERSION
55{
56 LINUX_2.5 {
57 global:
58 __kernel_vsyscall;
59 __kernel_sigreturn;
60 __kernel_rt_sigreturn;
61
62 local: *;
63 };
64}
65
66/* The ELF entry point can be used to set the AT_SYSINFO value. */
67ENTRY(__kernel_vsyscall);
diff --git a/arch/x86/vdso/Makefile b/arch/x86/vdso/Makefile
index a02e1ca2a1bc..ca2aabf8ed39 100644
--- a/arch/x86/vdso/Makefile
+++ b/arch/x86/vdso/Makefile
@@ -14,7 +14,8 @@ vdso-install-$(VDSO32-y) += $(vdso32-y:=.so)
14vobjs-y := vdso-note.o vclock_gettime.o vgetcpu.o vvar.o 14vobjs-y := vdso-note.o vclock_gettime.o vgetcpu.o vvar.o
15 15
16# files to link into kernel 16# files to link into kernel
17obj-y := vma.o vdso.o 17obj-$(VDSO64-y) += vma.o vdso.o
18obj-$(CONFIG_X86_32) += vdso32.o
18 19
19vobjs := $(foreach F,$(vobjs-y),$(obj)/$F) 20vobjs := $(foreach F,$(vobjs-y),$(obj)/$F)
20 21
@@ -52,7 +53,7 @@ $(obj)/vclock_gettime.o: KBUILD_CFLAGS = $(CFL)
52$(obj)/vgetcpu.o: KBUILD_CFLAGS = $(CFL) 53$(obj)/vgetcpu.o: KBUILD_CFLAGS = $(CFL)
53 54
54targets += vdso-syms.lds 55targets += vdso-syms.lds
55obj-y += vdso-syms.lds 56obj-$(VDSO64-y) += vdso-syms.lds
56 57
57# 58#
58# Match symbols in the DSO that look like VDSO*; produce a file of constants. 59# Match symbols in the DSO that look like VDSO*; produce a file of constants.
@@ -68,6 +69,7 @@ $(obj)/%-syms.lds: $(obj)/%.so.dbg FORCE
68# 69#
69# Build multiple 32-bit vDSO images to choose from at boot time. 70# Build multiple 32-bit vDSO images to choose from at boot time.
70# 71#
72obj-$(VDSO32-y) += vdso32-syms.lds
71vdso32.so-$(CONFIG_X86_32) += int80 73vdso32.so-$(CONFIG_X86_32) += int80
72vdso32.so-$(VDSO32-y) += sysenter 74vdso32.so-$(VDSO32-y) += sysenter
73 75
@@ -84,6 +86,8 @@ targets += vdso32/note.o $(vdso32.so-y:%=vdso32/%.o)
84 86
85extra-y += $(vdso32.so-y:%=vdso32-%.so) 87extra-y += $(vdso32.so-y:%=vdso32-%.so)
86 88
89$(obj)/vdso32.o: $(vdso32.so-y:%=$(obj)/vdso32-%.so)
90
87KBUILD_AFLAGS_32 := $(filter-out -m64,$(KBUILD_AFLAGS)) 91KBUILD_AFLAGS_32 := $(filter-out -m64,$(KBUILD_AFLAGS))
88$(vdso32.so-y:%=$(obj)/vdso32-%.so.dbg): KBUILD_AFLAGS = $(KBUILD_AFLAGS_32) 92$(vdso32.so-y:%=$(obj)/vdso32-%.so.dbg): KBUILD_AFLAGS = $(KBUILD_AFLAGS_32)
89$(vdso32.so-y:%=$(obj)/vdso32-%.so.dbg): asflags-$(CONFIG_X86_64) += -m32 93$(vdso32.so-y:%=$(obj)/vdso32-%.so.dbg): asflags-$(CONFIG_X86_64) += -m32
diff --git a/arch/x86/kernel/vsyscall_32.S b/arch/x86/vdso/vdso32.S
index a5ab3dc4fd25..cab020c99c3d 100644
--- a/arch/x86/kernel/vsyscall_32.S
+++ b/arch/x86/vdso/vdso32.S
@@ -4,12 +4,12 @@ __INITDATA
4 4
5 .globl vsyscall_int80_start, vsyscall_int80_end 5 .globl vsyscall_int80_start, vsyscall_int80_end
6vsyscall_int80_start: 6vsyscall_int80_start:
7 .incbin "arch/x86/kernel/vsyscall-int80_32.so" 7 .incbin "arch/x86/vdso/vdso32-int80.so"
8vsyscall_int80_end: 8vsyscall_int80_end:
9 9
10 .globl vsyscall_sysenter_start, vsyscall_sysenter_end 10 .globl vsyscall_sysenter_start, vsyscall_sysenter_end
11vsyscall_sysenter_start: 11vsyscall_sysenter_start:
12 .incbin "arch/x86/kernel/vsyscall-sysenter_32.so" 12 .incbin "arch/x86/vdso/vdso32-sysenter.so"
13vsyscall_sysenter_end: 13vsyscall_sysenter_end:
14 14
15__FINIT 15__FINIT
diff --git a/arch/x86/vdso/vdso32/note.S b/arch/x86/vdso/vdso32/note.S
index 0cf934f2633e..c83f25734696 100644
--- a/arch/x86/vdso/vdso32/note.S
+++ b/arch/x86/vdso/vdso32/note.S
@@ -35,10 +35,9 @@ ELFNOTE_END
35 35
36#include "../../xen/vdso.h" /* Defines VDSO_NOTE_NONEGSEG_BIT. */ 36#include "../../xen/vdso.h" /* Defines VDSO_NOTE_NONEGSEG_BIT. */
37 37
38 .globl VDSO_NOTE_MASK
39ELFNOTE_START(GNU, 2, "a") 38ELFNOTE_START(GNU, 2, "a")
40 .long 1 /* ncaps */ 39 .long 1 /* ncaps */
41VDSO_NOTE_MASK: 40VDSO32_NOTE_MASK: /* Symbol used by arch/x86/xen/setup.c */
42 .long 0 /* mask */ 41 .long 0 /* mask */
43 .byte VDSO_NOTE_NONEGSEG_BIT; .asciz "nosegneg" /* bit, name */ 42 .byte VDSO_NOTE_NONEGSEG_BIT; .asciz "nosegneg" /* bit, name */
44ELFNOTE_END 43ELFNOTE_END
diff --git a/arch/x86/vdso/vdso32/sysenter.S b/arch/x86/vdso/vdso32/sysenter.S
index 4b98fc41d3e0..109bfa394eaa 100644
--- a/arch/x86/vdso/vdso32/sysenter.S
+++ b/arch/x86/vdso/vdso32/sysenter.S
@@ -45,8 +45,7 @@ __kernel_vsyscall:
45 /* 14: System call restart point is here! (SYSENTER_RETURN-2) */ 45 /* 14: System call restart point is here! (SYSENTER_RETURN-2) */
46 jmp .Lenter_kernel 46 jmp .Lenter_kernel
47 /* 16: System call normal return point is here! */ 47 /* 16: System call normal return point is here! */
48 .globl SYSENTER_RETURN /* Symbol used by sysenter.c */ 48VDSO32_SYSENTER_RETURN: /* Symbol used by sysenter.c via vdso32-syms.h */
49SYSENTER_RETURN:
50 pop %ebp 49 pop %ebp
51.Lpop_ebp: 50.Lpop_ebp:
52 pop %edx 51 pop %edx
diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c
index f84e77226646..fd91568090f4 100644
--- a/arch/x86/xen/setup.c
+++ b/arch/x86/xen/setup.c
@@ -10,6 +10,7 @@
10#include <linux/pm.h> 10#include <linux/pm.h>
11 11
12#include <asm/elf.h> 12#include <asm/elf.h>
13#include <asm/vdso.h>
13#include <asm/e820.h> 14#include <asm/e820.h>
14#include <asm/setup.h> 15#include <asm/setup.h>
15#include <asm/xen/hypervisor.h> 16#include <asm/xen/hypervisor.h>
@@ -61,10 +62,8 @@ static void xen_idle(void)
61 */ 62 */
62static void fiddle_vdso(void) 63static void fiddle_vdso(void)
63{ 64{
64 extern u32 VDSO_NOTE_MASK; /* See ../kernel/vsyscall-note.S. */
65 extern char vsyscall_int80_start; 65 extern char vsyscall_int80_start;
66 u32 *mask = (u32 *) ((unsigned long) &VDSO_NOTE_MASK - VDSO_PRELINK + 66 u32 *mask = VDSO32_SYMBOL(&vsyscall_int80_start, NOTE_MASK);
67 &vsyscall_int80_start);
68 *mask |= 1 << VDSO_NOTE_NONEGSEG_BIT; 67 *mask |= 1 << VDSO_NOTE_NONEGSEG_BIT;
69} 68}
70 69