diff options
| author | Jisheng Zhang <jszhang@kernel.org> | 2026-10-08 23:00:44 +0800 |
|---|---|---|
| committer | Paul Walmsley <pjw@kernel.org> | 2026-10-08 15:39:37 -0600 |
| commit | 36de74049ec8cb1a9ef4d40c586e9c017cde6cc1 (patch) | |
| tree | 6fc532fac32203594cc13117eb30bbe2cc09f3bc /tools/lib/python | |
| parent | 267bb2b528b574a7f400bf66bb12b11940f26b1d (diff) | |
| download | linux-next-36de74049ec8cb1a9ef4d40c586e9c017cde6cc1.tar.gz linux-next-36de74049ec8cb1a9ef4d40c586e9c017cde6cc1.zip | |
riscv: introduce RISCV_ISA_SV48 and RISCV_ISA_SV57
In last commit, we have optimized the pgtable_l4|l5_enabled with isa
extension alternative mechanism, thus a typical access_ok(addr, 1);
is compiled as:
ffffffff8001dd30: 1141 addi sp,sp,-16
ffffffff8001dd32: e022 sd s0,0(sp)
ffffffff8001dd34: e406 sd ra,8(sp)
ffffffff8001dd36: 0800 addi s0,sp,16
ffffffff8001dd38: 00000013 nop
ffffffff8001dd3c: 02a0006f j ffffffff8001dd66 <foo+0x3e>
ffffffff8001dd40: 60a2 ld ra,8(sp)
ffffffff8001dd42: 6402 ld s0,0(sp)
ffffffff8001dd44: 57fd li a5,-1
ffffffff8001dd46: 83a1 srli a5,a5,0x8
ffffffff8001dd48: 00a7b533 sltu a0,a5,a0
ffffffff8001dd4c: 00154513 xori a0,a0,1
ffffffff8001dd50: 0141 addi sp,sp,16
ffffffff8001dd52: 8082 ret
...
ffffffff8001dd64: bfe1 j ffffffff8001dd3c <foo+0x14>
ffffffff8001dd66: 0180006f j ffffffff8001dd7e <foo+0x56>
ffffffff8001dd6a: 60a2 ld ra,8(sp)
ffffffff8001dd6c: 6402 ld s0,0(sp)
ffffffff8001dd6e: 57fd li a5,-1
ffffffff8001dd70: 83c5 srli a5,a5,0x11
ffffffff8001dd72: 00a7b533 sltu a0,a5,a0
ffffffff8001dd76: 00154513 xori a0,a0,1
ffffffff8001dd7a: 0141 addi sp,sp,16
ffffffff8001dd7c: 8082 ret
ffffffff8001dd7e: 60a2 ld ra,8(sp)
ffffffff8001dd80: 6402 ld s0,0(sp)
ffffffff8001dd82: 57fd li a5,-1
ffffffff8001dd84: 83e9 srli a5,a5,0x1a
ffffffff8001dd86: 00a7b533 sltu a0,a5,a0
ffffffff8001dd8a: 00154513 xori a0,a0,1
ffffffff8001dd8e: 0141 addi sp,sp,16
ffffffff8001dd90: 8082 ret
As can be seen, different branches for SV39/SV48/SV57 are still there,
since access_ok() sits at hot code path, why not reduce the code size
to optimize to make the instruction cache happy?
Introduce RISCV_ISA_SV48 and RISCV_ISA_SV57, so that the embedded
platforms can choose the best option themselves, while still keep the
feature of one unified kernel Image for all SV39, SV48 and SV57.
Before the patch, vmlinux built with pure RISCV64 defconfig
text data bss dec hex filename
13439437 6790446 483221 20713104 13c0e90 /tmp/old/vmlinux
After the patch, vmlinux built with pure RISCV64 defconfig:
text data bss dec hex filename
13314445 6787934 466837 20569216 139dc80 /tmp/new/vmlinux
.text section is reduced by 122KB!
And after the patch, typical access_ok(addr, 1) is compiled as:
ffffffff8001809a: 1141 addi sp,sp,-16
ffffffff8001809c: e022 sd s0,0(sp)
ffffffff8001809e: e406 sd ra,8(sp)
ffffffff800180a0: 0800 addi s0,sp,16
ffffffff800180a2: 00000013 nop
ffffffff800180a6: 60a2 ld ra,8(sp)
ffffffff800180a8: 6402 ld s0,0(sp)
ffffffff800180aa: 4785 li a5,1
ffffffff800180ac: 179a slli a5,a5,0x26
ffffffff800180ae: 00f53533 sltu a0,a0,a5
ffffffff800180b2: 0141 addi sp,sp,16
ffffffff800180b4: 8082 ret
only 12 instruction!! For refernece, before the patch, the access(addr,
1) needs 32 instructions.
Signed-off-by: Jisheng Zhang <jszhang@kernel.org>
Acked-by: Conor Dooley <conor.dooley@microchip.com>
Link: https://patch.msgid.link/20261008150045.28905-5-jszhang@kernel.org
Signed-off-by: Paul Walmsley <pjw@kernel.org>
Diffstat (limited to 'tools/lib/python')
0 files changed, 0 insertions, 0 deletions
