From: Qing He <qing.he@intel.com>
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>
---
drivers/kvm/kvm.h | 1 +
drivers/kvm/kvm_main.c | 1 +
drivers/kvm/svm.c | 2 +-
drivers/kvm/vmx.c | 2 +-
4 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/kvm/kvm.h b/drivers/kvm/kvm.h
index 336be86..b629a83 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,
struct kvm_vcpu {
struct kvm *kvm;
+ int vcpu_id;
union {
struct vmcs *vmcs;
struct vcpu_svm *svm;
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
index 36a458f..df9c05e 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)
goto out;
vcpu = &kvm->vcpus[n];
+ vcpu->vcpu_id = n;
mutex_lock(&vcpu->mutex);
diff --git a/drivers/kvm/svm.c b/drivers/kvm/svm.c
index bc818cc..52a11cc 100644
--- a/drivers/kvm/svm.c
+++ b/drivers/kvm/svm.c
@@ -591,7 +591,7 @@ static int svm_create_vcpu(struct kvm_vcpu *vcpu)
fx_init(vcpu);
vcpu->fpu_active = 1;
vcpu->apic_base = 0xfee00000 | MSR_IA32_APICBASE_ENABLE;
- if (vcpu == &vcpu->kvm->vcpus[0])
+ if (vcpu->vcpu_id == 0)
vcpu->apic_base |= MSR_IA32_APICBASE_BSP;
return 0;
diff --git a/drivers/kvm/vmx.c b/drivers/kvm/vmx.c
index 80628f6..7fa62c7 100644
--- a/drivers/kvm/vmx.c
+++ b/drivers/kvm/vmx.c
@@ -1253,7 +1253,7 @@ static int vmx_vcpu_setup(struct kvm_vcpu *vcpu)
vcpu->regs[VCPU_REGS_RDX] = get_rdx_init_val();
vcpu->cr8 = 0;
vcpu->apic_base = 0xfee00000 | MSR_IA32_APICBASE_ENABLE;
- if (vcpu == &vcpu->kvm->vcpus[0])
+ if (vcpu->vcpu_id == 0)
vcpu->apic_base |= MSR_IA32_APICBASE_BSP;
fx_init(vcpu);
--
1.5.3
-
| Kristen Carlson Accardi | [PATCH] ata: ahci: power off unused ports |
| Trent Piepho | [PATCH] [POWERPC] Improve (in|out)_beXX() asm code |
| Jan Engelhardt | Re: Kernel Development & Objective-C |
| Chuck Ebbert | Why do so many machines need "noapic"? |
git: | |
| Jan Engelhardt | about c8af1de9 (git status uses pager) |
| Junio C Hamano | Re: [PATCH 3/3] Teach "git branch" about --new-workdir |
| Nicolas Pitre | Re: Git tree for old kernels from before the current tree |
| Linus Torvalds | Re: cleaner/better zlib sources? |
| Nick Guenther | Re: Real men don't attack straw men |
| Predrag Punosevac | Skype on the OpenBSD |
| Karsten McMinn | Re: Packets Per Second Limit? |
| L. V. Lammert | Re: About Xen: maybe a reiterative question but .. |
| Marnix Klooster | Re: Europe Distribution |
| Sean Moss-Pultz | [openmoko-announce] Let us impact the material world |
| Kosa | Re: Car Mode Application... |
| Federico Lorenzi | Re: multi-tutch? |
| Battery Maximizer Software | 7 hours ago | Linux kernel |
| windows folder creation surprise | 8 hours ago | Windows |
| Problem in scim in Fedora 9 | 10 hours ago | Linux general |
| Firewall | 23 hours ago | OpenBSD |
| IP layer send packet | 1 day ago | Linux kernel |
| dtrace for linux available | 1 day ago | Linux kernel |
| Unable to mount ramdisk image using UBoot while upgrading to 2.6.15 kernel for a MPC8540 based target | 2 days ago | Linux kernel |
| RealTek RTL8169 - can't connect | 2 days ago | NetBSD |
| vsftpd Upload Problems | 2 days ago | Linux general |
| creating con folder in desktop | 3 days ago | Windows |
