Skip to contentSkip to conversation

KVM: SEV: Add lock subtyping in sev_lock_two_vms so lockdep doesn't report false dependencies

PATCH Applied Wanpeng Li 2 participants 2 messages Jan 5, 2022 – Jan 7, 2022

Subsystems (3)
lore
Share & tools
lore

Wanpeng Li

author
#0 lore raw

PATCH 1/1 KVM: SEV: Add lock subtyping in sev_lock_two_vms so lockdep doesn't report false dependencies

From: Wanpeng Li <[email protected]>

Both source and dest vms' kvm->locks are held in sev_lock_two_vms, we should mark one with different subtype to avoid false positives from lockdep.

Fixes c9d61dcb0bc26 (KVM: SEV: accept signals in sev_lock_two_vms)
---
 arch/x86/kvm/svm/sev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kvm/svm/sev.c +1 -1
index 7656a2c..be28831 100644
@@ -1565,7 +1565,7 @@ static int sev_lock_two_vms(struct kvm *dst_kvm, struct kvm *src_kvm)
 	r = -EINTR;
 	if (mutex_lock_killable(&dst_kvm->lock))
 		goto release_src;
-	if (mutex_lock_killable(&src_kvm->lock))
+	if (mutex_lock_killable_nested(&src_kvm->lock, SINGLE_DEPTH_NESTING))
 		goto unlock_dst;
 	return 0;
 
Signature · 1 line
2.7.4
maintainer Applied
#1 lore raw
Quoted 19 lines · Wanpeng Li

From: Wanpeng Li <[email protected]>

Both source and dest vms' kvm->locks are held in sev_lock_two_vms, we should mark one with different subtype to avoid false positives from lockdep.

Fixes c9d61dcb0bc26 (KVM: SEV: accept signals in sev_lock_two_vms)
---
  arch/x86/kvm/svm/sev.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kvm/svm/sev.c +0 -0
index 7656a2c..be28831 100644

arch/x86/kvm/svm/sev.c static int sev_lock_two_vms(struct kvm *dst_kvm, struct kvm *src_kvm) · line 1571

Quoted 8 lines
arch/x86/kvm/svm/sev.c +1 -1
@@ -1565,7 +1565,7 @@ static int sev_lock_two_vms(struct kvm *dst_kvm, struct kvm *src_kvm)
  	r = -EINTR;
  	if (mutex_lock_killable(&dst_kvm->lock))
  		goto release_src;
-	if (mutex_lock_killable(&src_kvm->lock))
+	if (mutex_lock_killable_nested(&src_kvm->lock, SINGLE_DEPTH_NESTING))
  		goto unlock_dst;
  	return 0;
 

Queued, thanks.

Paolo