From owner-p4-projects@FreeBSD.ORG Wed Feb 12 04:41:35 2014 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id E419DA53; Wed, 12 Feb 2014 04:41:34 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 75F6BA36 for ; Wed, 12 Feb 2014 04:41:34 +0000 (UTC) Received: from skunkworks.freebsd.org (skunkworks.freebsd.org [IPv6:2001:1900:2254:2068::682:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 5C9AB1371 for ; Wed, 12 Feb 2014 04:41:34 +0000 (UTC) Received: from skunkworks.freebsd.org ([127.0.1.74]) by skunkworks.freebsd.org (8.14.8/8.14.8) with ESMTP id s1C4fY2n027813 for ; Wed, 12 Feb 2014 04:41:34 GMT (envelope-from jhb@freebsd.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.8/8.14.8/Submit) id s1C4fYGx027810 for perforce@freebsd.org; Wed, 12 Feb 2014 04:41:34 GMT (envelope-from jhb@freebsd.org) Date: Wed, 12 Feb 2014 04:41:34 GMT Message-Id: <201402120441.s1C4fYGx027810@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to jhb@freebsd.org using -f From: John Baldwin Subject: PERFORCE change 1190879 for review To: Perforce Change Reviews Precedence: bulk X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.17 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Feb 2014 04:41:35 -0000 http://p4web.freebsd.org/@@1190879?ac=10 Change 1190879 by jhb@jhb_pippin on 2014/02/12 04:41:09 IFC @1190877 Affected files ... .. //depot/projects/pci/sys/amd64/amd64/pmap.c#15 integrate .. //depot/projects/pci/sys/amd64/include/resource.h#6 integrate .. //depot/projects/pci/sys/amd64/vmm/intel/vmx.c#12 integrate .. //depot/projects/pci/sys/amd64/vmm/vmm.c#11 integrate .. //depot/projects/pci/sys/amd64/vmm/vmm_host.c#2 integrate .. //depot/projects/pci/sys/amd64/vmm/vmm_host.h#2 integrate .. //depot/projects/pci/sys/amd64/vmm/vmm_stat.c#5 integrate .. //depot/projects/pci/sys/amd64/vmm/vmm_stat.h#5 integrate .. //depot/projects/pci/sys/amd64/vmm/x86.c#5 integrate .. //depot/projects/pci/sys/arm/arm/elf_trampoline.c#7 integrate .. //depot/projects/pci/sys/arm/arm/locore.S#8 integrate .. //depot/projects/pci/sys/arm/arm/machdep.c#11 integrate .. //depot/projects/pci/sys/arm/arm/mem.c#3 integrate .. //depot/projects/pci/sys/arm/arm/mp_machdep.c#6 integrate .. //depot/projects/pci/sys/arm/arm/physmem.c#1 branch .. //depot/projects/pci/sys/arm/arm/pmap-v6.c#9 integrate .. //depot/projects/pci/sys/arm/arm/pmap.c#10 integrate .. //depot/projects/pci/sys/arm/arm/support.S#4 integrate .. //depot/projects/pci/sys/arm/arm/vfp.c#7 integrate .. //depot/projects/pci/sys/arm/arm/vm_machdep.c#9 integrate .. //depot/projects/pci/sys/arm/at91/at91_machdep.c#7 integrate .. //depot/projects/pci/sys/arm/at91/at91_mci.c#6 integrate .. //depot/projects/pci/sys/arm/at91/at91_pio.c#5 integrate .. //depot/projects/pci/sys/arm/at91/at91_pit.c#3 integrate .. //depot/projects/pci/sys/arm/at91/at91_pmc.c#5 integrate .. //depot/projects/pci/sys/arm/at91/at91_rst.c#3 integrate .. //depot/projects/pci/sys/arm/at91/at91_spi.c#4 integrate .. //depot/projects/pci/sys/arm/at91/at91_twi.c#4 integrate .. //depot/projects/pci/sys/arm/at91/at91_wdt.c#4 integrate .. //depot/projects/pci/sys/arm/at91/board_tsc4370.c#3 integrate .. //depot/projects/pci/sys/arm/at91/if_ate.c#6 integrate .. //depot/projects/pci/sys/arm/at91/uart_dev_at91usart.c#8 integrate .. //depot/projects/pci/sys/arm/conf/AC100#5 integrate .. //depot/projects/pci/sys/arm/conf/ARMADAXP#6 integrate .. //depot/projects/pci/sys/arm/conf/ARNDALE#4 integrate .. //depot/projects/pci/sys/arm/conf/ATMEL#7 integrate .. //depot/projects/pci/sys/arm/conf/AVILA#9 integrate .. //depot/projects/pci/sys/arm/conf/BWCT#7 integrate .. //depot/projects/pci/sys/arm/conf/CAMBRIA#10 integrate .. //depot/projects/pci/sys/arm/conf/CNS11XXNAS#7 integrate .. //depot/projects/pci/sys/arm/conf/CRB#8 integrate .. //depot/projects/pci/sys/arm/conf/CUBIEBOARD#5 integrate .. //depot/projects/pci/sys/arm/conf/CUBIEBOARD2#3 integrate .. //depot/projects/pci/sys/arm/conf/DB-78XXX#7 integrate .. //depot/projects/pci/sys/arm/conf/DB-88F5XXX#7 integrate .. //depot/projects/pci/sys/arm/conf/DB-88F6XXX#7 integrate .. //depot/projects/pci/sys/arm/conf/DIGI-CCWMX53#4 integrate .. //depot/projects/pci/sys/arm/conf/EA3250#4 integrate .. //depot/projects/pci/sys/arm/conf/EB9200#4 integrate .. //depot/projects/pci/sys/arm/conf/EFIKA_MX#4 integrate .. //depot/projects/pci/sys/arm/conf/EP80219#8 integrate .. //depot/projects/pci/sys/arm/conf/ETHERNUT5#4 integrate .. //depot/projects/pci/sys/arm/conf/HL200#7 integrate .. //depot/projects/pci/sys/arm/conf/HL201#8 integrate .. //depot/projects/pci/sys/arm/conf/IMX53-QSB#3 integrate .. //depot/projects/pci/sys/arm/conf/IQ31244#8 integrate .. //depot/projects/pci/sys/arm/conf/KB920X#6 integrate .. //depot/projects/pci/sys/arm/conf/LN2410SBC#6 integrate .. //depot/projects/pci/sys/arm/conf/NSLU#7 integrate .. //depot/projects/pci/sys/arm/conf/PANDABOARD#4 integrate .. //depot/projects/pci/sys/arm/conf/QILA9G20#7 integrate .. //depot/projects/pci/sys/arm/conf/RPI-B#8 integrate .. //depot/projects/pci/sys/arm/conf/SAM9260EK#5 integrate .. //depot/projects/pci/sys/arm/conf/SAM9G20EK#7 integrate .. //depot/projects/pci/sys/arm/conf/SAM9X25EK#5 integrate .. //depot/projects/pci/sys/arm/conf/SHEEVAPLUG#7 integrate .. //depot/projects/pci/sys/arm/conf/SN9G45#5 integrate .. //depot/projects/pci/sys/arm/conf/TS7800#7 integrate .. //depot/projects/pci/sys/arm/conf/VYBRID.common#2 integrate .. //depot/projects/pci/sys/arm/conf/ZEDBOARD#4 integrate .. //depot/projects/pci/sys/arm/econa/econa_machdep.c#5 integrate .. //depot/projects/pci/sys/arm/freescale/vybrid/files.vybrid#3 integrate .. //depot/projects/pci/sys/arm/freescale/vybrid/vf_dmamux.c#1 branch .. //depot/projects/pci/sys/arm/freescale/vybrid/vf_dmamux.h#1 branch .. //depot/projects/pci/sys/arm/freescale/vybrid/vf_edma.c#1 branch .. //depot/projects/pci/sys/arm/freescale/vybrid/vf_edma.h#1 branch .. //depot/projects/pci/sys/arm/include/cpu.h#6 integrate .. //depot/projects/pci/sys/arm/include/machdep.h#5 integrate .. //depot/projects/pci/sys/arm/include/physmem.h#1 branch .. //depot/projects/pci/sys/arm/include/pmap.h#10 integrate .. //depot/projects/pci/sys/arm/include/sf_buf.h#4 integrate .. //depot/projects/pci/sys/arm/include/vmparam.h#9 integrate .. //depot/projects/pci/sys/arm/s3c2xx0/s3c24x0_machdep.c#5 integrate .. //depot/projects/pci/sys/arm/sa11x0/assabet_machdep.c#6 integrate .. //depot/projects/pci/sys/arm/xscale/i80321/ep80219_machdep.c#6 integrate .. //depot/projects/pci/sys/arm/xscale/i80321/iq31244_machdep.c#6 integrate .. //depot/projects/pci/sys/arm/xscale/i8134x/crb_machdep.c#8 integrate .. //depot/projects/pci/sys/arm/xscale/ixp425/avila_machdep.c#6 integrate .. //depot/projects/pci/sys/arm/xscale/pxa/pxa_machdep.c#6 integrate .. //depot/projects/pci/sys/arm/xscale/pxa/std.pxa#3 integrate .. //depot/projects/pci/sys/boot/Makefile.amd64#4 integrate .. //depot/projects/pci/sys/boot/Makefile.i386#3 integrate .. //depot/projects/pci/sys/boot/Makefile.powerpc#4 integrate .. //depot/projects/pci/sys/boot/efi/Makefile.inc#3 integrate .. //depot/projects/pci/sys/boot/fdt/dts/vybrid.dtsi#3 integrate .. //depot/projects/pci/sys/boot/i386/efi/Makefile#4 integrate .. //depot/projects/pci/sys/boot/i386/gptboot/Makefile#7 integrate .. //depot/projects/pci/sys/boot/i386/gptzfsboot/Makefile#6 integrate .. //depot/projects/pci/sys/boot/i386/loader/Makefile#5 integrate .. //depot/projects/pci/sys/boot/i386/zfsboot/Makefile#10 integrate .. //depot/projects/pci/sys/boot/libstand32/Makefile#1 branch .. //depot/projects/pci/sys/boot/powerpc/ofw/Makefile#4 integrate .. //depot/projects/pci/sys/boot/powerpc/ps3/Makefile#7 integrate .. //depot/projects/pci/sys/boot/powerpc/uboot/Makefile#4 integrate .. //depot/projects/pci/sys/cam/ctl/ctl_backend_block.c#7 integrate .. //depot/projects/pci/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c#11 integrate .. //depot/projects/pci/sys/conf/NOTES#18 integrate .. //depot/projects/pci/sys/conf/files#21 integrate .. //depot/projects/pci/sys/conf/files.arm#10 integrate .. //depot/projects/pci/sys/conf/files.i386#16 integrate .. //depot/projects/pci/sys/conf/options.arm#9 integrate .. //depot/projects/pci/sys/dev/acpica/acpi_pcib_acpi.c#36 integrate .. //depot/projects/pci/sys/dev/acpica/acpi_pcib_pci.c#7 integrate .. //depot/projects/pci/sys/dev/bvm/bvm_console.c#2 integrate .. //depot/projects/pci/sys/dev/cardbus/cardbus.c#10 integrate .. //depot/projects/pci/sys/dev/cardbus/cardbusvar.h#4 integrate .. //depot/projects/pci/sys/dev/cxgbe/adapter.h#14 integrate .. //depot/projects/pci/sys/dev/cxgbe/common/t4_hw.c#9 integrate .. //depot/projects/pci/sys/dev/cxgbe/t4_main.c#15 integrate .. //depot/projects/pci/sys/dev/cxgbe/t4_sge.c#15 integrate .. //depot/projects/pci/sys/dev/ed/if_ed.c#6 integrate .. //depot/projects/pci/sys/dev/ed/if_ed_hpp.c#4 integrate .. //depot/projects/pci/sys/dev/mfi/mfi_pci.c#7 integrate .. //depot/projects/pci/sys/dev/mfi/mfi_tbolt.c#3 integrate .. //depot/projects/pci/sys/dev/mfi/mfivar.h#6 integrate .. //depot/projects/pci/sys/dev/msk/if_msk.c#9 integrate .. //depot/projects/pci/sys/dev/pccbb/pccbb.c#9 integrate .. //depot/projects/pci/sys/dev/pccbb/pccbb_isa.c#5 integrate .. //depot/projects/pci/sys/dev/pccbb/pccbb_pci.c#12 integrate .. //depot/projects/pci/sys/dev/pccbb/pccbbvar.h#4 integrate .. //depot/projects/pci/sys/dev/pci/pci.c#58 integrate .. //depot/projects/pci/sys/dev/pci/pci_pci.c#50 integrate .. //depot/projects/pci/sys/dev/pci/pci_private.h#19 integrate .. //depot/projects/pci/sys/dev/pci/pci_subr.c#12 integrate .. //depot/projects/pci/sys/dev/pci/pcib_private.h#29 integrate .. //depot/projects/pci/sys/dev/re/if_re.c#8 integrate .. //depot/projects/pci/sys/dev/usb/controller/at91dci_atmelarm.c#5 integrate .. //depot/projects/pci/sys/dev/usb/controller/ohci_atmelarm.c#4 integrate .. //depot/projects/pci/sys/dev/usb/net/if_urndis.c#1 branch .. //depot/projects/pci/sys/dev/usb/net/if_urndisreg.h#1 branch .. //depot/projects/pci/sys/dev/usb/usb.h#6 integrate .. //depot/projects/pci/sys/dev/vt/hw/fb/vt_fb.c#4 integrate .. //depot/projects/pci/sys/dev/vt/hw/vga/vga.c#3 integrate .. //depot/projects/pci/sys/dev/vt/vt.h#3 integrate .. //depot/projects/pci/sys/dev/vt/vt_core.c#3 integrate .. //depot/projects/pci/sys/geom/eli/g_eli_crypto.c#4 integrate .. //depot/projects/pci/sys/geom/uncompress/g_uncompress.c#5 integrate .. //depot/projects/pci/sys/geom/uzip/g_uzip.c#4 integrate .. //depot/projects/pci/sys/i386/i386/machdep.c#13 integrate .. //depot/projects/pci/sys/i386/i386/pmap.c#12 integrate .. //depot/projects/pci/sys/i386/include/pmap.h#8 integrate .. //depot/projects/pci/sys/i386/include/resource.h#4 integrate .. //depot/projects/pci/sys/i386/xen/pmap.c#9 integrate .. //depot/projects/pci/sys/kern/kern_cons.c#5 integrate .. //depot/projects/pci/sys/kern/kern_proc.c#12 integrate .. //depot/projects/pci/sys/kern/kern_sysctl.c#9 integrate .. //depot/projects/pci/sys/kern/subr_counter.c#4 integrate .. //depot/projects/pci/sys/kern/subr_pcpu.c#7 integrate .. //depot/projects/pci/sys/kern/subr_prf.c#7 integrate .. //depot/projects/pci/sys/modules/usb/Makefile#12 integrate .. //depot/projects/pci/sys/modules/usb/urndis/Makefile#1 branch .. //depot/projects/pci/sys/net/flowtable.c#5 integrate .. //depot/projects/pci/sys/net/flowtable.h#3 integrate .. //depot/projects/pci/sys/net/pfvar.h#3 integrate .. //depot/projects/pci/sys/net/route.c#10 integrate .. //depot/projects/pci/sys/net/vnet.c#5 integrate .. //depot/projects/pci/sys/net/vnet.h#4 integrate .. //depot/projects/pci/sys/netinet/cc/cc_cdg.c#2 integrate .. //depot/projects/pci/sys/netinet/in_pcb.c#10 integrate .. //depot/projects/pci/sys/netinet/ip_input.c#12 integrate .. //depot/projects/pci/sys/netinet/ip_output.c#14 integrate .. //depot/projects/pci/sys/netinet/sctp_sysctl.c#9 integrate .. //depot/projects/pci/sys/netinet/tcp_reass.c#6 integrate .. //depot/projects/pci/sys/netinet/tcp_syncache.c#12 integrate .. //depot/projects/pci/sys/netinet6/in6_proto.c#10 integrate .. //depot/projects/pci/sys/netinet6/ip6_input.c#11 integrate .. //depot/projects/pci/sys/netinet6/ip6_mroute.c#9 integrate .. //depot/projects/pci/sys/netinet6/ip6_output.c#9 integrate .. //depot/projects/pci/sys/netinet6/nd6.c#16 integrate .. //depot/projects/pci/sys/pc98/pc98/machdep.c#12 integrate .. //depot/projects/pci/sys/pci/if_rlreg.h#6 integrate .. //depot/projects/pci/sys/sparc64/pci/apb.c#7 integrate .. //depot/projects/pci/sys/sys/mbuf.h#11 integrate .. //depot/projects/pci/sys/sys/pcpu.h#7 integrate .. //depot/projects/pci/sys/sys/sysctl.h#10 integrate .. //depot/projects/pci/sys/sys/systm.h#16 integrate .. //depot/projects/pci/sys/sys/user.h#11 integrate .. //depot/projects/pci/sys/teken/teken.c#6 integrate .. //depot/projects/pci/sys/vm/device_pager.c#9 integrate .. //depot/projects/pci/sys/vm/uma.h#5 integrate .. //depot/projects/pci/sys/vm/uma_core.c#11 integrate .. //depot/projects/pci/sys/vm/vm_fault.c#14 integrate .. //depot/projects/pci/sys/x86/include/legacyvar.h#5 integrate .. //depot/projects/pci/sys/x86/pci/pci_bus.c#8 integrate .. //depot/projects/pci/sys/x86/pci/qpi.c#8 integrate .. //depot/projects/pci/sys/x86/x86/mptable_pci.c#21 integrate Differences ... ==== //depot/projects/pci/sys/amd64/amd64/pmap.c#15 (text+ko) ==== @@ -79,7 +79,7 @@ #define AMD64_NPT_AWARE #include -__FBSDID("$FreeBSD: head/sys/amd64/amd64/pmap.c 261148 2014-01-25 06:58:41Z grehan $"); +__FBSDID("$FreeBSD: head/sys/amd64/amd64/pmap.c 261781 2014-02-11 22:02:40Z jhb $"); /* * Manages physical address maps. @@ -812,7 +812,7 @@ pmap_bootstrap(vm_paddr_t *firstaddr) { vm_offset_t va; - pt_entry_t *pte, *unused; + pt_entry_t *pte; /* * Create an initial set of page tables to run the kernel in. @@ -858,14 +858,11 @@ pte = vtopte(va); /* - * CMAP1 is only used for the memory test. + * Crashdump maps. The first page is reused as CMAP1 for the + * memory test. */ - SYSMAP(caddr_t, CMAP1, CADDR1, 1) - - /* - * Crashdump maps. - */ - SYSMAP(caddr_t, unused, crashdumpmap, MAXDUMPPGS) + SYSMAP(caddr_t, CMAP1, crashdumpmap, MAXDUMPPGS) + CADDR1 = crashdumpmap; virtual_avail = va; ==== //depot/projects/pci/sys/amd64/include/resource.h#6 (text+ko) ==== @@ -1,4 +1,4 @@ -/* $FreeBSD: head/sys/amd64/include/resource.h 139731 2005-01-05 20:17:21Z imp $ */ +/* $FreeBSD: head/sys/amd64/include/resource.h 261790 2014-02-12 04:30:37Z jhb $ */ /*- * Copyright 1998 Massachusetts Institute of Technology * ==== //depot/projects/pci/sys/amd64/vmm/intel/vmx.c#12 (text+ko) ==== @@ -23,11 +23,11 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: head/sys/amd64/vmm/intel/vmx.c 261504 2014-02-05 04:39:03Z jhb $ + * $FreeBSD: head/sys/amd64/vmm/intel/vmx.c 261638 2014-02-08 16:37:54Z jhb $ */ #include -__FBSDID("$FreeBSD: head/sys/amd64/vmm/intel/vmx.c 261504 2014-02-05 04:39:03Z jhb $"); +__FBSDID("$FreeBSD: head/sys/amd64/vmm/intel/vmx.c 261638 2014-02-08 16:37:54Z jhb $"); #include #include @@ -1228,6 +1228,40 @@ } static int +vmx_emulate_xsetbv(struct vmx *vmx, int vcpu) +{ + struct vmxctx *vmxctx; + uint64_t xcrval; + const struct xsave_limits *limits; + + vmxctx = &vmx->ctx[vcpu]; + limits = vmm_get_xsave_limits(); + + /* We only handle xcr0 if the host has XSAVE enabled. */ + if (vmxctx->guest_rcx != 0 || !limits->xsave_enabled) + return (UNHANDLED); + + xcrval = vmxctx->guest_rdx << 32 | (vmxctx->guest_rax & 0xffffffff); + if ((xcrval & ~limits->xcr0_allowed) != 0) + return (UNHANDLED); + + if (!(xcrval & XFEATURE_ENABLED_X87)) + return (UNHANDLED); + + if ((xcrval & (XFEATURE_ENABLED_AVX | XFEATURE_ENABLED_SSE)) == + XFEATURE_ENABLED_AVX) + return (UNHANDLED); + + /* + * This runs "inside" vmrun() with the guest's FPU state, so + * modifying xcr0 directly modifies the guest's xcr0, not the + * host's. + */ + load_xcr(0, xcrval); + return (HANDLED); +} + +static int vmx_emulate_cr_access(struct vmx *vmx, int vcpu, uint64_t exitqual) { int cr, vmcs_guest_cr, vmcs_shadow_cr; @@ -1719,22 +1753,12 @@ vmx_restore_nmi_blocking(vmx, vcpu); /* - * If the NMI-exiting VM execution control is set to '1' - * then an NMI in non-root operation causes a VM-exit. - * NMI blocking is in effect for this logical processor so - * it is sufficient to simply vector to the NMI handler via - * a software interrupt. + * The NMI has already been handled in vmx_exit_handle_nmi(). */ - if ((intr_info & VMCS_INTR_T_MASK) == VMCS_INTR_T_NMI) { - KASSERT((intr_info & 0xff) == IDT_NMI, ("VM exit due " - "to NMI has invalid vector: %#x", intr_info)); - VCPU_CTR0(vmx->vm, vcpu, "Vectoring to NMI handler"); - __asm __volatile("int $2"); + if ((intr_info & VMCS_INTR_T_MASK) == VMCS_INTR_T_NMI) return (1); - } break; case EXIT_REASON_EPT_FAULT: - vmm_stat_incr(vmx->vm, vcpu, VMEXIT_EPT_FAULT, 1); /* * If 'gpa' lies within the address space allocated to * memory then this must be a nested page fault otherwise @@ -1745,6 +1769,7 @@ vmexit->exitcode = VM_EXITCODE_PAGING; vmexit->u.paging.gpa = gpa; vmexit->u.paging.fault_type = ept_fault_type(qual); + vmm_stat_incr(vmx->vm, vcpu, VMEXIT_NESTED_FAULT, 1); } else if (ept_emulation_fault(qual)) { vmexit->exitcode = VM_EXITCODE_INST_EMUL; vmexit->u.inst_emul.gpa = gpa; @@ -1752,6 +1777,7 @@ vmexit->u.inst_emul.cr3 = vmcs_guest_cr3(); vmexit->u.inst_emul.cpu_mode = vmx_cpu_mode(); vmexit->u.inst_emul.paging_mode = vmx_paging_mode(); + vmm_stat_incr(vmx->vm, vcpu, VMEXIT_INST_EMUL, 1); } /* * If Virtual NMIs control is 1 and the VM-exit is due to an @@ -1782,6 +1808,9 @@ vlapic = vm_lapic(vmx->vm, vcpu); handled = vmx_handle_apic_write(vlapic, qual); break; + case EXIT_REASON_XSETBV: + handled = vmx_emulate_xsetbv(vmx, vcpu); + break; default: vmm_stat_incr(vmx->vm, vcpu, VMEXIT_UNKNOWN, 1); break; @@ -1874,6 +1903,36 @@ return (UNHANDLED); } +/* + * If the NMI-exiting VM execution control is set to '1' then an NMI in + * non-root operation causes a VM-exit. NMI blocking is in effect so it is + * sufficient to simply vector to the NMI handler via a software interrupt. + * However, this must be done before maskable interrupts are enabled + * otherwise the "iret" issued by an interrupt handler will incorrectly + * clear NMI blocking. + */ +static __inline void +vmx_exit_handle_nmi(struct vmx *vmx, int vcpuid, struct vm_exit *vmexit) +{ + uint32_t intr_info; + + KASSERT((read_rflags() & PSL_I) == 0, ("interrupts enabled")); + + if (vmexit->u.vmx.exit_reason != EXIT_REASON_EXCEPTION) + return; + + intr_info = vmcs_read(VMCS_EXIT_INTR_INFO); + KASSERT((intr_info & VMCS_INTR_VALID) != 0, + ("VM exit interruption info invalid: %#x", intr_info)); + + if ((intr_info & VMCS_INTR_T_MASK) == VMCS_INTR_T_NMI) { + KASSERT((intr_info & 0xff) == IDT_NMI, ("VM exit due " + "to NMI has invalid vector: %#x", intr_info)); + VCPU_CTR0(vmx->vm, vcpuid, "Vectoring to NMI handler"); + __asm __volatile("int $2"); + } +} + static int vmx_run(void *arg, int vcpu, register_t startrip, pmap_t pmap, void *rendezvous_cookie) @@ -1949,8 +2008,6 @@ vmx_run_trace(vmx, vcpu); rc = vmx_enter_guest(vmxctx, vmx, launched); - enable_intr(); - /* Collect some information for VM exit processing */ vmexit->rip = rip = vmcs_guest_rip(); vmexit->inst_length = vmexit_instruction_length(); @@ -1958,12 +2015,14 @@ vmexit->u.vmx.exit_qualification = vmcs_exit_qualification(); if (rc == VMX_GUEST_VMEXIT) { - launched = 1; + vmx_exit_handle_nmi(vmx, vcpu, vmexit); + enable_intr(); handled = vmx_exit_process(vmx, vcpu, vmexit); } else { + enable_intr(); handled = vmx_exit_inst_error(vmxctx, rc, vmexit); } - + launched = 1; vmx_exit_trace(vmx, vcpu, rip, exit_reason, handled); } while (handled); ==== //depot/projects/pci/sys/amd64/vmm/vmm.c#11 (text+ko) ==== @@ -23,11 +23,11 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: head/sys/amd64/vmm/vmm.c 261504 2014-02-05 04:39:03Z jhb $ + * $FreeBSD: head/sys/amd64/vmm/vmm.c 261638 2014-02-08 16:37:54Z jhb $ */ #include -__FBSDID("$FreeBSD: head/sys/amd64/vmm/vmm.c 261504 2014-02-05 04:39:03Z jhb $"); +__FBSDID("$FreeBSD: head/sys/amd64/vmm/vmm.c 261638 2014-02-08 16:37:54Z jhb $"); #include #include @@ -89,6 +89,7 @@ struct vlapic *vlapic; int vcpuid; struct savefpu *guestfpu; /* guest fpu state */ + uint64_t guest_xcr0; void *stats; struct vm_exit exitinfo; enum x2apic_state x2apic_state; @@ -206,6 +207,7 @@ vcpu->vcpuid = vcpu_id; vcpu->vlapic = VLAPIC_INIT(vm->cookie, vcpu_id); vm_set_x2apic_state(vm, vcpu_id, X2APIC_ENABLED); + vcpu->guest_xcr0 = XFEATURE_ENABLED_X87; vcpu->guestfpu = fpu_save_area_alloc(); fpu_save_area_reset(vcpu->guestfpu); vcpu->stats = vmm_stat_alloc(); @@ -815,6 +817,10 @@ fpu_stop_emulating(); fpurestore(vcpu->guestfpu); + /* restore guest XCR0 if XSAVE is enabled in the host */ + if (rcr4() & CR4_XSAVE) + load_xcr(0, vcpu->guest_xcr0); + /* * The FPU is now "dirty" with the guest's state so turn on emulation * to trap any access to the FPU by the host. @@ -829,6 +835,12 @@ if ((rcr0() & CR0_TS) == 0) panic("fpu emulation not enabled in host!"); + /* save guest XCR0 and restore host XCR0 */ + if (rcr4() & CR4_XSAVE) { + vcpu->guest_xcr0 = rxcr(0); + load_xcr(0, vmm_get_host_xcr0()); + } + /* save guest FPU state */ fpu_stop_emulating(); fpusave(vcpu->guestfpu); ==== //depot/projects/pci/sys/amd64/vmm/vmm_host.c#2 (text+ko) ==== @@ -23,11 +23,11 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: head/sys/amd64/vmm/vmm_host.c 242275 2012-10-29 01:51:24Z neel $ + * $FreeBSD: head/sys/amd64/vmm/vmm_host.c 261638 2014-02-08 16:37:54Z jhb $ */ #include -__FBSDID("$FreeBSD: head/sys/amd64/vmm/vmm_host.c 242275 2012-10-29 01:51:24Z neel $"); +__FBSDID("$FreeBSD: head/sys/amd64/vmm/vmm_host.c 261638 2014-02-08 16:37:54Z jhb $"); #include #include @@ -38,11 +38,14 @@ #include "vmm_host.h" -static uint64_t vmm_host_efer, vmm_host_pat, vmm_host_cr0, vmm_host_cr4; +static uint64_t vmm_host_efer, vmm_host_pat, vmm_host_cr0, vmm_host_cr4, + vmm_host_xcr0; +static struct xsave_limits vmm_xsave_limits; void vmm_host_state_init(void) { + int regs[4]; vmm_host_efer = rdmsr(MSR_EFER); vmm_host_pat = rdmsr(MSR_PAT); @@ -57,6 +60,21 @@ vmm_host_cr0 = rcr0() | CR0_TS; vmm_host_cr4 = rcr4(); + + /* + * Only permit a guest to use XSAVE if the host is using + * XSAVE. Only permit a guest to use XSAVE features supported + * by the host. This ensures that the FPU state used by the + * guest is always a subset of the saved guest FPU state. + */ + if (vmm_host_cr4 & CR4_XSAVE) { + vmm_xsave_limits.xsave_enabled = 1; + vmm_host_xcr0 = rxcr(0); + vmm_xsave_limits.xcr0_allowed = vmm_host_xcr0; + + cpuid_count(0xd, 0x0, regs); + vmm_xsave_limits.xsave_max_size = regs[1]; + } } uint64_t @@ -88,6 +106,13 @@ } uint64_t +vmm_get_host_xcr0(void) +{ + + return (vmm_host_xcr0); +} + +uint64_t vmm_get_host_datasel(void) { @@ -122,3 +147,10 @@ return (r_idt.rd_base); } + +const struct xsave_limits * +vmm_get_xsave_limits(void) +{ + + return (&vmm_xsave_limits); +} ==== //depot/projects/pci/sys/amd64/vmm/vmm_host.h#2 (text+ko) ==== @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: head/sys/amd64/vmm/vmm_host.h 242275 2012-10-29 01:51:24Z neel $ + * $FreeBSD: head/sys/amd64/vmm/vmm_host.h 261638 2014-02-08 16:37:54Z jhb $ */ #ifndef _VMM_HOST_H_ @@ -33,17 +33,25 @@ #error "no user-servicable parts inside" #endif +struct xsave_limits { + int xsave_enabled; + uint64_t xcr0_allowed; + uint32_t xsave_max_size; +}; + void vmm_host_state_init(void); uint64_t vmm_get_host_pat(void); uint64_t vmm_get_host_efer(void); uint64_t vmm_get_host_cr0(void); uint64_t vmm_get_host_cr4(void); +uint64_t vmm_get_host_xcr0(void); uint64_t vmm_get_host_datasel(void); uint64_t vmm_get_host_codesel(void); uint64_t vmm_get_host_tsssel(void); uint64_t vmm_get_host_fsbase(void); uint64_t vmm_get_host_idtrbase(void); +const struct xsave_limits *vmm_get_xsave_limits(void); /* * Inline access to host state that is used on every VM entry ==== //depot/projects/pci/sys/amd64/vmm/vmm_stat.c#5 (text+ko) ==== @@ -23,11 +23,11 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: head/sys/amd64/vmm/vmm_stat.c 261001 2014-01-22 04:03:11Z neel $ + * $FreeBSD: head/sys/amd64/vmm/vmm_stat.c 261621 2014-02-08 06:22:09Z neel $ */ #include -__FBSDID("$FreeBSD: head/sys/amd64/vmm/vmm_stat.c 261001 2014-01-22 04:03:11Z neel $"); +__FBSDID("$FreeBSD: head/sys/amd64/vmm/vmm_stat.c 261621 2014-02-08 06:22:09Z neel $"); #include #include @@ -146,7 +146,8 @@ VMM_STAT(VMEXIT_NMI_WINDOW, "vm exits due to nmi window opening"); VMM_STAT(VMEXIT_INOUT, "number of times in/out was intercepted"); VMM_STAT(VMEXIT_CPUID, "number of times cpuid was intercepted"); -VMM_STAT(VMEXIT_EPT_FAULT, "vm exits due to nested page fault"); +VMM_STAT(VMEXIT_NESTED_FAULT, "vm exits due to nested page fault"); +VMM_STAT(VMEXIT_INST_EMUL, "vm exits for instruction emulation"); VMM_STAT(VMEXIT_UNKNOWN, "number of vm exits for unknown reason"); VMM_STAT(VMEXIT_ASTPENDING, "number of times astpending at exit"); VMM_STAT(VMEXIT_USERSPACE, "number of vm exits handled in userspace"); ==== //depot/projects/pci/sys/amd64/vmm/vmm_stat.h#5 (text+ko) ==== @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: head/sys/amd64/vmm/vmm_stat.h 261001 2014-01-22 04:03:11Z neel $ + * $FreeBSD: head/sys/amd64/vmm/vmm_stat.h 261621 2014-02-08 06:22:09Z neel $ */ #ifndef _VMM_STAT_H_ @@ -116,7 +116,8 @@ VMM_STAT_DECLARE(VMEXIT_NMI_WINDOW); VMM_STAT_DECLARE(VMEXIT_INOUT); VMM_STAT_DECLARE(VMEXIT_CPUID); -VMM_STAT_DECLARE(VMEXIT_EPT_FAULT); +VMM_STAT_DECLARE(VMEXIT_NESTED_FAULT); +VMM_STAT_DECLARE(VMEXIT_INST_EMUL); VMM_STAT_DECLARE(VMEXIT_UNKNOWN); VMM_STAT_DECLARE(VMEXIT_ASTPENDING); VMM_STAT_DECLARE(VMEXIT_USERSPACE); ==== //depot/projects/pci/sys/amd64/vmm/x86.c#5 (text+ko) ==== @@ -23,24 +23,26 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: head/sys/amd64/vmm/x86.c 256645 2013-10-16 18:20:27Z neel $ + * $FreeBSD: head/sys/amd64/vmm/x86.c 261638 2014-02-08 16:37:54Z jhb $ */ #include -__FBSDID("$FreeBSD: head/sys/amd64/vmm/x86.c 256645 2013-10-16 18:20:27Z neel $"); +__FBSDID("$FreeBSD: head/sys/amd64/vmm/x86.c 261638 2014-02-08 16:37:54Z jhb $"); #include -#include +#include #include #include #include #include #include +#include #include #include +#include "vmm_host.h" #include "x86.h" #define CPUID_VM_HIGH 0x40000000 @@ -53,6 +55,8 @@ x86_emulate_cpuid(struct vm *vm, int vcpu_id, uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx) { + const struct xsave_limits *limits; + uint64_t cr4; int error, enable_invpcid; unsigned int func, regs[4]; enum x2apic_state x2apic_state; @@ -147,11 +151,27 @@ regs[2] |= CPUID2_X2APIC; /* - * Hide xsave/osxsave/avx until the FPU save/restore - * issues are resolved + * Only advertise CPUID2_XSAVE in the guest if + * the host is using XSAVE. + */ + if (!(regs[2] & CPUID2_OSXSAVE)) + regs[2] &= ~CPUID2_XSAVE; + + /* + * If CPUID2_XSAVE is being advertised and the + * guest has set CR4_XSAVE, set + * CPUID2_OSXSAVE. */ - regs[2] &= ~(CPUID2_XSAVE | CPUID2_OSXSAVE | - CPUID2_AVX); + regs[2] &= ~CPUID2_OSXSAVE; + if (regs[2] & CPUID2_XSAVE) { + error = vm_get_register(vm, vcpu_id, + VM_REG_GUEST_CR4, &cr4); + if (error) + panic("x86_emulate_cpuid: error %d " + "fetching %%cr4", error); + if (cr4 & CR4_XSAVE) + regs[2] |= CPUID2_OSXSAVE; + } /* * Hide monitor/mwait until we know how to deal with @@ -219,7 +239,6 @@ case CPUID_0000_0006: case CPUID_0000_000A: - case CPUID_0000_000D: /* * Handle the access, but report 0 for * all options @@ -240,6 +259,57 @@ regs[3] = vcpu_id; break; + case CPUID_0000_000D: + limits = vmm_get_xsave_limits(); + if (!limits->xsave_enabled) { + regs[0] = 0; + regs[1] = 0; + regs[2] = 0; + regs[3] = 0; + break; + } + + cpuid_count(*eax, *ecx, regs); + switch (*ecx) { + case 0: + /* + * Only permit the guest to use bits + * that are active in the host in + * %xcr0. Also, claim that the + * maximum save area size is + * equivalent to the host's current + * save area size. Since this runs + * "inside" of vmrun(), it runs with + * the guest's xcr0, so the current + * save area size is correct as-is. + */ + regs[0] &= limits->xcr0_allowed; + regs[2] = limits->xsave_max_size; + regs[3] &= (limits->xcr0_allowed >> 32); + break; + case 1: + /* Only permit XSAVEOPT. */ + regs[0] &= CPUID_EXTSTATE_XSAVEOPT; + regs[1] = 0; + regs[2] = 0; + regs[3] = 0; + break; + default: + /* + * If the leaf is for a permitted feature, + * pass through as-is, otherwise return + * all zeroes. + */ + if (!(limits->xcr0_allowed & (1ul << *ecx))) { + regs[0] = 0; + regs[1] = 0; + regs[2] = 0; + regs[3] = 0; + } + break; + } + break; + case 0x40000000: regs[0] = CPUID_VM_HIGH; bcopy(bhyve_id, ®s[1], 4); ==== //depot/projects/pci/sys/arm/arm/elf_trampoline.c#7 (text+ko) ==== @@ -30,7 +30,7 @@ #include "opt_kernname.h" #include -__FBSDID("$FreeBSD: head/sys/arm/arm/elf_trampoline.c 259640 2013-12-20 00:56:23Z ganbold $"); +__FBSDID("$FreeBSD: head/sys/arm/arm/elf_trampoline.c 261648 2014-02-09 02:06:12Z ian $"); #include #include #include @@ -186,14 +186,20 @@ void _startC(void) { - int physaddr = KERNPHYSADDR; int tmp1; unsigned int sp = ((unsigned int)&_end & ~3) + 4; -#if defined(FLASHADDR) && defined(LOADERRAMADDR) - unsigned int pc; + unsigned int pc, kernphysaddr; + /* + * Figure out the physical address the kernel was loaded at. This + * assumes the entry point (this code right here) is in the first page, + * which will always be the case for this trampoline code. + */ __asm __volatile("mov %0, pc\n" : "=r" (pc)); + kernphysaddr = pc & ~PAGE_MASK; + +#if defined(FLASHADDR) && defined(PHYSADDR) && defined(LOADERRAMADDR) if ((FLASHADDR > LOADERRAMADDR && pc >= FLASHADDR) || (FLASHADDR < LOADERRAMADDR && pc < LOADERRAMADDR)) { /* @@ -247,7 +253,7 @@ "mov pc, %0\n" "2: nop\n" "mov sp, %2\n" - : "=r" (tmp1), "+r" (physaddr), "+r" (sp)); + : "=r" (tmp1), "+r" (kernphysaddr), "+r" (sp)); #ifndef KZIP #ifdef CPU_ARM9 /* So that idcache_wbinv works; */ ==== //depot/projects/pci/sys/arm/arm/locore.S#8 (text+ko) ==== @@ -39,7 +39,7 @@ #include #include -__FBSDID("$FreeBSD: head/sys/arm/arm/locore.S 261393 2014-02-02 00:48:15Z ian $"); +__FBSDID("$FreeBSD: head/sys/arm/arm/locore.S 261783 2014-02-11 22:09:03Z imp $"); /* What size should this really be ? It is only used by initarm() */ #define INIT_ARM_STACK_SIZE (2048 * 4) @@ -153,22 +153,27 @@ ldr r2, =(KERNVIRTADDR - KERNPHYSADDR) sub r0, r1, r2 - adr r4, mmu_init_table - b 3f + /* + * Map PA == VA + */ + ldr r5, =(PHYSADDR) + mov r1, r5 + mov r2, r5 + /* Map 64MiB, preserved over calls to build_pagetables */ + mov r3, #64 + bl build_pagetables -2: - str r3, [r0, r2] - add r2, r2, #4 - add r3, r3, #(L1_S_SIZE) - adds r1, r1, #-1 - bhi 2b -3: - ldmia r4!, {r1,r2,r3} /* # of sections, VA, PA|attr */ - cmp r1, #0 - adrne r5, 2b - bicne r5, r5, #0xf0000000 - orrne r5, r5, #PHYSADDR - movne pc, r5 + /* Create the kernel map to jump to */ + mov r1, r5 + ldr r2, =(KERNBASE) + bl build_pagetables + +#if defined(SOCDEV_PA) && defined(SOCDEV_VA) + /* Create the custom map */ + ldr r1, =SOCDEV_PA + ldr r2, =SOCDEV_VA + bl build_pagetables +#endif #if defined(SMP) orr r0, r0, #2 /* Set TTB shared memory flag */ @@ -216,7 +221,7 @@ ldr pc, .Lvirt_done virt_done: - mov r1, #20 /* loader info size is 20 bytes also second arg */ + mov r1, #28 /* loader info size is 28 bytes also second arg */ subs sp, sp, r1 /* allocate arm_boot_params struct on stack */ bic sp, sp, #7 /* align stack to 8 bytes */ mov r0, sp /* loader info pointer is first arg */ @@ -225,6 +230,10 @@ str r8, [r0, #8] /* Store r1 from boot loader */ str ip, [r0, #12] /* store r2 from boot loader */ str fp, [r0, #16] /* store r3 from boot loader */ + ldr r5, =KERNPHYSADDR /* load KERNPHYSADDR as the physical address */ + str r5, [r0, #20] /* store the physical address */ + ldr r5, Lstartup_pagetable + str r5, [r0, #24] /* store the pagetable address */ mov fp, #0 /* trace back starts here */ bl _C_LABEL(initarm) /* Off we go */ @@ -236,10 +245,39 @@ adr r0, .Lmainreturned b _C_LABEL(panic) /* NOTREACHED */ -#define MMU_INIT(va,pa,n_sec,attr) \ - .word n_sec ; \ - .word 4*((va)>>L1_S_SHIFT) ; \ - .word (pa)|(attr) ; +END(btext) +END(_start) + +/* + * Builds the page table + * r0 - The table base address + * r1 - The physical address (trashed) + * r2 - The virtual address (trashed) + * r3 - The number of 1MiB sections + * r4 - Trashed + * + * Addresses must be 1MiB aligned + */ +build_pagetables: + /* Set the required page attributed */ + ldr r4, =(L1_TYPE_S|L1_S_C|L1_S_AP(AP_KRW)) +#if defined(SMP) + orr r4, #(L1_SHARED) +#endif + orr r1, r4 + + /* Move the virtual address to the correct bit location */ + lsr r2, #(L1_S_SHIFT - 2) + + mov r4, r3 +1: + str r1, [r0, r2] + add r2, r2, #4 + add r1, r1, #(L1_S_SIZE) + adds r4, r4, #-1 + bhi 1b + + RET Lvirtaddr: .word KERNVIRTADDR @@ -255,27 +293,7 @@ Lstartup_pagetable_secondary: .word temp_pagetable #endif -END(btext) -END(_start) -mmu_init_table: - /* fill all table VA==PA */ - /* map SDRAM VA==PA, WT cacheable */ -#if !defined(SMP) - MMU_INIT(PHYSADDR, PHYSADDR, 64, L1_TYPE_S|L1_S_C|L1_S_AP(AP_KRW)) - /* map VA 0xc0000000..0xc3ffffff to PA */ - MMU_INIT(KERNBASE, PHYSADDR, 64, L1_TYPE_S|L1_S_C|L1_S_AP(AP_KRW)) -#if defined(SOCDEV_PA) && defined(SOCDEV_VA) - /* Map in 0x04000000 worth of the SoC's devices for bootstrap debugging */ - MMU_INIT(SOCDEV_VA, SOCDEV_PA, 64, L1_TYPE_S|L1_S_C|L1_S_AP(AP_KRW)) -#endif -#else - MMU_INIT(PHYSADDR, PHYSADDR , 64, L1_TYPE_S|L1_SHARED|L1_S_C|L1_S_AP(AP_KRW)) - /* map VA 0xc0000000..0xc3ffffff to PA */ - MMU_INIT(KERNBASE, PHYSADDR, 64, L1_TYPE_S|L1_SHARED|L1_S_C|L1_S_AP(AP_KRW)) - MMU_INIT(0x48000000, 0x48000000, 1, L1_TYPE_S|L1_SHARED|L1_S_C|L1_S_AP(AP_KRW)) -#endif /* SMP */ - .word 0 /* end of table */ .Lstart: .word _edata .word _ebss ==== //depot/projects/pci/sys/arm/arm/machdep.c#11 (text+ko) ==== @@ -49,7 +49,7 @@ #include "opt_timer.h" #include -__FBSDID("$FreeBSD: head/sys/arm/arm/machdep.c 261415 2014-02-02 20:58:23Z cognet $"); +__FBSDID("$FreeBSD: head/sys/arm/arm/machdep.c 261789 2014-02-12 03:19:35Z imp $"); #include #include @@ -97,6 +97,7 @@ #include #include #include +#include #include #include >>> TRUNCATED FOR MAIL (1000 lines) <<<