On 27/02/2024 15:37, Akram Ahmad wrote:
Hello all,
Many of the Morello helper functions are implemented in assembly due to historical reasons. This patch series aims to translate the helpers into C functions to improve their readability, introducing additional helpers where necessary such as to access capability-based system registers. The newly translated helpers are defined directly in morello.c.
This patch series also removes the now empty morello.S file, and updates the Makefile accordingly. It also tidies up definitions of assembly-only values, removing these where necessary.
V1 -> V2:
- Minor adjustments to improve code readability
- Correction to cheri_cap_build usage
- Remove duplicate calls to read_cap_sysreg
V1 separates the patch series into two patches; one to add the register helpers, and another to translate the assembly helpers (and tidy up). V1 also corrects the more complicated helpers, whilst removing unnecessary casts and finally implementing some feedback for improving code clarity.
The review branch is accessible here: https://git.morello-project.org/arkamnite/linux/-/commits/morello%2Farm64_v2
The related issue is here: https://git.morello-project.org/morello/kernel/linux/-/issues/61
Many thanks,
Akram
Akram Ahmad (2): arm64: morello: add {read, write}_cap_sysreg helpers arm64: morello: rewrite Morello helpers in C
These are now in next, thanks! I made a few minor changes to morello_build_any_user_cap() in patch 2: moved the declaration of sealing_cap before the if, as statements should be after declarations (C89 style), and fixed the cast (uintcap_t instead of user_uintptr_t, the latter is ABI-specific but we are always manipulating a capability here).
I tested these patches in a variety of situations, including GDB (considering that many of the rewritten functions are used by ptrace), and haven't hit any regression.
Kevin
arch/arm64/include/asm/assembler.h | 10 -- arch/arm64/include/asm/morello.h | 7 +- arch/arm64/include/asm/sysreg.h | 14 ++ arch/arm64/kernel/asm-offsets.c | 8 -- arch/arm64/kernel/morello.c | 150 ++++++++++++++++++--- arch/arm64/lib/Makefile | 3 +- arch/arm64/lib/morello.S | 205 ----------------------------- 7 files changed, 152 insertions(+), 245 deletions(-) delete mode 100644 arch/arm64/lib/morello.S