]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
KVM: selftests: SYNC after guest ITS setup in vgic_lpi_stress
authorMaximilian Dittgen <mdittgen@amazon.de>
Wed, 19 Nov 2025 13:57:44 +0000 (14:57 +0100)
committerOliver Upton <oupton@kernel.org>
Wed, 19 Nov 2025 20:38:59 +0000 (12:38 -0800)
vgic_lpi_stress sends MAPTI and MAPC commands during guest GIC setup to
map interrupt events to ITT entries and collection IDs to
redistributors, respectively.

We have no guarantee that the ITS will finish handling these mapping
commands before the selftest calls KVM_SIGNAL_MSI to inject LPIs to the
guest. If LPIs are injected before ITS mapping completes, the ITS cannot
properly pass the interrupt on to the redistributor.

Fix by adding a SYNC command to the selftests ITS library, then calling
SYNC after ITS mapping to ensure mapping completes before signal_lpi()
writes to GITS_TRANSLATER.

Signed-off-by: Maximilian Dittgen <mdittgen@amazon.de>
Link: https://msgid.link/20251119135744.68552-2-mdittgen@amazon.de
Signed-off-by: Oliver Upton <oupton@kernel.org>
tools/testing/selftests/kvm/arm64/vgic_lpi_stress.c
tools/testing/selftests/kvm/include/arm64/gic_v3_its.h
tools/testing/selftests/kvm/lib/arm64/gic_v3_its.c

index 687d04463983becddb22a10a62436e1c96b7246b..e857a605f577a73a371e62b74a34d1367e14729a 100644 (file)
@@ -118,6 +118,10 @@ static void guest_setup_gic(void)
 
        guest_setup_its_mappings();
        guest_invalidate_all_rdists();
+
+       /* SYNC to ensure ITS setup is complete */
+       for (cpuid = 0; cpuid < test_data.nr_cpus; cpuid++)
+               its_send_sync_cmd(test_data.cmdq_base_va, cpuid);
 }
 
 static void guest_code(size_t nr_lpis)
index 3722ed9c8f96ed1bee3361719a5bd106ca5428b3..58feef3eb386cb4efaeca27ecb7bf9878ffb3794 100644 (file)
@@ -15,5 +15,6 @@ void its_send_mapc_cmd(void *cmdq_base, u32 vcpu_id, u32 collection_id, bool val
 void its_send_mapti_cmd(void *cmdq_base, u32 device_id, u32 event_id,
                        u32 collection_id, u32 intid);
 void its_send_invall_cmd(void *cmdq_base, u32 collection_id);
+void its_send_sync_cmd(void *cmdq_base, u32 vcpu_id);
 
 #endif // __SELFTESTS_GIC_V3_ITS_H__
index 09f270545646933ea24c7b5f55e4d2093fac60f1..aec1b69a4de37dcc2a0204bd9eff3367de8e7cf1 100644 (file)
@@ -246,3 +246,13 @@ void its_send_invall_cmd(void *cmdq_base, u32 collection_id)
 
        its_send_cmd(cmdq_base, &cmd);
 }
+
+void its_send_sync_cmd(void *cmdq_base, u32 vcpu_id)
+{
+       struct its_cmd_block cmd = {};
+
+       its_encode_cmd(&cmd, GITS_CMD_SYNC);
+       its_encode_target(&cmd, procnum_to_rdbase(vcpu_id));
+
+       its_send_cmd(cmdq_base, &cmd);
+}