mbox series

[GIT,PULL] ARM: convert VFP exception handling to C code

Message ID 20230522080310.502250-1-ardb@kernel.org (mailing list archive)
State New, archived
Headers show
Series [GIT,PULL] ARM: convert VFP exception handling to C code | expand

Pull-request

git://git.kernel.org/pub/scm/linux/kernel/git/ardb/linux.git tags/arm-vfp-refactor-for-rmk

Message

Ard Biesheuvel May 22, 2023, 8:03 a.m. UTC
Hello Russell,

This pull request covers the outstanding changes related to VFP exception
handling that I implemented on top of the VFP-in-softirq policy change and
subsequent fixes. The code changes are identical to the v2 series [0].

With these changes applied, only FPE related undef exceptions are dispatched in
the old way. Everything else is handled using undef hooks, with all logic
implemented in C.

I have tested this on a variety of platforms, including Cortex-A8 (using kernel
mode NEON) and the original Raspberry Pi (which relies on VFP bouncing), as
well as a host of platforms used in KernelCI [1]. All encountered issues have
been fixed. One notable configuration that I have not been able to test is FPE,
as it implies a OABI user space, which I don't have access to.

Please pull.


The following changes since commit f1fcbaa18b28dec10281551dfe6ed3a3ed80e3d6:

  Linux 6.4-rc2 (2023-05-14 12:51:40 -0700)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/ardb/linux.git tags/arm-vfp-refactor-for-rmk

for you to fetch changes up to 47ba5f39eab3c2a9a1ba878159a6050f2bbfc0e2:

  ARM: entry: Make asm coproc dispatch code NWFPE only (2023-05-17 15:08:22 +0200)


[0] https://lore.kernel.org/all/20230517212808.3895190-1-ardb@kernel.org/
[1] https://linux.kernelci.org/test/job/ardb/branch/for-kernelci/kernel/arm-vfp-refactor-for-rmk/

Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>

----------------------------------------------------------------
Refactor VFP support code and reimplement in C

The VFP related changes to permit kernel mode NEON in softirq context
resulted in some issues regarding en/disabling of sofirqs from asm code,
and this made it clear that it would be better to handle more of it from
C code.

Given that we already have infrastructure that associates undefined
instruction exceptions with handler code based on value/mask pairs, we
can easily move the dispatch of VFP and NEON instructions to C code once
we reimplement the actual VFP support routine (which reasons about how
to deal with the exception and whether any emulation is needed) in C
code first.

With those out of the way, we can drop the partial decoding logic in asm
that reasons about which ISA is being used by user space, as the
remaining cases are all 32-bit ARM only. This leaves a FPE specific
routine with some iWMMXT logic that is easily duplicated in C as well,
allowing us to move the FPE asm code into the FPE asm source file, and
out of the shared entry code.

----------------------------------------------------------------
Ard Biesheuvel (8):
      ARM: vfp: Record VFP bounces as perf emulation faults
      ARM: vfp: Remove workaround for Feroceon CPUs
      ARM: vfp: Reimplement VFP exception entry in C code
      ARM: kernel: Get rid of thread_info::used_cp[] array
      ARM: vfp: Use undef hook for handling VFP exceptions
      ARM: entry: Disregard Thumb undef exception in coproc dispatch
      ARM: iwmmxt: Use undef hook to enable coprocessor for task
      ARM: entry: Make asm coproc dispatch code NWFPE only

 arch/arm/include/asm/thread_info.h |  17 ++-
 arch/arm/kernel/asm-offsets.c      |   1 -
 arch/arm/kernel/entry-armv.S       | 254 ++-----------------------------------
 arch/arm/kernel/iwmmxt.S           |  18 ++-
 arch/arm/kernel/pj4-cp0.c          |   1 +
 arch/arm/kernel/process.c          |   1 -
 arch/arm/kernel/ptrace.c           |   2 -
 arch/arm/kernel/xscale-cp0.c       |   1 +
 arch/arm/mm/proc-feroceon.S        |   4 +
 arch/arm/nwfpe/entry.S             |  77 +++++++++++
 arch/arm/vfp/Makefile              |   2 +-
 arch/arm/vfp/entry.S               |  31 -----
 arch/arm/vfp/vfp.h                 |   1 +
 arch/arm/vfp/vfphw.S               | 208 ++----------------------------
 arch/arm/vfp/vfpmodule.c           | 208 +++++++++++++++++++++---------
 15 files changed, 286 insertions(+), 540 deletions(-)
 delete mode 100644 arch/arm/vfp/entry.S

