Skip to contentSkip to conversation

x86/boot: Avoid writing to cr4 twice in startup_64()

PATCH Superseded Khalid Ali 1 participant 1 message Jun 18, 2025 x86

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Khalid Ali

author
#0 lore raw

PATCH 1/1 x86/boot: Avoid writing to cr4 twice in startup_64()

From: Khalid Ali <[email protected]>

When Initializing cr4 bit PSE and PGE, cr4 is written twice for each bit.

Instead, set both bits first and write CR4 once, avoiding redundant writes.

---
 arch/x86/kernel/head_64.S | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
arch/x86/kernel/head_64.S +2 -5
index 4390a28f7dad..dfb5390e5c9a 100644
@@ -222,12 +222,9 @@ SYM_INNER_LABEL(common_startup_64, SYM_L_LOCAL)
 
 	/* Even if ignored in long mode, set PSE uniformly on all logical CPUs. */
 	btsl	$X86_CR4_PSE_BIT, %ecx
-	movq	%rcx, %cr4
-
-	/*
-	 * Set CR4.PGE to re-enable global translations.
-	 */
+	/* Set CR4.PGE to re-enable global translations. */
 	btsl	$X86_CR4_PGE_BIT, %ecx
+	
 	movq	%rcx, %cr4
 
 #ifdef CONFIG_SMP
Signature · 1 line
2.49.0