From: Maximilian Dittgen <mdittgen@amazon.de>
To: <maz@kernel.org>, <oliver.upton@linux.dev>
Cc: <pbonzini@redhat.com>, <shuah@kernel.org>,
<linux-arm-kernel@lists.infradead.org>, <kvmarm@lists.linux.dev>,
<linux-kselftest@vger.kernel.org>, <kvm@vger.kernel.org>,
<mdittgen@amazon.de>, <lilitj@amazon.de>, <sauravsc@amazon.de>,
<nh-open-source@amazon.com>
Subject: [RFC PATCH 10/13] KVM: selftests: fix MAPC RDbase target formatting in vgic_lpi_stress
Date: Thu, 20 Nov 2025 15:02:59 +0100 [thread overview]
Message-ID: <20251120140305.63515-11-mdittgen@amazon.de> (raw)
In-Reply-To: <20251120140305.63515-1-mdittgen@amazon.de>
Since GITS_TYPER.PTA == 0, the ITS MAPC command demands a CPU ID,
rather than a physical redistributor address, for its RDbase
command argument.
As such, when MAPC-ing guest ITS collections, vgic_lpi_stress iterates
over CPU IDs in the range [0, nr_cpus), passing them as the RDbase
vcpu_id argument to its_send_mapc_cmd().
However, its_encode_target() in the its_send_mapc_cmd() selftest
handler expects RDbase arguments to have a 16 bit offset, as shown
by the 16-bit target_addr right shift its implementation:
its_mask_encode(&cmd->raw_cmd[2], target_addr >> 16, 51, 16)
At the moment, all CPU IDs passed into its_send_mapc_cmd() have no
offset, therefore becoming 0x0 after the bit shift. Thus, when
vgic_its_cmd_handle_mapc() receives the ITS command in vgic-its.c,
it always interprets the RDbase target CPU as CPU 0. All interrupts
sent to collections will be processed by vCPU 0, which defeats the
purpose of this multi-vCPU test.
Fix by creating procnum_to_rdbase() helper function, which left-shifts
the vCPU parameter received by its_send_mapc_cmd 16 bits before passing
it to its_encode_target for encoding.
Signed-off-by: Maximilian Dittgen <mdittgen@amazon.de>
---
This patch has already been merged as a fix in Linux 6.18-rc6 as a24f7af.
---
tools/testing/selftests/kvm/lib/arm64/gic_v3_its.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/kvm/lib/arm64/gic_v3_its.c b/tools/testing/selftests/kvm/lib/arm64/gic_v3_its.c
index aec1b69a4de3..7f9fdcf42ae6 100644
--- a/tools/testing/selftests/kvm/lib/arm64/gic_v3_its.c
+++ b/tools/testing/selftests/kvm/lib/arm64/gic_v3_its.c
@@ -15,6 +15,8 @@
#include "gic_v3.h"
#include "processor.h"
+#define GITS_COLLECTION_TARGET_SHIFT 16
+
static u64 its_read_u64(unsigned long offset)
{
return readq_relaxed(GITS_BASE_GVA + offset);
@@ -163,6 +165,11 @@ static void its_encode_collection(struct its_cmd_block *cmd, u16 col)
its_mask_encode(&cmd->raw_cmd[2], col, 15, 0);
}
+static u64 procnum_to_rdbase(u32 vcpu_id)
+{
+ return vcpu_id << GITS_COLLECTION_TARGET_SHIFT;
+}
+
#define GITS_CMDQ_POLL_ITERATIONS 0
static void its_send_cmd(void *cmdq_base, struct its_cmd_block *cmd)
@@ -217,7 +224,7 @@ void its_send_mapc_cmd(void *cmdq_base, u32 vcpu_id, u32 collection_id, bool val
its_encode_cmd(&cmd, GITS_CMD_MAPC);
its_encode_collection(&cmd, collection_id);
- its_encode_target(&cmd, vcpu_id);
+ its_encode_target(&cmd, procnum_to_rdbase(vcpu_id));
its_encode_valid(&cmd, valid);
its_send_cmd(cmdq_base, &cmd);
--
2.50.1 (Apple Git-155)
Amazon Web Services Development Center Germany GmbH
Tamara-Danz-Str. 13
10243 Berlin
Geschaeftsfuehrung: Christian Schlaeger, Christof Hellmis
Eingetragen am Amtsgericht Charlottenburg unter HRB 257764 B
Sitz: Berlin
Ust-ID: DE 365 538 597
next prev parent reply other threads:[~2025-11-20 14:06 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-20 14:02 [RFC PATCH 00/13] Introduce per-vCPU vLPI injection control API Maximilian Dittgen
2025-11-20 14:02 ` [RFC PATCH 01/13] KVM: Introduce config option for per-vCPU vLPI enablement Maximilian Dittgen
2025-11-20 16:18 ` Marc Zyngier
2025-11-20 14:02 ` [RFC PATCH 02/13] KVM: arm64: Disable auto vCPU vPE assignment with per-vCPU vLPI config Maximilian Dittgen
2025-11-20 14:02 ` [RFC PATCH 03/13] KVM: arm64: Refactor out locked section of kvm_vgic_v4_set_forwarding() Maximilian Dittgen
2025-11-20 14:02 ` [RFC PATCH 04/13] KVM: arm64: Implement vLPI QUERY ioctl for per-vCPU vLPI injection API Maximilian Dittgen
2025-11-20 14:02 ` [RFC PATCH 05/13] KVM: arm64: Implement vLPI ENABLE " Maximilian Dittgen
2025-11-20 14:02 ` [RFC PATCH 06/13] KVM: arm64: Resolve race between vCPU scheduling and vLPI enablement Maximilian Dittgen
2025-11-20 14:02 ` [RFC PATCH 07/13] KVM: arm64: Implement vLPI DISABLE ioctl for per-vCPU vLPI Injection API Maximilian Dittgen
2025-11-20 14:02 ` [RFC PATCH 08/13] KVM: arm64: Make per-vCPU vLPI control ioctls atomic Maximilian Dittgen
2025-11-20 14:02 ` [RFC PATCH 09/13] KVM: arm64: Couple vSGI enablement with per-vCPU vPE allocation Maximilian Dittgen
2025-11-20 14:02 ` Maximilian Dittgen [this message]
2025-11-20 14:03 ` [RFC PATCH 11/13] KVM: Ioctl to set up userspace-injected MSIs as software-bypassing vLPIs Maximilian Dittgen
2025-11-20 14:03 ` [RFC PATCH 12/13] KVM: arm64: selftests: Add support for stress testing direct-injected vLPIs Maximilian Dittgen
2025-11-20 14:03 ` [RFC PATCH 13/13] KVM: arm64: selftests: Add test for per-vCPU vLPI control API Maximilian Dittgen
2025-11-20 14:40 ` [RFC PATCH 00/13] Introduce per-vCPU vLPI injection " Marc Zyngier
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=20251120140305.63515-11-mdittgen@amazon.de \
--to=mdittgen@amazon.de \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.linux.dev \
--cc=lilitj@amazon.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=maz@kernel.org \
--cc=nh-open-source@amazon.com \
--cc=oliver.upton@linux.dev \
--cc=pbonzini@redhat.com \
--cc=sauravsc@amazon.de \
--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;
as well as URLs for NNTP newsgroup(s).