ia64/xen-unstable

changeset 16408:9a9ddc04eea2

merge with xen-unstable.hg (staging)
author Alex Williamson <alex.williamson@hp.com>
date Tue Nov 20 11:53:44 2007 -0700 (2007-11-20)
parents 87afd05bd254 2e5d922b7ee3
children 53dc1cf50506
files xen/arch/ia64/xen/domain.c
line diff
     1.1 --- a/tools/python/xen/xend/XendAPI.py	Tue Nov 20 09:28:15 2007 -0700
     1.2 +++ b/tools/python/xen/xend/XendAPI.py	Tue Nov 20 11:53:44 2007 -0700
     1.3 @@ -2111,6 +2111,8 @@ class XendAPI(object):
     1.4  
     1.5      VIF_metrics_attr_ro = ['io_read_kbs',
     1.6                             'io_write_kbs',
     1.7 +                           'io_total_read_kbs',
     1.8 +                           'io_total_write_kbs',
     1.9                             'last_updated']
    1.10      VIF_metrics_attr_rw = []
    1.11      VIF_metrics_methods = []
    1.12 @@ -2125,6 +2127,8 @@ class XendAPI(object):
    1.13          return xen_api_success(
    1.14              { 'io_read_kbs'  : vm.get_dev_property('vif', ref, 'io_read_kbs'),
    1.15                'io_write_kbs' : vm.get_dev_property('vif', ref, 'io_write_kbs'),
    1.16 +              'io_total_read_kbs'  : vm.get_dev_property('vif', ref, 'io_total_read_kbs'),
    1.17 +              'io_total_write_kbs' : vm.get_dev_property('vif', ref, 'io_total_write_kbs'),
    1.18                'last_updated' : now()
    1.19              })
    1.20  
    1.21 @@ -2134,6 +2138,12 @@ class XendAPI(object):
    1.22      def VIF_metrics_get_io_write_kbs(self, session, ref):
    1.23          return self._VIF_get(ref, 'io_write_kbs')
    1.24  
    1.25 +    def VIF_metrics_get_io_total_read_kbs(self, _, ref):
    1.26 +        return self._VIF_get(ref, 'io_total_read_kbs')
    1.27 +
    1.28 +    def VIF_metrics_get_io_total_write_kbs(self, session, ref):
    1.29 +        return self._VIF_get(ref, 'io_total_write_kbs')
    1.30 +
    1.31      def VIF_metrics_get_last_updated(self, _1, _2):
    1.32          return xen_api_success(now())
    1.33  
     2.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Tue Nov 20 09:28:15 2007 -0700
     2.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Tue Nov 20 11:53:44 2007 -0700
     2.3 @@ -2606,9 +2606,14 @@ class XendDomainInfo:
     2.4                  rx_bps, tx_bps = xennode.get_vif_util(self.domid, devid)
     2.5                  config['io_read_kbs'] = rx_bps/1024
     2.6                  config['io_write_kbs'] = tx_bps/1024
     2.7 +                rx, tx = xennode.get_vif_stat(self.domid, devid)
     2.8 +                config['io_total_read_kbs'] = rx/1024
     2.9 +                config['io_total_write_kbs'] = tx/1024
    2.10              else:
    2.11                  config['io_read_kbs'] = 0.0
    2.12 -                config['io_write_kbs'] = 0.0                
    2.13 +                config['io_write_kbs'] = 0.0          
    2.14 +                config['io_total_read_kbs'] = 0.0
    2.15 +                config['io_total_write_kbs'] = 0.0
    2.16  
    2.17              config['security_label'] = config.get('security_label', '')
    2.18  
     3.1 --- a/tools/python/xen/xend/XendMonitor.py	Tue Nov 20 09:28:15 2007 -0700
     3.2 +++ b/tools/python/xen/xend/XendMonitor.py	Tue Nov 20 11:53:44 2007 -0700
     3.3 @@ -63,6 +63,8 @@ class XendMonitor(threading.Thread):
     3.4      @type domain_vcpus_util: {domid: {vcpuid: float, vcpuid: float}}
     3.5      @ivar domain_vifs_util: Bytes per second for VIFs indexed by domain
     3.6      @type domain_vifs_util: {domid: {vifid: (rx_bps, tx_bps)}}
     3.7 +    @ivar domain_vifs_stat: Total amount of bytes used for VIFs indexed by domain
     3.8 +    @type domain_vifs_stat: {domid: {vbdid: (rx, tx)}}
     3.9      @ivar domain_vbds_util: Blocks per second for VBDs index by domain.
    3.10      @type domain_vbds_util: {domid: {vbdid: (rd_reqps, wr_reqps)}}    
    3.11      
    3.12 @@ -83,6 +85,7 @@ class XendMonitor(threading.Thread):
    3.13          # instantaneous statistics
    3.14          self._domain_vcpus_util = {}
    3.15          self._domain_vifs_util = {}
    3.16 +        self._domain_vifs_stat = {}
    3.17          self._domain_vbds_util = {}
    3.18          self.pifs_util = {}
    3.19  
    3.20 @@ -107,6 +110,13 @@ class XendMonitor(threading.Thread):
    3.21          finally:
    3.22              self.lock.release()
    3.23  
    3.24 +    def get_domain_vifs_stat(self):
    3.25 +        self.lock.acquire()
    3.26 +        try:
    3.27 +            return self._domain_vifs_stat
    3.28 +        finally:
    3.29 +            self.lock.release()
    3.30 +
    3.31      def get_pifs_util(self):
    3.32          self.lock.acquire()
    3.33          try:
    3.34 @@ -269,6 +279,7 @@ class XendMonitor(threading.Thread):
    3.35                      if domid not in self._domain_vifs:
    3.36                          self._domain_vifs[domid] = vifs
    3.37                          self._domain_vifs_util[domid] = {}
    3.38 +                        self._domain_vifs_stat[domid] = {}
    3.39                          continue
    3.40                  
    3.41                      for devid, (usage_at, rx, tx) in vifs.items():
    3.42 @@ -286,6 +297,8 @@ class XendMonitor(threading.Thread):
    3.43                          # not the guest interface
    3.44                          self._domain_vifs_util[domid][devid] = \
    3.45                               (tx_util, rx_util)
    3.46 +                        self._domain_vifs_stat[domid][devid] = \
    3.47 +                             (float(tx), float(rx))
    3.48                          
    3.49                      self._domain_vifs[domid] = vifs
    3.50  
    3.51 @@ -313,6 +326,7 @@ class XendMonitor(threading.Thread):
    3.52                      if domid not in active_domids:
    3.53                          del self._domain_vifs_util[domid]
    3.54                          del self._domain_vifs[domid]
    3.55 +                        del self._domain_vifs_stat[domid]
    3.56                  for domid in self._domain_vbds_util.keys():
    3.57                      if domid not in active_domids:
    3.58                          del self._domain_vbds_util[domid]
     4.1 --- a/tools/python/xen/xend/XendNode.py	Tue Nov 20 09:28:15 2007 -0700
     4.2 +++ b/tools/python/xen/xend/XendNode.py	Tue Nov 20 11:53:44 2007 -0700
     4.3 @@ -651,6 +651,12 @@ class XendNode:
     4.4              return vif_loads[domid].get(vifid, (0.0, 0.0))
     4.5          return (0.0, 0.0)
     4.6  
     4.7 +    def get_vif_stat(self, domid, vifid):
     4.8 +        vif_loads = self.monitor.get_domain_vifs_stat()
     4.9 +        if domid in vif_loads:
    4.10 +            return vif_loads[domid].get(vifid, (0.0, 0.0))
    4.11 +        return (0.0, 0.0)
    4.12 +
    4.13      def get_vbd_util(self, domid, vbdid):
    4.14          vbd_loads = self.monitor.get_domain_vbds_util()
    4.15          if domid in vbd_loads:
     5.1 --- a/xen/arch/ia64/xen/domain.c	Tue Nov 20 09:28:15 2007 -0700
     5.2 +++ b/xen/arch/ia64/xen/domain.c	Tue Nov 20 11:53:44 2007 -0700
     5.3 @@ -2137,8 +2137,7 @@ int __init construct_dom0(struct domain 
     5.4  		panic("can't allocate start info page");
     5.5  	si = page_to_virt(start_info_page);
     5.6  	clear_page(si);
     5.7 -	snprintf(si->magic, sizeof(si->magic), "xen-%i.%i-ia64",
     5.8 -		xen_major_version(), xen_minor_version());
     5.9 +	snprintf(si->magic, sizeof(si->magic), "xen-3.0-ia64");
    5.10  	si->nr_pages     = max_pages;
    5.11  	si->flags = SIF_INITDOMAIN|SIF_PRIVILEGED;
    5.12  
     6.1 --- a/xen/arch/ia64/xen/mm.c	Tue Nov 20 09:28:15 2007 -0700
     6.2 +++ b/xen/arch/ia64/xen/mm.c	Tue Nov 20 11:53:44 2007 -0700
     6.3 @@ -2144,16 +2144,18 @@ dom0vp_unexpose_foreign_p2m(struct domai
     6.4  // mfn: frame: machine page frame
     6.5  // flags: GNTMAP_readonly | GNTMAP_application_map | GNTMAP_contains_pte
     6.6  int
     6.7 -create_grant_host_mapping(unsigned long gpaddr,
     6.8 -              unsigned long mfn, unsigned int flags)
     6.9 +create_grant_host_mapping(unsigned long gpaddr, unsigned long mfn, 
    6.10 +                          unsigned int flags, unsigned int cache_flags)
    6.11  {
    6.12      struct domain* d = current->domain;
    6.13      struct page_info* page;
    6.14      int ret;
    6.15  
    6.16 -    if (flags & (GNTMAP_device_map |
    6.17 -                 GNTMAP_application_map | GNTMAP_contains_pte)) {
    6.18 -        gdprintk(XENLOG_INFO, "%s: flags 0x%x\n", __func__, flags);
    6.19 +    if ((flags & (GNTMAP_device_map | 
    6.20 +                  GNTMAP_application_map | GNTMAP_contains_pte)) ||
    6.21 +        (cache_flags)) {
    6.22 +        gdprintk(XENLOG_INFO, "%s: flags 0x%x cache_flags 0x%x\n",
    6.23 +                 __func__, flags, cache_flags);
    6.24          return GNTST_general_error;
    6.25      }
    6.26  
     7.1 --- a/xen/arch/powerpc/mm.c	Tue Nov 20 09:28:15 2007 -0700
     7.2 +++ b/xen/arch/powerpc/mm.c	Tue Nov 20 11:53:44 2007 -0700
     7.3 @@ -168,7 +168,7 @@ static int destroy_grant_va_mapping(
     7.4  }
     7.5  
     7.6  int create_grant_host_mapping(
     7.7 -    unsigned long addr, unsigned long frame, unsigned int flags)
     7.8 +    unsigned long addr, unsigned long frame, unsigned int flags, unsigned int cache_flags)
     7.9  {
    7.10      if (flags & GNTMAP_application_map) {
    7.11          printk("%s: GNTMAP_application_map not supported\n", __func__);
    7.12 @@ -180,6 +180,11 @@ int create_grant_host_mapping(
    7.13          BUG();
    7.14          return GNTST_general_error;
    7.15      }
    7.16 +    if (cache_flags) {
    7.17 +        printk("%s: cache_flags not supported\n", __func__);
    7.18 +        BUG();
    7.19 +        return GNTST_general_error;
    7.20 +    }
    7.21      return create_grant_va_mapping(addr, frame, current);
    7.22  }
    7.23  
     8.1 --- a/xen/arch/x86/domain.c	Tue Nov 20 09:28:15 2007 -0700
     8.2 +++ b/xen/arch/x86/domain.c	Tue Nov 20 11:53:44 2007 -0700
     8.3 @@ -1756,10 +1756,6 @@ static void vcpu_destroy_pagetables(stru
     8.4              put_page(mfn_to_page(pfn));
     8.5          else
     8.6              put_page_and_type(mfn_to_page(pfn));
     8.7 -#ifdef __x86_64__
     8.8 -        if ( pfn == pagetable_get_pfn(v->arch.guest_table_user) )
     8.9 -            v->arch.guest_table_user = pagetable_null();
    8.10 -#endif
    8.11          v->arch.guest_table = pagetable_null();
    8.12      }
    8.13  
    8.14 @@ -1768,10 +1764,13 @@ static void vcpu_destroy_pagetables(stru
    8.15      pfn = pagetable_get_pfn(v->arch.guest_table_user);
    8.16      if ( pfn != 0 )
    8.17      {
    8.18 -        if ( paging_mode_refcounts(d) )
    8.19 -            put_page(mfn_to_page(pfn));
    8.20 -        else
    8.21 -            put_page_and_type(mfn_to_page(pfn));
    8.22 +        if ( !is_pv_32bit_vcpu(v) )
    8.23 +        {
    8.24 +            if ( paging_mode_refcounts(d) )
    8.25 +                put_page(mfn_to_page(pfn));
    8.26 +            else
    8.27 +                put_page_and_type(mfn_to_page(pfn));
    8.28 +        }
    8.29          v->arch.guest_table_user = pagetable_null();
    8.30      }
    8.31  #endif
     9.1 --- a/xen/arch/x86/domain_build.c	Tue Nov 20 09:28:15 2007 -0700
     9.2 +++ b/xen/arch/x86/domain_build.c	Tue Nov 20 11:53:44 2007 -0700
     9.3 @@ -832,10 +832,8 @@ int __init construct_dom0(
     9.4      si->pt_base      = vpt_start + 2 * PAGE_SIZE * !!is_pv_32on64_domain(d);
     9.5      si->nr_pt_frames = nr_pt_pages;
     9.6      si->mfn_list     = vphysmap_start;
     9.7 -    snprintf(si->magic, sizeof(si->magic), "xen-%i.%i-x86_%d%s",
     9.8 -            xen_major_version(), xen_minor_version(),
     9.9 -            elf_64bit(&elf) ? 64 : 32,
    9.10 -            parms.pae ? "p" : "");
    9.11 +    snprintf(si->magic, sizeof(si->magic), "xen-3.0-x86_%d%s",
    9.12 +             elf_64bit(&elf) ? 64 : 32, parms.pae ? "p" : "");
    9.13  
    9.14      /* Write the phys->machine and machine->phys table entries. */
    9.15      for ( pfn = 0; pfn < d->tot_pages; pfn++ )
    10.1 --- a/xen/arch/x86/hvm/svm/svm.c	Tue Nov 20 09:28:15 2007 -0700
    10.2 +++ b/xen/arch/x86/hvm/svm/svm.c	Tue Nov 20 11:53:44 2007 -0700
    10.3 @@ -74,11 +74,21 @@ static void *root_vmcb[NR_CPUS] __read_m
    10.4  static void svm_update_guest_efer(struct vcpu *v);
    10.5  
    10.6  static void inline __update_guest_eip(
    10.7 -    struct cpu_user_regs *regs, int inst_len) 
    10.8 +    struct cpu_user_regs *regs, unsigned int inst_len)
    10.9  {
   10.10 -    ASSERT(inst_len > 0);
   10.11 +    if ( unlikely((inst_len == 0) || (inst_len > 15)) )
   10.12 +    {
   10.13 +        gdprintk(XENLOG_ERR, "Bad instruction length %u\n", inst_len);
   10.14 +        domain_crash(current->domain);
   10.15 +        return;
   10.16 +    }
   10.17 +
   10.18 +    ASSERT(regs == guest_cpu_user_regs());
   10.19 +
   10.20      regs->eip += inst_len;
   10.21      regs->eflags &= ~X86_EFLAGS_RF;
   10.22 +
   10.23 +    current->arch.hvm_svm.vmcb->interrupt_shadow = 0;
   10.24  }
   10.25  
   10.26  static void svm_inject_exception(
   10.27 @@ -1061,7 +1071,6 @@ static void svm_vmexit_do_cpuid(struct v
   10.28                  ((uint64_t)eax << 32) | ebx, ((uint64_t)ecx << 32) | edx);
   10.29  
   10.30      inst_len = __get_instruction_length(v, INSTR_CPUID, NULL);
   10.31 -    ASSERT(inst_len > 0);
   10.32      __update_guest_eip(regs, inst_len);
   10.33  }
   10.34  
   10.35 @@ -1643,8 +1652,6 @@ static void svm_cr_access(
   10.36              v, list_b, ARRAY_SIZE(list_b), &buffer[index], &match);
   10.37      }
   10.38  
   10.39 -    ASSERT(inst_len > 0);
   10.40 -
   10.41      inst_len += index;
   10.42  
   10.43      /* Check for REX prefix - it's ALWAYS the last byte of any prefix bytes */
   10.44 @@ -1745,8 +1752,6 @@ static void svm_cr_access(
   10.45          BUG();
   10.46      }
   10.47  
   10.48 -    ASSERT(inst_len);
   10.49 -
   10.50      if ( result )
   10.51          __update_guest_eip(regs, inst_len);
   10.52  }
   10.53 @@ -1925,20 +1930,23 @@ static void svm_do_msr_access(
   10.54  static void svm_vmexit_do_hlt(struct vmcb_struct *vmcb,
   10.55                                struct cpu_user_regs *regs)
   10.56  {
   10.57 -    struct hvm_intack intack = hvm_vcpu_has_pending_irq(current);
   10.58 +    struct vcpu *curr = current;
   10.59 +    struct hvm_intack intack = hvm_vcpu_has_pending_irq(curr);
   10.60 +    unsigned int inst_len;
   10.61  
   10.62 -    __update_guest_eip(regs, 1);
   10.63 +    inst_len = __get_instruction_length(curr, INSTR_HLT, NULL);
   10.64 +    __update_guest_eip(regs, inst_len);
   10.65  
   10.66      /* Check for interrupt not handled or new interrupt. */
   10.67      if ( vmcb->eventinj.fields.v ||
   10.68           ((intack.source != hvm_intsrc_none) &&
   10.69            !svm_interrupt_blocked(current, intack)) )
   10.70      {
   10.71 -        HVMTRACE_1D(HLT, current, /*int pending=*/ 1);
   10.72 +        HVMTRACE_1D(HLT, curr, /*int pending=*/ 1);
   10.73          return;
   10.74      }
   10.75  
   10.76 -    HVMTRACE_1D(HLT, current, /*int pending=*/ 0);
   10.77 +    HVMTRACE_1D(HLT, curr, /*int pending=*/ 0);
   10.78      hvm_hlt(regs->eflags);
   10.79  }
   10.80  
   10.81 @@ -1971,17 +1979,15 @@ void svm_handle_invlpg(const short invlp
   10.82       * Unknown how many bytes the invlpg instruction will take.  Use the
   10.83       * maximum instruction length here
   10.84       */
   10.85 -    if (inst_copy_from_guest(opcode, svm_rip2pointer(v), length) < length)
   10.86 +    if ( inst_copy_from_guest(opcode, svm_rip2pointer(v), length) < length )
   10.87      {
   10.88          gdprintk(XENLOG_ERR, "Error reading memory %d bytes\n", length);
   10.89 -        domain_crash(v->domain);
   10.90 -        return;
   10.91 +        goto crash;
   10.92      }
   10.93  
   10.94 -    if (invlpga)
   10.95 +    if ( invlpga )
   10.96      {
   10.97          inst_len = __get_instruction_length(v, INSTR_INVLPGA, opcode);
   10.98 -        ASSERT(inst_len > 0);
   10.99          __update_guest_eip(regs, inst_len);
  10.100  
  10.101          /* 
  10.102 @@ -1993,9 +1999,13 @@ void svm_handle_invlpg(const short invlp
  10.103      else
  10.104      {
  10.105          /* What about multiple prefix codes? */
  10.106 -        prefix = (is_prefix(opcode[0])?opcode[0]:0);
  10.107 +        prefix = (is_prefix(opcode[0]) ? opcode[0] : 0);
  10.108          inst_len = __get_instruction_length(v, INSTR_INVLPG, opcode);
  10.109 -        ASSERT(inst_len > 0);
  10.110 +        if ( inst_len <= 0 )
  10.111 +        {
  10.112 +            gdprintk(XENLOG_ERR, "Error getting invlpg instr len\n");
  10.113 +            goto crash;
  10.114 +        }
  10.115  
  10.116          inst_len--;
  10.117          length -= inst_len;
  10.118 @@ -2012,10 +2022,14 @@ void svm_handle_invlpg(const short invlp
  10.119          __update_guest_eip(regs, inst_len);
  10.120      }
  10.121  
  10.122 -    HVMTRACE_3D(INVLPG, v, (invlpga?1:0), g_vaddr, (invlpga?regs->ecx:0));
  10.123 +    HVMTRACE_3D(INVLPG, v, !!invlpga, g_vaddr, (invlpga ? regs->ecx : 0));
  10.124  
  10.125      paging_invlpg(v, g_vaddr);
  10.126      svm_asid_g_invlpg(v, g_vaddr);
  10.127 +    return;
  10.128 +
  10.129 + crash:
  10.130 +    domain_crash(v->domain);
  10.131  }
  10.132  
  10.133  
  10.134 @@ -2242,7 +2256,6 @@ asmlinkage void svm_vmexit_handler(struc
  10.135  
  10.136      case VMEXIT_VMMCALL:
  10.137          inst_len = __get_instruction_length(v, INSTR_VMCALL, NULL);
  10.138 -        ASSERT(inst_len > 0);
  10.139          HVMTRACE_1D(VMMCALL, v, regs->eax);
  10.140          rc = hvm_do_hypercall(regs);
  10.141          if ( rc != HVM_HCALL_preempted )
    11.1 --- a/xen/arch/x86/mm.c	Tue Nov 20 09:28:15 2007 -0700
    11.2 +++ b/xen/arch/x86/mm.c	Tue Nov 20 11:53:44 2007 -0700
    11.3 @@ -645,11 +645,7 @@ get_page_from_l1e(
    11.4              return 0;
    11.5          }
    11.6  
    11.7 -        /* No reference counting for out-of-range I/O pages. */
    11.8 -        if ( !mfn_valid(mfn) )
    11.9 -            return 1;
   11.10 -
   11.11 -        d = dom_io;
   11.12 +        return 1;
   11.13      }
   11.14  
   11.15      /* Foreign mappings into guests in shadow external mode don't
   11.16 @@ -667,9 +663,8 @@ get_page_from_l1e(
   11.17                  mfn, get_gpfn_from_mfn(mfn),
   11.18                  l1e_get_intpte(l1e), d->domain_id);
   11.19      }
   11.20 -    else if ( (pte_flags_to_cacheattr(l1f) !=
   11.21 -               ((page->count_info >> PGC_cacheattr_base) & 7)) &&
   11.22 -              !is_iomem_page(mfn) )
   11.23 +    else if ( pte_flags_to_cacheattr(l1f) !=
   11.24 +              ((page->count_info >> PGC_cacheattr_base) & 7) )
   11.25      {
   11.26          uint32_t x, nx, y = page->count_info;
   11.27          uint32_t cacheattr = pte_flags_to_cacheattr(l1f);
   11.28 @@ -848,14 +843,16 @@ get_page_from_l4e(
   11.29  
   11.30  void put_page_from_l1e(l1_pgentry_t l1e, struct domain *d)
   11.31  {
   11.32 -    unsigned long    pfn  = l1e_get_pfn(l1e);
   11.33 -    struct page_info *page = mfn_to_page(pfn);
   11.34 -    struct domain   *e;
   11.35 -    struct vcpu     *v;
   11.36 -
   11.37 -    if ( !(l1e_get_flags(l1e) & _PAGE_PRESENT) || !mfn_valid(pfn) )
   11.38 +    unsigned long     pfn = l1e_get_pfn(l1e);
   11.39 +    struct page_info *page;
   11.40 +    struct domain    *e;
   11.41 +    struct vcpu      *v;
   11.42 +
   11.43 +    if ( !(l1e_get_flags(l1e) & _PAGE_PRESENT) || is_iomem_page(pfn) )
   11.44          return;
   11.45  
   11.46 +    page = mfn_to_page(pfn);
   11.47 +
   11.48      e = page_get_owner(page);
   11.49  
   11.50      /*
   11.51 @@ -2763,8 +2760,8 @@ static int destroy_grant_va_mapping(
   11.52      return replace_grant_va_mapping(addr, frame, l1e_empty(), v);
   11.53  }
   11.54  
   11.55 -int create_grant_host_mapping(
   11.56 -    uint64_t addr, unsigned long frame, unsigned int flags)
   11.57 +int create_grant_host_mapping(uint64_t addr, unsigned long frame, 
   11.58 +                              unsigned int flags, unsigned int cache_flags)
   11.59  {
   11.60      l1_pgentry_t pte = l1e_from_pfn(frame, GRANT_PTE_FLAGS);
   11.61  
   11.62 @@ -2773,6 +2770,8 @@ int create_grant_host_mapping(
   11.63      if ( !(flags & GNTMAP_readonly) )
   11.64          l1e_add_flags(pte,_PAGE_RW);
   11.65  
   11.66 +    l1e_add_flags(pte, cacheattr_to_pte_flags(cache_flags >> 5));
   11.67 +
   11.68      if ( flags & GNTMAP_contains_pte )
   11.69          return create_grant_pte_mapping(addr, pte, current);
   11.70      return create_grant_va_mapping(addr, pte, current);
    12.1 --- a/xen/common/grant_table.c	Tue Nov 20 09:28:15 2007 -0700
    12.2 +++ b/xen/common/grant_table.c	Tue Nov 20 11:53:44 2007 -0700
    12.3 @@ -198,6 +198,7 @@ static void
    12.4      int            handle;
    12.5      unsigned long  frame = 0;
    12.6      int            rc = GNTST_okay;
    12.7 +    unsigned int   cache_flags;
    12.8      struct active_grant_entry *act;
    12.9      struct grant_mapping *mt;
   12.10      grant_entry_t *sha;
   12.11 @@ -326,36 +327,58 @@ static void
   12.12  
   12.13      frame = act->frame;
   12.14  
   12.15 +    cache_flags = (sha->flags & (GTF_PAT | GTF_PWT | GTF_PCD) );
   12.16 +
   12.17      spin_unlock(&rd->grant_table->lock);
   12.18  
   12.19 -    if ( unlikely(!mfn_valid(frame)) ||
   12.20 -         unlikely(!((op->flags & GNTMAP_readonly) ?
   12.21 -                    get_page(mfn_to_page(frame), rd) :
   12.22 -                    get_page_and_type(mfn_to_page(frame), rd,
   12.23 -                                      PGT_writable_page))) )
   12.24 +    if ( is_iomem_page(frame) )
   12.25      {
   12.26 -        if ( !rd->is_dying )
   12.27 -            gdprintk(XENLOG_WARNING, "Could not pin grant frame %lx\n", frame);
   12.28 -        rc = GNTST_general_error;
   12.29 -        goto undo_out;
   12.30 -    }
   12.31 -        
   12.32 -    if ( op->flags & GNTMAP_host_map )
   12.33 -    {
   12.34 -        rc = create_grant_host_mapping(op->host_addr, frame, op->flags);
   12.35 -        if ( rc != GNTST_okay )
   12.36 +        if ( !iomem_access_permitted(rd, frame, frame) )
   12.37          {
   12.38 -            if ( !(op->flags & GNTMAP_readonly) )
   12.39 -                put_page_type(mfn_to_page(frame));
   12.40 -            put_page(mfn_to_page(frame));
   12.41 +            gdprintk(XENLOG_WARNING,
   12.42 +                     "Iomem mapping not permitted %lx (domain %d)\n", 
   12.43 +                     frame, rd->domain_id);
   12.44 +            rc = GNTST_general_error;
   12.45              goto undo_out;
   12.46          }
   12.47  
   12.48 -        if ( op->flags & GNTMAP_device_map )
   12.49 +        rc = create_grant_host_mapping(
   12.50 +            op->host_addr, frame, op->flags, cache_flags);
   12.51 +        if ( rc != GNTST_okay )
   12.52 +            goto undo_out;
   12.53 +    }
   12.54 +    else
   12.55 +    {
   12.56 +        if ( unlikely(!mfn_valid(frame)) ||
   12.57 +             unlikely(!((op->flags & GNTMAP_readonly) ?
   12.58 +                        get_page(mfn_to_page(frame), rd) :
   12.59 +                        get_page_and_type(mfn_to_page(frame), rd,
   12.60 +                                          PGT_writable_page))) )
   12.61          {
   12.62 -            (void)get_page(mfn_to_page(frame), rd);
   12.63 -            if ( !(op->flags & GNTMAP_readonly) )
   12.64 -                get_page_type(mfn_to_page(frame), PGT_writable_page);
   12.65 +            if ( !rd->is_dying )
   12.66 +                gdprintk(XENLOG_WARNING, "Could not pin grant frame %lx\n",
   12.67 +                         frame);
   12.68 +            rc = GNTST_general_error;
   12.69 +            goto undo_out;
   12.70 +        }
   12.71 +        
   12.72 +        if ( op->flags & GNTMAP_host_map )
   12.73 +        {
   12.74 +            rc = create_grant_host_mapping(op->host_addr, frame, op->flags, 0);
   12.75 +            if ( rc != GNTST_okay )
   12.76 +            {
   12.77 +                if ( !(op->flags & GNTMAP_readonly) )
   12.78 +                    put_page_type(mfn_to_page(frame));
   12.79 +                put_page(mfn_to_page(frame));
   12.80 +                goto undo_out;
   12.81 +            }
   12.82 +
   12.83 +            if ( op->flags & GNTMAP_device_map )
   12.84 +            {
   12.85 +                (void)get_page(mfn_to_page(frame), rd);
   12.86 +                if ( !(op->flags & GNTMAP_readonly) )
   12.87 +                    get_page_type(mfn_to_page(frame), PGT_writable_page);
   12.88 +            }
   12.89          }
   12.90      }
   12.91  
   12.92 @@ -559,10 +582,13 @@ static void
   12.93  
   12.94      if ( op->flags & GNTMAP_device_map ) 
   12.95      {
   12.96 -        if ( op->flags & GNTMAP_readonly )
   12.97 -            put_page(mfn_to_page(op->frame));
   12.98 -        else
   12.99 -            put_page_and_type(mfn_to_page(op->frame));
  12.100 +        if ( !is_iomem_page(act->frame) )
  12.101 +        {
  12.102 +            if ( op->flags & GNTMAP_readonly )
  12.103 +                put_page(mfn_to_page(op->frame));
  12.104 +            else
  12.105 +                put_page_and_type(mfn_to_page(op->frame));
  12.106 +        }
  12.107      }
  12.108  
  12.109      if ( (op->host_addr != 0) && (op->flags & GNTMAP_host_map) )
  12.110 @@ -576,10 +602,12 @@ static void
  12.111              goto unmap_out;
  12.112          }
  12.113  
  12.114 -        if ( op->flags & GNTMAP_readonly )
  12.115 +        if ( !is_iomem_page(op->frame) ) 
  12.116 +        {
  12.117 +            if ( !(op->flags & GNTMAP_readonly) )
  12.118 +                put_page_type(mfn_to_page(op->frame));
  12.119              put_page(mfn_to_page(op->frame));
  12.120 -        else
  12.121 -            put_page_and_type(mfn_to_page(op->frame));
  12.122 +        }
  12.123      }
  12.124  
  12.125      if ( (op->map->flags & (GNTMAP_device_map|GNTMAP_host_map)) == 0 )
  12.126 @@ -1595,14 +1623,16 @@ gnttab_release_mappings(
  12.127              {
  12.128                  BUG_ON(!(act->pin & GNTPIN_devr_mask));
  12.129                  act->pin -= GNTPIN_devr_inc;
  12.130 -                put_page(mfn_to_page(act->frame));
  12.131 +                if ( !is_iomem_page(act->frame) )
  12.132 +                    put_page(mfn_to_page(act->frame));
  12.133              }
  12.134  
  12.135              if ( map->flags & GNTMAP_host_map )
  12.136              {
  12.137                  BUG_ON(!(act->pin & GNTPIN_hstr_mask));
  12.138                  act->pin -= GNTPIN_hstr_inc;
  12.139 -                gnttab_release_put_page(mfn_to_page(act->frame));
  12.140 +                if ( !is_iomem_page(act->frame) )
  12.141 +                    gnttab_release_put_page(mfn_to_page(act->frame));
  12.142              }
  12.143          }
  12.144          else
  12.145 @@ -1611,14 +1641,16 @@ gnttab_release_mappings(
  12.146              {
  12.147                  BUG_ON(!(act->pin & GNTPIN_devw_mask));
  12.148                  act->pin -= GNTPIN_devw_inc;
  12.149 -                put_page_and_type(mfn_to_page(act->frame));
  12.150 +                if ( !is_iomem_page(act->frame) )
  12.151 +                    put_page_and_type(mfn_to_page(act->frame));
  12.152              }
  12.153  
  12.154              if ( map->flags & GNTMAP_host_map )
  12.155              {
  12.156                  BUG_ON(!(act->pin & GNTPIN_hstw_mask));
  12.157                  act->pin -= GNTPIN_hstw_inc;
  12.158 -                gnttab_release_put_page_and_type(mfn_to_page(act->frame));
  12.159 +                if ( !is_iomem_page(act->frame) )
  12.160 +                    gnttab_release_put_page_and_type(mfn_to_page(act->frame));
  12.161              }
  12.162  
  12.163              if ( (act->pin & (GNTPIN_devw_mask|GNTPIN_hstw_mask)) == 0 )
    13.1 --- a/xen/include/asm-ia64/grant_table.h	Tue Nov 20 09:28:15 2007 -0700
    13.2 +++ b/xen/include/asm-ia64/grant_table.h	Tue Nov 20 11:53:44 2007 -0700
    13.3 @@ -8,7 +8,8 @@
    13.4  #define INITIAL_NR_GRANT_FRAMES 1
    13.5  
    13.6  // for grant map/unmap
    13.7 -int create_grant_host_mapping(unsigned long gpaddr, unsigned long mfn, unsigned int flags);
    13.8 +int create_grant_host_mapping(unsigned long gpaddr, unsigned long mfn, 
    13.9 +			      unsigned int flags, unsigned int cache_flags);
   13.10  int replace_grant_host_mapping(unsigned long gpaddr, unsigned long mfn, unsigned long new_gpaddr, unsigned int flags);
   13.11  
   13.12  // for grant transfer
    14.1 --- a/xen/include/asm-powerpc/grant_table.h	Tue Nov 20 09:28:15 2007 -0700
    14.2 +++ b/xen/include/asm-powerpc/grant_table.h	Tue Nov 20 11:53:44 2007 -0700
    14.3 @@ -33,8 +33,8 @@ extern long pte_enter(ulong flags, ulong
    14.4  extern long pte_remove(ulong flags, ulong ptex, ulong avpn,
    14.5                         ulong *hi, ulong *lo);
    14.6  
    14.7 -int create_grant_host_mapping(
    14.8 -    unsigned long addr, unsigned long frame, unsigned int flags);
    14.9 +int create_grant_host_mapping(unsigned long addr, unsigned long frame, 
   14.10 +			      unsigned int flags, unsigned int cache_flags);
   14.11  int replace_grant_host_mapping(
   14.12      unsigned long addr, unsigned long frame, unsigned long new_addr,
   14.13      unsigned int flags);
    15.1 --- a/xen/include/asm-x86/grant_table.h	Tue Nov 20 09:28:15 2007 -0700
    15.2 +++ b/xen/include/asm-x86/grant_table.h	Tue Nov 20 11:53:44 2007 -0700
    15.3 @@ -13,8 +13,8 @@
    15.4   * Caller must own caller's BIGLOCK, is responsible for flushing the TLB, and
    15.5   * must hold a reference to the page.
    15.6   */
    15.7 -int create_grant_host_mapping(
    15.8 -    uint64_t addr, unsigned long frame, unsigned int flags);
    15.9 +int create_grant_host_mapping(uint64_t addr, unsigned long frame,
   15.10 +			      unsigned int flags, unsigned int cache_flags);
   15.11  int replace_grant_host_mapping(
   15.12      uint64_t addr, unsigned long frame, uint64_t new_addr, unsigned int flags);
   15.13  
    16.1 --- a/xen/include/public/grant_table.h	Tue Nov 20 09:28:15 2007 -0700
    16.2 +++ b/xen/include/public/grant_table.h	Tue Nov 20 11:53:44 2007 -0700
    16.3 @@ -119,6 +119,7 @@ typedef struct grant_entry grant_entry_t
    16.4   *  GTF_readonly: Restrict @domid to read-only mappings and accesses. [GST]
    16.5   *  GTF_reading: Grant entry is currently mapped for reading by @domid. [XEN]
    16.6   *  GTF_writing: Grant entry is currently mapped for writing by @domid. [XEN]
    16.7 + *  GTF_PAT, GTF_PWT, GTF_PCD: (x86) cache attribute flags for the grant [GST]
    16.8   */
    16.9  #define _GTF_readonly       (2)
   16.10  #define GTF_readonly        (1U<<_GTF_readonly)
   16.11 @@ -126,6 +127,12 @@ typedef struct grant_entry grant_entry_t
   16.12  #define GTF_reading         (1U<<_GTF_reading)
   16.13  #define _GTF_writing        (4)
   16.14  #define GTF_writing         (1U<<_GTF_writing)
   16.15 +#define _GTF_PWT            (5)
   16.16 +#define GTF_PWT             (1U<<_GTF_PWT)
   16.17 +#define _GTF_PCD            (6)
   16.18 +#define GTF_PCD             (1U<<_GTF_PCD)
   16.19 +#define _GTF_PAT            (7)
   16.20 +#define GTF_PAT             (1U<<_GTF_PAT)
   16.21  
   16.22  /*
   16.23   * Subflags for GTF_accept_transfer:
    17.1 --- a/xen/include/xsm/acm/acm_hooks.h	Tue Nov 20 09:28:15 2007 -0700
    17.2 +++ b/xen/include/xsm/acm/acm_hooks.h	Tue Nov 20 11:53:44 2007 -0700
    17.3 @@ -325,7 +325,7 @@ static inline int acm_authorization(ssid
    17.4               acm_secondary_ops->authorization(ssidref1, ssidref2)) {
    17.5          return ACM_ACCESS_DENIED;
    17.6      } else
    17.7 -        return ACM_ACCESS_PERMITTED;
    17.8 +        return acm_sharing(ssidref1, ssidref2);
    17.9  }
   17.10  
   17.11  
    18.1 --- a/xen/xsm/acm/acm_policy.c	Tue Nov 20 09:28:15 2007 -0700
    18.2 +++ b/xen/xsm/acm/acm_policy.c	Tue Nov 20 11:53:44 2007 -0700
    18.3 @@ -430,6 +430,9 @@ int
    18.4  acm_get_decision(ssidref_t ssidref1, ssidref_t ssidref2, u32 hook)
    18.5  {
    18.6      int ret = ACM_ACCESS_DENIED;
    18.7 +
    18.8 +    read_lock(&acm_bin_pol_rwlock);
    18.9 +
   18.10      switch ( hook )
   18.11      {
   18.12  
   18.13 @@ -447,6 +450,8 @@ acm_get_decision(ssidref_t ssidref1, ssi
   18.14          break;
   18.15      }
   18.16  
   18.17 +    read_unlock(&acm_bin_pol_rwlock);
   18.18 +
   18.19      printkd("%s: ssid1=%x, ssid2=%x, decision=%s.\n",
   18.20              __func__, ssidref1, ssidref2,
   18.21              (ret == ACM_ACCESS_PERMITTED) ? "GRANTED" : "DENIED");