summaryrefslogtreecommitdiff
path: root/usr/src/lib
diff options
context:
space:
mode:
authorPatrick Mooney <pmooney@pfmooney.com>2020-11-03 02:16:48 +0000
committerPatrick Mooney <pmooney@oxide.computer>2021-01-08 22:12:27 +0000
commit2606939d92dd3044a9851b2930ebf533c3c03892 (patch)
tree0732de0c5fa81e77230ed8909d0c6a2bfd42dcca /usr/src/lib
parent78f846c0ab4f41678386d3e1b49c16cc8db07a8b (diff)
downloadillumos-joyent-2606939d92dd3044a9851b2930ebf533c3c03892.tar.gz
13275 bhyve needs richer INIT/SIPI support
Reviewed by: Robert Mustacchi <rm@fingolfin.org> Approved by: Gordon Ross <gordon.w.ross@gmail.com>
Diffstat (limited to 'usr/src/lib')
-rw-r--r--usr/src/lib/libvmmapi/common/mapfile-vers2
-rw-r--r--usr/src/lib/libvmmapi/common/vmmapi.c46
-rw-r--r--usr/src/lib/libvmmapi/common/vmmapi.h4
3 files changed, 52 insertions, 0 deletions
diff --git a/usr/src/lib/libvmmapi/common/mapfile-vers b/usr/src/lib/libvmmapi/common/mapfile-vers
index 9e972b8d60..26cfd15426 100644
--- a/usr/src/lib/libvmmapi/common/mapfile-vers
+++ b/usr/src/lib/libvmmapi/common/mapfile-vers
@@ -123,6 +123,8 @@ SYMBOL_VERSION ILLUMOSprivate {
vm_unassign_pptdev;
vm_pmtmr_set_location;
vm_wrlock_cycle;
+ vm_get_run_state;
+ vm_set_run_state;
local:
*;
diff --git a/usr/src/lib/libvmmapi/common/vmmapi.c b/usr/src/lib/libvmmapi/common/vmmapi.c
index 5b2cb4c235..0b22ca7522 100644
--- a/usr/src/lib/libvmmapi/common/vmmapi.c
+++ b/usr/src/lib/libvmmapi/common/vmmapi.c
@@ -1302,6 +1302,18 @@ vm_set_x2apic_state(struct vmctx *ctx, int vcpu, enum x2apic_state state)
return (error);
}
+#ifndef __FreeBSD__
+int
+vcpu_reset(struct vmctx *vmctx, int vcpu)
+{
+ struct vm_vcpu_reset vvr;
+
+ vvr.vcpuid = vcpu;
+ vvr.kind = VRK_RESET;
+
+ return (ioctl(vmctx->fd, VM_RESET_CPU, &vvr));
+}
+#else /* __FreeBSD__ */
/*
* From Intel Vol 3a:
* Table 9-1. IA-32 Processor States Following Power-up, Reset or INIT
@@ -1458,6 +1470,7 @@ vcpu_reset(struct vmctx *vmctx, int vcpu)
done:
return (error);
}
+#endif /* __FreeBSD__ */
int
vm_get_gpa_pmap(struct vmctx *ctx, uint64_t gpa, uint64_t *pte, int *num)
@@ -1839,6 +1852,39 @@ vm_wrlock_cycle(struct vmctx *ctx)
}
return (0);
}
+
+int
+vm_get_run_state(struct vmctx *ctx, int vcpu, enum vcpu_run_state *state,
+ uint8_t *sipi_vector)
+{
+ struct vm_run_state data;
+
+ data.vcpuid = vcpu;
+ if (ioctl(ctx->fd, VM_GET_RUN_STATE, &data) != 0) {
+ return (errno);
+ }
+
+ *state = data.state;
+ *sipi_vector = data.sipi_vector;
+ return (0);
+}
+
+int
+vm_set_run_state(struct vmctx *ctx, int vcpu, enum vcpu_run_state state,
+ uint8_t sipi_vector)
+{
+ struct vm_run_state data;
+
+ data.vcpuid = vcpu;
+ data.state = state;
+ data.sipi_vector = sipi_vector;
+ if (ioctl(ctx->fd, VM_SET_RUN_STATE, &data) != 0) {
+ return (errno);
+ }
+
+ return (0);
+}
+
#endif /* __FreeBSD__ */
#ifdef __FreeBSD__
diff --git a/usr/src/lib/libvmmapi/common/vmmapi.h b/usr/src/lib/libvmmapi/common/vmmapi.h
index 96102ec925..f7aaa02087 100644
--- a/usr/src/lib/libvmmapi/common/vmmapi.h
+++ b/usr/src/lib/libvmmapi/common/vmmapi.h
@@ -304,6 +304,10 @@ int vm_get_topology(struct vmctx *ctx, uint16_t *sockets, uint16_t *cores,
/* illumos-specific APIs */
int vm_pmtmr_set_location(struct vmctx *ctx, uint16_t ioport);
int vm_wrlock_cycle(struct vmctx *ctx);
+int vm_get_run_state(struct vmctx *ctx, int vcpu, enum vcpu_run_state *state,
+ uint8_t *sipi_vector);
+int vm_set_run_state(struct vmctx *ctx, int vcpu, enum vcpu_run_state state,
+ uint8_t sipi_vector);
#endif /* __FreeBSD__ */
#ifdef __FreeBSD__