Skip to content

Commit ac9c408

Browse files
ubizjakbp3tk0v
authored andcommitted
x86/vdso: Fix output operand size of RDPID
RDPID instruction outputs to a word-sized register (64-bit on x86_64 and 32-bit on x86_32). Use an unsigned long variable to store the correct size. LSL outputs to 32-bit register, use %k operand prefix to always print the 32-bit name of the register. Use RDPID insn mnemonic while at it as the minimum binutils version of 2.30 supports it. [ bp: Merge two patches touching the same function into a single one. ] Fixes: ffebbae ("x86/vdso: Introduce helper functions for CPU and node number") Signed-off-by: Uros Bizjak <ubizjak@gmail.com> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Link: https://lore.kernel.org/20250616095315.230620-1-ubizjak@gmail.com
1 parent 1b237f1 commit ac9c408

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

arch/x86/include/asm/segment.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ static inline unsigned long vdso_encode_cpunode(int cpu, unsigned long node)
244244

245245
static inline void vdso_read_cpunode(unsigned *cpu, unsigned *node)
246246
{
247-
unsigned int p;
247+
unsigned long p;
248248

249249
/*
250250
* Load CPU and node number from the GDT. LSL is faster than RDTSCP
@@ -254,10 +254,10 @@ static inline void vdso_read_cpunode(unsigned *cpu, unsigned *node)
254254
*
255255
* If RDPID is available, use it.
256256
*/
257-
alternative_io ("lsl %[seg],%[p]",
258-
".byte 0xf3,0x0f,0xc7,0xf8", /* RDPID %eax/rax */
257+
alternative_io ("lsl %[seg],%k[p]",
258+
"rdpid %[p]",
259259
X86_FEATURE_RDPID,
260-
[p] "=a" (p), [seg] "r" (__CPUNODE_SEG));
260+
[p] "=r" (p), [seg] "r" (__CPUNODE_SEG));
261261

262262
if (cpu)
263263
*cpu = (p & VDSO_CPUNODE_MASK);

0 commit comments

Comments
 (0)