riscv: sbi: Check and test spec version
The base extension tests are only valid for spec versions 0.2 and
later, so ensure we have that before proceeding. Also check the
spec version matches an expected value, as we do the other functions.
Signed-off-by: Andrew Jones <ajones@ventanamicro.com>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
Signed-off-by: Andrew Jones <andrew.jones@linux.dev>
diff --git a/riscv/sbi.c b/riscv/sbi.c
index cd36290..707ce8d 100644
--- a/riscv/sbi.c
+++ b/riscv/sbi.c
@@ -50,6 +50,19 @@
report_prefix_push("base");
+ ret = __base_sbi_ecall(SBI_EXT_BASE_GET_SPEC_VERSION, 0);
+ if (ret.error || ret.value < 2) {
+ report_skip("SBI spec version 0.2 or higher required");
+ return;
+ }
+
+ report_prefix_push("spec_version");
+ if (env_or_skip("SPEC_VERSION")) {
+ expected = strtol(getenv("SPEC_VERSION"), NULL, 0);
+ gen_report(&ret, 0, expected);
+ }
+ report_prefix_pop();
+
report_prefix_push("impl_id");
if (env_or_skip("IMPL_ID")) {
expected = strtol(getenv("IMPL_ID"), NULL, 0);