cpuid should be VM wide instead of vCPU wide.

Signed-off-by: Xin Li <[EMAIL PROTECTED]>

diff --git a/drivers/kvm/kvm.h b/drivers/kvm/kvm.h
index b08272b..eb9a594 100644
--- a/drivers/kvm/kvm.h
+++ b/drivers/kvm/kvm.h
@@ -355,9 +355,6 @@ struct kvm_vcpu {
                } tr, es, ds, fs, gs;
        } rmode;
        int halt_request; /* real mode on Intel only */
-
-       int cpuid_nent;
-       struct kvm_cpuid_entry cpuid_entries[KVM_MAX_CPUID_ENTRIES];
 };
 
 struct kvm_mem_alias {
@@ -393,6 +390,9 @@ struct kvm {
        unsigned long rmap_overflow;
        struct list_head vm_list;
        struct file *filp;
+
+       int cpuid_nent;
+       struct kvm_cpuid_entry cpuid_entries[KVM_MAX_CPUID_ENTRIES];
 };
 
 struct descriptor_table {
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
index 633c2ed..098dc03 100644
--- a/drivers/kvm/kvm_main.c
+++ b/drivers/kvm/kvm_main.c
@@ -1698,8 +1698,8 @@ void kvm_emulate_cpuid(struct kvm_vcpu *vcpu)
        vcpu->regs[VCPU_REGS_RCX] = 0;
        vcpu->regs[VCPU_REGS_RDX] = 0;
        best = NULL;
-       for (i = 0; i < vcpu->cpuid_nent; ++i) {
-               e = &vcpu->cpuid_entries[i];
+       for (i = 0; i < vcpu->kvm->cpuid_nent; ++i) {
+               e = &vcpu->kvm->cpuid_entries[i];
                if (e->function == function) {
                        best = e;
                        break;
@@ -2461,8 +2461,8 @@ static void cpuid_fix_nx_cap(struct kvm_vcpu
*vcpu)
 
        rdmsrl(MSR_EFER, efer);
        entry = NULL;
-       for (i = 0; i < vcpu->cpuid_nent; ++i) {
-               e = &vcpu->cpuid_entries[i];
+       for (i = 0; i < vcpu->kvm->cpuid_nent; ++i) {
+               e = &vcpu->kvm->cpuid_entries[i];
                if (e->function == 0x80000001) {
                        entry = e;
                        break;
@@ -2484,10 +2484,10 @@ static int kvm_vcpu_ioctl_set_cpuid(struct
kvm_vcpu *vcpu,
        if (cpuid->nent > KVM_MAX_CPUID_ENTRIES)
                goto out;
        r = -EFAULT;
-       if (copy_from_user(&vcpu->cpuid_entries, entries,
+       if (copy_from_user(&vcpu->kvm->cpuid_entries, entries,
                           cpuid->nent * sizeof(struct
kvm_cpuid_entry)))
                goto out;
-       vcpu->cpuid_nent = cpuid->nent;
+       vcpu->kvm->cpuid_nent = cpuid->nent;
        cpuid_fix_nx_cap(vcpu);
        return 0;
 

Attachment: kvm_cpuid.patch
Description: kvm_cpuid.patch

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel

Reply via email to