Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+57 -68
+2 -1
arch/x86/entry/vdso/Makefile
··· 29 29 # files to link into the vdso 30 30 vobjs-y := vdso-note.o vclock_gettime.o vgetcpu.o 31 31 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 33 33 vobjs-$(CONFIG_X86_SGX) += vsgx.o 34 34 35 35 # files to link into kernel ··· 104 104 CFLAGS_REMOVE_vclock_gettime.o = -pg 105 105 CFLAGS_REMOVE_vdso32/vclock_gettime.o = -pg 106 106 CFLAGS_REMOVE_vgetcpu.o = -pg 107 + CFLAGS_REMOVE_vdso32/vgetcpu.o = -pg 107 108 CFLAGS_REMOVE_vsgx.o = -pg 108 109 109 110 #
+6
arch/x86/entry/vdso/vdso2c.h
··· 179 179 180 180 fprintf(outfile, "/* AUTOMATICALLY GENERATED -- DO NOT EDIT */\n\n"); 181 181 fprintf(outfile, "#include <linux/linkage.h>\n"); 182 + fprintf(outfile, "#include <linux/init.h>\n"); 182 183 fprintf(outfile, "#include <asm/page_types.h>\n"); 183 184 fprintf(outfile, "#include <asm/vdso.h>\n"); 184 185 fprintf(outfile, "\n"); ··· 219 218 fprintf(outfile, "\t.sym_%s = %" PRIi64 ",\n", 220 219 required_syms[i].name, (int64_t)syms[i]); 221 220 } 221 + fprintf(outfile, "};\n\n"); 222 + fprintf(outfile, "static __init int init_%s(void) {\n", image_name); 223 + fprintf(outfile, "\treturn init_vdso_image(&%s);\n", image_name); 222 224 fprintf(outfile, "};\n"); 225 + fprintf(outfile, "subsys_initcall(init_%s);\n", image_name); 226 + 223 227 }
-9
arch/x86/entry/vdso/vdso32-setup.c
··· 51 51 __setup_param("vdso=", vdso_setup, vdso32_setup, 0); 52 52 #endif 53 53 54 - int __init sysenter_setup(void) 55 - { 56 - init_vdso_image(&vdso_image_32); 57 - 58 - return 0; 59 - } 60 - 61 54 #ifdef CONFIG_X86_64 62 - 63 - subsys_initcall(sysenter_setup); 64 55 65 56 #ifdef CONFIG_SYSCTL 66 57 /* Register vsyscall32 into the ABI table */
+25
arch/x86/entry/vdso/vdso32/fake_32bit_build.h
··· 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
+1 -26
arch/x86/entry/vdso/vdso32/vclock_gettime.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 2 2 #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" 29 4 #include "../vclock_gettime.c"
+1
arch/x86/entry/vdso/vdso32/vdso32.lds.S
··· 28 28 __vdso_time; 29 29 __vdso_clock_getres; 30 30 __vdso_clock_gettime64; 31 + __vdso_getcpu; 31 32 }; 32 33 33 34 LINUX_2.5 {
+3
arch/x86/entry/vdso/vdso32/vgetcpu.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + #include "fake_32bit_build.h" 3 + #include "../vgetcpu.c"
+1 -2
arch/x86/entry/vdso/vgetcpu.c
··· 7 7 8 8 #include <linux/kernel.h> 9 9 #include <linux/getcpu.h> 10 - #include <linux/time.h> 11 - #include <asm/vgtod.h> 10 + #include <asm/segment.h> 12 11 13 12 notrace long 14 13 __vdso_getcpu(unsigned *cpu, unsigned *node, struct getcpu_cache *unused)
+4 -15
arch/x86/entry/vdso/vma.c
··· 44 44 unsigned int __read_mostly vdso64_enabled = 1; 45 45 #endif 46 46 47 - void __init init_vdso_image(const struct vdso_image *image) 47 + int __init init_vdso_image(const struct vdso_image *image) 48 48 { 49 + BUILD_BUG_ON(VDSO_CLOCKMODE_MAX >= 32); 49 50 BUG_ON(image->size % PAGE_SIZE != 0); 50 51 51 52 apply_alternatives((struct alt_instr *)(image->data + image->alt), 52 53 (struct alt_instr *)(image->data + image->alt + 53 54 image->alt_len)); 55 + 56 + return 0; 54 57 } 55 58 56 59 static const struct vm_special_mapping vvar_mapping; ··· 421 418 return 1; 422 419 } 423 420 __setup("vdso=", vdso_setup); 424 - 425 - static int __init init_vdso(void) 426 - { 427 - BUILD_BUG_ON(VDSO_CLOCKMODE_MAX >= 32); 428 - 429 - init_vdso_image(&vdso_image_64); 430 - 431 - #ifdef CONFIG_X86_X32_ABI 432 - init_vdso_image(&vdso_image_x32); 433 - #endif 434 - 435 - return 0; 436 - } 437 - subsys_initcall(init_vdso); 438 421 #endif /* CONFIG_X86_64 */
-1
arch/x86/include/asm/processor.h
··· 542 542 IDLE_POLL}; 543 543 544 544 extern void enable_sep_cpu(void); 545 - extern int sysenter_setup(void); 546 545 547 546 548 547 /* Defined in head.S */
+4 -4
arch/x86/include/asm/segment.h
··· 96 96 * 97 97 * 26 - ESPFIX small SS 98 98 * 27 - per-cpu [ offset to per-cpu data area ] 99 - * 28 - unused 99 + * 28 - VDSO getcpu 100 100 * 29 - unused 101 101 * 30 - unused 102 102 * 31 - TSS for double fault handler ··· 119 119 120 120 #define GDT_ENTRY_ESPFIX_SS 26 121 121 #define GDT_ENTRY_PERCPU 27 122 + #define GDT_ENTRY_CPUNODE 28 122 123 123 124 #define GDT_ENTRY_DOUBLEFAULT_TSS 31 124 125 ··· 159 158 #else 160 159 # define __KERNEL_PERCPU 0 161 160 #endif 161 + 162 + #define __CPUNODE_SEG (GDT_ENTRY_CPUNODE*8 + 3) 162 163 163 164 #else /* 64-bit: */ 164 165 ··· 229 226 #define GDT_ENTRY_TLS_ENTRIES 3 230 227 #define TLS_SIZE (GDT_ENTRY_TLS_ENTRIES* 8) 231 228 232 - #ifdef CONFIG_X86_64 233 - 234 229 /* Bit size and mask of CPU number stored in the per CPU data (and TSC_AUX) */ 235 230 #define VDSO_CPUNODE_BITS 12 236 231 #define VDSO_CPUNODE_MASK 0xfff ··· 266 265 } 267 266 268 267 #endif /* !__ASSEMBLY__ */ 269 - #endif /* CONFIG_X86_64 */ 270 268 271 269 #ifdef __KERNEL__ 272 270
+1 -1
arch/x86/include/asm/vdso.h
··· 45 45 extern const struct vdso_image vdso_image_32; 46 46 #endif 47 47 48 - extern void __init init_vdso_image(const struct vdso_image *image); 48 + extern int __init init_vdso_image(const struct vdso_image *image); 49 49 50 50 extern int map_vdso_once(const struct vdso_image *image, unsigned long addr); 51 51
+2
arch/x86/include/asm/vdso/gettimeofday.h
··· 318 318 } 319 319 #define vdso_calc_delta vdso_calc_delta 320 320 321 + int __vdso_clock_gettime64(clockid_t clock, struct __kernel_timespec *ts); 322 + 321 323 #endif /* !__ASSEMBLY__ */ 322 324 323 325 #endif /* __ASM_VDSO_GETTIMEOFDAY_H */
+4
arch/x86/include/asm/vdso/processor.h
··· 18 18 rep_nop(); 19 19 } 20 20 21 + struct getcpu_cache; 22 + 23 + notrace long __vdso_getcpu(unsigned *cpu, unsigned *node, struct getcpu_cache *unused); 24 + 21 25 #endif /* __ASSEMBLY__ */ 22 26 23 27 #endif /* __ASM_VDSO_PROCESSOR_H */
+1 -4
arch/x86/kernel/cpu/common.c
··· 1958 1958 if (HAS_KERNEL_IBT && cpu_feature_enabled(X86_FEATURE_IBT)) 1959 1959 pr_info("CET detected: Indirect Branch Tracking enabled\n"); 1960 1960 #ifdef CONFIG_X86_32 1961 - sysenter_setup(); 1962 1961 enable_sep_cpu(); 1963 1962 #endif 1964 1963 cpu_detect_tlb(&boot_cpu_data); ··· 2129 2130 #endif 2130 2131 } 2131 2132 2132 - #ifdef CONFIG_X86_64 2133 2133 static inline void setup_getcpu(int cpu) 2134 2134 { 2135 2135 unsigned long cpudata = vdso_encode_cpunode(cpu, early_cpu_to_node(cpu)); ··· 2150 2152 write_gdt_entry(get_cpu_gdt_rw(cpu), GDT_ENTRY_CPUNODE, &d, DESCTYPE_S); 2151 2153 } 2152 2154 2155 + #ifdef CONFIG_X86_64 2153 2156 static inline void ucode_cpu_init(int cpu) 2154 2157 { 2155 2158 if (cpu) ··· 2169 2170 } 2170 2171 2171 2172 #else /* CONFIG_X86_64 */ 2172 - 2173 - static inline void setup_getcpu(int cpu) { } 2174 2173 2175 2174 static inline void ucode_cpu_init(int cpu) 2176 2175 {
+2 -5
tools/testing/selftests/x86/test_vsyscall.c
··· 92 92 printf("[WARN]\tfailed to find time in vDSO\n"); 93 93 94 94 vdso_getcpu = (getcpu_t)dlsym(vdso, "__vdso_getcpu"); 95 - if (!vdso_getcpu) { 96 - /* getcpu() was never wired up in the 32-bit vDSO. */ 97 - printf("[%s]\tfailed to find getcpu in vDSO\n", 98 - sizeof(long) == 8 ? "WARN" : "NOTE"); 99 - } 95 + if (!vdso_getcpu) 96 + printf("[WARN]\tfailed to find getcpu in vDSO\n"); 100 97 } 101 98 102 99 static int init_vsys(void)