From: Yuntao Wang <yuntao.wang@linux.dev>
To: linux-kernel@vger.kernel.org, x86@kernel.org
Cc: Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
"H. Peter Anvin" <hpa@zytor.com>, Xin Li <xin3.li@intel.com>,
"Peter Zijlstra (Intel)" <peterz@infradead.org>,
Vegard Nossum <vegard.nossum@oracle.com>,
Tony Luck <tony.luck@intel.com>,
Pawan Gupta <pawan.kumar.gupta@linux.intel.com>,
Rick Edgecombe <rick.p.edgecombe@intel.com>,
Yuntao Wang <yuntao.wang@linux.dev>
Subject: [PATCH] x86/cpu: Use TLS_SIZE instead of open coding it
Date: Fri, 19 Jul 2024 11:24:37 +0800 [thread overview]
Message-ID: <20240719032437.35258-1-yuntao.wang@linux.dev> (raw)
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
reply other threads:[~2024-07-19 3:28 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240719032437.35258-1-yuntao.wang@linux.dev \
--to=yuntao.wang@linux.dev \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=pawan.kumar.gupta@linux.intel.com \
--cc=peterz@infradead.org \
--cc=rick.p.edgecombe@intel.com \
--cc=tglx@linutronix.de \
--cc=tony.luck@intel.com \
--cc=vegard.nossum@oracle.com \
--cc=x86@kernel.org \
--cc=xin3.li@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox