From 0242c25fe8b2f4a7ce3ced408a27fc18e264a020 Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Thu, 6 Dec 2007 17:29:12 +0000 Subject: [PATCH] x86: Move get_page/put_page out of header file, and only print on get_page() failure if the domain is not dying. Signed-off-by: Keir Fraser xen-unstable changeset: 16492:8e3d42fdb8e784b947fbd998d9a6df0ebf771718 xen-unstable date: Tue Dec 04 09:56:10 2007 +0000 --- xen/arch/x86/mm.c | 49 ++++++++++++++++++++++++++++++++++++++ xen/include/asm-x86/mm.h | 51 ++-------------------------------------- 2 files changed, 51 insertions(+), 49 deletions(-) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index c09ae3117..23d407da4 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -1563,6 +1563,55 @@ static int mod_l4_entry(struct domain *d, #endif +void put_page(struct page_info *page) +{ + u32 nx, x, y = page->count_info; + + do { + x = y; + nx = x - 1; + } + while ( unlikely((y = cmpxchg(&page->count_info, x, nx)) != x) ); + + if ( unlikely((nx & PGC_count_mask) == 0) ) + free_domheap_page(page); +} + + +int get_page(struct page_info *page, struct domain *domain) +{ + u32 x, nx, y = page->count_info; + u32 d, nd = page->u.inuse._domain; + u32 _domain = pickle_domptr(domain); + + do { + x = y; + nx = x + 1; + d = nd; + if ( unlikely((x & PGC_count_mask) == 0) || /* Not allocated? */ + unlikely((nx & PGC_count_mask) == 0) || /* Count overflow? */ + unlikely(d != _domain) ) /* Wrong owner? */ + { + if ( !_shadow_mode_refcounts(domain) && !domain->is_dying ) + gdprintk(XENLOG_INFO, + "Error pfn %lx: rd=%p, od=%p, caf=%08x, taf=%" + PRtype_info "\n", + page_to_mfn(page), domain, unpickle_domptr(d), + x, page->u.inuse.type_info); + return 0; + } + __asm__ __volatile__( + LOCK_PREFIX "cmpxchg8b %3" + : "=d" (nd), "=a" (y), "=c" (d), + "=m" (*(volatile u64 *)(&page->count_info)) + : "0" (d), "1" (x), "c" (d), "b" (nx) ); + } + while ( unlikely(nd != d) || unlikely(y != x) ); + + return 1; +} + + int alloc_page_type(struct page_info *page, unsigned long type) { struct domain *owner = page_get_owner(page); diff --git a/xen/include/asm-x86/mm.h b/xen/include/asm-x86/mm.h index 43d03ec17..5918cb481 100644 --- a/xen/include/asm-x86/mm.h +++ b/xen/include/asm-x86/mm.h @@ -148,55 +148,8 @@ int alloc_page_type(struct page_info *page, unsigned long type); void free_page_type(struct page_info *page, unsigned long type); int _shadow_mode_refcounts(struct domain *d); -static inline void put_page(struct page_info *page) -{ - u32 nx, x, y = page->count_info; - - do { - x = y; - nx = x - 1; - } - while ( unlikely((y = cmpxchg(&page->count_info, x, nx)) != x) ); - - if ( unlikely((nx & PGC_count_mask) == 0) ) - free_domheap_page(page); -} - - -static inline int get_page(struct page_info *page, - struct domain *domain) -{ - u32 x, nx, y = page->count_info; - u32 d, nd = page->u.inuse._domain; - u32 _domain = pickle_domptr(domain); - - do { - x = y; - nx = x + 1; - d = nd; - if ( unlikely((x & PGC_count_mask) == 0) || /* Not allocated? */ - unlikely((nx & PGC_count_mask) == 0) || /* Count overflow? */ - unlikely(d != _domain) ) /* Wrong owner? */ - { - if ( !_shadow_mode_refcounts(domain) ) - gdprintk(XENLOG_INFO, - "Error pfn %lx: rd=%p, od=%p, caf=%08x, taf=%" - PRtype_info "\n", - page_to_mfn(page), domain, unpickle_domptr(d), - x, page->u.inuse.type_info); - return 0; - } - __asm__ __volatile__( - LOCK_PREFIX "cmpxchg8b %3" - : "=d" (nd), "=a" (y), "=c" (d), - "=m" (*(volatile u64 *)(&page->count_info)) - : "0" (d), "1" (x), "c" (d), "b" (nx) ); - } - while ( unlikely(nd != d) || unlikely(y != x) ); - - return 1; -} - +void put_page(struct page_info *page); +int get_page(struct page_info *page, struct domain *domain); void put_page_type(struct page_info *page); int get_page_type(struct page_info *page, unsigned long type); int get_page_from_l1e(l1_pgentry_t l1e, struct domain *d); -- 2.39.5