Changeset View
Changeset View
Standalone View
Standalone View
lib/libvmmapi/vmmapi.c
| Show First 20 Lines • Show All 118 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| struct vmctx *vm; | struct vmctx *vm; | ||||
| vm = malloc(sizeof(struct vmctx) + strlen(name) + 1); | vm = malloc(sizeof(struct vmctx) + strlen(name) + 1); | ||||
| assert(vm != NULL); | assert(vm != NULL); | ||||
| vm->fd = -1; | vm->fd = -1; | ||||
| vm->memflags = 0; | vm->memflags = 0; | ||||
| vm->lowmem_limit = 3 * GB; | vm->lowmem_limit = 3 * GB; | ||||
grehan: This will hurt 32-bit VMs. However, it is possible to change this at runtime, though it has to… | |||||
| vm->name = (char *)(vm + 1); | vm->name = (char *)(vm + 1); | ||||
| strcpy(vm->name, name); | strcpy(vm->name, name); | ||||
| if ((vm->fd = vm_device_open(vm->name)) < 0) | if ((vm->fd = vm_device_open(vm->name)) < 0) | ||||
| goto err; | goto err; | ||||
| return (vm); | return (vm); | ||||
| err: | err: | ||||
| ▲ Show 20 Lines • Show All 840 Lines • ▼ Show 20 Lines | vm_map_pptdev_mmio(struct vmctx *ctx, int bus, int slot, int func, | ||||
| pptmmio.gpa = gpa; | pptmmio.gpa = gpa; | ||||
| pptmmio.len = len; | pptmmio.len = len; | ||||
| pptmmio.hpa = hpa; | pptmmio.hpa = hpa; | ||||
| return (ioctl(ctx->fd, VM_MAP_PPTDEV_MMIO, &pptmmio)); | return (ioctl(ctx->fd, VM_MAP_PPTDEV_MMIO, &pptmmio)); | ||||
| } | } | ||||
| int | int | ||||
| vm_unmap_pptdev_mmio(struct vmctx *ctx, int bus, int slot, int func, | |||||
| vm_paddr_t gpa, size_t len) | |||||
| { | |||||
| struct vm_pptdev_mmio pptmmio; | |||||
| bzero(&pptmmio, sizeof(pptmmio)); | |||||
| pptmmio.bus = bus; | |||||
| pptmmio.slot = slot; | |||||
| pptmmio.func = func; | |||||
| pptmmio.gpa = gpa; | |||||
| pptmmio.len = len; | |||||
| pptmmio.hpa = 0; | |||||
| if (gpa == 0) | |||||
| return (0); | |||||
| return (ioctl(ctx->fd, VM_UNMAP_PPTDEV_MMIO, &pptmmio)); | |||||
| } | |||||
| int | |||||
| vm_setup_pptdev_msi(struct vmctx *ctx, int vcpu, int bus, int slot, int func, | vm_setup_pptdev_msi(struct vmctx *ctx, int vcpu, int bus, int slot, int func, | ||||
| uint64_t addr, uint64_t msg, int numvec) | uint64_t addr, uint64_t msg, int numvec) | ||||
| { | { | ||||
| struct vm_pptdev_msi pptmsi; | struct vm_pptdev_msi pptmsi; | ||||
| bzero(&pptmsi, sizeof(pptmsi)); | bzero(&pptmsi, sizeof(pptmsi)); | ||||
| pptmsi.vcpu = vcpu; | pptmsi.vcpu = vcpu; | ||||
| pptmsi.bus = bus; | pptmsi.bus = bus; | ||||
| ▲ Show 20 Lines • Show All 643 Lines • ▼ Show 20 Lines | static const cap_ioctl_t vm_ioctl_cmds[] = { VM_RUN, VM_SUSPEND, VM_REINIT, | ||||
| VM_SET_SEGMENT_DESCRIPTOR, VM_GET_SEGMENT_DESCRIPTOR, | VM_SET_SEGMENT_DESCRIPTOR, VM_GET_SEGMENT_DESCRIPTOR, | ||||
| VM_SET_REGISTER_SET, VM_GET_REGISTER_SET, | VM_SET_REGISTER_SET, VM_GET_REGISTER_SET, | ||||
| VM_SET_KERNEMU_DEV, VM_GET_KERNEMU_DEV, | VM_SET_KERNEMU_DEV, VM_GET_KERNEMU_DEV, | ||||
| VM_INJECT_EXCEPTION, VM_LAPIC_IRQ, VM_LAPIC_LOCAL_IRQ, | VM_INJECT_EXCEPTION, VM_LAPIC_IRQ, VM_LAPIC_LOCAL_IRQ, | ||||
| VM_LAPIC_MSI, VM_IOAPIC_ASSERT_IRQ, VM_IOAPIC_DEASSERT_IRQ, | VM_LAPIC_MSI, VM_IOAPIC_ASSERT_IRQ, VM_IOAPIC_DEASSERT_IRQ, | ||||
| VM_IOAPIC_PULSE_IRQ, VM_IOAPIC_PINCOUNT, VM_ISA_ASSERT_IRQ, | VM_IOAPIC_PULSE_IRQ, VM_IOAPIC_PINCOUNT, VM_ISA_ASSERT_IRQ, | ||||
| VM_ISA_DEASSERT_IRQ, VM_ISA_PULSE_IRQ, VM_ISA_SET_IRQ_TRIGGER, | VM_ISA_DEASSERT_IRQ, VM_ISA_PULSE_IRQ, VM_ISA_SET_IRQ_TRIGGER, | ||||
| VM_SET_CAPABILITY, VM_GET_CAPABILITY, VM_BIND_PPTDEV, | VM_SET_CAPABILITY, VM_GET_CAPABILITY, VM_BIND_PPTDEV, | ||||
| VM_UNBIND_PPTDEV, VM_MAP_PPTDEV_MMIO, VM_PPTDEV_MSI, | VM_UNBIND_PPTDEV, VM_MAP_PPTDEV_MMIO, VM_UNMAP_PPTDEV_MMIO, VM_PPTDEV_MSI, | ||||
| VM_PPTDEV_MSIX, VM_INJECT_NMI, VM_STATS, VM_STAT_DESC, | VM_PPTDEV_MSIX, VM_INJECT_NMI, VM_STATS, VM_STAT_DESC, | ||||
| VM_SET_X2APIC_STATE, VM_GET_X2APIC_STATE, | VM_SET_X2APIC_STATE, VM_GET_X2APIC_STATE, | ||||
| VM_GET_HPET_CAPABILITIES, VM_GET_GPA_PMAP, VM_GLA2GPA, | VM_GET_HPET_CAPABILITIES, VM_GET_GPA_PMAP, VM_GLA2GPA, | ||||
| VM_GLA2GPA_NOFAULT, | VM_GLA2GPA_NOFAULT, | ||||
| VM_ACTIVATE_CPU, VM_GET_CPUS, VM_SUSPEND_CPU, VM_RESUME_CPU, | VM_ACTIVATE_CPU, VM_GET_CPUS, VM_SUSPEND_CPU, VM_RESUME_CPU, | ||||
| VM_SET_INTINFO, VM_GET_INTINFO, | VM_SET_INTINFO, VM_GET_INTINFO, | ||||
| VM_RTC_WRITE, VM_RTC_READ, VM_RTC_SETTIME, VM_RTC_GETTIME, | VM_RTC_WRITE, VM_RTC_READ, VM_RTC_SETTIME, VM_RTC_GETTIME, | ||||
| VM_RESTART_INSTRUCTION, VM_SET_TOPOLOGY, VM_GET_TOPOLOGY }; | VM_RESTART_INSTRUCTION, VM_SET_TOPOLOGY, VM_GET_TOPOLOGY }; | ||||
| Show All 12 Lines | |||||
This will hurt 32-bit VMs. However, it is possible to change this at runtime, though it has to be done prior to PCI config.