Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/bhyve/bhyverun.c
Show First 20 Lines • Show All 106 Lines • ▼ Show 20 Lines | |||||
#ifdef BHYVE_SNAPSHOT | #ifdef BHYVE_SNAPSHOT | ||||
#include "snapshot.h" | #include "snapshot.h" | ||||
#endif | #endif | ||||
#include "xmsr.h" | #include "xmsr.h" | ||||
#include "spinup_ap.h" | #include "spinup_ap.h" | ||||
#include "rtc.h" | #include "rtc.h" | ||||
#include "vmgenc.h" | #include "vmgenc.h" | ||||
#define GUEST_NIO_PORT 0x488 /* guest upcalls via i/o port */ | |||||
#define MB (1024UL * 1024) | #define MB (1024UL * 1024) | ||||
#define GB (1024UL * MB) | #define GB (1024UL * MB) | ||||
static const char * const vmx_exit_reason_desc[] = { | static const char * const vmx_exit_reason_desc[] = { | ||||
[EXIT_REASON_EXCEPTION] = "Exception or non-maskable interrupt (NMI)", | [EXIT_REASON_EXCEPTION] = "Exception or non-maskable interrupt (NMI)", | ||||
[EXIT_REASON_EXT_INTR] = "External interrupt", | [EXIT_REASON_EXT_INTR] = "External interrupt", | ||||
[EXIT_REASON_TRIPLE_FAULT] = "Triple fault", | [EXIT_REASON_TRIPLE_FAULT] = "Triple fault", | ||||
[EXIT_REASON_INIT] = "INIT signal", | [EXIT_REASON_INIT] = "INIT signal", | ||||
▲ Show 20 Lines • Show All 435 Lines • ▼ Show 20 Lines | if (!CPU_ISSET(vcpu, &cpumask)) { | ||||
exit(4); | exit(4); | ||||
} | } | ||||
CPU_CLR_ATOMIC(vcpu, &cpumask); | CPU_CLR_ATOMIC(vcpu, &cpumask); | ||||
return (CPU_EMPTY(&cpumask)); | return (CPU_EMPTY(&cpumask)); | ||||
} | } | ||||
static int | static int | ||||
vmexit_handle_notify(struct vmctx *ctx __unused, struct vcpu *vcpu __unused, | |||||
struct vm_exit *vme __unused, uint32_t eax __unused) | |||||
{ | |||||
#if BHYVE_DEBUG | |||||
/* | |||||
* put guest-driven debug here | |||||
*/ | |||||
#endif | |||||
return (VMEXIT_CONTINUE); | |||||
} | |||||
static int | |||||
vmexit_inout(struct vmctx *ctx, struct vcpu *vcpu, struct vm_run *vmrun) | vmexit_inout(struct vmctx *ctx, struct vcpu *vcpu, struct vm_run *vmrun) | ||||
{ | { | ||||
struct vm_exit *vme; | struct vm_exit *vme; | ||||
int error; | int error; | ||||
int bytes, port, in, out; | int bytes, port, in; | ||||
vme = vmrun->vm_exit; | vme = vmrun->vm_exit; | ||||
port = vme->u.inout.port; | port = vme->u.inout.port; | ||||
bytes = vme->u.inout.bytes; | bytes = vme->u.inout.bytes; | ||||
in = vme->u.inout.in; | in = vme->u.inout.in; | ||||
out = !in; | |||||
/* Extra-special case of host notifications */ | |||||
if (out && port == GUEST_NIO_PORT) { | |||||
error = vmexit_handle_notify(ctx, vcpu, vme, vme->u.inout.eax); | |||||
return (error); | |||||
} | |||||
error = emulate_inout(ctx, vcpu, vme); | error = emulate_inout(ctx, vcpu, vme); | ||||
if (error) { | if (error) { | ||||
fprintf(stderr, "Unhandled %s%c 0x%04x at 0x%lx\n", | fprintf(stderr, "Unhandled %s%c 0x%04x at 0x%lx\n", | ||||
in ? "in" : "out", | in ? "in" : "out", | ||||
bytes == 1 ? 'b' : (bytes == 2 ? 'w' : 'l'), | bytes == 1 ? 'b' : (bytes == 2 ? 'w' : 'l'), | ||||
port, vme->rip); | port, vme->rip); | ||||
return (VMEXIT_ABORT); | return (VMEXIT_ABORT); | ||||
▲ Show 20 Lines • Show All 1,046 Lines • Show Last 20 Lines |