[PATCH 1/2] x86/mem-sharing: ensure consistent lock order in get_two_gfns()

Jan Beulich posted 2 patches 4 years, 7 months ago
[PATCH 1/2] x86/mem-sharing: ensure consistent lock order in get_two_gfns()
Posted by Jan Beulich 4 years, 7 months ago
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>

--- 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);


Re: [PATCH 1/2] x86/mem-sharing: ensure consistent lock order in get_two_gfns()
Posted by Tamas K Lengyel 4 years, 7 months ago
On Tue, Jun 29, 2021 at 8:54 AM Jan Beulich <jbeulich@suse.com> wrote:
>
> 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>

Re: [PATCH 1/2] x86/mem-sharing: ensure consistent lock order in get_two_gfns()
Posted by Jan Beulich 4 years, 7 months ago
On 06.07.2021 14:36, Tamas K Lengyel wrote:
> On Tue, Jun 29, 2021 at 8:54 AM Jan Beulich <jbeulich@suse.com> wrote:
>>
>> 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>

Thanks. Do you think I should queue this for backporting (once it got
applied)?

Jan


Re: [PATCH 1/2] x86/mem-sharing: ensure consistent lock order in get_two_gfns()
Posted by Tamas K Lengyel 4 years, 7 months ago
On Tue, Jul 6, 2021 at 9:14 AM Jan Beulich <jbeulich@suse.com> wrote:
>
> On 06.07.2021 14:36, Tamas K Lengyel wrote:
> > On Tue, Jun 29, 2021 at 8:54 AM Jan Beulich <jbeulich@suse.com> wrote:
> >>
> >> 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>
>
> Thanks. Do you think I should queue this for backporting (once it got
> applied)?

Sure, considering it's a bugfix.

Thanks,
Tamas