Re: [patch 01/10] x86/fpu/signal: Clarify exception handling in restore_fpregs_from_user()

From: Borislav Petkov
Date: Mon Aug 30 2021 - 15:33:13 EST


On Mon, Aug 30, 2021 at 06:27:22PM +0200, Thomas Gleixner wrote:
> FPU restore from a signal frame can trigger various exceptions. The
> exceptions are caught with an exception table entry. The handler of this
> entry sets the error return value to the negated exception number.
>
> Any other exception than #PF is fatal and recovery is not possible. This
> relies on the fact that the #PF exception number is the same as EFAULT, but
> that's not really obvious.
>
> Check the error code for -X86_TRAP_PF instead of checking it for -EFAULT to
> make it clear how that works.

I guess you wanna fixup the comment over XSTATE_OP() too and perhaps
mention ex_handler_fault() explicitly so that one can make her/his way
around the code and pinpoint quickly where it sticks that exception
number into rAX.

Thx.

--
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette