KVM: fx_init() needs preemption disabled while it plays with the FPU state
authorRusty Russell <rusty@rustcorp.com.au>
Mon, 30 Jul 2007 06:29:56 +0000 (16:29 +1000)
committerAvi Kivity <avi@qumranet.com>
Sat, 13 Oct 2007 08:18:20 +0000 (10:18 +0200)
Now that kvm generally runs with preemption enabled, we need to protect
the fpu intialization sequence.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Avi Kivity <avi@qumranet.com>
drivers/kvm/kvm_main.c

index 7aeaaba..5b42731 100644 (file)
@@ -693,10 +693,13 @@ void fx_init(struct kvm_vcpu *vcpu)
 
        } *fx_image;
 
+       /* Initialize guest FPU by resetting ours and saving into guest's */
+       preempt_disable();
        fx_save(vcpu->host_fx_image);
        fpu_init();
        fx_save(vcpu->guest_fx_image);
        fx_restore(vcpu->host_fx_image);
+       preempt_enable();
 
        fx_image = (struct fx_image_s *)vcpu->guest_fx_image;
        fx_image->mxcsr = 0x1f80;