[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] x86/ept: fix shattering of special pages
- To: xen-devel@xxxxxxxxxxxxxxxxxxxx
- From: Roger Pau Monne <roger.pau@xxxxxxxxxx>
- Date: Mon, 27 Jun 2022 12:01:19 +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=kBuumvnaZMJyv/KTx3KCJxsfkE+oOmUhJW2T6CM4exE=; b=FPoZN8Lk/7lPXVe94Cu4SasB7vlRlYRy95L2W8GvDUhP1saGdikV2CBAC0hs/82hcvSjASxSy2871G/0DwH6gvhbRLBTP8XU8ynLVee8Va7Hjx6knt4MIAfwFUOjCIAg6tdyXDexI+gpeeG7b2vBRmFIrZM8Oc2xGV27HM0I5FSXCoOrpZCxTNBDui1syT4oQgFJdz25mfXDE39NX7BhW1/ONIzKNs3HqQp6ZZtwTGJHJ7+ktKDDNj8ndIIRTPUR5wQfhCf1ms/ZhCROrY2nwflwmItKz8KuI99UCKvjDzQ29mCVr4w7NynFG3mQp7yzVhOp9Dq6tm7bk7j+P/ziPA==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LdZ9EUvKjJn0zGPEhjj5JkLybfSEC5dAZPi+fZAvmQDgxUviu6K7P3RdOR32SPClHcHOg4L73mZ0UwHMjcVYzdhwJvB9BDIDMQpFlyv+doVmZF4ma3CxmteqZCjVHf2bJIjKTsxtSUyn+0jDd30PofffUb82zZcriMTx6uLKDObARWbwXwhXA8eqt5s0qzJDhftUGZUlQr45C2ODJMN222V4t7afawig6tM+Rbyt/GwsaGhtAdOpMo0ussYzFM5+i+qhw8idd35oIx5rgVHTkjHYyfrvf5CTLmnBG3uzEY1ISlnnA/fT6EmsCvjCajKmQwwRPXKaJOfz3P28we4Xvg==
- Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
- Cc: Roger Pau Monne <roger.pau@xxxxxxxxxx>, Jun Nakajima <jun.nakajima@xxxxxxxxx>, Kevin Tian <kevin.tian@xxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Paul Durrant <paul@xxxxxxx>
- Delivery-date: Mon, 27 Jun 2022 10:02:10 +0000
- Ironport-data: A9a23:sbHizaAhsGSCdRVW/wHiw5YqxClBgxIJ4kV8jS/XYbTApDl0gmQFy GEXWT2OPffbYmT8Ld0jb9mz/ExS65bdy4BkQQY4rX1jcSlH+JHPbTi7wuYcHM8wwunrFh8PA xA2M4GYRCwMZiaA4E/raNANlFEkvU2ybuOU5NXsZ2YgH2eIdA970Ug5w7Bj3dYx6TSEK1jlV e3a8pW31GCNg1aYAkpMg05UgEoy1BhakGpwUm0WPZinjneH/5UmJMt3yZWKB2n5WuFp8tuSH I4v+l0bElTxpH/BAvv9+lryn9ZjrrT6ZWBigVIOM0Sub4QrSoXfHc/XOdJFAXq7hQllkPhym ZJ1jqGZezszI7/dp9UcajlZKnBhaPguFL/veRBTsOS15mifKT7G5aUrC0s7e4oF5uxwHGdCs +QCLywAZQyCgOTwx6+nTu5rhYIoK8yD0IE34yk8i22GS6t7B8mcHs0m5vcBtNs0rtpJEvvEI dIQdBJkbQjaYg0JMVASYH47tLj33iWgLWwDwL6TjbAOuEvvz1E26YjOO8LYfdOhXt14u2/N8 woq+Ey8WHn2Lue32TeDt36hmOLLtSf6Q54JUq218OZwh1+ezXBVDwcZPXO5vP//jEe9UtBeL kU8+ywyoKx0/0uuJvH+UgO5pjiYvxcac9tWD+A+rgqKz8L84QyUG2wFRT5pc8E9uYk9QjlC/ kCNt8PkA3poqrL9YWqU67O8vT60fy8PIgc/iTQsSAIE55zpptE1hxeWFNJ7Svfq05vyBC36x C2MoG4mnbIPgMUX1qK9u1fanzaroZuPRQkwjunKYl+YAspCTNbNT+SVBZLztJ6s8K7xooG9g UU5
- Ironport-hdrordr: A9a23:Wq/fhaAVmQr1IwjlHehKsceALOsnbusQ8zAXPh9KJCC9I/bzqy nxpp8mPH/P5wr5lktQ++xoX5PwOU80lKQFmLX5WI3PYOCIghrNEGgP1+vfKl7balDDH5BmpM BdmsFFYbWfbGSS5fyKmjVQeOxQpeVvnprY5ts3mBxWPHpXguxbnnBE4kHxKDwGeCB2Qb4CUL aM7MtOoDStPVwRc8SAH3EAG8zOvcfCmp7KaQMPQ0dP0njGsRqYrJrBVzSI1BYXVD1ChZ8k7G j+igT8ooGuqeuyxBPw33Laq75WhNzi4N1eA9HksLliFhzcziKTIKhxUbyLuz445Mmp9VYRid HJ5ywtOsxigkmhDF2dkF/I4U3NwTwu43jtxRuzmn34u/H0Qzo8Fo5omZ9ZWgGx0TtsgPhMlI Zwm06JvZteCh3N2A7n4cLTah1snk2o5VI/jO8oiWBFW4d2Us4akWUmxjIbLH48JlO11Gh+e9 MeTf00pcwmOm9yVkqp8lWGm7eXLzQO9hTveDlwhiXa6UkUoJlD9Tpm+CUupAZ9yHsDceg72w 29CNUPqFhvdL5iUUsvPpZ0feKHTkrwfDnrDEW+ZXzaKYBvAQO8l3ew2sR82N2X
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
The current logic in epte_get_entry_emt() will split any page marked
as special with order greater than zero, without checking whether the
super page is all special.
Fix this by only splitting the page only if it's not all marked as
special, in order to prevent unneeded super page shuttering.
Fixes: ca24b2ffdb ('x86/hvm: set 'ipat' in EPT for special pages')
Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
---
Cc: Paul Durrant <paul@xxxxxxx>
---
It would seem weird to me to have a super page entry in EPT with
ranges marked as special and not the full page. I guess it's better
to be safe, but I don't see an scenario where we could end up in that
situation.
I've been trying to find a clarification in the original patch
submission about how it's possible to have such super page EPT entry,
but haven't been able to find any justification.
Might be nice to expand the commit message as to why it's possible to
have such mixed super page entries that would need splitting.
---
xen/arch/x86/mm/p2m-ept.c | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/xen/arch/x86/mm/p2m-ept.c b/xen/arch/x86/mm/p2m-ept.c
index b04ca6dbe8..b4919bad51 100644
--- a/xen/arch/x86/mm/p2m-ept.c
+++ b/xen/arch/x86/mm/p2m-ept.c
@@ -491,7 +491,7 @@ int epte_get_entry_emt(struct domain *d, gfn_t gfn, mfn_t
mfn,
{
int gmtrr_mtype, hmtrr_mtype;
struct vcpu *v = current;
- unsigned long i;
+ unsigned long i, special_pgs;
*ipat = false;
@@ -525,15 +525,17 @@ int epte_get_entry_emt(struct domain *d, gfn_t gfn, mfn_t
mfn,
return MTRR_TYPE_WRBACK;
}
- for ( i = 0; i < (1ul << order); i++ )
- {
+ for ( special_pgs = i = 0; i < (1ul << order); i++ )
if ( is_special_page(mfn_to_page(mfn_add(mfn, i))) )
- {
- if ( order )
- return -1;
- *ipat = true;
- return MTRR_TYPE_WRBACK;
- }
+ special_pgs++;
+
+ if ( special_pgs )
+ {
+ if ( special_pgs != (1ul << order) )
+ return -1;
+
+ *ipat = true;
+ return MTRR_TYPE_WRBACK;
}
switch ( type )
--
2.36.1
|