Skip to content

Commit 3f0b090

Browse files
committed
Merge tag 'x86_vdso_for_v6.3_rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 vdso updates from Borislav Petkov: - Add getcpu support for the 32-bit version of the vDSO - Some smaller fixes * tag 'x86_vdso_for_v6.3_rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/vdso: Fix -Wmissing-prototypes warnings x86/vdso: Fake 32bit VDSO build on 64bit compile for vgetcpu selftests: Emit a warning if getcpu() is missing on 32bit x86/vdso: Provide getcpu for x86-32. x86/cpu: Provide the full setup for getcpu() on x86-32 x86/vdso: Move VDSO image init to vdso2c generated code
2 parents efebca0 + dac0da4 commit 3f0b090

File tree

16 files changed

+57
-68
lines changed

16 files changed

+57
-68
lines changed

arch/x86/entry/vdso/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ VDSO32-$(CONFIG_IA32_EMULATION) := y
2929
# files to link into the vdso
3030
vobjs-y := vdso-note.o vclock_gettime.o vgetcpu.o
3131
vobjs32-y := vdso32/note.o vdso32/system_call.o vdso32/sigreturn.o
32-
vobjs32-y += vdso32/vclock_gettime.o
32+
vobjs32-y += vdso32/vclock_gettime.o vdso32/vgetcpu.o
3333
vobjs-$(CONFIG_X86_SGX) += vsgx.o
3434

3535
# files to link into kernel
@@ -104,6 +104,7 @@ $(vobjs): KBUILD_AFLAGS += -DBUILD_VDSO
104104
CFLAGS_REMOVE_vclock_gettime.o = -pg
105105
CFLAGS_REMOVE_vdso32/vclock_gettime.o = -pg
106106
CFLAGS_REMOVE_vgetcpu.o = -pg
107+
CFLAGS_REMOVE_vdso32/vgetcpu.o = -pg
107108
CFLAGS_REMOVE_vsgx.o = -pg
108109

109110
#

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>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
#ifdef CONFIG_X86_64
3+
4+
/*
5+
* in case of a 32 bit VDSO for a 64 bit kernel fake a 32 bit kernel
6+
* configuration
7+
*/
8+
#undef CONFIG_64BIT
9+
#undef CONFIG_X86_64
10+
#undef CONFIG_COMPAT
11+
#undef CONFIG_PGTABLE_LEVELS
12+
#undef CONFIG_ILLEGAL_POINTER_VALUE
13+
#undef CONFIG_SPARSEMEM_VMEMMAP
14+
#undef CONFIG_NR_CPUS
15+
#undef CONFIG_PARAVIRT_XXL
16+
17+
#define CONFIG_X86_32 1
18+
#define CONFIG_PGTABLE_LEVELS 2
19+
#define CONFIG_PAGE_OFFSET 0
20+
#define CONFIG_ILLEGAL_POINTER_VALUE 0
21+
#define CONFIG_NR_CPUS 1
22+
23+
#define BUILD_VDSO32_64
24+
25+
#endif
Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,4 @@
11
// SPDX-License-Identifier: GPL-2.0
22
#define BUILD_VDSO32
3-
4-
#ifdef CONFIG_X86_64
5-
6-
/*
7-
* in case of a 32 bit VDSO for a 64 bit kernel fake a 32 bit kernel
8-
* configuration
9-
*/
10-
#undef CONFIG_64BIT
11-
#undef CONFIG_X86_64
12-
#undef CONFIG_COMPAT
13-
#undef CONFIG_PGTABLE_LEVELS
14-
#undef CONFIG_ILLEGAL_POINTER_VALUE
15-
#undef CONFIG_SPARSEMEM_VMEMMAP
16-
#undef CONFIG_NR_CPUS
17-
#undef CONFIG_PARAVIRT_XXL
18-
19-
#define CONFIG_X86_32 1
20-
#define CONFIG_PGTABLE_LEVELS 2
21-
#define CONFIG_PAGE_OFFSET 0
22-
#define CONFIG_ILLEGAL_POINTER_VALUE 0
23-
#define CONFIG_NR_CPUS 1
24-
25-
#define BUILD_VDSO32_64
26-
27-
#endif
28-
3+
#include "fake_32bit_build.h"
294
#include "../vclock_gettime.c"

arch/x86/entry/vdso/vdso32/vdso32.lds.S

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ VERSION
2828
__vdso_time;
2929
__vdso_clock_getres;
3030
__vdso_clock_gettime64;
31+
__vdso_getcpu;
3132
};
3233

3334
LINUX_2.5 {

arch/x86/entry/vdso/vdso32/vgetcpu.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
#include "fake_32bit_build.h"
3+
#include "../vgetcpu.c"

arch/x86/entry/vdso/vgetcpu.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77

88
#include <linux/kernel.h>
99
#include <linux/getcpu.h>
10-
#include <linux/time.h>
11-
#include <asm/vgtod.h>
10+
#include <asm/segment.h>
1211

1312
notrace long
1413
__vdso_getcpu(unsigned *cpu, unsigned *node, struct getcpu_cache *unused)

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 */

0 commit comments

Comments
 (0)