mbox series

[v2,0/3] ARM: vfp: Switch to C API to en/disable softirqs

Message ID 20230314192756.217966-1-ardb@kernel.org (mailing list archive)
Headers show
Series ARM: vfp: Switch to C API to en/disable softirqs | expand

Message

Ard Biesheuvel March 14, 2023, 7:27 p.m. UTC
As it turns out, enabling or disabling softirqs from asm code is more
tricky than it looks. Simply bumping the associated bit in preempt_count
does the trick for uninstrumented kernels, but with lockdep or preempt
debug enabled, we really need to call the C versions, as replicating
their behavior in asm fully is intractible.

So let's rework the existing code a little bit so we can interpose a
little C helper 'vfp_entry()' that disables softirqs before calling the
existing vfpstate handling code in asm. Re-enabling softirqs from asm
code is more straight-forward, as we can simply perform a tail call via
a C routine that is guaranteed to be callable as a function.

Cc: Frederic Weisbecker <frederic@kernel.org>
Cc: Guenter Roeck <linux@roeck-us.net>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/all/ZBBYCSZUJOWBg1s8@localhost.localdomain/

Ard Biesheuvel (3):
  ARM: vfp: Pass thread_info pointer to vfp_support_entry
  ARM: vfp: Pass successful return address via register R3
  ARM: vfp: Fix broken softirq handling with instrumentation enabled

 arch/arm/include/asm/assembler.h | 13 ---------
 arch/arm/vfp/entry.S             | 17 ++---------
 arch/arm/vfp/vfphw.S             | 30 +++++++++++---------
 arch/arm/vfp/vfpmodule.c         | 27 ++++++++++++++----
 4 files changed, 42 insertions(+), 45 deletions(-)

Comments

Guenter Roeck March 14, 2023, 10:34 p.m. UTC | #1
On Tue, Mar 14, 2023 at 08:27:53PM +0100, Ard Biesheuvel wrote:
> As it turns out, enabling or disabling softirqs from asm code is more
> tricky than it looks. Simply bumping the associated bit in preempt_count
> does the trick for uninstrumented kernels, but with lockdep or preempt
> debug enabled, we really need to call the C versions, as replicating
> their behavior in asm fully is intractible.
> 
> So let's rework the existing code a little bit so we can interpose a
> little C helper 'vfp_entry()' that disables softirqs before calling the
> existing vfpstate handling code in asm. Re-enabling softirqs from asm
> code is more straight-forward, as we can simply perform a tail call via
> a C routine that is guaranteed to be callable as a function.
> 
> Cc: Frederic Weisbecker <frederic@kernel.org>
> Cc: Guenter Roeck <linux@roeck-us.net>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Link: https://lore.kernel.org/all/ZBBYCSZUJOWBg1s8@localhost.localdomain/
> 

For the series:

Tested-by: Guenter Roeck <linux@roeck-us.net>

Series applied on top of v6.3-rc2. Tested with 300+ boot tests on all
arm qemu machines in my test bed.

Cross-check: Without this series, a warning backtrace is observed
roughly once per ~20 boot attempts.

Thanks,
Guenter

> Ard Biesheuvel (3):
>   ARM: vfp: Pass thread_info pointer to vfp_support_entry
>   ARM: vfp: Pass successful return address via register R3
>   ARM: vfp: Fix broken softirq handling with instrumentation enabled
> 
>  arch/arm/include/asm/assembler.h | 13 ---------
>  arch/arm/vfp/entry.S             | 17 ++---------
>  arch/arm/vfp/vfphw.S             | 30 +++++++++++---------
>  arch/arm/vfp/vfpmodule.c         | 27 ++++++++++++++----
>  4 files changed, 42 insertions(+), 45 deletions(-)
> 
> -- 
> 2.39.2
>