[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2] 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 17:13:12 +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=fDywZwv3SCqlZfNHbQvneXAQdtFlWktPZEYLJwrCW/k=; b=MKECp8V1iPB9ziwyZSEffYK1rZdfWLzKxnxDXjucj6AHxtMqH6FMXnyVTvfTWP3SMip/MUSkKfNeHeCzpSL45RahLS2/jJV8HOqayOvr8r4XojPlk2LqRF67HGHs7S6E/AtQ1sqLpQE3A+ajaWrpqtfthWcyWK6LwVCeYcwXEa3Wq2botc1V6bgeaCRHcOCuUJlwosuEGUfx0Dm7KQmjJAozq+iF9QNSlXvBrkHuPYrZ9q0OlY9HXKi/DRRRKlX5PTFhU3wzqkx7pvrop6AGblwyiV+089dvOP7vQRUvZDC3Sf051cOK1wUqniyqLph/17kjRZiDwXyDrPIh3ShCzQ==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=miygD46idXtazNb3cKXt1ZD3UKev3kuAvBeaBnbKXlKkULHDqPpN7FecGA0LzQi1I2eWQHGiHGQ8JC/CKnLaH7ySkSNj8oFmy3c9ykxhJd94e6YOidD7A8oo2f5XOHSAX1g38nXCinUw5mmCOJCQDhTGhB3kSlwQH9bJeaMZ/mU6KiWYh5Vpb6mtyQiMjTlkhCsUmwSCd/NVSfsxjl04GaaAmAgYKs7ov++B5p0Z130GSmeCZZK7S/WEOUiPUfASXvpigQdQCJVb52wg9McFxMU3513uRnjGHY6yZz+CFm1gj/jZ6KClRq4CpiWxESPib921nDyB2MC4zwR8V/v0SA==
- Authentication-results: esa1.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 16:13:37 +0000
- Ironport-data: A9a23:Wnmf9qw/4ITS8RavTr96t+flwSrEfRIJ4+MujC+fZmUNrF6WrkVRm 2ZMDzjXbq2JYTejL9knOYm080wAu5+Bz4dkSFNsqCAxQypGp/SeCIXCJC8cHc8zwu4v7q5Dx 59DAjUVBJlsFhcwnvopW1TYhSEUOZugH9IQM8aZfHAhLeNYYH1500g7wrRl2tcAbeWRWGthh /uj+6UzB3f9s9JEGjp8B3Wr8U4HUFza4Vv0j3RmDRx5lAa2e0o9VfrzEZqZPXrgKrS4K8bhL wr1IBNVyUuCl/slIovNfr8W6STmSJaKVeSFoiI+t6RPHnGuD8H9u0o2HKN0VKtZt9mGt91h6 t5iloGwcyIWHqPCsskxdiEALD4raMWq+JefSZS+mcmazkmAeHrw2fR+SkoxOOX0+M4uXzsIr 6ZBbmlQMFbT3Ipaw5riIgVort4kI8TxepsWp1lrzC3DDOZgSpfGK0nPzYEDhGtu3Z4XdRrYT 9YiSgJrPErtXz9KNxRPDpA7lsn3v1CqJlW0r3rK/PFqsgA/1jdZz7zFINfTPNuQSq19nEyVu 2bH9GTRGQwBOZqUzj/t2mKhgKrDkD32XKoWFaak7bh6jVuL3GsRBRYKE1yhrpGEZlWWAowFb RZOo2x38PZ0pBfDosTBswOQrW6mtTE/RtpqNtIa5g+n54bx216mGT1RJtJeU+AOuMgzTD0s8 1aGmdL1GDBi2IGopWKhGqS89m3rZ3VMRYMWTWpdFFZevYG/yG0mp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sWPXCncTCkNbDbQQdDxAqxQGShXfwgYSKWCSw71M7aXdi0L0i+W /Kn0jQ4biiieiyzlv523XI55pbtdP9wp9oBdCKiOISNjLw4zzYLLhJavmnhnQYseuv4FElnJ 3lpAohBd167zfrcmS8sXLWqn3d+Qdrz0Wn5U6TgHPlr8C8bik9EdB9iYVQdQacw1Y8vflnuZ g7k16xht5yN1ftjS7979/HW1VBjUyvu0cvluYVkjh2TZYeUrlMtoYSlXklXavoJBiKprzPLd MeTf01vJ1tABOnhjHizyNSKeWXLzsO9kzseDlAhiSXuwIm6UyRgXFohvD3pU1wha7VfaM0ld gsAp4Y6o2mcfVmHZ6VfN1xOfdfKla9Ni4kY1jiV2gOKsk8SgHwQtjMkfAI2N0=
- Ironport-sdr: 5J1XyW7jpxnKwvS4Hl1hgWRZvOekUtORXIdWyblPDbHRqUnAzFpS+OCiEA1Pb5XaemoC6tJEbT 4fsCoXipJV+BpvEydsi/Z9j86Aonnwh/e2IvqtS/79+hn8UcCW0eSie+W6E24mrKPyNro7seRm VvwNvxH8m/7zm3Mtvr/IYHyt37b22jnTDTgG+O8/ttd/5269Q+ZRdEIyN+oIw8d/ykYOQRK4ur KDD16seAs+pTgfZSrQkWM/pWPQP5vQAg7qMZAP9Yc7nIcCyqZ2FVjGDnV/yAsQFvcwEw4T6SDx qE54bN2O1hdiCfuSYlzk9dAs
- 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>
Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
---
Changes since v1:
- Fix indentation.
- Expand existing assert.
---
xen/arch/x86/hvm/dom0_build.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/xen/arch/x86/hvm/dom0_build.c b/xen/arch/x86/hvm/dom0_build.c
index b00e45885c..63dceb2116 100644
--- a/xen/arch/x86/hvm/dom0_build.c
+++ b/xen/arch/x86/hvm/dom0_build.c
@@ -466,11 +466,16 @@ static int __init pvh_populate_p2m(struct domain *d)
for ( i = rc = 0; i < MB1_PAGES; ++i )
{
p2m_type_t p2mt;
+ mfn_t mfn = get_gfn_query(d, i, &p2mt);
- if ( mfn_eq(get_gfn_query(d, i, &p2mt), INVALID_MFN) )
+ 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);
+ /*
+ * If the p2m entry is already set it must belong to a RMRR and
+ * already be identity mapped, or be a RAM region.
+ */
+ ASSERT(p2mt == p2m_ram_rw || mfn_eq(mfn, _mfn(i)));
put_gfn(d, i);
if ( rc )
{
--
2.34.1
|