The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH -tip] x86/bootflag: Micro-optimize sbf_write()
@ 2025-02-26 15:36 Uros Bizjak
  2025-02-27  9:24 ` [tip: x86/boot] " tip-bot2 for Uros Bizjak
  0 siblings, 1 reply; 2+ messages in thread
From: Uros Bizjak @ 2025-02-26 15:36 UTC (permalink / raw)
  To: x86, linux-kernel
  Cc: Uros Bizjak, H. Peter Anvin, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Dave Hansen

Change parity bit with XOR when !parity instead of masking bit out
and conditionally setting it when !parity.

Saves a couple of bytes in the object file.

Co-developed-by: "H. Peter Anvin" <hpa@zytor.com>
Signed-off-by: "H. Peter Anvin" <hpa@zytor.com>
Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
---
 arch/x86/kernel/bootflag.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/x86/kernel/bootflag.c b/arch/x86/kernel/bootflag.c
index 4d89a2d80d0f..b935c3e42bfd 100644
--- a/arch/x86/kernel/bootflag.c
+++ b/arch/x86/kernel/bootflag.c
@@ -38,9 +38,8 @@ static void __init sbf_write(u8 v)
 	unsigned long flags;
 
 	if (sbf_port != -1) {
-		v &= ~SBF_PARITY;
 		if (!parity(v))
-			v |= SBF_PARITY;
+			v ^= SBF_PARITY;
 
 		printk(KERN_INFO "Simple Boot Flag at 0x%x set to 0x%x\n",
 			sbf_port, v);
-- 
2.42.0


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

end of thread, other threads:[~2025-02-27  9:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-26 15:36 [PATCH -tip] x86/bootflag: Micro-optimize sbf_write() Uros Bizjak
2025-02-27  9:24 ` [tip: x86/boot] " tip-bot2 for Uros Bizjak

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