Skip to contentSkip to conversation

x86/cpu: Use TLS_SIZE instead of open coding it

PATCH New Yuntao Wang 1 participant 1 message Jul 19, 2024 x86

lore
Share & tools
lore
#0 lore raw

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

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.

---
 arch/x86/include/asm/segment.h | 2 +-
 arch/x86/kernel/cpu/common.c   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
arch/x86/include/asm/segment.h +1 -1
index 9d6411c65920..c6d710340c02 100644
@@ -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
arch/x86/kernel/cpu/common.c +1 -1
index d4e539d4e158..08b58de86c45 100644
@@ -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);
Signature · 1 line
2.45.2