Skip to content

Commit 2ce8043

Browse files
t-8chIngo Molnar
authored andcommitted
x86/vdso: Remove #ifdeffery around page setup variants
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 <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Cc: Andrew Cooper <[email protected]> Cc: Andy Lutomirski <[email protected]> Cc: Brian Gerst <[email protected]> Cc: Eric Biederman <[email protected]> Cc: H. Peter Anvin <[email protected]> Cc: Juergen Gross <[email protected]> Cc: Kees Cook <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Rik van Riel <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent a33b5a0 commit 2ce8043

File tree

3 files changed

+12
-31
lines changed

3 files changed

+12
-31
lines changed

arch/x86/entry/vdso/vma.c

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -227,47 +227,40 @@ int map_vdso_once(const struct vdso_image *image, unsigned long addr)
227227
return map_vdso(image, addr);
228228
}
229229

230-
#if defined(CONFIG_X86_32) || defined(CONFIG_IA32_EMULATION)
231230
static int load_vdso32(void)
232231
{
233232
if (vdso32_enabled != 1) /* Other values all mean "disabled" */
234233
return 0;
235234

236235
return map_vdso(&vdso_image_32, 0);
237236
}
238-
#endif
239237

240-
#ifdef CONFIG_X86_64
241238
int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
242239
{
243-
if (!vdso64_enabled)
244-
return 0;
240+
if (IS_ENABLED(CONFIG_X86_64)) {
241+
if (!vdso64_enabled)
242+
return 0;
243+
244+
return map_vdso(&vdso_image_64, 0);
245+
}
245246

246-
return map_vdso(&vdso_image_64, 0);
247+
return load_vdso32();
247248
}
248249

249250
#ifdef CONFIG_COMPAT
250251
int compat_arch_setup_additional_pages(struct linux_binprm *bprm,
251252
int uses_interp, bool x32)
252253
{
253-
#ifdef CONFIG_X86_X32_ABI
254-
if (x32) {
254+
if (IS_ENABLED(CONFIG_X86_X32_ABI) && x32) {
255255
if (!vdso64_enabled)
256256
return 0;
257257
return map_vdso(&vdso_image_x32, 0);
258258
}
259-
#endif
260-
#ifdef CONFIG_IA32_EMULATION
261-
return load_vdso32();
262-
#else
259+
260+
if (IS_ENABLED(CONFIG_IA32_EMULATION))
261+
return load_vdso32();
262+
263263
return 0;
264-
#endif
265-
}
266-
#endif
267-
#else
268-
int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
269-
{
270-
return load_vdso32();
271264
}
272265
#endif
273266

arch/x86/include/asm/elf.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,8 @@ typedef struct user_i387_struct elf_fpregset_t;
7676

7777
#include <asm/vdso.h>
7878

79-
#ifdef CONFIG_X86_64
8079
extern unsigned int vdso64_enabled;
81-
#endif
82-
#if defined(CONFIG_X86_32) || defined(CONFIG_IA32_EMULATION)
8380
extern unsigned int vdso32_enabled;
84-
#endif
8581

8682
/*
8783
* This is used to ensure we don't load something for the wrong architecture.

arch/x86/include/asm/vdso.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,9 @@ struct vdso_image {
2727
long sym_vdso32_rt_sigreturn_landing_pad;
2828
};
2929

30-
#ifdef CONFIG_X86_64
3130
extern const struct vdso_image vdso_image_64;
32-
#endif
33-
34-
#ifdef CONFIG_X86_X32_ABI
3531
extern const struct vdso_image vdso_image_x32;
36-
#endif
37-
38-
#if defined CONFIG_X86_32 || defined CONFIG_COMPAT
3932
extern const struct vdso_image vdso_image_32;
40-
#endif
4133

4234
extern int __init init_vdso_image(const struct vdso_image *image);
4335

0 commit comments

Comments
 (0)