diff options
| -rw-r--r-- | arch/x86/kvm/x86.c | 11 | ||||
| -rw-r--r-- | include/asm-x86/kvm_host.h | 2 |
2 files changed, 11 insertions, 2 deletions
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index bc224bba1e87..21338bdb28ff 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c | |||
| @@ -3703,10 +3703,19 @@ void fx_init(struct kvm_vcpu *vcpu) | |||
| 3703 | { | 3703 | { |
| 3704 | unsigned after_mxcsr_mask; | 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 | /* Initialize guest FPU by resetting ours and saving into guest's */ | 3715 | /* Initialize guest FPU by resetting ours and saving into guest's */ |
| 3707 | preempt_disable(); | 3716 | preempt_disable(); |
| 3708 | fx_save(&vcpu->arch.host_fx_image); | 3717 | fx_save(&vcpu->arch.host_fx_image); |
| 3709 | fpu_init(); | 3718 | fx_finit(); |
| 3710 | fx_save(&vcpu->arch.guest_fx_image); | 3719 | fx_save(&vcpu->arch.guest_fx_image); |
| 3711 | fx_restore(&vcpu->arch.host_fx_image); | 3720 | fx_restore(&vcpu->arch.host_fx_image); |
| 3712 | preempt_enable(); | 3721 | preempt_enable(); |
diff --git a/include/asm-x86/kvm_host.h b/include/asm-x86/kvm_host.h index 4baa9c9e1f41..1d8cd01fa514 100644 --- a/include/asm-x86/kvm_host.h +++ b/include/asm-x86/kvm_host.h | |||
| @@ -627,7 +627,7 @@ static inline void fx_restore(struct i387_fxsave_struct *image) | |||
| 627 | asm("fxrstor (%0)":: "r" (image)); | 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 | asm("finit"); | 632 | asm("finit"); |
| 633 | } | 633 | } |
