Re: [RFC PATCH] x86/fpu: Don't unconditionally add XFEATURE_MASK_FPSSE on sigentry

From: Dave Hansen
Date: Fri Apr 26 2019 - 16:44:17 EST


On 4/26/19 1:05 PM, Sebastian Andrzej Siewior wrote:
>
> copy_fpstate_to_sigframe()
> |
> copy_fpregs_to_sigframe() fails.
> |
> using_compacted_format()

Aw, crud. I was looking at Linus's tree. Sorry about that. In Linus's
tree, if copy_fpregs_to_sigframe() fails, we just return from
copy_fpstate_to_sigframe() immediately. In other words, either XSAVE
works, and we don't have this issue, or XSAVE fails and we don't do the
fixup code in question.

I'll say it again, though: I think we should be using the XSAVE
instruction to save this state. If we need to map some pages in order
to make XSAVE work, then I think we should bring some pages in and we
can do *that* in the slow path. We can even do that without taking page
faults by just calling get_user_pages() for instance.

Or, the slow path could be to fpregs_unlock(), zero the user area
(taking and handling page faults), then fpregs_lock() and retry the
copy_fpregs_to_sigframe().