On 28/12/2018 15:43, Roger Pau Monné wrote:
> On Fri, Dec 28, 2018 at 12:39:35PM +0000, Andrew Cooper wrote:
>> AMD hardware before Zen doesn't safe/restore the FPU error pointers
>> unless an unmasked FPU exception is pending.  Zen processors have a
>> feature bit indicating that this (mis)behaviour no longer exists.
>>
>> Express the common logic in terms of cpu_bug_fpu_err_ptr as Hygon
>> processors (being Zen derivatives) won't inherit this behaviour.
>>
>> While at it, fix a performance issue with the workaround, which I should
>> have noticed by now.  Looking at the FPU state slows the context switch
>> path down, as it is a moderately complicated unpredictable condition
>> which will evaluate to true for all 64bit OSes and most 32bit ones.
>>
>> Leave the sole condition being the easily-predictable
>> cpu_bug_fpu_err_ptr as the asm sequence is needed in ~100% of cases
>> these days on affected hardware.
> I'm not that familiar with the FPU registers, but I assume current
> code checks whether there's an exception pending before decoding
> whether the error pointers should be cleared?

The current code has two checks.  One, whether you're trying to load
floating point state, and the second is whether there is an unmasked
floating point exception.

All callers, except those out of the emulator, restore FP state, and the
statistical likelihood of there being an unmasked floating point
exception pending is low when the x87 FPU is in use, and 0 on 64bit
systems which use SSE2 as their base floating point support.

~Andrew

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Reply via email to