public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/cpu: Use TLS_SIZE instead of open coding it
@ 2024-07-19  3:24 Yuntao Wang
  0 siblings, 0 replies; only message in thread
From: Yuntao Wang @ 2024-07-19  3:24 UTC (permalink / raw)
  To: linux-kernel, x86
  Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen,
	H. Peter Anvin, Xin Li, Peter Zijlstra (Intel), Vegard Nossum,
	Tony Luck, Pawan Gupta, Rick Edgecombe, Yuntao Wang

Currently, there is already a macro named TLS_SIZE defined in segment.h,
which is equivalent to 'GDT_ENTRY_TLS_ENTRIES * 8'. Therefore, we can use
this macro directly in cpu_init() instead of open coding it.

Signed-off-by: Yuntao Wang <yuntao.wang@linux.dev>
---
 arch/x86/include/asm/segment.h | 2 +-
 arch/x86/kernel/cpu/common.c   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/include/asm/segment.h b/arch/x86/include/asm/segment.h
index 9d6411c65920..c6d710340c02 100644
--- a/arch/x86/include/asm/segment.h
+++ b/arch/x86/include/asm/segment.h
@@ -227,7 +227,7 @@
 
 #define GDT_SIZE			(GDT_ENTRIES*8)
 #define GDT_ENTRY_TLS_ENTRIES		3
-#define TLS_SIZE			(GDT_ENTRY_TLS_ENTRIES* 8)
+#define TLS_SIZE			(GDT_ENTRY_TLS_ENTRIES*8)
 
 /* Bit size and mask of CPU number stored in the per CPU data (and TSC_AUX) */
 #define VDSO_CPUNODE_BITS		12
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index d4e539d4e158..08b58de86c45 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -2220,7 +2220,7 @@ void cpu_init(void)
 
 	if (IS_ENABLED(CONFIG_X86_64)) {
 		loadsegment(fs, 0);
-		memset(cur->thread.tls_array, 0, GDT_ENTRY_TLS_ENTRIES * 8);
+		memset(cur->thread.tls_array, 0, TLS_SIZE);
 		syscall_init();
 
 		wrmsrl(MSR_FS_BASE, 0);
-- 
2.45.2


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2024-07-19  3:28 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-19  3:24 [PATCH] x86/cpu: Use TLS_SIZE instead of open coding it Yuntao Wang

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