[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 1 of 4] x86/mm: Make asserts on types and counts of shared pages more accurate
xen/arch/x86/mm/mem_sharing.c | 3 ++- xen/arch/x86/mm/p2m.c | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) Signed-off-by: Andres Lagar-Cavilla <andres@xxxxxxxxxxxxxxxx> diff -r 658530e2f380 -r a70a87d7bf84 xen/arch/x86/mm/mem_sharing.c --- a/xen/arch/x86/mm/mem_sharing.c +++ b/xen/arch/x86/mm/mem_sharing.c @@ -201,7 +201,8 @@ static struct page_info* mem_sharing_loo /* Count has to be at least two, because we're called * with the mfn locked (1) and this is supposed to be * a shared page (1). */ - ASSERT((page->u.inuse.type_info & PGT_count_mask) >= 2); + unsigned long type = read_atomic(&page->u.inuse.type_info); + ASSERT((type & PGT_shared_page) && ((type & PGT_count_mask) >= 2)); ASSERT(get_gpfn_from_mfn(mfn) == SHARED_M2P_ENTRY); return page; } diff -r 658530e2f380 -r a70a87d7bf84 xen/arch/x86/mm/p2m.c --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -735,6 +735,7 @@ set_shared_p2m_entry(struct domain *d, u p2m_access_t a; p2m_type_t ot; mfn_t omfn; + unsigned long pg_type; if ( !paging_mode_translate(p2m->domain) ) return 0; @@ -745,8 +746,10 @@ set_shared_p2m_entry(struct domain *d, u * sharable first */ ASSERT(p2m_is_shared(ot)); ASSERT(mfn_valid(omfn)); - if ( ((mfn_to_page(omfn)->u.inuse.type_info & PGT_type_mask) - != PGT_shared_page) ) + /* Set the m2p entry to invalid only if there are no further type + * refs to this page as shared */ + pg_type = read_atomic(&(mfn_to_page(omfn)->u.inuse.type_info)); + if ( !((pg_type & PGT_shared_page) && (pg_type & PGT_count_mask)) ) set_gpfn_from_mfn(mfn_x(omfn), INVALID_M2P_ENTRY); P2M_DEBUG("set shared %lx %lx\n", gfn, mfn_x(mfn)); _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |