Skip to contentSkip to conversation

Handle p2m_ram_ro with HAP

PATCH New Trolle Selander 1 participant 1 message Jul 31, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Handle p2m_ram_ro with HAP

I realized that I had failed to cover the hardware assisted paging case in my earlier p2m_ram_ro patches. This should fix it.
Note that I say "should" - I don't actually have an NPT or EPT capable box to test this patch on, so treat it with a modicum of caution. :) The patch also contains an update to the comment for the p2m_ram_ro type, so that it describes the current behavior.

Signed-off-by: Trolle Selander <[email protected]><[email protected]>

Binary files xen-unstable.hg-orig/.hg/dirstate and xen-unstable.hg/.hg/dirstate differ
Binary files xen-unstable.hg-orig/.hg/store/data/xen/common/page__alloc.c.i and xen-unstable.hg/.hg/store/data/xen/common/page__alloc.c.i differ Binary files xen-unstable.hg-orig/.hg/store/undo and xen-unstable.hg/.hg/store/undo differ
Binary files xen-unstable.hg-orig/.hg/undo.dirstate and xen-unstable.hg/.hg/undo.dirstate differ

xen/arch/x86/hvm/svm/svm.c +2 -2
diff -uNr xen-unstable.hg-orig/xen/arch/x86/hvm/svm/svm.c xen-unstable.hg/xen/arch/x86/hvm/svm/svm.c
@@ -874,9 +874,9 @@
     mfn_t mfn;
     unsigned long gfn = gpa >> PAGE_SHIFT;
 
-    /* If this GFN is emulated MMIO, pass the fault to the mmio handler */
+    /* If this GFN is emulated MMIO or marked as read-only, pass the fault to the mmio handler */
     mfn = gfn_to_mfn_current(gfn, &p2mt);
-    if ( p2mt == p2m_mmio_dm )
+    if ( p2mt == p2m_mmio_dm || p2mt == p2m_ram_ro )
     {
         if ( !handle_mmio() )
             hvm_inject_exception(TRAP_gp_fault, 0, 0);
xen/arch/x86/hvm/vmx/vmx.c +1 -1
diff -uNr xen-unstable.hg-orig/xen/arch/x86/hvm/vmx/vmx.c xen-unstable.hg/xen/arch/x86/hvm/vmx/vmx.c
@@ -1971,7 +1971,7 @@
     }
 
     mfn = gfn_to_mfn(d, gfn, &t);
-    if ( p2m_is_ram(t) && paging_mode_log_dirty(d) )
+    if ( (t != p2m_ram_ro) && p2m_is_ram(t) && paging_mode_log_dirty(d) )
     {
         paging_mark_dirty(d, mfn_x(mfn));
         p2m_change_type(d, gfn, p2m_ram_logdirty, p2m_ram_rw);
xen/include/asm-x86/p2m.h +1 -1
diff -uNr xen-unstable.hg-orig/xen/include/asm-x86/p2m.h xen-unstable.hg/xen/include/asm-x86/p2m.h
@@ -61,7 +61,7 @@
     p2m_invalid = 0,            /* Nothing mapped here */
     p2m_ram_rw = 1,             /* Normal read/write guest RAM */
     p2m_ram_logdirty = 2,       /* Temporarily read-only for log-dirty */
-    p2m_ram_ro = 3,             /* Read-only; writes go to the device model */
+    p2m_ram_ro = 3,             /* Read-only; writes are silently dropped */
     p2m_mmio_dm = 4,            /* Reads and write go to the device model */
     p2m_mmio_direct = 5,        /* Read/write mapping of genuine MMIO area */
 } p2m_type_t;

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel