Linux Kernel Selftest development
 help / color / mirror / Atom feed
From: Marc Zyngier <maz@kernel.org>
To: Dan Carpenter <dan.carpenter@linaro.org>
Cc: Ricardo Koller <ricarkol@google.com>,
	Oliver Upton <oliver.upton@linux.dev>,
	Joey Gouly <joey.gouly@arm.com>,
	Suzuki K Poulose <suzuki.poulose@arm.com>,
	Zenghui Yu <yuzenghui@huawei.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Shuah Khan <shuah@kernel.org>, Andrew Jones <drjones@redhat.com>,
	linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev,
	kvm@vger.kernel.org, linux-kselftest@vger.kernel.org,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] KVM: selftests: Fix a couple "prio" signedness bugs
Date: Fri, 21 Mar 2025 17:04:22 +0000	[thread overview]
Message-ID: <87cyeaqprd.wl-maz@kernel.org> (raw)
In-Reply-To: <ca579322-dc9d-4300-bd74-7e9240e930c7@stanley.mountain>

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.

      reply	other threads:[~2025-03-21 17:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-21 14:32 [PATCH] KVM: selftests: Fix a couple "prio" signedness bugs Dan Carpenter
2025-03-21 17:04 ` Marc Zyngier [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87cyeaqprd.wl-maz@kernel.org \
    --to=maz@kernel.org \
    --cc=dan.carpenter@linaro.org \
    --cc=drjones@redhat.com \
    --cc=joey.gouly@arm.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.linux.dev \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=oliver.upton@linux.dev \
    --cc=pbonzini@redhat.com \
    --cc=ricarkol@google.com \
    --cc=shuah@kernel.org \
    --cc=suzuki.poulose@arm.com \
    --cc=yuzenghui@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox