Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e5c30142 authored by Avi Kivity's avatar Avi Kivity
Browse files

KVM: Initialize fpu state in preemptible context



init_fpu() (which is indirectly called by the fpu switching code) assumes
it is in process context.  Rather than makeing init_fpu() use an atomic
allocation, which can cause a task to be killed, make sure the fpu is
already initialized when we enter the run loop.

KVM-Stable-Tag.
Reported-and-tested-by: default avatarKirill A. Shutemov <kas@openvz.org>
Acked-by: default avatarPekka Enberg <penberg@kernel.org>
Reviewed-by: default avatarChristoph Lameter <cl@linux.com>
Signed-off-by: default avatarAvi Kivity <avi@redhat.com>
parent 444e863d
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -169,6 +169,7 @@ int init_fpu(struct task_struct *tsk)
	set_stopped_child_used_math(tsk);
	return 0;
}
EXPORT_SYMBOL_GPL(init_fpu);

/*
 * The xstateregs_active() routine is the same as the fpregs_active() routine,
+3 −0
Original line number Diff line number Diff line
@@ -5376,6 +5376,9 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
	int r;
	sigset_t sigsaved;

	if (!tsk_used_math(current) && init_fpu(current))
		return -ENOMEM;

	if (vcpu->sigset_active)
		sigprocmask(SIG_SETMASK, &vcpu->sigset, &sigsaved);