direct-io.hg

changeset 12953:a60e804c0a31

[XEN][POWERPC] The VIO rewrite
Once you figure it all out, its time to do a rewrite, lots of code I
thougth I needed is now removed and less PPC specific code now exists.
This patch uses the MEMORY_HOTPLUG system to add a region to the
Kernel Linear Mapping that will be used exclusively to map in
Granted/Foreign pages. This creates "struct page" objects in Linux
which are necessary to perform VIO operations. When one of these
pages are grant_mapped the pfn2mfn() translation in Xen is updated to
reflect the association and the subsequent H_ENTER() from the domain
will contain the correct mapping.
Signed-off-by: Jimi Xenidis <jimix@watson.ibm.com>
Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
author Jimi Xenidis <jimix@watson.ibm.com>
date Fri Nov 03 16:53:17 2006 -0500 (2006-11-03)
parents b0293bc59835
children 176c7264715c
files xen/arch/powerpc/domain.c xen/arch/powerpc/mm.c xen/arch/powerpc/ofd_fixup.c xen/include/asm-powerpc/domain.h xen/include/asm-powerpc/grant_table.h
line diff
     1.1 --- a/xen/arch/powerpc/domain.c	Tue Oct 24 19:11:00 2006 -0400
     1.2 +++ b/xen/arch/powerpc/domain.c	Fri Nov 03 16:53:17 2006 -0500
     1.3 @@ -88,6 +88,12 @@ int arch_domain_create(struct domain *d)
     1.4  
     1.5      INIT_LIST_HEAD(&d->arch.extent_list);
     1.6  
     1.7 +    d->arch.foreign_mfn_count = 1024;
     1.8 +    d->arch.foreign_mfns = xmalloc_array(uint, d->arch.foreign_mfn_count);
     1.9 +    BUG_ON(d->arch.foreign_mfns == NULL);
    1.10 +
    1.11 +    memset(d->arch.foreign_mfns, -1, d->arch.foreign_mfn_count * sizeof(uint));
    1.12 +
    1.13      return 0;
    1.14  }
    1.15  
    1.16 @@ -294,6 +300,7 @@ void domain_relinquish_resources(struct 
    1.17      relinquish_memory(d, &d->xenpage_list);
    1.18      relinquish_memory(d, &d->page_list);
    1.19      free_extents(d);
    1.20 +    xfree(d->arch.foreign_mfns);
    1.21      return;
    1.22  }
    1.23  
     2.1 --- a/xen/arch/powerpc/mm.c	Tue Oct 24 19:11:00 2006 -0400
     2.2 +++ b/xen/arch/powerpc/mm.c	Fri Nov 03 16:53:17 2006 -0500
     2.3 @@ -93,6 +93,26 @@ void share_xen_page_with_privileged_gues
     2.4          unimplemented();
     2.5  }
     2.6  
     2.7 +static ulong foreign_to_mfn(struct domain *d, ulong pfn)
     2.8 +{
     2.9 +
    2.10 +    pfn -= 1UL << cpu_foreign_map_order();
    2.11 +
    2.12 +    BUG_ON(pfn >= d->arch.foreign_mfn_count);
    2.13 +
    2.14 +    return d->arch.foreign_mfns[pfn];
    2.15 +}
    2.16 +
    2.17 +static int set_foreign(struct domain *d, ulong pfn, ulong mfn)
    2.18 +{
    2.19 +    pfn -= 1UL << cpu_foreign_map_order();
    2.20 +
    2.21 +    BUG_ON(pfn >= d->arch.foreign_mfn_count);
    2.22 +    d->arch.foreign_mfns[pfn] = mfn;
    2.23 +
    2.24 +    return 0;
    2.25 +}
    2.26 +
    2.27  static int create_grant_va_mapping(
    2.28      unsigned long va, unsigned long frame, struct vcpu *v)
    2.29  {
    2.30 @@ -101,6 +121,7 @@ static int create_grant_va_mapping(
    2.31          BUG();
    2.32          return GNTST_permission_denied;
    2.33      }
    2.34 +    set_foreign(v->domain, va >> PAGE_SHIFT, frame);
    2.35      return GNTST_okay;
    2.36  }
    2.37  
    2.38 @@ -112,6 +133,7 @@ static int destroy_grant_va_mapping(
    2.39          BUG();
    2.40          return GNTST_permission_denied;
    2.41      }
    2.42 +    set_foreign(d, addr >> PAGE_SHIFT, ~0UL);
    2.43      return GNTST_okay;
    2.44  }
    2.45  
    2.46 @@ -388,7 +410,7 @@ ulong pfn2mfn(struct domain *d, ulong pf
    2.47      /* quick tests first */
    2.48      if (pfn & foreign_map_pfn) {
    2.49          t = PFN_TYPE_FOREIGN;
    2.50 -        mfn = pfn & ~(foreign_map_pfn);
    2.51 +        mfn = foreign_to_mfn(d, pfn);
    2.52      } else if (pfn >= max_page && pfn < (max_page + NR_GRANT_FRAMES)) {
    2.53          /* Its a grant table access */
    2.54          t = PFN_TYPE_GNTTAB;
     3.1 --- a/xen/arch/powerpc/ofd_fixup.c	Tue Oct 24 19:11:00 2006 -0400
     3.2 +++ b/xen/arch/powerpc/ofd_fixup.c	Fri Nov 03 16:53:17 2006 -0500
     3.3 @@ -354,7 +354,7 @@ static ofdn_t ofd_xen_props(void *m, str
     3.4  
     3.5          /* tell dom0 where ranted pages go in the linear map */
     3.6          val[0] = cpu_foreign_map_order();
     3.7 -        val[1] = max_page;
     3.8 +        val[1] = d->arch.foreign_mfn_count;
     3.9          ofd_prop_add(m, n, "foreign-map", val, sizeof (val));
    3.10  
    3.11          n = ofd_node_add(m, n, console, sizeof (console));
     4.1 --- a/xen/include/asm-powerpc/domain.h	Tue Oct 24 19:11:00 2006 -0400
     4.2 +++ b/xen/include/asm-powerpc/domain.h	Fri Nov 03 16:53:17 2006 -0500
     4.3 @@ -41,6 +41,9 @@ struct arch_domain {
     4.4      /* list of extents beyond RMA */
     4.5      struct list_head extent_list;
     4.6  
     4.7 +    uint foreign_mfn_count;
     4.8 +    uint *foreign_mfns;
     4.9 +
    4.10      /* I/O-port access bitmap mask. */
    4.11      u8 *iobmp_mask;       /* Address of IO bitmap mask, or NULL.      */
    4.12  
     5.1 --- a/xen/include/asm-powerpc/grant_table.h	Tue Oct 24 19:11:00 2006 -0400
     5.2 +++ b/xen/include/asm-powerpc/grant_table.h	Fri Nov 03 16:53:17 2006 -0500
     5.3 @@ -69,8 +69,4 @@ static inline uint cpu_foreign_map_order
     5.4      /* 16 GiB */
     5.5      return 34 - PAGE_SHIFT;
     5.6  }
     5.7 -
     5.8 -#define GNTTAB_DEV_BUS(f) \
     5.9 -    ((f) | (1UL << (cpu_foreign_map_order() + PAGE_SHIFT)))
    5.10 -
    5.11  #endif  /* __ASM_PPC_GRANT_TABLE_H__ */