ia64/xen-unstable

changeset 19013:6cec460c3290

x86: Re-instate warnings for HVM guest writes to read-only memory.
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Jan 08 13:21:06 2009 +0000 (2009-01-08)
parents 7df072566b8c
children 1025a725d45b
files xen/arch/x86/hvm/hvm.c xen/arch/x86/mm/shadow/multi.c
line diff
     1.1 --- a/xen/arch/x86/hvm/hvm.c	Thu Jan 08 13:15:49 2009 +0000
     1.2 +++ b/xen/arch/x86/hvm/hvm.c	Thu Jan 08 13:21:06 2009 +0000
     1.3 @@ -1503,7 +1503,15 @@ static enum hvm_copy_result __hvm_copy(
     1.4  
     1.5          if ( flags & HVMCOPY_to_guest )
     1.6          {
     1.7 -            if ( p2mt != p2m_ram_ro )
     1.8 +            if ( p2mt == p2m_ram_ro )
     1.9 +            {
    1.10 +                static unsigned long lastpage;
    1.11 +                if ( xchg(&lastpage, gfn) != gfn )
    1.12 +                    gdprintk(XENLOG_DEBUG, "guest attempted write to read-only"
    1.13 +                             " memory page. gfn=%#lx, mfn=%#lx\n",
    1.14 +                             gfn, mfn);
    1.15 +            }
    1.16 +            else
    1.17              {
    1.18                  memcpy(p, buf, count);
    1.19                  paging_mark_dirty(curr->domain, mfn);
     2.1 --- a/xen/arch/x86/mm/shadow/multi.c	Thu Jan 08 13:15:49 2009 +0000
     2.2 +++ b/xen/arch/x86/mm/shadow/multi.c	Thu Jan 08 13:21:06 2009 +0000
     2.3 @@ -3230,7 +3230,14 @@ static int sh_page_fault(struct vcpu *v,
     2.4  
     2.5      /* Ignore attempts to write to read-only memory. */
     2.6      if ( (p2mt == p2m_ram_ro) && (ft == ft_demand_write) )
     2.7 +    {
     2.8 +        static unsigned long lastpage;
     2.9 +        if ( xchg(&lastpage, va & PAGE_MASK) != (va & PAGE_MASK) )
    2.10 +            gdprintk(XENLOG_DEBUG, "guest attempted write to read-only memory"
    2.11 +                     " page. va page=%#lx, mfn=%#lx\n",
    2.12 +                     va & PAGE_MASK, mfn_x(gmfn));
    2.13          goto emulate_readonly; /* skip over the instruction */
    2.14 +    }
    2.15  
    2.16      /* In HVM guests, we force CR0.WP always to be set, so that the
    2.17       * pagetables are always write-protected.  If the guest thinks