]> xenbits.xen.org Git - xenclient/xen.git/commitdiff
Rebase with xen-3.4.1.
authorJean Guyader <jean.guyader@eu.citrix.com>
Tue, 11 Aug 2009 16:44:03 +0000 (17:44 +0100)
committerJean Guyader <jean.guyader@eu.citrix.com>
Tue, 11 Aug 2009 16:44:03 +0000 (17:44 +0100)
changeset:   19718:13fe7f07df15
tag:         tip
user:        Keir Fraser <keir.fraser@citrix.com>
date:        Thu Aug 06 13:27:53 2009 +0100
summary:     Added tag RELEASE-3.4.1 for changeset 043043fdb7ab

28 files changed:
Config.mk
stubdom/Makefile
stubdom/stubdom-dm
tools/firmware/hvmloader/smbios.c
tools/hotplug/Linux/Makefile
tools/hotplug/Linux/xen-backend.rules
tools/libfsimage/zfs/fsys_zfs.c
tools/libfsimage/zfs/zfs-include/dmu_objset.h
tools/libfsimage/zfs/zfs-include/zfs.h
tools/libfsimage/zfs/zfs-include/zfs_znode.h
tools/python/xen/util/oshelp.py
tools/python/xen/util/xpopen.py
tools/python/xen/util/xsm/acm/acm.py
tools/python/xen/xend/Vifctl.py
tools/python/xen/xend/XendBootloader.py
tools/python/xen/xend/XendCheckpoint.py
tools/python/xen/xend/image.py
xen/Makefile
xen/arch/x86/acpi/cpu_idle.c
xen/arch/x86/hvm/vlapic.c
xen/arch/x86/hvm/vmx/vmx.c
xen/arch/x86/mm.c
xen/arch/x86/mm/hap/p2m-ept.c
xen/arch/x86/traps.c
xen/arch/x86/x86_32/seg_fixup.c
xen/include/public/xsm/acm.h
xen/include/xsm/acm/acm_hooks.h
xen/xsm/acm/acm_core.c

index 5d9197d088eb732ac64d0ad139f0059777e2e74a..37392b7c4910a968ee0a15484e64c712a5629a05 100644 (file)
--- a/Config.mk
+++ b/Config.mk
@@ -118,7 +118,7 @@ XEN_EXTFILES_URL=http://xenbits.xensource.com/xen-extfiles
 # the internet.  The original download URL is preserved as a comment
 # near the place in the Xen Makefiles where the file is used.
 
-QEMU_TAG=xen-3.4.1-rc7
+QEMU_TAG=xen-3.4.1
 QEMU_REMOTE=http://xenbits.xensource.com/git-http/qemu-xen-3.4-testing.git
 
 # Specify which qemu-dm to use. This may be `ioemu' to use the old
index fabb6908decc6674928bf3f2e3bdb19919c71924..3f597f27d3ec5dde4747f17b82482ac070c07fc8 100644 (file)
@@ -349,6 +349,7 @@ crossclean: clean
        rm -fr zlib-$(XEN_TARGET_ARCH) pciutils-$(XEN_TARGET_ARCH)
        rm -fr libxc-$(XEN_TARGET_ARCH) ioemu
        rm -f mk-headers-$(XEN_TARGET_ARCH)
+       rm -fr include
 
 # clean patched sources
 .PHONY: patchclean
index cb1e22c3856f1b78a0dd416e0c4d6bb30378befc..9bd423121c7807930839e2d433c983f35046937d 100644 (file)
@@ -62,8 +62,8 @@ do
     shift
 done
 
-[ -z "$domid"   ] && ( echo "couldn't find domain ID" ; exit 1 )
-[ -z "$domname" ] && ( echo "couldn't find domain name" ; exit 1 )
+[ -z "$domid"   ] && { echo "couldn't find domain ID" ; exit 1; }
+[ -z "$domname" ] && { echo "couldn't find domain name" ; exit 1; }
 
 # Termination handler
 
index 64fa799c0b882d9d515142951e603a7ccef16932..a5237cc81e040c8846ab4875f0422195a16bd180 100644 (file)
@@ -148,7 +148,8 @@ get_memsize(void)
 
     sz = (uint64_t)hvm_info->low_mem_pgend << PAGE_SHIFT;
     if ( hvm_info->high_mem_pgend )
-        sz += (hvm_info->high_mem_pgend << PAGE_SHIFT) - (1ull << 32);
+        sz += (((uint64_t)hvm_info->high_mem_pgend << PAGE_SHIFT)
+               - (1ull << 32));
 
     /*
      * Round up to the nearest MB.  The user specifies domU pseudo-physical 
index b9b7d642dd003186a0d7daad7d4d66a9fd2c7359..bdd1cc012f42c42c6617894c91d0531388bd6736 100644 (file)
@@ -16,6 +16,7 @@ XEN_SCRIPTS += network-route vif-route
 XEN_SCRIPTS += network-nat vif-nat
 XEN_SCRIPTS += block
 XEN_SCRIPTS += block-enbd block-nbd
+XEN_SCRIPTS += blktap
 XEN_SCRIPTS += vtpm vtpm-delete
 XEN_SCRIPTS += xen-hotplug-cleanup
 XEN_SCRIPTS += external-device-migrate
index af0e2316fad652f58ca63c19a8835ad5c7911e47..fe21fc1357ead3f8dfe5c06f1e39cf99490ed044 100644 (file)
@@ -1,3 +1,4 @@
+SUBSYSTEM=="xen-backend", KERNEL=="tap*", RUN+="/etc/xen/scripts/blktap $env{ACTION}"
 SUBSYSTEM=="xen-backend", KERNEL=="vbd*", RUN+="/etc/xen/scripts/block $env{ACTION}"
 SUBSYSTEM=="xen-backend", KERNEL=="vtpm*", RUN+="/etc/xen/scripts/vtpm $env{ACTION}"
 SUBSYSTEM=="xen-backend", KERNEL=="vif*", ACTION=="online", RUN+="$env{script} online"
index 0e4e6aeeaff92a098e4c5c200268f89b18957943..f398632c98cdf756d165e17d56a72ffd1b9301b6 100644 (file)
@@ -297,8 +297,7 @@ uberblock_verify(uberblock_phys_t *ub, int offset)
        if (zio_checksum_verify(&bp, (char *)ub, UBERBLOCK_SIZE) != 0)
                return (-1);
 
-       if (uber->ub_magic == UBERBLOCK_MAGIC &&
-           uber->ub_version > 0 && uber->ub_version <= SPA_VERSION)
+       if (uber->ub_magic == UBERBLOCK_MAGIC && uber->ub_version > 0)
                return (0);
 
        return (-1);
@@ -761,8 +760,6 @@ dnode_get_path(fsi_file_t *ffi, dnode_phys_t *mdn, char *path,
 
        if ((errnum = zap_lookup(ffi, dn, ZPL_VERSION_STR, &version, stack)))
                return (errnum);
-       if (version > ZPL_VERSION)
-               return (-1);
 
        if ((errnum = zap_lookup(ffi, dn, ZFS_ROOT_OBJ, &objnum, stack)))
                return (errnum);
index 9ddc4814e00e8651a773eab1be32d21791c93ff2..8d1cf8ea33b5316ebbacd7da5f74a0b8e6e5fba9 100644 (file)
@@ -17,7 +17,7 @@
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 /*
- * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
@@ -28,8 +28,11 @@ typedef struct objset_phys {
        dnode_phys_t os_meta_dnode;
        zil_header_t os_zil_header;
        uint64_t os_type;
-       char os_pad[1024 - sizeof (dnode_phys_t) - sizeof (zil_header_t) -
-           sizeof (uint64_t)];
+       uint64_t os_flags;
+       char os_pad[2048 - sizeof (dnode_phys_t)*3 -
+           sizeof (zil_header_t) - sizeof (uint64_t)*2];
+       dnode_phys_t os_userused_dnode;
+       dnode_phys_t os_groupused_dnode;
 } objset_phys_t;
 
 #endif /* _SYS_DMU_OBJSET_H */
index 3fd679e458b1ef9ccbcdfef681f85c51e3b85e03..5b1463fc4358aacfc6dea78df80a3d7f843d671f 100644 (file)
@@ -17,7 +17,7 @@
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 /*
- * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
@@ -28,7 +28,7 @@
 /*
  * On-disk version number.
  */
