x86: Re-instate warnings for HVM guest writes to read-only memory.
authorKeir Fraser <keir.fraser@citrix.com>
Thu, 8 Jan 2009 13:21:06 +0000 (13:21 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Thu, 8 Jan 2009 13:21:06 +0000 (13:21 +0000)
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
xen/arch/x86/hvm/hvm.c
xen/arch/x86/mm/shadow/multi.c

index fdcea74097b1945a29ccf732a916a617132ab9b0..0d13a79a5f0c811b5565e15d4402e3631582b376 100644 (file)
@@ -1503,7 +1503,15 @@ static enum hvm_copy_result __hvm_copy(
 
         if ( flags & HVMCOPY_to_guest )
         {
-            if ( p2mt != p2m_ram_ro )
+            if ( p2mt == p2m_ram_ro )
+            {
+                static unsigned long lastpage;
+                if ( xchg(&lastpage, gfn) != gfn )
+                    gdprintk(XENLOG_DEBUG, "guest attempted write to read-only"
+                             " memory page. gfn=%#lx, mfn=%#lx\n",
+                             gfn, mfn);
+            }
+            else
             {
                 memcpy(p, buf, count);
                 paging_mark_dirty(curr->domain, mfn);
index 5f335177d025c287c9a83efeb6ca311ead788755..338b8cf5ddf3c70ea9e8d434b5a1a1307e256c75 100644 (file)
@@ -3230,7 +3230,14 @@ static int sh_page_fault(struct vcpu *v,
 
     /* Ignore attempts to write to read-only memory. */
     if ( (p2mt == p2m_ram_ro) && (ft == ft_demand_write) )
+    {
+        static unsigned long lastpage;
+        if ( xchg(&lastpage, va & PAGE_MASK) != (va & PAGE_MASK) )
+            gdprintk(XENLOG_DEBUG, "guest attempted write to read-only memory"
+                     " page. va page=%#lx, mfn=%#lx\n",
+                     va & PAGE_MASK, mfn_x(gmfn));
         goto emulate_readonly; /* skip over the instruction */
+    }
 
     /* In HVM guests, we force CR0.WP always to be set, so that the
      * pagetables are always write-protected.  If the guest thinks