[PATCH RFC 0/9] String optimizations and call support in alternatives
Heiko Stuebner
heiko at sntech.de
Fri Nov 4 15:51:44 PDT 2022
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
--
2.35.1
More information about the linux-riscv
mailing list