[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-3.2-testing] x86: Foreign mappings of HVM-guest pages should not affect type count,
# HG changeset patch # User Keir Fraser <keir.fraser@xxxxxxxxxx> # Date 1204735773 0 # Node ID 28e0d4a37bb43079e5db0095a0eed70fc7fa8c13 # Parent 02c4362349d85afe2d1c17628629597dfca50980 x86: Foreign mappings of HVM-guest pages should not affect type count, even when the mapping is made via a grant reference. Signed-off-by: Keir Fraser <keir.fraser@xxxxxxxxxx> xen-unstable changeset: 17110:cb3e47897b85b34de1b2b3bee5812318618972a2 xen-unstable date: Mon Feb 25 11:24:06 2008 +0000 --- xen/common/grant_table.c | 24 +++++++++++++++--------- xen/include/asm-ia64/grant_table.h | 6 ++++-- xen/include/asm-powerpc/grant_table.h | 11 ++++------- xen/include/asm-x86/grant_table.h | 14 ++++++-------- 4 files changed, 29 insertions(+), 26 deletions(-) diff -r 02c4362349d8 -r 28e0d4a37bb4 xen/common/grant_table.c --- a/xen/common/grant_table.c Wed Mar 05 16:41:50 2008 +0000 +++ b/xen/common/grant_table.c Wed Mar 05 16:49:33 2008 +0000 @@ -350,10 +350,10 @@ __gnttab_map_grant_ref( else { if ( unlikely(!mfn_valid(frame)) || - unlikely(!((op->flags & GNTMAP_readonly) ? - get_page(mfn_to_page(frame), rd) : + unlikely(!(gnttab_host_mapping_get_page_type(op, ld, rd) ? get_page_and_type(mfn_to_page(frame), rd, - PGT_writable_page))) ) + PGT_writable_page) : + get_page(mfn_to_page(frame), rd))) ) { if ( !rd->is_dying ) gdprintk(XENLOG_WARNING, "Could not pin grant frame %lx\n", @@ -367,7 +367,7 @@ __gnttab_map_grant_ref( rc = create_grant_host_mapping(op->host_addr, frame, op->flags, 0); if ( rc != GNTST_okay ) { - if ( !(op->flags & GNTMAP_readonly) ) + if ( gnttab_host_mapping_get_page_type(op, ld, rd) ) put_page_type(mfn_to_page(frame)); put_page(mfn_to_page(frame)); goto undo_out; @@ -604,7 +604,7 @@ __gnttab_unmap_common_complete(struct gn if ( !is_iomem_page(op->frame) ) { - if ( !(op->flags & GNTMAP_readonly) ) + if ( gnttab_host_mapping_get_page_type(op, ld, rd) ) put_page_type(mfn_to_page(op->frame)); put_page(mfn_to_page(op->frame)); } @@ -1660,8 +1660,9 @@ gnttab_release_mappings( { BUG_ON(!(act->pin & GNTPIN_hstr_mask)); act->pin -= GNTPIN_hstr_inc; - if ( !is_iomem_page(act->frame) ) - gnttab_release_put_page(mfn_to_page(act->frame)); + if ( gnttab_release_host_mappings && + !is_iomem_page(act->frame) ) + put_page(mfn_to_page(act->frame)); } } else @@ -1678,8 +1679,13 @@ gnttab_release_mappings( { BUG_ON(!(act->pin & GNTPIN_hstw_mask)); act->pin -= GNTPIN_hstw_inc; - if ( !is_iomem_page(act->frame) ) - gnttab_release_put_page_and_type(mfn_to_page(act->frame)); + if ( gnttab_release_host_mappings && + !is_iomem_page(act->frame) ) + { + if ( gnttab_host_mapping_get_page_type(map, d, rd) ) + put_page_type(mfn_to_page(act->frame)); + put_page(mfn_to_page(act->frame)); + } } if ( (act->pin & (GNTPIN_devw_mask|GNTPIN_hstw_mask)) == 0 ) diff -r 02c4362349d8 -r 28e0d4a37bb4 xen/include/asm-ia64/grant_table.h --- a/xen/include/asm-ia64/grant_table.h Wed Mar 05 16:41:50 2008 +0000 +++ b/xen/include/asm-ia64/grant_table.h Wed Mar 05 16:49:33 2008 +0000 @@ -65,8 +65,10 @@ static inline void gnttab_clear_flag(uns clear_bit(nr, addr); } -#define gnttab_release_put_page(page) put_page((page)) -#define gnttab_release_put_page_and_type(page) put_page_and_type((page)) +#define gnttab_host_mapping_get_page_type(op, ld, rd) \ + (!((op)->flags & GNTMAP_readonly)) + +#define gnttab_release_host_mappings 1 static inline int replace_grant_supported(void) { diff -r 02c4362349d8 -r 28e0d4a37bb4 xen/include/asm-powerpc/grant_table.h --- a/xen/include/asm-powerpc/grant_table.h Wed Mar 05 16:41:50 2008 +0000 +++ b/xen/include/asm-powerpc/grant_table.h Wed Mar 05 16:49:33 2008 +0000 @@ -76,17 +76,14 @@ static inline uint cpu_foreign_map_order return 34 - PAGE_SHIFT; } -#if 0 +#define gnttab_host_mapping_get_page_type(op, ld, rd) \ + (!((op)->flags & GNTMAP_readonly)) + /* * without put_page()/put_page_and_type() page might be leaked. * with put_page()/put_page_and_type() freed page might be accessed. */ -#define gnttab_release_put_page(page) put_page((page)) -#define gnttab_release_put_page_and_type(page) put_page_and_type((page)) -#else -#define gnttab_release_put_page(page) do { } while (0) -#define gnttab_release_put_page_and_type(page) do { } while (0) -#endif +#define gnttab_release_host_mappings 0 static inline int replace_grant_supported(void) { diff -r 02c4362349d8 -r 28e0d4a37bb4 xen/include/asm-x86/grant_table.h --- a/xen/include/asm-x86/grant_table.h Wed Mar 05 16:41:50 2008 +0000 +++ b/xen/include/asm-x86/grant_table.h Wed Mar 05 16:49:33 2008 +0000 @@ -38,15 +38,13 @@ static inline void gnttab_clear_flag(uns clear_bit(nr, addr); } -#define gnttab_release_put_page(page) \ - do { \ - /* Done implicitly when page tables are destroyed. */ \ - } while (0) +/* Foreign mappings of HHVM-guest pages do not modify the type count. */ +#define gnttab_host_mapping_get_page_type(op, ld, rd) \ + (!((op)->flags & GNTMAP_readonly) && \ + (((ld) == (rd)) || !paging_mode_external(rd))) -#define gnttab_release_put_page_and_type(page) \ - do { \ - /* Done implicitly when page tables are destroyed. */ \ - } while (0) +/* Done implicitly when page tables are destroyed. */ +#define gnttab_release_host_mappings 0 static inline int replace_grant_supported(void) { _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |