* [PATCH] kvm: arm64: use BUG() instead of BUG_ON(1)
@ 2025-08-07 7:21 Arnd Bergmann
2025-08-07 15:56 ` Nathan Chancellor
2025-08-08 17:51 ` Oliver Upton
0 siblings, 2 replies; 3+ messages in thread
From: Arnd Bergmann @ 2025-08-07 7:21 UTC (permalink / raw)
To: Marc Zyngier, Oliver Upton, Catalin Marinas, Will Deacon,
Nathan Chancellor
Cc: Arnd Bergmann, Joey Gouly, Suzuki K Poulose, Zenghui Yu,
Nick Desaulniers, Bill Wendling, Justin Stitt, linux-arm-kernel,
kvmarm, linux-kernel, llvm
From: Arnd Bergmann <arnd@arndb.de>
The BUG_ON() macro adds a little bit of complexity over BUG(), and in
some cases this ends up confusing the compiler's control flow analysis
in a way that results in a warning. This one now shows up with clang-21:
arch/arm64/kvm/vgic/vgic-mmio.c:1094:3: error: variable 'len' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
1094 | BUG_ON(1);
Change both instances of BUG_ON(1) to a plain BUG() in the arm64 kvm
code, to avoid the false-positive warning.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
arch/arm64/kvm/hyp/nvhe/list_debug.c | 2 +-
arch/arm64/kvm/vgic/vgic-mmio.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/arm64/kvm/hyp/nvhe/list_debug.c b/arch/arm64/kvm/hyp/nvhe/list_debug.c
index 46a2d4f2b3c6..baa6260f88dc 100644
--- a/arch/arm64/kvm/hyp/nvhe/list_debug.c
+++ b/arch/arm64/kvm/hyp/nvhe/list_debug.c
@@ -17,7 +17,7 @@ static inline __must_check bool nvhe_check_data_corruption(bool v)
bool corruption = unlikely(condition); \
if (corruption) { \
if (IS_ENABLED(CONFIG_BUG_ON_DATA_CORRUPTION)) { \
- BUG_ON(1); \
+ BUG(); \
} else \
WARN_ON(1); \
} \
diff --git a/arch/arm64/kvm/vgic/vgic-mmio.c b/arch/arm64/kvm/vgic/vgic-mmio.c
index e416e433baff..a573b1f0c6cb 100644
--- a/arch/arm64/kvm/vgic/vgic-mmio.c
+++ b/arch/arm64/kvm/vgic/vgic-mmio.c
@@ -1091,7 +1091,7 @@ int vgic_register_dist_iodev(struct kvm *kvm, gpa_t dist_base_address,
len = vgic_v3_init_dist_iodev(io_device);
break;
default:
- BUG_ON(1);
+ BUG();
}
io_device->base_addr = dist_base_address;
--
2.39.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] kvm: arm64: use BUG() instead of BUG_ON(1)
2025-08-07 7:21 [PATCH] kvm: arm64: use BUG() instead of BUG_ON(1) Arnd Bergmann
@ 2025-08-07 15:56 ` Nathan Chancellor
2025-08-08 17:51 ` Oliver Upton
1 sibling, 0 replies; 3+ messages in thread
From: Nathan Chancellor @ 2025-08-07 15:56 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Marc Zyngier, Oliver Upton, Catalin Marinas, Will Deacon,
Arnd Bergmann, Joey Gouly, Suzuki K Poulose, Zenghui Yu,
Nick Desaulniers, Bill Wendling, Justin Stitt, linux-arm-kernel,
kvmarm, linux-kernel, llvm
On Thu, Aug 07, 2025 at 09:21:28AM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> The BUG_ON() macro adds a little bit of complexity over BUG(), and in
> some cases this ends up confusing the compiler's control flow analysis
> in a way that results in a warning. This one now shows up with clang-21:
>
> arch/arm64/kvm/vgic/vgic-mmio.c:1094:3: error: variable 'len' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
> 1094 | BUG_ON(1);
>
> Change both instances of BUG_ON(1) to a plain BUG() in the arm64 kvm
> code, to avoid the false-positive warning.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Yeah I had responded to a build report around this but I never followed
up on seeing if it got fixed.
https://lore.kernel.org/20250714171559.GA1364710@ax162/
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
> ---
> arch/arm64/kvm/hyp/nvhe/list_debug.c | 2 +-
> arch/arm64/kvm/vgic/vgic-mmio.c | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm64/kvm/hyp/nvhe/list_debug.c b/arch/arm64/kvm/hyp/nvhe/list_debug.c
> index 46a2d4f2b3c6..baa6260f88dc 100644
> --- a/arch/arm64/kvm/hyp/nvhe/list_debug.c
> +++ b/arch/arm64/kvm/hyp/nvhe/list_debug.c
> @@ -17,7 +17,7 @@ static inline __must_check bool nvhe_check_data_corruption(bool v)
> bool corruption = unlikely(condition); \
> if (corruption) { \
> if (IS_ENABLED(CONFIG_BUG_ON_DATA_CORRUPTION)) { \
> - BUG_ON(1); \
> + BUG(); \
> } else \
> WARN_ON(1); \
> } \
> diff --git a/arch/arm64/kvm/vgic/vgic-mmio.c b/arch/arm64/kvm/vgic/vgic-mmio.c
> index e416e433baff..a573b1f0c6cb 100644
> --- a/arch/arm64/kvm/vgic/vgic-mmio.c
> +++ b/arch/arm64/kvm/vgic/vgic-mmio.c
> @@ -1091,7 +1091,7 @@ int vgic_register_dist_iodev(struct kvm *kvm, gpa_t dist_base_address,
> len = vgic_v3_init_dist_iodev(io_device);
> break;
> default:
> - BUG_ON(1);
> + BUG();
> }
>
> io_device->base_addr = dist_base_address;
> --
> 2.39.5
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] kvm: arm64: use BUG() instead of BUG_ON(1)
2025-08-07 7:21 [PATCH] kvm: arm64: use BUG() instead of BUG_ON(1) Arnd Bergmann
2025-08-07 15:56 ` Nathan Chancellor
@ 2025-08-08 17:51 ` Oliver Upton
1 sibling, 0 replies; 3+ messages in thread
From: Oliver Upton @ 2025-08-08 17:51 UTC (permalink / raw)
To: Marc Zyngier, Catalin Marinas, Will Deacon, Nathan Chancellor,
Arnd Bergmann
Cc: Oliver Upton, Arnd Bergmann, Joey Gouly, Suzuki K Poulose,
Zenghui Yu, Nick Desaulniers, Bill Wendling, Justin Stitt,
linux-arm-kernel, kvmarm, linux-kernel, llvm
On Thu, 07 Aug 2025 09:21:28 +0200, Arnd Bergmann wrote:
> The BUG_ON() macro adds a little bit of complexity over BUG(), and in
> some cases this ends up confusing the compiler's control flow analysis
> in a way that results in a warning. This one now shows up with clang-21:
>
> arch/arm64/kvm/vgic/vgic-mmio.c:1094:3: error: variable 'len' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
> 1094 | BUG_ON(1);
>
> [...]
Applied to fixes, thanks!
[1/1] kvm: arm64: use BUG() instead of BUG_ON(1)
https://git.kernel.org/kvmarm/kvmarm/c/700d6868fee2
--
Best,
Oliver
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-08-08 17:51 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-07 7:21 [PATCH] kvm: arm64: use BUG() instead of BUG_ON(1) Arnd Bergmann
2025-08-07 15:56 ` Nathan Chancellor
2025-08-08 17:51 ` Oliver Upton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).