From: Zhang Xiantao <[EMAIL PROTECTED]>
Date: Fri, 14 Dec 2007 00:56:44 +0800
Subject: [PATCH] kvm portability: Moving mp_state, and sipi_vector to
kvm_vcpu_arch

In this patches, two fields mp_state and sipi_vector are moved to
kvm_vcpu_arch
Signed-off-by: Zhang Xiantao <[EMAIL PROTECTED]>
---
 drivers/kvm/lapic.c |   18 +++++++++---------
 drivers/kvm/svm.c   |    4 ++--
 drivers/kvm/vmx.c   |    4 ++--
 drivers/kvm/x86.c   |   16 ++++++++--------
 drivers/kvm/x86.h   |   12 ++++++------
 5 files changed, 27 insertions(+), 27 deletions(-)

diff --git a/drivers/kvm/lapic.c b/drivers/kvm/lapic.c
index 77a6252..60fef64 100644
--- a/drivers/kvm/lapic.c
+++ b/drivers/kvm/lapic.c
@@ -342,10 +342,10 @@ static int __apic_accept_irq(struct kvm_lapic
*apic, int delivery_mode,
                } else
                        apic_clear_vector(vector, apic->regs +
APIC_TMR);
 
-               if (vcpu->mp_state == VCPU_MP_STATE_RUNNABLE)
+               if (vcpu->arch.mp_state == VCPU_MP_STATE_RUNNABLE)
                        kvm_vcpu_kick(vcpu);
-               else if (vcpu->mp_state == VCPU_MP_STATE_HALTED) {
-                       vcpu->mp_state = VCPU_MP_STATE_RUNNABLE;
+               else if (vcpu->arch.mp_state == VCPU_MP_STATE_HALTED) {
+                       vcpu->arch.mp_state = VCPU_MP_STATE_RUNNABLE;
                        if (waitqueue_active(&vcpu->wq))
                                wake_up_interruptible(&vcpu->wq);
                }
@@ -366,11 +366,11 @@ static int __apic_accept_irq(struct kvm_lapic
*apic, int delivery_mode,
 
        case APIC_DM_INIT:
                if (level) {
-                       if (vcpu->mp_state == VCPU_MP_STATE_RUNNABLE)
+                       if (vcpu->arch.mp_state ==
VCPU_MP_STATE_RUNNABLE)
                                printk(KERN_DEBUG
                                       "INIT on a runnable vcpu %d\n",
                                       vcpu->vcpu_id);
-                       vcpu->mp_state = VCPU_MP_STATE_INIT_RECEIVED;
+                       vcpu->arch.mp_state =
VCPU_MP_STATE_INIT_RECEIVED;
                        kvm_vcpu_kick(vcpu);
                } else {
                        printk(KERN_DEBUG
@@ -383,9 +383,9 @@ static int __apic_accept_irq(struct kvm_lapic *apic,
int delivery_mode,
        case APIC_DM_STARTUP:
                printk(KERN_DEBUG "SIPI to vcpu %d vector 0x%02x\n",
                       vcpu->vcpu_id, vector);
-               if (vcpu->mp_state == VCPU_MP_STATE_INIT_RECEIVED) {
-                       vcpu->sipi_vector = vector;
-                       vcpu->mp_state = VCPU_MP_STATE_SIPI_RECEIVED;
+               if (vcpu->arch.mp_state == VCPU_MP_STATE_INIT_RECEIVED)
{
+                       vcpu->arch.sipi_vector = vector;
+                       vcpu->arch.mp_state =
VCPU_MP_STATE_SIPI_RECEIVED;
                        if (waitqueue_active(&vcpu->wq))
                                wake_up_interruptible(&vcpu->wq);
                }
@@ -918,7 +918,7 @@ static int __apic_timer_fn(struct kvm_lapic *apic)
 
        atomic_inc(&apic->timer.pending);
        if (waitqueue_active(q)) {
-               apic->vcpu->mp_state = VCPU_MP_STATE_RUNNABLE;
+               apic->vcpu->arch.mp_state = VCPU_MP_STATE_RUNNABLE;
                wake_up_interruptible(q);
        }
        if (apic_lvtt_period(apic)) {
diff --git a/drivers/kvm/svm.c b/drivers/kvm/svm.c
index f937292..6c100b1 100644
--- a/drivers/kvm/svm.c
+++ b/drivers/kvm/svm.c
@@ -559,8 +559,8 @@ static int svm_vcpu_reset(struct kvm_vcpu *vcpu)
 
        if (vcpu->vcpu_id != 0) {
                svm->vmcb->save.rip = 0;
-               svm->vmcb->save.cs.base = svm->vcpu.sipi_vector << 12;
-               svm->vmcb->save.cs.selector = svm->vcpu.sipi_vector <<
8;
+               svm->vmcb->save.cs.base = svm->vcpu.arch.sipi_vector <<
12;
+               svm->vmcb->save.cs.selector = svm->vcpu.arch.sipi_vector
<< 8;
        }
 
        return 0;
diff --git a/drivers/kvm/vmx.c b/drivers/kvm/vmx.c
index 5e9a542..72cc376 100644
--- a/drivers/kvm/vmx.c
+++ b/drivers/kvm/vmx.c
@@ -1632,8 +1632,8 @@ static int vmx_vcpu_reset(struct kvm_vcpu *vcpu)
                vmcs_write16(GUEST_CS_SELECTOR, 0xf000);
                vmcs_writel(GUEST_CS_BASE, 0x000f0000);
        } else {
-               vmcs_write16(GUEST_CS_SELECTOR, vmx->vcpu.sipi_vector <<
8);
-               vmcs_writel(GUEST_CS_BASE, vmx->vcpu.sipi_vector << 12);
+               vmcs_write16(GUEST_CS_SELECTOR,
vmx->vcpu.arch.sipi_vector << 8);
+               vmcs_writel(GUEST_CS_BASE, vmx->vcpu.arch.sipi_vector <<
12);
        }
        vmcs_write32(GUEST_CS_LIMIT, 0xffff);
        vmcs_write32(GUEST_CS_AR_BYTES, 0x9b);
diff --git a/drivers/kvm/x86.c b/drivers/kvm/x86.c
index a173bea..94a3ca4 100644
--- a/drivers/kvm/x86.c
+++ b/drivers/kvm/x86.c
@@ -2156,9 +2156,9 @@ int kvm_emulate_halt(struct kvm_vcpu *vcpu)
 {
        ++vcpu->stat.halt_exits;
        if (irqchip_in_kernel(vcpu->kvm)) {
-               vcpu->mp_state = VCPU_MP_STATE_HALTED;
+               vcpu->arch.mp_state = VCPU_MP_STATE_HALTED;
                kvm_vcpu_block(vcpu);
-               if (vcpu->mp_state != VCPU_MP_STATE_RUNNABLE)
+               if (vcpu->arch.mp_state != VCPU_MP_STATE_RUNNABLE)
                        return -EINTR;
                return 1;
        } else {
@@ -2400,14 +2400,14 @@ static int __vcpu_run(struct kvm_vcpu *vcpu,
struct kvm_run *kvm_run)
 {
        int r;
 
-       if (unlikely(vcpu->mp_state == VCPU_MP_STATE_SIPI_RECEIVED)) {
+       if (unlikely(vcpu->arch.mp_state ==
VCPU_MP_STATE_SIPI_RECEIVED)) {
                pr_debug("vcpu %d received sipi with vector # %x\n",
-                      vcpu->vcpu_id, vcpu->sipi_vector);
+                      vcpu->vcpu_id, vcpu->arch.sipi_vector);
                kvm_lapic_reset(vcpu);
                r = kvm_x86_ops->vcpu_reset(vcpu);
                if (r)
                        return r;
-               vcpu->mp_state = VCPU_MP_STATE_RUNNABLE;
+               vcpu->arch.mp_state = VCPU_MP_STATE_RUNNABLE;
        }
 
 preempted:
@@ -2512,7 +2512,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu,
struct kvm_run *kvm_run)
 
        vcpu_load(vcpu);
 
-       if (unlikely(vcpu->mp_state == VCPU_MP_STATE_UNINITIALIZED)) {
+       if (unlikely(vcpu->arch.mp_state ==
VCPU_MP_STATE_UNINITIALIZED)) {
                kvm_vcpu_block(vcpu);
                vcpu_put(vcpu);
                return -EAGAIN;
@@ -3005,9 +3005,9 @@ int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu)
 
        vcpu->mmu.root_hpa = INVALID_PAGE;
        if (!irqchip_in_kernel(kvm) || vcpu->vcpu_id == 0)
-               vcpu->mp_state = VCPU_MP_STATE_RUNNABLE;
+               vcpu->arch.mp_state = VCPU_MP_STATE_RUNNABLE;
        else
-               vcpu->mp_state = VCPU_MP_STATE_UNINITIALIZED;
+               vcpu->arch.mp_state = VCPU_MP_STATE_UNINITIALIZED;
 
        page = alloc_page(GFP_KERNEL | __GFP_ZERO);
        if (!page) {
diff --git a/drivers/kvm/x86.h b/drivers/kvm/x86.h
index 568cdb1..3416fcd 100644
--- a/drivers/kvm/x86.h
+++ b/drivers/kvm/x86.h
@@ -109,10 +109,6 @@ struct kvm_vcpu_arch {
        u64 shadow_efer;
        u64 apic_base;
        struct kvm_lapic *apic;    /* kernel irqchip context */
-};
-
-struct kvm_vcpu {
-       KVM_VCPU_COMM;
 #define VCPU_MP_STATE_RUNNABLE          0
 #define VCPU_MP_STATE_UNINITIALIZED     1
 #define VCPU_MP_STATE_INIT_RECEIVED     2
@@ -120,6 +116,10 @@ struct kvm_vcpu {
 #define VCPU_MP_STATE_HALTED            4
        int mp_state;
        int sipi_vector;
+};
+
+struct kvm_vcpu {
+       KVM_VCPU_COMM;
        u64 ia32_misc_enable_msr;
 
        struct kvm_mmu mmu;
@@ -493,8 +493,8 @@ static inline void kvm_inject_gp(struct kvm_vcpu
*vcpu, u32 error_code)
 
 static inline int kvm_arch_vcpu_runnable(struct kvm_vcpu *vcpu)
 {
-       return vcpu->mp_state == VCPU_MP_STATE_RUNNABLE
-              || vcpu->mp_state == VCPU_MP_STATE_SIPI_RECEIVED;
+       return vcpu->arch.mp_state == VCPU_MP_STATE_RUNNABLE
+              || vcpu->arch.mp_state == VCPU_MP_STATE_SIPI_RECEIVED;
 }
 
 #endif
-- 
1.5.1.2

Attachment: 0006-kvm-portability-Moving-mp_state-and-sipi_vector-to.patch
Description: 0006-kvm-portability-Moving-mp_state-and-sipi_vector-to.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

Reply via email to