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. 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 Closes: https://lore.kernel.org/all/sashiko-outbox-230439@kernel.org/ Fixes: bff8aa213dee ("KVM: arm64: Implement HW access flag management in stage-1 SW PTW") Signed-off-by: Jia He --- 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 4d83281a7a28..59d82a29ec01 100644 --- a/arch/arm64/kvm/nested.c +++ b/arch/arm64/kvm/nested.c @@ -1737,6 +1737,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