* [PATCH] KVM: selftests: Fix a couple "prio" signedness bugs
@ 2025-03-21 14:32 Dan Carpenter
2025-03-21 17:04 ` Marc Zyngier
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2025-03-21 14:32 UTC (permalink / raw)
To: Ricardo Koller
Cc: Marc Zyngier, Oliver Upton, Joey Gouly, Suzuki K Poulose,
Zenghui Yu, Paolo Bonzini, Shuah Khan, Andrew Jones,
linux-arm-kernel, kvmarm, kvm, linux-kselftest, linux-kernel,
kernel-janitors
There is an assert which relies on "prio" to be signed.
GUEST_ASSERT(prio >= 0);
Change the type from uint32_t to int.
Fixes: 728fcc46d2c2 ("KVM: selftests: aarch64: Add test for restoring active IRQs")
Fixes: 0ad3ff4a6adc ("KVM: selftests: aarch64: Add preemption tests in vgic_irq")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
---
tools/testing/selftests/kvm/arm64/vgic_irq.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/kvm/arm64/vgic_irq.c b/tools/testing/selftests/kvm/arm64/vgic_irq.c
index f4ac28d53747..e89c0fc5eef3 100644
--- a/tools/testing/selftests/kvm/arm64/vgic_irq.c
+++ b/tools/testing/selftests/kvm/arm64/vgic_irq.c
@@ -294,7 +294,8 @@ static void guest_restore_active(struct test_args *args,
uint32_t first_intid, uint32_t num,
kvm_inject_cmd cmd)
{
- uint32_t prio, intid, ap1r;
+ uint32_t intid, ap1r;
+ int prio;
int i;
/*
@@ -362,7 +363,8 @@ static void test_inject_preemption(struct test_args *args,
uint32_t first_intid, int num,
kvm_inject_cmd cmd)
{
- uint32_t intid, prio, step = KVM_PRIO_STEPS;
+ uint32_t intid, step = KVM_PRIO_STEPS;
+ int prio;
int i;
/* Set the priorities of the first (KVM_NUM_PRIOS - 1) IRQs
--
2.47.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] KVM: selftests: Fix a couple "prio" signedness bugs
2025-03-21 14:32 [PATCH] KVM: selftests: Fix a couple "prio" signedness bugs Dan Carpenter
@ 2025-03-21 17:04 ` Marc Zyngier
0 siblings, 0 replies; 2+ messages in thread
From: Marc Zyngier @ 2025-03-21 17:04 UTC (permalink / raw)
To: Dan Carpenter
Cc: Ricardo Koller, Oliver Upton, Joey Gouly, Suzuki K Poulose,
Zenghui Yu, Paolo Bonzini, Shuah Khan, Andrew Jones,
linux-arm-kernel, kvmarm, kvm, linux-kselftest, linux-kernel,
kernel-janitors
Hey Dan,
On Fri, 21 Mar 2025 14:32:53 +0000,
Dan Carpenter <dan.carpenter@linaro.org> wrote:
>
> There is an assert which relies on "prio" to be signed.
>
> GUEST_ASSERT(prio >= 0);
>
> Change the type from uint32_t to int.
>
> Fixes: 728fcc46d2c2 ("KVM: selftests: aarch64: Add test for restoring active IRQs")
> Fixes: 0ad3ff4a6adc ("KVM: selftests: aarch64: Add preemption tests in vgic_irq")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
> ---
> tools/testing/selftests/kvm/arm64/vgic_irq.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/kvm/arm64/vgic_irq.c b/tools/testing/selftests/kvm/arm64/vgic_irq.c
> index f4ac28d53747..e89c0fc5eef3 100644
> --- a/tools/testing/selftests/kvm/arm64/vgic_irq.c
> +++ b/tools/testing/selftests/kvm/arm64/vgic_irq.c
> @@ -294,7 +294,8 @@ static void guest_restore_active(struct test_args *args,
> uint32_t first_intid, uint32_t num,
> kvm_inject_cmd cmd)
> {
> - uint32_t prio, intid, ap1r;
> + uint32_t intid, ap1r;
> + int prio;
> int i;
>
> /*
> @@ -362,7 +363,8 @@ static void test_inject_preemption(struct test_args *args,
> uint32_t first_intid, int num,
> kvm_inject_cmd cmd)
> {
> - uint32_t intid, prio, step = KVM_PRIO_STEPS;
> + uint32_t intid, step = KVM_PRIO_STEPS;
> + int prio;
> int i;
>
> /* Set the priorities of the first (KVM_NUM_PRIOS - 1) IRQs
I think this is going in the wrong direction. A GIC priority is an
unsigned 8bit value as per the architecture definition.
So the type used by the test the first place looks wrong (it is too
wide), and the assertion is pointless.
Thanks,
M.
--
Without deviation from the norm, progress is not possible.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-03-21 17:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-21 14:32 [PATCH] KVM: selftests: Fix a couple "prio" signedness bugs Dan Carpenter
2025-03-21 17:04 ` Marc Zyngier
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox