mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/2] x86/vdso: Fix output operand size of RDPID insn
@ 2025-06-16  9:52 Uros Bizjak
  2025-06-16  9:52 ` [PATCH 2/2] x86/vdso: Use RDPID mnemonic in vdso_red_cpunode() Uros Bizjak
  2025-08-27  6:45 ` [tip: x86/asm] x86/vdso: Fix output operand size of RDPID tip-bot2 for Uros Bizjak
  0 siblings, 2 replies; 6+ messages in thread
From: Uros Bizjak @ 2025-06-16  9:52 UTC (permalink / raw)
  To: x86, linux-kernel
  Cc: Uros Bizjak, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
	Dave Hansen, H. Peter Anvin

RDPID instruction outputs to a word-sized register (64-bit on
x86_64 and 32-bit on x86_32). Use unsigned long variable to use
the correct size.

LSL outputs to 32-bit register, use %k operand prefix
to always print 32-bit name of the register.

Fixes: ffebbaedc861 ("x86/vdso: Introduce helper functions for CPU and node number")
Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
---
 arch/x86/include/asm/segment.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/include/asm/segment.h b/arch/x86/include/asm/segment.h
index 77d8f49b92bd..93fcf0daba01 100644
--- a/arch/x86/include/asm/segment.h
+++ b/arch/x86/include/asm/segment.h
@@ -244,7 +244,7 @@ static inline unsigned long vdso_encode_cpunode(int cpu, unsigned long node)
 
 static inline void vdso_read_cpunode(unsigned *cpu, unsigned *node)
 {
-	unsigned int p;
+	unsigned long p;
 
 	/*
 	 * Load CPU and node number from the GDT.  LSL is faster than RDTSCP
@@ -254,7 +254,7 @@ static inline void vdso_read_cpunode(unsigned *cpu, unsigned *node)
 	 *
 	 * If RDPID is available, use it.
 	 */
-	alternative_io ("lsl %[seg],%[p]",
+	alternative_io ("lsl %[seg],%k[p]",
 			".byte 0xf3,0x0f,0xc7,0xf8", /* RDPID %eax/rax */
 			X86_FEATURE_RDPID,
 			[p] "=a" (p), [seg] "r" (__CPUNODE_SEG));
-- 
2.49.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-08-27  8:29 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-06-16  9:52 [PATCH 1/2] x86/vdso: Fix output operand size of RDPID insn Uros Bizjak
2025-06-16  9:52 ` [PATCH 2/2] x86/vdso: Use RDPID mnemonic in vdso_red_cpunode() Uros Bizjak
2025-08-27  6:45 ` [tip: x86/asm] x86/vdso: Fix output operand size of RDPID tip-bot2 for Uros Bizjak
2025-08-27  7:53   ` Uros Bizjak
2025-08-27  8:19     ` Borislav Petkov
2025-08-27  8:28       ` Uros Bizjak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®