[PATCH v3 1/6] x86: Clean up 32-bit vs 64-bit vdso params

2014-05-02 Thread Andy Lutomirski
Rather than using 'vdso_enabled' and an awful #define, just call the
parameters vdso32_enabled and vdso64_enabled.

Signed-off-by: Andy Lutomirski 
---
 arch/x86/include/asm/elf.h   | 20 +---
 arch/x86/um/vdso/vma.c   |  2 +-
 arch/x86/vdso/vdso32-setup.c | 19 ---
 arch/x86/vdso/vma.c  |  6 +++---
 kernel/sysctl.c  |  5 +
 5 files changed, 30 insertions(+), 22 deletions(-)

diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h
index 2c71182..e96df2c 100644
--- a/arch/x86/include/asm/elf.h
+++ b/arch/x86/include/asm/elf.h
@@ -75,7 +75,12 @@ typedef struct user_fxsr_struct elf_fpxregset_t;
 
 #include 
 
-extern unsigned int vdso_enabled;
+#ifdef CONFIG_X86_64
+extern unsigned int vdso64_enabled;
+#endif
+#if defined(CONFIG_X86_32) || defined(CONFIG_COMPAT)
+extern unsigned int vdso32_enabled;
+#endif
 
 /*
  * This is used to ensure we don't load something for the wrong architecture.
@@ -269,9 +274,9 @@ extern int force_personality32;
 
 struct task_struct;
 
-#defineARCH_DLINFO_IA32(vdso_enabled)  
\
+#defineARCH_DLINFO_IA32
\
 do {   \
-   if (vdso_enabled) { \
+   if (vdso32_enabled) {   \
NEW_AUX_ENT(AT_SYSINFO, VDSO_ENTRY);\
NEW_AUX_ENT(AT_SYSINFO_EHDR, VDSO_CURRENT_BASE);\
}   \
@@ -281,7 +286,7 @@ do {
\
 
 #define STACK_RND_MASK (0x7ff)
 
-#define ARCH_DLINFOARCH_DLINFO_IA32(vdso_enabled)
+#define ARCH_DLINFOARCH_DLINFO_IA32
 
 /* update AT_VECTOR_SIZE_ARCH if the number of NEW_AUX_ENT entries changes */
 
