Skip to content

Commit

Permalink
KVM: fx_init() needs preemption disabled while it plays with the FPU …
Browse files Browse the repository at this point in the history
…state

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>
  • Loading branch information
Rusty Russell authored and Avi Kivity committed Oct 13, 2007
1 parent 11ec280 commit 9bd0150
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/kvm/kvm_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 9bd0150

Please sign in to comment.