Re: [PATCH v5 14/28] x86/fpu/xstate: Prevent unauthorised use of dynamic user state

Dave Hansen
2021-06-29T17:54:15Z

On 6/29/21 10:43 AM, Bae, Chang Seok wrote:
> On Jun 16, 2021, at 12:01, Dave Hansen <dave.hansen@intel.com> wrote:
>> On 6/16/21 11:47 AM, Bae, Chang Seok wrote:
>>> Reading XINUSE via XGETBV is cheap but not free. I don't know spending a
>>> hundred cycles for this WARN is big deal but this is one of the most
>>> performance-critical paths.
>> Is XGETBV(1) really a hundred cycles? That seems absurdly high for a
>> non-serializing register read.
> My apologies -- I neglect not to check the log immediately. XGETBV(1) took
> about 26 cycles on my test.

How about we pay this 26-cycle cost, but only when XFD is in use? We
could either look at the shadowed value of the XFD MSR, or flip a global
variable the first time XFD gets used.