ia64/xen-unstable

changeset 18633:f27787b9f8d7

[IA64] Change ioports_permit_access interface().

use VTD to assing device, guest port may not be equal to host port.
Change ioports_permit_access interface to get guest pseudo physical
address.

Signed-off-by: Anthony Xu <anthony.xu@intel.com>
author Isaku Yamahata <yamahata@valinux.co.jp>
date Fri Oct 17 17:40:15 2008 +0900 (2008-10-17)
parents 7db30bf36b0e
children 07558e1876e4
files xen/arch/ia64/xen/dom0_ops.c xen/arch/ia64/xen/domain.c xen/arch/ia64/xen/mm.c xen/include/asm-ia64/iocap.h
line diff
     1.1 --- a/xen/arch/ia64/xen/dom0_ops.c	Fri Oct 17 15:33:03 2008 +0900
     1.2 +++ b/xen/arch/ia64/xen/dom0_ops.c	Fri Oct 17 17:40:15 2008 +0900
     1.3 @@ -203,7 +203,7 @@ long arch_do_domctl(xen_domctl_t *op, XE
     1.4              ret = 0;
     1.5          else {
     1.6              if (op->u.ioport_permission.allow_access)
     1.7 -                ret = ioports_permit_access(d, fp, lp);
     1.8 +                ret = ioports_permit_access(d, fp, fp, lp);
     1.9              else
    1.10                  ret = ioports_deny_access(d, fp, lp);
    1.11          }
    1.12 @@ -522,7 +522,7 @@ dom0vp_add_io_space(struct domain *d, un
    1.13      fp = space_number << IO_SPACE_BITS;
    1.14      lp = fp | 0xffff;
    1.15  
    1.16 -    return ioports_permit_access(d, fp, lp);
    1.17 +    return ioports_permit_access(d, fp, fp, lp);
    1.18  }
    1.19  
    1.20  unsigned long
     2.1 --- a/xen/arch/ia64/xen/domain.c	Fri Oct 17 15:33:03 2008 +0900
     2.2 +++ b/xen/arch/ia64/xen/domain.c	Fri Oct 17 17:40:15 2008 +0900
     2.3 @@ -1993,7 +1993,7 @@ static void __init physdev_init_dom0(str
     2.4  		BUG();
     2.5  	if (irqs_permit_access(d, 0, NR_IRQS-1))
     2.6  		BUG();
     2.7 -	if (ioports_permit_access(d, 0, 0xffff))
     2.8 +	if (ioports_permit_access(d, 0, 0, 0xffff))
     2.9  		BUG();
    2.10  }
    2.11  
     3.1 --- a/xen/arch/ia64/xen/mm.c	Fri Oct 17 15:33:03 2008 +0900
     3.2 +++ b/xen/arch/ia64/xen/mm.c	Fri Oct 17 17:40:15 2008 +0900
     3.3 @@ -983,15 +983,22 @@ assign_domain_page(struct domain *d,
     3.4                                 ASSIGN_writable | ASSIGN_pgc_allocated);
     3.5  }
     3.6  
     3.7 +/* 
     3.8 + * Inpurt
     3.9 + * fgp: first guest port
    3.10 + * fmp: first machine port
    3.11 + * lmp: last machine port
    3.12 + */
    3.13  int
    3.14 -ioports_permit_access(struct domain *d, unsigned int fp, unsigned int lp)
    3.15 +ioports_permit_access(struct domain *d, unsigned int fgp,
    3.16 +        unsigned int fmp, unsigned int lmp)
    3.17  {
    3.18      struct io_space *space;
    3.19 -    unsigned long mmio_start, mmio_end, mach_start;
    3.20 +    unsigned long mmio_start, mach_start, mach_end;
    3.21      int ret;
    3.22  
    3.23 -    if (IO_SPACE_NR(fp) >= num_io_spaces) {
    3.24 -        dprintk(XENLOG_WARNING, "Unknown I/O Port range 0x%x - 0x%x\n", fp, lp);
    3.25 +    if (IO_SPACE_NR(fmp) >= num_io_spaces) {
    3.26 +        dprintk(XENLOG_WARNING, "Unknown I/O Port range 0x%x - 0x%x\n", fmp, lmp);
    3.27          return -EFAULT;
    3.28      }
    3.29  
    3.30 @@ -1005,42 +1012,44 @@ ioports_permit_access(struct domain *d, 
    3.31       * I/O port spaces and thus will number port spaces differently.
    3.32       * This is ok, they don't make use of this interface.
    3.33       */
    3.34 -    ret = rangeset_add_range(d->arch.ioport_caps, fp, lp);
    3.35 +    ret = rangeset_add_range(d->arch.ioport_caps, fmp, lmp);
    3.36      if (ret != 0)
    3.37          return ret;
    3.38  
    3.39 -    space = &io_space[IO_SPACE_NR(fp)];
    3.40 +    space = &io_space[IO_SPACE_NR(fmp)];
    3.41  
    3.42      /* Legacy I/O on dom0 is already setup */
    3.43      if (d == dom0 && space == &io_space[0])
    3.44          return 0;
    3.45  
    3.46 -    fp = IO_SPACE_PORT(fp);
    3.47 -    lp = IO_SPACE_PORT(lp);
    3.48 +    fmp = IO_SPACE_PORT(fmp);
    3.49 +    lmp = IO_SPACE_PORT(lmp);
    3.50  
    3.51      if (space->sparse) {
    3.52 -        mmio_start = IO_SPACE_SPARSE_ENCODING(fp) & PAGE_MASK;
    3.53 -        mmio_end = PAGE_ALIGN(IO_SPACE_SPARSE_ENCODING(lp));
    3.54 +        mach_start = IO_SPACE_SPARSE_ENCODING(fmp) & PAGE_MASK;
    3.55 +        mach_end = PAGE_ALIGN(IO_SPACE_SPARSE_ENCODING(lmp));
    3.56      } else {
    3.57 -        mmio_start = fp & PAGE_MASK;
    3.58 -        mmio_end = PAGE_ALIGN(lp);
    3.59 +        mach_start = fmp & PAGE_MASK;
    3.60 +        mach_end = PAGE_ALIGN(lmp);
    3.61      }
    3.62  
    3.63      /*
    3.64       * The "machine first port" is not necessarily identity mapped
    3.65       * to the guest first port.  At least for the legacy range.
    3.66       */
    3.67 -    mach_start = mmio_start | __pa(space->mmio_base);
    3.68 -
    3.69 -    if (space == &io_space[0]) {
    3.70 +    mach_start = mach_start | __pa(space->mmio_base);
    3.71 +    mach_end = mach_end | __pa(space->mmio_base);
    3.72 +
    3.73 +    mmio_start = IO_SPACE_SPARSE_ENCODING(fgp) & PAGE_MASK;
    3.74 +
    3.75 +    if (VMX_DOMAIN(d->vcpu[0]))
    3.76 +        mmio_start |= LEGACY_IO_START;
    3.77 +    else if (space == &io_space[0])
    3.78          mmio_start |= IO_PORTS_PADDR;
    3.79 -        mmio_end |= IO_PORTS_PADDR;
    3.80 -    } else {
    3.81 +    else
    3.82          mmio_start |= __pa(space->mmio_base);
    3.83 -        mmio_end |= __pa(space->mmio_base);
    3.84 -    }
    3.85 -
    3.86 -    while (mmio_start <= mmio_end) {
    3.87 +
    3.88 +    while (mach_start < mach_end) {
    3.89          (void)__assign_domain_page(d, mmio_start, mach_start, ASSIGN_nocache); 
    3.90          mmio_start += PAGE_SIZE;
    3.91          mach_start += PAGE_SIZE;
    3.92 @@ -1089,7 +1098,9 @@ ioports_deny_access(struct domain *d, un
    3.93          mmio_end = PAGE_ALIGN(lp_base);
    3.94      }
    3.95  
    3.96 -    if (space == &io_space[0] && d != dom0)
    3.97 +    if (VMX_DOMAIN(d->vcpu[0]))
    3.98 +        mmio_base = LEGACY_IO_START;
    3.99 +    else if (space == &io_space[0] && d != dom0)
   3.100          mmio_base = IO_PORTS_PADDR;
   3.101      else
   3.102          mmio_base = __pa(space->mmio_base);
     4.1 --- a/xen/include/asm-ia64/iocap.h	Fri Oct 17 15:33:03 2008 +0900
     4.2 +++ b/xen/include/asm-ia64/iocap.h	Fri Oct 17 17:40:15 2008 +0900
     4.3 @@ -7,7 +7,7 @@
     4.4  #ifndef __IA64_IOCAP_H__
     4.5  #define __IA64_IOCAP_H__
     4.6  
     4.7 -extern int ioports_permit_access(struct domain *d,
     4.8 +extern int ioports_permit_access(struct domain *d, unsigned int gs,
     4.9  				 unsigned int s, unsigned int e);
    4.10  extern int ioports_deny_access(struct domain *d,
    4.11  			       unsigned int s, unsigned int e);