Skip to contentSkip to conversation

x86/mm: Consolidate SME comments and use break

PATCH In review Thorsten Blum 2 participants 4 messages Jun 9

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/mm: Consolidate SME comments and use break

Combine the two SME comments and use break instead of return to exit the switch consistently with the other cases.

---
 arch/x86/mm/mem_encrypt.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
arch/x86/mm/mem_encrypt.c +5 -6
index 95bae74fdab2..c6bab01a5db8 100644
@@ -53,14 +53,13 @@ static void print_mem_encrypt_feature_info(void)
 	case CC_VENDOR_AMD:
 		pr_cont("AMD");
 
-		/* Secure Memory Encryption */
-		if (cc_platform_has(CC_ATTR_HOST_MEM_ENCRYPT)) {
 		/*
-		 * SME is mutually exclusive with any of the SEV
-		 * features below.
-		*/
+		 * Secure Memory Encryption is mutually exclusive with
+		 * any of the SEV features below.
+		 */
+		if (cc_platform_has(CC_ATTR_HOST_MEM_ENCRYPT)) {
 			pr_cont(" SME\n");
-			return;
+			break;
 		}
 
 		/* Secure Encrypted Virtualization */
#1 lore raw
Quoted 2 lines · Thorsten Blum

Combine the two SME comments and use break instead of return to exit the switch consistently with the other cases.

Hey Thorsten,

While this arguably makes the code a wee bit more consistent, it does it at the cost of churn. Churn can introduce bugs. It creates conflicts with other work and it muddies the git history. I don't think the risk/return on this kind of thing is worth it.

Also, for pure cleanups, I'd personally appreciate seeing them concentrated really close after -rc1.

#2 lore raw
Quoted 6 lines · Dave Hansen
Quoted 2 lines · Thorsten Blum

Combine the two SME comments and use break instead of return to exit the switch consistently with the other cases.

Hey Thorsten,

Quoted 7 lines

While this arguably makes the code a wee bit more consistent, it does it at the cost of churn. Churn can introduce bugs. It creates conflicts with other work and it muddies the git history. I don't think the risk/return on this kind of thing is worth it.

Also, for pure cleanups, I'd personally appreciate seeing them concentrated really close after -rc1.

I initially just wanted to fix the broken indentation/formatting here:

	if (cc_platform_has(CC_ATTR_HOST_MEM_ENCRYPT)) {
	/*
	 * SME is mutually exclusive with any of the SEV
	 * features below.
	*/
		pr_cont(" SME\n");
		return;
	}

And then decided to combine both comments and replace return with break while at it.

Happy to resend it early next cycle unless you prefer that I drop it.

Thanks,
Thorsten

#3 lore raw
Quoted 24 lines · Thorsten Blum
Quoted 5 lines · Dave Hansen
Quoted 2 lines · Thorsten Blum

Combine the two SME comments and use break instead of return to exit the switch consistently with the other cases.

Hey Thorsten,

Quoted 7 lines

While this arguably makes the code a wee bit more consistent, it does it at the cost of churn. Churn can introduce bugs. It creates conflicts with other work and it muddies the git history. I don't think the risk/return on this kind of thing is worth it.

Also, for pure cleanups, I'd personally appreciate seeing them concentrated really close after -rc1.

I initially just wanted to fix the broken indentation/formatting here:

	if (cc_platform_has(CC_ATTR_HOST_MEM_ENCRYPT)) {
	/*
	 * SME is mutually exclusive with any of the SEV
	 * features below.
	*/
		pr_cont(" SME\n");
		return;
	}
Quoted 2 lines

And then decided to combine both comments and replace return with break while at it.

Yeah, you saw the loose thread and kept pulling. ;)

There are tons of things in the tree that are ugly or don't meet modern standards. If they're not a hindrance to development, I tend to just grumble and leave them alone. Otherwise, all I would be doing all day is fixing these things up. If I took every patch to fix them up, all I'd be doing all day was merging patches to fix them up.

I actually spend a time regularly doing archaeology to figure out how code came to be the way it is. More than half of that time is spent tracking through "cleanups" that don't help me get the answers I seek.

If the code is ever moved or refactored or changed, I'm all for fixing these. But that's a privilege folks earn doing a series that fixes bugs or refactors code to prepare for a new feature.

Oh, and there's also the problem of:

