Revert "Revert "ANDROID: KVM: arm64: Avoid switching to guest context if guest is already loaded""

This reverts commit 6b08ae02c5.

Bug: 233587962
Signed-off-by: Will Deacon <willdeacon@google.com>
Change-Id: I550d659aa6cd77c20873b403e7c2bd813502d8b7
This commit is contained in:
Will Deacon
2022-07-07 15:49:23 +01:00
parent e335a5c33a
commit f0bb493a44

View File

@@ -17,6 +17,17 @@ struct tlb_inv_context {
static void __tlb_switch_to_guest(struct kvm_s2_mmu *mmu,
struct tlb_inv_context *cxt)
{
struct kvm_cpu_context *host_ctxt;
struct kvm_vcpu *vcpu;
host_ctxt = &this_cpu_ptr(&kvm_host_data)->host_ctxt;
vcpu = host_ctxt->__hyp_running_vcpu;
if (vcpu) {
WARN_ON(vcpu->arch.hw_mmu->vmid.vmid != mmu->vmid.vmid);
return;
}
if (cpus_have_final_cap(ARM64_WORKAROUND_SPECULATIVE_AT)) {
u64 val;
@@ -45,6 +56,12 @@ static void __tlb_switch_to_guest(struct kvm_s2_mmu *mmu,
static void __tlb_switch_to_host(struct tlb_inv_context *cxt)
{
struct kvm_cpu_context *host_ctxt;
host_ctxt = &this_cpu_ptr(&kvm_host_data)->host_ctxt;
if (host_ctxt->__hyp_running_vcpu)
return;
__load_host_stage2();
if (cpus_have_final_cap(ARM64_WORKAROUND_SPECULATIVE_AT)) {