summaryrefslogtreecommitdiffstats
path: root/lib/libvmmapi
diff options
context:
space:
mode:
authorneel <neel@FreeBSD.org>2014-02-26 00:52:05 +0000
committerneel <neel@FreeBSD.org>2014-02-26 00:52:05 +0000
commite01c440daea522b6348de5695e461ebda1d2f3b6 (patch)
tree8e63c8e98cb02ff5f17c88bfa673ac8eecb9736c /lib/libvmmapi
parentaa58833be65d477dac0e6cae4abd965e96601b0a (diff)
downloadFreeBSD-src-e01c440daea522b6348de5695e461ebda1d2f3b6.zip
FreeBSD-src-e01c440daea522b6348de5695e461ebda1d2f3b6.tar.gz
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. The order of event injection into the guest is: - hardware exception - NMI - maskable interrupt In the Intel VT-x case, a pending NMI or interrupt will enable the interrupt window-exiting and inject it as soon as possible after the hardware exception is injected. Also since interrupts are inherently asynchronous, injecting them after the hardware exception should not affect correctness from the guest perspective. 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. Discussed with: grehan, jhb Reviewed by: jhb
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