summaryrefslogtreecommitdiffstats
path: root/sys/amd64/vmm/intel/vmx.c
Commit message (Collapse)AuthorAgeFilesLines
...
* Add some more stats to keep track of all the reasons that a vcpu is exiting.neel2013-03-301-1/+16
|
* Allow vmm stats to be specific to the underlying hardware assist technology.neel2013-03-161-4/+3
| | | | | | | | | This can be done by using the new macros VMM_STAT_INTEL() and VMM_STAT_AMD(). Statistic counters that are common across the two are defined using VMM_STAT(). Suggested by: Anish Gupta Discussed with: grehan Obtained from: NetApp
* Always allow access to the sysenter cs/esp/eip MSRs since theygrehan2013-01-251-0/+7
| | | | | | | are automatically saved and restored in the VMCS. Reviewed by: neel Obtained from: NetApp
* Add support for the 0x81 AND instruction, now generatedgrehan2012-11-291-4/+5
| | | | | | | | | | | by clang in the local APIC code. 0x81 is a read-modify-write instruction - the EPT check that only allowed read or write and not both has been relaxed to allow read and write. Reviewed by: neel Obtained from: NetApp
* Cleanup the user-space paging exit handler now that the unified instructionneel2012-11-281-2/+0
| | | | | | emulation is in place. Obtained from: NetApp
* Change emulate_rdmsr() and emulate_wrmsr() to return 0 on sucess and errno onneel2012-11-281-6/+8
| | | | | | | failure. The conversion from the return value to HANDLED or UNHANDLED can be done locally in vmx_exit_process(). Obtained from: NetApp
* Revamp the x86 instruction emulation in bhyve.neel2012-11-281-25/+20
| | | | | | | | | | | | | | | | | | | On a nested page table fault the hypervisor will: - fetch the instruction using the guest %rip and %cr3 - decode the instruction in 'struct vie' - emulate the instruction in host kernel context for local apic accesses - any other type of mmio access is punted up to user-space (e.g. ioapic) The decoded instruction is passed as collateral to the user-space process that is handling the PAGING exit. The emulation code is fleshed out to include more addressing modes (e.g. SIB) and more types of operands (e.g. imm8). The source code is unified into a single file (vmm_instruction_emul.c) that is compiled into vmm.ko as well as /usr/sbin/bhyve. Reviewed by: grehan Obtained from: NetApp
* Convert VMCS_ENTRY_INTR_INFO field into a vmcs identifier before passing itneel2012-10-291-1/+1
| | | | | | | | | | | | | to vmcs_getreg(). Without this conversion vmcs_getreg() will return EINVAL. In particular this prevented injection of the breakpoint exception into the guest via the "-B" option to /usr/sbin/bhyve which is hugely useful when debugging guest hangs. This was broken in r241921. Pointy hat: me Obtained from: NetApp
* Corral all the host state associated with the virtual machine into its own file.neel2012-10-291-7/+4
| | | | | | | This state is independent of the type of hardware assist used so there is really no need for it to be in Intel-specific code. Obtained from: NetApp
* If the guest vcpu wants to idle then use that opportunity to relinquish theneel2012-10-251-3/+18
| | | | | | | | | | | | host cpu to the scheduler until the guest is ready to run again. This implies that the host cpu utilization will now closely mirror the actual load imposed by the guest vcpu. Also, the vcpu mutex now needs to be of type MTX_SPIN since we need to acquire it inside a critical section. Obtained from: NetApp
* Maintain state regarding NMI delivery to guest vcpu in VT-x independent manner.neel2012-10-241-14/+2
| | | | | | Also add a stats counter to count the number of NMIs delivered per vcpu. Obtained from: NetApp
* Test for AST pending with interrupts disabled right before entering the guest.neel2012-10-231-22/+43
| | | | | | | If an IPI was delivered to this cpu before interrupts were disabled then return right away via vmx_setjmp() with a return value of VMX_RETURN_AST. Obtained from: NetApp
* Add the guest physical address and r/w/x bits togrehan2012-10-121-0/+2
| | | | | | | | the paging exit in preparation for a rework of bhyve MMIO handling. Reviewed by: neel Obtained from: NetApp
* Provide per-vcpu locks instead of relying on a single big lock.neel2012-10-121-2/+2
| | | | | | | This also gets rid of all the witness.watch warnings related to calling malloc(M_WAITOK) while holding a mutex. Reviewed by: grehan
* Get rid of assumptions in the hypervisor that the host physical memoryneel2012-10-031-1/+2
| | | | | | | associated with guest physical memory is contiguous. Rewrite vm_gpa2hpa() to get the GPA to HPA mapping by querying the nested page tables.
* Intel VT-x provides the length of the instruction at the time of the nestedneel2012-09-271-3/+13
| | | | | | | | | | page table fault. Use this when fetching the instruction bytes from the guest memory. Also modify the lapic_mmio() API so that a decoded instruction is fed into it instead of having it fetch the instruction bytes from the guest. This is useful for hardware assists like SVM that provide the faulting instruction as part of the vmexit.
* Add support for trapping MMIO writes to local apic registers and emulating them.neel2012-09-251-14/+60
| | | | | The default behavior is still to present the local apic to the guest in the x2apic mode.
* Add an explicit exit code 'SPINUP_AP' to tell the controlling process that anneel2012-09-251-0/+8
| | | | | | | | | | AP needs to be activated by spinning up an execution context for it. The local apic emulation is now completely done in the hypervisor and it will detect writes to the ICR_LO register that try to bring up the AP. In response to such writes it will return to userspace with an exit code of SPINUP_AP. Reviewed by: grehan
* Stash the 'vm_exit' information in each 'struct vcpu'.neel2012-09-241-1/+4
| | | | | There is no functional change at this time but this paves the way for vm exit handler functions to easily modify the exit reason going forward.
* Force certain bits in %cr4 to be hard-wired to '1' or '0' from a guest'sneel2012-08-041-16/+52
| | | | | | | perspective. If we don't do this some guest OSes (e.g. Linux) will reset the CR4_VMXE bit in %cr4 with disastrous consequences. Reported by: grehan
* Verify that VMX operation has been enabled by BIOS before executing theneel2012-07-251-1/+11
| | | | | | VMXON instruction. Reported by "s vas" on freebsd-virtualization@
* MSI-x interrupt support for PCI pass-thru devices.grehan2012-04-281-0/+4
| | | | | | | | | | Includes instruction emulation for memory r/w access. This opens the door for io-apic, local apic, hpet timer, and legacy device emulation. Submitted by: ryan dot berryhill at sandvine dot com Reviewed by: grehan Obtained from: Sandvine
* Add support for running as a nested hypervisor under VMWare Fusion, ongrehan2011-12-241-18/+54
| | | | | | | | | | | | | | | | | | | | | | | | systems with VT-x/EPT (e.g. Sandybridge Macbooks). This will most likely work on VMWare Workstation8/Player4 as well. See the VMWare app note at: http://communities.vmware.com/docs/DOC-8970 Fusion doesn't propagate the PAT MSR auto save-restore entry/exit control bits. Deal with this by noting that fact and setting up the PAT MSR to essentially be a no-op - it is init'd to power-on default, and a software shadow copy maintained. Since it is treated as a no-op, o/s settings are essentially ignored. This may not give correct results, but since the hypervisor is running nested, a number of bets are already off. On a quad-core/HT-enabled 'MacBook8,2', nested VMs with 1/2/4 vCPUs were fired up. The more nested vCPUs the worse the performance, unless the VMs were started up in multiplexed mode where things worked perfectly up to the limit of 8 vCPUs. Reviewed by: neel
* Some tweaks to the CPUID support:jhb2011-06-021-6/+5
| | | | | | | | | | | | - Don't always pass the cpuid request to the current CPU as some nodes we will emulate purely in software. - Pass in the APIC ID of the virtual CPU so we can return the proper APIC ID. - Always report a completely flat topology with no SMT or multicore. - Report the CPUID2_HV feature and implement support for the 0x40000000 CPUID level. - Use existing constants from <machine/specialreg.h> when possible and use cpu_feature2 when checking for VMX support.
* Add a 'show vmcs' DDB command to dump state about the current CPU'sjhb2011-06-021-1/+1
| | | | current VMCS.
* Fix a long standing bug in VMXCTX_GUEST_RESTORE().neel2011-05-201-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There was an assumption by the "callers" of this macro that on "return" the %rsp will be pointing to the 'vmxctx'. The macro was not doing this and thus when trying to restore host state on an error from "vmlaunch" or "vmresume" we were treating the memory locations on the host stack as 'struct vmxctx'. This led to all sorts of weird bugs like double faults or invalid instruction faults. This bug is exposed by the -O2 option used to compile the kernel module. With the -O2 flag the compiler will optimize the following piece of code: int loopstart = 1; ... if (loopstart) { loopstart = 0; vmx_launch(); } else vmx_resume(); into this: vmx_launch(); Since vmx_launch() and vmx_resume() are declared to be __dead2 functions the compiler is free to do this. The compiler has no way to know that the functions return indirectly through vmx_setjmp(). This optimization in turn leads us to trigger the bug in VMXCTX_GUEST_RESTORE(). With this change we can boot a 8.1 guest on a 9.0 host. Reported by: jhb@
* Import of bhyve hypervisor and utilities, part 1.grehan2011-05-131-0/+1673
vmm.ko - kernel module for VT-x, VT-d and hypervisor control bhyve - user-space sequencer and i/o emulation vmmctl - dump of hypervisor register state libvmm - front-end to vmm.ko chardev interface bhyve was designed and implemented by Neel Natu. Thanks to the following folk from NetApp who helped to make this available: Joe CaraDonna Peter Snyder Jeff Heller Sandeep Mann Steve Miller Brian Pawlowski
OpenPOWER on IntegriCloud