-#define        SPA_VERSION                     14ULL
+#define        SPA_VERSION                     16ULL
 
 /*
  * The following are configuration names used in the nvlist describing a pool's
index cd18e71b54887690da5eb3c8976c39da2673d9be..199b3a605e608d4eda3abda649b165de2fdc01c7 100644 (file)
@@ -17,7 +17,7 @@
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 /*
- * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
@@ -28,7 +28,7 @@
 #define        ZFS_ROOT_OBJ            "ROOT"
 #define        ZPL_VERSION_STR         "VERSION"
 
-#define        ZPL_VERSION             3ULL
+#define        ZPL_VERSION             4ULL
 
 #define        ZFS_DIRENT_OBJ(de) BF64_GET(de, 0, 48)
 
index 3efc43d57fdaa0e89c7999e7db152380f705c115..c2c02824ce60a6a9742c3b4be1a64e28c3c91b7e 100644 (file)
@@ -1,6 +1,19 @@
 import fcntl
 import os
 
+def close_fds(pass_fds=()):
+    try:
+        MAXFD = os.sysconf('SC_OPEN_MAX')
+    except:
+        MAXFD = 256
+    for i in range(3, MAXFD):
+        if i in pass_fds:
+            continue
+        try:
+            os.close(i)
+        except OSError:
+            pass
+
 def fcntl_setfd_cloexec(file, bool):
         f = fcntl.fcntl(file, fcntl.F_GETFD)
         if bool: f |= fcntl.FD_CLOEXEC
index b0c880fafe34be140e45fb9f856419ecd73e06a1..66c2d9a5d892bec9c6e2eeb514c7106de35fd7d8 100644 (file)
@@ -85,7 +85,7 @@ class xPopen3:
 
     sts = -1                    # Child not completed yet
 
-    def __init__(self, cmd, capturestderr=False, bufsize=-1, passfd=()):
+    def __init__(self, cmd, capturestderr=False, bufsize=-1, passfd=(), env=None):
         """The parameter 'cmd' is the shell command to execute in a
         sub-process.  The 'capturestderr' flag, if true, specifies that
         the object should capture standard error output of the child process.
@@ -128,6 +128,10 @@ class xPopen3:
                 pass
         try:
             os.execvp(cmd[0], cmd)
+            if env is None:
+                os.execvp(cmd[0], cmd)
+            else:
+                os.execvpe(cmd[0], cmd, env)
         finally:
             os._exit(127)
 
@@ -154,16 +158,26 @@ class xPopen3:
         return self.sts
 
 
-def xpopen2(cmd, bufsize=-1, mode='t', passfd=[]):
+def xpopen2(cmd, bufsize=-1, mode='t', passfd=[], env=None):
     """Execute the shell command 'cmd' in a sub-process.  If 'bufsize' is
     specified, it sets the buffer size for the I/O pipes.  The file objects
     (child_stdout, child_stdin) are returned."""
-    inst = xPopen3(cmd, False, bufsize, passfd)
+    inst = xPopen3(cmd, False, bufsize, passfd, env)
     return inst.fromchild, inst.tochild
 
-def xpopen3(cmd, bufsize=-1, mode='t', passfd=[]):
+def xpopen3(cmd, bufsize=-1, mode='t', passfd=[], env=None):
     """Execute the shell command 'cmd' in a sub-process.  If 'bufsize' is
     specified, it sets the buffer size for the I/O pipes.  The file objects
     (child_stdout, child_stdin, child_stderr) are returned."""
-    inst = xPopen3(cmd, True, bufsize, passfd)
+    inst = xPopen3(cmd, True, bufsize, passfd, env)
     return inst.fromchild, inst.tochild, inst.childerr
+
+def call(*popenargs, **kwargs):
+    """Run command with arguments.  Wait for command to complete, then
+    return the status.
+
+    The arguments are the same as for the xPopen3 constructor.  Example:
+
+    status = call("ls -l")
+    """
+    return xPopen3(*popenargs, **kwargs).wait()
index c1efdfac0db7fb9f321a8afe013d980ddf5b15b9..8c8e99ba947e44f132a3ef077d7a86f982e3e11f 100644 (file)
@@ -31,7 +31,7 @@ from xen.xend import XendConstants
 from xen.xend import XendOptions
 from xen.xend.XendLogging import log
 from xen.xend.XendError import VmError
-from xen.util import dictio, xsconstants
+from xen.util import dictio, xsconstants, xpopen
 from xen.xend.XendConstants import *
 
 #global directories and tools for security management
@@ -1710,7 +1710,7 @@ def run_resource_label_change_script(resource, label, command):
                 log.info("Running resource label change script %s: %s" %
                          (script, parms))
                 parms.update(os.environ)
-                os.spawnve(os.P_WAIT, script[0], script, parms)
+                xpopen.call(" ".join(script, params))
         else:
             log.info("No script given for relabeling of resources.")
     if not __script_runner:
index ba2105098cd57792d637eb028956e32d76571a03..58d4ae7c1e164f8203b9a56f6aed410127765001 100644 (file)
 
 """Xend interface to networking control scripts.
 """
-import os
 
 import XendOptions
-
+from xen.util import xpopen
 
 def network(op):
     """Call a network control script.
@@ -33,4 +32,4 @@ def network(op):
     script = XendOptions.instance().get_network_script()
     if script:
         script.insert(1, op)
-        os.spawnv(os.P_WAIT, script[0], script)
+        xpopen.call(script)
index d2e5761fa2e384ceb0f96bc282d3661bb1ac1428..74c9a2ac196a8110a32d0331a91bb90dd9ac4822 100644 (file)
@@ -17,7 +17,7 @@ import random
 import shlex
 from xen.xend import sxp
 
-from xen.util import mkdir
+from xen.util import mkdir, oshelp
 from XendLogging import log
 from XendError import VmError
 
@@ -113,6 +113,7 @@ def bootloader(blexec, disk, dom, quiet = False, blargs = '', kernel = '',
             log.debug("Launching bootloader as %s." % str(args))
             env = os.environ.copy()
             env['TERM'] = 'vt100'
+            oshelp.close_fds()
             os.execvpe(args[0], args, env)
         except OSError, e:
             print e
index a0ea01166575da97a6409be87c488cff64bc126f..a0bb5df79a9b4e667d5070f0896964611cf50392 100644 (file)
@@ -315,8 +315,8 @@ def restore(xd, fd, dominfo = None, paused = False, relocating = False):
                 else:
                     break
             os.close(qemu_fd)
-            restore_image.setCpuid()
 
+        restore_image.setCpuid()
 
         os.read(fd, 1)           # Wait for source to close connection
         
index 411936d5d69136b7ab7bdb532a606467f84678a9..bcca28742acf7cd5940c881d30eddde10d253e05 100644 (file)
@@ -423,9 +423,7 @@ class ImageHandler:
                 os.dup2(null, 0)
                 os.dup2(logfd, 1)
                 os.dup2(logfd, 2)
-                os.close(null)
-                os.close(logfd)
-                self.sentinel_fifo.close()
+                oshelp.close_fds((sentinel_write.fileno(),))
                 try:
                     os.execve(self.device_model, args, env)
                 except Exception, e:
index b4dd12fc6787fe3a548ebda6f36ca1d1ef76aa1e..a2759de15e2d81fcf3a4ab7892bec3c0acc881e1 100644 (file)
@@ -2,7 +2,7 @@
 # All other places this is stored (eg. compile.h) should be autogenerated.
 export XEN_VERSION       = 3
 export XEN_SUBVERSION    = 4
-export XEN_EXTRAVERSION ?= .1-rc7$(XEN_VENDORVERSION)
+export XEN_EXTRAVERSION ?= .1$(XEN_VENDORVERSION)
 export XEN_FULLVERSION   = $(XEN_VERSION).$(XEN_SUBVERSION)$(XEN_EXTRAVERSION)
 -include xen-version
 
index 4bab13973b655e9acb6674a63318e2fb39e6a86b..12f6d2a3766d7458e2a4ab133e6a51b8d0b6a689 100644 (file)
@@ -184,10 +184,12 @@ static int acpi_idle_bm_check(void)
     return bm_status;
 }
 
+#if 0
 static struct {
     spinlock_t lock;
     unsigned int count;
 } c3_cpu_status = { .lock = SPIN_LOCK_UNLOCKED };
+#endif
 
 static void acpi_processor_idle(void)
 {
@@ -282,6 +284,7 @@ static void acpi_processor_idle(void)
          */
         if ( power->flags.bm_check && power->flags.bm_control )
         {
+#if 0
             spin_lock(&c3_cpu_status.lock);
             if ( ++c3_cpu_status.count == num_online_cpus() )
             {
@@ -292,6 +295,7 @@ static void acpi_processor_idle(void)
                 acpi_set_register(ACPI_BITREG_ARB_DISABLE, 1);
             }
             spin_unlock(&c3_cpu_status.lock);
+#endif
         }
         else if ( !power->flags.bm_check )
         {
@@ -323,11 +327,13 @@ static void acpi_processor_idle(void)
 
         if ( power->flags.bm_check && power->flags.bm_control )
         {
+#if 0
             /* Enable bus master arbitration */
             spin_lock(&c3_cpu_status.lock);
             if ( c3_cpu_status.count-- == num_online_cpus() )
                 acpi_set_register(ACPI_BITREG_ARB_DISABLE, 0);
             spin_unlock(&c3_cpu_status.lock);
+#endif
         }
 
         /* Re-enable interrupts */
@@ -413,6 +419,7 @@ static int init_cx_pminfo(struct acpi_processor_power *acpi_power)
     acpi_power->states[ACPI_STATE_C1].valid = 1;
 
     acpi_power->count = 2;
+    acpi_power->safe_state = &acpi_power->states[ACPI_STATE_C1];
 
     return 0;
 }