Comments

Ard Biesheuvel July 19, 2023, 10:15 a.m. UTC | #1
On Mon, 22 May 2023 at 10:03, Ard Biesheuvel <ardb@kernel.org> wrote:
>
> Hello Russell,
>
> This pull request covers the outstanding changes related to VFP exception
> handling that I implemented on top of the VFP-in-softirq policy change and
> subsequent fixes. The code changes are identical to the v2 series [0].
>
> With these changes applied, only FPE related undef exceptions are dispatched in
> the old way. Everything else is handled using undef hooks, with all logic
> implemented in C.
>
> I have tested this on a variety of platforms, including Cortex-A8 (using kernel
> mode NEON) and the original Raspberry Pi (which relies on VFP bouncing), as
> well as a host of platforms used in KernelCI [1]. All encountered issues have
> been fixed. One notable configuration that I have not been able to test is FPE,
> as it implies a OABI user space, which I don't have access to.
>
> Please pull.
>

Ping?

>
> The following changes since commit f1fcbaa18b28dec10281551dfe6ed3a3ed80e3d6:
>
>   Linux 6.4-rc2 (2023-05-14 12:51:40 -0700)
>
> are available in the Git repository at:
>
>   git://git.kernel.org/pub/scm/linux/kernel/git/ardb/linux.git tags/arm-vfp-refactor-for-rmk
>
> for you to fetch changes up to 47ba5f39eab3c2a9a1ba878159a6050f2bbfc0e2:
>
>   ARM: entry: Make asm coproc dispatch code NWFPE only (2023-05-17 15:08:22 +0200)
>
>
> [0] https://lore.kernel.org/all/20230517212808.3895190-1-ardb@kernel.org/
> [1] https://linux.kernelci.org/test/job/ardb/branch/for-kernelci/kernel/arm-vfp-refactor-for-rmk/
>
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
>
> ----------------------------------------------------------------
> Refactor VFP support code and reimplement in C
>
> The VFP related changes to permit kernel mode NEON in softirq context
> resulted in some issues regarding en/disabling of sofirqs from asm code,
> and this made it clear that it would be better to handle more of it from
> C code.
>
> Given that we already have infrastructure that associates undefined
> instruction exceptions with handler code based on value/mask pairs, we
> can easily move the dispatch of VFP and NEON instructions to C code once
> we reimplement the actual VFP support routine (which reasons about how
> to deal with the exception and whether any emulation is needed) in C
> code first.
>
> With those out of the way, we can drop the partial decoding logic in asm
> that reasons about which ISA is being used by user space, as the
> remaining cases are all 32-bit ARM only. This leaves a FPE specific
> routine with some iWMMXT logic that is easily duplicated in C as well,
> allowing us to move the FPE asm code into the FPE asm source file, and
> out of the shared entry code.
>
> ----------------------------------------------------------------
> Ard Biesheuvel (8):
>       ARM: vfp: Record VFP bounces as perf emulation faults
>       ARM: vfp: Remove workaround for Feroceon CPUs
>       ARM: vfp: Reimplement VFP exception entry in C code
>       ARM: kernel: Get rid of thread_info::used_cp[] array
>       ARM: vfp: Use undef hook for handling VFP exceptions
>       ARM: entry: Disregard Thumb undef exception in coproc dispatch
>       ARM: iwmmxt: Use undef hook to enable coprocessor for task
>       ARM: entry: Make asm coproc dispatch code NWFPE only
>
>  arch/arm/include/asm/thread_info.h |  17 ++-
>  arch/arm/kernel/asm-offsets.c      |   1 -
>  arch/arm/kernel/entry-armv.S       | 254 ++-----------------------------------
>  arch/arm/kernel/iwmmxt.S           |  18 ++-
>  arch/arm/kernel/pj4-cp0.c          |   1 +
>  arch/arm/kernel/process.c          |   1 -
>  arch/arm/kernel/ptrace.c           |   2 -
>  arch/arm/kernel/xscale-cp0.c       |   1 +
>  arch/arm/mm/proc-feroceon.S        |   4 +
>  arch/arm/nwfpe/entry.S             |  77 +++++++++++
>  arch/arm/vfp/Makefile              |   2 +-
>  arch/arm/vfp/entry.S               |  31 -----
>  arch/arm/vfp/vfp.h                 |   1 +
>  arch/arm/vfp/vfphw.S               | 208 ++----------------------------
>  arch/arm/vfp/vfpmodule.c           | 208 +++++++++++++++++++++---------
>  15 files changed, 286 insertions(+), 540 deletions(-)
>  delete mode 100644 arch/arm/vfp/entry.S
Russell King (Oracle) July 19, 2023, 10:17 a.m. UTC | #2
On Wed, Jul 19, 2023 at 12:15:10PM +0200, Ard Biesheuvel wrote:
> On Mon, 22 May 2023 at 10:03, Ard Biesheuvel <ardb@kernel.org> wrote:
> >
> > Hello Russell,
> >
> > This pull request covers the outstanding changes related to VFP exception
> > handling that I implemented on top of the VFP-in-softirq policy change and
> > subsequent fixes. The code changes are identical to the v2 series [0].
> >
> > With these changes applied, only FPE related undef exceptions are dispatched in
> > the old way. Everything else is handled using undef hooks, with all logic
> > implemented in C.
> >
> > I have tested this on a variety of platforms, including Cortex-A8 (using kernel
> > mode NEON) and the original Raspberry Pi (which relies on VFP bouncing), as
> > well as a host of platforms used in KernelCI [1]. All encountered issues have
> > been fixed. One notable configuration that I have not been able to test is FPE,
> > as it implies a OABI user space, which I don't have access to.
> >
> > Please pull.
> >
> 
> Ping?

I pulled it before heading away on holiday:

http://git.armlinux.org.uk/cgit/linux-arm.git/log/?h=devel-stable
Ard Biesheuvel July 19, 2023, 10:20 a.m. UTC | #3
On Wed, 19 Jul 2023 at 12:18, Russell King (Oracle)
<linux@armlinux.org.uk> wrote:
>
> On Wed, Jul 19, 2023 at 12:15:10PM +0200, Ard Biesheuvel wrote:
> > On Mon, 22 May 2023 at 10:03, Ard Biesheuvel <ardb@kernel.org> wrote:
> > >
> > > Hello Russell,
> > >
> > > This pull request covers the outstanding changes related to VFP exception
> > > handling that I implemented on top of the VFP-in-softirq policy change and
> > > subsequent fixes. The code changes are identical to the v2 series [0].
> > >
> > > With these changes applied, only FPE related undef exceptions are dispatched in
> > > the old way. Everything else is handled using undef hooks, with all logic
> > > implemented in C.
> > >
> > > I have tested this on a variety of platforms, including Cortex-A8 (using kernel
> > > mode NEON) and the original Raspberry Pi (which relies on VFP bouncing), as
> > > well as a host of platforms used in KernelCI [1]. All encountered issues have
> > > been fixed. One notable configuration that I have not been able to test is FPE,
> > > as it implies a OABI user space, which I don't have access to.
> > >
> > > Please pull.
> > >
> >
> > Ping?
>
> I pulled it before heading away on holiday:
>
> http://git.armlinux.org.uk/cgit/linux-arm.git/log/?h=devel-stable
>

Ah excellent - thanks.