[PATCH] ARM: entry: omit FP emulation for UND exceptions taken in kernel mode

Linus Walleij linus.walleij at linaro.org
Thu Nov 5 05:44:36 EST 2020


On Mon, Oct 26, 2020 at 3:37 PM Ard Biesheuvel <ardb at kernel.org> wrote:

> There are a couple of problems with the exception entry code that deals
> with FP exceptions (which are reported as UND exceptions) when building
> the kernel in Thumb2 mode:
> - the conditional branch to vfp_kmode_exception in vfp_support_entry()
>   may be out of range for its target, depending on how the linker decides
>   to arrange the sections;
> - when the UND exception is taken in kernel mode, the emulation handling
>   logic is entered via the 'call_fpe' label, which means we end up using
>   the wrong value/mask pairs to match and detect the NEON opcodes.
>
> Since UND exceptions in kernel mode are unlikely to occur on a hot path
> (as opposed to the user mode version which is invoked for VFP support
> code and lazy restore), we can use the existing undef hook machinery for
> any kernel mode instruction emulation that is needed, including calling
> the existing vfp_kmode_exception() routine for unexpected cases. So drop
> the call to call_fpe, and instead, install an undef hook that will get
> called for NEON and VFP instructions that trigger an UND exception in
> kernel mode.
>
> Cc: Russell King - ARM Linux admin <linux at armlinux.org.uk>
> Cc: Linus Walleij <linus.walleij at linaro.org>
> Cc: Dmitry Osipenko <digetx at gmail.com>
> Cc: Kees Cook <keescook at chromium.org>
> Cc: Nick Desaulniers <ndesaulniers at google.com>
> Signed-off-by: Ard Biesheuvel <ardb at kernel.org>
> ---
> Related discussion here:
> https://lore.kernel.org/linux-arm-kernel/20201021225737.739-1-digetx@gmail.com/

I would put that with Link: in the commit message so people
can find it easily if they have a problem here.

FWIW:
Reviewed-by: Linus Walleij <iinus.walleij at linaro.org>

I can't claim to thoroughly understand it, but I roughly understand
it. Back to studies...

One sideeffect of moving to the generic hook makes this available
at core_initcall() time so later during boot IIUC, which may be worth
noting in the commit message as well? Indeed if we have
an exception like this during that early boot we will certainly
notice anyway, as long as it gives some kind of splat an not
just hang, I'm happy.

Yours,
Linus Walleij



More information about the linux-arm-kernel mailing list