Skip to contentSkip to conversation

[PATCH linux-6.1.y 0/2]

PATCH Superseded Clark Williams 2 participants 4 messages Jun 16

Subsystems (5)
Stable branch x86 BPF KVM x86 +1 more subsystems

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover [PATCH linux-6.1.y 0/2]

GCC 16.1.1 introduces stricter diagnostics that surface two latent issues in the 6.1.y stable tree, both of which become hard errors under -Werror:

1. -Wattributes on regparm(0) for x86-64 arch/x86/kvm/vmx/vmx_ops.h applies __attribute__((regparm(0))) to vmread_error_trampoline(). On x86-32 this is intentional: it overrides the kernel's -mregparm=3 convention so the trampoline receives its arguments on the stack, matching the inline-asm callers that push args before the call. On x86-64 the attribute has always been a no-op (the SysV ABI already passes arguments in registers), but older GCC silently accepted it. GCC 16.1.1 now warns, which -Werror promotes to a build failure. The fix guards the attribute with #ifdef CONFIG_X86_32.

2. -Wdiscarded-qualifiers in libbpf
In tools/lib/bpf/libbpf.c, resolve_full_path() assigns the result of strchr() on a const char * to a plain char * variable. Newer GCC/glibc combinations propagate the const qualifier through strchr(), so this assignment now triggers -Werror=discarded-qualifiers. Since the variable (next_path) is only used for pointer arithmetic and is never written through, the fix is simply to declare it const char *.

Clark Williams (2):
tools/lib/bpf: fix const-qualifier discard in resolve_full_path kvm/vmx: guard regparm(0) on vmread_error_trampoline for x86_32 only

 arch/x86/kvm/vmx/vmx_ops.h | 7 +++++--
 tools/lib/bpf/libbpf.c     | 2 +-
 2 files changed, 6 insertions(+), 3 deletions(-)
Signature · 1 line
2.54.0
#1 lore raw

PATCH 1/2 tools/lib/bpf: fix const-qualifier discard in resolve_full_path

From: Clark Williams <[email protected]>

strchr() now propagates const when passed a const char * argument in newer GCC/glibc combinations, causing -Werror=discarded-qualifiers to fire on the assignment to next_path. Declare next_path as const char * since it is only used for pointer arithmetic, never written through.

Assisted-By Claude Sonnet 4.6 <[email protected]>
---
 tools/lib/bpf/libbpf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/lib/bpf/libbpf.c +1 -1
index 7bd6aff6e260..33b214a91338 100644
@@ -10748,7 +10748,7 @@ static int resolve_full_path(const char *file, char *result, size_t result_sz)
 		if (!search_paths[i])
 			continue;
 		for (s = search_paths[i]; s != NULL; s = strchr(s, ':')) {
-			char *next_path;
+			const char *next_path;
 			int seg_len;
 
 			if (s[0] == ':')
Signature · 1 line
2.54.0
#2 lore raw

PATCH 2/2 kvm/vmx: guard regparm(0) on vmread_error_trampoline for x86_32 only

In reply to Clark Williams

From: Clark Williams <[email protected]>

regparm(0) overrides the kernel's -mregparm=3 convention on x86-32 so that vmread_error_trampoline receives its arguments on the stack, matching the inline asm callers that push args before the call. On x86-64 the attribute is a no-op and newer GCC now emits -Wattributes for it, which becomes a build error under -Werror. Guard it with CONFIG_X86_32.

Assisted-By Claude Sonnet 4.6 <[email protected]>
---
 arch/x86/kvm/vmx/vmx_ops.h | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
arch/x86/kvm/vmx/vmx_ops.h +5 -2
index 5edab28dfb2e..50328be40b2b 100644
@@ -11,8 +11,11 @@
 #include "../x86.h"
 
 void vmread_error(unsigned long field, bool fault);
-__attribute__((regparm(0))) void vmread_error_trampoline(unsigned long field,
-							 bool fault);
+/* regparm(0) overrides -mregparm=3 so args are stack-passed, matching asm callers */
+#ifdef CONFIG_X86_32
+__attribute__((regparm(0)))
+#endif
+void vmread_error_trampoline(unsigned long field, bool fault);
 void vmwrite_error(unsigned long field, unsigned long value);
 void vmclear_error(struct vmcs *vmcs, u64 phys_addr);
 void vmptrld_error(struct vmcs *vmcs, u64 phys_addr);
Signature · 1 line
2.54.0
maintainer
#3 lore raw
In reply to Clark Williams
Quoted 21 lines · Clark Williams

GCC 16.1.1 introduces stricter diagnostics that surface two latent issues in the 6.1.y stable tree, both of which become hard errors under -Werror:

1. -Wattributes on regparm(0) for x86-64 arch/x86/kvm/vmx/vmx_ops.h applies __attribute__((regparm(0))) to vmread_error_trampoline(). On x86-32 this is intentional: it overrides the kernel's -mregparm=3 convention so the trampoline receives its arguments on the stack, matching the inline-asm callers that push args before the call. On x86-64 the attribute has always been a no-op (the SysV ABI already passes arguments in registers), but older GCC silently accepted it. GCC 16.1.1 now warns, which -Werror promotes to a build failure. The fix guards the attribute with #ifdef CONFIG_X86_32.

2. -Wdiscarded-qualifiers in libbpf
In tools/lib/bpf/libbpf.c, resolve_full_path() assigns the result of strchr() on a const char * to a plain char * variable. Newer GCC/glibc combinations propagate the const qualifier through strchr(), so this assignment now triggers -Werror=discarded-qualifiers. Since the variable (next_path) is only used for pointer arithmetic and is never written through, the fix is simply to declare it const char *.

Quoted 13 lines

Clark Williams (2):
tools/lib/bpf: fix const-qualifier discard in resolve_full_path kvm/vmx: guard regparm(0) on vmread_error_trampoline for x86_32 only

 arch/x86/kvm/vmx/vmx_ops.h | 7 +++++--
 tools/lib/bpf/libbpf.c     | 2 +-
 2 files changed, 6 insertions(+), 3 deletions(-)
Signature · 1 line
2.54.0

<formletter>

This is not the correct way to submit patches for inclusion in the stable kernel tree. Please read:
https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html
for how to do this properly.

</formletter>