* Re: [PATCH v4] KVM: arm64: selftests: Check the pending SError state in external_aborts
2026-10-06 9:28 [PATCH v4] KVM: arm64: selftests: Check the pending SError state in external_aborts Fuad Tabba
@ 2026-10-06 13:17 ` Oliver Upton
2026-10-07 2:28 ` Itaru Kitayama
2026-10-07 12:16 ` Marc Zyngier
2 siblings, 0 replies; 4+ messages in thread
From: Oliver Upton @ 2026-10-06 13:17 UTC (permalink / raw)
To: Fuad Tabba
Cc: maz, kvmarm, linux-arm-kernel, linux-kernel, catalin.marinas,
will, joey.gouly, seiden, suzuki.poulose, yuzenghui, vdonnefort,
qperret, tabba
On Tue, Oct 06, 2026 at 10:28:41AM +0100, Fuad Tabba wrote:
> None of the external abort tests look at the vCPU events once the guest
> is done, so an SError left pending after the guest took it, or dropped
> while the guest had it masked, goes unnoticed.
>
> Read the vCPU events back at the end of every test that runs the guest.
> The SError must still be pending in the masked case, with the injected
> ESR when the vCPU has RAS, and no SError, injected or spurious, may be
> pending in any of the others.
>
> Signed-off-by: Fuad Tabba <fuad.tabba@linux.dev>
Reviewed-by: Oliver Upton <oupton@kernel.org>
Thanks,
Oliver
> ---
> The check that no SError is left pending after the guest took it is
> what fails without commit 3708f6342f01 ("KVM: arm64: Sync HCR_EL2.VSE
> back to the host vCPU under pKVM"), in kvmarm/next.
>
> Changes since v3 [1]:
> - Check the SError pending state at the end of every test that runs the
> guest, and assert it is still pending, with the injected ESR, in the
> masked case (Oliver [2]).
>
> [1] https://lore.kernel.org/all/20261005050349.836795-1-fuad.tabba@linux.dev/
> [2] https://lore.kernel.org/all/asNdAXGkxagm88Su@kernel.org/
>
> .../selftests/kvm/arm64/external_aborts.c | 20 +++++++++++++++++++
> 1 file changed, 20 insertions(+)
>
> diff --git a/tools/testing/selftests/kvm/arm64/external_aborts.c b/tools/testing/selftests/kvm/arm64/external_aborts.c
> index 7836756a38a6c..1a858d0d82968 100644
> --- a/tools/testing/selftests/kvm/arm64/external_aborts.c
> +++ b/tools/testing/selftests/kvm/arm64/external_aborts.c
> @@ -75,6 +75,17 @@ static void vcpu_inject_serror(struct kvm_vcpu *vcpu)
> vcpu_events_set(vcpu, &events);
> }
>
> +static void vcpu_assert_serror_pending(struct kvm_vcpu *vcpu, bool pending)
> +{
> + struct kvm_vcpu_events events;
> +
> + vcpu_events_get(vcpu, &events);
> + TEST_ASSERT_EQ(events.exception.serror_pending, pending);
> +
> + if (pending && vcpu_has_ras(vcpu))
> + TEST_ASSERT_EQ(events.exception.serror_esr, EXPECTED_SERROR_ISS);
> +}
> +
> static void __vcpu_run_expect(struct kvm_vcpu *vcpu, unsigned int cmd)
> {
> struct ucall uc;
> @@ -134,6 +145,7 @@ static void test_mmio_abort(void)
>
> vcpu_inject_sea(vcpu);
> vcpu_run_expect_done(vcpu);
> + vcpu_assert_serror_pending(vcpu, false);
> kvm_vm_free(vm);
> }
>
> @@ -162,6 +174,7 @@ static void test_mmio_nisv(void)
>
> TEST_ASSERT(_vcpu_run(vcpu), "Expected nonzero return code from KVM_RUN");
> TEST_ASSERT_EQ(errno, ENOSYS);
> + vcpu_assert_serror_pending(vcpu, false);
>
> kvm_vm_free(vm);
> }
> @@ -185,6 +198,7 @@ static void test_mmio_nisv_abort(void)
>
> vcpu_inject_sea(vcpu);
> vcpu_run_expect_done(vcpu);
> + vcpu_assert_serror_pending(vcpu, false);
> kvm_vm_free(vm);
> }
>
> @@ -212,6 +226,7 @@ static void test_serror_masked(void)
>
> vcpu_inject_serror(vcpu);
> vcpu_run_expect_done(vcpu);
> + vcpu_assert_serror_pending(vcpu, true);
> kvm_vm_free(vm);
> }
>
> @@ -247,6 +262,7 @@ static void test_serror(void)
>
> vcpu_inject_serror(vcpu);
> vcpu_run_expect_done(vcpu);
> + vcpu_assert_serror_pending(vcpu, false);
> kvm_vm_free(vm);
> }
>
> @@ -288,6 +304,7 @@ static void test_s1ptw_abort(void)
> *ptep |= bad_pa;
>
> vcpu_run_expect_done(vcpu);
> + vcpu_assert_serror_pending(vcpu, false);
> kvm_vm_free(vm);
> }
>
> @@ -313,6 +330,7 @@ static void test_serror_emulated(void)
> vcpu_run_expect_sync(vcpu);
> vcpu_inject_serror(vcpu);
> vcpu_run_expect_done(vcpu);
> + vcpu_assert_serror_pending(vcpu, false);
> kvm_vm_free(vm);
> }
>
> @@ -356,6 +374,7 @@ static void test_mmio_ease(void)
>
> vcpu_inject_sea(vcpu);
> vcpu_run_expect_done(vcpu);
> + vcpu_assert_serror_pending(vcpu, false);
> done:
> kvm_vm_free(vm);
> }
> @@ -395,6 +414,7 @@ static void test_serror_amo(void)
> vcpu_run_expect_sync(vcpu);
> vcpu_inject_serror(vcpu);
> vcpu_run_expect_done(vcpu);
> + vcpu_assert_serror_pending(vcpu, false);
> kvm_vm_free(vm);
> }
>
>
> base-commit: fa22cd9947fc245d71bc40482f7f78eb0d5a4af0
> --
> 2.39.5
>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH v4] KVM: arm64: selftests: Check the pending SError state in external_aborts
2026-10-06 9:28 [PATCH v4] KVM: arm64: selftests: Check the pending SError state in external_aborts Fuad Tabba
2026-10-06 13:17 ` Oliver Upton
@ 2026-10-07 2:28 ` Itaru Kitayama
2026-10-07 12:16 ` Marc Zyngier
2 siblings, 0 replies; 4+ messages in thread
From: Itaru Kitayama @ 2026-10-07 2:28 UTC (permalink / raw)
To: Fuad Tabba
Cc: maz, oupton, kvmarm, linux-arm-kernel, linux-kernel,
catalin.marinas, will, joey.gouly, seiden, suzuki.poulose,
yuzenghui, vdonnefort, qperret, tabba
On Tue, Oct 06, 2026 at 10:28:41AM +0100, Fuad Tabba wrote:
> None of the external abort tests look at the vCPU events once the guest
> is done, so an SError left pending after the guest took it, or dropped
> while the guest had it masked, goes unnoticed.
>
> Read the vCPU events back at the end of every test that runs the guest.
> The SError must still be pending in the masked case, with the injected
> ESR when the vCPU has RAS, and no SError, injected or spurious, may be
> pending in any of the others.
>
> Signed-off-by: Fuad Tabba <fuad.tabba@linux.dev>
> ---
> The check that no SError is left pending after the guest took it is
> what fails without commit 3708f6342f01 ("KVM: arm64: Sync HCR_EL2.VSE
> back to the host vCPU under pKVM"), in kvmarm/next.
Applied this fix cleanly on today's kvmarm/next and did run
extranl_aborts on a NVIDIA Grace system booted with the proper ACPI tables,
the program finished quietly.
Tested-by: Itaru Kitayama <itaru.kitayama@fujitsu.com>
Thanks,
Itaru.
>
> Changes since v3 [1]:
> - Check the SError pending state at the end of every test that runs the
> guest, and assert it is still pending, with the injected ESR, in the
> masked case (Oliver [2]).
>
> [1] https://lore.kernel.org/all/20261005050349.836795-1-fuad.tabba@linux.dev/
> [2] https://lore.kernel.org/all/asNdAXGkxagm88Su@kernel.org/
>
> .../selftests/kvm/arm64/external_aborts.c | 20 +++++++++++++++++++
> 1 file changed, 20 insertions(+)
>
> diff --git a/tools/testing/selftests/kvm/arm64/external_aborts.c b/tools/testing/selftests/kvm/arm64/external_aborts.c
> index 7836756a38a6c..1a858d0d82968 100644
> --- a/tools/testing/selftests/kvm/arm64/external_aborts.c
> +++ b/tools/testing/selftests/kvm/arm64/external_aborts.c
> @@ -75,6 +75,17 @@ static void vcpu_inject_serror(struct kvm_vcpu *vcpu)
> vcpu_events_set(vcpu, &events);
> }
>
> +static void vcpu_assert_serror_pending(struct kvm_vcpu *vcpu, bool pending)
> +{
> + struct kvm_vcpu_events events;
> +
> + vcpu_events_get(vcpu, &events);
> + TEST_ASSERT_EQ(events.exception.serror_pending, pending);
> +
> + if (pending && vcpu_has_ras(vcpu))
> + TEST_ASSERT_EQ(events.exception.serror_esr, EXPECTED_SERROR_ISS);
> +}
> +
> static void __vcpu_run_expect(struct kvm_vcpu *vcpu, unsigned int cmd)
> {
> struct ucall uc;
> @@ -134,6 +145,7 @@ static void test_mmio_abort(void)
>
> vcpu_inject_sea(vcpu);
> vcpu_run_expect_done(vcpu);
> + vcpu_assert_serror_pending(vcpu, false);
> kvm_vm_free(vm);
> }
>
> @@ -162,6 +174,7 @@ static void test_mmio_nisv(void)
>
> TEST_ASSERT(_vcpu_run(vcpu), "Expected nonzero return code from KVM_RUN");
> TEST_ASSERT_EQ(errno, ENOSYS);
> + vcpu_assert_serror_pending(vcpu, false);
>
> kvm_vm_free(vm);
> }
> @@ -185,6 +198,7 @@ static void test_mmio_nisv_abort(void)
>
> vcpu_inject_sea(vcpu);
> vcpu_run_expect_done(vcpu);
> + vcpu_assert_serror_pending(vcpu, false);
> kvm_vm_free(vm);
> }
>
> @@ -212,6 +226,7 @@ static void test_serror_masked(void)
>
> vcpu_inject_serror(vcpu);
> vcpu_run_expect_done(vcpu);
> + vcpu_assert_serror_pending(vcpu, true);
> kvm_vm_free(vm);
> }
>
> @@ -247,6 +262,7 @@ static void test_serror(void)
>
> vcpu_inject_serror(vcpu);
> vcpu_run_expect_done(vcpu);
> + vcpu_assert_serror_pending(vcpu, false);
> kvm_vm_free(vm);
> }
>
> @@ -288,6 +304,7 @@ static void test_s1ptw_abort(void)
> *ptep |= bad_pa;
>
> vcpu_run_expect_done(vcpu);
> + vcpu_assert_serror_pending(vcpu, false);
> kvm_vm_free(vm);
> }
>
> @@ -313,6 +330,7 @@ static void test_serror_emulated(void)
> vcpu_run_expect_sync(vcpu);
> vcpu_inject_serror(vcpu);
> vcpu_run_expect_done(vcpu);
> + vcpu_assert_serror_pending(vcpu, false);
> kvm_vm_free(vm);
> }
>
> @@ -356,6 +374,7 @@ static void test_mmio_ease(void)
>
> vcpu_inject_sea(vcpu);
> vcpu_run_expect_done(vcpu);
> + vcpu_assert_serror_pending(vcpu, false);
> done:
> kvm_vm_free(vm);
> }
> @@ -395,6 +414,7 @@ static void test_serror_amo(void)
> vcpu_run_expect_sync(vcpu);
> vcpu_inject_serror(vcpu);
> vcpu_run_expect_done(vcpu);
> + vcpu_assert_serror_pending(vcpu, false);
> kvm_vm_free(vm);
> }
>
>
> base-commit: fa22cd9947fc245d71bc40482f7f78eb0d5a4af0
> --
> 2.39.5
>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH v4] KVM: arm64: selftests: Check the pending SError state in external_aborts
2026-10-06 9:28 [PATCH v4] KVM: arm64: selftests: Check the pending SError state in external_aborts Fuad Tabba
2026-10-06 13:17 ` Oliver Upton
2026-10-07 2:28 ` Itaru Kitayama
@ 2026-10-07 12:16 ` Marc Zyngier
2 siblings, 0 replies; 4+ messages in thread
From: Marc Zyngier @ 2026-10-07 12:16 UTC (permalink / raw)
To: oupton, kvmarm, linux-arm-kernel, linux-kernel, Fuad Tabba
Cc: catalin.marinas, will, joey.gouly, seiden, suzuki.poulose,
yuzenghui, vdonnefort, qperret
On Tue, 06 Oct 2026 10:28:41 +0100, Fuad Tabba wrote:
> None of the external abort tests look at the vCPU events once the guest
> is done, so an SError left pending after the guest took it, or dropped
> while the guest had it masked, goes unnoticed.
>
> Read the vCPU events back at the end of every test that runs the guest.
> The SError must still be pending in the masked case, with the injected
> ESR when the vCPU has RAS, and no SError, injected or spurious, may be
> pending in any of the others.
>
> [...]
Applied to next, thanks!
[1/1] KVM: arm64: selftests: Check the pending SError state in external_aborts
commit: 49664cd0b1db434b6bbf9e37c84b3f448a545dc5
Cheers,
M.
--
Without deviation from the norm, progress is not possible.
^ permalink raw reply [flat|nested] 4+ messages in thread