summaryrefslogtreecommitdiffstats
path: root/usr.sbin/bhyve
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2014-06-12 19:58:12 +0000
committerjhb <jhb@FreeBSD.org>2014-06-12 19:58:12 +0000
commit3e1f2ae835422b06a1812ad150561de8d78e7998 (patch)
treea88a56bf8fd9c614d7ab81310cc3f2e44f3a1606 /usr.sbin/bhyve
parent572e5ac4530c8a38b1fb79a4c94be7f76df567f4 (diff)
downloadFreeBSD-src-3e1f2ae835422b06a1812ad150561de8d78e7998.zip
FreeBSD-src-3e1f2ae835422b06a1812ad150561de8d78e7998.tar.gz
MFC 261638,262144,262506,266765:
Add virtualized XSAVE support to bhyve which permits guests to use XSAVE and XSAVE-enabled features like AVX. - Store a per-cpu guest xcr0 register and handle xsetbv VM exits by emulating the instruction. - Only expose XSAVE to guests if XSAVE is enabled in the host. Only expose a subset of XSAVE features currently supported by the guest and for which the proper emulation of xsetbv is known. Currently this includes X87, SSE, AVX, AVX-512, and Intel MPX. - Add support for injecting hardware exceptions into the guest and use this to trigger exceptions in the guest for invalid xsetbv operations instead of potentially faulting in the host. - Queue pending exceptions in the 'struct vcpu' instead of directly updating the processor-specific VMCS or VMCB. The pending exception will be delivered right before entering the guest. - Rename the unused ioctl VM_INJECT_EVENT to VM_INJECT_EXCEPTION and restrict it to only deliver x86 hardware exceptions. This new ioctl is now used to inject a protection fault when the guest accesses an unimplemented MSR. - Expose a subset of known-safe features from leaf 0 of the structured extended features to guests if they are supported on the host including RDFSBASE/RDGSBASE, BMI1/2, AVX2, AVX-512, HLE, ERMS, and RTM. Aside from AVX-512, these features are all new instructions available for use in ring 3 with no additional hypervisor changes needed.
Diffstat (limited to 'usr.sbin/bhyve')
-rw-r--r--usr.sbin/bhyve/bhyverun.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/usr.sbin/bhyve/bhyverun.c b/usr.sbin/bhyve/bhyverun.c
index c587aef..b6662ca 100644
--- a/usr.sbin/bhyve/bhyverun.c
+++ b/usr.sbin/bhyve/bhyverun.c
@@ -326,8 +326,11 @@ vmexit_rdmsr(struct vmctx *ctx, struct vm_exit *vme, int *pvcpu)
if (error != 0) {
fprintf(stderr, "rdmsr to register %#x on vcpu %d\n",
vme->u.msr.code, *pvcpu);
- if (strictmsr)
- return (VMEXIT_ABORT);
+ if (strictmsr) {
+ error = vm_inject_exception2(ctx, *pvcpu, IDT_GP, 0);
+ assert(error == 0);
+ return (VMEXIT_RESTART);
+ }
}
eax = val;
@@ -350,8 +353,11 @@ vmexit_wrmsr(struct vmctx *ctx, struct vm_exit *vme, int *pvcpu)
if (error != 0) {
fprintf(stderr, "wrmsr to register %#x(%#lx) on vcpu %d\n",
vme->u.msr.code, vme->u.msr.wval, *pvcpu);
- if (strictmsr)
- return (VMEXIT_ABORT);
+ if (strictmsr) {
+ error = vm_inject_exception2(ctx, *pvcpu, IDT_GP, 0);
+ assert(error == 0);
+ return (VMEXIT_RESTART);
+ }
}
return (VMEXIT_CONTINUE);
}
OpenPOWER on IntegriCloud