From: "Radim Krčmář" <rkrcmar@ventanamicro.com>
To: linux-riscv@lists.infradead.org
Cc: linux-kernel@vger.kernel.org,
"Paul Walmsley" <paul.walmsley@sifive.com>,
"Palmer Dabbelt" <palmer@dabbelt.com>,
"Albert Ou" <aou@eecs.berkeley.edu>,
"Alexandre Ghiti" <alex@ghiti.fr>,
"Atish Patra" <atishp@rivosinc.com>,
"Andrew Jones" <ajones@ventanamicro.com>,
"Clément Léger" <cleger@rivosinc.com>,
"Anup Patel" <apatel@ventanamicro.com>
Subject: [PATCH 0/2] RISC-V: turn sbi_ecall into a variadic macro
Date: Thu, 12 Jun 2025 16:57:53 +0200 [thread overview]
Message-ID: <20250612145754.2126147-2-rkrcmar@ventanamicro.com> (raw)
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
next reply other threads:[~2025-06-12 15:00 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-12 14:57 Radim Krčmář [this message]
2025-06-12 14:57 ` [PATCH 1/2] RISC-V: sbi: turn sbi_ecall into " Radim Krčmář
2025-06-12 15:14 ` Thomas Weißschuh
2025-06-12 15:35 ` Radim Krčmář
2025-06-12 14:57 ` [PATCH 2/2] RISC-V: make use of variadic sbi_ecall Radim Krčmář
2025-06-13 10:54 ` David Laight
2025-06-13 14:10 ` Radim Krčmář
2025-06-13 15:52 ` David Laight
2025-06-13 17:08 ` Radim Krčmář
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250612145754.2126147-2-rkrcmar@ventanamicro.com \
--to=rkrcmar@ventanamicro.com \
--cc=ajones@ventanamicro.com \
--cc=alex@ghiti.fr \
--cc=aou@eecs.berkeley.edu \
--cc=apatel@ventanamicro.com \
--cc=atishp@rivosinc.com \
--cc=cleger@rivosinc.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®