x86/fpu/signal: Handle #PF in the direct restore path
authorThomas Gleixner <tglx@linutronix.de>
Wed, 23 Jun 2021 12:02:31 +0000 (14:02 +0200)
committerBorislav Petkov <bp@suse.de>
Wed, 23 Jun 2021 18:05:33 +0000 (20:05 +0200)
commitfcb3635f5018e53024c6be3c3213737f469f74ff
tree3b21b1cbaeca68ab42232f22d78e4dc690d547d8
parentaee8c67a4faa40a8df4e79316dbfc92d123989c1
x86/fpu/signal: Handle #PF in the direct restore path

If *RSTOR raises an exception, then the slow path is taken. That's wrong
because if the reason was not #PF then going through the slow path is waste
of time because that will end up with the same conclusion that the data is
invalid.

Now that the wrapper around *RSTOR return an negative error code, which is
the negated trap number, it's possible to differentiate.

If the *RSTOR raised #PF then handle it directly in the fast path and if it
was some other exception, e.g. #GP, then give up and do not try the fast
path.

This removes the legacy frame FRSTOR code from the slow path because FRSTOR
is not a ia32_fxstate frame and is therefore handled in the fast path.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Borislav Petkov <bp@suse.de>
Link: https://lkml.kernel.org/r/20210623121457.696022863@linutronix.de
arch/x86/kernel/fpu/signal.c