@@ -292,14 +297,15 @@ do {  
\
 
 #define ARCH_DLINFO\
 do {   \
-   if (vdso_enabled)   \
+   if (vdso64_enabled) \
NEW_AUX_ENT(AT_SYSINFO_EHDR,\
(unsigned long)current->mm->context.vdso);  \
 } while (0)
 
+/* As a historical oddity, the x32 and x86_64 vDSOs are controlled together. */
 #define ARCH_DLINFO_X32
\
 do {   \
-   if (vdso_enabled)   \
+   if (vdso64_enabled) \
NEW_AUX_ENT(AT_SYSINFO_EHDR,\
(unsigned long)current->mm->context.vdso);  \
 } while (0)
@@ -310,7 +316,7 @@ do {
\
 if (test_thread_flag(TIF_X32)) \
ARCH_DLINFO_X32;\
 else   \
-   ARCH_DLINFO_IA32(sysctl_vsyscall32)
+   ARCH_DLINFO_IA32
 
 #define COMPAT_ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x100)
 
diff --git a/arch/x86/um/vdso/vma.c b/arch/x86/um/vdso/vma.c
index af91901..916cda4 100644
--- a/arch/x86/um/vdso/vma.c
+++ b/arch/x86/um/vdso/vma.c
@@ -12,7 +12,7 @@
 #include 
 #include 
 
-unsigned int __read_mostly vdso_enabled = 1;
+static unsigned int __read_mostly vdso_enabled = 1;
 unsigned long um_vdso_addr;
 
 extern unsigned long task_size;
diff --git a/arch/x86/vdso/vdso32-setup.c b/arch/x86/vdso/vdso32-setup.c
index 0034898..5a657d9 100644
--- a/arch/x86/vdso/vdso32-setup.c
+++ b/arch/x86/vdso/vdso32-setup.c
@@ -37,7 +37,6 @@
 #endif
 
 #ifdef CONFIG_X86_64
-#define vdso_enabled   sysctl_vsyscall32
 #define arch_setup_additional_pagessyscall32_setup_pages
 #endif
 
@@ -45,13 +44,13 @@
  * Should the kernel map a VDSO page into processes and pass its
  * address down to glibc upon exec()?
  */
-unsigned int __read_mostly vdso_enabled = VDSO_DEFAULT;
+unsigned int __read_mostly vdso32_enabled = VDSO_DEFAULT;
 
-static int __init vdso_setup(char *s)
+static int __init vdso32_setup(char *s)
 {
-   vdso_enabled = simple_strtoul(s, NULL, 0);
+   vdso32_enabled = simple_strtoul(s, NULL, 0);
 
-   if (vdso_enabled > 1)
+   if (vdso32_enabled > 1)
pr_warn("vdso32 values other than 0 and 1 are no longer 
allowed; vdso disabled\n");
 
return 1;
@@ -62,12 +61,10 @@ static int __init vdso_setup(char *s)
  * behavior on both 64-bit and 32-bit kernels.
  * On 

[PATCH v3 1/6] x86: Clean up 32-bit vs 64-bit vdso params

2014-05-02 Thread Andy Lutomirski
Rather than using 'vdso_enabled' and an awful #define, just call the
parameters vdso32_enabled and vdso64_enabled.

Signed-off-by: Andy Lutomirski l...@amacapital.net
---
 arch/x86/include/asm/elf.h   | 20 +---
 arch/x86/um/vdso/vma.c   |  2 +-
 arch/x86/vdso/vdso32-setup.c | 19 ---
 arch/x86/vdso/vma.c  |  6 +++---
 kernel/sysctl.c  |  5 +
 5 files changed, 30 insertions(+), 22 deletions(-)

diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h
index 2c71182..e96df2c 100644
--- a/arch/x86/include/asm/elf.h
+++ b/arch/x86/include/asm/elf.h
@@ -75,7 +75,12 @@ typedef struct user_fxsr_struct elf_fpxregset_t;
 
 #include asm/vdso.h
 
-extern unsigned int vdso_enabled;
+#ifdef CONFIG_X86_64
+extern unsigned int vdso64_enabled;
+#endif
+#if defined(CONFIG_X86_32) || defined(CONFIG_COMPAT)
+extern unsigned int vdso32_enabled;
+#endif
 
 /*
  * This is used to ensure we don't load something for the wrong architecture.
@@ -269,9 +274,9 @@ extern int force_personality32;
 
 struct task_struct;
 
-#defineARCH_DLINFO_IA32(vdso_enabled)  
\
+#defineARCH_DLINFO_IA32
\
 do {   \
-   if (vdso_enabled) { \
+   if (vdso32_enabled) {   \
NEW_AUX_ENT(AT_SYSINFO, VDSO_ENTRY);\
NEW_AUX_ENT(AT_SYSINFO_EHDR, VDSO_CURRENT_BASE);\
}   \
@@ -281,7 +286,7 @@ do {
\
 
 #define STACK_RND_MASK (0x7ff)
 
-#define ARCH_DLINFOARCH_DLINFO_IA32(vdso_enabled)
+#define ARCH_DLINFOARCH_DLINFO_IA32
 
 /* update AT_VECTOR_SIZE_ARCH if the number of NEW_AUX_ENT entries changes */
 
@@ -292,14 +297,15 @@ do {  
\
 
 #define ARCH_DLINFO\
 do {   \
-   if (vdso_enabled)   \
+   if (vdso64_enabled) \
NEW_AUX_ENT(AT_SYSINFO_EHDR,\
(unsigned long)current-mm-context.vdso);  \
 } while (0)
 
+/* As a historical oddity, the x32 and x86_64 vDSOs are controlled together. */
 #define ARCH_DLINFO_X32
\
 do {   \
-   if (vdso_enabled)   \
+   if (vdso64_enabled) \
NEW_AUX_ENT(AT_SYSINFO_EHDR,\
(unsigned long)current-mm-context.vdso);  \
 } while (0)
@@ -310,7 +316,7 @@ do {
\
 if (test_thread_flag(TIF_X32)) \
ARCH_DLINFO_X32;\
 else   \
-   ARCH_DLINFO_IA32(sysctl_vsyscall32)
+   ARCH_DLINFO_IA32
 
 #define COMPAT_ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x100)
 
diff --git a/arch/x86/um/vdso/vma.c b/arch/x86/um/vdso/vma.c
index af91901..916cda4 100644
--- a/arch/x86/um/vdso/vma.c
+++ b/arch/x86/um/vdso/vma.c
@@ -12,7 +12,7 @@
 #include asm/page.h
 #include linux/init.h
 
-unsigned int __read_mostly vdso_enabled = 1;
+static unsigned int __read_mostly vdso_enabled = 1;
 unsigned long um_vdso_addr;
 
 extern unsigned long task_size;
diff --git a/arch/x86/vdso/vdso32-setup.c b/arch/x86/vdso/vdso32-setup.c
index 0034898..5a657d9 100644
--- a/arch/x86/vdso/vdso32-setup.c
+++ b/arch/x86/vdso/vdso32-setup.c
@@ -37,7 +37,6 @@
 #endif
 
 #ifdef CONFIG_X86_64
-#define vdso_enabled   sysctl_vsyscall32
 #define arch_setup_additional_pagessyscall32_setup_pages
 #endif
 
@@ -45,13 +44,13 @@
  * Should the kernel map a VDSO page into processes and pass its
  * address down to glibc upon exec()?
  */
-unsigned int __read_mostly vdso_enabled = VDSO_DEFAULT;
+unsigned int __read_mostly vdso32_enabled = VDSO_DEFAULT;
 
-static int __init vdso_setup(char *s)
+static int __init vdso32_setup(char *s)
 {
-   vdso_enabled = simple_strtoul(s, NULL, 0);
+   vdso32_enabled = simple_strtoul(s, NULL, 0);
 
-   if (vdso_enabled  1)
+   if (vdso32_enabled  1)
pr_warn(vdso32 values other than 0 and 1 are no longer 
allowed; vdso disabled\n);
 
return 1;
@@ -62,12 +61,10 @@ static int __init vdso_setup(char *s)
  * behavior on