From 7de7e7cad5eb79542fe67450d06ba3beb917558c Mon Sep 17 00:00:00 2001 From: Will Deacon Date: Thu, 7 Jul 2022 15:51:18 +0100 Subject: [PATCH] Revert "ANDROID: KVM: arm64: pkvm: Manage the non-protected guest dirty state from EL1" This reverts commit 28f12f0fa00f156468268456d690d6dc12cb8209. Bug: 233587962 Signed-off-by: Will Deacon Change-Id: I9356bcade5fa5f1bdc7cb8a917b7d27750598c4e --- arch/arm64/kvm/arm.c | 10 +--------- arch/arm64/kvm/handle_exit.c | 22 ---------------------- 2 files changed, 1 insertion(+), 31 deletions(-) diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c index f603ab667cea..7d12b5b25100 100644 --- a/arch/arm64/kvm/arm.c +++ b/arch/arm64/kvm/arm.c @@ -585,10 +585,6 @@ void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu) kvm_call_hyp(__vgic_v3_save_vmcr_aprs, &vcpu->arch.vgic_cpu.vgic_v3); kvm_call_hyp_nvhe(__pkvm_vcpu_put, vcpu); - - /* __pkvm_vcpu_put implies a sync of the state */ - if (!kvm_vm_is_protected(vcpu->kvm)) - vcpu->arch.flags |= KVM_ARM64_PKVM_STATE_DIRTY; } kvm_arch_vcpu_put_debug_state_flags(vcpu); @@ -795,12 +791,8 @@ int kvm_arch_vcpu_run_pid_change(struct kvm_vcpu *vcpu) static_branch_inc(&userspace_irqchip_in_use); } - if (is_protected_kvm_enabled()) { - /* Start with the vcpu in a dirty state */ - if (!kvm_vm_is_protected(vcpu->kvm)) - vcpu->arch.flags |= KVM_ARM64_PKVM_STATE_DIRTY; + if (is_protected_kvm_enabled()) ret = create_el2_shadow(kvm); - } return ret; } diff --git a/arch/arm64/kvm/handle_exit.c b/arch/arm64/kvm/handle_exit.c index 74789a68ef96..a5ab5215094e 100644 --- a/arch/arm64/kvm/handle_exit.c +++ b/arch/arm64/kvm/handle_exit.c @@ -201,21 +201,6 @@ static int handle_trap_exceptions(struct kvm_vcpu *vcpu) { int handled; - /* - * If we run a non-protected VM when protection is enabled - * system-wide, resync the state from the hypervisor and mark - * it as dirty on the host side if it wasn't dirty already - * (which could happen if preemption has taken place). - */ - if (is_protected_kvm_enabled() && !kvm_vm_is_protected(vcpu->kvm)) { - preempt_disable(); - if (!(vcpu->arch.flags & KVM_ARM64_PKVM_STATE_DIRTY)) { - kvm_call_hyp_nvhe(__pkvm_vcpu_sync_state, vcpu); - vcpu->arch.flags |= KVM_ARM64_PKVM_STATE_DIRTY; - } - preempt_enable(); - } - /* * See ARM ARM B1.14.1: "Hyp traps on instructions * that fail their condition code check" @@ -283,13 +268,6 @@ int handle_exit(struct kvm_vcpu *vcpu, int exception_index) /* For exit types that need handling before we can be preempted */ void handle_exit_early(struct kvm_vcpu *vcpu, int exception_index) { - /* - * We just exited, so the state is clean from a hypervisor - * perspective. - */ - if (is_protected_kvm_enabled()) - vcpu->arch.flags &= ~KVM_ARM64_PKVM_STATE_DIRTY; - if (ARM_SERROR_PENDING(exception_index)) { if (this_cpu_has_cap(ARM64_HAS_RAS_EXTN)) { u64 disr = kvm_vcpu_get_disr(vcpu);