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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 20 Jul 2021 14:02:15 +0000 (16:02 +0200)
commite6fbd44df86b7f40f11c0576c15fa48e7a8359d0
tree8a5a9005596f2d20b3a6fc2461dfdbd23ce7c019
parentec04c03541be40b37d16b9a959bceb02a7910ecd
x86/fpu: Return proper error codes from user access functions

[ Upstream commit aee8c67a4faa40a8df4e79316dbfc92d123989c1 ]

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
Signed-off-by: Sasha Levin <sashal@kernel.org>
arch/x86/include/asm/fpu/internal.h