summaryrefslogtreecommitdiff
path: root/arch/x86/kvm/x86.c
diff options
context:
space:
mode:
authorAvi Kivity <avi@redhat.com>2011-03-28 16:53:59 +0200
committerAvi Kivity <avi@redhat.com>2011-05-11 07:56:58 -0400
commit5037f6f324cdcc6c9071dc774aba992f96c7e5ff (patch)
tree600ae6a745b1952e2de36d8a7a14034438190041 /arch/x86/kvm/x86.c
parent1d6b114f20d06ac0749686e4d7b7c7913d9116db (diff)
downloadlinux-3.10-5037f6f324cdcc6c9071dc774aba992f96c7e5ff.tar.gz
linux-3.10-5037f6f324cdcc6c9071dc774aba992f96c7e5ff.tar.bz2
linux-3.10-5037f6f324cdcc6c9071dc774aba992f96c7e5ff.zip
KVM: x86 emulator: define callbacks for using the guest fpu within the emulator
Needed for emulating fpu instructions. Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch/x86/kvm/x86.c')
-rw-r--r--arch/x86/kvm/x86.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 11d692c7018..5af66515337 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -4281,6 +4281,22 @@ static void emulator_set_segment_selector(u16 sel, int seg,
kvm_set_segment(vcpu, &kvm_seg, seg);
}
+static void emulator_get_fpu(struct x86_emulate_ctxt *ctxt)
+{
+ preempt_disable();
+ kvm_load_guest_fpu(ctxt->vcpu);
+ /*
+ * CR0.TS may reference the host fpu state, not the guest fpu state,
+ * so it may be clear at this point.
+ */
+ clts();
+}
+
+static void emulator_put_fpu(struct x86_emulate_ctxt *ctxt)
+{
+ preempt_enable();
+}
+
static struct x86_emulate_ops emulate_ops = {
.read_std = kvm_read_guest_virt_system,
.write_std = kvm_write_guest_virt_system,
@@ -4304,6 +4320,8 @@ static struct x86_emulate_ops emulate_ops = {
.set_dr = emulator_set_dr,
.set_msr = kvm_set_msr,
.get_msr = kvm_get_msr,
+ .get_fpu = emulator_get_fpu,
+ .put_fpu = emulator_put_fpu,
};
static void cache_all_regs(struct kvm_vcpu *vcpu)