From: Zhang Xiantao <[EMAIL PROTECTED]>
Date: Fri, 14 Dec 2007 01:17:26 +0800
Subject: [PATCH] kvm: portability: Moving {host, guest}_fx_image fields
to arch

This patch moves {host, guest}_fx_image to kvm_vcpu_arch.
Signed-off-by: Zhang Xiantao <[EMAIL PROTECTED]>
---
 drivers/kvm/x86.c |   24 ++++++++++++------------
 drivers/kvm/x86.h |    7 +++----
 2 files changed, 15 insertions(+), 16 deletions(-)

diff --git a/drivers/kvm/x86.c b/drivers/kvm/x86.c
index 9136865..92b40cf 100644
--- a/drivers/kvm/x86.c
+++ b/drivers/kvm/x86.c
@@ -2842,7 +2842,7 @@ int kvm_arch_vcpu_ioctl_translate(struct kvm_vcpu
*vcpu,
 
 int kvm_arch_vcpu_ioctl_get_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu
*fpu)
 {
-       struct fxsave *fxsave = (struct fxsave *)&vcpu->guest_fx_image;
+       struct fxsave *fxsave = (struct fxsave
*)&vcpu->arch.guest_fx_image;
 
        vcpu_load(vcpu);
 
@@ -2862,7 +2862,7 @@ int kvm_arch_vcpu_ioctl_get_fpu(struct kvm_vcpu
*vcpu, struct kvm_fpu *fpu)
 
 int kvm_arch_vcpu_ioctl_set_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu
*fpu)
 {
-       struct fxsave *fxsave = (struct fxsave *)&vcpu->guest_fx_image;
+       struct fxsave *fxsave = (struct fxsave
*)&vcpu->arch.guest_fx_image;
 
        vcpu_load(vcpu);
 
@@ -2886,16 +2886,16 @@ void fx_init(struct kvm_vcpu *vcpu)
 
        /* Initialize guest FPU by resetting ours and saving into
guest's */
        preempt_disable();
-       fx_save(&vcpu->host_fx_image);
+       fx_save(&vcpu->arch.host_fx_image);
        fpu_init();
-       fx_save(&vcpu->guest_fx_image);
-       fx_restore(&vcpu->host_fx_image);
+       fx_save(&vcpu->arch.guest_fx_image);
+       fx_restore(&vcpu->arch.host_fx_image);
        preempt_enable();
 
        vcpu->arch.cr0 |= X86_CR0_ET;
        after_mxcsr_mask = offsetof(struct i387_fxsave_struct,
st_space);
-       vcpu->guest_fx_image.mxcsr = 0x1f80;
-       memset((void *)&vcpu->guest_fx_image + after_mxcsr_mask,
+       vcpu->arch.guest_fx_image.mxcsr = 0x1f80;
+       memset((void *)&vcpu->arch.guest_fx_image + after_mxcsr_mask,
               0, sizeof(struct i387_fxsave_struct) - after_mxcsr_mask);
 }
 EXPORT_SYMBOL_GPL(fx_init);
@@ -2906,8 +2906,8 @@ void kvm_load_guest_fpu(struct kvm_vcpu *vcpu)
                return;
 
        vcpu->guest_fpu_loaded = 1;
-       fx_save(&vcpu->host_fx_image);
-       fx_restore(&vcpu->guest_fx_image);
+       fx_save(&vcpu->arch.host_fx_image);
+       fx_restore(&vcpu->arch.guest_fx_image);
 }
 EXPORT_SYMBOL_GPL(kvm_load_guest_fpu);
 
@@ -2917,8 +2917,8 @@ void kvm_put_guest_fpu(struct kvm_vcpu *vcpu)
                return;
 
        vcpu->guest_fpu_loaded = 0;
-       fx_save(&vcpu->guest_fx_image);
-       fx_restore(&vcpu->host_fx_image);
+       fx_save(&vcpu->arch.guest_fx_image);
+       fx_restore(&vcpu->arch.host_fx_image);
        ++vcpu->stat.fpu_reload;
 }
 EXPORT_SYMBOL_GPL(kvm_put_guest_fpu);
@@ -2939,7 +2939,7 @@ int kvm_arch_vcpu_setup(struct kvm_vcpu *vcpu)
        int r;
 
        /* We do fxsave: this must be aligned. */
-       BUG_ON((unsigned long)&vcpu->host_fx_image & 0xF);
+       BUG_ON((unsigned long)&vcpu->arch.host_fx_image & 0xF);
 
        vcpu_load(vcpu);
        r = kvm_arch_vcpu_reset(vcpu);
diff --git a/drivers/kvm/x86.h b/drivers/kvm/x86.h
index 466fe68..c698ffc 100644
--- a/drivers/kvm/x86.h
+++ b/drivers/kvm/x86.h
@@ -129,15 +129,14 @@ struct kvm_vcpu_arch {
        int   last_pt_write_count;
        u64  *last_pte_updated;
 
+       struct i387_fxsave_struct host_fx_image;
+       struct i387_fxsave_struct guest_fx_image;
+
 };
 
 struct kvm_vcpu {
        KVM_VCPU_COMM;
 
-
-       struct i387_fxsave_struct host_fx_image;
-       struct i387_fxsave_struct guest_fx_image;
-
        gva_t mmio_fault_cr2;
        struct kvm_pio_request pio;
        void *pio_data;
-- 
1.5.1.2

Attachment: 0009-kvm-portability-Moving-host-guest-_fx_image-fiel.patch
Description: 0009-kvm-portability-Moving-host-guest-_fx_image-fiel.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