# HG changeset patch # User yamahata@xxxxxxxxxxxxx # Date 1173943536 -32400 # Node ID c268103362bb5183d7aa3f0e7abb2e6649281c3a # Parent 817647aff01f2770aa60064cac0445a2169a18b3 Add tow arch hooks to gnttab_release_mappings(). The c/s 8409:b3edbeea3e79 changed gnttab_release_mappings() such that it doesn't put page/type reference count because it is done implicitly when page table is destructed. It is x86 specific issue and it isn't the case for ia64 and powerpc. Introduce two arch hook to address it. PATCHNAME: gnttab_release_mappings_put_page_and_type Signed-off-by: Isaku Yamahata diff -r 817647aff01f -r c268103362bb xen/common/grant_table.c --- a/xen/common/grant_table.c Wed Mar 14 14:18:51 2007 -0700 +++ b/xen/common/grant_table.c Thu Mar 15 16:25:36 2007 +0900 @@ -1392,8 +1392,7 @@ gnttab_release_mappings( { BUG_ON(!(act->pin & GNTPIN_hstr_mask)); act->pin -= GNTPIN_hstr_inc; - /* Done implicitly when page tables are destroyed. */ - /* put_page(mfn_to_page(act->frame)); */ + gnttab_release_put_page(mfn_to_page(act->frame)); } } else @@ -1409,8 +1408,7 @@ gnttab_release_mappings( { BUG_ON(!(act->pin & GNTPIN_hstw_mask)); act->pin -= GNTPIN_hstw_inc; - /* Done implicitly when page tables are destroyed. */ - /* put_page_and_type(mfn_to_page(act->frame)); */ + gnttab_release_put_page_and_type(mfn_to_page(act->frame)); } if ( (act->pin & (GNTPIN_devw_mask|GNTPIN_hstw_mask)) == 0 ) diff -r 817647aff01f -r c268103362bb xen/include/asm-ia64/grant_table.h --- a/xen/include/asm-ia64/grant_table.h Wed Mar 14 14:18:51 2007 -0700 +++ b/xen/include/asm-ia64/grant_table.h Thu Mar 15 16:25:36 2007 +0900 @@ -64,4 +64,7 @@ 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)) + #endif /* __ASM_GRANT_TABLE_H__ */ diff -r 817647aff01f -r c268103362bb xen/include/asm-powerpc/grant_table.h --- a/xen/include/asm-powerpc/grant_table.h Wed Mar 14 14:18:51 2007 -0700 +++ b/xen/include/asm-powerpc/grant_table.h Thu Mar 15 16:25:36 2007 +0900 @@ -69,4 +69,17 @@ static inline uint cpu_foreign_map_order /* 16 GiB */ return 34 - PAGE_SHIFT; } + +#if 0 +/* + * 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 + #endif /* __ASM_PPC_GRANT_TABLE_H__ */ diff -r 817647aff01f -r c268103362bb xen/include/asm-x86/grant_table.h --- a/xen/include/asm-x86/grant_table.h Wed Mar 14 14:18:51 2007 -0700 +++ b/xen/include/asm-x86/grant_table.h Thu Mar 15 16:25:36 2007 +0900 @@ -38,4 +38,14 @@ 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) + +#define gnttab_release_put_page_and_type(page) \ + do { \ + /* Done implicitly when page tables are destroyed. */ \ + } while (0) + #endif /* __ASM_GRANT_TABLE_H__ */