[PATCH] x86/cpu: Use TLS_SIZE instead of open coding it

From: Yuntao Wang
Date: Thu Jul 18 2024 - 23:28:44 EST


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@xxxxxxxxx>
---
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