Skip to content

Commit 4c382d7

Browse files
Brian Gerstingomolnar
authored andcommitted
x86/vdso: Move VDSO image init to vdso2c generated code
Generate an init function for each VDSO image, replacing init_vdso() and sysenter_setup(). Signed-off-by: Brian Gerst <brgerst@gmail.com> Signed-off-by: Ingo Molnar <mingo@kernel.org> Link: https://lore.kernel.org/r/20230124184019.26850-1-brgerst@gmail.com
1 parent 2241ab5 commit 4c382d7

6 files changed

Lines changed: 11 additions & 27 deletions

File tree

arch/x86/entry/vdso/vdso2c.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ static void BITSFUNC(go)(void *raw_addr, size_t raw_len,
179179

180180
fprintf(outfile, "/* AUTOMATICALLY GENERATED -- DO NOT EDIT */\n\n");
181181
fprintf(outfile, "#include <linux/linkage.h>\n");
182+
fprintf(outfile, "#include <linux/init.h>\n");
182183
fprintf(outfile, "#include <asm/page_types.h>\n");
183184
fprintf(outfile, "#include <asm/vdso.h>\n");
184185
fprintf(outfile, "\n");
@@ -218,5 +219,10 @@ static void BITSFUNC(go)(void *raw_addr, size_t raw_len,
218219
fprintf(outfile, "\t.sym_%s = %" PRIi64 ",\n",
219220
required_syms[i].name, (int64_t)syms[i]);
220221
}
222+
fprintf(outfile, "};\n\n");
223+
fprintf(outfile, "static __init int init_%s(void) {\n", image_name);
224+
fprintf(outfile, "\treturn init_vdso_image(&%s);\n", image_name);
221225
fprintf(outfile, "};\n");
226+
fprintf(outfile, "subsys_initcall(init_%s);\n", image_name);
227+
222228
}

arch/x86/entry/vdso/vdso32-setup.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,8 @@ __setup("vdso32=", vdso32_setup);
5151
__setup_param("vdso=", vdso_setup, vdso32_setup, 0);
5252
#endif
5353

54-
int __init sysenter_setup(void)
55-
{
56-
init_vdso_image(&vdso_image_32);
57-
58-
return 0;
59-
}
60-
6154
#ifdef CONFIG_X86_64
6255

63-
subsys_initcall(sysenter_setup);
64-
6556
#ifdef CONFIG_SYSCTL
6657
/* Register vsyscall32 into the ABI table */
6758
#include <linux/sysctl.h>

arch/x86/entry/vdso/vma.c

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,16 @@ unsigned int vclocks_used __read_mostly;
4444
unsigned int __read_mostly vdso64_enabled = 1;
4545
#endif
4646

47-
void __init init_vdso_image(const struct vdso_image *image)
47+
int __init init_vdso_image(const struct vdso_image *image)
4848
{
49+
BUILD_BUG_ON(VDSO_CLOCKMODE_MAX >= 32);
4950
BUG_ON(image->size % PAGE_SIZE != 0);
5051

5152
apply_alternatives((struct alt_instr *)(image->data + image->alt),
5253
(struct alt_instr *)(image->data + image->alt +
5354
image->alt_len));
55+
56+
return 0;
5457
}
5558

5659
static const struct vm_special_mapping vvar_mapping;
@@ -418,18 +421,4 @@ static __init int vdso_setup(char *s)
418421
return 1;
419422
}
420423
__setup("vdso=", vdso_setup);
421-
422-
static int __init init_vdso(void)
423-
{
424-
BUILD_BUG_ON(VDSO_CLOCKMODE_MAX >= 32);
425-
426-
init_vdso_image(&vdso_image_64);
427-
428-
#ifdef CONFIG_X86_X32_ABI
429-
init_vdso_image(&vdso_image_x32);
430-
#endif
431-
432-
return 0;
433-
}
434-
subsys_initcall(init_vdso);
435424
#endif /* CONFIG_X86_64 */

arch/x86/include/asm/processor.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,6 @@ enum idle_boot_override {IDLE_NO_OVERRIDE=0, IDLE_HALT, IDLE_NOMWAIT,
542542
IDLE_POLL};
543543

544544
extern void enable_sep_cpu(void);
545-
extern int sysenter_setup(void);
546545

547546

548547
/* Defined in head.S */

arch/x86/include/asm/vdso.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ extern const struct vdso_image vdso_image_x32;
4545
extern const struct vdso_image vdso_image_32;
4646
#endif
4747

48-
extern void __init init_vdso_image(const struct vdso_image *image);
48+
extern int __init init_vdso_image(const struct vdso_image *image);
4949

5050
extern int map_vdso_once(const struct vdso_image *image, unsigned long addr);
5151

arch/x86/kernel/cpu/common.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1953,7 +1953,6 @@ void __init identify_boot_cpu(void)
19531953
if (HAS_KERNEL_IBT && cpu_feature_enabled(X86_FEATURE_IBT))
19541954
pr_info("CET detected: Indirect Branch Tracking enabled\n");
19551955
#ifdef CONFIG_X86_32
1956-
sysenter_setup();
19571956
enable_sep_cpu();
19581957
#endif
19591958
cpu_detect_tlb(&boot_cpu_data);

0 commit comments

Comments
 (0)