Re: [PATCH v3 2/4] KVM: arm64: nv: Inject an SEA when the VNCR walk cannot set the AF

From: Yao Yuan

Date: Thu Dec 03 2026 - 02:39:50 EST


On Sat, Nov 28, 2026 at 01:14:45AM +0800, Jia He wrote:
> When the guest hypervisor enables hardware Access flag management
> (TCR_EL2.HA), KVM's stage-1 walker sets the AF in the descriptor that
> maps VNCR_EL2 with __kvm_at_swap_desc(). If the descriptor is in a
> read-only memslot, the update fails with -EPERM and walk_s1() records an
> SEA on translation table walk in the walk result.
>
> kvm_handle_vncr_abort() does not handle -EPERM. It neither injects the
> fault nor maps the VNCR page, and returns to the guest. The guest takes
> the same VNCR abort again and never makes progress.
>
> -EPERM can only come from this AF update. The VNCR walk uses the EL2&0
> translation regime, which has no stage-2.

LGTM.

Reviewed-by: Yuan Yao <yaoyuan@xxxxxxxxxxxxxxxxx>

>
> Treat -EPERM like the other walk failures and inject the recorded fault
> into the guest hypervisor.
>
> Tested with the selftest added in the next patch on a Neoverse-N2 host.
> Without this patch, the vCPU exits about 1.3 million times in 5 seconds
> on the same VNCR abort and makes no progress. With this patch, the
> guest hypervisor receives an SEA on translation table walk at level 3.
>
> Reported-by: Sashiko <sashiko-bot@xxxxxxxxxx>
> Closes: https://lore.kernel.org/all/sashiko-outbox-230439@xxxxxxxxxx/
> Fixes: bff8aa213dee ("KVM: arm64: Implement HW access flag management in stage-1 SW PTW")
> Signed-off-by: Jia He <justin.he@xxxxxxx>
> ---
> arch/arm64/kvm/nested.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/arch/arm64/kvm/nested.c b/arch/arm64/kvm/nested.c
> index 08582fbc09d5..523d71d4df13 100644
> --- a/arch/arm64/kvm/nested.c
> +++ b/arch/arm64/kvm/nested.c
> @@ -1743,6 +1743,7 @@ int kvm_handle_vncr_abort(struct kvm_vcpu *vcpu)
> case -EINVAL:
> case -ENOENT:
> case -EACCES:
> + case -EPERM:
> /*
> * Translation failed, inject the corresponding
> * exception back to EL2.
> --
> 2.34.1
>