[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2] x86/PoD: defer nested P2M flushes
- To: Jan Beulich <jbeulich@xxxxxxxx>
- From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
- Date: Tue, 19 Oct 2021 15:53:27 +0200
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=yFKrmk1ZxEyJHA+8j5lD6LJLD+20vaarteCLEUr83X4=; b=gfo4k9jYsg5SEZMiQPAptdir9lKrElXoulr5wSwvVuevC/jw0OWr5gPOCvo1UUkKmWr9d0b1UM6fLyoACKZpOSVDSQ6439+i10nwK8Ic3t3LCYMCy9lndFMLzWegxYoJH7yS5CXiRi0qdeCGpVTpmjkgo1IWSUrXxh1/ekueA8loRSicb7Ay1ZZEYW/yrJpZRRKcccGZ7bQjRHgBPs7PXOyWtukAlrHGSDzUNgKyFvaTshx2gbpT3n9DdvRTwqwM3RbxuYzPGHe3Ky5wMpbO/Ah27rjsYooDRD7ByQoh4hWCH2K08iCUpYmR6f0Fi9GoRIAEdVzmiSiBIpz4QnUfQg==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fGMBgv3oBp/WEWRjupC6weubtCr7wpfPFLCGck1OZTn9GxzXc6GJMbEYLKa4glgVujDlEyIey2a4mjW8aPPP/tekshMQKwI5k9KjScwpcK5Xyrls8KitCPZbeEztwk8MtUbbv3g3PXdMp7EJHU3RzpwGeiEik5yEqUOh8ozPyUkpzY6xKEFUUIDlfjhFCPGi53ariCIWbN8GPCspdqTmNMmC8hnc675+uJ3wHLnlHAH3t9YhrROPogCkY6Aa0NyeEt6jBld/FVjdpaiK56n8/gN5I5sNAXKebepsJX5nOmj1rQX322FOT8N1pWkqySK+Q2groU6fiAEqx2vmXRHosw==
- Authentication-results: esa6.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
- Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Kevin Tian <kevin.tian@xxxxxxxxx>
- Delivery-date: Tue, 19 Oct 2021 13:54:03 +0000
- Ironport-data: A9a23:lRcuj6suLWomR4fQ8eVqy2GILefnVLRZMUV32f8akzHdYApBsoF/q tZmKWnXP/bcZ2DyKdkiOY608k8EsZaDzt8xSAFtrS5jEnlB+JbJXdiXEBz9bniYRiHhoOOLz Cm8hv3odp1coqr0/0/1WlTZQP0VOZigHtIQMsadUsxKbVIiGHhJZS5LwbZj29cw2InhX2thh PupyyHhEA79s9JLGjp8B5Kr8HuDa9yr5Vv0FnRnDRx6lAe2e0s9VfrzFonoR5fMeaFGH/bSe gr25OrRElU1XfsaIojNfr7TKiXmS1NJVOSEoiI+t6OK2nCuqsGuu0qS2TV1hUp/0l20c95NJ NplqLicZyotBYr1o6dNcBteESN6I5R+9+qSSZS/mZT7I0zudnLtx7NlDV0sPJ1e8eFyaY1M3 aVGcnZXNEnF3r/ohuLgIgVvrp1LwM3DJoQQt2sm1TjEJf0nXYrCU+PB4towMDIY250TR6uBO JFxhTxHQBrbbCYfJFMtVakRjPb0i3XjWDRRkQfAzUYwyzeKl1EguFT3C/LWd8KLQ4NJn0+ej mPA42n9RBodMbS32TeDt36hmOLLtSf6Q54JUq218OZwh1+ezXBVDwcZPXO5q/Skjk+1W/pEN lcZvCEpqMAPGFeDF4enGUfi+Tjd40BaC4E4//AGBB+l1474zSudPU89dX0RS94gts0yWwU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h4xgPM tbAs1D4ZjLfCRHZKXBkXiF+rQbsaC6GcmT7I+0pRcdLnAbV0gj1XYANu/yKDwJeOAsP+teKH Pz3Lsim9L2Ek5nEfhTS0N1E9Qq4Lbw5ebbSC9DIyRixBiFjDuu5rK/Ox+E3i0GWzcK5bs562 DKnyHw+63m6piAu1Hh/l6Wy64TtMrqy9NFCsDJos8JKg/0ggLtQIh6QbWNsB08venqwlc3l9 vnpQsmIq1ImjzsV1DwhSGo9xjr0T4o5XOn4ViEgUH7qci8fz4+A9opv/MTTjLpr24b+P1s2q NC2GyU87BNCwnboSj779/UEzl3i0uduxMZ4K0upk0adbFbRK5arIQZ8k8QOowHBjjG5IcuF/ QrJN3A5cxRbUiRYxnizylSKeSXLzEO9yq9Mww/UpT/6UkQoJk59TpY+CUnpAZDyHpnIKM0od gtMcxT5flzp4EtHPtA7Epoe7rBNoX3e2O/DIulGyWvKEg2AQO/l3fJ2sRB2AiLQu1D8HJgou WNbLtn3VRCDX4GT/f+hKF2zg==
- Ironport-sdr: oLQ3OfsH3woR6xV/hjKVkg+e/ex1bS3CGb7DbBrYVp3Fav1SBSTEqNyEheuggghbPtTdRudjxR 2lKLVaW/T5BNaWDBAHAtssqq8zP++wcEwI93cwY0BLTdM7bEu11Av5gwiuoQkwgkk9nfEAMZas nauVVcZ6hnyWMtHQ+SrLUAENjQwzi6MHDe6Fhc2ntErk3+zZjHQMVh7gR3WNLaQjHrRaSUTPrg sjYfzRIj5PS7L4ZLF4ekfd6ByR3/rZFuLcqWTPPpaVGNJSoFhikBypI6uAum+j0Dldqb1so4dV k3gW1UZdXI46ido3PZxsfzfY
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On Tue, Oct 19, 2021 at 02:52:27PM +0200, Jan Beulich wrote:
> With NPT or shadow in use, the p2m_set_entry() -> p2m_pt_set_entry() ->
> write_p2m_entry() -> p2m_flush_nestedp2m() call sequence triggers a lock
> order violation when the PoD lock is held around it. Hence such flushing
> needs to be deferred. Steal the approach from p2m_change_type_range().
> (Note that strictly speaking the change at the out_of_memory label is
> not needed, as the domain gets crashed there anyway. The change is being
> made nevertheless to avoid setting up a trap from someone meaning to
> deal with that case better than by domain_crash().)
>
> Similarly for EPT I think ept_set_entry() -> ept_sync_domain() ->
> ept_sync_domain_prepare() -> p2m_flush_nestedp2m() is affected. Make its
> p2m_flush_nestedp2m() invocation conditional. Note that this then also
> alters behavior of p2m_change_type_range() on EPT, deferring the nested
> flushes there as well. I think this should have been that way from the
> introduction of the flag.
>
> Reported-by: Elliott Mitchell <ehem+xen@xxxxxxx>
> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
Acked-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
> ---
> v2: Also adjust ept_sync_domain_prepare(). Also convert the flush at the
> out_of_memory label. Extend description to cover these.
>
> --- a/xen/arch/x86/mm/p2m-ept.c
> +++ b/xen/arch/x86/mm/p2m-ept.c
> @@ -1253,7 +1253,7 @@ static void ept_sync_domain_prepare(stru
> {
> if ( p2m_is_nestedp2m(p2m) )
> ept = &p2m_get_hostp2m(d)->ept;
> - else
> + else if ( !p2m->defer_nested_flush )
> p2m_flush_nestedp2m(d);
I find this model slightly concerning, as we don't actually notify the
caller that a nested flush as been deferred, so we must make sure that
whoever sets defer_nested_flush also performs a flush unconditionally
when clearing the flag.
Thanks, Roger.
|