Page MenuHomeFreeBSD

D41002.diff
No OneTemporary

D41002.diff

diff --git a/lib/libvmmapi/amd64/vmmapi_machdep.c b/lib/libvmmapi/amd64/vmmapi_machdep.c
--- a/lib/libvmmapi/amd64/vmmapi_machdep.c
+++ b/lib/libvmmapi/amd64/vmmapi_machdep.c
@@ -275,6 +275,130 @@
return (vcpu_ioctl(vcpu, VM_INJECT_NMI, &vmnmi));
}
+int
+vm_inject_exception(struct vcpu *vcpu, int vector, int errcode_valid,
+ uint32_t errcode, int restart_instruction)
+{
+ struct vm_exception exc;
+
+ exc.vector = vector;
+ exc.error_code = errcode;
+ exc.error_code_valid = errcode_valid;
+ exc.restart_instruction = restart_instruction;
+
+ return (vcpu_ioctl(vcpu, VM_INJECT_EXCEPTION, &exc));
+}
+
+int
+vm_readwrite_kernemu_device(struct vcpu *vcpu, vm_paddr_t gpa,
+ bool write, int size, uint64_t *value)
+{
+ struct vm_readwrite_kernemu_device irp = {
+ .access_width = fls(size) - 1,
+ .gpa = gpa,
+ .value = write ? *value : ~0ul,
+ };
+ long cmd = (write ? VM_SET_KERNEMU_DEV : VM_GET_KERNEMU_DEV);
+ int rc;
+
+ rc = vcpu_ioctl(vcpu, cmd, &irp);
+ if (rc == 0 && !write)
+ *value = irp.value;
+ return (rc);
+}
+
+int
+vm_get_x2apic_state(struct vcpu *vcpu, enum x2apic_state *state)
+{
+ int error;
+ struct vm_x2apic x2apic;
+
+ bzero(&x2apic, sizeof(x2apic));
+
+ error = vcpu_ioctl(vcpu, VM_GET_X2APIC_STATE, &x2apic);
+ *state = x2apic.state;
+ return (error);
+}
+
+int
+vm_set_x2apic_state(struct vcpu *vcpu, enum x2apic_state state)
+{
+ int error;
+ struct vm_x2apic x2apic;
+
+ bzero(&x2apic, sizeof(x2apic));
+ x2apic.state = state;
+
+ error = vcpu_ioctl(vcpu, VM_SET_X2APIC_STATE, &x2apic);
+
+ return (error);
+}
+
+int
+vm_get_hpet_capabilities(struct vmctx *ctx, uint32_t *capabilities)
+{
+ int error;
+ struct vm_hpet_cap cap;
+
+ bzero(&cap, sizeof(struct vm_hpet_cap));
+ error = ioctl(ctx->fd, VM_GET_HPET_CAPABILITIES, &cap);
+ if (capabilities != NULL)
+ *capabilities = cap.capabilities;
+ return (error);
+}
+
+int
+vm_rtc_write(struct vmctx *ctx, int offset, uint8_t value)
+{
+ struct vm_rtc_data rtcdata;
+ int error;
+
+ bzero(&rtcdata, sizeof(struct vm_rtc_data));
+ rtcdata.offset = offset;
+ rtcdata.value = value;
+ error = ioctl(ctx->fd, VM_RTC_WRITE, &rtcdata);
+ return (error);
+}
+
+int
+vm_rtc_read(struct vmctx *ctx, int offset, uint8_t *retval)
+{
+ struct vm_rtc_data rtcdata;
+ int error;
+
+ bzero(&rtcdata, sizeof(struct vm_rtc_data));
+ rtcdata.offset = offset;
+ error = ioctl(ctx->fd, VM_RTC_READ, &rtcdata);
+ if (error == 0)
+ *retval = rtcdata.value;
+ return (error);
+}
+
+int
+vm_rtc_settime(struct vmctx *ctx, time_t secs)
+{
+ struct vm_rtc_time rtctime;
+ int error;
+
+ bzero(&rtctime, sizeof(struct vm_rtc_time));
+ rtctime.secs = secs;
+ error = ioctl(ctx->fd, VM_RTC_SETTIME, &rtctime);
+ return (error);
+}
+
+int
+vm_rtc_gettime(struct vmctx *ctx, time_t *secs)
+{
+ struct vm_rtc_time rtctime;
+ int error;
+
+ bzero(&rtctime, sizeof(struct vm_rtc_time));
+ error = ioctl(ctx->fd, VM_RTC_GETTIME, &rtctime);
+ if (error == 0)
+ *secs = rtctime.secs;
+ return (error);
+}
+
/*
* From Intel Vol 3a:
* Table 9-1. IA-32 Processor States Following Power-up, Reset or INIT
diff --git a/lib/libvmmapi/vmmapi.h b/lib/libvmmapi/vmmapi.h
--- a/lib/libvmmapi/vmmapi.h
+++ b/lib/libvmmapi/vmmapi.h
@@ -158,9 +158,9 @@
int vm_suspend(struct vmctx *ctx, enum vm_suspend_how how);
int vm_reinit(struct vmctx *ctx);
int vm_apicid2vcpu(struct vmctx *ctx, int apicid);
+#ifdef __amd64__
int vm_inject_exception(struct vcpu *vcpu, int vector,
int errcode_valid, uint32_t errcode, int restart_instruction);
-#ifdef __amd64__
int vm_lapic_irq(struct vcpu *vcpu, int vector);
int vm_lapic_local_irq(struct vcpu *vcpu, int vector);
int vm_lapic_msi(struct vmctx *ctx, uint64_t addr, uint64_t msg);
@@ -174,9 +174,9 @@
int vm_isa_set_irq_trigger(struct vmctx *ctx, int atpic_irq,
enum vm_intr_trigger trigger);
int vm_inject_nmi(struct vcpu *vcpu);
-#endif
int vm_readwrite_kernemu_device(struct vcpu *vcpu,
vm_paddr_t gpa, bool write, int size, uint64_t *value);
+#endif
int vm_capability_name2type(const char *capname);
const char *vm_capability_type2name(int type);
int vm_get_capability(struct vcpu *vcpu, enum vm_cap_type cap,
@@ -206,10 +206,12 @@
int *ret_entries);
const char *vm_get_stat_desc(struct vmctx *ctx, int index);
+#ifdef __amd64__
int vm_get_x2apic_state(struct vcpu *vcpu, enum x2apic_state *s);
int vm_set_x2apic_state(struct vcpu *vcpu, enum x2apic_state s);
int vm_get_hpet_capabilities(struct vmctx *ctx, uint32_t *capabilities);
+#endif
/*
* Translate the GLA range [gla,gla+len) into GPA segments in 'iov'.
@@ -227,11 +229,13 @@
void vm_copyout(const void *host_src, struct iovec *guest_iov, size_t len);
void vm_copy_teardown(struct iovec *iov, int iovcnt);
+#ifdef __amd64__
/* RTC */
int vm_rtc_write(struct vmctx *ctx, int offset, uint8_t value);
int vm_rtc_read(struct vmctx *ctx, int offset, uint8_t *retval);
int vm_rtc_settime(struct vmctx *ctx, time_t secs);
int vm_rtc_gettime(struct vmctx *ctx, time_t *secs);
+#endif
/* Reset vcpu register state */
int vcpu_reset(struct vcpu *vcpu);
diff --git a/lib/libvmmapi/vmmapi.c b/lib/libvmmapi/vmmapi.c
--- a/lib/libvmmapi/vmmapi.c
+++ b/lib/libvmmapi/vmmapi.c
@@ -679,38 +679,6 @@
return (ioctl(ctx->fd, VM_REINIT, 0));
}
-int
-vm_inject_exception(struct vcpu *vcpu, int vector, int errcode_valid,
- uint32_t errcode, int restart_instruction)
-{
- struct vm_exception exc;
-
- exc.vector = vector;
- exc.error_code = errcode;
- exc.error_code_valid = errcode_valid;
- exc.restart_instruction = restart_instruction;
-
- return (vcpu_ioctl(vcpu, VM_INJECT_EXCEPTION, &exc));
-}
-
-int
-vm_readwrite_kernemu_device(struct vcpu *vcpu, vm_paddr_t gpa,
- bool write, int size, uint64_t *value)
-{
- struct vm_readwrite_kernemu_device irp = {
- .access_width = fls(size) - 1,
- .gpa = gpa,
- .value = write ? *value : ~0ul,
- };
- long cmd = (write ? VM_SET_KERNEMU_DEV : VM_GET_KERNEMU_DEV);
- int rc;
-
- rc = vcpu_ioctl(vcpu, cmd, &irp);
- if (rc == 0 && !write)
- *value = irp.value;
- return (rc);
-}
-
int
vm_capability_name2type(const char *capname)
{
@@ -924,33 +892,6 @@
return (NULL);
}
-int
-vm_get_x2apic_state(struct vcpu *vcpu, enum x2apic_state *state)
-{
- int error;
- struct vm_x2apic x2apic;
-
- bzero(&x2apic, sizeof(x2apic));
-
- error = vcpu_ioctl(vcpu, VM_GET_X2APIC_STATE, &x2apic);
- *state = x2apic.state;
- return (error);
-}
-
-int
-vm_set_x2apic_state(struct vcpu *vcpu, enum x2apic_state state)
-{
- int error;
- struct vm_x2apic x2apic;
-
- bzero(&x2apic, sizeof(x2apic));
- x2apic.state = state;
-
- error = vcpu_ioctl(vcpu, VM_SET_X2APIC_STATE, &x2apic);
-
- return (error);
-}
-
int
vm_get_gpa_pmap(struct vmctx *ctx, uint64_t gpa, uint64_t *pte, int *num)
{
@@ -971,19 +912,6 @@
return (error);
}
-int
-vm_get_hpet_capabilities(struct vmctx *ctx, uint32_t *capabilities)
-{
- int error;
- struct vm_hpet_cap cap;
-
- bzero(&cap, sizeof(struct vm_hpet_cap));
- error = ioctl(ctx->fd, VM_GET_HPET_CAPABILITIES, &cap);
- if (capabilities != NULL)
- *capabilities = cap.capabilities;
- return (error);
-}
-
int
vm_gla2gpa(struct vcpu *vcpu, struct vm_guest_paging *paging,
uint64_t gla, int prot, uint64_t *gpa, int *fault)
@@ -1236,58 +1164,6 @@
return (error);
}
-int
-vm_rtc_write(struct vmctx *ctx, int offset, uint8_t value)
-{
- struct vm_rtc_data rtcdata;
- int error;
-
- bzero(&rtcdata, sizeof(struct vm_rtc_data));
- rtcdata.offset = offset;
- rtcdata.value = value;
- error = ioctl(ctx->fd, VM_RTC_WRITE, &rtcdata);
- return (error);
-}
-
-int
-vm_rtc_read(struct vmctx *ctx, int offset, uint8_t *retval)
-{
- struct vm_rtc_data rtcdata;
- int error;
-
- bzero(&rtcdata, sizeof(struct vm_rtc_data));
- rtcdata.offset = offset;
- error = ioctl(ctx->fd, VM_RTC_READ, &rtcdata);
- if (error == 0)
- *retval = rtcdata.value;
- return (error);
-}
-
-int
-vm_rtc_settime(struct vmctx *ctx, time_t secs)
-{
- struct vm_rtc_time rtctime;
- int error;
-
- bzero(&rtctime, sizeof(struct vm_rtc_time));
- rtctime.secs = secs;
- error = ioctl(ctx->fd, VM_RTC_SETTIME, &rtctime);
- return (error);
-}
-
-int
-vm_rtc_gettime(struct vmctx *ctx, time_t *secs)
-{
- struct vm_rtc_time rtctime;
- int error;
-
- bzero(&rtctime, sizeof(struct vm_rtc_time));
- error = ioctl(ctx->fd, VM_RTC_GETTIME, &rtctime);
- if (error == 0)
- *secs = rtctime.secs;
- return (error);
-}
-
int
vm_restart_instruction(struct vcpu *vcpu)
{

File Metadata

Mime Type
text/plain
Expires
Fri, Jan 24, 10:23 PM (20 h, 39 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
16107049
Default Alt Text
D41002.diff (8 KB)

Event Timeline