[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen staging-4.15] x86/pvh: fix population of the low 1MB for dom0



commit 2a0c6e79dafeafeb1dcf9b87fcb9abc1e47b40e0
Author:     Roger Pau Monné <roger.pau@xxxxxxxxxx>
AuthorDate: Wed Jan 26 12:28:14 2022 +0100
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Wed Jan 26 12:28:14 2022 +0100

    x86/pvh: fix population of the low 1MB for dom0
    
    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>
    master commit: 2d5fc9120d556ec3c4b1acf0ab5660a6d3f7ebeb
    master date: 2022-01-25 10:52:24 +0000
---
 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 01b1356bd2..453f115847 100644
--- a/xen/arch/x86/hvm/dom0_build.c
+++ b/xen/arch/x86/hvm/dom0_build.c
@@ -465,11 +465,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 )
         {
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.15



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.