summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryan Cantrill <bryan@joyent.com>2011-04-24 16:03:56 -0700
committerBryan Cantrill <bryan@joyent.com>2011-04-24 16:03:56 -0700
commit51fee0aa7e95b3193093e597f4d969cbab472393 (patch)
treeb56710f501ef205c037f2af57db2f04568944371
parent4715a6be9e7460adb7dbaf79b2f5b0c439723999 (diff)
downloadillumos-kvm-51fee0aa7e95b3193093e597f4d969cbab472393.tar.gz
HVM-119 eliminate checks of return value for KM_SLEEP allocations
HVM-120 all kvm structures should have an associated typedef
-rw-r--r--apicdef.h2
-rw-r--r--coalesced_mmio.h12
-rw-r--r--ioapic.h4
-rw-r--r--iodev.h8
-rw-r--r--irq.h8
-rw-r--r--kvm.c206
-rw-r--r--kvm.h440
-rw-r--r--kvm_emulate.h20
-rw-r--r--kvm_host.h4
-rw-r--r--kvm_types.h4
-rw-r--r--kvm_x86host.h88
-rw-r--r--msr.h12
-rw-r--r--tss.h8
-rw-r--r--[-rwxr-xr-x]vmcs_dump.h4
14 files changed, 372 insertions, 448 deletions
diff --git a/apicdef.h b/apicdef.h
index 3fdbf30..058a077 100644
--- a/apicdef.h
+++ b/apicdef.h
@@ -417,6 +417,8 @@ struct local_apic {
} __attribute__ ((packed));
+typedef struct local_apic local_apic_t;
+
#undef uint32_t
#ifdef CONFIG_X86_32
diff --git a/coalesced_mmio.h b/coalesced_mmio.h
index 045949b..fc2942f 100644
--- a/coalesced_mmio.h
+++ b/coalesced_mmio.h
@@ -10,16 +10,16 @@
*
*/
-struct kvm_coalesced_mmio_zone {
+typedef struct kvm_coalesced_mmio_zone {
uint64_t addr;
uint32_t size;
uint32_t pad;
-};
+} kvm_coalesced_mmio_zone_t;
-struct kvm_coalesced_mmio_zone_ioc {
+typedef struct kvm_coalesced_mmio_zone_ioc {
struct kvm_coalesced_mmio_zone zone;
int kvmid;
-};
+} kvm_coalesced_mmio_zone_ioc_t;
#ifdef CONFIG_KVM_MMIO
@@ -30,13 +30,13 @@ struct kvm_coalesced_mmio_zone_ioc {
#ifdef _KERNEL
-struct kvm_coalesced_mmio_dev {
+typedef struct kvm_coalesced_mmio_dev {
struct kvm_io_device dev;
struct kvm *kvm;
kmutex_t lock;
int nb_zones;
struct kvm_coalesced_mmio_zone zone[KVM_COALESCED_MMIO_ZONE_MAX];
-};
+} kvm_coalesced_mmio_dev_t;
int kvm_coalesced_mmio_init(struct kvm *kvm);
void kvm_coalesced_mmio_free(struct kvm *kvm);
diff --git a/ioapic.h b/ioapic.h
index bd9c28e..5d7c75a 100644
--- a/ioapic.h
+++ b/ioapic.h
@@ -36,7 +36,7 @@ struct kvm_vcpu;
#define IOAPIC_INIT 0x5
#define IOAPIC_EXTINT 0x7
-struct kvm_ioapic {
+typedef struct kvm_ioapic {
uint64_t base_address;
uint32_t ioregsel;
uint32_t id;
@@ -53,7 +53,7 @@ struct kvm_ioapic {
#else
unsigned long handled_vectors[BT_BITOUL(256)];
#endif /*XXX*/
-};
+} kvm_ioapic_t;
static struct kvm_ioapic *ioapic_irqchip(struct kvm *kvm)
{
diff --git a/iodev.h b/iodev.h
index 79bef85..e1efad6 100644
--- a/iodev.h
+++ b/iodev.h
@@ -25,7 +25,7 @@ struct kvm_io_device;
* read and write handlers return 0 if the transaction has been handled,
* or non-zero to have it passed to the next device.
**/
-struct kvm_io_device_ops {
+typedef struct kvm_io_device_ops {
int (*read)(struct kvm_io_device *this,
gpa_t addr,
int len,
@@ -35,13 +35,13 @@ struct kvm_io_device_ops {
int len,
const void *val);
void (*destructor)(struct kvm_io_device *this);
-};
+} kvm_io_device_ops_t;
-struct kvm_io_device {
+typedef struct kvm_io_device {
struct kvm_lapic *lapic;
const struct kvm_io_device_ops *ops;
-};
+} kvm_io_device_t;
static void kvm_iodevice_init(struct kvm_io_device *dev,
const struct kvm_io_device_ops *ops)
diff --git a/irq.h b/irq.h
index 4e37f71..f31aca2 100644
--- a/irq.h
+++ b/irq.h
@@ -42,7 +42,7 @@ struct kvm_vcpu;
typedef void irq_request_func(void *opaque, int level);
-struct kvm_kpic_state {
+typedef struct kvm_kpic_state {
uint8_t last_irr; /* edge detection */
uint8_t irr; /* interrupt request register */
uint8_t imr; /* interrupt mask register */
@@ -61,9 +61,9 @@ struct kvm_kpic_state {
uint8_t elcr; /* PIIX edge/trigger selection */
uint8_t elcr_mask;
struct kvm_pic *pics_state;
-};
+} kvm_kpic_state_t;
-struct kvm_pic {
+typedef struct kvm_pic {
kmutex_t lock;
unsigned pending_acks;
struct kvm *kvm;
@@ -74,7 +74,7 @@ struct kvm_pic {
struct kvm_io_device dev;
void (*ack_notifier)(void *opaque, int irq);
unsigned long irq_states[16];
-};
+} kvm_pic_t;
struct kvm_pic *kvm_create_pic(struct kvm *kvm);
void kvm_destroy_pic(struct kvm *kvm);
diff --git a/kvm.c b/kvm.c
index 11eca0e..ca909c7 100644
--- a/kvm.c
+++ b/kvm.c
@@ -1270,9 +1270,6 @@ alloc_kvm_area(void)
*/
vmxarea = kmem_alloc(ncpus * sizeof (struct vmcs *), KM_SLEEP);
- if (vmxarea == NULL)
- return (ENOMEM);
-
for (i = 0; i < ncpus; i++) {
struct vmcs *vmcs;
@@ -1280,12 +1277,6 @@ alloc_kvm_area(void)
/* are PAGESIZE aligned. We could enforce this */
/* via kmem_cache_create, but I'm lazy */
vmcs = kmem_zalloc(PAGESIZE, KM_SLEEP);
- if (!vmcs) {
- for (j = 0; j < i; j++)
- kmem_free(vmxarea[j], PAGESIZE);
- return (ENOMEM);
- }
-
vmxarea[i] = vmcs;
}
@@ -2851,12 +2842,6 @@ kvm_init(void *opaque, unsigned int vcpu_size)
return (r);
bad_page = alloc_page(PAGESIZE, KM_SLEEP);
-
- if (bad_page == NULL) {
- r = ENOMEM;
- goto out;
- }
-
bad_pfn = bad_page->p_pagenum;
#ifdef XXX
@@ -3085,29 +3070,10 @@ vmx_init(void)
kvm_define_shared_msr(i, vmx_msr_index[i]);
#ifdef XXX
- vmx_io_bitmap_a = (unsigned long *)kmem_zalloc(PAGESIZE, KM_SLEEP);
- if (!vmx_io_bitmap_a)
- return (ENOMEM);
-
- vmx_io_bitmap_b = (unsigned long *)kmem_zalloc(PAGESIZE, KM_SLEEP);
- if (!vmx_io_bitmap_b) {
- r = ENOMEM;
- goto out;
- }
-
- vmx_msr_bitmap_legacy =
- (unsigned long *)kmem_zalloc(PAGESIZE, KM_SLEEP);
-
- if (!vmx_msr_bitmap_legacy) {
- r = ENOMEM;
- goto out1;
- }
-
- vmx_msr_bitmap_longmode = (unsigned long *)kmem_zalloc(PAGESIZE,
- KM_SLEEP);
- if (!vmx_msr_bitmap_longmode) {
- r = ENOMEM; goto out2;
- }
+ vmx_io_bitmap_a = kmem_zalloc(PAGESIZE, KM_SLEEP);
+ vmx_io_bitmap_b = kmem_zalloc(PAGESIZE, KM_SLEEP);
+ vmx_msr_bitmap_legacy = kmem_zalloc(PAGESIZE, KM_SLEEP);
+ vmx_msr_bitmap_longmode = kmem_zalloc(PAGESIZE, KM_SLEEP);
#else
XXX_KVM_PROBE;
#endif
@@ -3712,12 +3678,6 @@ kvm_create_vm(void)
for (i = 0; i < KVM_NR_BUSES; i++) {
kvmp->buses[i] =
kmem_zalloc(sizeof (struct kvm_io_bus), KM_SLEEP);
- if (!kvmp->buses[i]) {
- rw_destroy(&kvmp->kvm_rwlock);
- kmem_free(kvmp->memslots, sizeof (struct kvm_memslots));
- kvm_arch_destroy_vm(kvmp);
- return (NULL);
- }
}
rval = kvm_init_mmu_notifier(kvmp);
@@ -4043,12 +4003,8 @@ __kvm_set_memory_region(struct kvm *kvmp,
/* Allocate if a slot is being created */
if (npages && !new.rmap) {
- new.rmap = kmem_alloc(npages * sizeof(struct page *), KM_SLEEP);
-
- if (!new.rmap)
- goto out_free;
-
- memset(new.rmap, 0, npages * sizeof(*new.rmap));
+ new.rmap =
+ kmem_zalloc(npages * sizeof (struct page *), KM_SLEEP);
new.user_alloc = user_alloc;
new.userspace_addr = mem->userspace_addr;
@@ -4074,13 +4030,7 @@ __kvm_set_memory_region(struct kvm *kvmp,
lpages -= base_gfn / KVM_PAGES_PER_HPAGE(level);
new.lpage_info[i] =
- kmem_alloc(lpages * sizeof (*new.lpage_info[i]), KM_SLEEP);
-
- if (!new.lpage_info[i])
- goto out_free;
-
- memset(new.lpage_info[i], 0,
- lpages * sizeof(*new.lpage_info[i]));
+ kmem_zalloc(lpages * sizeof (*new.lpage_info[i]), KM_SLEEP);
if (base_gfn % KVM_PAGES_PER_HPAGE(level))
new.lpage_info[i][0].write_count = 1;
@@ -4104,10 +4054,8 @@ skip_lpage:
if ((new.flags & KVM_MEM_LOG_DIRTY_PAGES) && !new.dirty_bitmap) {
unsigned long dirty_bytes = kvm_dirty_bitmap_bytes(&new);
- new.dirty_bitmap = kmem_alloc(dirty_bytes, KM_SLEEP);
- if (!new.dirty_bitmap)
- goto out_free;
- memset(new.dirty_bitmap, 0, dirty_bytes);
+ new.dirty_bitmap = kmem_zalloc(dirty_bytes, KM_SLEEP);
+
/* destroy any largepage mappings for dirty tracking */
if (old.npages)
flush_shadow = 1;
@@ -4116,8 +4064,6 @@ skip_lpage:
if (!npages) {
r = ENOMEM;
slots = kmem_zalloc(sizeof(struct kvm_memslots), KM_SLEEP);
- if (!slots)
- goto out_free;
memcpy(slots, kvmp->memslots, sizeof(struct kvm_memslots));
if (mem->slot >= slots->nmemslots)
slots->nmemslots = mem->slot + 1;
@@ -4159,8 +4105,6 @@ skip_lpage:
r = ENOMEM;
slots = kmem_zalloc(sizeof(struct kvm_memslots), KM_SLEEP);
- if (!slots)
- goto out_free;
memcpy(slots, kvmp->memslots, sizeof(struct kvm_memslots));
if (mem->slot >= slots->nmemslots)
slots->nmemslots = mem->slot + 1;
@@ -4480,8 +4424,6 @@ static int kvm_dev_ioctl_get_supported_cpuid(struct kvm_cpuid2 *cpuid,
r = ENOMEM;
allocsize = sizeof(struct kvm_cpuid_entry2)*cpuid->nent;
cpuid_entries = kmem_zalloc(allocsize, KM_SLEEP);
- if (!cpuid_entries)
- goto out;
do_cpuid_ent(&cpuid_entries[0], 0, 0, &nent, cpuid->nent);
limit = cpuid_entries[0].eax;
@@ -6356,8 +6298,6 @@ static int xen_hvm_config(struct kvm_vcpu *vcpu, uint64_t data)
goto out;
r = ENOMEM;
page = kmem_alloc(PAGESIZE, KM_SLEEP);
- if (!page)
- goto out;
r = EFAULT;
if (copyin(blob_addr + (page_num * PAGESIZE), page, PAGESIZE))
goto out_free;
@@ -6595,9 +6535,6 @@ int clear_user(void *addr, unsigned long size)
caddr_t ka;
int rval = 0;
-#ifdef DEBUG
- cmn_err(CE_NOTE, "clear_user: addr = %p, size = %lx\n", addr, size);
-#endif /*DEBUG*/
ka = kmem_zalloc(size, KM_SLEEP);
rval = copyout(ka, addr, size);
kmem_free(ka, size);
@@ -12619,8 +12556,6 @@ struct kvm_pic *kvm_create_pic(struct kvm *kvm)
int ret;
s = kmem_zalloc(sizeof(struct kvm_pic), KM_SLEEP);
- if (!s)
- return NULL;
mutex_init(&s->lock, NULL, MUTEX_DRIVER, 0);
s->kvm = kvm;
s->pics[0].elcr_mask = 0xf8;
@@ -13018,8 +12953,6 @@ int kvm_ioapic_init(struct kvm *kvm)
int ret;
ioapic = kmem_zalloc(sizeof(struct kvm_ioapic), KM_SLEEP);
- if (!ioapic)
- return -ENOMEM;
mutex_init(&ioapic->lock, NULL, MUTEX_DRIVER, 0);
kvm->arch.vioapic = ioapic;
kvm_ioapic_reset(ioapic);
@@ -13220,24 +13153,17 @@ int kvm_set_irq_routing(struct kvm *kvm,
new = kmem_zalloc(sizeof(*new) + (nr_rt_entries * sizeof(list_t))
+ (nr * sizeof(struct kvm_kernel_irq_routing_entry)),
KM_SLEEP);
- if (!new)
- return -ENOMEM;
new->rt_entries = (void *)&new->map[nr_rt_entries];
#else
XXX_KVM_PROBE;
new = kmem_zalloc(sizeof(*new), KM_SLEEP);
- if (!new)
- return -ENOMEM;
+
for (i = 0; i < KVM_MAX_IRQ_ROUTES; i++) {
list_create(&new->map[i], sizeof(struct kvm_kernel_irq_routing_entry),
offsetof(struct kvm_kernel_irq_routing_entry, link));
}
new->rt_entries = kmem_zalloc(sizeof(struct kvm_kernel_irq_routing_entry)*nr, KM_SLEEP);
- if (!new->rt_entries) {
- kmem_free(new, sizeof(*new));
- return -ENOMEM;
- }
#endif /*XXX*/
@@ -13849,8 +13775,6 @@ struct kvm_pit *kvm_create_pit(struct kvm *kvm, uint32_t flags)
int ret;
pit = kmem_zalloc(sizeof(struct kvm_pit), KM_SLEEP);
- if (!pit)
- return NULL;
pit->irq_source_id = kvm_request_irq_source_id(kvm);
if (pit->irq_source_id < 0) {
@@ -14185,10 +14109,9 @@ kvm_ioctl(dev_t dev, int cmd, intptr_t arg, int mode, cred_t *cred_p, int *rval_
struct kvm_create_pit_ioc *kvm_create_pit_ioc;
struct kvm *kvmp;
- if ((kvm_create_pit_ioc = kmem_zalloc(sizeof(struct kvm_create_pit_ioc), KM_SLEEP)) == NULL) {
- rval = ENOMEM;
- break;
- }
+ kvm_create_pit_ioc =
+ kmem_zalloc(sizeof (struct kvm_create_pit_ioc), KM_SLEEP);
+
if (ddi_copyin((const char *)arg, kvm_create_pit_ioc, sizeof (struct kvm_create_pit_ioc), mode)) {
rval = EFAULT;
kmem_free(kvm_create_pit_ioc, sizeof(struct kvm_create_pit_ioc));
@@ -14240,10 +14163,8 @@ kvm_ioctl(dev_t dev, int cmd, intptr_t arg, int mode, cred_t *cred_p, int *rval_
struct kvm_irq_ioc *kvm_irq_ioc;
struct kvm *kvmp;
- if ((kvm_irq_ioc = kmem_zalloc(sizeof(struct kvm_irq_ioc), KM_SLEEP)) == NULL) {
- rval = ENOMEM;
- break;
- }
+ kvm_irq_ioc = kmem_zalloc(sizeof (kvm_irq_ioc_t), KM_SLEEP);
+
if (ddi_copyin((const caddr_t)arg, kvm_irq_ioc, sizeof(struct kvm_irq_ioc), mode)) {
rval = EFAULT;
kmem_free(kvm_irq_ioc, sizeof(struct kvm_irq_ioc));
@@ -14306,10 +14227,8 @@ kvm_ioctl(dev_t dev, int cmd, intptr_t arg, int mode, cred_t *cred_p, int *rval_
break;
}
- if ((kvm_run_ioc = kmem_zalloc(sizeof(struct kvm_run_ioc), KM_SLEEP)) == NULL) {
- rval = ENOMEM;
- break;
- }
+ kvm_run_ioc = kmem_zalloc(sizeof(struct kvm_run_ioc), KM_SLEEP);
+
if (ddi_copyin((caddr_t)arg, kvm_run_ioc, sizeof (struct kvm_run_ioc), mode)) {
rval = EFAULT;
kmem_free(kvm_run_ioc, sizeof(struct kvm_run_ioc));
@@ -14377,7 +14296,9 @@ kvm_ioctl(dev_t dev, int cmd, intptr_t arg, int mode, cred_t *cred_p, int *rval_
struct kvm *kvmp;
struct kvm_vcpu *vcpu;
- kvm_msrs_ioc = kmem_alloc(sizeof(struct kvm_msrs_ioc), KM_SLEEP);
+ kvm_msrs_ioc =
+ kmem_alloc(sizeof (struct kvm_msrs_ioc), KM_SLEEP);
+
if (ddi_copyin((const void *)arg, kvm_msrs_ioc,
sizeof(struct kvm_msrs_ioc), mode) != 0) {
rval = EFAULT;
@@ -14416,10 +14337,8 @@ kvm_ioctl(dev_t dev, int cmd, intptr_t arg, int mode, cred_t *cred_p, int *rval_
struct kvm_id_map_addr_ioc *kvm_id_map_addr_ioc;
struct kvm *kvmp;
- if ((kvm_id_map_addr_ioc = kmem_zalloc(sizeof(struct kvm_id_map_addr_ioc), KM_SLEEP)) == NULL) {
- rval = ENOMEM;
- break;
- }
+ kvm_id_map_addr_ioc =
+ kmem_zalloc(sizeof (struct kvm_id_map_addr_ioc), KM_SLEEP);
rval = EFAULT;
if (ddi_copyin((const char *)arg, kvm_id_map_addr_ioc, sizeof (struct kvm_id_map_addr_ioc), mode)) {
@@ -14443,7 +14362,8 @@ kvm_ioctl(dev_t dev, int cmd, intptr_t arg, int mode, cred_t *cred_p, int *rval_
struct kvm_vcpu *vcpu;
int n;
- kvm_msrs_ioc = kmem_alloc(sizeof(struct kvm_msrs_ioc), KM_SLEEP);
+ kvm_msrs_ioc =
+ kmem_alloc(sizeof (struct kvm_msrs_ioc), KM_SLEEP);
if (ddi_copyin((const void *)arg, kvm_msrs_ioc,
sizeof(struct kvm_msrs_ioc), mode) != 0) {
rval = EFAULT;
@@ -14549,10 +14469,9 @@ kvm_ioctl(dev_t dev, int cmd, intptr_t arg, int mode, cred_t *cred_p, int *rval_
struct kvm_set_user_memory_ioc *kvmioc;
struct kvm *kvmp;
- if ((kvmioc = kmem_zalloc(sizeof(struct kvm_set_user_memory_ioc), KM_SLEEP)) == NULL) {
- rval = ENOMEM;
- break;
- }
+ kvmioc = kmem_zalloc(sizeof (struct kvm_set_user_memory_ioc),
+ KM_SLEEP);
+
if (ddi_copyin((const void *)arg, kvmioc,
sizeof(struct kvm_set_user_memory_ioc), mode) != 0) {
rval = EFAULT;
@@ -14577,10 +14496,7 @@ kvm_ioctl(dev_t dev, int cmd, intptr_t arg, int mode, cred_t *cred_p, int *rval_
struct kvm_cpuid2 *cpuid_arg = (struct kvm_cpuid2 *)arg;
struct kvm_cpuid2 *cpuid;
- if ((cpuid = kmem_zalloc(sizeof(struct kvm_cpuid2), KM_SLEEP)) == NULL) {
- rval = ENOMEM;
- break;
- }
+ cpuid = kmem_zalloc(sizeof(struct kvm_cpuid2), KM_SLEEP);
if (ddi_copyin(cpuid_arg, cpuid, sizeof (struct kvm_cpuid2), mode)) {
rval = EFAULT;
@@ -14605,10 +14521,8 @@ kvm_ioctl(dev_t dev, int cmd, intptr_t arg, int mode, cred_t *cred_p, int *rval_
struct kvm_msr_list *msr_list;
unsigned n;
- if ((msr_list = kmem_zalloc(sizeof(struct kvm_msr_list), KM_SLEEP)) == NULL) {
- rval = ENOMEM;
- break;
- }
+ msr_list = kmem_zalloc(sizeof (struct kvm_msr_list), KM_SLEEP);
+
if (ddi_copyin(user_msr_list, msr_list, sizeof (struct kvm_msr_list), mode)) {
rval = EFAULT;
kmem_free(msr_list, sizeof(struct kvm_msr_list));
@@ -14649,10 +14563,9 @@ kvm_ioctl(dev_t dev, int cmd, intptr_t arg, int mode, cred_t *cred_p, int *rval_
struct kvm *kvmp;
struct kvm_vcpu *vcpu;
- if ((kvm_regs_ioc = kmem_zalloc(sizeof(struct kvm_regs_ioc), KM_SLEEP)) == NULL) {
- rval = ENOMEM;
- break;
- }
+ kvm_regs_ioc =
+ kmem_zalloc(sizeof (struct kvm_regs_ioc), KM_SLEEP);
+
if (ddi_copyin((caddr_t)arg, kvm_regs_ioc, sizeof (struct kvm_regs_ioc), mode)) {
rval = EFAULT;
kmem_free(kvm_regs_ioc, sizeof(struct kvm_regs_ioc));
@@ -14686,10 +14599,9 @@ kvm_ioctl(dev_t dev, int cmd, intptr_t arg, int mode, cred_t *cred_p, int *rval_
struct kvm *kvmp;
struct kvm_vcpu *vcpu;
- if ((kvm_regs_ioc = kmem_zalloc(sizeof(struct kvm_regs_ioc), KM_SLEEP)) == NULL) {
- rval = ENOMEM;
- break;
- }
+ kvm_regs_ioc =
+ kmem_zalloc(sizeof (struct kvm_regs_ioc), KM_SLEEP);
+
if (ddi_copyin((caddr_t)arg, kvm_regs_ioc, sizeof (struct kvm_regs_ioc), mode)) {
rval = EFAULT;
kmem_free(kvm_regs_ioc, sizeof(struct kvm_regs_ioc));
@@ -14717,10 +14629,8 @@ kvm_ioctl(dev_t dev, int cmd, intptr_t arg, int mode, cred_t *cred_p, int *rval_
struct kvm *kvmp;
struct kvm_vcpu *vcpu;
- if ((kvm_fpu_ioc = kmem_zalloc(sizeof(struct kvm_fpu_ioc), KM_SLEEP)) == NULL) {
- rval = ENOMEM;
- break;
- }
+ kvm_fpu_ioc =
+ kmem_zalloc(sizeof(struct kvm_fpu_ioc), KM_SLEEP);
if (ddi_copyin((caddr_t)arg, kvm_fpu_ioc, sizeof(struct kvm_fpu_ioc), mode)) {
rval = EFAULT;
@@ -14756,10 +14666,9 @@ kvm_ioctl(dev_t dev, int cmd, intptr_t arg, int mode, cred_t *cred_p, int *rval_
struct kvm *kvmp;
struct kvm_vcpu *vcpu;
- if ((kvm_fpu_ioc = kmem_zalloc(sizeof(struct kvm_fpu_ioc), KM_SLEEP)) == NULL) {
- rval = ENOMEM;
- break;
- }
+ kvm_fpu_ioc =
+ kmem_zalloc(sizeof (struct kvm_fpu_ioc), KM_SLEEP);
+
if (ddi_copyin((caddr_t)arg, kvm_fpu_ioc, sizeof(struct kvm_fpu_ioc), mode)) {
rval = EFAULT;
kmem_free(kvm_fpu_ioc, sizeof(struct kvm_fpu_ioc));
@@ -14787,10 +14696,8 @@ kvm_ioctl(dev_t dev, int cmd, intptr_t arg, int mode, cred_t *cred_p, int *rval_
struct kvm *kvmp;
struct kvm_vcpu *vcpu;
- if ((kvm_sregs_ioc = kmem_zalloc(sizeof(struct kvm_sregs_ioc), KM_SLEEP)) == NULL) {
- rval = ENOMEM;
- break;
- }
+ kvm_sregs_ioc =
+ kmem_zalloc(sizeof (struct kvm_sregs_ioc), KM_SLEEP);
if (ddi_copyin((caddr_t)arg, kvm_sregs_ioc, sizeof (struct kvm_sregs_ioc), mode)) {
rval = EFAULT;
@@ -14824,10 +14731,8 @@ kvm_ioctl(dev_t dev, int cmd, intptr_t arg, int mode, cred_t *cred_p, int *rval_
struct kvm *kvmp;
struct kvm_vcpu *vcpu;
- if ((kvm_sregs_ioc = kmem_zalloc(sizeof(struct kvm_sregs_ioc), KM_SLEEP)) == NULL) {
- rval = ENOMEM;
- break;
- }
+ kvm_sregs_ioc =
+ kmem_zalloc(sizeof (struct kvm_sregs_ioc), KM_SLEEP);
if (ddi_copyin((caddr_t)arg, kvm_sregs_ioc, sizeof (struct kvm_sregs_ioc), mode)) {
rval = EFAULT;
@@ -14857,7 +14762,8 @@ kvm_ioctl(dev_t dev, int cmd, intptr_t arg, int mode, cred_t *cred_p, int *rval_
struct kvm *kvmp;
struct kvm_vcpu *vcpu;
- cpuid2_ioc = kmem_alloc(sizeof(struct kvm_cpuid2_ioc), KM_SLEEP);
+ cpuid2_ioc =
+ kmem_alloc(sizeof (struct kvm_cpuid2_ioc), KM_SLEEP);
cpuid2_data = kmem_alloc(sizeof(struct kvm_cpuid2), KM_SLEEP);
if (ddi_copyin((const char *)arg, cpuid2_ioc, sizeof (struct kvm_cpuid2_ioc), mode)) {
@@ -14897,7 +14803,8 @@ kvm_ioctl(dev_t dev, int cmd, intptr_t arg, int mode, cred_t *cred_p, int *rval_
struct kvm_vcpu *vcpu;
struct kvm *kvmp;
- cpuid2_ioc = kmem_zalloc(sizeof(struct kvm_cpuid2_ioc), KM_SLEEP);
+ cpuid2_ioc =
+ kmem_zalloc(sizeof (struct kvm_cpuid2_ioc), KM_SLEEP);
cpuid2_data = kmem_zalloc(sizeof(struct kvm_cpuid2), KM_SLEEP);
if (ddi_copyin((const char *)arg, cpuid2_ioc, sizeof (struct kvm_cpuid2_ioc), mode)) {
@@ -14940,7 +14847,8 @@ kvm_ioctl(dev_t dev, int cmd, intptr_t arg, int mode, cred_t *cred_p, int *rval_
struct kvm *kvmp;
struct kvm_vcpu *vcpu;
- events_ioc = kmem_zalloc(sizeof(struct kvm_vcpu_events_ioc), KM_SLEEP);
+ events_ioc =
+ kmem_zalloc(sizeof (struct kvm_vcpu_events_ioc), KM_SLEEP);
if (ddi_copyin((const char *)arg, events_ioc, sizeof (struct kvm_vcpu_events_ioc), mode)) {
rval = EFAULT;
@@ -14971,7 +14879,9 @@ kvm_ioctl(dev_t dev, int cmd, intptr_t arg, int mode, cred_t *cred_p, int *rval_
struct kvm *kvmp;
struct kvm_vcpu *vcpu;
- lapic_ioc = kmem_zalloc(sizeof(struct kvm_lapic_ioc), KM_SLEEP);
+ lapic_ioc =
+ kmem_zalloc(sizeof (struct kvm_lapic_ioc), KM_SLEEP);
+
if (ddi_copyin((const char *)arg, lapic_ioc, sizeof (struct kvm_lapic_ioc), mode)) {
rval = EFAULT;
kmem_free(lapic_ioc, sizeof(struct kvm_lapic_ioc));
@@ -15044,7 +14954,8 @@ kvm_ioctl(dev_t dev, int cmd, intptr_t arg, int mode, cred_t *cred_p, int *rval_
struct kvm *kvmp;
struct kvm_vcpu *vcpu;
- events_ioc = kmem_zalloc(sizeof(struct kvm_vcpu_events_ioc), KM_SLEEP);
+ events_ioc =
+ kmem_zalloc(sizeof (struct kvm_vcpu_events_ioc), KM_SLEEP);
if (ddi_copyin((const char *)arg, events_ioc, sizeof (struct kvm_vcpu_events_ioc), mode)) {
rval = EFAULT;
kmem_free(events_ioc, sizeof(struct kvm_vcpu_events_ioc));
@@ -15149,10 +15060,11 @@ kvm_ioctl(dev_t dev, int cmd, intptr_t arg, int mode, cred_t *cred_p, int *rval_
#endif
#ifdef KVM_COALESCED_MMIO_PAGE_OFFSET
case KVM_REGISTER_COALESCED_MMIO: {
- struct kvm_coalesced_mmio_zone_ioc *zone_ioc;
struct kvm *kvmp;
+ struct kvm_coalesced_mmio_zone_ioc *zone_ioc =
+ kmem_zalloc(sizeof (struct kvm_coalesced_mmio_zone_ioc),
+ KM_SLEEP);
- zone_ioc = kmem_zalloc(sizeof(struct kvm_coalesced_mmio_zone_ioc), KM_SLEEP);
rval = EFAULT;
if (ddi_copyin((caddr_t)arg, zone_ioc, sizeof (struct kvm_coalesced_mmio_zone_ioc), mode)) {
kmem_free(zone_ioc, sizeof(struct kvm_coalesced_mmio_zone_ioc));
diff --git a/kvm.h b/kvm.h
index 5398198..5e3d15b 100644
--- a/kvm.h
+++ b/kvm.h
@@ -117,11 +117,11 @@
#define KVM_MCE_CAP_SUPPORTED MCG_CTL_P
/* for ioctl KVM_X86_SETUP_MCE */
-struct mcg_cap_ioc {
+typedef struct mcg_cap_ioc {
int kvm_kvmid;
int kvm_cpu_index;
uint64_t mcg_cap;
-};
+} mcg_cap_ioc_t;
#define KVM_GUEST_CR0_MASK_UNRESTRICTED_GUEST \
(X86_CR0_WP | X86_CR0_NE | X86_CR0_NW | X86_CR0_CD)
@@ -246,19 +246,19 @@ struct mcg_cap_ioc {
#define KVM_NR_PAGE_SIZES 3 /* XXX assumes x86 */
#ifdef _KERNEL
-struct kvm_vcpu_data {
+typedef struct kvm_vcpu_data {
char vcpu_vhpt[VHPT_SIZE];
char vcpu_vtlb[VTLB_SIZE];
char vcpu_vpd[VPD_SIZE];
char vcpu_struct[VCPU_STRUCT_SIZE];
-};
+} kvm_vcpu_data_t;
-struct kvm_vm_data {
+typedef struct kvm_vm_data {
char kvm_p2m[KVM_P2M_SIZE];
char kvm_vm_struct[KVM_VM_STRUCT_SIZE];
char kvm_mem_dirty_log[KVM_MEM_DIRTY_LOG_SIZE];
struct kvm_vcpu_data vcpu_data[KVM_MAX_VCPUS];
-};
+} kvm_vm_data_t;
/*
* We don't want allocation failures within the mmu code, so we preallocate
@@ -272,7 +272,7 @@ struct kvm_vm_data {
* fxsave fpu state. Taken from x86_64/processor.h. To be killed when
* we have asm/x86/processor.h
*/
-struct fxsave {
+typedef struct fxsave {
uint16_t cwd;
uint16_t swd;
uint16_t twd;
@@ -287,7 +287,7 @@ struct fxsave {
#else
uint32_t xmm_space[32]; /* 8*16 bytes for each XMM-reg = 128 bytes */
#endif
-};
+} fxsave_t;
#endif /*_KERNEL*/
@@ -338,7 +338,7 @@ struct fxsave {
#ifdef _KERNEL
-struct kvm_timer {
+typedef struct kvm_timer {
#ifdef XXX
struct hrtimer timer;
#else
@@ -355,13 +355,13 @@ struct kvm_timer {
struct kvm_timer_ops *t_ops;
struct kvm *kvm;
struct kvm_vcpu *vcpu;
-};
+} kvm_timer_t;
-struct kvm_timer_ops {
+typedef struct kvm_timer_ops {
int (*is_periodic)(struct kvm_timer *);
-};
+} kvm_timer_ops_t;
-struct kvm_lapic {
+typedef struct kvm_lapic {
unsigned long base_address;
struct kvm_io_device dev;
struct kvm_timer lapic_timer;
@@ -372,12 +372,12 @@ struct kvm_lapic {
void *regs;
gpa_t vapic_addr;
page_t *vapic_page;
-};
+} kvm_lapic_t;
struct vcpu_vmx;
struct kvm_user_return_notifier;
-struct kvm_vcpu {
+typedef struct kvm_vcpu {
struct kvm *kvm;
#ifdef CONFIG_PREEMPT_NOTIFIERS
struct preempt_notifier preempt_notifier;
@@ -411,32 +411,30 @@ struct kvm_vcpu {
struct kvm_vcpu_arch arch;
ddi_umem_cookie_t cookie;
struct kvm_user_return_notifier *urn;
-};
-typedef struct kvm_vcpu kvm_vcpu_t;
-
+} kvm_vcpu_t;
#define KVM_NR_SHARED_MSRS 16
-struct kvm_shared_msrs_global {
+typedef struct kvm_shared_msrs_global {
int nr;
uint32_t msrs[KVM_NR_SHARED_MSRS];
-};
+} kvm_shared_msrs_global_t;
-struct kvm_user_return_notifier {
+typedef struct kvm_user_return_notifier {
void (*on_user_return)(struct kvm_vcpu *,
struct kvm_user_return_notifier *);
-};
+} kvm_user_return_notifier_t;
-struct kvm_shared_msrs {
+typedef struct kvm_shared_msrs {
struct kvm_user_return_notifier urn;
int registered;
struct kvm_shared_msr_values {
uint64_t host;
uint64_t curr;
} values[KVM_NR_SHARED_MSRS];
-};
+} kvm_shared_msrs_t;
-struct kvm_memory_slot {
+typedef struct kvm_memory_slot {
gfn_t base_gfn;
unsigned long npages;
unsigned long flags;
@@ -448,14 +446,14 @@ struct kvm_memory_slot {
} *lpage_info[KVM_NR_PAGE_SIZES];
unsigned long userspace_addr;
int user_alloc;
-};
+} kvm_memory_slot_t;
-struct kvm_memslots {
+typedef struct kvm_memslots {
int nmemslots;
struct kvm_memory_slot memslots[KVM_MEMORY_SLOTS +
KVM_PRIVATE_MEM_SLOTS];
-};
+} kvm_memslots_t;
#endif /*_KERNEL*/
@@ -585,7 +583,7 @@ extern list_t vm_list;
#define KVM_NR_IRQCHIPS 3
/* for KVM_GET_IRQCHIP and KVM_SET_IRQCHIP */
-struct kvm_pic_state {
+typedef struct kvm_pic_state {
uint8_t last_irr; /* edge detection */
uint8_t irr; /* interrupt request register */
uint8_t imr; /* interrupt mask register */
@@ -602,10 +600,10 @@ struct kvm_pic_state {
uint8_t init4; /* true if 4 byte init */
uint8_t elcr; /* PIIX edge/trigger selection */
uint8_t elcr_mask;
-};
+} kvm_pic_state_t;
#define KVM_IOAPIC_NUM_PINS 24
-struct kvm_ioapic_state {
+typedef struct kvm_ioapic_state {
uint64_t base_address;
uint32_t ioregsel;
uint32_t id;
@@ -627,9 +625,9 @@ struct kvm_ioapic_state {
uint8_t dest_id;
} fields;
} redirtbl[KVM_IOAPIC_NUM_PINS];
-};
+} kvm_ioapic_state_t;
-struct kvm_irqchip {
+typedef struct kvm_irqchip {
uint32_t chip_id;
uint32_t pad;
union {
@@ -637,79 +635,79 @@ struct kvm_irqchip {
struct kvm_pic_state pic;
struct kvm_ioapic_state ioapic;
} chip;
-};
+} kvm_irqchip_t;
/* for KVM_GET_IRQCHIP */
-struct kvm_irqchip_ioc {
+typedef struct kvm_irqchip_ioc {
struct kvm_irqchip chip;
int kvmid;
-};
+} kvm_irqchip_ioc_t;
/* for KVM_CREATE_PIT2 */
-struct kvm_pit_config {
+typedef struct kvm_pit_config {
uint32_t flags;
uint32_t pad[15];
-};
+} kvm_pit_config_t;
/* for KVM_GET_REGS and KVM_SET_REGS */
-struct kvm_regs {
+typedef struct kvm_regs {
/* out (KVM_GET_REGS) / in (KVM_SET_REGS) */
uint64_t rax, rbx, rcx, rdx;
uint64_t rsi, rdi, rsp, rbp;
uint64_t r8, r9, r10, r11;
uint64_t r12, r13, r14, r15;
uint64_t rip, rflags;
-};
+} kvm_regs_t;
-struct kvm_regs_ioc {
+typedef struct kvm_regs_ioc {
struct kvm_regs kvm_regs;
int kvm_cpu_index;
int kvm_kvmid;
-};
+} kvm_regs_ioc_t;
-struct kvm_mp_state {
+typedef struct kvm_mp_state {
uint32_t mp_state;
-};
+} kvm_mp_state_t;
-struct kvm_mp_state_ioc {
+typedef struct kvm_mp_state_ioc {
struct kvm_mp_state mp_state;
int kvm_cpu_index;
int kvm_kvmid;
-};
+} kvm_mp_state_ioc_t;
/* for KVM_GET_LAPIC and KVM_SET_LAPIC */
#define KVM_APIC_REG_SIZE 0x400
-struct kvm_lapic_state {
+typedef struct kvm_lapic_state {
char regs[KVM_APIC_REG_SIZE];
-};
+} kvm_lapic_state_t;
-struct kvm_lapic_ioc {
+typedef struct kvm_lapic_ioc {
int kvm_cpu_index;
int kvm_kvmid;
struct kvm_lapic_state s;
-};
+} kvm_lapic_ioc_t;
-struct kvm_dtable {
+typedef struct kvm_dtable {
uint64_t base;
unsigned short limit;
unsigned short padding[3];
-};
+} kvm_dtable_t;
/* Architectural interrupt line count. */
#define KVM_NR_INTERRUPTS 256
-struct kvm_vmx_segment_field {
+typedef struct kvm_vmx_segment_field {
unsigned selector;
unsigned base;
unsigned limit;
unsigned ar_bytes;
-};
+} kvm_vmx_segment_field_t;
/* for KVM_GET_SREGS and KVM_SET_SREGS */
-struct kvm_sregs {
+typedef struct kvm_sregs {
/* out (KVM_GET_SREGS) / in (KVM_SET_SREGS) */
struct kvm_segment cs, ds, es, fs, gs, ss;
struct kvm_segment tr, ldt;
@@ -718,20 +716,20 @@ struct kvm_sregs {
uint64_t efer;
uint64_t apic_base;
unsigned long interrupt_bitmap[(KVM_NR_INTERRUPTS + (64-1)) / 64]; /*XXX 64 = bits in unsigned long*/
-};
+} kvm_sregs_t;
-struct kvm_sregs_ioc {
+typedef struct kvm_sregs_ioc {
struct kvm_sregs sregs;
int kvm_cpu_index;
int kvm_kvmid;
-};
+} kvm_sregs_ioc_t;
/* When set in flags, include corresponding fields on KVM_SET_VCPU_EVENTS */
#define KVM_VCPUEVENT_VALID_NMI_PENDING 0x00000001
#define KVM_VCPUEVENT_VALID_SIPI_VECTOR 0x00000002
/* for KVM_GET/SET_VCPU_EVENTS */
-struct kvm_vcpu_events {
+typedef struct kvm_vcpu_events {
struct {
unsigned char injected;
unsigned char nr;
@@ -754,21 +752,21 @@ struct kvm_vcpu_events {
uint32_t sipi_vector;
uint32_t flags;
uint32_t reserved[10];
-};
+} kvm_vcpu_events_t;
-struct kvm_vcpu_events_ioc {
+typedef struct kvm_vcpu_events_ioc {
struct kvm_vcpu_events events;
int kvm_cpu_index;
int kvm_kvmid;
-};
+} kvm_vcpu_events_ioc_t;
#define KVM_CAP_IRQ_ROUTING 25
#ifdef KVM_CAP_IRQ_ROUTING
-struct kvm_irq_routing_irqchip {
+typedef struct kvm_irq_routing_irqchip {
uint32_t irqchip;
uint32_t pin;
-};
+} kvm_irq_routing_irqchip_t;
/*
* Shift/mask fields for msi address
@@ -805,18 +803,18 @@ struct kvm_irq_routing_irqchip {
#define MSI_DATA_TRIGGER_EDGE (0 << MSI_DATA_TRIGGER_SHIFT)
#define MSI_DATA_TRIGGER_LEVEL (1 << MSI_DATA_TRIGGER_SHIFT)
-struct kvm_irq_routing_msi {
+typedef struct kvm_irq_routing_msi {
uint32_t address_lo;
uint32_t address_hi;
uint32_t data;
uint32_t pad;
-};
+} kvm_irq_routing_msi_t;
/* gsi routing entry types */
#define KVM_IRQ_ROUTING_IRQCHIP 1
#define KVM_IRQ_ROUTING_MSI 2
-struct kvm_irq_routing_entry {
+typedef struct kvm_irq_routing_entry {
uint32_t gsi;
uint32_t type;
uint32_t flags;
@@ -826,13 +824,13 @@ struct kvm_irq_routing_entry {
struct kvm_irq_routing_msi msi;
uint32_t pad[8];
} u;
-};
+} kvm_irq_routing_entry_t;
-struct kvm_irq_routing {
+typedef struct kvm_irq_routing {
uint32_t nr;
uint32_t flags;
struct kvm_irq_routing_entry entries[1];
-};
+} kvm_irq_routing_t;
#endif
@@ -843,20 +841,20 @@ struct kvm_irq_routing {
struct kvm_vcpu;
struct kvm;
-struct kvm_irq_ack_notifier {
+typedef struct kvm_irq_ack_notifier {
list_t link;
unsigned gsi;
void (*irq_acked)(struct kvm_irq_ack_notifier *kian);
-};
+} kvm_irq_ack_notifier_t;
#define KVM_ASSIGNED_MSIX_PENDING 0x1
-struct kvm_guest_msix_entry {
+typedef struct kvm_guest_msix_entry {
uint32_t vector;
unsigned short entry;
unsigned short flags;
-};
+} kvm_guest_msix_entry_t;
-struct kvm_assigned_dev_kernel {
+typedef struct kvm_assigned_dev_kernel {
struct kvm_irq_ack_notifier ack_notifier;
list_t interrupt_work;
list_t list;
@@ -876,7 +874,7 @@ struct kvm_assigned_dev_kernel {
struct pci_dev *dev;
struct kvm *kvm;
kmutex_t assigned_dev_lock;
-};
+} kvm_assigned_dev_kernel_t;
#ifndef container_of
/**
@@ -905,29 +903,29 @@ struct kvm_assigned_dev_kernel {
#define NMI_VECTOR 0x02
-struct kvm_mmu_pages {
+typedef struct kvm_mmu_pages {
struct mmu_page_and_offset {
struct kvm_mmu_page *sp;
unsigned int idx;
} page[KVM_PAGE_ARRAY_NR];
unsigned int nr;
-};
+} kvm_mmu_pages_t;
-struct mmu_page_path {
+typedef struct mmu_page_path {
struct kvm_mmu_page *parent[PT64_ROOT_LEVEL-1];
unsigned int idx[PT64_ROOT_LEVEL-1];
-};
+} mmu_page_path_t;
/*
* Save the original ist values for checking stack pointers during debugging
*/
-struct orig_ist {
+typedef struct orig_ist {
unsigned long ist[7];
-};
+} orig_ist_t;
#define MXCSR_DEFAULT 0x1f80
-struct i387_fsave_struct {
+typedef struct i387_fsave_struct {
uint32_t cwd; /* FPU Control Word */
uint32_t swd; /* FPU Status Word */
uint32_t twd; /* FPU Tag Word */
@@ -941,10 +939,10 @@ struct i387_fsave_struct {
/* Software status information [not touched by FSAVE ]: */
uint32_t status;
-};
+} i387_fsave_struct_t;
-struct i387_soft_struct {
+typedef struct i387_soft_struct {
uint32_t cwd;
uint32_t swd;
uint32_t twd;
@@ -962,7 +960,7 @@ struct i387_soft_struct {
unsigned char alimit;
struct math_emu_info *info;
uint32_t entry_eip;
-};
+} i387_soft_struct_t;
#define KVM_CPUID_FLAG_SIGNIFCANT_INDEX 1
#define KVM_CPUID_FLAG_STATEFUL_FUNC 2
@@ -970,7 +968,7 @@ struct i387_soft_struct {
/* for KVM_GET_FPU and KVM_SET_FPU */
-struct kvm_fpu {
+typedef struct kvm_fpu {
unsigned char fpr[8][16];
unsigned short fcw;
unsigned short fsw;
@@ -982,66 +980,66 @@ struct kvm_fpu {
unsigned char xmm[16][16];
uint32_t mxcsr;
uint32_t pad2;
-};
+} kvm_fpu_t;
-struct kvm_fpu_ioc {
+typedef struct kvm_fpu_ioc {
struct kvm_fpu fpu;
int kvm_cpu_index;
int kvm_kvmid;
-};
+} kvm_fpu_ioc_t;
-struct kvm_msr_entry {
+typedef struct kvm_msr_entry {
uint32_t index;
uint32_t reserved;
uint64_t data;
-};
+} kvm_msr_entry_t;
/* for KVM_GET_MSRS and KVM_SET_MSRS */
-struct kvm_msrs {
+typedef struct kvm_msrs {
uint32_t nmsrs; /* number of msrs in entries */
uint32_t pad;
struct kvm_msr_entry entries[100];
-};
+} kvm_msrs_t;
-struct kvm_msrs_ioc {
+typedef struct kvm_msrs_ioc {
struct kvm_msrs kvm_msrs;
int kvm_cpu_index;
int kvm_kvmid;
-};
+} kvm_msrs_ioc_t;
/* for KVM_GET_MSR_INDEX_LIST */
-struct kvm_msr_list {
+typedef struct kvm_msr_list {
uint32_t nmsrs; /* number of msrs in entries */
uint32_t indices[1];
-};
+} kvm_msr_list_t;
-struct kvm_cpuid_entry {
+typedef struct kvm_cpuid_entry {
uint32_t function;
uint32_t eax;
uint32_t ebx;
uint32_t ecx;
uint32_t edx;
uint32_t padding;
-};
+} kvm_cpuid_entry_t;
/* for KVM_SET_CPUID */
-struct kvm_cpuid {
+typedef struct kvm_cpuid {
uint32_t nent;
uint32_t padding;
struct kvm_cpuid_entry entries[1];
-};
+} kvm_cpuid_t;
-struct kvm_cpuid_ioc {
+typedef struct kvm_cpuid_ioc {
uint32_t nent;
uint32_t padding;
struct kvm_cpuid_entry entries[100]; /* XXX is 100 enough? */
int kvm_cpu_index;
int kvm_kvmid;
-};
+} kvm_cpuid_ioc_t;
/* for KVM_GET_PIT and KVM_SET_PIT */
-struct kvm_pit_channel_state {
+typedef struct kvm_pit_channel_state {
uint32_t count; /* can be 65536 */
uint16_t latched_count;
uint8_t count_latched;
@@ -1055,21 +1053,21 @@ struct kvm_pit_channel_state {
uint8_t bcd;
uint8_t gate;
int64_t count_load_time;
-};
+} kvm_pit_channel_state_t;
-struct kvm_pit_ioc {
+typedef struct kvm_pit_ioc {
int kvmid;
int pad;
struct kvm_pic_state s;
-};
+} kvm_pit_ioc_t;
-struct kvm_debug_exit_arch {
+typedef struct kvm_debug_exit_arch {
uint32_t exception;
uint32_t pad;
uint64_t pc;
uint64_t dr6;
uint64_t dr7;
-};
+} kvm_debug_exit_arch_t;
#define KVM_GUESTDBG_USE_SW_BP 0x00010000
#define KVM_GUESTDBG_USE_HW_BP 0x00020000
@@ -1078,35 +1076,35 @@ struct kvm_debug_exit_arch {
#ifdef XXX
/* for KVM_SET_GUEST_DEBUG */
-struct kvm_guest_debug_arch {
+typedef struct kvm_guest_debug_arch {
uint64_t debugreg[8];
-};
+} kvm_guest_debug_arch_t;
#endif /*XXX*/
-struct kvm_pit_state {
+typedef struct kvm_pit_state {
struct kvm_pit_channel_state channels[3];
-};
+} kvm_pit_state_t;
#define KVM_PIT_FLAGS_HPET_LEGACY 0x00000001
-struct kvm_pit_state2 {
+typedef struct kvm_pit_state2 {
struct kvm_pit_channel_state channels[3];
uint32_t flags;
uint32_t reserved[9];
-};
+} kvm_pit_state2_t;
-struct kvm_reinject_control {
+typedef struct kvm_reinject_control {
uint8_t pit_reinject;
uint8_t reserved[31];
-};
+} kvm_reinject_control_t;
/* for KVM_SET_CPUID2 */
-struct kvm_cpuid2 {
+typedef struct kvm_cpuid2 {
uint32_t nent;
uint32_t padding;
struct kvm_cpuid_entry2 entries[100];
-};
+} kvm_cpuid2_t;
#define X86_SHADOW_INT_MOV_SS 1
@@ -1119,14 +1117,16 @@ struct pvclock_wall_clock {
uint32_t nsec;
} __attribute__((__packed__));
-struct msi_msg {
+typedef struct pvclock_wall_clock pvclock_wall_clock_t;
+
+typedef struct msi_msg {
uint32_t address_lo; /* low 32 bits of msi message address */
uint32_t address_hi; /* high 32 bits of msi message address */
uint32_t data; /* 16 bits of msi message data */
-};
+} msi_msg_t;
-struct kvm_kernel_irq_routing_entry {
+typedef struct kvm_kernel_irq_routing_entry {
uint32_t gsi;
uint32_t type;
int (*set)(struct kvm_kernel_irq_routing_entry *e,
@@ -1139,13 +1139,13 @@ struct kvm_kernel_irq_routing_entry {
struct msi_msg msi;
};
struct list_node link;
-};
+} kvm_kernel_irq_routing_entry_t;
/*#ifdef __KVM_HAVE_IOAPIC*/
#define KVM_MAX_IRQ_ROUTES 1024
-struct kvm_irq_routing_table {
+typedef struct kvm_irq_routing_table {
int chip[KVM_NR_IRQCHIPS][KVM_IOAPIC_NUM_PINS];
struct kvm_kernel_irq_routing_entry *rt_entries;
uint32_t nr_rt_entries;
@@ -1154,18 +1154,18 @@ struct kvm_irq_routing_table {
* the gsi is connected to.
*/
list_t map[KVM_MAX_IRQ_ROUTES+1];
-};
+} kvm_irq_routing_table_t;
-struct kvm_kirq_routing {
+typedef struct kvm_kirq_routing {
uint32_t nr;
uint32_t flags;
struct kvm_irq_routing_entry entries[KVM_MAX_IRQ_ROUTES+1];
-};
+} kvm_kirq_routing_t;
-struct kvm_irq_routing_ioc {
+typedef struct kvm_irq_routing_ioc {
struct kvm_kirq_routing kvm_kirq_routing;
int kvmid;
-};
+} kvm_irq_routing_ioc_t;
/*#endif __KVM_HAVE_IOAPIC*/
@@ -1176,13 +1176,13 @@ struct kvm_irq_routing_ioc {
#ifdef _KERNEL
-struct kvm_shadow_walk_iterator {
+typedef struct kvm_shadow_walk_iterator {
uint64_t addr;
hpa_t shadow_addr;
uint64_t *sptep;
int level;
unsigned index;
-};
+} kvm_shadow_walk_iterator_t;
extern void shadow_walk_init(struct kvm_shadow_walk_iterator *iterator,
struct kvm_vcpu *vcpu, uint64_t addr);
@@ -1200,7 +1200,7 @@ enum kvm_bus {
KVM_NR_BUSES
};
-struct kvm {
+typedef struct kvm {
kmutex_t mmu_lock;
kmutex_t requests_lock;
kmutex_t slots_lock;
@@ -1247,7 +1247,7 @@ struct kvm {
long mmu_notifier_count;
#endif
int kvmid; /* unique identifier for this kvm */
-};
+} kvm_t;
#endif /*_KERNEL*/
#define KVM_EXIT_UNKNOWN 0
@@ -1274,7 +1274,7 @@ struct kvm {
#define KVM_INTERNAL_ERROR_SIMUL_EX 2
/* for KVM_RUN, returned by mmap(vcpu_fd, offset=0) */
-struct kvm_run {
+typedef struct kvm_run {
/* in */
unsigned char request_interrupt_window;
unsigned char padding1[7];
@@ -1380,7 +1380,7 @@ struct kvm_run {
/* Fix the size of the union. */
char padding[256];
};
-};
+} kvm_run_t;
/* the following is directly copied from ioctl.h on linux */
#ifndef _ASM_GENERIC_IOCTL_H
@@ -1503,20 +1503,20 @@ static void native_load_tr_desc(void)
#define KVMIO 0xAE
/* for KVM_SET_CPUID2/KVM_GET_CPUID2 */
-struct kvm_cpuid2_ioc {
+typedef struct kvm_cpuid2_ioc {
struct kvm_cpuid2 cpuid_data;
int kvm_id;
int cpu_index;
-};
+} kvm_cpuid2_ioc_t;
/* for KVM_RUN */
-struct kvm_run_ioc {
+typedef struct kvm_run_ioc {
int kvm_kvmid;
int kvm_cpu_index;
-};
+} kvm_run_ioc_t;
/* x86 MCE */
-struct kvm_x86_mce {
+typedef struct kvm_x86_mce {
uint64_t status;
uint64_t addr;
uint64_t misc;
@@ -1524,30 +1524,30 @@ struct kvm_x86_mce {
uint8_t bank;
uint8_t pad1[7];
uint64_t pad2[3];
-};
+} kvm_x86_mce_t;
-struct kvm_clock_data {
+typedef struct kvm_clock_data {
uint64_t clock;
uint32_t flags;
uint32_t pad[9];
-};
+} kvm_clock_data_t;
/* for KVM_SET_SIGNAL_MASK */
-struct kvm_signal_mask {
+typedef struct kvm_signal_mask {
uint32_t len;
uint8_t sigset[1];
-};
+} kvm_signal_mask_t;
-struct kvm_pit_s2_ioc {
+typedef struct kvm_pit_s2_ioc {
int kvmid;
int pad;
struct kvm_pit_state2 s;
-};
+} kvm_pit_s2_ioc_t;
-struct kvm_set_boot_cpu_id_ioc {
+typedef struct kvm_set_boot_cpu_id_ioc {
int kvmid;
int id;
-};
+} kvm_set_boot_cpu_id_ioc_t;
/*
* ioctls for vcpu fds
@@ -1603,7 +1603,7 @@ struct kvm_set_boot_cpu_id_ioc {
#define KVM_GET_SUPPORTED_CPUID _IOWR(KVMIO, 0x05, struct kvm_cpuid2)
/* for KVM_IRQ_LINE */
-struct kvm_irq_level {
+typedef struct kvm_irq_level {
/*
* ACPI gsi notion of irq.
* For IA-64 (APIC model) IOAPIC0: irq 0-23; IOAPIC1: irq 24-47..
@@ -1614,37 +1614,37 @@ struct kvm_irq_level {
int32_t status;
};
uint32_t level;
-};
+} kvm_irq_level_t;
-struct kvm_irq_level_ioc {
+typedef struct kvm_irq_level_ioc {
struct kvm_irq_level event;
int kvmid;
-};
+} kvm_irq_level_ioc_t;
/*
* for KVM_SET_IDENTITY_MAP_ADDR
*/
-struct kvm_id_map_addr {
+typedef struct kvm_id_map_addr {
int kvmid;
int pad;
uint64_t addr;
-};
+} kvm_id_map_addr_t;
-struct kvm_create_pit_ioc {
+typedef struct kvm_create_pit_ioc {
int kvmid;
-};
+} kvm_create_pit_ioc_t;
/* for KVM_CREATE_IRQCHIP */
-struct kvm_irq_ioc {
+typedef struct kvm_irq_ioc {
int kvmid;
-};
+} kvm_irq_ioc_t;
/* for KVM_SET_IDENTITY_MAP_ADDR */
-struct kvm_id_map_addr_ioc {
+typedef struct kvm_id_map_addr_ioc {
uint64_t ident_addr;
int kvmid;
-};
+} kvm_id_map_addr_ioc_t;
/*
@@ -1688,7 +1688,7 @@ struct kvm_id_map_addr_ioc {
*/
#define KVM_CHECK_EXTENSION _IO(KVMIO, 0x03)
-struct vmcs_config {
+typedef struct vmcs_config {
int size;
int order;
uint32_t revision_id;
@@ -1697,80 +1697,80 @@ struct vmcs_config {
uint32_t cpu_based_2nd_exec_ctrl;
uint32_t vmexit_ctrl;
uint32_t vmentry_ctrl;
-};
+} vmcs_config_t;
#define RMAP_EXT 4
-struct kvm_rmap_desc {
+typedef struct kvm_rmap_desc {
uint64_t *sptes[RMAP_EXT];
struct kvm_rmap_desc *more;
-};
+} kvm_rmap_desc_t;
-struct vmx_capability {
+typedef struct vmx_capability {
uint32_t ept;
uint32_t vpid;
-};
+} vmx_capability_t;
-struct vmcs {
+typedef struct vmcs {
uint32_t revision_id;
uint32_t abort;
char data[1]; /* size is read from MSR */
-};
+} vmcs_t;
/* for KVM_INTERRUPT */
-struct kvm_interrupt {
+typedef struct kvm_interrupt {
/* in */
uint32_t irq;
-};
+} kvm_interrupt_t;
-struct kvm_interrupt_ioc {
+typedef struct kvm_interrupt_ioc {
struct kvm_interrupt intr;
int kvm_kvmid;
int kvm_cpu_index;
-};
+} kvm_interrupt_ioc_t;
/* for KVM_GET_DIRTY_LOG */
-struct kvm_dirty_log {
+typedef struct kvm_dirty_log {
uint32_t slot;
uint32_t padding1;
union {
void *dirty_bitmap; /* one bit per page */
uint64_t padding2;
}v;
-};
+} kvm_dirty_log_t;
-struct kvm_dirty_log_ioc {
+typedef struct kvm_dirty_log_ioc {
struct kvm_dirty_log d;
int kvmid;
-};
+} kvm_dirty_log_ioc_t;
-struct kvm_coalesced_mmio {
+typedef struct kvm_coalesced_mmio {
uint64_t phys_addr;
uint32_t len;
uint32_t pad;
unsigned char data[8];
-};
+} kvm_coalesced_mmio_t;
-struct kvm_coalesced_mmio_ring {
+typedef struct kvm_coalesced_mmio_ring {
uint32_t first, last;
struct kvm_coalesced_mmio coalesced_mmio[1];
-};
+} kvm_coalesced_mmio_ring_t;
#define KVM_COALESCED_MMIO_MAX \
((PAGESIZE - sizeof(struct kvm_coalesced_mmio_ring)) / \
sizeof(struct kvm_coalesced_mmio))
/* for KVM_SET_VAPIC_ADDR */
-struct kvm_vapic_addr {
+typedef struct kvm_vapic_addr {
uint64_t vapic_addr;
-};
+} kvm_vapic_addr_t;
-struct kvm_vapic_ioc {
+typedef struct kvm_vapic_ioc {
int kvm_cpu_index;
int kvm_kvmid;
struct kvm_vapic_addr va;
-};
+} kvm_vapic_ioc_t;
@@ -1783,17 +1783,17 @@ struct kvm_vapic_ioc {
#define KVM_MP_STATE_SIPI_RECEIVED 4
/* for KVM_TPR_ACCESS_REPORTING */
-struct kvm_tpr_access_ctl {
+typedef struct kvm_tpr_access_ctl {
uint32_t enabled;
uint32_t flags;
uint32_t reserved[8];
-};
+} kvm_tpr_access_ctl_t;
-struct kvm_tpr_acl_ioc {
+typedef struct kvm_tpr_acl_ioc {
struct kvm_tpr_access_ctl tac;
int kvm_id;
int cpu_index;
-};
+} kvm_tpr_acl_ioc_t;
#define KVM_SET_CPUID2 _IOW(KVMIO, 0x90, struct kvm_cpuid2_ioc)
#define KVM_GET_CPUID2 _IOWR(KVMIO, 0x91, struct kvm_cpuid2_ioc)
@@ -1812,28 +1812,28 @@ struct kvm_tpr_acl_ioc {
/* for KVM_CREATE_MEMORY_REGION */
-struct kvm_memory_region {
+typedef struct kvm_memory_region {
uint32_t slot;
uint32_t flags;
uint64_t guest_phys_addr;
uint64_t memory_size; /* bytes */
-};
+} kvm_memory_region_t;
/* for KVM_SET_USER_MEMORY_REGION */
-struct kvm_userspace_memory_region {
+typedef struct kvm_userspace_memory_region {
uint32_t slot;
uint32_t flags;
uint64_t guest_phys_addr;
uint64_t memory_size; /* bytes */
uint64_t userspace_addr; /* start of the userspace allocated memory */
-};
+} kvm_userspace_memory_region_t;
/* for KVM_SET_USER_MEMORY_REGION */
-struct kvm_set_user_memory_ioc {
+typedef struct kvm_set_user_memory_ioc {
struct kvm_userspace_memory_region kvm_userspace_map;
int32_t kvmid;
int32_t pad;
-};
+} kvm_set_user_memory_ioc_t;
#ifdef XXX
#define KVM_SET_USER_MEMORY_REGION _IOW(KVMIO, 0x46, \
@@ -1844,18 +1844,18 @@ struct kvm_set_user_memory_ioc {
#endif /*XXX*/
/* for KVM_SET_TSS_ADDR ioctl */
-struct kvm_tss {
+typedef struct kvm_tss {
uint64_t addr; /* in */
int kvmid;
-};
+} kvm_tss_t;
/* for KVM_CREATE_VCPU */
-struct kvm_vcpu_ioc {
+typedef struct kvm_vcpu_ioc {
uint32_t id; /*IN*/
int32_t kvmid;
uint64_t kvm_run_addr; /*OUT*/
uint64_t kvm_vcpu_addr; /* OUT, id is not unique across VMs */
-};
+} kvm_vcpu_ioc_t;
@@ -1869,14 +1869,16 @@ struct ldttss_desc64 {
uint32_t zero1;
} __attribute__((packed));
-struct shared_msr_entry {
+typedef struct ldttss_desc64 ldttss_desc64_t;
+
+typedef struct shared_msr_entry {
unsigned index;
uint64_t data;
uint64_t mask;
-};
+} shared_msr_entry_t;
#ifdef _KERNEL
-struct vcpu_vmx {
+typedef struct vcpu_vmx {
struct kvm_vcpu vcpu;
list_t local_vcpus_link;
unsigned long host_rsp;
@@ -1922,7 +1924,7 @@ struct vcpu_vmx {
uint32_t exit_reason;
char rdtscp_enabled;
-};
+} vcpu_vmx_t;
#define kvm_for_each_vcpu(idx, vcpup, kvm) \
for (idx = 0, vcpup = kvm_get_vcpu(kvm, idx); \
@@ -1932,11 +1934,11 @@ struct vcpu_vmx {
extern struct kvm_vcpu *kvm_get_vcpu(struct kvm *kvm, int i);
#ifdef XXX
-struct kvm_irq_mask_notifier {
+typedef struct kvm_irq_mask_notifier {
void (*func)(struct kvm_irq_mask_notifier *kimn, bool masked);
int irq;
struct list_node link;
-};
+} kvm_irq_mask_notifier_t;
#endif /*XXX*/
#ifdef __KVM_HAVE_IOAPIC
@@ -1985,7 +1987,7 @@ static void kvm_free_irq_routing(struct kvm *kvm) {}
#define KVM_USERSPACE_IRQ_SOURCE_ID 0
-struct kvm_kpit_channel_state {
+typedef struct kvm_kpit_channel_state {
uint32_t count; /* can be 65536 */
uint16_t latched_count;
uint8_t count_latched;
@@ -1999,9 +2001,9 @@ struct kvm_kpit_channel_state {
uint8_t bcd; /* not supported */
uint8_t gate; /* timer start */
hrtime_t count_load_time;
-};
+} kvm_kpit_channel_state_t;
-struct kvm_kpit_state {
+typedef struct kvm_kpit_state {
struct kvm_kpit_channel_state channels[3];
uint32_t flags;
struct kvm_timer pit_timer;
@@ -2012,9 +2014,9 @@ struct kvm_kpit_state {
kmutex_t inject_lock;
unsigned long irq_ack;
struct kvm_irq_ack_notifier irq_ack_notifier;
-};
+} kvm_kpit_state_t;
-struct kvm_pit {
+typedef struct kvm_pit {
unsigned long base_addresss;
struct kvm_io_device dev;
struct kvm_io_device speaker_dev;
@@ -2024,7 +2026,7 @@ struct kvm_pit {
#ifdef XXX
struct kvm_irq_mask_notifier mask_notifier;
#endif /*XXX*/
-};
+} kvm_pit_t;
#define KVM_PIT_BASE_ADDRESS 0x40
#define KVM_SPEAKER_BASE_ADDRESS 0x61
@@ -2064,11 +2066,11 @@ struct preempt_notifier;
* while sched_in is called without rq lock and irq enabled. This
* difference is intentional and depended upon by its users.
*/
-struct preempt_ops {
+typedef struct preempt_ops {
void (*sched_in)(struct preempt_notifier *notifier, int cpu);
void (*sched_out)(struct preempt_notifier *notifier,
struct task_struct *next);
-};
+} preempt_ops_t;
/**
* preempt_notifier - key for installing preemption notifiers
@@ -2077,10 +2079,10 @@ struct preempt_ops {
*
* Usually used in conjunction with container_of().
*/
-struct preempt_notifier {
+typedef struct preempt_notifier {
struct hlist_node link;
struct preempt_ops *ops;
-};
+} preempt_notifier_t;
void preempt_notifier_register(struct preempt_notifier *notifier);
void preempt_notifier_unregister(struct preempt_notifier *notifier);
@@ -2089,7 +2091,7 @@ void preempt_notifier_init(struct preempt_notifier *notifier,
#endif /*XXX*/
#endif /*CONFIG_PREEMPT_NOTIFIERS*/
-struct cpuid_data {
+typedef struct cpuid_data {
struct kvm_cpuid2 cpuid;
struct kvm_cpuid_entry2 entries[100];
} __attribute__((packed)) cpuid_data;
@@ -2100,11 +2102,11 @@ struct cpuid_data {
* so until then it will suffice. At least its abstracted so we can change
* in one place.
*/
-struct kvm_io_bus {
+typedef struct kvm_io_bus {
int dev_count;
#define NR_IOBUS_DEVS 200
struct kvm_io_device *devs[NR_IOBUS_DEVS];
-};
+} kvm_io_bus_t;
int kvm_io_bus_write(struct kvm *kvm, enum kvm_bus bus_idx, gpa_t addr,
int len, const void *val);
diff --git a/kvm_emulate.h b/kvm_emulate.h
index afdabb4..4026eea 100644
--- a/kvm_emulate.h
+++ b/kvm_emulate.h
@@ -51,7 +51,7 @@ struct x86_emulate_ctxt;
#define X86EMUL_PROPAGATE_FAULT 2 /* propagate a generated fault to guest */
#define X86EMUL_RETRY_INSTR 2 /* retry the instruction for some reason */
#define X86EMUL_CMPXCHG_FAILED 2 /* cmpxchg did not see expected value */
-struct x86_emulate_ops {
+typedef struct x86_emulate_ops {
/*
* read_std: Read bytes of standard (non-emulated/special) memory.
* Used for descriptor reading.
@@ -109,23 +109,23 @@ struct x86_emulate_ops {
unsigned int bytes,
struct kvm_vcpu *vcpu);
-};
+} x86_emulate_ops_t;
#endif /*_KERNEL*/
/* Type, address-of, and value of an instruction's operand. */
-struct operand {
+typedef struct operand {
enum { OP_REG, OP_MEM, OP_IMM, OP_NONE } type;
unsigned int bytes;
unsigned long val, orig_val, *ptr;
-};
+} operand_t;
-struct fetch_cache {
+typedef struct fetch_cache {
uint8_t data[15];
unsigned long start;
unsigned long end;
-};
+} fetch_cache_t;
-struct decode_cache {
+typedef struct decode_cache {
uint8_t twobyte;
uint8_t b;
uint8_t lock_prefix;
@@ -152,12 +152,12 @@ struct decode_cache {
void *modrm_ptr;
unsigned long modrm_val;
struct fetch_cache fetch;
-};
+} decode_cache_t;
#define X86_SHADOW_INT_MOV_SS 1
#define X86_SHADOW_INT_STI 2
-struct x86_emulate_ctxt {
+typedef struct x86_emulate_ctxt {
/* Register state before/after emulation. */
struct kvm_vcpu *vcpu;
@@ -171,7 +171,7 @@ struct x86_emulate_ctxt {
/* decode cache */
struct decode_cache decode;
-};
+} x86_emulate_ctxt_t;
/* Repeat String Operation Prefix */
#define REPE_PREFIX 1
diff --git a/kvm_host.h b/kvm_host.h
index d5144ba..c81718b 100644
--- a/kvm_host.h
+++ b/kvm_host.h
@@ -117,12 +117,12 @@ enum kvm_stat_kind {
KVM_STAT_VCPU,
};
-struct kvm_stats_debugfs_item {
+typedef struct kvm_stats_debugfs_item {
const char *name;
int offset;
enum kvm_stat_kind kind;
struct dentry *dentry;
-};
+} kvm_stats_debugfs_item_t;
extern struct kvm_stats_debugfs_item debugfs_entries[];
extern struct dentry *kvm_debugfs_dir;
diff --git a/kvm_types.h b/kvm_types.h
index 3901090..923950e 100644
--- a/kvm_types.h
+++ b/kvm_types.h
@@ -54,7 +54,7 @@ union kvm_ioapic_redirect_entry {
} fields;
};
-struct kvm_lapic_irq {
+typedef struct kvm_lapic_irq {
uint32_t vector;
uint32_t delivery_mode;
uint32_t dest_mode;
@@ -62,6 +62,6 @@ struct kvm_lapic_irq {
uint32_t trig_mode;
uint32_t shorthand;
uint32_t dest_id;
-};
+} kvm_lapic_irq_t;
#endif /* __KVM_TYPES_H__ */
diff --git a/kvm_x86host.h b/kvm_x86host.h
index b5051cd..f582ad5 100644
--- a/kvm_x86host.h
+++ b/kvm_x86host.h
@@ -158,18 +158,18 @@ enum kvm_reg_ex {
*/
#define KVM_NR_MEM_OBJS 40
-struct kvm_mmu_memory_cache {
+typedef struct kvm_mmu_memory_cache {
int nobjs;
void *objects[KVM_NR_MEM_OBJS];
-};
+} kvm_mmu_memory_cache_t;
#ifdef _KERNEL
#define NR_PTE_CHAIN_ENTRIES 5
-struct kvm_pte_chain {
+typedef struct kvm_pte_chain {
uint64_t *parent_ptes[NR_PTE_CHAIN_ENTRIES];
struct list_node link;
-};
+} kvm_pte_chain_t;
/*
* kvm_mmu_page_role, below, is defined as:
@@ -196,7 +196,7 @@ union kvm_mmu_page_role {
};
};
-struct kvm_mmu_page {
+typedef struct kvm_mmu_page {
struct list_node link;
struct list_node hash_link;
@@ -227,19 +227,19 @@ struct kvm_mmu_page {
list_t parent_ptes; /* multimapped, kvm_pte_chain */
};
unsigned long unsync_child_bitmap[BT_BITOUL(512)];
-};
+} kvm_mmu_page_t;
#endif /*_KERNEL*/
-struct kvm_pv_mmu_op_buffer {
+typedef struct kvm_pv_mmu_op_buffer {
void *ptr;
unsigned len;
unsigned processed;
char pad[2];
char buf[512];
-};
+} kvm_pv_mmu_op_buffer_t;
-struct kvm_pio_request {
+typedef struct kvm_pio_request {
unsigned long count;
int cur_count;
gva_t guest_gva;
@@ -249,7 +249,7 @@ struct kvm_pio_request {
int string;
int down;
int rep;
-};
+} kvm_pio_request_t;
#ifdef _KERNEL
/*
@@ -257,7 +257,7 @@ struct kvm_pio_request {
* 32-bit). The kvm_mmu structure abstracts the details of the current mmu
* mode.
*/
-struct kvm_mmu {
+typedef struct kvm_mmu {
void (*new_cr3)(struct kvm_vcpu *vcpu);
int (*page_fault)(struct kvm_vcpu *vcpu, gva_t gva, uint32_t err);
void (*free)(struct kvm_vcpu *vcpu);
@@ -275,11 +275,11 @@ struct kvm_mmu {
uint64_t *pae_root;
uint64_t rsvd_bits_mask[2][4];
-};
+} kvm_mmu_t;
#endif /*_KERNEL*/
-struct kvm_cpuid_entry2 {
+typedef struct kvm_cpuid_entry2 {
uint32_t function;
uint32_t index;
uint32_t flags;
@@ -288,9 +288,9 @@ struct kvm_cpuid_entry2 {
uint32_t ecx;
uint32_t edx;
uint32_t padding[3];
-};
+} kvm_cpuid_entry2_t;
-struct kvm_segment {
+typedef struct kvm_segment {
uint64_t base;
uint32_t limit;
unsigned short selector;
@@ -298,7 +298,7 @@ struct kvm_segment {
unsigned char present, dpl, db, s, l, g, avl;
unsigned char unusable;
unsigned char padding;
-};
+} kvm_segment_t;
#ifdef _KERNEL
@@ -312,20 +312,20 @@ typedef unsigned char mtrr_type;
#define MTRR_NUM_FIXED_RANGES 88
#define MTRR_MAX_VAR_RANGES 256
-struct mtrr_var_range {
+typedef struct mtrr_var_range {
uint32_t base_lo;
uint32_t base_hi;
uint32_t mask_lo;
uint32_t mask_hi;
-};
+} mtrr_var_range_t;
-struct mtrr_state_type {
+typedef struct mtrr_state_type {
struct mtrr_var_range var_ranges[MTRR_MAX_VAR_RANGES];
mtrr_type fixed_ranges[MTRR_NUM_FIXED_RANGES];
unsigned char enabled;
unsigned char have_fixed;
mtrr_type def_type;
-};
+} mtrr_state_type_t;
struct i387_fxsave_struct {
unsigned short cwd; /* Control Word */
@@ -362,6 +362,8 @@ struct i387_fxsave_struct {
} __attribute__((aligned(16)));
+typedef struct i387_fxsave_struct i387_fxsave_struct_t;
+
/*
* These structs MUST NOT be changed.
* They are the ABI between hypervisor and guest OS.
@@ -392,7 +394,9 @@ struct pvclock_vcpu_time_info {
unsigned char pad[3];
} __attribute__((__packed__)); /* 32 bytes */
-struct kvm_vcpu_arch {
+typedef struct pvclock_vcpu_time_info pvclock_vcpu_time_info_t;
+
+typedef struct kvm_vcpu_arch {
uint64_t host_tsc;
/*
* rip and regs accesses must go through
@@ -505,24 +509,24 @@ struct kvm_vcpu_arch {
unsigned long singlestep_rip;
/* fields used by HYPER-V emulation */
uint64_t hv_vapic;
-};
+} kvm_vcpu_arch_t;
-struct kvm_mem_alias {
+typedef struct kvm_mem_alias {
gfn_t base_gfn;
unsigned long npages;
gfn_t target_gfn;
#define KVM_ALIAS_INVALID 1UL
unsigned long flags;
-};
+} kvm_mem_alias_t;
#define KVM_ARCH_HAS_UNALIAS_INSTANTIATION
-struct kvm_mem_aliases {
+typedef struct kvm_mem_aliases {
struct kvm_mem_alias aliases[KVM_ALIAS_SLOTS];
int naliases;
-};
+} kvm_mem_aliases_t;
-struct kvm_xen_hvm_config {
+typedef struct kvm_xen_hvm_config {
uint32_t flags;
uint32_t msr;
uint64_t blob_addr_32;
@@ -530,11 +534,11 @@ struct kvm_xen_hvm_config {
unsigned char blob_size_32;
unsigned char blob_size_64;
unsigned char pad2[30];
-};
+} kvm_xen_hvm_config_t;
-struct kvm_arch {
+typedef struct kvm_arch {
struct kvm_mem_aliases *aliases;
unsigned int n_free_mmu_pages;
@@ -571,9 +575,9 @@ struct kvm_arch {
/* fields used by HYPER-V emulation */
uint64_t hv_guest_os_id;
uint64_t hv_hypercall;
-};
+} kvm_arch_t;
-struct kvm_vm_stat {
+typedef struct kvm_vm_stat {
uint32_t mmu_shadow_zapped;
uint32_t mmu_pte_write;
uint32_t mmu_pte_updated;
@@ -584,9 +588,9 @@ struct kvm_vm_stat {
uint32_t mmu_unsync;
uint32_t remote_tlb_flush;
uint32_t lpages;
-};
+} kvm_vm_stat_t;
-struct kvm_vcpu_stat {
+typedef struct kvm_vcpu_stat {
uint32_t pf_fixed;
uint32_t pf_guest;
uint32_t tlb_flush;
@@ -610,7 +614,7 @@ struct kvm_vcpu_stat {
uint32_t hypercalls;
uint32_t irq_injections;
uint32_t nmi_injections;
-};
+} kvm_vcpu_stat_t;
#define KVM_GUESTDBG_USE_SW_BP 0x00010000
#define KVM_GUESTDBG_USE_HW_BP 0x00020000
@@ -618,29 +622,31 @@ struct kvm_vcpu_stat {
#define KVM_GUESTDBG_INJECT_BP 0x00080000
/* for KVM_SET_GUEST_DEBUG */
-struct kvm_guest_debug_arch {
+typedef struct kvm_guest_debug_arch {
uint64_t debugreg[8];
-};
+} kvm_guest_debug_arch_t;
/* for KVM_SET_GUEST_DEBUG */
#define KVM_GUESTDBG_ENABLE 0x00000001
#define KVM_GUESTDBG_SINGLESTEP 0x00000002
-struct kvm_guest_debug {
+typedef struct kvm_guest_debug {
uint32_t control;
uint32_t pad;
struct kvm_guest_debug_arch arch;
-};
+} kvm_guest_debug_t;
struct descriptor_table {
unsigned short limit;
unsigned long base;
} __attribute__((packed));
+typedef struct descriptor_table descriptor_table_t;
+
struct kvm_vcpu_ioc;
-struct kvm_x86_ops {
+typedef struct kvm_x86_ops {
int (*cpu_has_kvm_support)(void); /* __init */
int (*disabled_by_bios)(void); /* __init */
int (*hardware_enable)(void *dummy);
@@ -716,7 +722,7 @@ struct kvm_x86_ops {
int (*get_lpage_level)(void);
int (*rdtscp_supported)(void);
const struct trace_print_flags *exit_reasons_str;
-};
+} kvm_x86_ops_t;
extern struct kvm_x86_ops *kvm_x86_ops;
@@ -930,6 +936,8 @@ struct desc_struct {
}c;
} __attribute__((packed));
+typedef struct desc_struct desc_struct_t;
+
static unsigned long get_desc_base(const struct desc_struct *desc)
{
return (unsigned)(desc->c.b.base0 | ((desc->c.b.base1) << 16) | ((desc->c.b.base2) << 24));
diff --git a/msr.h b/msr.h
index 96b4e34..f804e16 100644
--- a/msr.h
+++ b/msr.h
@@ -19,7 +19,7 @@
#include <asm/cpumask.h>
#endif /*XXX*/
-struct msr {
+typedef struct msr {
union {
struct {
uint32_t l;
@@ -27,19 +27,19 @@ struct msr {
};
uint64_t q;
}b;
-};
+} msr_t;
-struct msr_info {
+typedef struct msr_info {
uint32_t msr_no;
struct msr reg;
struct msr *msrs;
int err;
-};
+} msr_info_t;
-struct msr_regs_info {
+typedef struct msr_regs_info {
uint32_t *regs;
int err;
-};
+} msr_regs_info_t;
extern unsigned long long native_read_tscp(unsigned int *aux);
diff --git a/tss.h b/tss.h
index 4d95c26..ad632c9 100644
--- a/tss.h
+++ b/tss.h
@@ -1,7 +1,7 @@
#ifndef __TSS_SEGMENT_H
#define __TSS_SEGMENT_H
-struct tss_segment_32 {
+typedef struct tss_segment_32 {
uint32_t prev_task_link;
uint32_t esp0;
uint32_t ss0;
@@ -29,9 +29,9 @@ struct tss_segment_32 {
uint32_t ldt_selector;
uint16_t t;
uint16_t io_map;
-};
+} tss_segment_32_t;
-struct tss_segment_16 {
+typedef struct tss_segment_16 {
uint16_t prev_task_link;
uint16_t sp0;
uint16_t ss0;
@@ -54,6 +54,6 @@ struct tss_segment_16 {
uint16_t ss;
uint16_t ds;
uint16_t ldt;
-};
+} tss_segment_16_t;
#endif
diff --git a/vmcs_dump.h b/vmcs_dump.h
index 9bdbaa0..34da250 100755..100644
--- a/vmcs_dump.h
+++ b/vmcs_dump.h
@@ -5,7 +5,7 @@
/* note that a vmcs must be loaded (via vcpu_load) */
/* of course, x86/x64 only */
-struct vmcs_dump_area {
+typedef struct vmcs_dump_area {
int where; /* 0, 1, or 2 depending on when the area is dumped to */
uint16_t virtual_processor_id;
uint16_t guest_es_selector;
@@ -155,4 +155,4 @@ struct vmcs_dump_area {
long host_ia32_sysenter_eip;
long host_rsp;
long host_rip;
-};
+} vmcs_dump_area_t;