# HG changeset patch # User yamahata@xxxxxxxxxxxxx # Date 1171871352 -32400 # Node ID f5f232aef7bdfabd4997f45d88620dc45b50c185 # Parent cca098fd122c9568b67e4ffec5d0c992003e37b9 GNTTAB: powerpc part expandable grant table. Currently it is inhibited to grow grant table on powerpc. Patch only. Even compilation isn't tested. PATCHNAME: grow_granttable_powerpc Signed-off-by: Isaku Yamahata diff -r cca098fd122c -r f5f232aef7bd xen/arch/powerpc/mm.c --- a/xen/arch/powerpc/mm.c Mon Feb 19 16:16:16 2007 +0900 +++ b/xen/arch/powerpc/mm.c Mon Feb 19 16:49:12 2007 +0900 @@ -412,7 +412,13 @@ ulong pfn2mfn(struct domain *d, ulong pf if (pfn & foreign_map_pfn) { t = PFN_TYPE_FOREIGN; mfn = foreign_to_mfn(d, pfn); - } else if (pfn >= max_page && pfn < (max_page + NR_GRANT_FRAMES)) { + } else if (pfn >= max_page && pfn < + (max_page + nr_grant_frames(d->grant_table))) { + /* XXX access d->grant_table->nr_grant_frames without lock. + * Currently on powerpc dynamic expanding grant table is + * inhibited by setting max_nr_grant_frames = INITIAL_NR_GRANT_FRAMES + * so that this access is safe. + */ /* Its a grant table access */ t = PFN_TYPE_GNTTAB; mfn = gnttab_shared_mfn(d, d->grant_table, (pfn - max_page)); @@ -490,9 +496,15 @@ unsigned long mfn_to_gmfn(struct domain ulong gnttab_mfn; ulong rma_mfn; + /* XXX access d->grant_table->nr_grant_frames without lock. + * Currently on powerpc dynamic expanding grant table is + * inhibited by setting max_nr_grant_frames = INITIAL_NR_GRANT_FRAMES + * so that this access is safe. + */ /* grant? */ gnttab_mfn = gnttab_shared_mfn(d, d->grant_table, 0); - if (mfn >= gnttab_mfn && mfn < (gnttab_mfn + NR_GRANT_FRAMES)) + if (mfn >= gnttab_mfn && mfn < + (gnttab_mfn + nr_grant_frames(d->grant_table))) return max_page + (mfn - gnttab_mfn); /* IO? */ diff -r cca098fd122c -r f5f232aef7bd xen/common/grant_table.c --- a/xen/common/grant_table.c Mon Feb 19 16:16:16 2007 +0900 +++ b/xen/common/grant_table.c Mon Feb 19 16:49:12 2007 +0900 @@ -35,8 +35,10 @@ #include #include +#ifndef max_nr_grant_frames unsigned int max_nr_grant_frames = DEFAULT_MAX_NR_GRANT_FRAMES; integer_param("gnttab_max_nr_frames", max_nr_grant_frames); +#endif /* The maximum number of grant mappings is defined as a multiplier of the * maximum number of grant table entries. This defines the multiplier used. diff -r cca098fd122c -r f5f232aef7bd xen/include/asm-powerpc/config.h --- a/xen/include/asm-powerpc/config.h Mon Feb 19 16:16:16 2007 +0900 +++ b/xen/include/asm-powerpc/config.h Mon Feb 19 16:49:12 2007 +0900 @@ -73,4 +73,13 @@ extern char __bss_start[]; #include +/* + * Disallow grant table growing tempralily because pfn2mfn() and + * mfn_to_gmfn() depends on the fact that grant table is machine-address + * contiguous. Grant table growing breaks the assumption. + */ +#ifndef max_nr_grant_frames +#define max_nr_grant_frames INITIAL_NR_GRANT_FRAMES #endif + +#endif diff -r cca098fd122c -r f5f232aef7bd xen/include/asm-powerpc/grant_table.h --- a/xen/include/asm-powerpc/grant_table.h Mon Feb 19 16:16:16 2007 +0900 +++ b/xen/include/asm-powerpc/grant_table.h Mon Feb 19 16:49:12 2007 +0900 @@ -41,11 +41,11 @@ int destroy_grant_host_mapping( #define gnttab_create_shared_page(d, t, i) \ do { \ share_xen_page_with_guest( \ - virt_to_page((char *)(t)->shared + ((i) * PAGE_SIZE)), \ + virt_to_page((t)->shared_frames[(i)]), \ (d), XENSHARE_writable); \ } while ( 0 ) -#define gnttab_shared_mfn(d, t, i) (((ulong)((t)->shared) >> PAGE_SHIFT) + (i)) +#define gnttab_shared_mfn(d, t, i) (virt_to_mfn((t)->shared_frames[(i)])) #define gnttab_shared_gmfn(d, t, i) \ (mfn_to_gmfn(d, gnttab_shared_mfn(d, t, i))) diff -r cca098fd122c -r f5f232aef7bd xen/include/xen/grant_table.h --- a/xen/include/xen/grant_table.h Mon Feb 19 16:16:16 2007 +0900 +++ b/xen/include/xen/grant_table.h Mon Feb 19 16:49:12 2007 +0900 @@ -56,10 +56,14 @@ struct active_grant_entry { #define INITIAL_NR_GRANT_ENTRIES ((INITIAL_NR_GRANT_FRAMES << PAGE_SHIFT) / \ sizeof(grant_entry_t)) +#ifndef DEFAULT_MAX_NR_GRANT_FRAMES /* to allow arch to override */ /* Default maximum size of a grant table. [POLICY] */ #define DEFAULT_MAX_NR_GRANT_FRAMES 32 +#endif +#ifndef max_nr_grant_frames /* to allow arch to override */ /* The maximum size of a grant table. */ extern unsigned int max_nr_grant_frames; +#endif /* * Tracks a mapping of another domain's grant reference. Each domain has a