summaryrefslogtreecommitdiffstats
path: root/lib/libvmmapi
diff options
context:
space:
mode:
authorsjg <sjg@FreeBSD.org>2014-04-27 08:13:43 +0000
committersjg <sjg@FreeBSD.org>2014-04-27 08:13:43 +0000
commit0c7e03a54c8e7ddc9c3fe710f83d9ca53173692e (patch)
treeb92e741b68057a24e381faa9809f32030d65574c /lib/libvmmapi
parentc244fcbcaa61dc2a15995e7dbdf3ae8107bc2111 (diff)
parent69c3e6933b6946c49fe99b19986f018d71621980 (diff)
downloadFreeBSD-src-0c7e03a54c8e7ddc9c3fe710f83d9ca53173692e.zip
FreeBSD-src-0c7e03a54c8e7ddc9c3fe710f83d9ca53173692e.tar.gz
Merge head
Diffstat (limited to 'lib/libvmmapi')
-rw-r--r--lib/libvmmapi/vmmapi.c161
-rw-r--r--lib/libvmmapi/vmmapi.h30
2 files changed, 161 insertions, 30 deletions
diff --git a/lib/libvmmapi/vmmapi.c b/lib/libvmmapi/vmmapi.c
index 810b39e..60d3105 100644
--- a/lib/libvmmapi/vmmapi.c
+++ b/lib/libvmmapi/vmmapi.c
@@ -342,36 +342,40 @@ vm_run(struct vmctx *ctx, int vcpu, uint64_t rip, struct vm_exit *vmexit)
return (error);
}
+int
+vm_suspend(struct vmctx *ctx)
+{
+
+ return (ioctl(ctx->fd, VM_SUSPEND, 0));
+}
+
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
@@ -397,6 +401,105 @@ vm_lapic_irq(struct vmctx *ctx, int vcpu, int vector)
}
int
+vm_lapic_local_irq(struct vmctx *ctx, int vcpu, int vector)
+{
+ struct vm_lapic_irq vmirq;
+
+ bzero(&vmirq, sizeof(vmirq));
+ vmirq.cpuid = vcpu;
+ vmirq.vector = vector;
+
+ return (ioctl(ctx->fd, VM_LAPIC_LOCAL_IRQ, &vmirq));
+}
+
+int
+vm_lapic_msi(struct vmctx *ctx, uint64_t addr, uint64_t msg)
+{
+ struct vm_lapic_msi vmmsi;
+
+ bzero(&vmmsi, sizeof(vmmsi));
+ vmmsi.addr = addr;
+ vmmsi.msg = msg;
+
+ return (ioctl(ctx->fd, VM_LAPIC_MSI, &vmmsi));
+}
+
+int
+vm_ioapic_assert_irq(struct vmctx *ctx, int irq)
+{
+ struct vm_ioapic_irq ioapic_irq;
+
+ bzero(&ioapic_irq, sizeof(struct vm_ioapic_irq));
+ ioapic_irq.irq = irq;
+
+ return (ioctl(ctx->fd, VM_IOAPIC_ASSERT_IRQ, &ioapic_irq));
+}
+
+int
+vm_ioapic_deassert_irq(struct vmctx *ctx, int irq)
+{
+ struct vm_ioapic_irq ioapic_irq;
+
+ bzero(&ioapic_irq, sizeof(struct vm_ioapic_irq));
+ ioapic_irq.irq = irq;
+
+ return (ioctl(ctx->fd, VM_IOAPIC_DEASSERT_IRQ, &ioapic_irq));
+}
+
+int
+vm_ioapic_pulse_irq(struct vmctx *ctx, int irq)
+{
+ struct vm_ioapic_irq ioapic_irq;
+
+ bzero(&ioapic_irq, sizeof(struct vm_ioapic_irq));
+ ioapic_irq.irq = irq;
+
+ return (ioctl(ctx->fd, VM_IOAPIC_PULSE_IRQ, &ioapic_irq));
+}
+
+int
+vm_ioapic_pincount(struct vmctx *ctx, int *pincount)
+{
+
+ return (ioctl(ctx->fd, VM_IOAPIC_PINCOUNT, pincount));
+}
+
+int
+vm_isa_assert_irq(struct vmctx *ctx, int atpic_irq, int ioapic_irq)
+{
+ struct vm_isa_irq isa_irq;
+
+ bzero(&isa_irq, sizeof(struct vm_isa_irq));
+ isa_irq.atpic_irq = atpic_irq;
+ isa_irq.ioapic_irq = ioapic_irq;
+
+ return (ioctl(ctx->fd, VM_ISA_ASSERT_IRQ, &isa_irq));
+}
+
+int
+vm_isa_deassert_irq(struct vmctx *ctx, int atpic_irq, int ioapic_irq)
+{
+ struct vm_isa_irq isa_irq;
+
+ bzero(&isa_irq, sizeof(struct vm_isa_irq));
+ isa_irq.atpic_irq = atpic_irq;
+ isa_irq.ioapic_irq = ioapic_irq;
+
+ return (ioctl(ctx->fd, VM_ISA_DEASSERT_IRQ, &isa_irq));
+}
+
+int
+vm_isa_pulse_irq(struct vmctx *ctx, int atpic_irq, int ioapic_irq)
+{
+ struct vm_isa_irq isa_irq;
+ bzero(&isa_irq, sizeof(struct vm_isa_irq));
+ isa_irq.atpic_irq = atpic_irq;
+ isa_irq.ioapic_irq = ioapic_irq;
+
+ return (ioctl(ctx->fd, VM_ISA_PULSE_IRQ, &isa_irq));
+}
+
+int
vm_inject_nmi(struct vmctx *ctx, int vcpu)
{
struct vm_nmi vmnmi;
@@ -415,6 +518,7 @@ static struct {
{ "mtrap_exit", VM_CAP_MTRAP_EXIT },
{ "pause_exit", VM_CAP_PAUSE_EXIT },
{ "unrestricted_guest", VM_CAP_UNRESTRICTED_GUEST },
+ { "enable_invpcid", VM_CAP_ENABLE_INVPCID },
{ 0 }
};
@@ -517,8 +621,8 @@ vm_map_pptdev_mmio(struct vmctx *ctx, int bus, int slot, int func,
}
int
-vm_setup_msi(struct vmctx *ctx, int vcpu, int bus, int slot, int func,
- int destcpu, int vector, int numvec)
+vm_setup_pptdev_msi(struct vmctx *ctx, int vcpu, int bus, int slot, int func,
+ uint64_t addr, uint64_t msg, int numvec)
{
struct vm_pptdev_msi pptmsi;
@@ -527,16 +631,16 @@ vm_setup_msi(struct vmctx *ctx, int vcpu, int bus, int slot, int func,
pptmsi.bus = bus;
pptmsi.slot = slot;
pptmsi.func = func;
- pptmsi.destcpu = destcpu;
- pptmsi.vector = vector;
+ pptmsi.msg = msg;
+ pptmsi.addr = addr;
pptmsi.numvec = numvec;
return (ioctl(ctx->fd, VM_PPTDEV_MSI, &pptmsi));
}
int
-vm_setup_msix(struct vmctx *ctx, int vcpu, int bus, int slot, int func,
- int idx, uint32_t msg, uint32_t vector_control, uint64_t addr)
+vm_setup_pptdev_msix(struct vmctx *ctx, int vcpu, int bus, int slot, int func,
+ int idx, uint64_t addr, uint64_t msg, uint32_t vector_control)
{
struct vm_pptdev_msix pptmsix;
@@ -791,3 +895,16 @@ vm_get_gpa_pmap(struct vmctx *ctx, uint64_t gpa, uint64_t *pte, int *num)
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);
+}
diff --git a/lib/libvmmapi/vmmapi.h b/lib/libvmmapi/vmmapi.h
index 0720e2e..ed63fb2 100644
--- a/lib/libvmmapi/vmmapi.h
+++ b/lib/libvmmapi/vmmapi.h
@@ -61,12 +61,20 @@ int vm_set_register(struct vmctx *ctx, int vcpu, int reg, uint64_t val);
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_suspend(struct vmctx *ctx);
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);
+int vm_ioapic_assert_irq(struct vmctx *ctx, int irq);
+int vm_ioapic_deassert_irq(struct vmctx *ctx, int irq);
+int vm_ioapic_pulse_irq(struct vmctx *ctx, int irq);
+int vm_ioapic_pincount(struct vmctx *ctx, int *pincount);
+int vm_isa_assert_irq(struct vmctx *ctx, int atpic_irq, int ioapic_irq);
+int vm_isa_deassert_irq(struct vmctx *ctx, int atpic_irq, int ioapic_irq);
+int vm_isa_pulse_irq(struct vmctx *ctx, int atpic_irq, int ioapic_irq);
int vm_inject_nmi(struct vmctx *ctx, int vcpu);
int vm_capability_name2type(const char *capname);
const char *vm_capability_type2name(int type);
@@ -78,10 +86,11 @@ int vm_assign_pptdev(struct vmctx *ctx, int bus, int slot, int func);
int vm_unassign_pptdev(struct vmctx *ctx, int bus, int slot, int func);
int vm_map_pptdev_mmio(struct vmctx *ctx, int bus, int slot, int func,
vm_paddr_t gpa, size_t len, vm_paddr_t hpa);
-int vm_setup_msi(struct vmctx *ctx, int vcpu, int bus, int slot, int func,
- int dest, int vector, int numvec);
-int vm_setup_msix(struct vmctx *ctx, int vcpu, int bus, int slot, int func,
- int idx, uint32_t msg, uint32_t vector_control, uint64_t addr);
+int vm_setup_pptdev_msi(struct vmctx *ctx, int vcpu, int bus, int slot,
+ int func, uint64_t addr, uint64_t msg, int numvec);
+int vm_setup_pptdev_msix(struct vmctx *ctx, int vcpu, int bus, int slot,
+ int func, int idx, uint64_t addr, uint64_t msg,
+ uint32_t vector_control);
/*
* Return a pointer to the statistics buffer. Note that this is not MT-safe.
@@ -93,6 +102,8 @@ const char *vm_get_stat_desc(struct vmctx *ctx, int index);
int vm_get_x2apic_state(struct vmctx *ctx, int vcpu, enum x2apic_state *s);
int vm_set_x2apic_state(struct vmctx *ctx, int vcpu, enum x2apic_state s);
+int vm_get_hpet_capabilities(struct vmctx *ctx, uint32_t *capabilities);
+
/* Reset vcpu register state */
int vcpu_reset(struct vmctx *ctx, int vcpu);
@@ -102,5 +113,8 @@ int vcpu_reset(struct vmctx *ctx, int vcpu);
int vm_setup_freebsd_registers(struct vmctx *ctx, int vcpu,
uint64_t rip, uint64_t cr3, uint64_t gdtbase,
uint64_t rsp);
+int vm_setup_freebsd_registers_i386(struct vmctx *vmctx, int vcpu,
+ uint32_t eip, uint32_t gdtbase,
+ uint32_t esp);
void vm_setup_freebsd_gdt(uint64_t *gdtr);
#endif /* _VMMAPI_H_ */
OpenPOWER on IntegriCloud