[PATCH 1/7] x86/vdso32: Separate sigreturn code

From: Brian Gerst
Date: Sat Aug 29 2015 - 11:22:57 EST


Compile a separate sigreturn.o instead of including it in the three
syscall entry stub files. Use alternatives to patch in a syscall
instruction when supported.

Signed-off-by: Brian Gerst <brgerst@xxxxxxxxx>
---
arch/x86/entry/vdso/Makefile | 3 ++-
arch/x86/entry/vdso/vdso32/int80.S | 5 +----
arch/x86/entry/vdso/vdso32/sigreturn.S | 9 +++++++--
arch/x86/entry/vdso/vdso32/syscall.S | 7 +------
arch/x86/entry/vdso/vdso32/sysenter.S | 5 +----
5 files changed, 12 insertions(+), 17 deletions(-)

diff --git a/arch/x86/entry/vdso/Makefile b/arch/x86/entry/vdso/Makefile
index a3d0767..b4cd431 100644
--- a/arch/x86/entry/vdso/Makefile
+++ b/arch/x86/entry/vdso/Makefile
@@ -140,7 +140,7 @@ override obj-dirs = $(dir $(obj)) $(obj)/vdso32/

targets += vdso32/vdso32.lds
targets += vdso32/note.o vdso32/vclock_gettime.o $(vdso32.so-y:%=vdso32/%.o)
-targets += vdso32/vclock_gettime.o
+targets += vdso32/vclock_gettime.o vdso32/sigreturn.o

$(obj)/vdso32.o: $(vdso32-images:%=$(obj)/%)

@@ -163,6 +163,7 @@ $(vdso32-images:%=$(obj)/%.dbg): $(obj)/vdso32-%.so.dbg: FORCE \
$(obj)/vdso32/vdso32.lds \
$(obj)/vdso32/vclock_gettime.o \
$(obj)/vdso32/note.o \
+ $(obj)/vdso32/sigreturn.o \
$(obj)/vdso32/%.o
$(call if_changed,vdso)

diff --git a/arch/x86/entry/vdso/vdso32/int80.S b/arch/x86/entry/vdso/vdso32/int80.S
index b15b7c0..e40af1c 100644
--- a/arch/x86/entry/vdso/vdso32/int80.S
+++ b/arch/x86/entry/vdso/vdso32/int80.S
@@ -1,10 +1,7 @@
/*
* Code for the vDSO. This version uses the old int $0x80 method.
- *
- * First get the common code for the sigreturn entry points.
- * This must come first.
*/
-#include "sigreturn.S"
+#include <linux/linkage.h>

.text
.globl __kernel_vsyscall
diff --git a/arch/x86/entry/vdso/vdso32/sigreturn.S b/arch/x86/entry/vdso/vdso32/sigreturn.S
index d7ec4e2..ca0e6ca 100644
--- a/arch/x86/entry/vdso/vdso32/sigreturn.S
+++ b/arch/x86/entry/vdso/vdso32/sigreturn.S
@@ -9,9 +9,14 @@
#include <linux/linkage.h>
#include <asm/unistd_32.h>
#include <asm/asm-offsets.h>
+#include <asm/alternative-asm.h>
+#include <asm/cpufeature.h>

-#ifndef SYSCALL_ENTER_KERNEL
-#define SYSCALL_ENTER_KERNEL int $0x80
+#ifdef CONFIG_COMPAT
+#define SYSCALL_ENTER_KERNEL \
+ ALTERNATIVE "int $0x80", "syscall", X86_FEATURE_SYSCALL32
+#else
+#define SYSCALL_ENTER_KERNEL int $0x80
#endif

.text
diff --git a/arch/x86/entry/vdso/vdso32/syscall.S b/arch/x86/entry/vdso/vdso32/syscall.S
index 6b286bb..75545ec 100644
--- a/arch/x86/entry/vdso/vdso32/syscall.S
+++ b/arch/x86/entry/vdso/vdso32/syscall.S
@@ -1,12 +1,7 @@
/*
* Code for the vDSO. This version uses the syscall instruction.
- *
- * First get the common code for the sigreturn entry points.
- * This must come first.
*/
-#define SYSCALL_ENTER_KERNEL syscall
-#include "sigreturn.S"
-
+#include <linux/linkage.h>
#include <asm/segment.h>

.text
diff --git a/arch/x86/entry/vdso/vdso32/sysenter.S b/arch/x86/entry/vdso/vdso32/sysenter.S
index e354bce..e99c7699 100644
--- a/arch/x86/entry/vdso/vdso32/sysenter.S
+++ b/arch/x86/entry/vdso/vdso32/sysenter.S
@@ -1,10 +1,7 @@
/*
* Code for the vDSO. This version uses the sysenter instruction.
- *
- * First get the common code for the sigreturn entry points.
- * This must come first.
*/
-#include "sigreturn.S"
+#include <linux/linkage.h>

/*
* The caller puts arg2 in %ecx, which gets pushed. The kernel will use
--
2.4.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/