Commit bc1a34f1bf354fabc03e3f465620c80e510d0e8f

Authored by Andrea Arcangeli
Committed by Avi Kivity
1 parent b4f14abd95

KVM: avoid fx_init() schedule in atomic

This make sure not to schedule in atomic during fx_init. I also
changed the name of fpu_init to fx_finit to avoid duplicating the name
with fpu_init that is already used in the kernel, this makes grep
simpler if nothing else.

Signed-off-by: Andrea Arcangeli <andrea@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>

Showing 2 changed files with 11 additions and 2 deletions Side-by-side Diff

... ... @@ -3703,10 +3703,19 @@
3703 3703 {
3704 3704 unsigned after_mxcsr_mask;
3705 3705  
  3706 + /*
  3707 + * Touch the fpu the first time in non atomic context as if
  3708 + * this is the first fpu instruction the exception handler
  3709 + * will fire before the instruction returns and it'll have to
  3710 + * allocate ram with GFP_KERNEL.
  3711 + */
  3712 + if (!used_math())
  3713 + fx_save(&vcpu->arch.host_fx_image);
  3714 +
3706 3715 /* Initialize guest FPU by resetting ours and saving into guest's */
3707 3716 preempt_disable();
3708 3717 fx_save(&vcpu->arch.host_fx_image);
3709   - fpu_init();
  3718 + fx_finit();
3710 3719 fx_save(&vcpu->arch.guest_fx_image);
3711 3720 fx_restore(&vcpu->arch.host_fx_image);
3712 3721 preempt_enable();
include/asm-x86/kvm_host.h
... ... @@ -627,7 +627,7 @@
627 627 asm("fxrstor (%0)":: "r" (image));
628 628 }
629 629  
630   -static inline void fpu_init(void)
  630 +static inline void fx_finit(void)
631 631 {
632 632 asm("finit");
633 633 }