index 98684d499ae3117aec5f3a0675bb5ce6fca85c77..a5c80dc813647740c41dcf218620c50ea5c87073 100644 (file)
@@ -599,13 +599,13 @@ static int vlapic_write(struct vcpu *v, unsigned long address,
     val = (uint32_t)val;
     if ( len != 4 )
     {
-        unsigned long tmp;
+        unsigned int tmp;
         unsigned char alignment;
 
         gdprintk(XENLOG_INFO, "Notice: Local APIC write with len = %lx\n",len);
 
         alignment = offset & 0x3;
-        (void)vlapic_read(v, offset & ~0x3, 4, &tmp);
+        (void)vlapic_read_aligned(vlapic, offset & ~0x3, &tmp);
 
         switch ( len )
         {
index 23649a3cbc4fa311be5e986ce56e04820e25d7bb..6845b02903dd3c9f3e2e9bad256154ae637cfea9 100644 (file)
@@ -176,20 +176,14 @@ static enum handler_return long_mode_do_msr_read(struct cpu_user_regs *regs)
 
     case MSR_FS_BASE:
         msr_content = __vmread(GUEST_FS_BASE);
-        goto check_long_mode;
+        break;
 
     case MSR_GS_BASE:
         msr_content = __vmread(GUEST_GS_BASE);
-        goto check_long_mode;
+        break;
 
     case MSR_SHADOW_GS_BASE:
-        msr_content = v->arch.hvm_vmx.shadow_gs;
-    check_long_mode:
-        if ( !(hvm_long_mode_enabled(v)) )
-        {
-            vmx_inject_hw_exception(TRAP_gp_fault, 0);
-            return HNDL_exception_raised;
-        }
+        rdmsrl(MSR_SHADOW_GS_BASE, msr_content);
         break;
 
     case MSR_STAR:
@@ -240,9 +234,6 @@ static enum handler_return long_mode_do_msr_write(struct cpu_user_regs *regs)
     case MSR_FS_BASE:
     case MSR_GS_BASE:
     case MSR_SHADOW_GS_BASE:
-        if ( !hvm_long_mode_enabled(v) )
-            goto gp_fault;
-
         if ( !is_canonical_address(msr_content) )
             goto uncanonical_address;
 
@@ -251,10 +242,7 @@ static enum handler_return long_mode_do_msr_write(struct cpu_user_regs *regs)
         else if ( ecx == MSR_GS_BASE )
             __vmwrite(GUEST_GS_BASE, msr_content);
         else
-        {
-            v->arch.hvm_vmx.shadow_gs = msr_content;
             wrmsrl(MSR_SHADOW_GS_BASE, msr_content);
-        }
 
         break;
 
@@ -283,7 +271,6 @@ static enum handler_return long_mode_do_msr_write(struct cpu_user_regs *regs)
 
  uncanonical_address:
     HVM_DBG_LOG(DBG_LEVEL_0, "Not cano address of msr write %x", ecx);
- gp_fault:
     vmx_inject_hw_exception(TRAP_gp_fault, 0);
  exception_raised:
     return HNDL_exception_raised;
@@ -310,7 +297,10 @@ static void vmx_restore_host_msrs(void)
 
 static void vmx_save_guest_msrs(struct vcpu *v)
 {
-    /* MSR_SHADOW_GS_BASE may have been changed by swapgs instruction. */
+    /*
+     * We cannot cache SHADOW_GS_BASE while the VCPU runs, as it can
+     * be updated at any time via SWAPGS, which we cannot trap.
+     */
     rdmsrl(MSR_SHADOW_GS_BASE, v->arch.hvm_vmx.shadow_gs);
 }
 
index 32fe02efc48e821ec6c2a067f1fe4017d6366517..0d6d5eefca9f1bd9dd1bbcb3add626df58347568 100644 (file)
@@ -1145,10 +1145,9 @@ static int alloc_l1_table(struct page_info *page)
 static int create_pae_xen_mappings(struct domain *d, l3_pgentry_t *pl3e)
 {
     struct page_info *page;
-    l2_pgentry_t    *pl2e;
     l3_pgentry_t     l3e3;
-#ifndef CONFIG_COMPAT
-    l2_pgentry_t     l2e;
+#ifdef __i386__
+    l2_pgentry_t     *pl2e, l2e;
     int              i;
 #endif
 
@@ -1184,19 +1183,9 @@ static int create_pae_xen_mappings(struct domain *d, l3_pgentry_t *pl3e)
         return 0;
     }
 
-    /* Xen private mappings. */
+#ifdef __i386__
+    /* Xen linear pagetable mappings. */
     pl2e = map_domain_page(l3e_get_pfn(l3e3));
-#ifndef CONFIG_COMPAT
-    memcpy(&pl2e[L2_PAGETABLE_FIRST_XEN_SLOT & (L2_PAGETABLE_ENTRIES-1)],
-           &idle_pg_table_l2[L2_PAGETABLE_FIRST_XEN_SLOT],
-           L2_PAGETABLE_XEN_SLOTS * sizeof(l2_pgentry_t));
-    for ( i = 0; i < PDPT_L2_ENTRIES; i++ )
-    {
-        l2e = l2e_from_page(
-            virt_to_page(d->arch.mm_perdomain_pt) + i,
-            __PAGE_HYPERVISOR);
-        l2e_write(&pl2e[l2_table_offset(PERDOMAIN_VIRT_START) + i], l2e);
-    }
     for ( i = 0; i < (LINEARPT_MBYTES >> (L2_PAGETABLE_SHIFT - 20)); i++ )
     {
         l2e = l2e_empty();
@@ -1204,13 +1193,8 @@ static int create_pae_xen_mappings(struct domain *d, l3_pgentry_t *pl3e)
             l2e = l2e_from_pfn(l3e_get_pfn(pl3e[i]), __PAGE_HYPERVISOR);
         l2e_write(&pl2e[l2_table_offset(LINEAR_PT_VIRT_START) + i], l2e);
     }
-#else
-    memcpy(&pl2e[COMPAT_L2_PAGETABLE_FIRST_XEN_SLOT(d)],
-           &compat_idle_pg_table_l2[
-               l2_table_offset(HIRO_COMPAT_MPT_VIRT_START)],
-           COMPAT_L2_PAGETABLE_XEN_SLOTS(d) * sizeof(*pl2e));
-#endif
     unmap_domain_page(pl2e);
+#endif
 
     return 1;
 }
@@ -1303,6 +1287,27 @@ static int alloc_l2_table(struct page_info *page, unsigned long type,
         adjust_guest_l2e(pl2e[i], d);
     }
 
+    if ( rc >= 0 && (type & PGT_pae_xen_l2) )
+    {
+        /* Xen private mappings. */
+#if defined(__i386__)
+        memcpy(&pl2e[L2_PAGETABLE_FIRST_XEN_SLOT & (L2_PAGETABLE_ENTRIES-1)],
+               &idle_pg_table_l2[L2_PAGETABLE_FIRST_XEN_SLOT],
+               L2_PAGETABLE_XEN_SLOTS * sizeof(l2_pgentry_t));
+        for ( i = 0; i < PDPT_L2_ENTRIES; i++ )
+            l2e_write(&pl2e[l2_table_offset(PERDOMAIN_VIRT_START) + i],
+                      l2e_from_page(virt_to_page(d->arch.mm_perdomain_pt) + i,
+                                    __PAGE_HYPERVISOR));
+        pl2e[l2_table_offset(LINEAR_PT_VIRT_START)] =
+            l2e_from_pfn(pfn, __PAGE_HYPERVISOR);
+#elif defined(CONFIG_COMPAT)
+        memcpy(&pl2e[COMPAT_L2_PAGETABLE_FIRST_XEN_SLOT(d)],
+               &compat_idle_pg_table_l2[
+                   l2_table_offset(HIRO_COMPAT_MPT_VIRT_START)],
+               COMPAT_L2_PAGETABLE_XEN_SLOTS(d) * sizeof(*pl2e));
+#endif
+    }
+
     unmap_domain_page(pl2e);
     return rc > 0 ? 0 : rc;
 }
index 25311321879cb058906cf7224d8161dbbaa0adda..40172486f5ecc767a9bad5567b19b78f06f5b33b 100644 (file)
@@ -36,15 +36,16 @@ static void ept_p2m_type_to_flags(ept_entry_t *entry, p2m_type_t type)
         case p2m_invalid:
         case p2m_mmio_dm:
         default:
+            entry->r = entry->w = entry->x = 0;
             return;
         case p2m_ram_rw:
         case p2m_mmio_direct:
-             entry->r = entry->w = entry->x = 1;
+            entry->r = entry->w = entry->x = 1;
             return;
         case p2m_ram_logdirty:
         case p2m_ram_ro:
-             entry->r = entry->x = 1;
-             entry->w = 0;
+            entry->r = entry->x = 1;
+            entry->w = 0;
             return;
     }
 }
