summaryrefslogtreecommitdiffstats
path: root/lib/libvmmapi/vmmapi.c
diff options
context:
space:
mode:
authorneel <neel@FreeBSD.org>2014-07-19 20:59:08 +0000
committerneel <neel@FreeBSD.org>2014-07-19 20:59:08 +0000
commit1f15eea2e088718478067efc8df6ecd1fc86dcee (patch)
tree5276627274ad6c55ba76fce7b924b9a9eef00e3d /lib/libvmmapi/vmmapi.c
parent79931797441bc166c7381ef7865f139e5cdb47e8 (diff)
downloadFreeBSD-src-1f15eea2e088718478067efc8df6ecd1fc86dcee.zip
FreeBSD-src-1f15eea2e088718478067efc8df6ecd1fc86dcee.tar.gz
Handle nested exceptions in bhyve.
A nested exception condition arises when a second exception is triggered while delivering the first exception. Most nested exceptions can be handled serially but some are converted into a double fault. If an exception is generated during delivery of a double fault then the virtual machine shuts down as a result of a triple fault. vm_exit_intinfo() is used to record that a VM-exit happened while an event was being delivered through the IDT. If an exception is triggered while handling the VM-exit it will be treated like a nested exception. vm_entry_intinfo() is used by processor-specific code to get the event to be injected into the guest on the next VM-entry. This function is responsible for deciding the disposition of nested exceptions.
Diffstat (limited to 'lib/libvmmapi/vmmapi.c')
-rw-r--r--lib/libvmmapi/vmmapi.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/libvmmapi/vmmapi.c b/lib/libvmmapi/vmmapi.c
index 9fb2308..483aa51 100644
--- a/lib/libvmmapi/vmmapi.c
+++ b/lib/libvmmapi/vmmapi.c
@@ -1106,3 +1106,32 @@ vm_activate_cpu(struct vmctx *ctx, int vcpu)
error = ioctl(ctx->fd, VM_ACTIVATE_CPU, &ac);
return (error);
}
+
+int
+vm_get_intinfo(struct vmctx *ctx, int vcpu, uint64_t *info1, uint64_t *info2)
+{
+ struct vm_intinfo vmii;
+ int error;
+
+ bzero(&vmii, sizeof(struct vm_intinfo));
+ vmii.vcpuid = vcpu;
+ error = ioctl(ctx->fd, VM_GET_INTINFO, &vmii);
+ if (error == 0) {
+ *info1 = vmii.info1;
+ *info2 = vmii.info2;
+ }
+ return (error);
+}
+
+int
+vm_set_intinfo(struct vmctx *ctx, int vcpu, uint64_t info1)
+{
+ struct vm_intinfo vmii;
+ int error;
+
+ bzero(&vmii, sizeof(struct vm_intinfo));
+ vmii.vcpuid = vcpu;
+ vmii.info1 = info1;
+ error = ioctl(ctx->fd, VM_SET_INTINFO, &vmii);
+ return (error);
+}
OpenPOWER on IntegriCloud