* [PATCH v2 1/1] x86/vdso: choose the right GDT_ENTRY_CPUNODE for 32-bit getcpu() on 64-bit kernel
@ 2023-03-22 6:17 Xin Li
2023-08-08 7:36 ` [tip: x86/urgent] x86/vdso: Choose " tip-bot2 for Xin Li
0 siblings, 1 reply; 2+ messages in thread
From: Xin Li @ 2023-03-22 6:17 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_.
When BUILD_VDSO32_64 is defined, choose the 64-bit Linux kernel GDT definitions
to compile the 32-bit getcpu().
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>
---
Change since v1:
* Define all of the GDT_ENTRY_* macros in *one* place, then make that *one*
place depend on BUILD_VDSO32_64 (Dave Hansen).
---
arch/x86/include/asm/segment.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/include/asm/segment.h b/arch/x86/include/asm/segment.h
index 794f69625780..9d6411c65920 100644
--- a/arch/x86/include/asm/segment.h
+++ b/arch/x86/include/asm/segment.h
@@ -56,7 +56,7 @@
#define GDT_ENTRY_INVALID_SEG 0
-#ifdef CONFIG_X86_32
+#if defined(CONFIG_X86_32) && !defined(BUILD_VDSO32_64)
/*
* The layout of the per-CPU GDT under Linux:
*
--
2.34.1
^ permalink raw reply [flat|nested] 2+ messages in thread* [tip: x86/urgent] x86/vdso: Choose the right GDT_ENTRY_CPUNODE for 32-bit getcpu() on 64-bit kernel
2023-03-22 6:17 [PATCH v2 1/1] x86/vdso: choose the right GDT_ENTRY_CPUNODE for 32-bit getcpu() on 64-bit kernel Xin Li
@ 2023-08-08 7:36 ` tip-bot2 for Xin Li
0 siblings, 0 replies; 2+ messages in thread
From: tip-bot2 for Xin Li @ 2023-08-08 7:36 UTC (permalink / raw)
To: linux-tip-commits
Cc: kernel test robot, Shan Kang, Xin Li, Thomas Gleixner, x86, linux-kernel
The following commit has been merged into the x86/urgent branch of tip:
Commit-ID: 39163d5479285a36522b6e8f9cc568cc4987db08
Gitweb: https://git.kernel.org/tip/39163d5479285a36522b6e8f9cc568cc4987db08
Author: Xin Li <xin3.li@intel.com>
AuthorDate: Tue, 21 Mar 2023 23:17:58 -07:00
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Tue, 08 Aug 2023 09:31:43 +02:00
x86/vdso: Choose the right GDT_ENTRY_CPUNODE for 32-bit getcpu() on 64-bit kernel
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_.
When BUILD_VDSO32_64 is defined, choose the 64-bit Linux kernel GDT definitions
to compile the 32-bit getcpu().
Fixes: 877cff5296faa6e ("x86/vdso: Fake 32bit VDSO build on 64bit compile for vgetcpu")
Reported-by: kernel test robot <yujie.liu@intel.com>
Reported-by: Shan Kang <shan.kang@intel.com>
Signed-off-by: Xin Li <xin3.li@intel.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/r/20230322061758.10639-1-xin3.li@intel.com
Link: https://lore.kernel.org/oe-lkp/202303020903.b01fd1de-yujie.liu@intel.com
---
arch/x86/include/asm/segment.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/include/asm/segment.h b/arch/x86/include/asm/segment.h
index 794f696..9d6411c 100644
--- a/arch/x86/include/asm/segment.h
+++ b/arch/x86/include/asm/segment.h
@@ -56,7 +56,7 @@
#define GDT_ENTRY_INVALID_SEG 0
-#ifdef CONFIG_X86_32
+#if defined(CONFIG_X86_32) && !defined(BUILD_VDSO32_64)
/*
* The layout of the per-CPU GDT under Linux:
*
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-08-08 16:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-22 6:17 [PATCH v2 1/1] x86/vdso: choose the right GDT_ENTRY_CPUNODE for 32-bit getcpu() on 64-bit kernel Xin Li
2023-08-08 7:36 ` [tip: x86/urgent] x86/vdso: Choose " tip-bot2 for Xin Li
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®