From: Andrew Jones <andrew.jones@linux.dev>
To: kvm-riscv@lists.infradead.org, kvm@vger.kernel.org
Cc: cleger@rivosinc.com, atishp@rivosinc.com, akshaybehl231@gmail.com
Subject: [kvm-unit-tests PATCH 1/3] lib/riscv: Also provide sbiret impl functions
Date: Fri, 21 Mar 2025 17:54:05 +0100 [thread overview]
Message-ID: <20250321165403.57859-6-andrew.jones@linux.dev> (raw)
In-Reply-To: <20250321165403.57859-5-andrew.jones@linux.dev>
We almost always return sbiret from sbi wrapper functions so
do that for sbi_get_imp_version() and sbi_get_imp_id(), but
asserting no error and returning the value is also useful,
so continue to provide those functions too, just with a slightly
different name.
Signed-off-by: Andrew Jones <andrew.jones@linux.dev>
---
lib/riscv/asm/sbi.h | 6 ++++--
lib/riscv/sbi.c | 18 ++++++++++++++----
riscv/sbi-sse.c | 4 ++--
3 files changed, 20 insertions(+), 8 deletions(-)
diff --git a/lib/riscv/asm/sbi.h b/lib/riscv/asm/sbi.h
index edaee462c3fa..a5738a5ce209 100644
--- a/lib/riscv/asm/sbi.h
+++ b/lib/riscv/asm/sbi.h
@@ -260,9 +260,11 @@ struct sbiret sbi_send_ipi_cpumask(const cpumask_t *mask);
struct sbiret sbi_send_ipi_broadcast(void);
struct sbiret sbi_set_timer(unsigned long stime_value);
struct sbiret sbi_get_spec_version(void);
-unsigned long sbi_get_imp_version(void);
-unsigned long sbi_get_imp_id(void);
+struct sbiret sbi_get_imp_version(void);
+struct sbiret sbi_get_imp_id(void);
long sbi_probe(int ext);
+unsigned long __sbi_get_imp_version(void);
+unsigned long __sbi_get_imp_id(void);
typedef void (*sbi_sse_handler_fn)(void *data, struct pt_regs *regs, unsigned int hartid);
diff --git a/lib/riscv/sbi.c b/lib/riscv/sbi.c
index 53d25489f905..2959378f64bb 100644
--- a/lib/riscv/sbi.c
+++ b/lib/riscv/sbi.c
@@ -183,21 +183,31 @@ struct sbiret sbi_set_timer(unsigned long stime_value)
return sbi_ecall(SBI_EXT_TIME, SBI_EXT_TIME_SET_TIMER, stime_value, 0, 0, 0, 0, 0);
}
-unsigned long sbi_get_imp_version(void)
+struct sbiret sbi_get_imp_version(void)
+{
+ return sbi_ecall(SBI_EXT_BASE, SBI_EXT_BASE_GET_IMP_VERSION, 0, 0, 0, 0, 0, 0);
+}
+
+struct sbiret sbi_get_imp_id(void)
+{
+ return sbi_ecall(SBI_EXT_BASE, SBI_EXT_BASE_GET_IMP_ID, 0, 0, 0, 0, 0, 0);
+}
+
+unsigned long __sbi_get_imp_version(void)
{
struct sbiret ret;
- ret = sbi_ecall(SBI_EXT_BASE, SBI_EXT_BASE_GET_IMP_VERSION, 0, 0, 0, 0, 0, 0);
+ ret = sbi_get_imp_version();
assert(!ret.error);
return ret.value;
}
-unsigned long sbi_get_imp_id(void)
+unsigned long __sbi_get_imp_id(void)
{
struct sbiret ret;
- ret = sbi_ecall(SBI_EXT_BASE, SBI_EXT_BASE_GET_IMP_ID, 0, 0, 0, 0, 0, 0);
+ ret = sbi_get_imp_id();
assert(!ret.error);
return ret.value;
diff --git a/riscv/sbi-sse.c b/riscv/sbi-sse.c
index 97e07725c359..bc6afaf5481e 100644
--- a/riscv/sbi-sse.c
+++ b/riscv/sbi-sse.c
@@ -1232,8 +1232,8 @@ void check_sse(void)
return;
}
- if (sbi_get_imp_id() == SBI_IMPL_OPENSBI &&
- sbi_get_imp_version() < sbi_impl_opensbi_mk_version(1, 7)) {
+ if (__sbi_get_imp_id() == SBI_IMPL_OPENSBI &&
+ __sbi_get_imp_version() < sbi_impl_opensbi_mk_version(1, 7)) {
report_skip("OpenSBI < v1.7 detected, skipping tests");
report_prefix_pop();
return;
--
2.48.1
--
kvm-riscv mailing list
kvm-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kvm-riscv
WARNING: multiple messages have this Message-ID (diff)
From: Andrew Jones <andrew.jones@linux.dev>
To: kvm-riscv@lists.infradead.org, kvm@vger.kernel.org
Cc: cleger@rivosinc.com, atishp@rivosinc.com, akshaybehl231@gmail.com
Subject: [kvm-unit-tests PATCH 1/3] lib/riscv: Also provide sbiret impl functions
Date: Fri, 21 Mar 2025 17:54:05 +0100 [thread overview]
Message-ID: <20250321165403.57859-6-andrew.jones@linux.dev> (raw)
In-Reply-To: <20250321165403.57859-5-andrew.jones@linux.dev>
We almost always return sbiret from sbi wrapper functions so
do that for sbi_get_imp_version() and sbi_get_imp_id(), but
asserting no error and returning the value is also useful,
so continue to provide those functions too, just with a slightly
different name.
Signed-off-by: Andrew Jones <andrew.jones@linux.dev>
---
lib/riscv/asm/sbi.h | 6 ++++--
lib/riscv/sbi.c | 18 ++++++++++++++----
riscv/sbi-sse.c | 4 ++--
3 files changed, 20 insertions(+), 8 deletions(-)
diff --git a/lib/riscv/asm/sbi.h b/lib/riscv/asm/sbi.h
index edaee462c3fa..a5738a5ce209 100644
--- a/lib/riscv/asm/sbi.h
+++ b/lib/riscv/asm/sbi.h
@@ -260,9 +260,11 @@ struct sbiret sbi_send_ipi_cpumask(const cpumask_t *mask);
struct sbiret sbi_send_ipi_broadcast(void);
struct sbiret sbi_set_timer(unsigned long stime_value);
struct sbiret sbi_get_spec_version(void);
-unsigned long sbi_get_imp_version(void);
-unsigned long sbi_get_imp_id(void);
+struct sbiret sbi_get_imp_version(void);
+struct sbiret sbi_get_imp_id(void);
long sbi_probe(int ext);
+unsigned long __sbi_get_imp_version(void);
+unsigned long __sbi_get_imp_id(void);
typedef void (*sbi_sse_handler_fn)(void *data, struct pt_regs *regs, unsigned int hartid);
diff --git a/lib/riscv/sbi.c b/lib/riscv/sbi.c
index 53d25489f905..2959378f64bb 100644
--- a/lib/riscv/sbi.c
+++ b/lib/riscv/sbi.c
@@ -183,21 +183,31 @@ struct sbiret sbi_set_timer(unsigned long stime_value)
return sbi_ecall(SBI_EXT_TIME, SBI_EXT_TIME_SET_TIMER, stime_value, 0, 0, 0, 0, 0);
}
-unsigned long sbi_get_imp_version(void)
+struct sbiret sbi_get_imp_version(void)
+{
+ return sbi_ecall(SBI_EXT_BASE, SBI_EXT_BASE_GET_IMP_VERSION, 0, 0, 0, 0, 0, 0);
+}
+
+struct sbiret sbi_get_imp_id(void)
+{
+ return sbi_ecall(SBI_EXT_BASE, SBI_EXT_BASE_GET_IMP_ID, 0, 0, 0, 0, 0, 0);
+}
+
+unsigned long __sbi_get_imp_version(void)
{
struct sbiret ret;
- ret = sbi_ecall(SBI_EXT_BASE, SBI_EXT_BASE_GET_IMP_VERSION, 0, 0, 0, 0, 0, 0);
+ ret = sbi_get_imp_version();
assert(!ret.error);
return ret.value;
}
-unsigned long sbi_get_imp_id(void)
+unsigned long __sbi_get_imp_id(void)
{
struct sbiret ret;
- ret = sbi_ecall(SBI_EXT_BASE, SBI_EXT_BASE_GET_IMP_ID, 0, 0, 0, 0, 0, 0);
+ ret = sbi_get_imp_id();
assert(!ret.error);
return ret.value;
diff --git a/riscv/sbi-sse.c b/riscv/sbi-sse.c
index 97e07725c359..bc6afaf5481e 100644
--- a/riscv/sbi-sse.c
+++ b/riscv/sbi-sse.c
@@ -1232,8 +1232,8 @@ void check_sse(void)
return;
}
- if (sbi_get_imp_id() == SBI_IMPL_OPENSBI &&
- sbi_get_imp_version() < sbi_impl_opensbi_mk_version(1, 7)) {
+ if (__sbi_get_imp_id() == SBI_IMPL_OPENSBI &&
+ __sbi_get_imp_version() < sbi_impl_opensbi_mk_version(1, 7)) {
report_skip("OpenSBI < v1.7 detected, skipping tests");
report_prefix_pop();
return;
--
2.48.1
next prev parent reply other threads:[~2025-03-21 16:54 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-21 16:54 [kvm-unit-tests PATCH 0/3] riscv: sbi: Ensure we can pass with any opensbi Andrew Jones
2025-03-21 16:54 ` Andrew Jones
2025-03-21 16:54 ` Andrew Jones [this message]
2025-03-21 16:54 ` [kvm-unit-tests PATCH 1/3] lib/riscv: Also provide sbiret impl functions Andrew Jones
2025-03-21 20:15 ` Clément Léger
2025-03-21 20:15 ` Clément Léger
2025-03-21 16:54 ` [kvm-unit-tests PATCH 2/3] riscv: sbi: Add kfail versions of sbiret_report functions Andrew Jones
2025-03-21 16:54 ` Andrew Jones
2025-03-21 20:17 ` Clément Léger
2025-03-21 20:17 ` Clément Léger
2025-03-21 16:54 ` [kvm-unit-tests PATCH 3/3] riscv: sbi: Use kfail for known opensbi failures Andrew Jones
2025-03-21 16:54 ` Andrew Jones
2025-03-21 20:22 ` Clément Léger
2025-03-21 20:22 ` Clément Léger
2025-03-22 7:38 ` Andrew Jones
2025-03-22 7:38 ` Andrew Jones
2025-03-22 10:47 ` [kvm-unit-tests PATCH 0/3] riscv: sbi: Ensure we can pass with any opensbi Andrew Jones
2025-03-22 10:47 ` 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=20250321165403.57859-6-andrew.jones@linux.dev \
--to=andrew.jones@linux.dev \
--cc=akshaybehl231@gmail.com \
--cc=atishp@rivosinc.com \
--cc=cleger@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.