lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251013143444.3999-46-david.kaplan@amd.com>
Date: Mon, 13 Oct 2025 09:34:33 -0500
From: David Kaplan <david.kaplan@....com>
To: Thomas Gleixner <tglx@...utronix.de>, Borislav Petkov <bp@...en8.de>,
	Peter Zijlstra <peterz@...radead.org>, Josh Poimboeuf <jpoimboe@...nel.org>,
	Pawan Gupta <pawan.kumar.gupta@...ux.intel.com>, Ingo Molnar
	<mingo@...hat.com>, Dave Hansen <dave.hansen@...ux.intel.com>,
	<x86@...nel.org>, "H . Peter Anvin" <hpa@...or.com>
CC: Alexander Graf <graf@...zon.com>, Boris Ostrovsky
	<boris.ostrovsky@...cle.com>, <linux-kernel@...r.kernel.org>
Subject: [RFC PATCH 45/56] x86/alternative: Use boot_cpu_has in ITS code

Replace cpu_feature_enabled with boot_cpu_has because under dynamic
re-patching, this code may be called after features have changed but before
alternatives are patched.

Signed-off-by: David Kaplan <david.kaplan@....com>
---
 arch/x86/kernel/alternative.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
index 2d48d750d4d9..5a543ffca10d 100644
--- a/arch/x86/kernel/alternative.c
+++ b/arch/x86/kernel/alternative.c
@@ -187,7 +187,7 @@ static void its_fini_core(void)
 #ifdef CONFIG_MODULES
 void its_init_mod(struct module *mod)
 {
-	if (!cpu_feature_enabled(X86_FEATURE_INDIRECT_THUNK_ITS))
+	if (!boot_cpu_has(X86_FEATURE_INDIRECT_THUNK_ITS))
 		return;
 
 	mutex_lock(&text_mutex);
@@ -197,7 +197,7 @@ void its_init_mod(struct module *mod)
 
 void its_fini_mod(struct module *mod)
 {
-	if (!cpu_feature_enabled(X86_FEATURE_INDIRECT_THUNK_ITS))
+	if (!boot_cpu_has(X86_FEATURE_INDIRECT_THUNK_ITS))
 		return;
 
 	WARN_ON_ONCE(its_mod != mod);
@@ -901,7 +901,7 @@ static int emit_its_trampoline(void *addr, struct insn *insn, int reg, u8 *bytes
 /* Check if an indirect branch is at ITS-unsafe address */
 static bool cpu_wants_indirect_its_thunk_at(unsigned long addr, int reg)
 {
-	if (!cpu_feature_enabled(X86_FEATURE_INDIRECT_THUNK_ITS))
+	if (!boot_cpu_has(X86_FEATURE_INDIRECT_THUNK_ITS))
 		return false;
 
 	/* Indirect branch opcode is 2 or 3 bytes depending on reg */
@@ -967,9 +967,9 @@ static int patch_retpoline(void *addr, struct insn *insn, u8 *bytes)
 	/* If anyone ever does: CALL/JMP *%rsp, we're in deep trouble. */
 	BUG_ON(reg == 4);
 
-	if (cpu_feature_enabled(X86_FEATURE_RETPOLINE) &&
-	    !cpu_feature_enabled(X86_FEATURE_RETPOLINE_LFENCE)) {
-		if (cpu_feature_enabled(X86_FEATURE_CALL_DEPTH))
+	if (boot_cpu_has(X86_FEATURE_RETPOLINE) &&
+	    !boot_cpu_has(X86_FEATURE_RETPOLINE_LFENCE)) {
+		if (boot_cpu_has(X86_FEATURE_CALL_DEPTH))
 			return emit_call_track_retpoline(addr, insn, reg, bytes);
 
 		return -1;
@@ -1004,7 +1004,7 @@ static int patch_retpoline(void *addr, struct insn *insn, u8 *bytes)
 	/*
 	 * For RETPOLINE_LFENCE: prepend the indirect CALL/JMP with an LFENCE.
 	 */
-	if (cpu_feature_enabled(X86_FEATURE_RETPOLINE_LFENCE)) {
+	if (boot_cpu_has(X86_FEATURE_RETPOLINE_LFENCE)) {
 		bytes[i++] = 0x0f;
 		bytes[i++] = 0xae;
 		bytes[i++] = 0xe8; /* LFENCE */
-- 
2.34.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