x86, vdso: Clean up 32-bit vs 64-bit vdso params
authorAndy Lutomirski <luto@amacapital.net>
Mon, 5 May 2014 19:19:32 +0000 (12:19 -0700)
committerH. Peter Anvin <hpa@linux.intel.com>
Mon, 5 May 2014 20:18:40 +0000 (13:18 -0700)
Rather than using 'vdso_enabled' and an awful #define, just call the
parameters vdso32_enabled and vdso64_enabled.

Signed-off-by: Andy Lutomirski <luto@amacapital.net>
Link: http://lkml.kernel.org/r/87913de56bdcbae3d93917938302fc369b05caee.1399317206.git.luto@amacapital.net
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
arch/x86/include/asm/elf.h
arch/x86/um/vdso/vma.c
arch/x86/vdso/vdso32-setup.c
arch/x86/vdso/vma.c
kernel/sysctl.c

index 2c71182d30ef5bce4fc92e34059efd589e5f92ee..e96df2c0dd6910a343d2754821373d923d698105 100644 (file)
@@ -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;
 
-#define        ARCH_DLINFO_IA32(vdso_enabled)                                  \
+#define        ARCH_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_DLINFO            ARCH_DLINFO_IA32(vdso_enabled)
+#define ARCH_DLINFO            ARCH_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 + 0x1000000)
 
index af91901babb8455f9ed4a8e10b8f6f8f856d8bec..916cda4cd5b4c1b6f886bb5bed6daf387b141c6b 100644 (file)
@@ -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;
index 00348980a3a64a49180be23bda3517d314c6bf81..5a657d93c6e0c700115fa0c954867e1f6c11391e 100644 (file)
@@ -37,7 +37,6 @@
 #endif
 
 #ifdef CONFIG_X86_64
-#define vdso_enabled                   sysctl_vsyscall32
 #define arch_setup_additional_pages    syscall32_setup_pages
 #endif
 
  * 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 32-bit kernels, vdso=[012] means the same thing.
  */
-__setup("vdso32=", vdso_setup);
+__setup("vdso32=", vdso32_setup);
 
 #ifdef CONFIG_X86_32
-__setup_param("vdso=", vdso32_setup, vdso_setup, 0);
-
-EXPORT_SYMBOL_GPL(vdso_enabled);
+__setup_param("vdso=", vdso_setup, vdso32_setup, 0);
 #endif
 
 static struct page **vdso32_pages;
@@ -160,7 +157,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
                return x32_setup_additional_pages(bprm, uses_interp);
 #endif
 
-       if (vdso_enabled != 1)  /* Other values all mean "disabled" */
+       if (vdso32_enabled != 1)  /* Other values all mean "disabled" */
                return 0;
 
        down_write(&mm->mmap_sem);
@@ -244,7 +241,7 @@ subsys_initcall(sysenter_setup);
 static struct ctl_table abi_table2[] = {
        {
                .procname       = "vsyscall32",
-               .data           = &sysctl_vsyscall32,
+               .data           = &vdso32_enabled,
                .maxlen         = sizeof(int),
                .mode           = 0644,
                .proc_handler   = proc_dointvec
index 1ad102613127c4e23650acf5a510b668d411c7c2..8b790398ed1dbec8e503c7eb2d21c575262503cb 100644 (file)
@@ -17,7 +17,7 @@
 #include <asm/page.h>
 
 #if defined(CONFIG_X86_64)
-unsigned int __read_mostly vdso_enabled = 1;
+unsigned int __read_mostly vdso64_enabled = 1;
 
 DECLARE_VDSO_IMAGE(vdso);
 extern unsigned short vdso_sync_cpuid;
@@ -160,7 +160,7 @@ static int setup_additional_pages(struct linux_binprm *bprm,
        unsigned long addr;
        int ret;
 
-       if (!vdso_enabled)
+       if (!vdso64_enabled)
                return 0;
 
        down_write(&mm->mmap_sem);
@@ -203,7 +203,7 @@ int x32_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
 
 static __init int vdso_setup(char *s)
 {
-       vdso_enabled = simple_strtoul(s, NULL, 0);
+       vdso64_enabled = simple_strtoul(s, NULL, 0);
        return 0;
 }
 __setup("vdso=", vdso_setup);
index 74f5b580fe34904fa4d9bcb2790545a323367773..420d77afa8fd54c006bbc015e9f661b5cfbfab0b 100644 (file)
@@ -1418,8 +1418,13 @@ static struct ctl_table vm_table[] = {
    (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
        {
                .procname       = "vdso_enabled",
+#ifdef CONFIG_X86_32
+               .data           = &vdso32_enabled,
+               .maxlen         = sizeof(vdso32_enabled),
+#else
                .data           = &vdso_enabled,
                .maxlen         = sizeof(vdso_enabled),
+#endif
                .mode           = 0644,
                .proc_handler   = proc_dointvec,
                .extra1         = &zero,