ia64/xen-unstable

changeset 14233:7e9dc164b572

GNTTAB: PowerPC patch for dynamic grant tables.
Grant table expansion is disabled for now, since we currently make assumptions
about grant table MFNs being contiguous.
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
author Hollis Blanchard <hollisb@us.ibm.com>
date Mon Feb 19 16:49:12 2007 +0900 (2007-02-19)
parents 3ac19fda0bc2
children 6b42b8c08731
files xen/arch/powerpc/mm.c xen/common/grant_table.c xen/include/asm-powerpc/config.h xen/include/asm-powerpc/grant_table.h xen/include/xen/grant_table.h
line diff
     1.1 --- a/xen/arch/powerpc/mm.c	Fri Mar 02 12:11:52 2007 +0000
     1.2 +++ b/xen/arch/powerpc/mm.c	Mon Feb 19 16:49:12 2007 +0900
     1.3 @@ -416,7 +416,13 @@ ulong pfn2mfn(struct domain *d, ulong pf
     1.4      if (pfn & foreign_map_pfn) {
     1.5          t = PFN_TYPE_FOREIGN;
     1.6          mfn = foreign_to_mfn(d, pfn);
     1.7 -    } else if (pfn >= max_page && pfn < (max_page + NR_GRANT_FRAMES)) {
     1.8 +    } else if (pfn >= max_page && pfn <
     1.9 +	       (max_page + nr_grant_frames(d->grant_table))) {
    1.10 +        /* XXX access d->grant_table->nr_grant_frames without lock.
    1.11 +         * Currently on powerpc dynamic expanding grant table is
    1.12 +         * inhibited by setting max_nr_grant_frames = INITIAL_NR_GRANT_FRAMES
    1.13 +         * so that this access is safe.
    1.14 +         */
    1.15          /* Its a grant table access */
    1.16          t = PFN_TYPE_GNTTAB;
    1.17          mfn = gnttab_shared_mfn(d, d->grant_table, (pfn - max_page));
    1.18 @@ -494,9 +500,15 @@ unsigned long mfn_to_gmfn(struct domain 
    1.19      ulong gnttab_mfn;
    1.20      ulong rma_mfn;
    1.21  
    1.22 +    /* XXX access d->grant_table->nr_grant_frames without lock.
    1.23 +     * Currently on powerpc dynamic expanding grant table is
    1.24 +     * inhibited by setting max_nr_grant_frames = INITIAL_NR_GRANT_FRAMES
    1.25 +     * so that this access is safe.
    1.26 +     */
    1.27      /* grant? */
    1.28      gnttab_mfn = gnttab_shared_mfn(d, d->grant_table, 0);
    1.29 -    if (mfn >= gnttab_mfn && mfn < (gnttab_mfn + NR_GRANT_FRAMES))
    1.30 +    if (mfn >= gnttab_mfn && mfn <
    1.31 +	(gnttab_mfn + nr_grant_frames(d->grant_table)))
    1.32          return max_page + (mfn - gnttab_mfn);
    1.33  
    1.34      /* IO? */
     2.1 --- a/xen/common/grant_table.c	Fri Mar 02 12:11:52 2007 +0000
     2.2 +++ b/xen/common/grant_table.c	Mon Feb 19 16:49:12 2007 +0900
     2.3 @@ -35,8 +35,10 @@
     2.4  #include <xen/domain_page.h>
     2.5  #include <acm/acm_hooks.h>
     2.6  
     2.7 +#ifndef max_nr_grant_frames
     2.8  unsigned int max_nr_grant_frames = DEFAULT_MAX_NR_GRANT_FRAMES;
     2.9  integer_param("gnttab_max_nr_frames", max_nr_grant_frames);
    2.10 +#endif
    2.11  
    2.12  /* The maximum number of grant mappings is defined as a multiplier of the
    2.13   * maximum number of grant table entries. This defines the multiplier used.
     3.1 --- a/xen/include/asm-powerpc/config.h	Fri Mar 02 12:11:52 2007 +0000
     3.2 +++ b/xen/include/asm-powerpc/config.h	Mon Feb 19 16:49:12 2007 +0900
     3.3 @@ -73,4 +73,13 @@ extern char __bss_start[];
     3.4  
     3.5  #include <asm/powerpc64/config.h>
     3.6  
     3.7 +/*
     3.8 + * Disallow grant table growing tempralily because pfn2mfn() and
     3.9 + * mfn_to_gmfn() depends on the fact that grant table is machine-address
    3.10 + * contiguous. Grant table growing breaks the assumption.
    3.11 + */
    3.12 +#ifndef max_nr_grant_frames
    3.13 +#define max_nr_grant_frames INITIAL_NR_GRANT_FRAMES
    3.14  #endif
    3.15 +
    3.16 +#endif
     4.1 --- a/xen/include/asm-powerpc/grant_table.h	Fri Mar 02 12:11:52 2007 +0000
     4.2 +++ b/xen/include/asm-powerpc/grant_table.h	Mon Feb 19 16:49:12 2007 +0900
     4.3 @@ -41,11 +41,11 @@ int destroy_grant_host_mapping(
     4.4  #define gnttab_create_shared_page(d, t, i)                               \
     4.5      do {                                                                 \
     4.6          share_xen_page_with_guest(                                       \
     4.7 -            virt_to_page((char *)(t)->shared + ((i) * PAGE_SIZE)),       \
     4.8 +            virt_to_page((t)->shared[(i)]),                       \
     4.9              (d), XENSHARE_writable);                                     \
    4.10      } while ( 0 )
    4.11  
    4.12 -#define gnttab_shared_mfn(d, t, i) (((ulong)((t)->shared) >> PAGE_SHIFT) + (i))
    4.13 +#define gnttab_shared_mfn(d, t, i) (virt_to_mfn((t)->shared[(i)]))
    4.14  
    4.15  #define gnttab_shared_gmfn(d, t, i)                     \
    4.16      (mfn_to_gmfn(d, gnttab_shared_mfn(d, t, i)))
     5.1 --- a/xen/include/xen/grant_table.h	Fri Mar 02 12:11:52 2007 +0000
     5.2 +++ b/xen/include/xen/grant_table.h	Mon Feb 19 16:49:12 2007 +0900
     5.3 @@ -56,10 +56,14 @@ struct active_grant_entry {
     5.4  #define INITIAL_NR_GRANT_ENTRIES ((INITIAL_NR_GRANT_FRAMES << PAGE_SHIFT) / \
     5.5                                       sizeof(grant_entry_t))
     5.6  
     5.7 +#ifndef DEFAULT_MAX_NR_GRANT_FRAMES /* to allow arch to override */
     5.8  /* Default maximum size of a grant table. [POLICY] */
     5.9  #define DEFAULT_MAX_NR_GRANT_FRAMES   32
    5.10 +#endif
    5.11 +#ifndef max_nr_grant_frames /* to allow arch to override */
    5.12  /* The maximum size of a grant table. */
    5.13  extern unsigned int max_nr_grant_frames;
    5.14 +#endif
    5.15  
    5.16  /*
    5.17   * Tracks a mapping of another domain's grant reference. Each domain has a