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:05:48 +0000 (16:05 +0200)
commitf3a56cd3eaf6a3e82060ee7afddb32e94bffdef1
treecbf8ade37d9addd9e41211217736019f49e46a89
parent39ed17de8c6ff54c7ed4605a4a8e04a2e2f0b82e
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