]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
x86/vdso: Remove #ifdeffery around page setup variants
authorThomas Weißschuh <thomas.weissschuh@linutronix.de>
Tue, 10 Sep 2024 10:11:35 +0000 (12:11 +0200)
committerIngo Molnar <mingo@kernel.org>
Tue, 22 Apr 2025 12:24:07 +0000 (14:24 +0200)
Replace the open-coded ifdefs in C sources files with IS_ENABLED().
This makes the code easier to read and enables the compiler to typecheck
also the disabled parts, before optimizing them away.
To make this work, also remove the ifdefs from declarations of used
variables.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Eric Biederman <ebiederm@xmission.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Juergen Gross <jgross@suse.com>
Cc: Kees Cook <kees@kernel.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rik van Riel <riel@surriel.com>
Link: https://lore.kernel.org/r/20240910-x86-vdso-ifdef-v1-1-877c9df9b081@linutronix.de
arch/x86/entry/vdso/vma.c
arch/x86/include/asm/elf.h
arch/x86/include/asm/vdso.h

index adb299d3b6a16a2297b4963c03bf49c3dacd392a..495fdd4ec3f6a629574e8c730a532e509086e474 100644 (file)
@@ -227,7 +227,6 @@ int map_vdso_once(const struct vdso_image *image, unsigned long addr)
        return map_vdso(image, addr);
 }
 
-#if defined(CONFIG_X86_32) || defined(CONFIG_IA32_EMULATION)
 static int load_vdso32(void)
 {
        if (vdso32_enabled != 1)  /* Other values all mean "disabled" */
@@ -235,39 +234,33 @@ static int load_vdso32(void)
 
        return map_vdso(&vdso_image_32, 0);
 }
-#endif
 
-#ifdef CONFIG_X86_64
 int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
 {
-       if (!vdso64_enabled)
-               return 0;
+       if (IS_ENABLED(CONFIG_X86_64)) {
+               if (!vdso64_enabled)
+                       return 0;
+
+               return map_vdso(&vdso_image_64, 0);
+       }
 
-       return map_vdso(&vdso_image_64, 0);
+       return load_vdso32();
 }
 
 #ifdef CONFIG_COMPAT
 int compat_arch_setup_additional_pages(struct linux_binprm *bprm,
                                       int uses_interp, bool x32)
 {
-#ifdef CONFIG_X86_X32_ABI
-       if (x32) {
+       if (IS_ENABLED(CONFIG_X86_X32_ABI) && x32) {
                if (!vdso64_enabled)
                        return 0;
                return map_vdso(&vdso_image_x32, 0);
        }
-#endif
-#ifdef CONFIG_IA32_EMULATION
-       return load_vdso32();
-#else
+
+       if (IS_ENABLED(CONFIG_IA32_EMULATION))
+               return load_vdso32();
+
        return 0;
-#endif
-}
-#endif
-#else
-int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
-{
-       return load_vdso32();
 }
 #endif
 
index 128602612ecaa5a7f9a8869eb6990876e7491344..6c8fdc96be7e8bd33919d9b56ae8a8a68f4b0c3f 100644 (file)
@@ -76,12 +76,8 @@ typedef struct user_i387_struct elf_fpregset_t;
 
 #include <asm/vdso.h>
 
-#ifdef CONFIG_X86_64
 extern unsigned int vdso64_enabled;
-#endif
-#if defined(CONFIG_X86_32) || defined(CONFIG_IA32_EMULATION)
 extern unsigned int vdso32_enabled;
-#endif
 
 /*
  * This is used to ensure we don't load something for the wrong architecture.
index 80be0da733df43de7520bef69ad120ce05d37994..b7253ef3205a6d146f505f4edb36b452cc04518b 100644 (file)
@@ -27,17 +27,9 @@ struct vdso_image {
        long sym_vdso32_rt_sigreturn_landing_pad;
 };
 
-#ifdef CONFIG_X86_64
 extern const struct vdso_image vdso_image_64;
-#endif
-
-#ifdef CONFIG_X86_X32_ABI
 extern const struct vdso_image vdso_image_x32;
-#endif
-
-#if defined CONFIG_X86_32 || defined CONFIG_COMPAT
 extern const struct vdso_image vdso_image_32;
-#endif
 
 extern int __init init_vdso_image(const struct vdso_image *image);