[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] x86/pvh: fix population of the low 1MB for dom0
- To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
- From: Roger Pau Monne <roger.pau@xxxxxxxxxx>
- Date: Mon, 24 Jan 2022 16:23:16 +0100
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=9Fcmxul0WcH9tCwscw4bf/6Se6SVoxRS1aD5DGoEopw=; b=BF3VrqfUXkkOjmWjKD5ikTOuMS9Y81A1bzNueTqAmqJ+/xrdq48jjZDreiwQ+2lbjw8HUGsXGDuQ62qBrVmBQOZ3xGYL/5Su/zEhFN9phX20bK8wum5RHWj5x8jo4jrUew9T2JxT9GfCOUjryhHGj2GXUKZuSZdDcXLKzIVJ7/ZUMEsuPoNGJDtkydDX9uvLar91JthrOj/IHJzJYvoqp0JxY5Do6RNwcAZ+RRVI++Vo8najOudbHQcD6C2/8P/c/pZtHNLobLJwDVkin88a4HUyKgg7mJ323d4hkOfse7zjMuIw52lClj3N/RliMsmAf0dk7XTx9ABCXvImdgIbUQ==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Tjdj1diuw5YXZeMwmzb4JJGU8PXkhizLMJkKkBUZ2Gl4PHx0meO6PBtlaIfUN5HbxvaxWuAijRvEMq/+kis7lBKMlxzO3KRaxjRb9lH5Nz1ySartaGapg6o1HiLVSGCd2xvUxg+vq4MtwBiqPOD5rzCO35g9VHz9RSU/LNfqDDrGb7oUCcCPrCO3LivwCMbXuJQEhm1HUHbDpzSTMgKWOsINhxFpa29CSq/yjFYes5JV0UXY+ScZYh4j92/U6REuZmN59yhmyXXQvFzMhPNZsl6CK9mtqu0atypCqrLdCPzz2h0jjyhpXN8eQ2ew/+dwsc1dvwZIxbja+Ql8wzV3TA==
- Authentication-results: esa3.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
- Cc: Roger Pau Monne <roger.pau@xxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
- Delivery-date: Mon, 24 Jan 2022 15:23:48 +0000
- Ironport-data: A9a23:j2avx675VmVrpAi7i94JqQxRtOrAchMFZxGqfqrLsTDasY5as4F+v jceXjiEMvbYNjf2f9p0Yd6xoEsHusXRydFjHQo6rn83Hi5G8cbLO4+Ufxz6V8+wwmwvb67FA +E2MISowBUcFyeEzvuV3zyIQUBUjclkfJKlYAL/En03FV8MpBsJ00o5wbZg2NIw2LBVPivW0 T/Mi5yHULOa82Yc3lI8s8pvfzs24ZweEBtB1rAPTagjUG32zhH5P7pGTU2FFFPqQ5E8IwKPb 72rIIdVXI/u10xF5tuNyt4Xe6CRK1LYFVDmZnF+A8BOjvXez8CbP2lS2Pc0MC9qZzu1c99Zm NNLtaW7axoVHIb8kuU8TwNlPwAjIvgTkFPHCSDXXc27ykTHdz3nwul0DVFwNoodkgp1KTgQr 7pCcmlLN03dwbLtqF64YrAEasALNs7kMZlZonh95TrYEewnUdbIRKCiCdpwgm1u3ZsXRa22i 8wxch40djXgZwFzPFpOObgQxceCu2ncbGgNwL6SjfVuuDWCpOBr65DyNPLFd9rMQt9a9m6ar G/b+2XyAjkBKceSjzGC9xqEluLJ2C/2Ro8WPLm57eJxxk2ewHQJDx8bXkf9puO24nNSQPoGd RZSoHB36/Fvqgr7FbERQiFUvlbUuBgcYtFyDtEYwzGHy4vI+Tu1JzUbG2sphMMdiOc6Qjkj1 1msltzvBCByvLD9dU9x5ot4vhvpZ3FLcDZqiTssCFJcvoK9+N1bYgfn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p7KaQMPQ0dP0njFsRqYrJrBVzSI1BYXVD1ChZ8k7G j+igT8ooGuqeuyxBPw33Laq75WhNzi4N1eA9HksLlfFhzcziKTIKhxUbyLuz445Mmp9VYRid HJ5ywtOsxigkmhCV2dkF/I4U3NwTwu43jtxRuzmn34u/H0Qzo8Fo5omZ9ZWgGx0TtugPhMlI Zwm06JvZteCh3N2A7n4cLTah1snk2o5VI/jO8oiWBFW4d2Us4ckWUmxjIVLH48JlO71Gh+e9 MeT/00pcwmPG9yVkqp8FWGm7eXLzYO9hTveDl3hiXa6UkSoJlD9Tpp+CUopAZ0yHsMceg02w 36CNUaqFg3dL5sUUtcPpZ2fSLlMB2FffrzWFjiU2gPUpt3f07wlw==
- Ironport-sdr: 7DZU3U+KG/fm0IbDCaId5dNTGxeHqvh/z2zxdqRyNq7Vl5LEpU02RNkKsqSZxI87KWvn4XloWn fllZG20nXOUDtMgJU8I0rMdswboOCgOlXf/3qQGMXo3+oRP5rSL01xxvuGmGFsbM0qeRfgyHGI VdDpialcSH44qptU/zbgrOEEV6wv69go674r0HkdXh60hu+iIKau9VHW8DmEuqWtaPcMJKUvdH iYldlOVh5UZ/lQSCVB79lKeXCiEr453ZD6ZozjOhjm7xToAz0FTvskgkxRqhgMFYOy6fXEMz2o +AMIHZ+L9s/evJubB5+A9PKW
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
RMRRs are setup ahead of populating the p2m and hence the ASSERT when
populating the low 1MB needs to be relaxed when it finds an existing
entry: it's either RAM or a RMRR resulting from the IOMMU setup.
Rework the logic a bit and introduce a local mfn variable in order to
assert that if the gfn is populated and not RAM it is an identity map.
Fixes: 6b4f6a31ac ('x86/PVH: de-duplicate mappings for first Mb of Dom0 memory')
Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
---
xen/arch/x86/hvm/dom0_build.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/xen/arch/x86/hvm/dom0_build.c b/xen/arch/x86/hvm/dom0_build.c
index b00e45885c..739bb8adb6 100644
--- a/xen/arch/x86/hvm/dom0_build.c
+++ b/xen/arch/x86/hvm/dom0_build.c
@@ -466,11 +466,17 @@ static int __init pvh_populate_p2m(struct domain *d)
for ( i = rc = 0; i < MB1_PAGES; ++i )
{
p2m_type_t p2mt;
+ mfn_t mfn;
- if ( mfn_eq(get_gfn_query(d, i, &p2mt), INVALID_MFN) )
+ mfn = get_gfn_query(d, i, &p2mt);
+ if ( mfn_eq(mfn, INVALID_MFN) )
rc = set_mmio_p2m_entry(d, _gfn(i), _mfn(i), PAGE_ORDER_4K);
- else
- ASSERT(p2mt == p2m_ram_rw);
+ else if ( p2mt != p2m_ram_rw && !mfn_eq(mfn, _mfn(i)) )
+ /*
+ * If the p2m entry is already set it must belong to a RMRR and
+ * already be identity mapped, or be a RAM region.
+ */
+ ASSERT_UNREACHABLE();
put_gfn(d, i);
if ( rc )
{
--
2.34.1
|