[PATCH 01/16] KVM: arm64: selftests: Inject an abort before a vCPU's first run

From: Fuad Tabba

Date: Wed Nov 04 2026 - 03:49:03 EST


KVM commits an external abort injected with KVM_SET_VCPU_EVENTS
immediately, even before the vCPU's first run. For a normal VM on a pKVM
host that path panicked the hypervisor until commit a2bb5f5c67a95
("KVM: arm64: Pin the host vCPU before adjusting its PC under pKVM"). No
test injects before the first run.

Add one, checking that the guest takes the abort at its entry point.

Signed-off-by: Fuad Tabba <fuad.tabba@xxxxxxxxx>
---
.../selftests/kvm/arm64/external_aborts.c | 21 +++++++++++++++++++
1 file changed, 21 insertions(+)

diff --git a/tools/testing/selftests/kvm/arm64/external_aborts.c b/tools/testing/selftests/kvm/arm64/external_aborts.c
index 1a858d0d82968..45c9300b2ca0e 100644
--- a/tools/testing/selftests/kvm/arm64/external_aborts.c
+++ b/tools/testing/selftests/kvm/arm64/external_aborts.c
@@ -113,6 +113,26 @@ static void vcpu_run_expect_sync(struct kvm_vcpu *vcpu)
__vcpu_run_expect(vcpu, UCALL_SYNC);
}

+static void test_sea_before_run_guest(void)
+{
+ GUEST_FAIL("Guest ran before taking the injected abort");
+}
+
+/* Test that an abort injected before the vCPU's first run is taken at its entry point. */
+static void test_sea_before_run(void)
+{
+ struct kvm_vcpu *vcpu;
+ struct kvm_vm *vm = vm_create_with_dabt_handler(&vcpu, test_sea_before_run_guest,
+ expect_sea_handler);
+
+ expected_abort_pc = (u64)test_sea_before_run_guest;
+ sync_global_to_guest(vm, expected_abort_pc);
+
+ vcpu_inject_sea(vcpu);
+ vcpu_run_expect_done(vcpu);
+ kvm_vm_free(vm);
+}
+
extern char test_mmio_abort_insn;

static noinline void test_mmio_abort_guest(void)
@@ -420,6 +440,7 @@ static void test_serror_amo(void)

int main(void)
{
+ test_sea_before_run();
test_mmio_abort();
test_mmio_nisv();
test_mmio_nisv_abort();
--
2.47.3