x86/mem-sharing: ensure consistent lock order in get_two_gfns()
authorJan Beulich <jbeulich@suse.com>
Wed, 7 Jul 2021 10:35:12 +0000 (12:35 +0200)
committerJan Beulich <jbeulich@suse.com>
Wed, 7 Jul 2021 10:35:12 +0000 (12:35 +0200)
While the comment validly says "Sort by domain, if same domain by gfn",
the implementation also included equal domain IDs in the first part of
the check, thus rending the second part entirely dead and leaving
deadlock potential when there's only a single domain involved.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Tamas K Lengyel <tamas@tklengyel.com>
xen/include/asm-x86/p2m.h

index 5b697df573a416bea00afdbe06360bfefb5617c5..e569471a2f8ef0c0c31d0370ce1cbeb92165a05f 100644 (file)
@@ -587,7 +587,7 @@ do {                                                    \
     dest ## _t   = (source ## t)   ?: &scratch_t;       \
 } while (0)
 
-    if ( (rd->domain_id <= ld->domain_id) ||
+    if ( (rd->domain_id < ld->domain_id) ||
          ((rd == ld) && (gfn_x(rgfn) <= gfn_x(lgfn))) )
     {
         assign_pointers(first, r);