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);
/* 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