Skip to contentSkip to conversation

xen: allow guest_remove_page to remove p2m_mmio_direct pages

PATCH In review Roger Pau Monne 2 participants 3 messages Jun 19, 2014

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 xen: allow guest_remove_page to remove p2m_mmio_direct pages

IF a guest tries to do a foreign/grant mapping in a memory region marked as p2m_mmio_direct Xen will complain with the following message:

(XEN) memory.c:241:d0v0 Bad page free for domain 0

Albeit the mapping will succeed. This is specially problematic for PVH Dom0, in which we map all the e820 holes and memory up to 4GB as p2m_mmio_direct.

In order to deal with it, add a special casing for p2m_mmio_direct regions in guest_remove_page if the domain is a hardware domain, that calls clear_mmio_p2m_entry in order to remove the mappings.

Cc Ian Campbell <[email protected]>
Cc Ian Jackson <[email protected]>
Cc Jan Beulich <[email protected]>
Cc Keir Fraser <[email protected]>
Cc Tim Deegan <[email protected]>

---
Changes since v1:
- Remove the is_hardware_domain check.

---
 xen/common/memory.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
xen/common/memory.c +6 -0
index 257f4b0..c2dd31b 100644
@@ -204,6 +204,12 @@ int guest_remove_page(struct domain *d, unsigned long gmfn)
         p2m_mem_paging_drop_page(d, gmfn, p2mt);
         return 1;
     }
+    if ( p2mt == p2m_mmio_direct )
+    {
+        clear_mmio_p2m_entry(d, gmfn);
+        put_gfn(d, gmfn);
+        return 1;
+    }
 #else
     mfn = gmfn_to_mfn(d, gmfn);
 #endif
Signature · 7 lines
1.7.7.5 (Apple Git-26)


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Acked-by on v2 1/1
#1 lore raw
Quoted 10 lines · Roger Pau Monne

IF a guest tries to do a foreign/grant mapping in a memory region marked as p2m_mmio_direct Xen will complain with the following message:

(XEN) memory.c:241:d0v0 Bad page free for domain 0

Albeit the mapping will succeed. This is specially problematic for PVH Dom0, in which we map all the e820 holes and memory up to 4GB as p2m_mmio_direct.

Quoted 5 lines

In order to deal with it, add a special casing for p2m_mmio_direct regions in guest_remove_page if the domain is a hardware domain, that calls clear_mmio_p2m_entry in order to remove the mappings.

as being an improvement on what's there right now. But as I said, I think code that relies on this is probably doing the wrong thing -- in this case having MMIOmaps og all non-RAM areas seems wrong; dom0 ought to know what addresses are really hardware and map them appropriately.

Tim.

Quoted 27 lines

---
Changes since v1:
- Remove the is_hardware_domain check.

---
 xen/common/memory.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
xen/common/memory.c +6 -0
index 257f4b0..c2dd31b 100644
@@ -204,6 +204,12 @@ int guest_remove_page(struct domain *d, unsigned long gmfn)
         p2m_mem_paging_drop_page(d, gmfn, p2mt);
         return 1;
     }
+    if ( p2mt == p2m_mmio_direct )
+    {
+        clear_mmio_p2m_entry(d, gmfn);
+        put_gfn(d, gmfn);
+        return 1;
+    }
 #else
     mfn = gmfn_to_mfn(d, gmfn);
 #endif
Signature · 1 line
1.7.7.5 (Apple Git-26)
#2 lore raw
Quoted 15 lines · Tim Deegan
Quoted 14 lines · Roger Pau Monne

IF a guest tries to do a foreign/grant mapping in a memory region marked as p2m_mmio_direct Xen will complain with the following message:

(XEN) memory.c:241:d0v0 Bad page free for domain 0

Albeit the mapping will succeed. This is specially problematic for PVH Dom0, in which we map all the e820 holes and memory up to 4GB as p2m_mmio_direct.

In order to deal with it, add a special casing for p2m_mmio_direct regions in guest_remove_page if the domain is a hardware domain, that calls clear_mmio_p2m_entry in order to remove the mappings.

Quoted 8 lines
Quoted 1 line

as being an improvement on what's there right now. But as I said, I think code that relies on this is probably doing the wrong thing -- in this case having MMIOmaps og all non-RAM areas seems wrong; dom0 ought to know what addresses are really hardware and map them appropriately.

Yes, the problem is mainly in the Xen Dom0 PVH domain builder, that maps all holes and not assigned memory up to 4GB as MMIO in the p2m. I will look into finding a better way to do this.

Roger.