Skip to content

Commit ee372e6

Browse files
Marc Zyngieroupton
authored andcommitted
KVM: arm64: nv: Fix ATS12 handling of single-stage translation
Volodymyr reports that using a Xen DomU as a nested guest (where HCR_EL2.E2H == 0), ATS12 results in a translation that stops at the L2's S1, which isn't something you'd normally expects. Comparing the code against the spec proves to be illuminating, and suggests that the author of such code must have been tired, cross-eyed, drunk, or maybe all of the above. The gist of it is that, apart from HCR_EL2.VM or HCR_EL2.DC being 0, only the use of the EL2&0 translation regime limits the walk to S1 only, and that we must finish the S2 walk in any other case. Which solves the above issue, as E2H==0 indicates that ATS12 walks the EL1&0 translation regime. Explicitly checking for EL2&0 fixes this. Reported-by: Volodymyr Babchuk <[email protected]> Suggested-by: Oliver Upton <[email protected]> Signed-off-by: Marc Zyngier <[email protected]> Fixes: be04ceb ("KVM: arm64: nv: Add emulation of AT S12E{0,1}{R,W}") Link: https://lore.kernel.org/r/[email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Oliver Upton <[email protected]>
1 parent 3328d17 commit ee372e6

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

arch/arm64/kvm/at.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1420,10 +1420,10 @@ void __kvm_at_s12(struct kvm_vcpu *vcpu, u32 op, u64 vaddr)
14201420
return;
14211421

14221422
/*
1423-
* If we only have a single stage of translation (E2H=0 or
1424-
* TGE=1), exit early. Same thing if {VM,DC}=={0,0}.
1423+
* If we only have a single stage of translation (EL2&0), exit
1424+
* early. Same thing if {VM,DC}=={0,0}.
14251425
*/
1426-
if (!vcpu_el2_e2h_is_set(vcpu) || vcpu_el2_tge_is_set(vcpu) ||
1426+
if (compute_translation_regime(vcpu, op) == TR_EL20 ||
14271427
!(vcpu_read_sys_reg(vcpu, HCR_EL2) & (HCR_VM | HCR_DC)))
14281428
return;
14291429

0 commit comments

Comments
 (0)