diff options
-rw-r--r-- | Makefile | 6 | ||||
-rw-r--r-- | kvm.h | 369 | ||||
-rw-r--r-- | kvm_bitops.h | 73 |
3 files changed, 215 insertions, 233 deletions
@@ -16,6 +16,10 @@ CSTYLE=$(KERNEL_SOURCE)/usr/src/tools/scripts/cstyle all: kvm kvm.so +HEADERS= \ + kvm.h \ + kvm_bitops.h + kvm: kvm.c kvm_x86.c kvm_emulate.c kvm.h kvm_x86host.h msr.h kvm_bitops.h kvm_subr.c kvm_irq.c kvm_i8254.c kvm_lapic.c kvm_mmu.c kvm_iodev.c kvm_ioapic.c kvm_vmx.c kvm_i8259.c kvm_coalesced_mmio.c kvm_irq_comm.c kvm_cache_regs.c kvm_bitops.c $(CC) $(CFLAGS) $(INCLUDEDIR) kvm.c $(CC) $(CFLAGS) $(INCLUDEDIR) kvm_x86.c @@ -63,7 +67,7 @@ install: kvm @pfexec cp kvm.conf /usr/kernel/drv check: - @$(CSTYLE) kvm.c kvm_mdb.c kvm_emulate.c kvm_x86.c kvm_irq.c kvm_lapic.c kvm_i8254.c kvm_mmu.c kvm_iodev.c kvm_subr.c kvm_ioapic.c kvm_vmx.c kvm_i8259.c kvm_coalesced_mmio.c kvm_irq_comm.c kvm_cache_regs.c kvm_bitops.c + @$(CSTYLE) kvm.c kvm_mdb.c kvm_emulate.c kvm_x86.c kvm_irq.c kvm_lapic.c kvm_i8254.c kvm_mmu.c kvm_iodev.c kvm_subr.c kvm_ioapic.c kvm_vmx.c kvm_i8259.c kvm_coalesced_mmio.c kvm_irq_comm.c kvm_cache_regs.c kvm_bitops.c $(HEADERS) @./tools/xxxcheck kvm_x86.c kvm.c kvm_irq.c kvm_lapic.c kvm_i8254.c kvm_mmu.c kvm_iodev.c kvm_ioapic.c kvm_vmx.c kvm_i8259.c kvm_coalesced_mmio.c kvm_irq_comm.c kvm_cache_regs.c kvm_bitops.c load: install @@ -1,11 +1,11 @@ #ifndef __KVM_H -#define __KVM_H +#define __KVM_H #include <sys/types.h> #include <sys/param.h> #include "kvm_x86.h" -#define KVM_API_VERSION 12 /* same as linux (for qemu compatability...) */ +#define KVM_API_VERSION 12 /* same as linux (for qemu compatability...) */ /* for KVM_CREATE_MEMORY_REGION */ typedef struct kvm_memory_region { @@ -25,8 +25,8 @@ typedef struct kvm_userspace_memory_region { } kvm_userspace_memory_region_t; /* for kvm_memory_region::flags */ -#define KVM_MEM_LOG_DIRTY_PAGES 1UL -#define KVM_MEMSLOT_INVALID (1UL << 1) +#define KVM_MEM_LOG_DIRTY_PAGES 1UL +#define KVM_MEMSLOT_INVALID (1UL << 1) /* for KVM_IRQ_LINE */ typedef struct kvm_irq_level { @@ -45,7 +45,7 @@ typedef struct kvm_irq_level { typedef struct kvm_irqchip { uint32_t chip_id; uint32_t pad; - union { + union { char dummy[512]; /* reserving space */ struct kvm_pic_state pic; struct kvm_ioapic_state ioapic; @@ -58,30 +58,30 @@ typedef struct kvm_pit_config { uint32_t pad[15]; } kvm_pit_config_t; -#define KVM_PIT_SPEAKER_DUMMY 1 - -#define KVM_EXIT_UNKNOWN 0 -#define KVM_EXIT_EXCEPTION 1 -#define KVM_EXIT_IO 2 -#define KVM_EXIT_HYPERCALL 3 -#define KVM_EXIT_DEBUG 4 -#define KVM_EXIT_HLT 5 -#define KVM_EXIT_MMIO 6 -#define KVM_EXIT_IRQ_WINDOW_OPEN 7 -#define KVM_EXIT_SHUTDOWN 8 -#define KVM_EXIT_FAIL_ENTRY 9 -#define KVM_EXIT_INTR 10 -#define KVM_EXIT_SET_TPR 11 -#define KVM_EXIT_TPR_ACCESS 12 -#define KVM_EXIT_S390_SIEIC 13 -#define KVM_EXIT_S390_RESET 14 -#define KVM_EXIT_DCR 15 -#define KVM_EXIT_NMI 16 -#define KVM_EXIT_INTERNAL_ERROR 17 +#define KVM_PIT_SPEAKER_DUMMY 1 + +#define KVM_EXIT_UNKNOWN 0 +#define KVM_EXIT_EXCEPTION 1 +#define KVM_EXIT_IO 2 +#define KVM_EXIT_HYPERCALL 3 +#define KVM_EXIT_DEBUG 4 +#define KVM_EXIT_HLT 5 +#define KVM_EXIT_MMIO 6 +#define KVM_EXIT_IRQ_WINDOW_OPEN 7 +#define KVM_EXIT_SHUTDOWN 8 +#define KVM_EXIT_FAIL_ENTRY 9 +#define KVM_EXIT_INTR 10 +#define KVM_EXIT_SET_TPR 11 +#define KVM_EXIT_TPR_ACCESS 12 +#define KVM_EXIT_S390_SIEIC 13 +#define KVM_EXIT_S390_RESET 14 +#define KVM_EXIT_DCR 15 +#define KVM_EXIT_NMI 16 +#define KVM_EXIT_INTERNAL_ERROR 17 /* For KVM_EXIT_INTERNAL_ERROR */ -#define KVM_INTERNAL_ERROR_EMULATION 1 -#define KVM_INTERNAL_ERROR_SIMUL_EX 2 +#define KVM_INTERNAL_ERROR_EMULATION 1 +#define KVM_INTERNAL_ERROR_SIMUL_EX 2 /* for KVM_RUN, returned by mmap(vcpu_fd, offset=0) */ typedef struct kvm_run { @@ -99,22 +99,7 @@ typedef struct kvm_run { uint64_t cr8; uint64_t apic_base; -#ifdef __KVM_S390 - /* the processor status word for s390 */ - uint64_t psw_mask; /* psw upper half */ - uint64_t psw_addr; /* psw lower half */ -#endif union { - /* - * As a temporary hack, we set the PFNs for programmed I/O and - * memory-mapped I/O upon initialization to allow them to be - * mmap'd after the kvm_run structure. - */ - struct { - uint64_t xxx_pio_paddr; - uint64_t xxx_mmio_paddr; - } xxx_paddrs; - /* KVM_EXIT_UNKNOWN */ struct { uint64_t hardware_exit_reason; @@ -130,8 +115,8 @@ typedef struct kvm_run { } ex; /* KVM_EXIT_IO */ struct { -#define KVM_EXIT_IO_IN 0 -#define KVM_EXIT_IO_OUT 1 +#define KVM_EXIT_IO_IN 0 +#define KVM_EXIT_IO_OUT 1 unsigned char direction; unsigned char size; /* bytes */ unsigned short port; @@ -162,19 +147,6 @@ typedef struct kvm_run { uint32_t is_write; uint32_t pad; } tpr_access; - /* KVM_EXIT_S390_SIEIC */ - struct { - unsigned char icptcode; - unsigned short ipa; - uint32_t ipb; - } s390_sieic; - /* KVM_EXIT_S390_RESET */ -#define KVM_S390_RESET_POR 1 -#define KVM_S390_RESET_CLEAR 2 -#define KVM_S390_RESET_SUBSYSTEM 4 -#define KVM_S390_RESET_CPU_INIT 8 -#define KVM_S390_RESET_IPL 16 - uint64_t s390_reset_flags; /* KVM_EXIT_DCR */ struct { uint32_t dcrn; @@ -216,9 +188,9 @@ typedef struct kvm_coalesced_mmio_zone_ioc { int kvmid; } kvm_coalesced_mmio_zone_ioc_t; -#define KVM_COALESCED_MMIO_MAX \ - ((PAGESIZE - sizeof(struct kvm_coalesced_mmio_ring)) / \ - sizeof(struct kvm_coalesced_mmio)) +#define KVM_COALESCED_MMIO_MAX \ + ((PAGESIZE - sizeof (struct kvm_coalesced_mmio_ring)) / \ + sizeof (struct kvm_coalesced_mmio)) /* for KVM_INTERRUPT */ typedef struct kvm_interrupt { @@ -238,15 +210,15 @@ typedef struct kvm_dirty_log { /* for KVM_SET_SIGNAL_MASK */ typedef struct kvm_signal_mask { - uint32_t len; - uint8_t sigset[1]; + uint32_t len; + uint8_t sigset[1]; } kvm_signal_mask_t; /* for KVM_TPR_ACCESS_REPORTING */ typedef struct kvm_tpr_access_ctl { - uint32_t enabled; - uint32_t flags; - uint32_t reserved[8]; + uint32_t enabled; + uint32_t flags; + uint32_t reserved[8]; } kvm_tpr_access_ctl_t; /* for KVM_SET_VAPIC_ADDR */ @@ -255,11 +227,11 @@ typedef struct kvm_vapic_addr { } kvm_vapic_addr_t; /* for KVM_SET_MP_STATE */ -#define KVM_MP_STATE_RUNNABLE 0 -#define KVM_MP_STATE_UNINITIALIZED 1 -#define KVM_MP_STATE_INIT_RECEIVED 2 -#define KVM_MP_STATE_HALTED 3 -#define KVM_MP_STATE_SIPI_RECEIVED 4 +#define KVM_MP_STATE_RUNNABLE 0 +#define KVM_MP_STATE_UNINITIALIZED 1 +#define KVM_MP_STATE_INIT_RECEIVED 2 +#define KVM_MP_STATE_HALTED 3 +#define KVM_MP_STATE_SIPI_RECEIVED 4 typedef struct kvm_mp_state { uint32_t mp_state; @@ -267,107 +239,112 @@ typedef struct kvm_mp_state { /* for KVM_SET_GUEST_DEBUG */ -#define KVM_GUESTDBG_ENABLE 0x00000001 -#define KVM_GUESTDBG_SINGLESTEP 0x00000002 +#define KVM_GUESTDBG_ENABLE 0x00000001 +#define KVM_GUESTDBG_SINGLESTEP 0x00000002 typedef struct kvm_guest_debug { - uint32_t control; - uint32_t pad; - struct kvm_guest_debug_arch arch; + uint32_t control; + uint32_t pad; + struct kvm_guest_debug_arch arch; } kvm_guest_debug_t; - /* ioctl commands */ -#define KVMIO 0xAE +#define KVMIO 0xAE /* * ioctls for /dev/kvm fds: */ -#define KVM_GET_API_VERSION _IO(KVMIO, 0x00) -#define KVM_CREATE_VM _IO(KVMIO, 0x01) /* returns a VM fd */ -#define KVM_GET_MSR_INDEX_LIST _IOWR(KVMIO, 0x02, struct kvm_msr_list) -#define KVM_CLONE _IO(KVMIO, 0x20) -#define KVM_NET_QUEUE _IO(KVMIO, 0x21) +#define KVM_GET_API_VERSION _IO(KVMIO, 0x00) +#define KVM_CREATE_VM _IO(KVMIO, 0x01) /* returns a VM fd */ +#define KVM_GET_MSR_INDEX_LIST _IOWR(KVMIO, 0x02, struct kvm_msr_list) +#define KVM_CLONE _IO(KVMIO, 0x20) +#define KVM_NET_QUEUE _IO(KVMIO, 0x21) /* * Check if a kvm extension is available. Argument is extension number, * return is 1 (yes) or 0 (no, sorry). */ -#define KVM_CHECK_EXTENSION _IO(KVMIO, 0x03) +#define KVM_CHECK_EXTENSION _IO(KVMIO, 0x03) /* * Get size for mmap(vcpu_fd) */ -#define KVM_GET_VCPU_MMAP_SIZE _IO(KVMIO, 0x04) /* in bytes */ -#define KVM_GET_SUPPORTED_CPUID _IOWR(KVMIO, 0x05, struct kvm_cpuid2) +#define KVM_GET_VCPU_MMAP_SIZE _IO(KVMIO, 0x04) /* in bytes */ +#define KVM_GET_SUPPORTED_CPUID _IOWR(KVMIO, 0x05, struct kvm_cpuid2) /* * Extension capability list. */ -#define KVM_CAP_IRQCHIP 0 -#define KVM_CAP_HLT 1 -#define KVM_CAP_MMU_SHADOW_CACHE_CONTROL 2 -#define KVM_CAP_USER_MEMORY 3 -#define KVM_CAP_SET_TSS_ADDR 4 -#define KVM_CAP_VAPIC 6 -#define KVM_CAP_EXT_CPUID 7 -#define KVM_CAP_CLOCKSOURCE 8 -#define KVM_CAP_NR_VCPUS 9 /* returns max vcpus per vm */ -#define KVM_CAP_NR_MEMSLOTS 10 /* returns max memory slots per vm */ -#define KVM_CAP_PIT 11 -#define KVM_CAP_NOP_IO_DELAY 12 -#define KVM_CAP_PV_MMU 13 -#define KVM_CAP_MP_STATE 14 -#define KVM_CAP_COALESCED_MMIO 15 -#define KVM_CAP_SYNC_MMU 16 /* Changes to host mmap are reflected in guest */ +#define KVM_CAP_IRQCHIP 0 +#define KVM_CAP_HLT 1 +#define KVM_CAP_MMU_SHADOW_CACHE_CONTROL 2 +#define KVM_CAP_USER_MEMORY 3 +#define KVM_CAP_SET_TSS_ADDR 4 +#define KVM_CAP_VAPIC 6 +#define KVM_CAP_EXT_CPUID 7 +#define KVM_CAP_CLOCKSOURCE 8 +#define KVM_CAP_NR_VCPUS 9 +#define KVM_CAP_NR_MEMSLOTS 10 +#define KVM_CAP_PIT 11 +#define KVM_CAP_NOP_IO_DELAY 12 +#define KVM_CAP_PV_MMU 13 +#define KVM_CAP_MP_STATE 14 +#define KVM_CAP_COALESCED_MMIO 15 +#define KVM_CAP_SYNC_MMU 16 + #ifdef __KVM_HAVE_DEVICE_ASSIGNMENT -#define KVM_CAP_DEVICE_ASSIGNMENT 17 +#define KVM_CAP_DEVICE_ASSIGNMENT 17 #endif -#define KVM_CAP_IOMMU 18 + +#define KVM_CAP_IOMMU 18 + #ifdef __KVM_HAVE_MSI -#define KVM_CAP_DEVICE_MSI 20 +#define KVM_CAP_DEVICE_MSI 20 #endif + /* Bug in KVM_SET_USER_MEMORY_REGION fixed: */ -#define KVM_CAP_DESTROY_MEMORY_REGION_WORKS 21 +#define KVM_CAP_DESTROY_MEMORY_REGION_WORKS 21 + #ifdef __KVM_HAVE_USER_NMI -#define KVM_CAP_USER_NMI 22 +#define KVM_CAP_USER_NMI 22 #endif + #ifdef __KVM_HAVE_GUEST_DEBUG -#define KVM_CAP_SET_GUEST_DEBUG 23 +#define KVM_CAP_SET_GUEST_DEBUG 23 #endif -#define KVM_CAP_REINJECT_CONTROL 24 +#define KVM_CAP_REINJECT_CONTROL 24 #ifdef __KVM_HAVE_IOAPIC -#define KVM_CAP_IRQ_ROUTING 25 +#define KVM_CAP_IRQ_ROUTING 25 #endif -#define KVM_CAP_IRQ_INJECT_STATUS 26 +#define KVM_CAP_IRQ_INJECT_STATUS 26 #ifdef __KVM_HAVE_DEVICE_ASSIGNMENT -#define KVM_CAP_DEVICE_DEASSIGNMENT 27 +#define KVM_CAP_DEVICE_DEASSIGNMENT 27 #endif #ifdef __KVM_HAVE_MSIX -#define KVM_CAP_DEVICE_MSIX 28 +#define KVM_CAP_DEVICE_MSIX 28 #endif -#define KVM_CAP_ASSIGN_DEV_IRQ 29 +#define KVM_CAP_ASSIGN_DEV_IRQ 29 /* Another bug in KVM_SET_USER_MEMORY_REGION fixed: */ -#define KVM_CAP_JOIN_MEMORY_REGIONS_WORKS 30 -#define KVM_CAP_MCE 31 -#define KVM_CAP_IRQFD 32 -#define KVM_CAP_PIT2 33 -#define KVM_CAP_SET_BOOT_CPU_ID 34 -#define KVM_CAP_PIT_STATE2 35 -#define KVM_CAP_IOEVENTFD 36 -#define KVM_CAP_SET_IDENTITY_MAP_ADDR 37 -#define KVM_CAP_XEN_HVM 38 -#define KVM_CAP_ADJUST_CLOCK 39 -#define KVM_CAP_INTERNAL_ERROR_DATA 40 -#define KVM_CAP_VCPU_EVENTS 41 -#define KVM_CAP_S390_PSW 42 -#define KVM_CAP_PPC_SEGSTATE 43 -#define KVM_CAP_HYPERV 44 -#define KVM_CAP_HYPERV_VAPIC 45 -#define KVM_CAP_HYPERV_SPIN 46 -#define KVM_CAP_PCI_SEGMENT 47 -#define KVM_CAP_X86_ROBUST_SINGLESTEP 51 +#define KVM_CAP_JOIN_MEMORY_REGIONS_WORKS 30 +#define KVM_CAP_MCE 31 +#define KVM_CAP_IRQFD 32 +#define KVM_CAP_PIT2 33 +#define KVM_CAP_SET_BOOT_CPU_ID 34 +#define KVM_CAP_PIT_STATE2 35 +#define KVM_CAP_IOEVENTFD 36 +#define KVM_CAP_SET_IDENTITY_MAP_ADDR 37 +#define KVM_CAP_XEN_HVM 38 +#define KVM_CAP_ADJUST_CLOCK 39 +#define KVM_CAP_INTERNAL_ERROR_DATA 40 +#define KVM_CAP_VCPU_EVENTS 41 +#define KVM_CAP_S390_PSW 42 +#define KVM_CAP_PPC_SEGSTATE 43 +#define KVM_CAP_HYPERV 44 +#define KVM_CAP_HYPERV_VAPIC 45 +#define KVM_CAP_HYPERV_SPIN 46 +#define KVM_CAP_PCI_SEGMENT 47 +#define KVM_CAP_X86_ROBUST_SINGLESTEP 51 #ifdef KVM_CAP_IRQ_ROUTING typedef struct kvm_irq_routing_irqchip { @@ -383,8 +360,8 @@ typedef struct kvm_irq_routing_msi { } kvm_irq_routing_msi_t; /* gsi routing entry types */ -#define KVM_IRQ_ROUTING_IRQCHIP 1 -#define KVM_IRQ_ROUTING_MSI 2 +#define KVM_IRQ_ROUTING_IRQCHIP 1 +#define KVM_IRQ_ROUTING_MSI 2 typedef struct kvm_irq_routing_entry { uint32_t gsi; @@ -433,78 +410,80 @@ typedef struct kvm_clock_data { * KVM_CREATE_VCPU receives as a parameter the vcpu slot, and returns * a vcpu fd. */ -#define KVM_CREATE_VCPU _IO(KVMIO, 0x41) -#define KVM_GET_DIRTY_LOG _IOW(KVMIO, 0x42, struct kvm_dirty_log) -#define KVM_SET_NR_MMU_PAGES _IO(KVMIO, 0x44) -#define KVM_GET_NR_MMU_PAGES _IO(KVMIO, 0x45) -#define KVM_SET_USER_MEMORY_REGION _IOW(KVMIO, 0x46, \ - struct kvm_userspace_memory_region) +#define KVM_CREATE_VCPU _IO(KVMIO, 0x41) +#define KVM_GET_DIRTY_LOG _IOW(KVMIO, 0x42, struct kvm_dirty_log) +#define KVM_SET_NR_MMU_PAGES _IO(KVMIO, 0x44) +#define KVM_GET_NR_MMU_PAGES _IO(KVMIO, 0x45) +#define KVM_SET_USER_MEMORY_REGION _IOW(KVMIO, 0x46, \ + struct kvm_userspace_memory_region) -#define KVM_SET_TSS_ADDR _IO(KVMIO, 0x47) -#define KVM_SET_IDENTITY_MAP_ADDR _IOW(KVMIO, 0x48, struct kvm_id_map_addr_ioc) +#define KVM_SET_TSS_ADDR _IO(KVMIO, 0x47) +#define KVM_SET_IDENTITY_MAP_ADDR _IOW(KVMIO, 0x48, \ + struct kvm_id_map_addr_ioc) /* Device model IOC */ -#define KVM_CREATE_IRQCHIP _IO(KVMIO, 0x60) -#define KVM_IRQ_LINE _IOW(KVMIO, 0x61, struct kvm_irq_level) -#define KVM_GET_IRQCHIP _IOWR(KVMIO, 0x62, struct kvm_irqchip) -#define KVM_SET_IRQCHIP _IOR(KVMIO, 0x63, struct kvm_irqchip) -#define KVM_CREATE_PIT _IO(KVMIO, 0x64) -#define KVM_GET_PIT _IOWR(KVMIO, 0x65, struct kvm_pit_state) -#define KVM_SET_PIT _IOR(KVMIO, 0x66, struct kvm_pit_state) -#define KVM_IRQ_LINE_STATUS _IOWR(KVMIO, 0x67, struct kvm_irq_level) -#define KVM_REGISTER_COALESCED_MMIO \ - _IOW(KVMIO, 0x67, struct kvm_coalesced_mmio_zone_ioc) -#define KVM_UNREGISTER_COALESCED_MMIO \ - _IOW(KVMIO, 0x68, struct kvm_coalesced_mmio_zone_ioc) -#define KVM_SET_GSI_ROUTING _IOW(KVMIO, 0x6a, struct kvm_irq_routing) -#define KVM_REINJECT_CONTROL _IO(KVMIO, 0x71) -#define KVM_CREATE_PIT2 _IOW(KVMIO, 0x77, struct kvm_pit_config) -#define KVM_SET_BOOT_CPU_ID _IO(KVMIO, 0x78) -#define KVM_SET_CLOCK _IOW(KVMIO, 0x7b, struct kvm_clock_data) -#define KVM_GET_CLOCK _IOR(KVMIO, 0x7c, struct kvm_clock_data) +#define KVM_CREATE_IRQCHIP _IO(KVMIO, 0x60) +#define KVM_IRQ_LINE _IOW(KVMIO, 0x61, struct kvm_irq_level) +#define KVM_GET_IRQCHIP _IOWR(KVMIO, 0x62, struct kvm_irqchip) +#define KVM_SET_IRQCHIP _IOR(KVMIO, 0x63, struct kvm_irqchip) +#define KVM_CREATE_PIT _IO(KVMIO, 0x64) +#define KVM_GET_PIT _IOWR(KVMIO, 0x65, struct kvm_pit_state) +#define KVM_SET_PIT _IOR(KVMIO, 0x66, struct kvm_pit_state) +#define KVM_IRQ_LINE_STATUS _IOWR(KVMIO, 0x67, struct kvm_irq_level) + +#define KVM_REGISTER_COALESCED_MMIO _IOW(KVMIO, 0x67, \ + struct kvm_coalesced_mmio_zone_ioc) +#define KVM_UNREGISTER_COALESCED_MMIO _IOW(KVMIO, 0x68, \ + struct kvm_coalesced_mmio_zone_ioc) +#define KVM_SET_GSI_ROUTING _IOW(KVMIO, 0x6a, struct kvm_irq_routing) +#define KVM_REINJECT_CONTROL _IO(KVMIO, 0x71) +#define KVM_CREATE_PIT2 _IOW(KVMIO, 0x77, struct kvm_pit_config) +#define KVM_SET_BOOT_CPU_ID _IO(KVMIO, 0x78) +#define KVM_SET_CLOCK _IOW(KVMIO, 0x7b, struct kvm_clock_data) +#define KVM_GET_CLOCK _IOR(KVMIO, 0x7c, struct kvm_clock_data) /* Available with KVM_CAP_PIT_STATE2 */ -#define KVM_GET_PIT2 _IOR(KVMIO, 0x9f, struct kvm_pit_state2) -#define KVM_SET_PIT2 _IOW(KVMIO, 0xa0, struct kvm_pit_state2) +#define KVM_GET_PIT2 _IOR(KVMIO, 0x9f, struct kvm_pit_state2) +#define KVM_SET_PIT2 _IOW(KVMIO, 0xa0, struct kvm_pit_state2) /* * ioctls for vcpu fds */ -#define KVM_RUN _IO(KVMIO, 0x80) -#define KVM_GET_REGS _IOR(KVMIO, 0x81, struct kvm_regs) -#define KVM_SET_REGS _IOW(KVMIO, 0x82, struct kvm_regs) -#define KVM_GET_SREGS _IOR(KVMIO, 0x83, struct kvm_sregs) -#define KVM_SET_SREGS _IOW(KVMIO, 0x84, struct kvm_sregs) -#define KVM_INTERRUPT _IOW(KVMIO, 0x86, struct kvm_interrupt) -#define KVM_GET_MSRS _IOWR(KVMIO, 0x88, struct kvm_msrs) -#define KVM_SET_MSRS _IOW(KVMIO, 0x89, struct kvm_msrs) -#define KVM_SET_CPUID _IOW(KVMIO, 0x8a, struct kvm_cpuid) -#define KVM_SET_SIGNAL_MASK _IOW(KVMIO, 0x8b, struct kvm_signal_mask) -#define KVM_GET_FPU _IOR(KVMIO, 0x8c, struct kvm_fpu) -#define KVM_SET_FPU _IOW(KVMIO, 0x8d, struct kvm_fpu) -#define KVM_GET_LAPIC _IOR(KVMIO, 0x8e, struct kvm_lapic_state) -#define KVM_SET_LAPIC _IOW(KVMIO, 0x8f, struct kvm_lapic_state) -#define KVM_SET_CPUID2 _IOW(KVMIO, 0x90, struct kvm_cpuid2) -#define KVM_GET_CPUID2 _IOWR(KVMIO, 0x91, struct kvm_cpuid2) +#define KVM_RUN _IO(KVMIO, 0x80) +#define KVM_GET_REGS _IOR(KVMIO, 0x81, struct kvm_regs) +#define KVM_SET_REGS _IOW(KVMIO, 0x82, struct kvm_regs) +#define KVM_GET_SREGS _IOR(KVMIO, 0x83, struct kvm_sregs) +#define KVM_SET_SREGS _IOW(KVMIO, 0x84, struct kvm_sregs) +#define KVM_INTERRUPT _IOW(KVMIO, 0x86, struct kvm_interrupt) +#define KVM_GET_MSRS _IOWR(KVMIO, 0x88, struct kvm_msrs) +#define KVM_SET_MSRS _IOW(KVMIO, 0x89, struct kvm_msrs) +#define KVM_SET_CPUID _IOW(KVMIO, 0x8a, struct kvm_cpuid) +#define KVM_SET_SIGNAL_MASK _IOW(KVMIO, 0x8b, struct kvm_signal_mask) +#define KVM_GET_FPU _IOR(KVMIO, 0x8c, struct kvm_fpu) +#define KVM_SET_FPU _IOW(KVMIO, 0x8d, struct kvm_fpu) +#define KVM_GET_LAPIC _IOR(KVMIO, 0x8e, struct kvm_lapic_state) +#define KVM_SET_LAPIC _IOW(KVMIO, 0x8f, struct kvm_lapic_state) +#define KVM_SET_CPUID2 _IOW(KVMIO, 0x90, struct kvm_cpuid2) +#define KVM_GET_CPUID2 _IOWR(KVMIO, 0x91, struct kvm_cpuid2) /* Available with KVM_CAP_VAPIC */ -#define KVM_TPR_ACCESS_REPORTING _IOWR(KVMIO, 0x92, struct kvm_tpr_acl_ioc) +#define KVM_TPR_ACCESS_REPORTING _IOWR(KVMIO, 0x92, struct kvm_tpr_acl_ioc) /* Available with KVM_CAP_VAPIC */ -#define KVM_SET_VAPIC_ADDR _IOW(KVMIO, 0x93, struct kvm_vapic_addr) -#define KVM_GET_MP_STATE _IOR(KVMIO, 0x98, struct kvm_mp_state) -#define KVM_SET_MP_STATE _IOW(KVMIO, 0x99, struct kvm_mp_state) +#define KVM_SET_VAPIC_ADDR _IOW(KVMIO, 0x93, struct kvm_vapic_addr) +#define KVM_GET_MP_STATE _IOR(KVMIO, 0x98, struct kvm_mp_state) +#define KVM_SET_MP_STATE _IOW(KVMIO, 0x99, struct kvm_mp_state) /* MCE for x86 */ -#define KVM_X86_SETUP_MCE _IOW(KVMIO, 0x9c, uint64_t) -#define KVM_X86_GET_MCE_CAP_SUPPORTED _IOR(KVMIO, 0x9d, uint64_t) -#define KVM_X86_SET_MCE _IOW(KVMIO, 0x9e, struct kvm_x86_mce) +#define KVM_X86_SETUP_MCE _IOW(KVMIO, 0x9c, uint64_t) +#define KVM_X86_GET_MCE_CAP_SUPPORTED _IOR(KVMIO, 0x9d, uint64_t) +#define KVM_X86_SET_MCE _IOW(KVMIO, 0x9e, struct kvm_x86_mce) /* Available with KVM_CAP_VCPU_EVENTS */ -#define KVM_GET_VCPU_EVENTS _IOR(KVMIO, 0x9f, struct kvm_vcpu_events) -#define KVM_SET_VCPU_EVENTS _IOW(KVMIO, 0xa0, struct kvm_vcpu_events) +#define KVM_GET_VCPU_EVENTS _IOR(KVMIO, 0x9f, struct kvm_vcpu_events) +#define KVM_SET_VCPU_EVENTS _IOW(KVMIO, 0xa0, struct kvm_vcpu_events) /* * XXX Additions which probably are changes from qemu/kvm upstream */ /* for KVM_SET_TSS_ADDR ioctl */ typedef struct kvm_tss { - uint64_t addr; /* in */ + uint64_t addr; /* in */ } kvm_tss_t; /* @@ -512,23 +491,23 @@ typedef struct kvm_tss { */ typedef struct kvm_id_map_addr { - int pad; - uint64_t addr; + int pad; + uint64_t addr; } kvm_id_map_addr_t; /* for KVM_SET_IDENTITY_MAP_ADDR */ typedef struct kvm_id_map_addr_ioc { - uint64_t ident_addr; + uint64_t ident_addr; } kvm_id_map_addr_ioc_t; typedef struct kvm_tpr_acl_ioc { - struct kvm_tpr_access_ctl tac; - int kvm_id; - int cpu_index; + struct kvm_tpr_access_ctl tac; + int kvm_id; + int cpu_index; } kvm_tpr_acl_ioc_t; typedef struct kvm_set_boot_cpu_id_ioc { - int id; + int id; } kvm_set_boot_cpu_id_ioc_t; #endif /* __KVM_H */ diff --git a/kvm_bitops.h b/kvm_bitops.h index bd3435e..93fca7b 100644 --- a/kvm_bitops.h +++ b/kvm_bitops.h @@ -1,5 +1,5 @@ #ifndef _ASM_X86_BITOPS_H -#define _ASM_X86_BITOPS_H +#define _ASM_X86_BITOPS_H /* * Copyright 1992, Linus Torvalds. @@ -8,8 +8,8 @@ * __always_inline to avoid problems with older gcc's inlining heuristics. */ -#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) -#define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, 8 * sizeof(long)) +#define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d)) +#define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, 8 * sizeof (long)) /* * These have to be done with inline assembly: that way the bit-setting @@ -18,24 +18,26 @@ * * bit 0 is the LSB of addr; bit 32 is the LSB of (addr+1). */ - #if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 1) -/* Technically wrong, but this avoids compilation errors on some gcc - versions. */ -#define BITOP_ADDR(x) "=m" (*(volatile long *) (x)) +/* + * Technically wrong, but this avoids compilation errors on some gcc + * versions. + */ +#define BITOP_ADDR(x) "=m" (*(volatile long *) (x)) #else -#define BITOP_ADDR(x) "+m" (*(volatile long *) (x)) +#define BITOP_ADDR(x) "+m" (*(volatile long *) (x)) #endif /* * We do the locked ops that don't return the old value as * a mask operation on a byte. */ -#define IS_IMMEDIATE(nr) (__builtin_constant_p(nr)) -#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((uintptr_t)(addr) + ((nr)>>3)) -#define CONST_MASK(nr) (1 << ((nr) & 7)) +#define IS_IMMEDIATE(nr) (__builtin_constant_p(nr)) +#define CONST_MASK_ADDR(nr, addr) \ + BITOP_ADDR((uintptr_t)(addr) + ((nr) >> 3)) +#define CONST_MASK(nr) (1 << ((nr) & 7)) -/** +/* * set_bit - Atomically set a bit in memory * @nr: the bit to set * @addr: the address to start counting from @@ -52,7 +54,7 @@ */ inline void set_bit(unsigned int nr, volatile unsigned long *addr); -/** +/* * __set_bit - Set a bit in memory * @nr: the bit to set * @addr: the address to start counting from @@ -63,7 +65,7 @@ inline void set_bit(unsigned int nr, volatile unsigned long *addr); */ inline void __set_bit(int nr, volatile unsigned long *addr); -/** +/* * clear_bit - Clears a bit in memory * @nr: Bit to clear * @addr: Address to start counting from @@ -101,10 +103,10 @@ inline void __clear_bit(int nr, volatile unsigned long *addr); */ inline void __clear_bit_unlock(unsigned nr, volatile unsigned long *addr); -#define smp_mb__before_clear_bit() barrier() -#define smp_mb__after_clear_bit() barrier() +#define smp_mb__before_clear_bit() barrier() +#define smp_mb__after_clear_bit() barrier() -/** +/* * __change_bit - Toggle a bit in memory * @nr: the bit to change * @addr: the address to start counting from @@ -115,7 +117,7 @@ inline void __clear_bit_unlock(unsigned nr, volatile unsigned long *addr); */ inline void __change_bit(int nr, volatile unsigned long *addr); -/** +/* * change_bit - Toggle a bit in memory * @nr: Bit to change * @addr: Address to start counting from @@ -126,7 +128,7 @@ inline void __change_bit(int nr, volatile unsigned long *addr); */ inline void change_bit(int nr, volatile unsigned long *addr); -/** +/* * test_and_set_bit - Set a bit and return its old value * @nr: Bit to set * @addr: Address to count from @@ -136,7 +138,7 @@ inline void change_bit(int nr, volatile unsigned long *addr); */ inline int test_and_set_bit(int nr, volatile unsigned long *addr); -/** +/* * test_and_set_bit_lock - Set a bit and return its old value for lock * @nr: Bit to set * @addr: Address to count from @@ -145,7 +147,7 @@ inline int test_and_set_bit(int nr, volatile unsigned long *addr); */ inline int test_and_set_bit_lock(int nr, volatile unsigned long *addr); -/** +/* * __test_and_set_bit - Set a bit and return its old value * @nr: Bit to set * @addr: Address to count from @@ -156,7 +158,7 @@ inline int test_and_set_bit_lock(int nr, volatile unsigned long *addr); */ inline int __test_and_set_bit(int nr, volatile unsigned long *addr); -/** +/* * test_and_clear_bit - Clear a bit and return its old value * @nr: Bit to clear * @addr: Address to count from @@ -166,7 +168,7 @@ inline int __test_and_set_bit(int nr, volatile unsigned long *addr); */ inline int test_and_clear_bit(int nr, volatile unsigned long *addr); -/** +/* * __test_and_clear_bit - Clear a bit and return its old value * @nr: Bit to clear * @addr: Address to count from @@ -180,7 +182,7 @@ inline int __test_and_clear_bit(int nr, volatile unsigned long *addr); /* WARNING: non atomic and it can be reordered! */ inline int __test_and_change_bit(int nr, volatile unsigned long *addr); -/** +/* * test_and_change_bit - Change a bit and return its old value * @nr: Bit to change * @addr: Address to count from @@ -190,25 +192,22 @@ inline int __test_and_change_bit(int nr, volatile unsigned long *addr); */ inline int test_and_change_bit(int nr, volatile unsigned long *addr); -inline int constant_test_bit(unsigned int nr, const volatile unsigned long *addr); - +inline int constant_test_bit(unsigned int nr, + const volatile unsigned long *addr); inline int variable_test_bit(int nr, volatile const unsigned long *addr); -#if 0 /* Fool kernel-doc since it doesn't do macros yet */ -/** +/* * test_bit - Determine whether a bit is set * @nr: bit number to test * @addr: Address to start counting from */ -int test_bit(int nr, const volatile unsigned long *addr); -#endif -#define test_bit(nr, addr) \ +#define test_bit(nr, addr) \ (__builtin_constant_p((nr)) \ - ? constant_test_bit((nr), (addr)) \ - : variable_test_bit((nr), (addr))) + ? constant_test_bit((nr), (addr)) \ + : variable_test_bit((nr), (addr))) -/** +/* * __ffs - find first set bit in word * @word: The word to search * @@ -216,7 +215,7 @@ int test_bit(int nr, const volatile unsigned long *addr); */ inline unsigned long __ffs(unsigned long word); -/** +/* * ffz - find first zero bit in word * @word: The word to search * @@ -233,7 +232,7 @@ inline unsigned long ffz(unsigned long word); inline unsigned long __fls(unsigned long word); #ifdef __KERNEL__ -/** +/* * ffs - find first set bit in word * @x: the word to search * @@ -246,7 +245,7 @@ inline unsigned long __fls(unsigned long word); */ inline int ffs(int x); -/** +/* * fls - find last set bit in word * @x: the word to search * |