From: Jan Beulich Date: Wed, 7 Jul 2021 10:35:12 +0000 (+0200) Subject: x86/mem-sharing: ensure consistent lock order in get_two_gfns() X-Git-Tag: archive/raspbian/4.16.0+51-g0941d6cb-1+rpi1~2^2~42^2~356 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=09af2d01a2fe6a0af08598bdfe12c9707f4d82ba;p=xen.git x86/mem-sharing: ensure consistent lock order in get_two_gfns() 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 Acked-by: Tamas K Lengyel --- diff --git a/xen/include/asm-x86/p2m.h b/xen/include/asm-x86/p2m.h index 5b697df573..e569471a2f 100644 --- a/xen/include/asm-x86/p2m.h +++ b/xen/include/asm-x86/p2m.h @@ -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);