Skip to content

Commit 1ff2755

Browse files
author
Marc Zyngier
committed
KVM: arm64: vhe: Synchronise with page table walker on MMU update
Contrary to nVHE, VHE is a lot easier when it comes to dealing with speculative page table walks started at EL1. As we only change EL1&0 translation regime when context-switching, we already benefit from the effect of the DSB that sits in the context switch code. We only need to take care of it in the NV case, where we can flip between between two EL1 contexts (one of them being the virtual EL2) without a context switch. Signed-off-by: Marc Zyngier <maz@kernel.org> Reviewed-by: Oliver Upton <oliver.upton@linux.dev>
1 parent 8442d65 commit 1ff2755

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

arch/arm64/kvm/hyp/vhe/sysreg-sr.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <asm/kvm_asm.h>
1414
#include <asm/kvm_emulate.h>
1515
#include <asm/kvm_hyp.h>
16+
#include <asm/kvm_nested.h>
1617

1718
/*
1819
* VHE: Host and guest must save mdscr_el1 and sp_el0 (and the PC and
@@ -69,6 +70,17 @@ void kvm_vcpu_load_sysregs_vhe(struct kvm_vcpu *vcpu)
6970
host_ctxt = &this_cpu_ptr(&kvm_host_data)->host_ctxt;
7071
__sysreg_save_user_state(host_ctxt);
7172

73+
/*
74+
* When running a normal EL1 guest, we only load a new vcpu
75+
* after a context switch, which imvolves a DSB, so all
76+
* speculative EL1&0 walks will have already completed.
77+
* If running NV, the vcpu may transition between vEL1 and
78+
* vEL2 without a context switch, so make sure we complete
79+
* those walks before loading a new context.
80+
*/
81+
if (vcpu_has_nv(vcpu))
82+
dsb(nsh);
83+
7284
/*
7385
* Load guest EL1 and user state
7486
*

0 commit comments

Comments
 (0)