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

Ard Biesheuvel ardb at kernel.org
Mon Oct 26 13:10:13 EDT 2020


On Mon, 26 Oct 2020 at 18:04, Dmitry Osipenko <digetx at gmail.com> wrote:
>
> 26.10.2020 17:35, Ard Biesheuvel пишет:
> > 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 think yours original patch with the fixes tag is still needed, hence
> it should be two patches: 1) fixes the original problem 2) makes the
> improvement.

Russell was pretty clear that he doesn't want the additional IT
instruction on the hot path.

This patch removes the kernel mode check entirely, which is justified,
given that there is never a need to invoke the VFP support code from
kernel mode in the first place.



More information about the linux-arm-kernel mailing list