lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening linux-cve-announce PHC | |
Open Source and information security mailing list archives
| ||
|
Date: Mon, 4 Apr 2022 12:46:05 -0700 From: Peter Gonda <pgonda@...gle.com> To: kvm@...r.kernel.org Cc: Peter Gonda <pgonda@...gle.com>, John Sperbeck <jsperbeck@...gle.com>, David Rientjes <rientjes@...gle.com>, Paolo Bonzini <pbonzini@...hat.com>, Sean Christopherson <seanjc@...gle.com>, linux-kernel@...r.kernel.org Subject: [PATCH] KVM: SEV: Mark nested locking of vcpu->lock svm_vm_migrate_from() uses sev_lock_vcpus_for_migration() to lock all source and target vcpu->locks. Mark the nested subclasses to avoid false positives from lockdep. Fixes: b56639318bb2b ("KVM: SEV: Add support for SEV intra host migration") Reported-by: John Sperbeck<jsperbeck@...gle.com> Suggested-by: David Rientjes <rientjes@...gle.com> Signed-off-by: Peter Gonda <pgonda@...gle.com> Cc: Paolo Bonzini <pbonzini@...hat.com> Cc: Sean Christopherson <seanjc@...gle.com> Cc: kvm@...r.kernel.org Cc: linux-kernel@...r.kernel.org --- Tested by running sev_migrate_tests with lockdep enabled. Before we see a warning from sev_lock_vcpus_for_migration(). After we get no warnings. --- arch/x86/kvm/svm/sev.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c index 75fa6dd268f0..8f77421c1c4b 100644 --- a/arch/x86/kvm/svm/sev.c +++ b/arch/x86/kvm/svm/sev.c @@ -1591,15 +1591,16 @@ static void sev_unlock_two_vms(struct kvm *dst_kvm, struct kvm *src_kvm) atomic_set_release(&src_sev->migration_in_progress, 0); } - -static int sev_lock_vcpus_for_migration(struct kvm *kvm) +static int sev_lock_vcpus_for_migration(struct kvm *kvm, unsigned int *subclass) { struct kvm_vcpu *vcpu; unsigned long i, j; kvm_for_each_vcpu(i, vcpu, kvm) { - if (mutex_lock_killable(&vcpu->mutex)) + if (mutex_lock_killable_nested(&vcpu->mutex, *subclass)) goto out_unlock; + + ++(*subclass); } return 0; @@ -1717,6 +1718,7 @@ int sev_vm_move_enc_context_from(struct kvm *kvm, unsigned int source_fd) struct kvm *source_kvm; bool charged = false; int ret; + unsigned int vcpu_mutex_subclass = 0; source_kvm_file = fget(source_fd); if (!file_is_kvm(source_kvm_file)) { @@ -1745,10 +1747,10 @@ int sev_vm_move_enc_context_from(struct kvm *kvm, unsigned int source_fd) charged = true; } - ret = sev_lock_vcpus_for_migration(kvm); + ret = sev_lock_vcpus_for_migration(kvm, &vcpu_mutex_subclass); if (ret) goto out_dst_cgroup; - ret = sev_lock_vcpus_for_migration(source_kvm); + ret = sev_lock_vcpus_for_migration(source_kvm, &vcpu_mutex_subclass); if (ret) goto out_dst_vcpu; -- 2.35.1.1094.g7c7d902a7c-goog
Powered by blists - more mailing lists