Skip to content

RFC String optimizations and call support in alternatives

Heiko Stuebner linux-riscv 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest9 patches 0 repliesNew

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/9string: allow override for strstarts()include/linux/string.h+2 -00 replies
2/9efi/riscv: libstub: mark when compiling libstubdrivers/firmware/efi/libstub/Makefile+1 -10 replies
3/9RISC-V: add auipc elements to parse_asm headerarch/riscv/include/asm/parse_asm.h+3 -00 replies
4/9RISC-V: add U-type imm parsing to parse_asm headerarch/riscv/include/asm/parse_asm.h+13 -00 replies
5/9RISC-V: add rd reg parsing to parse_asm headerarch/riscv/include/asm/parse_asm.h+5 -00 replies
6/9RISC-V: fix auipc-jalr addresses in patched alternativesarch/riscv/kernel/cpufeature.c+76 -20 replies
7/9RISC-V: add infrastructure to allow different str* implementationsarch/riscv/include/asm/string.h arch/riscv/kernel/image-vars.h arch/riscv/lib/Makefile +4 more+173 -30 replies
8/9HACK: RISC-V: add zbb support to string functionsarch/riscv/Kconfig arch/riscv/include/asm/errata_list.h arch/riscv/include/asm/hwcap.h +10 more+378 -50 replies
9/9HACK: disable strchr call in overlay-fsfs/overlayfs/super.c+2 -10 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH RFC 0/9] String optimizations and call support in alternatives

Hi all,

this is sort of a "where I'm at" with optimizing str* and mem* when taking into account possible multiple variants due to various extensions being available.

There are essentially two parts to handle:
- making str* functions able to replace what they do performantly for possible multiple variants

This is done by inlining the core functions and then using alternatives to call the actual variant.

This of course will also need a more intelligent selection mechanism in the future and as you can see also involves the EFI stub in a tiny way.

- actually allowing calls in alternatives
Function calls use auipc + jalr to reach those 32bit relative addresses but when they're compiled the offset will be wrong as alternatives live in a different section, so when the patch got applied the address will point to the wrong location.

So similar to arm64 the target addresses need to be updated.

As you can see the zbb part itself is not ready yet, as I lost way too much time on the offset fixes so far, so my replacement functions are actually "just" copies of the generic ones so far.

But the effect is similar. Without the offset fix, the function addresses are wrong as expected and the fix seems to point things correctly in all my tests, both in the kernel and modules.

So this is my try to get some eyeballs on all the things I may be missing and as similar topics came up in different threads, to also allow me to point to something.

Thanks
Heiko

Heiko Stuebner (9):
string: allow override for strstarts()
efi/riscv: libstub: mark when compiling libstub
RISC-V: add auipc elements to parse_asm header
RISC-V: add U-type imm parsing to parse_asm header
RISC-V: add rd reg parsing to parse_asm header
RISC-V: fix auipc-jalr addresses in patched alternatives
RISC-V: add infrastructure to allow different str* implementations
HACK: RISC-V: add zbb support to string functions
HACK: disable strchr call in overlay-fs

 arch/riscv/Kconfig                    | 23 +++++++
 arch/riscv/include/asm/errata_list.h  |  3 +-
 arch/riscv/include/asm/hwcap.h        |  1 +
 arch/riscv/include/asm/parse_asm.h    | 21 ++++++
 arch/riscv/include/asm/string.h       | 96 +++++++++++++++++++++++++++
 arch/riscv/kernel/cpu.c               |  1 +
 arch/riscv/kernel/cpufeature.c        | 96 ++++++++++++++++++++++++++-
 arch/riscv/kernel/image-vars.h        |  6 +-
 arch/riscv/lib/Makefile               | 10 +++
 arch/riscv/lib/strcmp.S               | 25 +++++++
 arch/riscv/lib/strcmp_tmp.S           | 25 +++++++
 arch/riscv/lib/strcmp_zbb.S           | 70 +++++++++++++++++++
 arch/riscv/lib/string.c               | 20 ++++++
 arch/riscv/lib/strlen.S               | 17 +++++
 arch/riscv/lib/strlen_tmp.S           | 17 +++++
 arch/riscv/lib/strlen_zbb.S           | 80 ++++++++++++++++++++++
 arch/riscv/lib/strncmp.S              | 27 ++++++++
 arch/riscv/lib/strncmp_tmp.S          | 27 ++++++++
 arch/riscv/lib/strncmp_zbb.S          | 85 ++++++++++++++++++++++++
 drivers/firmware/efi/libstub/Makefile |  2 +-
 fs/overlayfs/super.c                  |  3 +-
 include/linux/string.h                |  2 +
 22 files changed, 649 insertions(+), 8 deletions(-)
 create mode 100644 arch/riscv/lib/strcmp.S
 create mode 100644 arch/riscv/lib/strcmp_tmp.S
 create mode 100644 arch/riscv/lib/strcmp_zbb.S
 create mode 100644 arch/riscv/lib/string.c
 create mode 100644 arch/riscv/lib/strlen.S
 create mode 100644 arch/riscv/lib/strlen_tmp.S
 create mode 100644 arch/riscv/lib/strlen_zbb.S
 create mode 100644 arch/riscv/lib/strncmp.S
 create mode 100644 arch/riscv/lib/strncmp_tmp.S
 create mode 100644 arch/riscv/lib/strncmp_zbb.S
Signature · 7 lines
2.35.1


_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv