[PATCH 6.1.y RESEND] KVM: arm64: silence -Wuninitialized-const-pointer warning

Justin Stitt posted 1 patch 2 weeks ago
arch/arm64/kvm/sys_regs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH 6.1.y RESEND] KVM: arm64: silence -Wuninitialized-const-pointer warning
Posted by Justin Stitt 2 weeks ago
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.

Silence the warning by initializing the struct.

This patch won't apply to anything past v6.1 as this code section was
reworked in Commit 7af0c2534f4c ("KVM: arm64: Normalize cache
configuration"). There is no upstream equivalent so this patch only
needs to be applied (stable only) to 6.1.

Cc: stable@vger.kernel.org
Fixes: 7c8c5e6a9101e ("arm64: KVM: system register handling")
Link: https://github.com/llvm/llvm-project/commit/00dacf8c22f065cb52efb14cd091d441f19b319e [1]
Signed-off-by: Justin Stitt <justinstitt@google.com>
---
Resending this with Nathan's RB tag, an updated commit log and better
recipients from checkpatch.pl.

I've also sent a similar patch resend for 5.15
---
 arch/arm64/kvm/sys_regs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c
index f4a7c5abcbca..d7ebd7387221 100644
--- a/arch/arm64/kvm/sys_regs.c
+++ b/arch/arm64/kvm/sys_regs.c
@@ -2948,7 +2948,7 @@ int kvm_sys_reg_table_init(void)
 {
 	bool valid = true;
 	unsigned int i;
-	struct sys_reg_desc clidr;
+	struct sys_reg_desc clidr = {0};
 
 	/* Make sure tables are unique and in order. */
 	valid &= check_sysreg_table(sys_reg_descs, ARRAY_SIZE(sys_reg_descs), false);

---
base-commit: 830b3c68c1fb1e9176028d02ef86f3cf76aa2476
change-id: 20250724-b4-clidr-unint-const-ptr-7edb960bc3bd

Best regards,
--
Justin Stitt <justinstitt@google.com>
Re: [PATCH 6.1.y RESEND] KVM: arm64: silence -Wuninitialized-const-pointer warning
Posted by Justin Stitt 2 weeks ago
Quick correction:

On Thu, Dec 04, 2025 at 12:50:11PM -0800, Justin Stitt wrote:
> 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.
> 
> Silence the warning by initializing the struct.
> 
> This patch won't apply to anything past v6.1 as this code section was
> reworked in Commit 7af0c2534f4c ("KVM: arm64: Normalize cache
> configuration"). There is no upstream equivalent so this patch only
> needs to be applied (stable only) to 6.1.
> 
> Cc: stable@vger.kernel.org
> Fixes: 7c8c5e6a9101e ("arm64: KVM: system register handling")
> Link: https://github.com/llvm/llvm-project/commit/00dacf8c22f065cb52efb14cd091d441f19b319e [1]
> Signed-off-by: Justin Stitt <justinstitt@google.com>
> ---
> Resending this with Nathan's RB tag, an updated commit log and better
> recipients from checkpatch.pl.

My usage of $ b4 trailers must've not been correct because this 6.1
version didn't pick up Nathan's RB tag. Whoops! Hopefully whoever picks
this up can add that for me :)

<snip>
Re: [PATCH 6.1.y RESEND] KVM: arm64: silence -Wuninitialized-const-pointer warning
Posted by Nathan Chancellor 2 weeks ago
On Thu, Dec 04, 2025 at 12:53:58PM -0800, Justin Stitt wrote:
> Quick correction:
> 
> On Thu, Dec 04, 2025 at 12:50:11PM -0800, Justin Stitt wrote:
> > 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.
> > 
> > Silence the warning by initializing the struct.
> > 
> > This patch won't apply to anything past v6.1 as this code section was
> > reworked in Commit 7af0c2534f4c ("KVM: arm64: Normalize cache
> > configuration"). There is no upstream equivalent so this patch only
> > needs to be applied (stable only) to 6.1.
> > 
> > Cc: stable@vger.kernel.org
> > Fixes: 7c8c5e6a9101e ("arm64: KVM: system register handling")
> > Link: https://github.com/llvm/llvm-project/commit/00dacf8c22f065cb52efb14cd091d441f19b319e [1]
> > Signed-off-by: Justin Stitt <justinstitt@google.com>
> > ---
> > Resending this with Nathan's RB tag, an updated commit log and better
> > recipients from checkpatch.pl.
> 
> My usage of $ b4 trailers must've not been correct because this 6.1
> version didn't pick up Nathan's RB tag. Whoops! Hopefully whoever picks
> this up can add that for me :)

Looks like you resent the first iteration of this change [1] instead of
the second [2], hence why 'b4 trailers -u' did not work, since I never
reviewed the first iteration after Marc rejected it :)

Your 5.15 resend looks correct though.

[1]: https://lore.kernel.org/20250724-b4-clidr-unint-const-ptr-v1-1-67c4d620b6b6@google.com/
[2]: https://lore.kernel.org/20250728-stable-disable-unit-ptr-warn-v1-1-958be9b66520@google.com/

Cheers,
Nathan
Re: [PATCH 6.1.y RESEND] KVM: arm64: silence -Wuninitialized-const-pointer warning
Posted by Justin Stitt 1 week, 6 days ago
Hi,

On Thu, Dec 04, 2025 at 05:22:45PM -0700, Nathan Chancellor wrote:
> On Thu, Dec 04, 2025 at 12:53:58PM -0800, Justin Stitt wrote:
> > Quick correction:
> > 
> > On Thu, Dec 04, 2025 at 12:50:11PM -0800, Justin Stitt wrote:
> > > 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.
> > > 
> > > Silence the warning by initializing the struct.
> > > 
> > > This patch won't apply to anything past v6.1 as this code section was
> > > reworked in Commit 7af0c2534f4c ("KVM: arm64: Normalize cache
> > > configuration"). There is no upstream equivalent so this patch only
> > > needs to be applied (stable only) to 6.1.
> > > 
> > > Cc: stable@vger.kernel.org
> > > Fixes: 7c8c5e6a9101e ("arm64: KVM: system register handling")
> > > Link: https://github.com/llvm/llvm-project/commit/00dacf8c22f065cb52efb14cd091d441f19b319e [1]
> > > Signed-off-by: Justin Stitt <justinstitt@google.com>
> > > ---
> > > Resending this with Nathan's RB tag, an updated commit log and better
> > > recipients from checkpatch.pl.
> > 
> > My usage of $ b4 trailers must've not been correct because this 6.1
> > version didn't pick up Nathan's RB tag. Whoops! Hopefully whoever picks
> > this up can add that for me :)
> 
> Looks like you resent the first iteration of this change [1] instead of
> the second [2], hence why 'b4 trailers -u' did not work, since I never
> reviewed the first iteration after Marc rejected it :)
> 
> Your 5.15 resend looks correct though.
> 
> [1]: https://lore.kernel.org/20250724-b4-clidr-unint-const-ptr-v1-1-67c4d620b6b6@google.com/
> [2]: https://lore.kernel.org/20250728-stable-disable-unit-ptr-warn-v1-1-958be9b66520@google.com/

Thanks for spotting this, I got lost in my b4 branches. I've sent the v2
resend [1]. Hopefully all is good there :)

> 
> Cheers,
> Nathan

[1]: https://lore.kernel.org/r/20251205-stable-disable-unit-ptr-warn-v2-1-cec53a8f736b@google.com

Justin