@@ -194,7 +195,6 @@ ept_set_entry(struct domain *d, unsigned long gfn, mfn_t mfn,
             ept_entry->rsvd = 0;
             ept_entry->avail2 = 0;
             /* last step */
-            ept_entry->r = ept_entry->w = ept_entry->x = 1;
             ept_p2m_type_to_flags(ept_entry, p2mt);
         }
         else
@@ -240,7 +240,6 @@ ept_set_entry(struct domain *d, unsigned long gfn, mfn_t mfn,
             split_ept_entry->rsvd = 0;
             split_ept_entry->avail2 = 0;
             /* last step */
-            split_ept_entry->r = split_ept_entry->w = split_ept_entry->x = 1;
             ept_p2m_type_to_flags(split_ept_entry, split_p2mt);
         }
 
index 0b134a3c109f7fe1fb94a8f8324fe76b7270577a..3eab9cad29a835df6af37b67b8c7c61737577b69 100644 (file)
@@ -1648,7 +1648,7 @@ static int is_cpufreq_controller(struct domain *d)
 static int emulate_privileged_op(struct cpu_user_regs *regs)
 {
     struct vcpu *v = current;
-    unsigned long *reg, eip = regs->eip, res;
+    unsigned long *reg, eip = regs->eip;
     u8 opcode, modrm_reg = 0, modrm_rm = 0, rep_prefix = 0, lock = 0, rex = 0;
     enum { lm_seg_none, lm_seg_fs, lm_seg_gs } lm_ovr = lm_seg_none;
     unsigned int port, i, data_sel, ar, data, rc, bpmatch = 0;
@@ -1666,7 +1666,7 @@ static int emulate_privileged_op(struct cpu_user_regs *regs)
     unsigned long code_base, code_limit;
     char io_emul_stub[32];
     void (*io_emul)(struct cpu_user_regs *) __attribute__((__regparm__(1)));
-    u32 l, h, eax, edx;
+    u32 l, h;
 
     if ( !read_descriptor(regs->cs, v, regs,
                           &code_base, &code_limit, &ar,
@@ -2045,7 +2045,8 @@ static int emulate_privileged_op(struct cpu_user_regs *regs)
         }
         break;
 
-    case 0x21: /* MOV DR?,<reg> */
+    case 0x21: /* MOV DR?,<reg> */ {
+        unsigned long res;
         opcode = insn_fetch(u8, code_base, eip, code_limit);
         if ( opcode < 0xc0 )
             goto fail;
@@ -2056,6 +2057,7 @@ static int emulate_privileged_op(struct cpu_user_regs *regs)
             goto fail;
         *reg = res;
         break;
+    }
 
     case 0x22: /* MOV <reg>,CR? */
         opcode = insn_fetch(u8, code_base, eip, code_limit);
@@ -2116,10 +2118,10 @@ static int emulate_privileged_op(struct cpu_user_regs *regs)
             goto fail;
         break;
 
-    case 0x30: /* WRMSR */
-        eax = regs->eax;
-        edx = regs->edx;
-        res = ((u64)edx << 32) | eax;
+    case 0x30: /* WRMSR */ {
+        u32 eax = regs->eax;
+        u32 edx = regs->edx;
+        u64 val = ((u64)edx << 32) | eax;
         switch ( (u32)regs->ecx )
         {
 #ifdef CONFIG_X86_64
@@ -2128,21 +2130,21 @@ static int emulate_privileged_op(struct cpu_user_regs *regs)
                 goto fail;
             if ( wrmsr_safe(MSR_FS_BASE, eax, edx) )
                 goto fail;
-            v->arch.guest_context.fs_base = res;
+            v->arch.guest_context.fs_base = val;
             break;
         case MSR_GS_BASE:
             if ( is_pv_32on64_vcpu(v) )
                 goto fail;
             if ( wrmsr_safe(MSR_GS_BASE, eax, edx) )
                 goto fail;
-            v->arch.guest_context.gs_base_kernel = res;
+            v->arch.guest_context.gs_base_kernel = val;
             break;
         case MSR_SHADOW_GS_BASE:
             if ( is_pv_32on64_vcpu(v) )
                 goto fail;
             if ( wrmsr_safe(MSR_SHADOW_GS_BASE, eax, edx) )
                 goto fail;
-            v->arch.guest_context.gs_base_user = res;
+            v->arch.guest_context.gs_base_user = val;
             break;
 #endif
         case MSR_K7_FID_VID_STATUS:
@@ -2185,7 +2187,7 @@ static int emulate_privileged_op(struct cpu_user_regs *regs)
             if ( !IS_PRIV(v->domain) )
                 break;
             if ( (rdmsr_safe(MSR_FAM10H_MMIO_CONF_BASE, l, h) != 0) ||
-                 (((((u64)h << 32) | l) ^ res) &
+                 (((((u64)h << 32) | l) ^ val) &
                   ~((1 << FAM10H_MMIO_CONF_ENABLE_BIT) |
                     (FAM10H_MMIO_CONF_BUSRANGE_MASK <<
                      FAM10H_MMIO_CONF_BUSRANGE_SHIFT) |
@@ -2218,7 +2220,7 @@ static int emulate_privileged_op(struct cpu_user_regs *regs)
                 break;
             if ( boot_cpu_data.x86_vendor == X86_VENDOR_INTEL )
             {
-                int rc = intel_mce_wrmsr(regs->ecx, res);
+                int rc = intel_mce_wrmsr(regs->ecx, val);
                 if ( rc < 0 )
                     goto fail;
                 if ( rc )
@@ -2234,6 +2236,7 @@ static int emulate_privileged_op(struct cpu_user_regs *regs)
             break;
         }
         break;
+    }
 
     case 0x31: /* RDTSC */
         rdtsc(regs->eax, regs->edx);
index 6dec66f5033a8bee8c284fd53c61d71a33d06c92..849d35a42220d816d3e909c7dd98dc08f642674e 100644 (file)
@@ -42,7 +42,7 @@
 #define O  OPCODE_BYTE
 #define M  HAS_MODRM
 
-static const unsigned char insn_decode[256] = {
+static const u8 insn_decode[256] = {
     /* 0x00 - 0x0F */
     O|M, O|M, O|M, O|M, X, X, X, X,
     O|M, O|M, O|M, O|M, X, X, X, X,
@@ -93,7 +93,18 @@ static const unsigned char insn_decode[256] = {
     X, X, X, X, X, X, O|M, O|M
 };
 
-static const unsigned char twobyte_decode[256] = {
+static const u8 float_decode[64] = {
+    O|M, O|M, O|M, O|M, O|M, O|M, O|M, O|M, /* 0xD8 */
+    O|M, X, O|M, O|M, O|M, O|M, O|M, O|M, /* 0xD9 */
+    O|M, O|M, O|M, O|M, O|M, O|M, O|M, O|M, /* 0xDA */
+    O|M, X, O|M, O|M, X, O|M, X, O|M, /* 0xDB */
+    O|M, O|M, O|M, O|M, O|M, O|M, O|M, O|M, /* 0xDC */
+    O|M, O|M, O|M, O|M, O|M, X, O|M, O|M, /* 0xDD */
+    O|M, O|M, O|M, O|M, O|M, O|M, O|M, O|M, /* 0xDE */
+    O|M, X, O|M, O|M, O|M, O|M, O|M, O|M, /* 0xDF */
+};
+
+static const u8 twobyte_decode[256] = {
     /* 0x00 - 0x0F */
     X, X, X, X, X, X, X, X,
     X, X, X, X, X, X, X, X,
@@ -321,7 +332,8 @@ int gpf_emulate_4gb(struct cpu_user_regs *regs)
     s32            disp32 = 0;
     u8            *eip;         /* ptr to instruction start */
     u8            *pb, b;       /* ptr into instr. / current instr. byte */
-    int            gs_override = 0, scale = 0, twobyte = 0;
+    int            gs_override = 0, scale = 0, opcode = -1;
+    const u8      *table = insn_decode;
 
     /* WARNING: We only work for ring-3 segments. */
     if ( unlikely(vm86_mode(regs)) || unlikely(!ring_3(regs)) )
@@ -352,8 +364,11 @@ int gpf_emulate_4gb(struct cpu_user_regs *regs)
             goto fail;
         }
 
-        if ( twobyte )
+        if ( opcode != -1 )
+        {
+            opcode = (opcode << 8) | b;
             break;
+        }
 
         switch ( b )
         {
@@ -374,8 +389,29 @@ int gpf_emulate_4gb(struct cpu_user_regs *regs)
             gs_override = 1;
             break;
         case 0x0f: /* Not really a prefix byte */
-            twobyte = 1;
+            table = twobyte_decode;
+            opcode = b;
             break;
+        case 0xd8: /* Math coprocessor instructions.  */
+        case 0xd9:
+        case 0xda:
+        case 0xdb:
+        case 0xdc:
+        case 0xdd:
+        case 0xde:
+        case 0xdf:
+            /* Float opcodes have a secondary opcode in the modrm byte.  */
+            table = float_decode;
+            if ( get_user(modrm, pb + 1) )
+            {
+                dprintk(XENLOG_DEBUG, "Fault while extracting modrm byte\n");
+                goto page_fault;
+            }
+
+            opcode = (b << 8) | modrm;
+            b = ((b & 7) << 3) + ((modrm >> 3) & 7);
+            goto done_prefix;
+
         default: /* Not a prefix byte */
             goto done_prefix;
         }
@@ -388,13 +424,16 @@ int gpf_emulate_4gb(struct cpu_user_regs *regs)
         goto fail;
     }
 
-    decode = (!twobyte ? insn_decode : twobyte_decode)[b];
+    decode = table[b];
     pb++;
 
     if ( !(decode & OPCODE_BYTE) )
     {
-        dprintk(XENLOG_DEBUG, "Unsupported %sopcode %02x\n",
-                twobyte ? "two byte " : "", b);
+        if (opcode == -1)
+            dprintk(XENLOG_DEBUG, "Unsupported opcode %02x\n", b);
+        else
+            dprintk(XENLOG_DEBUG, "Unsupported opcode %02x %02x\n",
+                    opcode >> 8, opcode & 255);
         goto fail;
     }
 
index 4417c30f0ebc6470f83f833210f410d4544c71b6..b6ac8d51301b1d44456dfe2ae612c7c5dc15370a 100644 (file)
 
 #include "../xen.h"
 
-/* if ACM_DEBUG defined, all hooks should
- * print a short trace message (comment it out
- * when not in testing mode )
- */
-/* #define ACM_DEBUG */
-
-#ifdef ACM_DEBUG
-#  define printkd(fmt, args...) printk(fmt,## args)
-#else
-#  define printkd(fmt, args...)
-#endif
-
 /* default ssid reference value if not supplied */
 #define ACM_DEFAULT_SSID  0x0
 #define ACM_DEFAULT_LOCAL_SSID  0x0
index 19e37f9e2eee3bf85690581aa7204ad7105fe035..67bd49f570c4fc198aeaae3aedb75eb449205a93 100644 (file)
@@ -130,11 +130,22 @@ extern struct acm_operations *acm_secondary_ops;
 /* #define ACM_TRACE_MODE */
 
 #ifdef ACM_TRACE_MODE
-# define traceprintk(fmt, args...) printk(fmt,## args)
+# define traceprintk(fmt, args...) printk(fmt, ## args)
 #else
 # define traceprintk(fmt, args...)
 #endif
 
+/* if ACM_DEBUG defined, all hooks should
+ * print a short trace message (comment it out
+ * when not in testing mode )
+ */
+/* #define ACM_DEBUG */
+
+#ifdef ACM_DEBUG
+#  define printkd(fmt, args...) printk(fmt, ## args)
+#else
+#  define printkd(fmt, args...)
+#endif
 
 #ifndef ACM_SECURITY
 
index 3133877cf4063594693237f4e026bd3e7a969b2a..b8b7b4f59cb84f7e7405ff046fb8423e4c3e32b9 100644 (file)
@@ -38,7 +38,7 @@
  *   define/undefine this constant to receive / suppress any
  *   security hook debug output of sHype
  *
- *   include/public/xsm/acm.h defines a constant ACM_DEBUG
+ *   include/xsm/acm/acm_hooks.h defines a constant ACM_DEBUG
  *   define/undefine this constant to receive non-hook-related
  *   debug output.
  */