From 2bd2fb9c821109401f868787766abdc94e2ab2b9 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Sat, 10 Jun 2023 08:16:47 +0000 Subject: [PATCH] Revert "KVM: arm64: Avoid lock inversion when setting the VM register width" This reverts commit 6c9d3f2a5e178bc22172ce2c7abac269738a4218. It breaks the Android kernel ABI at this point in time, so needs to be dropped. If it is needed, it can come back in an ABI-safe way in the future. Bug: 161946584 Cc: Will Deacon Change-Id: Ifa88c3662cdd4f16e4da4f5d2606976b039055f7 Signed-off-by: Greg Kroah-Hartman --- arch/arm64/include/asm/kvm_host.h | 3 --- arch/arm64/kvm/arm.c | 18 ------------------ arch/arm64/kvm/reset.c | 6 +++--- 3 files changed, 3 insertions(+), 24 deletions(-) diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h index 2ae81a7c89c8..43015791f9c5 100644 --- a/arch/arm64/include/asm/kvm_host.h +++ b/arch/arm64/include/asm/kvm_host.h @@ -203,9 +203,6 @@ struct kvm_arch { /* Mandated version of PSCI */ u32 psci_version; - /* Protects VM-scoped configuration data */ - struct mutex config_lock; - /* * If we encounter a data abort without valid instruction syndrome * information, report this to user space. User space can (and diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c index 87411e494248..e4965f6038b2 100644 --- a/arch/arm64/kvm/arm.c +++ b/arch/arm64/kvm/arm.c @@ -155,16 +155,6 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type) if (type & ~KVM_VM_TYPE_MASK) return -EINVAL; - mutex_init(&kvm->arch.config_lock); - -#ifdef CONFIG_LOCKDEP - /* Clue in lockdep that the config_lock must be taken inside kvm->lock */ - mutex_lock(&kvm->lock); - mutex_lock(&kvm->arch.config_lock); - mutex_unlock(&kvm->arch.config_lock); - mutex_unlock(&kvm->lock); -#endif - ret = kvm_share_hyp(kvm, kvm + 1); if (ret) return ret; @@ -435,14 +425,6 @@ int kvm_arch_vcpu_create(struct kvm_vcpu *vcpu) spin_lock_init(&vcpu->arch.mp_state_lock); -#ifdef CONFIG_LOCKDEP - /* Inform lockdep that the config_lock is acquired after vcpu->mutex */ - mutex_lock(&vcpu->mutex); - mutex_lock(&vcpu->kvm->arch.config_lock); - mutex_unlock(&vcpu->kvm->arch.config_lock); - mutex_unlock(&vcpu->mutex); -#endif - /* Force users to call KVM_ARM_VCPU_INIT */ vcpu->arch.target = -1; bitmap_zero(vcpu->arch.features, KVM_VCPU_MAX_FEATURES); diff --git a/arch/arm64/kvm/reset.c b/arch/arm64/kvm/reset.c index 4b80f4e2b438..50349553bee9 100644 --- a/arch/arm64/kvm/reset.c +++ b/arch/arm64/kvm/reset.c @@ -176,7 +176,7 @@ static int kvm_set_vm_width(struct kvm_vcpu *vcpu) is32bit = vcpu_has_feature(vcpu, KVM_ARM_VCPU_EL1_32BIT); - lockdep_assert_held(&kvm->arch.config_lock); + lockdep_assert_held(&kvm->lock); if (test_bit(KVM_ARCH_FLAG_REG_WIDTH_CONFIGURED, &kvm->arch.flags)) { /* @@ -228,9 +228,9 @@ int kvm_reset_vcpu(struct kvm_vcpu *vcpu) int ret; bool loaded; - mutex_lock(&vcpu->kvm->arch.config_lock); + mutex_lock(&vcpu->kvm->lock); ret = kvm_set_vm_width(vcpu); - mutex_unlock(&vcpu->kvm->arch.config_lock); + mutex_unlock(&vcpu->kvm->lock); if (ret) return ret;