mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v3] x86/boot: Avoid writing to cr4 twice in startup_64()
@ 2025-07-15 18:16 Khalid Ali
  2025-07-15 18:45 ` Nikolay Borisov
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: Khalid Ali @ 2025-07-15 18:16 UTC (permalink / raw)
  To: tglx, mingo, bp, dave.hansen
  Cc: x86, hpa, ardb, ubizjak, brgerst, linux-kernel, Khalid Ali

From: Khalid Ali <khaliidcaliy@gmail.com>

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

Instead, set both bits first and write CR4 once, avoiding redundant
writes. This makes consistent with cr0 writes, which is set bits and
write once.

Signed-off-by: Khalid Ali <khaliidcaliy@gmail.com>
---
 arch/x86/kernel/head_64.S | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
index 4390a28f7dad..dfb5390e5c9a 100644
--- a/arch/x86/kernel/head_64.S
+++ b/arch/x86/kernel/head_64.S
@@ -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
-- 
2.49.0


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2025-07-16 13:25 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-07-15 18:16 [PATCH v3] x86/boot: Avoid writing to cr4 twice in startup_64() Khalid Ali
2025-07-15 18:45 ` Nikolay Borisov
2025-07-15 19:05 ` [tip: x86/cleanups] x86/boot: Avoid redundant %cr4 write " tip-bot2 for Khalid Ali
2025-07-15 20:30 ` [PATCH v3] x86/boot: Avoid writing to cr4 twice " H. Peter Anvin
2025-07-15 20:31 ` H. Peter Anvin
2025-07-15 21:21 ` Andrew Cooper
2025-07-16  1:45   ` Borislav Petkov
2025-07-16  9:07     ` Khalid Ali
2025-07-16 13:27       ` Borislav Petkov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®