summaryrefslogtreecommitdiffstats
path: root/lib/libvmmapi
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 /lib/libvmmapi
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 'lib/libvmmapi')
-rw-r--r--lib/libvmmapi/vmmapi.c29
-rw-r--r--lib/libvmmapi/vmmapi.h6
2 files changed, 15 insertions, 20 deletions
diff --git a/lib/libvmmapi/vmmapi.c b/lib/libvmmapi/vmmapi.c
index eba3367..7198c99 100644
--- a/lib/libvmmapi/vmmapi.c
+++ b/lib/libvmmapi/vmmapi.c
@@ -343,35 +343,32 @@ vm_run(struct vmctx *ctx, int vcpu, uint64_t rip, struct vm_exit *vmexit)
}
static int
-vm_inject_event_real(struct vmctx *ctx, int vcpu, enum vm_event_type type,
- int vector, int error_code, int error_code_valid)
+vm_inject_exception_real(struct vmctx *ctx, int vcpu, int vector,
+ int error_code, int error_code_valid)
{
- struct vm_event ev;
+ struct vm_exception exc;
- bzero(&ev, sizeof(ev));
- ev.cpuid = vcpu;
- ev.type = type;
- ev.vector = vector;
- ev.error_code = error_code;
- ev.error_code_valid = error_code_valid;
+ bzero(&exc, sizeof(exc));
+ exc.cpuid = vcpu;
+ exc.vector = vector;
+ exc.error_code = error_code;
+ exc.error_code_valid = error_code_valid;
- return (ioctl(ctx->fd, VM_INJECT_EVENT, &ev));
+ return (ioctl(ctx->fd, VM_INJECT_EXCEPTION, &exc));
}
int
-vm_inject_event(struct vmctx *ctx, int vcpu, enum vm_event_type type,
- int vector)
+vm_inject_exception(struct vmctx *ctx, int vcpu, int vector)
{
- return (vm_inject_event_real(ctx, vcpu, type, vector, 0, 0));
+ return (vm_inject_exception_real(ctx, vcpu, vector, 0, 0));
}
int
-vm_inject_event2(struct vmctx *ctx, int vcpu, enum vm_event_type type,
- int vector, int error_code)
+vm_inject_exception2(struct vmctx *ctx, int vcpu, int vector, int errcode)
{
- return (vm_inject_event_real(ctx, vcpu, type, vector, error_code, 1));
+ return (vm_inject_exception_real(ctx, vcpu, vector, errcode, 1));
}
int
diff --git a/lib/libvmmapi/vmmapi.h b/lib/libvmmapi/vmmapi.h
index 4a3db5d..dcb5a98 100644
--- a/lib/libvmmapi/vmmapi.h
+++ b/lib/libvmmapi/vmmapi.h
@@ -62,10 +62,8 @@ int vm_get_register(struct vmctx *ctx, int vcpu, int reg, uint64_t *retval);
int vm_run(struct vmctx *ctx, int vcpu, uint64_t rip,
struct vm_exit *ret_vmexit);
int vm_apicid2vcpu(struct vmctx *ctx, int apicid);
-int vm_inject_event(struct vmctx *ctx, int vcpu, enum vm_event_type type,
- int vector);
-int vm_inject_event2(struct vmctx *ctx, int vcpu, enum vm_event_type type,
- int vector, int error_code);
+int vm_inject_exception(struct vmctx *ctx, int vcpu, int vec);
+int vm_inject_exception2(struct vmctx *ctx, int vcpu, int vec, int errcode);
int vm_lapic_irq(struct vmctx *ctx, int vcpu, int vector);
int vm_lapic_local_irq(struct vmctx *ctx, int vcpu, int vector);
int vm_lapic_msi(struct vmctx *ctx, uint64_t addr, uint64_t msg);
OpenPOWER on IntegriCloud