From: Keir Fraser Date: Thu, 8 Jan 2009 13:21:06 +0000 (+0000) Subject: x86: Re-instate warnings for HVM guest writes to read-only memory. X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~14014^2~92 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=21b9b29dc4008f7466b45561f8846d87c775730f;p=xen.git x86: Re-instate warnings for HVM guest writes to read-only memory. Signed-off-by: Keir Fraser --- diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index fdcea74097..0d13a79a5f 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -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); diff --git a/xen/arch/x86/mm/shadow/multi.c b/xen/arch/x86/mm/shadow/multi.c index 5f335177d0..338b8cf5dd 100644 --- a/xen/arch/x86/mm/shadow/multi.c +++ b/xen/arch/x86/mm/shadow/multi.c @@ -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