Re: [PATCH] KVM: selftests: fix ITS collection target addresses in vgic_lpi_stress

Maximilian Dittgen
2025-10-20T12:12:58Z

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
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().

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

Thanks,
Maximilian