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

x86/asm-offsets: Export certain 'struct cpuinfo_x86' fields for 64-bit asm use too

Expose certain 'struct cpuinfo_x86' fields via asm-offsets for x86_64
too, so that it will be possible to set CPU capabilities from 64-bit
asm code.

32-bit already used these fields, so simply move those offset exports into
the unified asm-offsets.c file.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Link: https://lore.kernel.org/r/20250514104242.1275040-12-ardb+git@google.com

authored by

Ard Biesheuvel and committed by
Ingo Molnar
25219c25 64797551

+8 -9
+8
arch/x86/kernel/asm-offsets.c
··· 33 33 34 34 static void __used common(void) 35 35 { 36 + OFFSET(CPUINFO_x86, cpuinfo_x86, x86); 37 + OFFSET(CPUINFO_x86_vendor, cpuinfo_x86, x86_vendor); 38 + OFFSET(CPUINFO_x86_model, cpuinfo_x86, x86_model); 39 + OFFSET(CPUINFO_x86_stepping, cpuinfo_x86, x86_stepping); 40 + OFFSET(CPUINFO_cpuid_level, cpuinfo_x86, cpuid_level); 41 + OFFSET(CPUINFO_x86_capability, cpuinfo_x86, x86_capability); 42 + OFFSET(CPUINFO_x86_vendor_id, cpuinfo_x86, x86_vendor_id); 43 + 36 44 BLANK(); 37 45 OFFSET(TASK_threadsp, task_struct, thread.sp); 38 46 #ifdef CONFIG_STACKPROTECTOR
-9
arch/x86/kernel/asm-offsets_32.c
··· 12 12 13 13 void foo(void) 14 14 { 15 - OFFSET(CPUINFO_x86, cpuinfo_x86, x86); 16 - OFFSET(CPUINFO_x86_vendor, cpuinfo_x86, x86_vendor); 17 - OFFSET(CPUINFO_x86_model, cpuinfo_x86, x86_model); 18 - OFFSET(CPUINFO_x86_stepping, cpuinfo_x86, x86_stepping); 19 - OFFSET(CPUINFO_cpuid_level, cpuinfo_x86, cpuid_level); 20 - OFFSET(CPUINFO_x86_capability, cpuinfo_x86, x86_capability); 21 - OFFSET(CPUINFO_x86_vendor_id, cpuinfo_x86, x86_vendor_id); 22 - BLANK(); 23 - 24 15 OFFSET(PT_EBX, pt_regs, bx); 25 16 OFFSET(PT_ECX, pt_regs, cx); 26 17 OFFSET(PT_EDX, pt_regs, dx);