public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Marc Zyngier <maz@kernel.org>
To: Maximilian Dittgen <mdittgen@amazon.de>
Cc: <epetron@amazon.de>, <kvm@vger.kernel.org>,
	<kvmarm@lists.linux.dev>, <linux-arm-kernel@lists.infradead.org>,
	<linux-kselftest@vger.kernel.org>, <mdittgen@amazon.com>,
	<nh-open-source@amazon.com>, <oliver.upton@linux.dev>,
	<pbonzini@redhat.com>, <shuah@kernel.org>
Subject: Re: [PATCH] KVM: selftests: fix ITS collection target addresses in vgic_lpi_stress
Date: Mon, 20 Oct 2025 14:01:15 +0100	[thread overview]
Message-ID: <86ms5lwwv8.wl-maz@kernel.org> (raw)
In-Reply-To: <20251020121220.83972-1-mdittgen@amazon.de>

On Mon, 20 Oct 2025 13:12:20 +0100,
Maximilian Dittgen <mdittgen@amazon.de> wrote:
> 
> On Fri, 17 Oct 2025 19:06:25 +0200,
> Marc Zyngier <maz@kernel.org> wrote:
> >
> >	  * We use linear CPU numbers for redistributor addressing,
> >	  * so GITS_TYPER.PTA is 0.
> >
> > It is not an address.
> 
> The issue is that its_encode_target in selftests is designed for
> physical redistriubtor addresses (GITS_TYPER.PTA = 1) and thus

No. Please read the spec.

> performs a right shift by 16 bits:
> 
> 		its_mask_encode(&cmd->raw_cmd[2], target_addr >> 16, 51, 16);
> 
> When the vgic_lpi_stress selftest passes in a linear vCPU id as
> the redistributor address (GITS_TYPER.PTA = 0 behavior),
> The its_encode_target function shifts the CPU numbers 16 bits right,
> functionally zeroing them.
> 
> We need to either:
> - Align this specific selftest with GITS_TYPER.PTA = 0 and not use
>     its_encode_target to encode the target vCPU id. Instead have a
>     dedicated encode function for the use case without a bit shift.
> - Align all selftests with GITS_TYPER.PTA = 0 and refactor
>     its_encode_target to skip the bit shift altogether.
> - Align selftests with GITS_TYPER.PTA = 1 and pass a redistributor
>     address, not a vCPU id, into its_send_mapc_cmd().

What part of "GITS_TYPER.PTA is 0" did you miss?

>
> Otherwise, the selftest's current behavior incorrectly maps all
> collections to target vCPU 0.

To be clear: I don't object to the patch. I object to the nonsensical
commit message.

You cannot say "I'm replacing the vcpu_id with an address". That's not
for you to decide, as the emulated HW is *imposing* that decision on
you. You don't even have the addresses at which the RDs are. You are
merely *reformatting* the vcpu_id to fit a field that can *also*
contain a 64kB-aligned address *when GITS_TYPER.PTA==1*. See 5.3.1 in
the GICv3 spec.

And yes, what you have is the correct fix. Just wrap it as a helper
(I'd suggest procnum_to_rdbase(), if you need a name for it).

This test also violate the architecture by not performing a SYNC after
any command, which would also require the use of a properly formatted
target field. But hey, correctness is overrated.

Thanks,

	M.

-- 
Without deviation from the norm, progress is not possible.

  reply	other threads:[~2025-10-20 13:01 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-17 16:19 [PATCH] KVM: selftests: fix ITS collection target addresses in vgic_lpi_stress Maximilian Dittgen
2025-10-17 17:06 ` Marc Zyngier
2025-10-20 12:12   ` Maximilian Dittgen
2025-10-20 13:01     ` Marc Zyngier [this message]
2025-10-20 15:13       ` Maximilian Dittgen

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=86ms5lwwv8.wl-maz@kernel.org \
    --to=maz@kernel.org \
    --cc=epetron@amazon.de \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.linux.dev \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=mdittgen@amazon.com \
    --cc=mdittgen@amazon.de \
    --cc=nh-open-source@amazon.com \
    --cc=oliver.upton@linux.dev \
    --cc=pbonzini@redhat.com \
    --cc=shuah@kernel.org \
    /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