ia64/xen-unstable

changeset 10872:aa9d157d7637

[IA64] bug fixes for recent ioports patch

Bug fixes: dom0 do not virtualize IO space, do not over-deny IO ports.

Signed-off-by: Tristan Gingold <tristan.gingold@bull.net>
author awilliam@xenbuild.aw
date Mon Jul 31 13:10:39 2006 -0600 (2006-07-31)
parents 87247ceb0acd
children 86ff604d8e20
files xen/arch/ia64/xen/mm.c xen/include/asm-ia64/linux-xen/asm/io.h
line diff
     1.1 --- a/xen/arch/ia64/xen/mm.c	Mon Jul 31 10:18:28 2006 -0600
     1.2 +++ b/xen/arch/ia64/xen/mm.c	Mon Jul 31 13:10:39 2006 -0600
     1.3 @@ -908,6 +908,10 @@ ioports_permit_access(struct domain *d, 
     1.4      if (ret != 0)
     1.5          return ret;
     1.6  
     1.7 +    /* Domain 0 doesn't virtualize IO ports space. */
     1.8 +    if (d == dom0)
     1.9 +        return 0;
    1.10 +
    1.11      fp_offset = IO_SPACE_SPARSE_ENCODING(fp) & ~PAGE_MASK;
    1.12      lp_offset = PAGE_ALIGN(IO_SPACE_SPARSE_ENCODING(lp));
    1.13  
    1.14 @@ -918,6 +922,16 @@ ioports_permit_access(struct domain *d, 
    1.15      return 0;
    1.16  }
    1.17  
    1.18 +static int
    1.19 +ioports_has_allowed(struct domain *d, unsigned long fp, unsigned long lp)
    1.20 +{
    1.21 +    unsigned long i;
    1.22 +    for (i = fp; i < lp; i++)
    1.23 +        if (rangeset_contains_singleton(d->arch.ioport_caps, i))
    1.24 +            return 1;
    1.25 +    return 0;
    1.26 +}
    1.27 +
    1.28  int
    1.29  ioports_deny_access(struct domain *d, unsigned long fp, unsigned long lp)
    1.30  {
    1.31 @@ -936,9 +950,18 @@ ioports_deny_access(struct domain *d, un
    1.32  
    1.33      for (off = fp_offset; off <= lp_offset; off += PAGE_SIZE) {
    1.34          unsigned long mpaddr = IO_PORTS_PADDR + off;
    1.35 +        unsigned long port;
    1.36          volatile pte_t *pte;
    1.37          pte_t old_pte;
    1.38  
    1.39 +        port = IO_SPACE_SPARSE_DECODING (off);
    1.40 +        if (port < fp || port + IO_SPACE_SPARSE_PORTS_PER_PAGE > lp) {
    1.41 +            /* Maybe this covers an allowed port.  */
    1.42 +            if (ioports_has_allowed(d, port,
    1.43 +                                    port + IO_SPACE_SPARSE_PORTS_PER_PAGE))
    1.44 +                continue;
    1.45 +        }
    1.46 +
    1.47          pte = lookup_noalloc_domain_pte_none(d, mpaddr);
    1.48          BUG_ON(pte == NULL);
    1.49          BUG_ON(pte_none(*pte));
     2.1 --- a/xen/include/asm-ia64/linux-xen/asm/io.h	Mon Jul 31 10:18:28 2006 -0600
     2.2 +++ b/xen/include/asm-ia64/linux-xen/asm/io.h	Mon Jul 31 13:10:39 2006 -0600
     2.3 @@ -47,6 +47,12 @@
     2.4  
     2.5  #define IO_SPACE_SPARSE_ENCODING(p)	((((p) >> 2) << 12) | (p & 0xfff))
     2.6  
     2.7 +#ifdef XEN
     2.8 +/* Offset to IO port; do not catch error.  */
     2.9 +#define IO_SPACE_SPARSE_DECODING(off)	((((off) >> 12) << 2) | (off & 0x3))
    2.10 +#define IO_SPACE_SPARSE_PORTS_PER_PAGE	(0x4 << (PAGE_SHIFT - 12))
    2.11 +#endif
    2.12 +
    2.13  struct io_space {
    2.14  	unsigned long mmio_base;	/* base in MMIO space */
    2.15  	int sparse;