[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Xen-devel] [PATCH 3/3] x86/mm-locks: apply a bias to lock levels for current domain
- To: Roger Pau Monné <roger.pau@xxxxxxxxxx>
- From: George Dunlap <george.dunlap@xxxxxxxxxx>
- Date: Thu, 20 Dec 2018 13:47:33 +0000
- Autocrypt: addr=george.dunlap@xxxxxxxxxx; prefer-encrypt=mutual; keydata= mQINBFPqG+MBEACwPYTQpHepyshcufo0dVmqxDo917iWPslB8lauFxVf4WZtGvQSsKStHJSj 92Qkxp4CH2DwudI8qpVbnWCXsZxodDWac9c3PordLwz5/XL41LevEoM3NWRm5TNgJ3ckPA+J K5OfSK04QtmwSHFP3G/SXDJpGs+oDJgASta2AOl9vPV+t3xG6xyfa2NMGn9wmEvvVMD44Z7R W3RhZPn/NEZ5gaJhIUMgTChGwwWDOX0YPY19vcy5fT4bTIxvoZsLOkLSGoZb/jHIzkAAznug Q7PPeZJ1kXpbW9EHHaUHiCD9C87dMyty0N3TmWfp0VvBCaw32yFtM9jUgB7UVneoZUMUKeHA fgIXhJ7I7JFmw3J0PjGLxCLHf2Q5JOD8jeEXpdxugqF7B/fWYYmyIgwKutiGZeoPhl9c/7RE Bf6f9Qv4AtQoJwtLw6+5pDXsTD5q/GwhPjt7ohF7aQZTMMHhZuS52/izKhDzIufl6uiqUBge 0lqG+/ViLKwCkxHDREuSUTtfjRc9/AoAt2V2HOfgKORSCjFC1eI0+8UMxlfdq2z1AAchinU0 eSkRpX2An3CPEjgGFmu2Je4a/R/Kd6nGU8AFaE8ta0oq5BSFDRYdcKchw4TSxetkG6iUtqOO ZFS7VAdF00eqFJNQpi6IUQryhnrOByw+zSobqlOPUO7XC5fjnwARAQABtCRHZW9yZ2UgVy4g RHVubGFwIDxkdW5sYXBnQHVtaWNoLmVkdT6JAkAEEwEKACoCGwMFCwkIBwMFFQoJCAsFFgID AQACHgECF4ACGQEFAlpk2IEFCQo9I54ACgkQpjY8MQWQtG1A1BAAnc0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UFHCC5a8fSMal7+hrwKASyWNY4xgavv5ET61l6aGkJ+xV1hnzKlPjZGPXp8 q5c=
- Cc: Wei Liu <wei.liu2@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Tim Deegan <tim@xxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
- Delivery-date: Thu, 20 Dec 2018 13:47:39 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
- Openpgp: preference=signencrypt
On 12/20/18 9:05 AM, Roger Pau Monné wrote:
> On Wed, Dec 19, 2018 at 06:10:04PM +0000, George Dunlap wrote:
>> On 12/19/18 2:59 PM, Roger Pau Monné wrote:
>>>> Using 'current' means that potential deadlocks which would now cause a
>>>> BUG() won't anymore. I'm fine with not adding extra protections that
>>>> aren't there now; but I don't want to remove protections that are.
>>>
>>> The lock ordering enforcement is still kept as-is, but Xen is allowed
>>> to lock the caller mm locks in the right order (be it privileged or
>>> not) after having locked a subject domain ones also in the correct
>>> order.
>>
>> Suppose we have mm_lock_x, with value 8, and mm_lock_y with value 16.
>>
>> Suppose we have H1, which grabs current->mm_lock_x and tgt->mm_lock_y.
>
> With my proposal H1 won't be a valid lock sequence, since
> current->mm_lock_x level > tgt->mm_lock_y level.
I made a mistake; here's a corrected and expanded example.
Suppose we have mm_lock_x, with value 8, and mm_lock_y with value 16.
Suppose we have H1, which grabs tgt->mm_lock_x and current->mm_lock_y.
And suppose we have H2, which grabs tgt->mm_lock_y, and current->mm_lock_x.
And suppose domA calls H1 on domB at the same time that domB calls H2 on
domA. We could have the following sequence:
1. H1: grab B->mm_lock_x
2. H2: grab A->mm_lock_y
3. H1: wait on A->mm_lock_y
4. H2: wait on B->mm_lock_x #DEADLOCK
With the current mm lock checking:
* H1 grabs a lock of level 8, then a lock of level 16, so no BUG check.
* H2 grabs a lock of level 16 and then a lock of level 8, and so BUG
checks, catching this potential deadlock.
With your "current bias" patch:
* H1 grabs a lock of level 8, then a lock of level 80 (16 + 64), so no
BUG check.
* H2 grabs a lock of level 16, then a lock of level 72 (8 + 64), so no
BUG check, missing the potential deadlock.
With "dom0 bias", you basically have to choose one of the hypercalls to
be privileged only. If we choose H2 to be privileged, then B must be
dom0 and A must be a domU. So we get:
* H1 grabs lock level 72 (16 + 64), then lock level 16, causing a BUG check.
* H2 grabs lock level 16, then lock level 80, no bug check.
The practical implication of dom0 bias is that any hypercall which grabs
two mm locks, one of two things must be true:
* When it is called from one domU to another domU, locks must follow the
"normal" locking order listed in mm-locks.h
* When it is called between a dom0 and a domU, it must be consistenly
called either one way or the other; i.e., it must always be dom0 calling
it with a domU target, or domU calling it with a dom0 target (otherwise
the dom0 / domU locking order is violated).
Now that I state it that way, it's not immediately obvious that's a
property we have or want.
> I'm fine with this proposal, it's just that if it's safe for Dom0 to
> pick any other domain mm lock and then any Dom0 mm lock it should also
> be safe for any domain and not Dom0 only.
If this were true, I'd be happy with your proposal; but I'm pretty sure
it's not true. If you can give me a proof that no two hypercalls H1 and
H2 can exist under your proposal, then we can consider it.
-George
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel
|