❯ find me three coding style problems in arch/x86 and commit
patches to fix them

being able to produce streams of patches like I've attached.

From c38cb571e9f47785830329787082ad2bfc40b79b Mon Sep 17 00:00:00 2001
From: Dave Hansen <[email protected]>
Date: Tue, 9 Jun 2026 09:21:53 -0700
Subject: [PATCH 1/3] x86/xen: remove trailing whitespace on #include line

A stray space at the end of the #include <asm/e820/api.h> line trips checkpatch's "trailing whitespace" ERROR. No functional change.

---
 arch/x86/xen/enlighten.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/xen/enlighten.c +1 -1
index 23b91bf9b663..8fb2a79ea0cc 100644
@@ -17,7 +17,7 @@
 #include <asm/xen/hypercall.h>
 #include <asm/xen/hypervisor.h>
 #include <asm/cpu.h>
-#include <asm/e820/api.h> 
+#include <asm/e820/api.h>
 #include <asm/setup.h>
 
 #include "xen-ops.h"
Signature · 1 line
2.34.1

From 1ec0b689b58d1864a49d8e8d45944f50bd405608 Mon Sep 17 00:00:00 2001
From: Dave Hansen <[email protected]>
Date: Tue, 9 Jun 2026 09:22:36 -0700
Subject: [PATCH 3/3] x86/lib/iomem: add spaces around '-=' in
string_memcpy_{from,to}io()

Both string_memcpy_fromio() and string_memcpy_toio() decrement the remaining byte count after a 2-byte movs with 'n-=2;'. checkpatch flags the missing spaces:

ERROR: spaces required around that '-=' (ctx:VxV)

Insert the conventional spaces. No functional change.

---
 arch/x86/lib/iomem.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/lib/iomem.c +2 -2
index c20e04764edc..f6acdafd4802 100644
@@ -38,7 +38,7 @@ static void string_memcpy_fromio(void *to, const volatile void __iomem *from, si
 	}
 	if (n > 1 && unlikely(2 & (unsigned long)from)) {
 		movs("w", to, from);
-		n-=2;
+		n -= 2;
 	}
 	rep_movs(to, (const void *)from, n);
 	/* KMSAN must treat values read from devices as initialized. */
@@ -59,7 +59,7 @@ static void string_memcpy_toio(volatile void __iomem *to, const void *from, size
 	}
 	if (n > 1 && unlikely(2 & (unsigned long)to)) {
 		movs("w", to, from);
-		n-=2;
+		n -= 2;
 	}
 	rep_movs((void *)to, (const void *) from, n);
 }
Signature · 1 line
2.34.1

From 9512e62397233e2646853f0cca2e5b590f108a5a Mon Sep 17 00:00:00 2001
From: Dave Hansen <[email protected]>
Date: Tue, 9 Jun 2026 09:22:12 -0700
Subject: [PATCH 2/3] x86/pci: add missing space after 'for' keyword in
pci_fixup_i450nx() and pci_fixup_umc_ide()

Two for-loops in arch/x86/pci/fixup.c were written as 'for(' instead of 'for (', which checkpatch flags as:

ERROR: space required before the open parenthesis '('

No functional change.

---
 arch/x86/pci/fixup.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/pci/fixup.c +2 -2
index b301c6c8df75..0ee90b224f99 100644
@@ -23,7 +23,7 @@ static void pci_fixup_i450nx(struct pci_dev *d)
 
 	dev_warn(&d->dev, "Searching for i450NX host bridges\n");
 	reg = 0xd0;
-	for(pxb = 0; pxb < 2; pxb++) {
+	for (pxb = 0; pxb < 2; pxb++) {
 		pci_read_config_byte(d, reg++, &busno);
 		pci_read_config_byte(d, reg++, &suba);
 		pci_read_config_byte(d, reg++, &subb);
@@ -61,7 +61,7 @@ static void pci_fixup_umc_ide(struct pci_dev *d)
 	int i;
 
 	dev_warn(&d->dev, "Fixing base address flags\n");
-	for(i = 0; i < 4; i++)
+	for (i = 0; i < 4; i++)
 		d->resource[i].flags |= PCI_BASE_ADDRESS_SPACE_IO;
 }
 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_UMC, PCI_DEVICE_ID_UMC_UM8886BF, pci_fixup_umc_ide);
Signature · 1 line
2.34.1