[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] x86/mm: Do not set page's count_info directly
# HG changeset patch # User Keir Fraser <keir.fraser@xxxxxxxxxx> # Date 1236366890 0 # Node ID f1080b20cd15e06d5fc72062c35b627b2f947339 # Parent 0942baa2a088d47f6d4fdf531163172352b1013e x86/mm: Do not set page's count_info directly Page offline patch add several flag to page_info->count_info. However, currently some code will try to set count_info after alloc_domheap_pages without using "&" or "|" operation, this may cause the new flags lost, since there are no protection. This patch try to make sure all write to count_info will only impact specific field. Also currently shadow code assume count_info is 0 for shadow page, however, this is invalid after the new flags. Change some assert in shadow code. Signed-off-by: Jiang, Yunhong <yunhong.jiang@xxxxxxxxx> --- xen/arch/x86/mm/hap/hap.c | 5 ++--- xen/arch/x86/mm/p2m.c | 4 ++-- xen/arch/x86/mm/shadow/common.c | 6 +++--- xen/arch/x86/mm/shadow/multi.c | 2 +- xen/arch/x86/mm/shadow/private.h | 2 +- 5 files changed, 9 insertions(+), 10 deletions(-) diff -r 0942baa2a088 -r f1080b20cd15 xen/arch/x86/mm/hap/hap.c --- a/xen/arch/x86/mm/hap/hap.c Fri Mar 06 19:13:23 2009 +0000 +++ b/xen/arch/x86/mm/hap/hap.c Fri Mar 06 19:14:50 2009 +0000 @@ -152,7 +152,7 @@ static struct page_info *hap_alloc_p2m_p d->arch.paging.hap.total_pages--; d->arch.paging.hap.p2m_pages++; page_set_owner(pg, d); - pg->count_info = 1; + pg->count_info |= 1; } hap_unlock(d); @@ -167,7 +167,7 @@ void hap_free_p2m_page(struct domain *d, if ( (pg->count_info & PGC_count_mask) != 1 ) HAP_ERROR("Odd p2m page count c=%#lx t=%"PRtype_info"\n", pg->count_info, pg->u.inuse.type_info); - pg->count_info = 0; + pg->count_info &= ~PGC_count_mask; /* Free should not decrement domain's total allocation, since * these pages were allocated without an owner. */ page_set_owner(pg, NULL); @@ -218,7 +218,6 @@ hap_set_allocation(struct domain *d, uns ASSERT(pg); d->arch.paging.hap.free_pages--; d->arch.paging.hap.total_pages--; - pg->count_info = 0; free_domheap_page(pg); } diff -r 0942baa2a088 -r f1080b20cd15 xen/arch/x86/mm/p2m.c --- a/xen/arch/x86/mm/p2m.c Fri Mar 06 19:13:23 2009 +0000 +++ b/xen/arch/x86/mm/p2m.c Fri Mar 06 19:14:50 2009 +0000 @@ -177,7 +177,7 @@ p2m_next_level(struct domain *d, mfn_t * return 0; page_list_add_tail(pg, &d->arch.p2m->pages); pg->u.inuse.type_info = type | 1 | PGT_validated; - pg->count_info = 1; + pg->count_info |= 1; new_entry = l1e_from_pfn(mfn_x(page_to_mfn(pg)), __PAGE_HYPERVISOR|_PAGE_USER); @@ -216,7 +216,7 @@ p2m_next_level(struct domain *d, mfn_t * return 0; page_list_add_tail(pg, &d->arch.p2m->pages); pg->u.inuse.type_info = PGT_l1_page_table | 1 | PGT_validated; - pg->count_info = 1; + pg->count_info |= 1; /* New splintered mappings inherit the flags of the old superpage, * with a little reorganisation for the _PAGE_PSE_PAT bit. */ diff -r 0942baa2a088 -r f1080b20cd15 xen/arch/x86/mm/shadow/common.c --- a/xen/arch/x86/mm/shadow/common.c Fri Mar 06 19:13:23 2009 +0000 +++ b/xen/arch/x86/mm/shadow/common.c Fri Mar 06 19:14:50 2009 +0000 @@ -1677,7 +1677,7 @@ sh_alloc_p2m_pages(struct domain *d) * believed to be a concern. */ page_set_owner(&pg[i], d); - pg[i].count_info = 1; + pg[i].count_info |= 1; page_list_add_tail(&pg[i], &d->arch.paging.shadow.p2m_freelist); } return 1; @@ -1721,7 +1721,7 @@ shadow_free_p2m_page(struct domain *d, s SHADOW_ERROR("Odd p2m page count c=%#lx t=%"PRtype_info"\n", pg->count_info, pg->u.inuse.type_info); } - pg->count_info = 0; + pg->count_info &= ~PGC_count_mask; /* Free should not decrement domain's total allocation, since * these pages were allocated without an owner. */ page_set_owner(pg, NULL); @@ -1895,7 +1895,7 @@ static void sh_hash_audit_bucket(struct while ( sp ) { /* Not a shadow? */ - BUG_ON( sp->count_info != 0 ); + BUG_ON( (sp->count_info & PGC_count_mask )!= 0 ) ; /* Bogus type? */ BUG_ON( sp->u.sh.type == 0 ); BUG_ON( sp->u.sh.type > SH_type_max_shadow ); diff -r 0942baa2a088 -r f1080b20cd15 xen/arch/x86/mm/shadow/multi.c --- a/xen/arch/x86/mm/shadow/multi.c Fri Mar 06 19:13:23 2009 +0000 +++ b/xen/arch/x86/mm/shadow/multi.c Fri Mar 06 19:14:50 2009 +0000 @@ -4281,7 +4281,7 @@ int sh_rm_write_access_from_sl1p(struct sp = mfn_to_page(smfn); - if ( sp->count_info != 0 + if ( ((sp->count_info & PGC_count_mask) != 0) || (sp->u.sh.type != SH_type_l1_shadow && sp->u.sh.type != SH_type_fl1_shadow) ) goto fail; diff -r 0942baa2a088 -r f1080b20cd15 xen/arch/x86/mm/shadow/private.h --- a/xen/arch/x86/mm/shadow/private.h Fri Mar 06 19:13:23 2009 +0000 +++ b/xen/arch/x86/mm/shadow/private.h Fri Mar 06 19:14:50 2009 +0000 @@ -647,7 +647,7 @@ static inline void sh_put_ref(struct vcp struct page_info *sp = mfn_to_page(smfn); ASSERT(mfn_valid(smfn)); - ASSERT(sp->count_info == 0); + ASSERT(!(sp->count_info & PGC_count_mask)); /* If this is the entry in the up-pointer, remove it */ if ( entry_pa != 0 _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |