WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] merge with xen-unstable.hg (staging)

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] merge with xen-unstable.hg (staging)
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Thu, 22 Nov 2007 12:00:54 -0800
Delivery-date: Thu, 22 Nov 2007 12:04:02 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Alex Williamson <alex.williamson@xxxxxx>
# Date 1195584824 25200
# Node ID 9a9ddc04eea2cac0ccfe8be2b9259b4edea5ec9d
# Parent  87afd05bd254024f5726191861e8ea201102c7b4
# Parent  2e5d922b7ee3d80b513c641b6e7a50aae7d1a058
merge with xen-unstable.hg (staging)
---
 tools/python/xen/xend/XendAPI.py        |   10 ++
 tools/python/xen/xend/XendDomainInfo.py |    7 +-
 tools/python/xen/xend/XendMonitor.py    |   14 ++++
 tools/python/xen/xend/XendNode.py       |    6 +
 xen/arch/ia64/xen/domain.c              |    3 
 xen/arch/ia64/xen/mm.c                  |   12 ++-
 xen/arch/powerpc/mm.c                   |    7 +-
 xen/arch/x86/domain.c                   |   15 ++--
 xen/arch/x86/domain_build.c             |    6 -
 xen/arch/x86/hvm/svm/svm.c              |   61 ++++++++++--------
 xen/arch/x86/mm.c                       |   31 ++++-----
 xen/common/grant_table.c                |  108 ++++++++++++++++++++------------
 xen/include/asm-ia64/grant_table.h      |    3 
 xen/include/asm-powerpc/grant_table.h   |    4 -
 xen/include/asm-x86/grant_table.h       |    4 -
 xen/include/public/grant_table.h        |    7 ++
 xen/include/xsm/acm/acm_hooks.h         |    2 
 xen/xsm/acm/acm_policy.c                |    5 +
 18 files changed, 200 insertions(+), 105 deletions(-)

diff -r 87afd05bd254 -r 9a9ddc04eea2 tools/python/xen/xend/XendAPI.py
--- a/tools/python/xen/xend/XendAPI.py  Tue Nov 20 09:28:15 2007 -0700
+++ b/tools/python/xen/xend/XendAPI.py  Tue Nov 20 11:53:44 2007 -0700
@@ -2111,6 +2111,8 @@ class XendAPI(object):
 
     VIF_metrics_attr_ro = ['io_read_kbs',
                            'io_write_kbs',
+                           'io_total_read_kbs',
+                           'io_total_write_kbs',
                            'last_updated']
     VIF_metrics_attr_rw = []
     VIF_metrics_methods = []
@@ -2125,6 +2127,8 @@ class XendAPI(object):
         return xen_api_success(
             { 'io_read_kbs'  : vm.get_dev_property('vif', ref, 'io_read_kbs'),
               'io_write_kbs' : vm.get_dev_property('vif', ref, 'io_write_kbs'),
+              'io_total_read_kbs'  : vm.get_dev_property('vif', ref, 
'io_total_read_kbs'),
+              'io_total_write_kbs' : vm.get_dev_property('vif', ref, 
'io_total_write_kbs'),
               'last_updated' : now()
             })
 
@@ -2133,6 +2137,12 @@ class XendAPI(object):
     
     def VIF_metrics_get_io_write_kbs(self, session, ref):
         return self._VIF_get(ref, 'io_write_kbs')
+
+    def VIF_metrics_get_io_total_read_kbs(self, _, ref):
+        return self._VIF_get(ref, 'io_total_read_kbs')
+
+    def VIF_metrics_get_io_total_write_kbs(self, session, ref):
+        return self._VIF_get(ref, 'io_total_write_kbs')
 
     def VIF_metrics_get_last_updated(self, _1, _2):
         return xen_api_success(now())
diff -r 87afd05bd254 -r 9a9ddc04eea2 tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py   Tue Nov 20 09:28:15 2007 -0700
+++ b/tools/python/xen/xend/XendDomainInfo.py   Tue Nov 20 11:53:44 2007 -0700
@@ -2606,9 +2606,14 @@ class XendDomainInfo:
                 rx_bps, tx_bps = xennode.get_vif_util(self.domid, devid)
                 config['io_read_kbs'] = rx_bps/1024
                 config['io_write_kbs'] = tx_bps/1024
+                rx, tx = xennode.get_vif_stat(self.domid, devid)
+                config['io_total_read_kbs'] = rx/1024
+                config['io_total_write_kbs'] = tx/1024
             else:
                 config['io_read_kbs'] = 0.0
-                config['io_write_kbs'] = 0.0                
+                config['io_write_kbs'] = 0.0          
+                config['io_total_read_kbs'] = 0.0
+                config['io_total_write_kbs'] = 0.0
 
             config['security_label'] = config.get('security_label', '')
 
diff -r 87afd05bd254 -r 9a9ddc04eea2 tools/python/xen/xend/XendMonitor.py
--- a/tools/python/xen/xend/XendMonitor.py      Tue Nov 20 09:28:15 2007 -0700
+++ b/tools/python/xen/xend/XendMonitor.py      Tue Nov 20 11:53:44 2007 -0700
@@ -63,6 +63,8 @@ class XendMonitor(threading.Thread):
     @type domain_vcpus_util: {domid: {vcpuid: float, vcpuid: float}}
     @ivar domain_vifs_util: Bytes per second for VIFs indexed by domain
     @type domain_vifs_util: {domid: {vifid: (rx_bps, tx_bps)}}
+    @ivar domain_vifs_stat: Total amount of bytes used for VIFs indexed by 
domain
+    @type domain_vifs_stat: {domid: {vbdid: (rx, tx)}}
     @ivar domain_vbds_util: Blocks per second for VBDs index by domain.
     @type domain_vbds_util: {domid: {vbdid: (rd_reqps, wr_reqps)}}    
     
@@ -83,6 +85,7 @@ class XendMonitor(threading.Thread):
         # instantaneous statistics
         self._domain_vcpus_util = {}
         self._domain_vifs_util = {}
+        self._domain_vifs_stat = {}
         self._domain_vbds_util = {}
         self.pifs_util = {}
 
@@ -104,6 +107,13 @@ class XendMonitor(threading.Thread):
         self.lock.acquire()
         try:
             return self._domain_vifs_util
+        finally:
+            self.lock.release()
+
+    def get_domain_vifs_stat(self):
+        self.lock.acquire()
+        try:
+            return self._domain_vifs_stat
         finally:
             self.lock.release()
 
@@ -269,6 +279,7 @@ class XendMonitor(threading.Thread):
                     if domid not in self._domain_vifs:
                         self._domain_vifs[domid] = vifs
                         self._domain_vifs_util[domid] = {}
+                        self._domain_vifs_stat[domid] = {}
                         continue
                 
                     for devid, (usage_at, rx, tx) in vifs.items():
@@ -286,6 +297,8 @@ class XendMonitor(threading.Thread):
                         # not the guest interface
                         self._domain_vifs_util[domid][devid] = \
                              (tx_util, rx_util)
+                        self._domain_vifs_stat[domid][devid] = \
+                             (float(tx), float(rx))
                         
                     self._domain_vifs[domid] = vifs
 
@@ -313,6 +326,7 @@ class XendMonitor(threading.Thread):
                     if domid not in active_domids:
                         del self._domain_vifs_util[domid]
                         del self._domain_vifs[domid]
+                        del self._domain_vifs_stat[domid]
                 for domid in self._domain_vbds_util.keys():
                     if domid not in active_domids:
                         del self._domain_vbds_util[domid]
diff -r 87afd05bd254 -r 9a9ddc04eea2 tools/python/xen/xend/XendNode.py
--- a/tools/python/xen/xend/XendNode.py Tue Nov 20 09:28:15 2007 -0700
+++ b/tools/python/xen/xend/XendNode.py Tue Nov 20 11:53:44 2007 -0700
@@ -651,6 +651,12 @@ class XendNode:
             return vif_loads[domid].get(vifid, (0.0, 0.0))
         return (0.0, 0.0)
 
+    def get_vif_stat(self, domid, vifid):
+        vif_loads = self.monitor.get_domain_vifs_stat()
+        if domid in vif_loads:
+            return vif_loads[domid].get(vifid, (0.0, 0.0))
+        return (0.0, 0.0)
+
     def get_vbd_util(self, domid, vbdid):
         vbd_loads = self.monitor.get_domain_vbds_util()
         if domid in vbd_loads:
diff -r 87afd05bd254 -r 9a9ddc04eea2 xen/arch/ia64/xen/domain.c
--- a/xen/arch/ia64/xen/domain.c        Tue Nov 20 09:28:15 2007 -0700
+++ b/xen/arch/ia64/xen/domain.c        Tue Nov 20 11:53:44 2007 -0700
@@ -2137,8 +2137,7 @@ int __init construct_dom0(struct domain 
                panic("can't allocate start info page");
        si = page_to_virt(start_info_page);
        clear_page(si);
-       snprintf(si->magic, sizeof(si->magic), "xen-%i.%i-ia64",
-               xen_major_version(), xen_minor_version());
+       snprintf(si->magic, sizeof(si->magic), "xen-3.0-ia64");
        si->nr_pages     = max_pages;
        si->flags = SIF_INITDOMAIN|SIF_PRIVILEGED;
 
diff -r 87afd05bd254 -r 9a9ddc04eea2 xen/arch/ia64/xen/mm.c
--- a/xen/arch/ia64/xen/mm.c    Tue Nov 20 09:28:15 2007 -0700
+++ b/xen/arch/ia64/xen/mm.c    Tue Nov 20 11:53:44 2007 -0700
@@ -2144,16 +2144,18 @@ dom0vp_unexpose_foreign_p2m(struct domai
 // mfn: frame: machine page frame
 // flags: GNTMAP_readonly | GNTMAP_application_map | GNTMAP_contains_pte
 int
-create_grant_host_mapping(unsigned long gpaddr,
-              unsigned long mfn, unsigned int flags)
+create_grant_host_mapping(unsigned long gpaddr, unsigned long mfn, 
+                          unsigned int flags, unsigned int cache_flags)
 {
     struct domain* d = current->domain;
     struct page_info* page;
     int ret;
 
-    if (flags & (GNTMAP_device_map |
-                 GNTMAP_application_map | GNTMAP_contains_pte)) {
-        gdprintk(XENLOG_INFO, "%s: flags 0x%x\n", __func__, flags);
+    if ((flags & (GNTMAP_device_map | 
+                  GNTMAP_application_map | GNTMAP_contains_pte)) ||
+        (cache_flags)) {
+        gdprintk(XENLOG_INFO, "%s: flags 0x%x cache_flags 0x%x\n",
+                 __func__, flags, cache_flags);
         return GNTST_general_error;
     }
 
diff -r 87afd05bd254 -r 9a9ddc04eea2 xen/arch/powerpc/mm.c
--- a/xen/arch/powerpc/mm.c     Tue Nov 20 09:28:15 2007 -0700
+++ b/xen/arch/powerpc/mm.c     Tue Nov 20 11:53:44 2007 -0700
@@ -168,7 +168,7 @@ static int destroy_grant_va_mapping(
 }
 
 int create_grant_host_mapping(
-    unsigned long addr, unsigned long frame, unsigned int flags)
+    unsigned long addr, unsigned long frame, unsigned int flags, unsigned int 
cache_flags)
 {
     if (flags & GNTMAP_application_map) {
         printk("%s: GNTMAP_application_map not supported\n", __func__);
@@ -177,6 +177,11 @@ int create_grant_host_mapping(
     }
     if (flags & GNTMAP_contains_pte) {
         printk("%s: GNTMAP_contains_pte not supported\n", __func__);
+        BUG();
+        return GNTST_general_error;
+    }
+    if (cache_flags) {
+        printk("%s: cache_flags not supported\n", __func__);
         BUG();
         return GNTST_general_error;
     }
diff -r 87afd05bd254 -r 9a9ddc04eea2 xen/arch/x86/domain.c
--- a/xen/arch/x86/domain.c     Tue Nov 20 09:28:15 2007 -0700
+++ b/xen/arch/x86/domain.c     Tue Nov 20 11:53:44 2007 -0700
@@ -1756,10 +1756,6 @@ static void vcpu_destroy_pagetables(stru
             put_page(mfn_to_page(pfn));
         else
             put_page_and_type(mfn_to_page(pfn));
-#ifdef __x86_64__
-        if ( pfn == pagetable_get_pfn(v->arch.guest_table_user) )
-            v->arch.guest_table_user = pagetable_null();
-#endif
         v->arch.guest_table = pagetable_null();
     }
 
@@ -1768,10 +1764,13 @@ static void vcpu_destroy_pagetables(stru
     pfn = pagetable_get_pfn(v->arch.guest_table_user);
     if ( pfn != 0 )
     {
-        if ( paging_mode_refcounts(d) )
-            put_page(mfn_to_page(pfn));
-        else
-            put_page_and_type(mfn_to_page(pfn));
+        if ( !is_pv_32bit_vcpu(v) )
+        {
+            if ( paging_mode_refcounts(d) )
+                put_page(mfn_to_page(pfn));
+            else
+                put_page_and_type(mfn_to_page(pfn));
+        }
         v->arch.guest_table_user = pagetable_null();
     }
 #endif
diff -r 87afd05bd254 -r 9a9ddc04eea2 xen/arch/x86/domain_build.c
--- a/xen/arch/x86/domain_build.c       Tue Nov 20 09:28:15 2007 -0700
+++ b/xen/arch/x86/domain_build.c       Tue Nov 20 11:53:44 2007 -0700
@@ -832,10 +832,8 @@ int __init construct_dom0(
     si->pt_base      = vpt_start + 2 * PAGE_SIZE * !!is_pv_32on64_domain(d);
     si->nr_pt_frames = nr_pt_pages;
     si->mfn_list     = vphysmap_start;
-    snprintf(si->magic, sizeof(si->magic), "xen-%i.%i-x86_%d%s",
-            xen_major_version(), xen_minor_version(),
-            elf_64bit(&elf) ? 64 : 32,
-            parms.pae ? "p" : "");
+    snprintf(si->magic, sizeof(si->magic), "xen-3.0-x86_%d%s",
+             elf_64bit(&elf) ? 64 : 32, parms.pae ? "p" : "");
 
     /* Write the phys->machine and machine->phys table entries. */
     for ( pfn = 0; pfn < d->tot_pages; pfn++ )
diff -r 87afd05bd254 -r 9a9ddc04eea2 xen/arch/x86/hvm/svm/svm.c
--- a/xen/arch/x86/hvm/svm/svm.c        Tue Nov 20 09:28:15 2007 -0700
+++ b/xen/arch/x86/hvm/svm/svm.c        Tue Nov 20 11:53:44 2007 -0700
@@ -74,11 +74,21 @@ static void svm_update_guest_efer(struct
 static void svm_update_guest_efer(struct vcpu *v);
 
 static void inline __update_guest_eip(
-    struct cpu_user_regs *regs, int inst_len) 
-{
-    ASSERT(inst_len > 0);
+    struct cpu_user_regs *regs, unsigned int inst_len)
+{
+    if ( unlikely((inst_len == 0) || (inst_len > 15)) )
+    {
+        gdprintk(XENLOG_ERR, "Bad instruction length %u\n", inst_len);
+        domain_crash(current->domain);
+        return;
+    }
+
+    ASSERT(regs == guest_cpu_user_regs());
+
     regs->eip += inst_len;
     regs->eflags &= ~X86_EFLAGS_RF;
+
+    current->arch.hvm_svm.vmcb->interrupt_shadow = 0;
 }
 
 static void svm_inject_exception(
@@ -1061,7 +1071,6 @@ static void svm_vmexit_do_cpuid(struct v
                 ((uint64_t)eax << 32) | ebx, ((uint64_t)ecx << 32) | edx);
 
     inst_len = __get_instruction_length(v, INSTR_CPUID, NULL);
-    ASSERT(inst_len > 0);
     __update_guest_eip(regs, inst_len);
 }
 
@@ -1642,8 +1651,6 @@ static void svm_cr_access(
         inst_len = __get_instruction_length_from_list(
             v, list_b, ARRAY_SIZE(list_b), &buffer[index], &match);
     }
-
-    ASSERT(inst_len > 0);
 
     inst_len += index;
 
@@ -1745,8 +1752,6 @@ static void svm_cr_access(
         BUG();
     }
 
-    ASSERT(inst_len);
-
     if ( result )
         __update_guest_eip(regs, inst_len);
 }
@@ -1925,20 +1930,23 @@ static void svm_vmexit_do_hlt(struct vmc
 static void svm_vmexit_do_hlt(struct vmcb_struct *vmcb,
                               struct cpu_user_regs *regs)
 {
-    struct hvm_intack intack = hvm_vcpu_has_pending_irq(current);
-
-    __update_guest_eip(regs, 1);
+    struct vcpu *curr = current;
+    struct hvm_intack intack = hvm_vcpu_has_pending_irq(curr);
+    unsigned int inst_len;
+
+    inst_len = __get_instruction_length(curr, INSTR_HLT, NULL);
+    __update_guest_eip(regs, inst_len);
 
     /* Check for interrupt not handled or new interrupt. */
     if ( vmcb->eventinj.fields.v ||
          ((intack.source != hvm_intsrc_none) &&
           !svm_interrupt_blocked(current, intack)) )
     {
-        HVMTRACE_1D(HLT, current, /*int pending=*/ 1);
+        HVMTRACE_1D(HLT, curr, /*int pending=*/ 1);
         return;
     }
 
-    HVMTRACE_1D(HLT, current, /*int pending=*/ 0);
+    HVMTRACE_1D(HLT, curr, /*int pending=*/ 0);
     hvm_hlt(regs->eflags);
 }
 
@@ -1971,17 +1979,15 @@ void svm_handle_invlpg(const short invlp
      * Unknown how many bytes the invlpg instruction will take.  Use the
      * maximum instruction length here
      */
-    if (inst_copy_from_guest(opcode, svm_rip2pointer(v), length) < length)
+    if ( inst_copy_from_guest(opcode, svm_rip2pointer(v), length) < length )
     {
         gdprintk(XENLOG_ERR, "Error reading memory %d bytes\n", length);
-        domain_crash(v->domain);
-        return;
-    }
-
-    if (invlpga)
+        goto crash;
+    }
+
+    if ( invlpga )
     {
         inst_len = __get_instruction_length(v, INSTR_INVLPGA, opcode);
-        ASSERT(inst_len > 0);
         __update_guest_eip(regs, inst_len);
 
         /* 
@@ -1993,9 +1999,13 @@ void svm_handle_invlpg(const short invlp
     else
     {
         /* What about multiple prefix codes? */
-        prefix = (is_prefix(opcode[0])?opcode[0]:0);
+        prefix = (is_prefix(opcode[0]) ? opcode[0] : 0);
         inst_len = __get_instruction_length(v, INSTR_INVLPG, opcode);
-        ASSERT(inst_len > 0);
+        if ( inst_len <= 0 )
+        {
+            gdprintk(XENLOG_ERR, "Error getting invlpg instr len\n");
+            goto crash;
+        }
 
         inst_len--;
         length -= inst_len;
@@ -2012,10 +2022,14 @@ void svm_handle_invlpg(const short invlp
         __update_guest_eip(regs, inst_len);
     }
 
-    HVMTRACE_3D(INVLPG, v, (invlpga?1:0), g_vaddr, (invlpga?regs->ecx:0));
+    HVMTRACE_3D(INVLPG, v, !!invlpga, g_vaddr, (invlpga ? regs->ecx : 0));
 
     paging_invlpg(v, g_vaddr);
     svm_asid_g_invlpg(v, g_vaddr);
+    return;
+
+ crash:
+    domain_crash(v->domain);
 }
 
 
@@ -2242,7 +2256,6 @@ asmlinkage void svm_vmexit_handler(struc
 
     case VMEXIT_VMMCALL:
         inst_len = __get_instruction_length(v, INSTR_VMCALL, NULL);
-        ASSERT(inst_len > 0);
         HVMTRACE_1D(VMMCALL, v, regs->eax);
         rc = hvm_do_hypercall(regs);
         if ( rc != HVM_HCALL_preempted )
diff -r 87afd05bd254 -r 9a9ddc04eea2 xen/arch/x86/mm.c
--- a/xen/arch/x86/mm.c Tue Nov 20 09:28:15 2007 -0700
+++ b/xen/arch/x86/mm.c Tue Nov 20 11:53:44 2007 -0700
@@ -645,11 +645,7 @@ get_page_from_l1e(
             return 0;
         }
 
-        /* No reference counting for out-of-range I/O pages. */
-        if ( !mfn_valid(mfn) )
-            return 1;
-
-        d = dom_io;
+        return 1;
     }
 
     /* Foreign mappings into guests in shadow external mode don't
@@ -667,9 +663,8 @@ get_page_from_l1e(
                 mfn, get_gpfn_from_mfn(mfn),
                 l1e_get_intpte(l1e), d->domain_id);
     }
-    else if ( (pte_flags_to_cacheattr(l1f) !=
-               ((page->count_info >> PGC_cacheattr_base) & 7)) &&
-              !is_iomem_page(mfn) )
+    else if ( pte_flags_to_cacheattr(l1f) !=
+              ((page->count_info >> PGC_cacheattr_base) & 7) )
     {
         uint32_t x, nx, y = page->count_info;
         uint32_t cacheattr = pte_flags_to_cacheattr(l1f);
@@ -848,13 +843,15 @@ get_page_from_l4e(
 
 void put_page_from_l1e(l1_pgentry_t l1e, struct domain *d)
 {
-    unsigned long    pfn  = l1e_get_pfn(l1e);
-    struct page_info *page = mfn_to_page(pfn);
-    struct domain   *e;
-    struct vcpu     *v;
-
-    if ( !(l1e_get_flags(l1e) & _PAGE_PRESENT) || !mfn_valid(pfn) )
+    unsigned long     pfn = l1e_get_pfn(l1e);
+    struct page_info *page;
+    struct domain    *e;
+    struct vcpu      *v;
+
+    if ( !(l1e_get_flags(l1e) & _PAGE_PRESENT) || is_iomem_page(pfn) )
         return;
+
+    page = mfn_to_page(pfn);
 
     e = page_get_owner(page);
 
@@ -2763,8 +2760,8 @@ static int destroy_grant_va_mapping(
     return replace_grant_va_mapping(addr, frame, l1e_empty(), v);
 }
 
-int create_grant_host_mapping(
-    uint64_t addr, unsigned long frame, unsigned int flags)
+int create_grant_host_mapping(uint64_t addr, unsigned long frame, 
+                              unsigned int flags, unsigned int cache_flags)
 {
     l1_pgentry_t pte = l1e_from_pfn(frame, GRANT_PTE_FLAGS);
 
@@ -2772,6 +2769,8 @@ int create_grant_host_mapping(
         l1e_add_flags(pte,_PAGE_USER);
     if ( !(flags & GNTMAP_readonly) )
         l1e_add_flags(pte,_PAGE_RW);
+
+    l1e_add_flags(pte, cacheattr_to_pte_flags(cache_flags >> 5));
 
     if ( flags & GNTMAP_contains_pte )
         return create_grant_pte_mapping(addr, pte, current);
diff -r 87afd05bd254 -r 9a9ddc04eea2 xen/common/grant_table.c
--- a/xen/common/grant_table.c  Tue Nov 20 09:28:15 2007 -0700
+++ b/xen/common/grant_table.c  Tue Nov 20 11:53:44 2007 -0700
@@ -198,6 +198,7 @@ __gnttab_map_grant_ref(
     int            handle;
     unsigned long  frame = 0;
     int            rc = GNTST_okay;
+    unsigned int   cache_flags;
     struct active_grant_entry *act;
     struct grant_mapping *mt;
     grant_entry_t *sha;
@@ -326,36 +327,58 @@ __gnttab_map_grant_ref(
 
     frame = act->frame;
 
+    cache_flags = (sha->flags & (GTF_PAT | GTF_PWT | GTF_PCD) );
+
     spin_unlock(&rd->grant_table->lock);
 
-    if ( unlikely(!mfn_valid(frame)) ||
-         unlikely(!((op->flags & GNTMAP_readonly) ?
-                    get_page(mfn_to_page(frame), rd) :
-                    get_page_and_type(mfn_to_page(frame), rd,
-                                      PGT_writable_page))) )
-    {
-        if ( !rd->is_dying )
-            gdprintk(XENLOG_WARNING, "Could not pin grant frame %lx\n", frame);
-        rc = GNTST_general_error;
-        goto undo_out;
-    }
+    if ( is_iomem_page(frame) )
+    {
+        if ( !iomem_access_permitted(rd, frame, frame) )
+        {
+            gdprintk(XENLOG_WARNING,
+                     "Iomem mapping not permitted %lx (domain %d)\n", 
+                     frame, rd->domain_id);
+            rc = GNTST_general_error;
+            goto undo_out;
+        }
+
+        rc = create_grant_host_mapping(
+            op->host_addr, frame, op->flags, cache_flags);
+        if ( rc != GNTST_okay )
+            goto undo_out;
+    }
+    else
+    {
+        if ( unlikely(!mfn_valid(frame)) ||
+             unlikely(!((op->flags & GNTMAP_readonly) ?
+                        get_page(mfn_to_page(frame), rd) :
+                        get_page_and_type(mfn_to_page(frame), rd,
+                                          PGT_writable_page))) )
+        {
+            if ( !rd->is_dying )
+                gdprintk(XENLOG_WARNING, "Could not pin grant frame %lx\n",
+                         frame);
+            rc = GNTST_general_error;
+            goto undo_out;
+        }
         
-    if ( op->flags & GNTMAP_host_map )
-    {
-        rc = create_grant_host_mapping(op->host_addr, frame, op->flags);
-        if ( rc != GNTST_okay )
-        {
-            if ( !(op->flags & GNTMAP_readonly) )
-                put_page_type(mfn_to_page(frame));
-            put_page(mfn_to_page(frame));
-            goto undo_out;
-        }
-
-        if ( op->flags & GNTMAP_device_map )
-        {
-            (void)get_page(mfn_to_page(frame), rd);
-            if ( !(op->flags & GNTMAP_readonly) )
-                get_page_type(mfn_to_page(frame), PGT_writable_page);
+        if ( op->flags & GNTMAP_host_map )
+        {
+            rc = create_grant_host_mapping(op->host_addr, frame, op->flags, 0);
+            if ( rc != GNTST_okay )
+            {
+                if ( !(op->flags & GNTMAP_readonly) )
+                    put_page_type(mfn_to_page(frame));
+                put_page(mfn_to_page(frame));
+                goto undo_out;
+            }
+
+            if ( op->flags & GNTMAP_device_map )
+            {
+                (void)get_page(mfn_to_page(frame), rd);
+                if ( !(op->flags & GNTMAP_readonly) )
+                    get_page_type(mfn_to_page(frame), PGT_writable_page);
+            }
         }
     }
 
@@ -559,10 +582,13 @@ __gnttab_unmap_common_complete(struct gn
 
     if ( op->flags & GNTMAP_device_map ) 
     {
-        if ( op->flags & GNTMAP_readonly )
-            put_page(mfn_to_page(op->frame));
-        else
-            put_page_and_type(mfn_to_page(op->frame));
+        if ( !is_iomem_page(act->frame) )
+        {
+            if ( op->flags & GNTMAP_readonly )
+                put_page(mfn_to_page(op->frame));
+            else
+                put_page_and_type(mfn_to_page(op->frame));
+        }
     }
 
     if ( (op->host_addr != 0) && (op->flags & GNTMAP_host_map) )
@@ -576,10 +602,12 @@ __gnttab_unmap_common_complete(struct gn
             goto unmap_out;
         }
 
-        if ( op->flags & GNTMAP_readonly )
+        if ( !is_iomem_page(op->frame) ) 
+        {
+            if ( !(op->flags & GNTMAP_readonly) )
+                put_page_type(mfn_to_page(op->frame));
             put_page(mfn_to_page(op->frame));
-        else
-            put_page_and_type(mfn_to_page(op->frame));
+        }
     }
 
     if ( (op->map->flags & (GNTMAP_device_map|GNTMAP_host_map)) == 0 )
@@ -1595,14 +1623,16 @@ gnttab_release_mappings(
             {
                 BUG_ON(!(act->pin & GNTPIN_devr_mask));
                 act->pin -= GNTPIN_devr_inc;
-                put_page(mfn_to_page(act->frame));
+                if ( !is_iomem_page(act->frame) )
+                    put_page(mfn_to_page(act->frame));
             }
 
             if ( map->flags & GNTMAP_host_map )
             {
                 BUG_ON(!(act->pin & GNTPIN_hstr_mask));
                 act->pin -= GNTPIN_hstr_inc;
-                gnttab_release_put_page(mfn_to_page(act->frame));
+                if ( !is_iomem_page(act->frame) )
+                    gnttab_release_put_page(mfn_to_page(act->frame));
             }
         }
         else
@@ -1611,14 +1641,16 @@ gnttab_release_mappings(
             {
                 BUG_ON(!(act->pin & GNTPIN_devw_mask));
                 act->pin -= GNTPIN_devw_inc;
-                put_page_and_type(mfn_to_page(act->frame));
+                if ( !is_iomem_page(act->frame) )
+                    put_page_and_type(mfn_to_page(act->frame));
             }
 
             if ( map->flags & GNTMAP_host_map )
             {
                 BUG_ON(!(act->pin & GNTPIN_hstw_mask));
                 act->pin -= GNTPIN_hstw_inc;
-                gnttab_release_put_page_and_type(mfn_to_page(act->frame));
+                if ( !is_iomem_page(act->frame) )
+                    gnttab_release_put_page_and_type(mfn_to_page(act->frame));
             }
 
             if ( (act->pin & (GNTPIN_devw_mask|GNTPIN_hstw_mask)) == 0 )
diff -r 87afd05bd254 -r 9a9ddc04eea2 xen/include/asm-ia64/grant_table.h
--- a/xen/include/asm-ia64/grant_table.h        Tue Nov 20 09:28:15 2007 -0700
+++ b/xen/include/asm-ia64/grant_table.h        Tue Nov 20 11:53:44 2007 -0700
@@ -8,7 +8,8 @@
 #define INITIAL_NR_GRANT_FRAMES 1
 
 // for grant map/unmap
-int create_grant_host_mapping(unsigned long gpaddr, unsigned long mfn, 
unsigned int flags);
+int create_grant_host_mapping(unsigned long gpaddr, unsigned long mfn, 
+                             unsigned int flags, unsigned int cache_flags);
 int replace_grant_host_mapping(unsigned long gpaddr, unsigned long mfn, 
unsigned long new_gpaddr, unsigned int flags);
 
 // for grant transfer
diff -r 87afd05bd254 -r 9a9ddc04eea2 xen/include/asm-powerpc/grant_table.h
--- a/xen/include/asm-powerpc/grant_table.h     Tue Nov 20 09:28:15 2007 -0700
+++ b/xen/include/asm-powerpc/grant_table.h     Tue Nov 20 11:53:44 2007 -0700
@@ -33,8 +33,8 @@ extern long pte_remove(ulong flags, ulon
 extern long pte_remove(ulong flags, ulong ptex, ulong avpn,
                        ulong *hi, ulong *lo);
 
-int create_grant_host_mapping(
-    unsigned long addr, unsigned long frame, unsigned int flags);
+int create_grant_host_mapping(unsigned long addr, unsigned long frame, 
+                             unsigned int flags, unsigned int cache_flags);
 int replace_grant_host_mapping(
     unsigned long addr, unsigned long frame, unsigned long new_addr,
     unsigned int flags);
diff -r 87afd05bd254 -r 9a9ddc04eea2 xen/include/asm-x86/grant_table.h
--- a/xen/include/asm-x86/grant_table.h Tue Nov 20 09:28:15 2007 -0700
+++ b/xen/include/asm-x86/grant_table.h Tue Nov 20 11:53:44 2007 -0700
@@ -13,8 +13,8 @@
  * Caller must own caller's BIGLOCK, is responsible for flushing the TLB, and
  * must hold a reference to the page.
  */
-int create_grant_host_mapping(
-    uint64_t addr, unsigned long frame, unsigned int flags);
+int create_grant_host_mapping(uint64_t addr, unsigned long frame,
+                             unsigned int flags, unsigned int cache_flags);
 int replace_grant_host_mapping(
     uint64_t addr, unsigned long frame, uint64_t new_addr, unsigned int flags);
 
diff -r 87afd05bd254 -r 9a9ddc04eea2 xen/include/public/grant_table.h
--- a/xen/include/public/grant_table.h  Tue Nov 20 09:28:15 2007 -0700
+++ b/xen/include/public/grant_table.h  Tue Nov 20 11:53:44 2007 -0700
@@ -119,6 +119,7 @@ typedef struct grant_entry grant_entry_t
  *  GTF_readonly: Restrict @domid to read-only mappings and accesses. [GST]
  *  GTF_reading: Grant entry is currently mapped for reading by @domid. [XEN]
  *  GTF_writing: Grant entry is currently mapped for writing by @domid. [XEN]
+ *  GTF_PAT, GTF_PWT, GTF_PCD: (x86) cache attribute flags for the grant [GST]
  */
 #define _GTF_readonly       (2)
 #define GTF_readonly        (1U<<_GTF_readonly)
@@ -126,6 +127,12 @@ typedef struct grant_entry grant_entry_t
 #define GTF_reading         (1U<<_GTF_reading)
 #define _GTF_writing        (4)
 #define GTF_writing         (1U<<_GTF_writing)
+#define _GTF_PWT            (5)
+#define GTF_PWT             (1U<<_GTF_PWT)
+#define _GTF_PCD            (6)
+#define GTF_PCD             (1U<<_GTF_PCD)
+#define _GTF_PAT            (7)
+#define GTF_PAT             (1U<<_GTF_PAT)
 
 /*
  * Subflags for GTF_accept_transfer:
diff -r 87afd05bd254 -r 9a9ddc04eea2 xen/include/xsm/acm/acm_hooks.h
--- a/xen/include/xsm/acm/acm_hooks.h   Tue Nov 20 09:28:15 2007 -0700
+++ b/xen/include/xsm/acm/acm_hooks.h   Tue Nov 20 11:53:44 2007 -0700
@@ -325,7 +325,7 @@ static inline int acm_authorization(ssid
              acm_secondary_ops->authorization(ssidref1, ssidref2)) {
         return ACM_ACCESS_DENIED;
     } else
-        return ACM_ACCESS_PERMITTED;
+        return acm_sharing(ssidref1, ssidref2);
 }
 
 
diff -r 87afd05bd254 -r 9a9ddc04eea2 xen/xsm/acm/acm_policy.c
--- a/xen/xsm/acm/acm_policy.c  Tue Nov 20 09:28:15 2007 -0700
+++ b/xen/xsm/acm/acm_policy.c  Tue Nov 20 11:53:44 2007 -0700
@@ -430,6 +430,9 @@ acm_get_decision(ssidref_t ssidref1, ssi
 acm_get_decision(ssidref_t ssidref1, ssidref_t ssidref2, u32 hook)
 {
     int ret = ACM_ACCESS_DENIED;
+
+    read_lock(&acm_bin_pol_rwlock);
+
     switch ( hook )
     {
 
@@ -446,6 +449,8 @@ acm_get_decision(ssidref_t ssidref1, ssi
         /* deny */
         break;
     }
+
+    read_unlock(&acm_bin_pol_rwlock);
 
     printkd("%s: ssid1=%x, ssid2=%x, decision=%s.\n",
             __func__, ssidref1, ssidref2,

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog