summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--kvm.c14
-rw-r--r--kvm_host.h3
-rw-r--r--kvm_x86.c12
-rw-r--r--kvm_x86.h8
4 files changed, 26 insertions, 11 deletions
diff --git a/kvm.c b/kvm.c
index a53a35a..47f7c62 100644
--- a/kvm.c
+++ b/kvm.c
@@ -1984,26 +1984,28 @@ kvm_ioctl(dev_t dev, int cmd, intptr_t arg, int md, cred_t *cr, int *rv)
if (ioctl->vmwide) {
kvm_t *kvmp;
- int (*func)(kvm_t *, void *, int *);
+ int (*func)(kvm_t *, void *, int *, intptr_t);
if ((kvmp = ksp->kds_kvmp) == NULL) {
kmem_free(buf, ioctl->size);
return (EINVAL);
}
- func = (int(*)(kvm_t *, void *, int *))ioctl->func;
- rval = func(kvmp, buf, rv);
+ func = (int(*)(kvm_t *, void *, int *,
+ intptr_t))ioctl->func;
+ rval = func(kvmp, buf, rv, arg);
} else {
kvm_vcpu_t *vcpu;
- int (*func)(kvm_vcpu_t *, void *, int *);
+ int (*func)(kvm_vcpu_t *, void *, int *, intptr_t);
if ((vcpu = ksp->kds_vcpu) == NULL) {
kmem_free(buf, ioctl->size);
return (EINVAL);
}
- func = (int(*)(kvm_vcpu_t *, void *, int *))ioctl->func;
- rval = func(vcpu, buf, rv);
+ func = (int(*)(kvm_vcpu_t *, void *, int *,
+ intptr_t))ioctl->func;
+ rval = func(vcpu, buf, rv, arg);
}
if (rval == 0 && ioctl->size != 0 && ioctl->copyout) {
diff --git a/kvm_host.h b/kvm_host.h
index 1fe76ba..a22e84b 100644
--- a/kvm_host.h
+++ b/kvm_host.h
@@ -358,7 +358,8 @@ int kvm_vcpu_ioctl_get_msrs(struct kvm_vcpu *vcpu, struct kvm_msrs *msrs, int *r
int kvm_vcpu_ioctl_set_msrs(struct kvm_vcpu *vcpu, struct kvm_msrs *msrs, int *rv);
int kvm_vcpu_ioctl_x86_setup_mce(struct kvm_vcpu *vcpu, uint64_t *mcg_capp);
int kvm_vcpu_ioctl_get_cpuid2(struct kvm_vcpu *vcpu, struct kvm_cpuid2 *cpuid);
-int kvm_vcpu_ioctl_set_cpuid2(struct kvm_vcpu *vcpu, struct kvm_cpuid2 *cpuid);
+int kvm_vcpu_ioctl_set_cpuid2(struct kvm_vcpu *, struct kvm_cpuid2 *, int *,
+ intptr_t);
int kvm_vcpu_ioctl_get_lapic(struct kvm_vcpu *vcpu, struct kvm_lapic_state *s);
int kvm_vcpu_ioctl_set_lapic(struct kvm_vcpu *vcpu, struct kvm_lapic_state *s);
int kvm_vcpu_ioctl_x86_get_vcpu_events(struct kvm_vcpu *vcpu,
diff --git a/kvm_x86.c b/kvm_x86.c
index 25d350d..17c6fe0 100644
--- a/kvm_x86.c
+++ b/kvm_x86.c
@@ -1662,13 +1662,19 @@ is_efer_nx(void)
}
int
-kvm_vcpu_ioctl_set_cpuid2(struct kvm_vcpu *vcpu, struct kvm_cpuid2 *cpuid)
+kvm_vcpu_ioctl_set_cpuid2(struct kvm_vcpu *vcpu, struct kvm_cpuid2 *cpuid,
+ int *rv, intptr_t arg)
{
+ struct kvm_cpuid2 *id;
+
+ id = (void *)arg;
+
if (cpuid->nent > KVM_MAX_CPUID_ENTRIES)
return (E2BIG);
- bcopy(cpuid->entries, vcpu->arch.cpuid_entries,
- cpuid->nent * sizeof (struct kvm_cpuid_entry2));
+ if (copyin(id->entries, vcpu->arch.cpuid_entries,
+ cpuid->nent * sizeof (struct kvm_cpuid_entry2)) < 0)
+ return (EFAULT);
vcpu_load(vcpu);
vcpu->arch.cpuid_nent = cpuid->nent;
diff --git a/kvm_x86.h b/kvm_x86.h
index a245b6f..176bb09 100644
--- a/kvm_x86.h
+++ b/kvm_x86.h
@@ -1,6 +1,12 @@
#ifndef __KVM_X86_H
#define __KVM_X86_H
+/* See <sys/kvm.h> for an explanation of why this is necessary */
+#ifndef __GNUC__
+#error "The KVM Header files require GNU C extensions for compatibility."
+#endif
+
+
#include <sys/types.h>
#define KVM_NR_INTERRUPTS 256
@@ -170,7 +176,7 @@ typedef struct kvm_cpuid_entry2 {
typedef struct kvm_cpuid2 {
uint32_t nent;
uint32_t padding;
- struct kvm_cpuid_entry2 entries[100];
+ struct kvm_cpuid_entry2 entries[0];
} kvm_cpuid2_t;
/* for KVM_GET_PIT and KVM_SET_PIT */