Skip to content

Commit 61b0280

Browse files
author
Marc Zyngier
committed
KVM: arm64: Don't switch MMU on translation from non-NV context
If calling into the AT code from guest EL1, there is no need to consider any context switch, as we are guaranteed to be in the correct context. Reviewed-by: Oliver Upton <[email protected]> Signed-off-by: Marc Zyngier <[email protected]>
1 parent cb17629 commit 61b0280

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

arch/arm64/kvm/at.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,7 +1285,7 @@ static u64 __kvm_at_s1e01_fast(struct kvm_vcpu *vcpu, u32 op, u64 vaddr)
12851285
{
12861286
struct mmu_config config;
12871287
struct kvm_s2_mmu *mmu;
1288-
bool fail;
1288+
bool fail, mmu_cs;
12891289
u64 par;
12901290

12911291
par = SYS_PAR_EL1_F;
@@ -1301,8 +1301,13 @@ static u64 __kvm_at_s1e01_fast(struct kvm_vcpu *vcpu, u32 op, u64 vaddr)
13011301
* If HCR_EL2.{E2H,TGE} == {1,1}, the MMU context is already
13021302
* the right one (as we trapped from vEL2). If not, save the
13031303
* full MMU context.
1304+
*
1305+
* We are also guaranteed to be in the correct context if
1306+
* we're not in a nested VM.
13041307
*/
1305-
if (vcpu_el2_e2h_is_set(vcpu) && vcpu_el2_tge_is_set(vcpu))
1308+
mmu_cs = (vcpu_has_nv(vcpu) &&
1309+
!(vcpu_el2_e2h_is_set(vcpu) && vcpu_el2_tge_is_set(vcpu)));
1310+
if (!mmu_cs)
13061311
goto skip_mmu_switch;
13071312

13081313
/*
@@ -1370,7 +1375,7 @@ static u64 __kvm_at_s1e01_fast(struct kvm_vcpu *vcpu, u32 op, u64 vaddr)
13701375

13711376
write_sysreg_hcr(HCR_HOST_VHE_FLAGS);
13721377

1373-
if (!(vcpu_el2_e2h_is_set(vcpu) && vcpu_el2_tge_is_set(vcpu)))
1378+
if (mmu_cs)
13741379
__mmu_config_restore(&config);
13751380

13761381
return par;

0 commit comments

Comments
 (0)