Skip to content

Commit 23e6025

Browse files
dwmw2bonzini
authored andcommitted
KVM: x86/xen: Fix lockdep warning on "recursive" gpc locking
In commit 5ec3289 ("KVM: x86/xen: Compatibility fixes for shared runstate area") we declared it safe to obtain two gfn_to_pfn_cache locks at the same time: /* * The guest's runstate_info is split across two pages and we * need to hold and validate both GPCs simultaneously. We can * declare a lock ordering GPC1 > GPC2 because nothing else * takes them more than one at a time. */ However, we forgot to tell lockdep. Do so, by setting a subclass on the first lock before taking the second. Fixes: 5ec3289 ("KVM: x86/xen: Compatibility fixes for shared runstate area") Suggested-by: Peter Zijlstra <[email protected]> Signed-off-by: David Woodhouse <[email protected]> Message-Id: <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 71d0393 commit 23e6025

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

arch/x86/kvm/xen.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,10 @@ static void kvm_xen_update_runstate_guest(struct kvm_vcpu *v, bool atomic)
304304
* The guest's runstate_info is split across two pages and we
305305
* need to hold and validate both GPCs simultaneously. We can
306306
* declare a lock ordering GPC1 > GPC2 because nothing else
307-
* takes them more than one at a time.
307+
* takes them more than one at a time. Set a subclass on the
308+
* gpc1 lock to make lockdep shut up about it.
308309
*/
310+
lock_set_subclass(&gpc1->lock.dep_map, 1, _THIS_IP_);
309311
read_lock(&gpc2->lock);
310312

311313
if (!kvm_gpc_check(gpc2, user_len2)) {

0 commit comments

Comments
 (0)