[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250612145754.2126147-2-rkrcmar@ventanamicro.com>
Date: Thu, 12 Jun 2025 16:57:53 +0200
From: Radim Krčmář <rkrcmar@...tanamicro.com>
To: linux-riscv@...ts.infradead.org
Cc: linux-kernel@...r.kernel.org,
Paul Walmsley <paul.walmsley@...ive.com>,
Palmer Dabbelt <palmer@...belt.com>,
Albert Ou <aou@...s.berkeley.edu>,
Alexandre Ghiti <alex@...ti.fr>,
Atish Patra <atishp@...osinc.com>,
Andrew Jones <ajones@...tanamicro.com>,
Clément Léger <cleger@...osinc.com>,
Anup Patel <apatel@...tanamicro.com>
Subject: [PATCH 0/2] RISC-V: turn sbi_ecall into a variadic macro
Padding the ecalls with zeros is not great for reasons in [1/2].
I could also redo the code to use sbi_ecall1~sbi_ecall8, and drop
sbi_ecall if you think that variadic macros are too evil.
[2/2] puts the new macro that into use, and I hopefully haven't deleted
any intentional trailing 0.
For a related issue, I hoped that the tracepoints in __sbi_ecall would
only add a nop or two, because __sbi_ecall without tracepoints looks
like this:
0xffffffff80023ad0 <+0>: addi sp,sp,-32
0xffffffff80023ad2 <+2>: sd s0,16(sp)
0xffffffff80023ad4 <+4>: sd ra,24(sp)
0xffffffff80023ad6 <+6>: addi s0,sp,32
0xffffffff80023ad8 <+8>: ecall
0xffffffff80023adc <+12>: ld ra,24(sp)
0xffffffff80023ade <+14>: ld s0,16(sp)
0xffffffff80023ae0 <+16>: addi sp,sp,32
0xffffffff80023ae2 <+18>: ret
Maybe I am missing some kernel config, because __sbi_ecall currently
looks like this:
0xffffffff80023e58 <+0>: addi sp,sp,-112
0xffffffff80023e5a <+2>: sd s0,96(sp)
0xffffffff80023e5c <+4>: sd s1,88(sp)
0xffffffff80023e5e <+6>: sd s3,72(sp)
0xffffffff80023e60 <+8>: sd s4,64(sp)
0xffffffff80023e62 <+10>: sd s5,56(sp)
0xffffffff80023e64 <+12>: sd s6,48(sp)
0xffffffff80023e66 <+14>: sd s7,40(sp)
0xffffffff80023e68 <+16>: sd s8,32(sp)
0xffffffff80023e6a <+18>: sd s9,24(sp)
0xffffffff80023e6c <+20>: sd ra,104(sp)
0xffffffff80023e6e <+22>: sd s2,80(sp)
0xffffffff80023e70 <+24>: addi s0,sp,112
0xffffffff80023e72 <+26>: mv s9,a0
0xffffffff80023e74 <+28>: mv s8,a1
0xffffffff80023e76 <+30>: mv s7,a2
0xffffffff80023e78 <+32>: mv s6,a3
0xffffffff80023e7a <+34>: mv s5,a4
0xffffffff80023e7c <+36>: mv s4,a5
0xffffffff80023e7e <+38>: mv s3,a6
0xffffffff80023e80 <+40>: mv s1,a7
0xffffffff80023e82 <+42>: nop
0xffffffff80023e84 <+44>: nop
0xffffffff80023e88 <+48>: mv a0,s9
0xffffffff80023e8a <+50>: mv a1,s8
0xffffffff80023e8c <+52>: mv a2,s7
0xffffffff80023e8e <+54>: mv a3,s6
0xffffffff80023e90 <+56>: mv a4,s5
0xffffffff80023e92 <+58>: mv a5,s4
0xffffffff80023e94 <+60>: mv a6,s3
0xffffffff80023e96 <+62>: mv a7,s1
0xffffffff80023e98 <+64>: ecall
0xffffffff80023e9c <+68>: mv s3,a0
0xffffffff80023e9e <+70>: mv s2,a1
0xffffffff80023ea0 <+72>: nop
0xffffffff80023ea4 <+76>: ld ra,104(sp)
0xffffffff80023ea6 <+78>: ld s0,96(sp)
0xffffffff80023ea8 <+80>: ld s1,88(sp)
0xffffffff80023eaa <+82>: ld s4,64(sp)
0xffffffff80023eac <+84>: ld s5,56(sp)
0xffffffff80023eae <+86>: ld s6,48(sp)
0xffffffff80023eb0 <+88>: ld s7,40(sp)
0xffffffff80023eb2 <+90>: ld s8,32(sp)
0xffffffff80023eb4 <+92>: ld s9,24(sp)
0xffffffff80023eb6 <+94>: mv a0,s3
0xffffffff80023eb8 <+96>: mv a1,s2
0xffffffff80023eba <+98>: ld s3,72(sp)
0xffffffff80023ebc <+100>: ld s2,80(sp)
0xffffffff80023ebe <+102>: addi sp,sp,112
0xffffffff80023ec0 <+104>: ret
...
[The actual tracepoint handling goes up to +328.]
Radim Krčmář (2):
RISC-V: sbi: turn sbi_ecall into variadic macro
RISC-V: make use of variadic sbi_ecall
arch/riscv/include/asm/kvm_nacl.h | 4 +--
arch/riscv/include/asm/sbi.h | 34 +++++++++++++++++-
arch/riscv/kernel/cpu_ops_sbi.c | 6 ++--
arch/riscv/kernel/paravirt.c | 2 +-
arch/riscv/kernel/sbi.c | 57 ++++++++++++++-----------------
arch/riscv/kernel/sbi_ecall.c | 2 +-
arch/riscv/kernel/suspend.c | 4 +--
arch/riscv/kvm/nacl.c | 7 ++--
drivers/acpi/riscv/cppc.c | 4 +--
drivers/perf/riscv_pmu_sbi.c | 48 +++++++++++++-------------
10 files changed, 98 insertions(+), 70 deletions(-)
--
2.49.0
Powered by blists - more mailing lists