From: Jean Guyader Date: Tue, 11 Aug 2009 16:44:03 +0000 (+0100) Subject: Rebase with xen-3.4.1. X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=56685882e1eae36035a1274ad5edda2fe4378d21;p=xenclient%2Fxen.git Rebase with xen-3.4.1. changeset: 19718:13fe7f07df15 tag: tip user: Keir Fraser date: Thu Aug 06 13:27:53 2009 +0100 summary: Added tag RELEASE-3.4.1 for changeset 043043fdb7ab --- diff --git a/Config.mk b/Config.mk index 5d9197d..37392b7 100644 --- 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 diff --git a/stubdom/Makefile b/stubdom/Makefile index fabb690..3f597f2 100644 --- a/stubdom/Makefile +++ b/stubdom/Makefile @@ -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 diff --git a/stubdom/stubdom-dm b/stubdom/stubdom-dm index cb1e22c..9bd4231 100644 --- a/stubdom/stubdom-dm +++ b/stubdom/stubdom-dm @@ -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 diff --git a/tools/firmware/hvmloader/smbios.c b/tools/firmware/hvmloader/smbios.c index 64fa799..a5237cc 100644 --- a/tools/firmware/hvmloader/smbios.c +++ b/tools/firmware/hvmloader/smbios.c @@ -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 diff --git a/tools/hotplug/Linux/Makefile b/tools/hotplug/Linux/Makefile index b9b7d64..bdd1cc0 100644 --- a/tools/hotplug/Linux/Makefile +++ b/tools/hotplug/Linux/Makefile @@ -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 diff --git a/tools/hotplug/Linux/xen-backend.rules b/tools/hotplug/Linux/xen-backend.rules index af0e231..fe21fc1 100644 --- a/tools/hotplug/Linux/xen-backend.rules +++ b/tools/hotplug/Linux/xen-backend.rules @@ -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" diff --git a/tools/libfsimage/zfs/fsys_zfs.c b/tools/libfsimage/zfs/fsys_zfs.c index 0e4e6ae..f398632 100644 --- a/tools/libfsimage/zfs/fsys_zfs.c +++ b/tools/libfsimage/zfs/fsys_zfs.c @@ -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); diff --git a/tools/libfsimage/zfs/zfs-include/dmu_objset.h b/tools/libfsimage/zfs/zfs-include/dmu_objset.h index 9ddc481..8d1cf8e 100644 --- a/tools/libfsimage/zfs/zfs-include/dmu_objset.h +++ b/tools/libfsimage/zfs/zfs-include/dmu_objset.h @@ -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 */ diff --git a/tools/libfsimage/zfs/zfs-include/zfs.h b/tools/libfsimage/zfs/zfs-include/zfs.h index 3fd679e..5b1463f 100644 --- a/tools/libfsimage/zfs/zfs-include/zfs.h +++ b/tools/libfsimage/zfs/zfs-include/zfs.h @@ -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 diff --git a/tools/libfsimage/zfs/zfs-include/zfs_znode.h b/tools/libfsimage/zfs/zfs-include/zfs_znode.h index cd18e71..199b3a6 100644 --- a/tools/libfsimage/zfs/zfs-include/zfs_znode.h +++ b/tools/libfsimage/zfs/zfs-include/zfs_znode.h @@ -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) diff --git a/tools/python/xen/util/oshelp.py b/tools/python/xen/util/oshelp.py index 3efc43d..c2c0282 100644 --- a/tools/python/xen/util/oshelp.py +++ b/tools/python/xen/util/oshelp.py @@ -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 diff --git a/tools/python/xen/util/xpopen.py b/tools/python/xen/util/xpopen.py index b0c880f..66c2d9a 100644 --- a/tools/python/xen/util/xpopen.py +++ b/tools/python/xen/util/xpopen.py @@ -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() diff --git a/tools/python/xen/util/xsm/acm/acm.py b/tools/python/xen/util/xsm/acm/acm.py index c1efdfa..8c8e99b 100644 --- a/tools/python/xen/util/xsm/acm/acm.py +++ b/tools/python/xen/util/xsm/acm/acm.py @@ -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: diff --git a/tools/python/xen/xend/Vifctl.py b/tools/python/xen/xend/Vifctl.py index ba21050..58d4ae7 100644 --- a/tools/python/xen/xend/Vifctl.py +++ b/tools/python/xen/xend/Vifctl.py @@ -18,10 +18,9 @@ """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) diff --git a/tools/python/xen/xend/XendBootloader.py b/tools/python/xen/xend/XendBootloader.py index d2e5761..74c9a2a 100644 --- a/tools/python/xen/xend/XendBootloader.py +++ b/tools/python/xen/xend/XendBootloader.py @@ -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 diff --git a/tools/python/xen/xend/XendCheckpoint.py b/tools/python/xen/xend/XendCheckpoint.py index a0ea011..a0bb5df 100644 --- a/tools/python/xen/xend/XendCheckpoint.py +++ b/tools/python/xen/xend/XendCheckpoint.py @@ -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 diff --git a/tools/python/xen/xend/image.py b/tools/python/xen/xend/image.py index 411936d..bcca287 100644 --- a/tools/python/xen/xend/image.py +++ b/tools/python/xen/xend/image.py @@ -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: diff --git a/xen/Makefile b/xen/Makefile index b4dd12f..a2759de 100644 --- a/xen/Makefile +++ b/xen/Makefile @@ -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 diff --git a/xen/arch/x86/acpi/cpu_idle.c b/xen/arch/x86/acpi/cpu_idle.c index 4bab139..12f6d2a 100644 --- a/xen/arch/x86/acpi/cpu_idle.c +++ b/xen/arch/x86/acpi/cpu_idle.c @@ -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; } diff --git a/xen/arch/x86/hvm/vlapic.c b/xen/arch/x86/hvm/vlapic.c index 98684d4..a5c80dc 100644 --- a/xen/arch/x86/hvm/vlapic.c +++ b/xen/arch/x86/hvm/vlapic.c @@ -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 ) { diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c index 23649a3..6845b02 100644 --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arch/x86/hvm/vmx/vmx.c @@ -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); } diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index 32fe02e..0d6d5ee 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -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; } diff --git a/xen/arch/x86/mm/hap/p2m-ept.c b/xen/arch/x86/mm/hap/p2m-ept.c index 2531132..4017248 100644 --- a/xen/arch/x86/mm/hap/p2m-ept.c +++ b/xen/arch/x86/mm/hap/p2m-ept.c @@ -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); } diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c index 0b134a3..3eab9ca 100644 --- a/xen/arch/x86/traps.c +++ b/xen/arch/x86/traps.c @@ -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?, */ + case 0x21: /* MOV DR?, */ { + 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 ,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); diff --git a/xen/arch/x86/x86_32/seg_fixup.c b/xen/arch/x86/x86_32/seg_fixup.c index 6dec66f..849d35a 100644 --- a/xen/arch/x86/x86_32/seg_fixup.c +++ b/xen/arch/x86/x86_32/seg_fixup.c @@ -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; } diff --git a/xen/include/public/xsm/acm.h b/xen/include/public/xsm/acm.h index 4417c30..b6ac8d5 100644 --- a/xen/include/public/xsm/acm.h +++ b/xen/include/public/xsm/acm.h @@ -28,18 +28,6 @@ #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 diff --git a/xen/include/xsm/acm/acm_hooks.h b/xen/include/xsm/acm/acm_hooks.h index 19e37f9..67bd49f 100644 --- a/xen/include/xsm/acm/acm_hooks.h +++ b/xen/include/xsm/acm/acm_hooks.h @@ -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 diff --git a/xen/xsm/acm/acm_core.c b/xen/xsm/acm/acm_core.c index 3133877..b8b7b4f 100644 --- a/xen/xsm/acm/acm_core.c +++ b/xen/xsm/acm/acm_core.c @@ -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. */