From: Zhang Xiantao <[EMAIL PROTECTED]> Date: Fri, 14 Dec 2007 01:33:04 +0800 Subject: [PATCH] kvm: portabiltiy: Moving cpuid_entries to arch
This patch moves cpuid_entries to kvm_vcpu_arch. Signed-off-by: Zhang Xiantao <[EMAIL PROTECTED]> --- drivers/kvm/x86.c | 50 +++++++++++++++++++++++++------------------------- drivers/kvm/x86.h | 5 ++--- 2 files changed, 27 insertions(+), 28 deletions(-) diff --git a/drivers/kvm/x86.c b/drivers/kvm/x86.c index 41d8e37..1333103 100644 --- a/drivers/kvm/x86.c +++ b/drivers/kvm/x86.c @@ -760,8 +760,8 @@ static void cpuid_fix_nx_cap(struct kvm_vcpu *vcpu) struct kvm_cpuid_entry2 *e, *entry; entry = NULL; - for (i = 0; i < vcpu->cpuid_nent; ++i) { - e = &vcpu->cpuid_entries[i]; + for (i = 0; i < vcpu->arch.cpuid_nent; ++i) { + e = &vcpu->arch.cpuid_entries[i]; if (e->function == 0x80000001) { entry = e; break; @@ -793,18 +793,18 @@ static int kvm_vcpu_ioctl_set_cpuid(struct kvm_vcpu *vcpu, cpuid->nent * sizeof(struct kvm_cpuid_entry))) goto out_free; for (i = 0; i < cpuid->nent; i++) { - vcpu->cpuid_entries[i].function = cpuid_entries[i].function; - vcpu->cpuid_entries[i].eax = cpuid_entries[i].eax; - vcpu->cpuid_entries[i].ebx = cpuid_entries[i].ebx; - vcpu->cpuid_entries[i].ecx = cpuid_entries[i].ecx; - vcpu->cpuid_entries[i].edx = cpuid_entries[i].edx; - vcpu->cpuid_entries[i].index = 0; - vcpu->cpuid_entries[i].flags = 0; - vcpu->cpuid_entries[i].padding[0] = 0; - vcpu->cpuid_entries[i].padding[1] = 0; - vcpu->cpuid_entries[i].padding[2] = 0; - } - vcpu->cpuid_nent = cpuid->nent; + vcpu->arch.cpuid_entries[i].function = cpuid_entries[i].function; + vcpu->arch.cpuid_entries[i].eax = cpuid_entries[i].eax; + vcpu->arch.cpuid_entries[i].ebx = cpuid_entries[i].ebx; + vcpu->arch.cpuid_entries[i].ecx = cpuid_entries[i].ecx; + vcpu->arch.cpuid_entries[i].edx = cpuid_entries[i].edx; + vcpu->arch.cpuid_entries[i].index = 0; + vcpu->arch.cpuid_entries[i].flags = 0; + vcpu->arch.cpuid_entries[i].padding[0] = 0; + vcpu->arch.cpuid_entries[i].padding[1] = 0; + vcpu->arch.cpuid_entries[i].padding[2] = 0; + } + vcpu->arch.cpuid_nent = cpuid->nent; cpuid_fix_nx_cap(vcpu); r = 0; @@ -824,10 +824,10 @@ static int kvm_vcpu_ioctl_set_cpuid2(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->arch.cpuid_entries, entries, cpuid->nent * sizeof(struct kvm_cpuid_entry2))) goto out; - vcpu->cpuid_nent = cpuid->nent; + vcpu->arch.cpuid_nent = cpuid->nent; return 0; out: @@ -841,16 +841,16 @@ static int kvm_vcpu_ioctl_get_cpuid2(struct kvm_vcpu *vcpu, int r; r = -E2BIG; - if (cpuid->nent < vcpu->cpuid_nent) + if (cpuid->nent < vcpu->arch.cpuid_nent) goto out; r = -EFAULT; - if (copy_to_user(entries, &vcpu->cpuid_entries, - vcpu->cpuid_nent * sizeof(struct kvm_cpuid_entry2))) + if (copy_to_user(entries, &vcpu->arch.cpuid_entries, + vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2))) goto out; return 0; out: - cpuid->nent = vcpu->cpuid_nent; + cpuid->nent = vcpu->arch.cpuid_nent; return r; } @@ -2297,13 +2297,13 @@ void realmode_set_cr(struct kvm_vcpu *vcpu, int cr, unsigned long val, static int move_to_next_stateful_cpuid_entry(struct kvm_vcpu *vcpu, int i) { - struct kvm_cpuid_entry2 *e = &vcpu->cpuid_entries[i]; - int j, nent = vcpu->cpuid_nent; + struct kvm_cpuid_entry2 *e = &vcpu->arch.cpuid_entries[i]; + int j, nent = vcpu->arch.cpuid_nent; e->flags &= ~KVM_CPUID_FLAG_STATE_READ_NEXT; /* when no next entry is found, the current entry[i] is reselected */ for (j = i + 1; j == i; j = (j + 1) % nent) { - struct kvm_cpuid_entry2 *ej = &vcpu->cpuid_entries[j]; + struct kvm_cpuid_entry2 *ej = &vcpu->arch.cpuid_entries[j]; if (ej->function == e->function) { ej->flags |= KVM_CPUID_FLAG_STATE_READ_NEXT; return j; @@ -2341,8 +2341,8 @@ void kvm_emulate_cpuid(struct kvm_vcpu *vcpu) vcpu->arch.regs[VCPU_REGS_RCX] = 0; vcpu->arch.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->arch.cpuid_nent; ++i) { + e = &vcpu->arch.cpuid_entries[i]; if (is_matching_cpuid_entry(e, function, index)) { if (e->flags & KVM_CPUID_FLAG_STATEFUL_FUNC) move_to_next_stateful_cpuid_entry(vcpu, i); diff --git a/drivers/kvm/x86.h b/drivers/kvm/x86.h index c4bb5fc..2a7bd5d 100644 --- a/drivers/kvm/x86.h +++ b/drivers/kvm/x86.h @@ -155,14 +155,13 @@ struct kvm_vcpu_arch { } rmode; int halt_request; /* real mode on Intel only */ + int cpuid_nent; + struct kvm_cpuid_entry2 cpuid_entries[KVM_MAX_CPUID_ENTRIES]; }; struct kvm_vcpu { KVM_VCPU_COMM; - int cpuid_nent; - struct kvm_cpuid_entry2 cpuid_entries[KVM_MAX_CPUID_ENTRIES]; - /* emulate context */ struct x86_emulate_ctxt emulate_ctxt; -- 1.5.1.2
0012-kvm-portabiltiy-Moving-cpuid_entries-to-arch.patch
Description: 0012-kvm-portabiltiy-Moving-cpuid_entries-to-arch.patch
------------------------------------------------------------------------- SF.Net email is sponsored by: Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel