All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] x86/vdso: use the right GDT_ENTRY_CPUNODE for 32-bit getcpu() on 64-bit kernel
@ 2023-03-11  8:48 Xin Li
  2023-03-13 15:22 ` Dave Hansen
  0 siblings, 1 reply; 7+ messages in thread
From: Xin Li @ 2023-03-11  8:48 UTC (permalink / raw)
  To: linux-kernel, x86
  Cc: tglx, mingo, bp, dave.hansen, hpa, bigeasy, yujie.liu, shan.kang

The vDSO getcpu() reads CPU ID from the GDT_ENTRY_CPUNODE entry when the RDPID
instruction is not available. And GDT_ENTRY_CPUNODE is defined as 28 on 32-bit
Linux kernel and 15 on 64-bit. But the 32-bit getcpu() on 64-bit Linux kernel
is compiled with 32-bit Linux kernel GDT_ENTRY_CPUNODE, i.e., 28, beyond the
64-bit Linux kernel GDT limit. Thus, it just fails _silently_.

Compile the 32-bit getcpu() on 64-bit Linux kernel with the 64-bit Linux kernel
GDT_ENTRY_CPUNODE.

Fixes: 877cff5296faa6e ("x86/vdso: Fake 32bit VDSO build on 64bit compile for vgetcpu")
Reported-by: kernel test robot <yujie.liu@intel.com>
https://lore.kernel.org/oe-lkp/202303020903.b01fd1de-yujie.liu@intel.com/
Reported-by: Shan Kang <shan.kang@intel.com>
Signed-off-by: Xin Li <xin3.li@intel.com>
---
 arch/x86/include/asm/segment.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/x86/include/asm/segment.h b/arch/x86/include/asm/segment.h
index 794f69625780..d3b4f8797054 100644
--- a/arch/x86/include/asm/segment.h
+++ b/arch/x86/include/asm/segment.h
@@ -119,7 +119,11 @@
 
 #define GDT_ENTRY_ESPFIX_SS		26
 #define GDT_ENTRY_PERCPU		27
+#ifndef BUILD_VDSO32_64
 #define GDT_ENTRY_CPUNODE		28
+#else
+#define GDT_ENTRY_CPUNODE		15
+#endif
 
 #define GDT_ENTRY_DOUBLEFAULT_TSS	31
 
-- 
2.34.1


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

end of thread, other threads:[~2023-03-29 23:59 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-11  8:48 [PATCH 1/1] x86/vdso: use the right GDT_ENTRY_CPUNODE for 32-bit getcpu() on 64-bit kernel Xin Li
2023-03-13 15:22 ` Dave Hansen
2023-03-13 17:42   ` Li, Xin3
2023-03-18  8:14     ` Li, Xin3
2023-03-29  8:50     ` Li, Xin3
2023-03-29 23:11       ` Li, Xin3
2023-03-29 23:59         ` H. Peter Anvin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.