x86/fpu: Return proper error codes from user access functions
authorThomas Gleixner <tglx@linutronix.de>
Wed, 23 Jun 2021 12:02:30 +0000 (14:02 +0200)
committerBorislav Petkov <bp@suse.de>
Wed, 23 Jun 2021 18:04:58 +0000 (20:04 +0200)
commitaee8c67a4faa40a8df4e79316dbfc92d123989c1
treeaff7d82eda101151ac605fc2cdc999b81939f307
parent0a6c2e9ec91c96bde1e8ce063180ac6e05e680f7
x86/fpu: Return proper error codes from user access functions

When *RSTOR from user memory raises an exception, there is no way to
differentiate them. That's bad because it forces the slow path even when
the failure was not a fault. If the operation raised eg. #GP then going
through the slow path is pointless.

Use _ASM_EXTABLE_FAULT() which stores the trap number and let the exception
fixup return the negated trap number as error.

This allows to separate the fast path and let it handle faults directly and
avoid the slow path for all other exceptions.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Borislav Petkov <bp@suse.de>
Link: https://lkml.kernel.org/r/20210623121457.601480369@linutronix.de
arch/x86/include/asm/fpu/internal.h