From: "Clément Léger" <cleger@rivosinc.com>
To: kvm@vger.kernel.org, kvm-riscv@lists.infradead.org
Cc: "Clément Léger" <cleger@rivosinc.com>,
"Andrew Jones" <ajones@ventanamicro.com>,
"Anup Patel" <apatel@ventanamicro.com>,
"Atish Patra" <atishp@rivosinc.com>,
"Andrew Jones" <andrew.jones@linux.dev>
Subject: [kvm-unit-tests PATCH v11 3/8] riscv: Use asm-offsets to generate SBI_EXT_HSM values
Date: Mon, 17 Mar 2025 17:46:48 +0100 [thread overview]
Message-ID: <20250317164655.1120015-4-cleger@rivosinc.com> (raw)
In-Reply-To: <20250317164655.1120015-1-cleger@rivosinc.com>
Replace hardcoded values with generated ones using sbi-asm-offset. This
allows to directly use ASM_SBI_EXT_HSM and ASM_SBI_EXT_HSM_STOP in
assembly.
Signed-off-by: Clément Léger <cleger@rivosinc.com>
Reviewed-by: Andrew Jones <andrew.jones@linux.dev>
---
riscv/Makefile | 2 +-
riscv/sbi-asm.S | 6 ++++--
riscv/sbi-asm-offsets.c | 11 +++++++++++
riscv/.gitignore | 1 +
4 files changed, 17 insertions(+), 3 deletions(-)
create mode 100644 riscv/sbi-asm-offsets.c
create mode 100644 riscv/.gitignore
diff --git a/riscv/Makefile b/riscv/Makefile
index ae9cf02a..02d2ac39 100644
--- a/riscv/Makefile
+++ b/riscv/Makefile
@@ -87,7 +87,7 @@ CFLAGS += -ffreestanding
CFLAGS += -O2
CFLAGS += -I $(SRCDIR)/lib -I $(SRCDIR)/lib/libfdt -I lib -I $(SRCDIR)/riscv
-asm-offsets = lib/riscv/asm-offsets.h
+asm-offsets = lib/riscv/asm-offsets.h riscv/sbi-asm-offsets.h
include $(SRCDIR)/scripts/asm-offsets.mak
.PRECIOUS: %.aux.o
diff --git a/riscv/sbi-asm.S b/riscv/sbi-asm.S
index f4185496..51f46efd 100644
--- a/riscv/sbi-asm.S
+++ b/riscv/sbi-asm.S
@@ -6,6 +6,8 @@
*/
#include <asm/asm.h>
#include <asm/csr.h>
+#include <asm/asm-offsets.h>
+#include <generated/sbi-asm-offsets.h>
#include "sbi-tests.h"
@@ -57,8 +59,8 @@ sbi_hsm_check:
7: lb t0, 0(t1)
pause
beqz t0, 7b
- li a7, 0x48534d /* SBI_EXT_HSM */
- li a6, 1 /* SBI_EXT_HSM_HART_STOP */
+ li a7, ASM_SBI_EXT_HSM
+ li a6, ASM_SBI_EXT_HSM_HART_STOP
ecall
8: pause
j 8b
diff --git a/riscv/sbi-asm-offsets.c b/riscv/sbi-asm-offsets.c
new file mode 100644
index 00000000..bd37b6a2
--- /dev/null
+++ b/riscv/sbi-asm-offsets.c
@@ -0,0 +1,11 @@
+// SPDX-License-Identifier: GPL-2.0-only
+#include <kbuild.h>
+#include <asm/sbi.h>
+
+int main(void)
+{
+ DEFINE(ASM_SBI_EXT_HSM, SBI_EXT_HSM);
+ DEFINE(ASM_SBI_EXT_HSM_HART_STOP, SBI_EXT_HSM_HART_STOP);
+
+ return 0;
+}
diff --git a/riscv/.gitignore b/riscv/.gitignore
new file mode 100644
index 00000000..0a8c5a36
--- /dev/null
+++ b/riscv/.gitignore
@@ -0,0 +1 @@
+/*-asm-offsets.[hs]
--
2.47.2
next prev parent reply other threads:[~2025-03-17 16:49 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-17 16:46 [kvm-unit-tests PATCH v11 0/8] riscv: add SBI SSE extension tests Clément Léger
2025-03-17 16:46 ` [kvm-unit-tests PATCH v11 1/8] kbuild: Allow multiple asm-offsets file to be generated Clément Léger
2025-03-17 16:46 ` [kvm-unit-tests PATCH v11 2/8] riscv: Set .aux.o files as .PRECIOUS Clément Léger
2025-03-17 16:46 ` Clément Léger [this message]
2025-03-20 13:36 ` [kvm-unit-tests PATCH v11 3/8] riscv: Use asm-offsets to generate SBI_EXT_HSM values Andrew Jones
2025-03-17 16:46 ` [kvm-unit-tests PATCH v11 4/8] lib: riscv: Add functions for version checking Clément Léger
2025-03-19 17:31 ` Andrew Jones
2025-03-20 8:08 ` Clément Léger
2025-03-17 16:46 ` [kvm-unit-tests PATCH v11 5/8] lib: riscv: Add functions to get implementer ID and version Clément Léger
2025-03-19 17:36 ` Andrew Jones
2025-03-17 16:46 ` [kvm-unit-tests PATCH v11 6/8] riscv: lib: Add SBI SSE extension definitions Clément Léger
2025-03-17 16:46 ` [kvm-unit-tests PATCH v11 7/8] lib: riscv: Add SBI SSE support Clément Léger
2025-03-17 16:46 ` [kvm-unit-tests PATCH v11 8/8] riscv: sbi: Add SSE extension tests Clément Léger
2025-03-20 13:40 ` Andrew Jones
2025-03-20 13:44 ` Clément Léger
2025-03-20 13:46 ` Andrew Jones
2025-03-20 13:50 ` Clément Léger
2025-03-19 18:01 ` [kvm-unit-tests PATCH v11 0/8] riscv: add SBI " Andrew Jones
2025-03-20 8:13 ` Clément Léger
2025-03-20 14:26 ` Andrew Jones
2025-03-22 10:46 ` Andrew Jones
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=20250317164655.1120015-4-cleger@rivosinc.com \
--to=cleger@rivosinc.com \
--cc=ajones@ventanamicro.com \
--cc=andrew.jones@linux.dev \
--cc=apatel@ventanamicro.com \
--cc=atishp@rivosinc.com \
--cc=kvm-riscv@lists.infradead.org \
--cc=kvm@vger.kernel.org \
/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