x86, fpu: Avoid possible error in math_state_restore()
For non-eager fpu mode, thread's fpu state is allocated during the first
fpu usage (in the context of device not available exception). This can be
a blocking call and hence we enable interrupts (which were originally
disabled when the exception happened), allocate memory and disable
interrupts etc.
Math_state_restore() is called from multiple places
and it is error pone if the caller expects interrupts to be disabled
throughout the execution of math_state_restore(). Can lead to subtle
bugs like Ubuntu bug #
1265841. So simplifying the code which cause subtle
bugs.
The patch has one known problem when the machine is running baremetal
(or PVHVM) and when there is low amount of memory. The problem is that the
applications won't get SIGKILL when the FPU area can't be allocated and
instead they will continue on running - without any FPU context
allocated for them. The 'init_fpu(tsk)' can return -ENOMEM and that
patch does not check that condition. This update will be tracked
in another bug since the patch already fixes two known issues related
to corruption.
Orabug:
20270524
Signed-off-by: Suresh Siddha <sbsiddha@gmail.com>
Signed-off-by: David Vrabel <david.vrabel@citrix.com>
Signed-off-by: Annie Li <annie.li@oracle.com>
[santosh.shilimkar@oracle.com: Added FIXME comment]
Signed-off-by: Santosh Shilimkar <santosh.shilimkar@oracle.com>