[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen master] x86: add a new p2m type class - P2M_DISCARD_WRITE_TYPES
commit 1c02cce0edfa53190b58fa4a1451f47be4d0f1c4 Author: Yu Zhang <yu.c.zhang@xxxxxxxxxxxxxxx> AuthorDate: Wed Jan 7 11:25:55 2015 +0100 Commit: Jan Beulich <jbeulich@xxxxxxxx> CommitDate: Wed Jan 7 11:25:55 2015 +0100 x86: add a new p2m type class - P2M_DISCARD_WRITE_TYPES Currently, the P2M_RO_TYPES bears 2 meanings: one is "_PAGE_RW bit is clear in their PTEs", and another is to discard the write operations on these pages. This patch adds a p2m type class, P2M_DISCARD_WRITE_TYPES, to bear the second meaning, so we can use this type class instead of the P2M_RO_TYPES, to decide if a write operation is to be ignored. Signed-off-by: Yu Zhang <yu.c.zhang@xxxxxxxxxxxxxxx> Reviewed-by: Tim Deegan <tim@xxxxxxx> Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx> --- xen/arch/x86/hvm/hvm.c | 16 +++------------- xen/arch/x86/mm/shadow/multi.c | 2 +- xen/include/asm-x86/p2m.h | 5 +++++ 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index e33cd0a..5e2e7ce 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -2837,7 +2837,7 @@ int hvm_hap_nested_page_fault(paddr_t gpa, unsigned long gla, * to the mmio handler. */ if ( (p2mt == p2m_mmio_dm) || - (npfec.write_access && (p2mt == p2m_ram_ro)) ) + (npfec.write_access && (p2m_is_discard_write(p2mt))) ) { put_gfn(p2m->domain, gfn); @@ -2882,16 +2882,6 @@ int hvm_hap_nested_page_fault(paddr_t gpa, unsigned long gla, goto out_put_gfn; } - /* Shouldn't happen: Maybe the guest was writing to a r/o grant mapping? */ - if ( npfec.write_access && (p2mt == p2m_grant_map_ro) ) - { - gdprintk(XENLOG_WARNING, - "trying to write to read-only grant mapping\n"); - hvm_inject_hw_exception(TRAP_gp_fault, 0); - rc = 1; - goto out_put_gfn; - } - /* If we fell through, the vcpu will retry now that access restrictions have * been removed. It may fault again if the p2m entry type still requires so. * Otherwise, this is an error condition. */ @@ -3941,7 +3931,7 @@ static enum hvm_copy_result __hvm_copy( if ( flags & HVMCOPY_to_guest ) { - if ( p2mt == p2m_ram_ro ) + if ( p2m_is_discard_write(p2mt) ) { static unsigned long lastpage; if ( xchg(&lastpage, gfn) != gfn ) @@ -4035,7 +4025,7 @@ static enum hvm_copy_result __hvm_clear(paddr_t addr, int size) p = (char *)__map_domain_page(page) + (addr & ~PAGE_MASK); - if ( p2mt == p2m_ram_ro ) + if ( p2m_is_discard_write(p2mt) ) { static unsigned long lastpage; if ( xchg(&lastpage, gfn) != gfn ) diff --git a/xen/arch/x86/mm/shadow/multi.c b/xen/arch/x86/mm/shadow/multi.c index 225290e..94cf06d 100644 --- a/xen/arch/x86/mm/shadow/multi.c +++ b/xen/arch/x86/mm/shadow/multi.c @@ -4575,7 +4575,7 @@ static mfn_t emulate_gva_to_mfn(struct vcpu *v, { return _mfn(BAD_GFN_TO_MFN); } - if ( p2m_is_readonly(p2mt) ) + if ( p2m_is_discard_write(p2mt) ) { put_page(page); return _mfn(READONLY_GFN); diff --git a/xen/include/asm-x86/p2m.h b/xen/include/asm-x86/p2m.h index 5f7fe71..42de75d 100644 --- a/xen/include/asm-x86/p2m.h +++ b/xen/include/asm-x86/p2m.h @@ -113,6 +113,10 @@ typedef unsigned int p2m_query_t; | p2m_to_mask(p2m_grant_map_ro) \ | p2m_to_mask(p2m_ram_shared) ) +/* Write-discard types, which should discard the write operations */ +#define P2M_DISCARD_WRITE_TYPES (p2m_to_mask(p2m_ram_ro) \ + | p2m_to_mask(p2m_grant_map_ro)) + /* Types that can be subject to bulk transitions. */ #define P2M_CHANGEABLE_TYPES (p2m_to_mask(p2m_ram_rw) \ | p2m_to_mask(p2m_ram_logdirty) ) @@ -145,6 +149,7 @@ typedef unsigned int p2m_query_t; #define p2m_is_hole(_t) (p2m_to_mask(_t) & P2M_HOLE_TYPES) #define p2m_is_mmio(_t) (p2m_to_mask(_t) & P2M_MMIO_TYPES) #define p2m_is_readonly(_t) (p2m_to_mask(_t) & P2M_RO_TYPES) +#define p2m_is_discard_write(_t) (p2m_to_mask(_t) & P2M_DISCARD_WRITE_TYPES) #define p2m_is_changeable(_t) (p2m_to_mask(_t) & P2M_CHANGEABLE_TYPES) #define p2m_is_pod(_t) (p2m_to_mask(_t) & P2M_POD_TYPES) #define p2m_is_grant(_t) (p2m_to_mask(_t) & P2M_GRANT_TYPES) -- generated by git-patchbot for /home/xen/git/xen.git#master _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |