]> xenbits.xensource.com Git - xen.git/commitdiff
[HVM] iommu p2m ops: check guest is translated, and maintain m2p consistency
authorTim Deegan <Tim.Deegan@xensource.com>
Thu, 20 Sep 2007 09:54:52 +0000 (10:54 +0100)
committerTim Deegan <Tim.Deegan@xensource.com>
Thu, 20 Sep 2007 09:54:52 +0000 (10:54 +0100)
Signed-off-by: Tim Deegan <Tim.Deegan@xensource.com>
xen/arch/x86/mm/p2m.c

index 5569cbe632bcde3a3272007b6576ba72f579df1e..a241d7cbb3e5f87838b0308f73b9d18b4ac7b9d7 100644 (file)
@@ -873,6 +873,18 @@ int
 set_mmio_p2m_entry(struct domain *d, unsigned long gfn, mfn_t mfn)
 {
     int rc = 0;
+    p2m_type_t ot;
+    mfn_t omfn;
+
+    if ( !paging_mode_translate(d) )
+        return 0;
+
+    omfn = gfn_to_mfn(d, gfn, &ot);
+    if ( p2m_is_ram(ot) )
+    {
+        ASSERT(mfn_valid(omfn));
+        set_gpfn_from_mfn(mfn_x(omfn), INVALID_M2P_ENTRY);
+    }
 
     rc = set_p2m_entry(d, gfn, mfn, p2m_mmio_direct);
     if ( 0 == rc )
@@ -886,8 +898,11 @@ int
 clear_mmio_p2m_entry(struct domain *d, unsigned long gfn)
 {
     int rc = 0;
-
     unsigned long mfn;
+
+    if ( !paging_mode_translate(d) )
+        return 0;
+
     mfn = gmfn_to_mfn(d, gfn);
     if ( INVALID_MFN == mfn )
     {