aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/kvm
diff options
context:
space:
mode:
authorQing He <qing.he@intel.com>2007-07-12 05:33:56 -0400
committerAvi Kivity <avi@qumranet.com>2007-10-13 04:18:17 -0400
commitdad3795d2baa4e02cbfd161d9089c73dea16b4ba (patch)
tree56bedc042a5ba0a2b92eecc4e488b0328a35db54 /drivers/kvm
parentcd0d91379776cb6850c7b11c0a8843ca75967558 (diff)
KVM: SMP: Add vcpu_id field in struct vcpu
This patch adds a `vcpu_id' field in `struct vcpu', so we can differentiate BSP and APs without pointer comparison or arithmetic. Signed-off-by: Qing He <qing.he@intel.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
Diffstat (limited to 'drivers/kvm')
-rw-r--r--drivers/kvm/kvm.h1
-rw-r--r--drivers/kvm/kvm_main.c1
-rw-r--r--drivers/kvm/svm.c2
-rw-r--r--drivers/kvm/vmx.c2
4 files changed, 4 insertions, 2 deletions
diff --git a/drivers/kvm/kvm.h b/drivers/kvm/kvm.h
index 336be86c6f5a..b629a83eb82d 100644
--- a/drivers/kvm/kvm.h
+++ b/drivers/kvm/kvm.h
@@ -328,6 +328,7 @@ void kvm_io_bus_register_dev(struct kvm_io_bus *bus,
328 328
329struct kvm_vcpu { 329struct kvm_vcpu {
330 struct kvm *kvm; 330 struct kvm *kvm;
331 int vcpu_id;
331 union { 332 union {
332 struct vmcs *vmcs; 333 struct vmcs *vmcs;
333 struct vcpu_svm *svm; 334 struct vcpu_svm *svm;
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
index 36a458f13ec4..df9c05e9b34e 100644
--- a/drivers/kvm/kvm_main.c
+++ b/drivers/kvm/kvm_main.c
@@ -2355,6 +2355,7 @@ static int kvm_vm_ioctl_create_vcpu(struct kvm *kvm, int n)
2355 goto out; 2355 goto out;
2356 2356
2357 vcpu = &kvm->vcpus[n]; 2357 vcpu = &kvm->vcpus[n];
2358 vcpu->vcpu_id = n;
2358 2359
2359 mutex_lock(&vcpu->mutex); 2360 mutex_lock(&vcpu->mutex);
2360 2361
diff --git a/drivers/kvm/svm.c b/drivers/kvm/svm.c
index bc818cc126e3..52a11ccdf0c2 100644
--- a/drivers/kvm/svm.c
+++ b/drivers/kvm/svm.c
@@ -591,7 +591,7 @@ static int svm_create_vcpu(struct kvm_vcpu *vcpu)
591 fx_init(vcpu); 591 fx_init(vcpu);
592 vcpu->fpu_active = 1; 592 vcpu->fpu_active = 1;
593 vcpu->apic_base = 0xfee00000 | MSR_IA32_APICBASE_ENABLE; 593 vcpu->apic_base = 0xfee00000 | MSR_IA32_APICBASE_ENABLE;
594 if (vcpu == &vcpu->kvm->vcpus[0]) 594 if (vcpu->vcpu_id == 0)
595 vcpu->apic_base |= MSR_IA32_APICBASE_BSP; 595 vcpu->apic_base |= MSR_IA32_APICBASE_BSP;
596 596
597 return 0; 597 return 0;
diff --git a/drivers/kvm/vmx.c b/drivers/kvm/vmx.c
index 80628f69916d..7fa62c780ce4 100644
--- a/drivers/kvm/vmx.c
+++ b/drivers/kvm/vmx.c
@@ -1253,7 +1253,7 @@ static int vmx_vcpu_setup(struct kvm_vcpu *vcpu)
1253 vcpu->regs[VCPU_REGS_RDX] = get_rdx_init_val(); 1253 vcpu->regs[VCPU_REGS_RDX] = get_rdx_init_val();
1254 vcpu->cr8 = 0; 1254 vcpu->cr8 = 0;
1255 vcpu->apic_base = 0xfee00000 | MSR_IA32_APICBASE_ENABLE; 1255 vcpu->apic_base = 0xfee00000 | MSR_IA32_APICBASE_ENABLE;
1256 if (vcpu == &vcpu->kvm->vcpus[0]) 1256 if (vcpu->vcpu_id == 0)
1257 vcpu->apic_base |= MSR_IA32_APICBASE_BSP; 1257 vcpu->apic_base |= MSR_IA32_APICBASE_BSP;
1258 1258
1259 fx_init(vcpu); 1259 fx_init(vcpu);