direct-io.hg

changeset 11496:a817acb39386

[POWERPC][XEN] More Robust Memory Checking

This patch allows the platform to define the "IO Hole" of
addressibility and checks that even Dom0 does not try to Map "Remote"
memory that is not there. Also replaces some panic calls with WARN();
and returns failure.

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 Thu Sep 07 01:30:12 2006 -0400 (2006-09-07)
parents ccdaa3ea71a7
children 22e01a4864b0
files xen/arch/powerpc/mm.c xen/arch/powerpc/powerpc64/ppc970.c xen/arch/powerpc/usercopy.c xen/include/asm-powerpc/mm.h xen/include/asm-powerpc/processor.h
line diff
     1.1 --- a/xen/arch/powerpc/mm.c	Tue Sep 05 15:25:06 2006 -0400
     1.2 +++ b/xen/arch/powerpc/mm.c	Thu Sep 07 01:30:12 2006 -0400
     1.3 @@ -229,16 +229,6 @@ extern void copy_page(void *dp, void *sp
     1.4      }
     1.5  }
     1.6  
     1.7 -static int mfn_in_hole(ulong mfn)
     1.8 -{
     1.9 -    /* totally cheating */
    1.10 -    if (mfn >= (0xf0000000UL >> PAGE_SHIFT) &&
    1.11 -        mfn < (((1UL << 32) - 1) >> PAGE_SHIFT))
    1.12 -        return 1;
    1.13 -
    1.14 -    return 0;
    1.15 -}
    1.16 -
    1.17  static uint add_extent(struct domain *d, struct page_info *pg, uint order)
    1.18  {
    1.19      struct page_extents *pe;
    1.20 @@ -339,7 +329,7 @@ int allocate_rma(struct domain *d, unsig
    1.21      return 0;
    1.22  }
    1.23  
    1.24 -ulong pfn2mfn(struct domain *d, long pfn, int *type)
    1.25 +ulong pfn2mfn(struct domain *d, ulong pfn, int *type)
    1.26  {
    1.27      ulong rma_base_mfn = page_to_mfn(d->arch.rma_page);
    1.28      ulong rma_size_mfn = 1UL << d->arch.rma_order;
    1.29 @@ -356,7 +346,7 @@ ulong pfn2mfn(struct domain *d, long pfn
    1.30      }
    1.31  
    1.32      if (test_bit(_DOMF_privileged, &d->domain_flags) &&
    1.33 -        mfn_in_hole(pfn)) {
    1.34 +        cpu_io_mfn(pfn)) {
    1.35          if (type)
    1.36              *type = PFN_TYPE_IO;
    1.37          return pfn;
    1.38 @@ -374,7 +364,8 @@ ulong pfn2mfn(struct domain *d, long pfn
    1.39  
    1.40      /* This hack allows dom0 to map all memory, necessary to
    1.41       * initialize domU state. */
    1.42 -    if (test_bit(_DOMF_privileged, &d->domain_flags)) {
    1.43 +    if (test_bit(_DOMF_privileged, &d->domain_flags) &&
    1.44 +        pfn < max_page) {
    1.45          if (type)
    1.46              *type = PFN_TYPE_REMOTE;
    1.47          return pfn;
     2.1 --- a/xen/arch/powerpc/powerpc64/ppc970.c	Tue Sep 05 15:25:06 2006 -0400
     2.2 +++ b/xen/arch/powerpc/powerpc64/ppc970.c	Thu Sep 07 01:30:12 2006 -0400
     2.3 @@ -88,6 +88,19 @@ unsigned int cpu_extent_order(void)
     2.4      return log_large_page_sizes[0] - PAGE_SHIFT;
     2.5  }
     2.6  
     2.7 +
     2.8 +/* This is more a platform thing than a CPU thing, but we only have
     2.9 + * one platform now */
    2.10 +int cpu_io_mfn(ulong mfn)
    2.11 +{
    2.12 +    /* totally cheating */
    2.13 +    if (mfn >= (2UL << (30 - PAGE_SHIFT)) && /* 2GiB */
    2.14 +        mfn < (4UL << (30 - PAGE_SHIFT)))    /* 4GiB */
    2.15 +        return 1;
    2.16 +
    2.17 +    return 0;
    2.18 +}
    2.19 +
    2.20  static u64 cpu0_hids[6];
    2.21  static u64 cpu0_hior;
    2.22  
     3.1 --- a/xen/arch/powerpc/usercopy.c	Tue Sep 05 15:25:06 2006 -0400
     3.2 +++ b/xen/arch/powerpc/usercopy.c	Thu Sep 07 01:30:12 2006 -0400
     3.3 @@ -56,15 +56,21 @@ static unsigned long paddr_to_maddr(unsi
     3.4      case PFN_TYPE_RMA:
     3.5      case PFN_TYPE_LOGICAL:
     3.6          break;
     3.7 +
     3.8      case PFN_TYPE_REMOTE:
     3.9 +        /* I don't think this should ever happen, but I suppose it
    3.10 +         * could be possible */
    3.11          printk("%s: Dom:%d paddr: 0x%lx type: REMOTE\n",
    3.12                 __func__, d->domain_id, paddr);
    3.13          WARN();
    3.14          break;
    3.15 +
    3.16 +    case PFN_TYPE_IO:
    3.17      default:
    3.18 -        panic("%s: Dom:%d paddr: 0x%lx bad type:0x%x\n",
    3.19 +        printk("%s: Dom:%d paddr: 0x%lx bad type: 0x%x\n",
    3.20                 __func__, d->domain_id, paddr, mtype);
    3.21 -        break;
    3.22 +        WARN();
    3.23 +        return 0;
    3.24      }
    3.25      pa <<= PAGE_SHIFT;
    3.26      pa |= offset;
     4.1 --- a/xen/include/asm-powerpc/mm.h	Tue Sep 05 15:25:06 2006 -0400
     4.2 +++ b/xen/include/asm-powerpc/mm.h	Thu Sep 07 01:30:12 2006 -0400
     4.3 @@ -241,7 +241,7 @@ extern int update_grant_va_mapping(unsig
     4.4  #define PFN_TYPE_IO 3
     4.5  #define PFN_TYPE_REMOTE 4
     4.6  
     4.7 -extern ulong pfn2mfn(struct domain *d, long pfn, int *type);
     4.8 +extern ulong pfn2mfn(struct domain *d, ulong pfn, int *type);
     4.9  
    4.10  /* Arch-specific portion of memory_op hypercall. */
    4.11  long arch_memory_op(int op, XEN_GUEST_HANDLE(void) arg);
     5.1 --- a/xen/include/asm-powerpc/processor.h	Tue Sep 05 15:25:06 2006 -0400
     5.2 +++ b/xen/include/asm-powerpc/processor.h	Thu Sep 07 01:30:12 2006 -0400
     5.3 @@ -46,6 +46,7 @@ extern int cpu_rma_valid(unsigned int lo
     5.4  extern uint cpu_large_page_orders(uint *sizes, uint max);
     5.5  extern void cpu_initialize(int cpuid);
     5.6  extern void cpu_init_vcpu(struct vcpu *);
     5.7 +extern int cpu_io_mfn(ulong mfn);
     5.8  extern void save_cpu_sprs(struct vcpu *);
     5.9  extern void load_cpu_sprs(struct vcpu *);
    5.10