KVM: arm64: sys_regs: disable -Wuninitialized-const-pointer warning
Subsystems (3)
PATCH RESEND v2 1/1 KVM: arm64: sys_regs: disable -Wuninitialized-const-pointer warning
A new warning in Clang 22 [1] complains that @clidr passed to get_clidr_el1() is an uninitialized const pointer. get_clidr_el1() doesn't really care since it casts away the const-ness anyways -- it is a false positive.
This patch isn't needed for anything past 6.1 as this code section was reworked in Commit 7af0c2534f4c ("KVM: arm64: Normalize cache configuration") which incidentally removed the aforementioned warning. Since there is no upstream equivalent, this patch just needs to be applied to 6.1.
Disable this warning for sys_regs.o instead of backporting the patches from 6.2+ that modified this code area.
---
Changes in v2:
- disable warning for TU instead of initialising the struct
- update commit message
- Link to v1: https://lore.kernel.org/all/[email protected]/
- Link to v1 resend (sent wrong diff, thanks Nathan): https://lore.kernel.org/all/[email protected]/
--- arch/arm64/kvm/Makefile | 3 +++ 1 file changed, 3 insertions(+)
arch/arm64/kvm/Makefile +3 -0
@@ -24,6 +24,9 @@ kvm-y += arm.o mmu.o mmio.o psci.o hypercalls.o pvtime.o \ kvm-$(CONFIG_HW_PERF_EVENTS) += pmu-emul.o pmu.o +# Work around a false positive Clang 22 -Wuninitialized-const-pointer warning +CFLAGS_sys_regs.o := $(call cc-disable-warning, uninitialized-const-pointer) + always-y := hyp_constants.h hyp-constants.s define rule_gen_hyp_constants
---
base-commit: 830b3c68c1fb1e9176028d02ef86f3cf76aa2476
change-id: 20250728-stable-disable-unit-ptr-warn-281fee82539c
Best regards,
--
Justin Stitt <[email protected]>
Quoted 4 lines · Justin Stitt
A new warning in Clang 22 [1] complains that @clidr passed to
get_clidr_el1()is an uninitialized const pointer.get_clidr_el1()doesn't really care since it casts away the const-ness anyways -- it is a false positive.
<snip>
Signature · 1 line
Tiffany Y. Yang
Patch "KVM: arm64: sys_regs: disable -Wuninitialized-const-pointer warning" has been added to the 6.1-stable tree
In reply to Justin StittThis is a note to let you know that I've just added the patch titled
KVM: arm64: sys_regs: disable -Wuninitialized-const-pointer warning
to the 6.1-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
kvm-arm64-sys_regs-disable-wuninitialized-const-pointer-warning.patch
and it can be found in the queue-6.1 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
From [email protected] Thu Jan 8 14:27:57 2026
From: Justin Stitt <[email protected]>
Date: Fri, 05 Dec 2025 14:51:41 -0800
Subject: KVM: arm64: sys_regs: disable -Wuninitialized-const-pointer warning
To: Marc Zyngier <[email protected]>, Oliver Upton <[email protected]>, Alexandru Elisei <[email protected]>, Joey Gouly <[email protected]>, Suzuki K Poulose <[email protected]>, Catalin Marinas <[email protected]>, Zenghui Yu <[email protected]>, Will Deacon <[email protected]>, Nathan Chancellor <[email protected]>, Christopher Covington <[email protected]>
Cc: [email protected], [email protected], [email protected], [email protected], [email protected], Justin Stitt <[email protected]>
Message-ID: <20251205-stable-disable-unit-ptr-warn-v2-1-cec53a8f736b@google.com>
From: Justin Stitt <[email protected]>
A new warning in Clang 22 [1] complains that @clidr passed to get_clidr_el1() is an uninitialized const pointer. get_clidr_el1() doesn't really care since it casts away the const-ness anyways -- it is a false positive.
This patch isn't needed for anything past 6.1 as this code section was reworked in Commit 7af0c2534f4c ("KVM: arm64: Normalize cache configuration") which incidentally removed the aforementioned warning. Since there is no upstream equivalent, this patch just needs to be applied to 6.1.
Disable this warning for sys_regs.o instead of backporting the patches from 6.2+ that modified this code area.
--- arch/arm64/kvm/Makefile | 3 +++ 1 file changed, 3 insertions(+)
arch/arm64/kvm/Makefile +3 -0
@@ -24,6 +24,9 @@ kvm-y += arm.o mmu.o mmio.o psci.o hyper kvm-$(CONFIG_HW_PERF_EVENTS) += pmu-emul.o pmu.o +# Work around a false positive Clang 22 -Wuninitialized-const-pointer warning +CFLAGS_sys_regs.o := $(call cc-disable-warning, uninitialized-const-pointer) + always-y := hyp_constants.h hyp-constants.s define rule_gen_hyp_constants
Patches currently in stable-queue which might be from [email protected] are
queue-6.1/kvm-arm64-sys_regs-disable-wuninitialized-const-pointer-warning.patch