Skip to contentSkip to conversation

riscv: add SBI SSE extension tests

PATCH Superseded Clément Léger 3 participants 13 messages Mar 17, 2025

Subsystems (3)

v10 of 11 Superseded Latest is v11 →

lore
Share & tools
lore
#0 lore raw

v10 cover riscv: add SBI SSE extension tests

This series adds tests for SBI SSE extension as well as needed infrastructure for SSE support. It also adds test specific asm-offsets generation to use custom OFFSET and DEFINE from the test directory.

These tests can be run using an OpenSBI version that implements latest specifications modification [1]

---

V10:
- Use && instead of || for timeout handling
- Add SBI patches which introduce function to get implementer ID and version as well as implementer ID defines.
- Skip injection tests in OpenSBI < v1.6

V9:
- Use __ASSEMBLER__ instead of __ASSEMBLY__
- Remove extra spaces
- Use assert to check global event in sse_global_event_set_current_hart()
- Tabulate SSE events names table
- Use sbi_sse_register() instead of sbi_sse_register_raw() in error testing
- Move a report_pass() out of error path
- Rework all injection tests with better error handling
- Use an env var for sse event completion timeout
- Add timeout for some potentially infinite while() loops

V8:
- Short circuit current event tests if failure happens
- Remove SSE from all report strings
- Indent .prio field
- Add cpu_relax()/smp_rmb() where needed
- Add timeout for global event ENABLED state check
- Added BIT(32) aliases tests for attribute/event_id.

V7:
- Test ids/attributes/attributes count > 32 bits
- Rename all SSE function to sbi_sse_*
- Use event_id instead of event/evt
- Factorize read/write test
- Use virt_to_phys() for attributes read/write.
- Extensively use sbiret_report_error()
- Change check function return values to bool.
- Added assert for stack size to be below or equal to PAGE_SIZE
- Use en env variable for the maximum hart ID
- Check that individual read from attributes matches the multiple attributes read.
- Added multiple attributes write at once
- Used READ_ONCE/WRITE_ONCE
- Inject all local event at once rather than looping fopr each core.
- Split test_arg for local_dispatch test so that all CPUs can run at once.
- Move SSE entry and generic code to lib/riscv for other tests
- Fix unmask/mask state checking

V6:
- Add missing $(generated-file) dependencies for "-deps" objects
- Split SSE entry from sbi-asm.S to sse-asm.S and all SSE core functions since it will be useful for other tests as well (dbltrp).

V5:
- Update event ranges based on latest spec
- Rename asm-offset-test.c to sbi-asm-offset.c

V4:
- Fix typo sbi_ext_ss_fid -> sbi_ext_sse_fid
- Add proper asm-offset generation for tests
- Move SSE specific file from lib/riscv to riscv/

V3:
- Add -deps variable for test specific dependencies
- Fix formatting errors/typo in sbi.h
- Add missing double trap event
- Alphabetize sbi-sse.c includes
- Fix a6 content after unmasking event
- Add SSE HART_MASK/UNMASK test
- Use mv instead of move
- move sbi_check_sse() definition in sbi.c
- Remove sbi_sse test from unitests.cfg

V2:
- Rebased on origin/master and integrate it into sbi.c tests

Clément Léger (8):
kbuild: Allow multiple asm-offsets file to be generated
riscv: Set .aux.o files as .PRECIOUS
riscv: Use asm-offsets to generate SBI_EXT_HSM values
riscv: sbi: Add functions for version checking
lib: riscv: add functions to get implementer ID and version
riscv: lib: Add SBI SSE extension definitions
lib: riscv: Add SBI SSE support
riscv: sbi: Add SSE extension tests

 scripts/asm-offsets.mak |   22 +-
 riscv/Makefile          |    5 +-
 lib/riscv/asm/csr.h     |    1 +
 lib/riscv/asm/sbi.h     |  187 +++++-
 lib/riscv/sbi-sse-asm.S |  102 ++++
 lib/riscv/asm-offsets.c |    9 +
 lib/riscv/sbi.c         |   95 ++-
 riscv/sbi-tests.h       |    1 +
 riscv/sbi-asm.S         |    6 +-
 riscv/sbi-asm-offsets.c |   11 +
 riscv/sbi-sse.c         | 1280 +++++++++++++++++++++++++++++++++++++++
 riscv/sbi.c             |    2 +
 riscv/.gitignore        |    1 +
 13 files changed, 1709 insertions(+), 13 deletions(-)
 create mode 100644 lib/riscv/sbi-sse-asm.S
 create mode 100644 riscv/sbi-asm-offsets.c
 create mode 100644 riscv/sbi-sse.c
 create mode 100644 riscv/.gitignore
Signature · 1 line
2.47.2
#1 lore raw

PATCH v10 1/8 kbuild: Allow multiple asm-offsets file to be generated

In order to allow multiple asm-offsets files to generated the include guard need to be different between these file. Add a asm_offset_name makefile macro to obtain an uppercase name matching the original asm offsets file.

---
 scripts/asm-offsets.mak | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)
scripts/asm-offsets.mak +15 -7
index 7b64162d..a5fdbf5d 100644
@@ -15,10 +15,14 @@ define sed-y
 	s:->::; p;}'
 endef
 
+define asm_offset_name
+	$(shell echo $(notdir $(1)) | tr [:lower:]- [:upper:]_)
+endef
+
 define make_asm_offsets
 	(set -e; \
-	 echo "#ifndef __ASM_OFFSETS_H__"; \
-	 echo "#define __ASM_OFFSETS_H__"; \
+	 echo "#ifndef __$(strip $(asm_offset_name))_H__"; \
+	 echo "#define __$(strip $(asm_offset_name))_H__"; \
 	 echo "/*"; \
 	 echo " * Generated file. DO NOT MODIFY."; \
 	 echo " *"; \
@@ -29,12 +33,16 @@ define make_asm_offsets
 	 echo "#endif" ) > $@
 endef
 
-$(asm-offsets:.h=.s): $(asm-offsets:.h=.c)
-	$(CC) $(CFLAGS) -fverbose-asm -S -o $@ $<
+define gen_asm_offsets_rules
+$(1).s: $(1).c
+	$(CC) $(CFLAGS) -fverbose-asm -S -o $$@ $$<
+
+$(1).h: $(1).s
+	$$(call make_asm_offsets,$(1))
+	cp -f $$@ lib/generated/
+endef
 
-$(asm-offsets): $(asm-offsets:.h=.s)
-	$(call make_asm_offsets)
-	cp -f $(asm-offsets) lib/generated/
+$(foreach o,$(asm-offsets),$(eval $(call gen_asm_offsets_rules, $(o:.h=))))
 
 OBJDIRS += lib/generated
 
Signature · 1 line
2.47.2
#2 lore raw

PATCH v10 2/8 riscv: Set .aux.o files as .PRECIOUS

In reply to Clément Léger

When compiling, we need to keep .aux.o file or they will be removed after the compilation which leads to dependent files to be recompiled. Set these files as .PRECIOUS to keep them.

---
 riscv/Makefile | 1 +
 1 file changed, 1 insertion(+)
riscv/Makefile +1 -0
index 52718f3f..ae9cf02a 100644
@@ -90,6 +90,7 @@ CFLAGS += -I $(SRCDIR)/lib -I $(SRCDIR)/lib/libfdt -I lib -I $(SRCDIR)/riscv
 asm-offsets = lib/riscv/asm-offsets.h
 include $(SRCDIR)/scripts/asm-offsets.mak
 
+.PRECIOUS: %.aux.o
 %.aux.o: $(SRCDIR)/lib/auxinfo.c
 	$(CC) $(CFLAGS) -c -o $@ $< \
 		-DPROGNAME=\"$(notdir $(@:.aux.o=.$(exe)))\" -DAUXFLAGS=$(AUXFLAGS)
Signature · 1 line
2.47.2
#3 lore raw

PATCH v10 3/8 riscv: Use asm-offsets to generate SBI_EXT_HSM values

In reply to Clément Léger

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.

---
 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
riscv/Makefile +1 -1
index ae9cf02a..02d2ac39 100644
@@ -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
riscv/sbi-asm.S +4 -2
index f4185496..51f46efd 100644
@@ -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
riscv/sbi-asm-offsets.c new file +11 -0
new file mode 100644
index 00000000..bd37b6a2
@@ -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;
+}
riscv/.gitignore new file +1 -0
new file mode 100644
index 00000000..0a8c5a36
@@ -0,0 +1 @@
+/*-asm-offsets.[hs]
Signature · 1 line
2.47.2
#4 lore raw

PATCH v10 4/8 riscv: sbi: Add functions for version checking

In reply to Clément Léger

Version checking was done using some custom hardcoded values, backport a few SBI function and defines from Linux to do that cleanly.

---
 lib/riscv/asm/sbi.h | 15 +++++++++++++++
 lib/riscv/sbi.c     |  9 +++++++--
 2 files changed, 22 insertions(+), 2 deletions(-)
lib/riscv/asm/sbi.h +15 -0
index 2f4d91ef..197288c7 100644
@@ -18,6 +18,12 @@
 #define SBI_ERR_IO			-13
 #define SBI_ERR_DENIED_LOCKED		-14
 
+/* SBI spec version fields */
+#define SBI_SPEC_VERSION_DEFAULT	0x1
+#define SBI_SPEC_VERSION_MAJOR_SHIFT	24
+#define SBI_SPEC_VERSION_MAJOR_MASK	0x7f
+#define SBI_SPEC_VERSION_MINOR_MASK	0xffffff
+
 #ifndef __ASSEMBLER__
 #include <cpumask.h>
 
@@ -110,6 +116,14 @@ struct sbiret {
 	long value;
 };
 
+/* Make SBI version */
+static inline unsigned long sbi_mk_version(unsigned long major, unsigned long minor)
+{
+	return ((major & SBI_SPEC_VERSION_MAJOR_MASK) << SBI_SPEC_VERSION_MAJOR_SHIFT)
+		| (minor & SBI_SPEC_VERSION_MINOR_MASK);
+}
+
+
 struct sbiret sbi_ecall(int ext, int fid, unsigned long arg0,
 			unsigned long arg1, unsigned long arg2,
 			unsigned long arg3, unsigned long arg4,
@@ -124,6 +138,7 @@ struct sbiret sbi_send_ipi_cpu(int cpu);
 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);
 long sbi_probe(int ext);
 
 #endif /* !__ASSEMBLER__ */
lib/riscv/sbi.c +7 -2
index 02dd338c..3c395cff 100644
@@ -107,12 +107,17 @@ 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);
 }
 
+struct sbiret sbi_get_spec_version(void)
+{
+	return sbi_ecall(SBI_EXT_BASE, SBI_EXT_BASE_GET_SPEC_VERSION, 0, 0, 0, 0, 0, 0);
+}
+
 long sbi_probe(int ext)
 {
 	struct sbiret ret;
 
-	ret = sbi_ecall(SBI_EXT_BASE, SBI_EXT_BASE_GET_SPEC_VERSION, 0, 0, 0, 0, 0, 0);
-	assert(!ret.error && (ret.value & 0x7ffffffful) >= 2);
+	ret = sbi_get_spec_version();
+	assert(!ret.error && ret.value >= sbi_mk_version(2, 0));
 
 	ret = sbi_ecall(SBI_EXT_BASE, SBI_EXT_BASE_PROBE_EXT, ext, 0, 0, 0, 0, 0);
 	assert(!ret.error);
Signature · 1 line
2.47.2
#5 lore raw

Re: [kvm-unit-tests PATCH v10 4/8] riscv: sbi: Add functions for version checking

Quoted 14 lines · Clément Léger

Version checking was done using some custom hardcoded values, backport a few SBI function and defines from Linux to do that cleanly.

---
 lib/riscv/asm/sbi.h | 15 +++++++++++++++
 lib/riscv/sbi.c     |  9 +++++++--
 2 files changed, 22 insertions(+), 2 deletions(-)
lib/riscv/asm/sbi.h +0 -0
index 2f4d91ef..197288c7 100644

lib/riscv/asm/sbi.h line 22

Quoted 5 lines
lib/riscv/asm/sbi.h +2 -0
@@ -18,6 +18,12 @@
 #define SBI_ERR_IO			-13
 #define SBI_ERR_DENIED_LOCKED		-14
 
+/* SBI spec version fields */
+#define SBI_SPEC_VERSION_DEFAULT	0x1

We don't need this define, since we don't support version 0.1. But there is another mask we should add. See below.

Quoted 9 lines
lib/riscv/asm/sbi.h +4 -0
+#define SBI_SPEC_VERSION_MAJOR_SHIFT	24
+#define SBI_SPEC_VERSION_MAJOR_MASK	0x7f
+#define SBI_SPEC_VERSION_MINOR_MASK	0xffffff
+
 #ifndef __ASSEMBLER__
 #include <cpumask.h>
 
@@ -110,6 +116,14 @@ struct sbiret {
 	long value;

lib/riscv/asm/sbi.h struct sbiret { · line 126

Quoted 10 lines
lib/riscv/asm/sbi.h +8 -0
 };
 
+/* Make SBI version */
+static inline unsigned long sbi_mk_version(unsigned long major, unsigned long minor)
+{
+	return ((major & SBI_SPEC_VERSION_MAJOR_MASK) << SBI_SPEC_VERSION_MAJOR_SHIFT)
+		| (minor & SBI_SPEC_VERSION_MINOR_MASK);
+}
+
+

Extra blank, but I see it goes away with the next patch.

Quoted 22 lines
lib/riscv/asm/sbi.h +1 -0
 struct sbiret sbi_ecall(int ext, int fid, unsigned long arg0,
 			unsigned long arg1, unsigned long arg2,
 			unsigned long arg3, unsigned long arg4,
@@ -124,6 +138,7 @@ struct sbiret sbi_send_ipi_cpu(int cpu);
 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);
 long sbi_probe(int ext);
 
 #endif /* !__ASSEMBLER__ */
lib/riscv/sbi.c +3 -0
index 02dd338c..3c395cff 100644
@@ -107,12 +107,17 @@ 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);
 }
 
+struct sbiret sbi_get_spec_version(void)
+{
+	return sbi_ecall(SBI_EXT_BASE, SBI_EXT_BASE_GET_SPEC_VERSION, 0, 0, 0, 0, 0, 0);

lib/riscv/sbi.c struct sbiret sbi_set_timer(unsigned long stime_value) · line 120

Quoted 10 lines
lib/riscv/sbi.c +4 -2
+}
+
 long sbi_probe(int ext)
 {
 	struct sbiret ret;
 
-	ret = sbi_ecall(SBI_EXT_BASE, SBI_EXT_BASE_GET_SPEC_VERSION, 0, 0, 0, 0, 0, 0);
-	assert(!ret.error && (ret.value & 0x7ffffffful) >= 2);
+	ret = sbi_get_spec_version();
+	assert(!ret.error && ret.value >= sbi_mk_version(2, 0));

This changes the check from >= 0.2 to >= 2.0. Also, before, we were more tolerant with the return value potentially having upper bits set, since the spec only recently added "When XLEN is greater than 32, bits 32 and above are also reserved and must be 0." and we can leave it to the SBI tests to check those bits. IOW, this should be

#define SBI_SPEC_VERSION_MASK 0x7fffffff

assert(!ret.error && (ret.value & SBI_SPEC_VERSION_MASK) >= sbi_mk_version(0, 2));

Quoted 6 lines
lib/riscv/sbi.c +0 -0
 	ret = sbi_ecall(SBI_EXT_BASE, SBI_EXT_BASE_PROBE_EXT, ext, 0, 0, 0, 0, 0);
 	assert(!ret.error);
Signature · 1 line
2.47.2

Thanks,
drew

#6 lore raw

PATCH v10 5/8 lib: riscv: add functions to get implementer ID and version

In reply to Clément Léger

These function will be used by SSE tests to check for a specific opensbi version. sbi_impl_check() is an helper allowing to check for a specific SBI implementor without needing to check for ret.error.

---
 lib/riscv/asm/sbi.h | 30 ++++++++++++++++++++++++++++++
 lib/riscv/sbi.c     | 10 ++++++++++
 2 files changed, 40 insertions(+)
lib/riscv/asm/sbi.h +30 -0
index 197288c7..06bcec16 100644
@@ -18,6 +18,19 @@
 #define SBI_ERR_IO			-13
 #define SBI_ERR_DENIED_LOCKED		-14
 
+#define SBI_IMPL_BBL		0
+#define SBI_IMPL_OPENSBI	1
+#define SBI_IMPL_XVISOR		2
+#define SBI_IMPL_KVM		3
+#define SBI_IMPL_RUSTSBI	4
+#define SBI_IMPL_DIOSIX		5
+#define SBI_IMPL_COFFER		6
+#define SBI_IMPL_XEN Project	7
+#define SBI_IMPL_POLARFIRE_HSS	8
+#define SBI_IMPL_COREBOOT	9
+#define SBI_IMPL_OREBOOT	10
+#define SBI_IMPL_BHYVE		11
+
 /* SBI spec version fields */
 #define SBI_SPEC_VERSION_DEFAULT	0x1
 #define SBI_SPEC_VERSION_MAJOR_SHIFT	24
@@ -123,6 +136,10 @@ static inline unsigned long sbi_mk_version(unsigned long major, unsigned long mi
 		| (minor & SBI_SPEC_VERSION_MINOR_MASK);
 }
 
+static inline unsigned long sbi_impl_opensbi_mk_version(unsigned long major, unsigned long minor)
+{
+	return ((major << 16) | (minor));
+}
 
 struct sbiret sbi_ecall(int ext, int fid, unsigned long arg0,
 			unsigned long arg1, unsigned long arg2,
@@ -139,7 +156,20 @@ 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);
+struct sbiret sbi_get_imp_version(void);
+struct sbiret sbi_get_imp_id(void);
 long sbi_probe(int ext);
 
+static inline bool sbi_check_impl(unsigned long impl)
+{
+	struct sbiret ret;
+
+	ret = sbi_get_imp_id();
+	if (ret.error)
+		return false;
+
+	return ret.value == impl;
+}
+
 #endif /* !__ASSEMBLER__ */
 #endif /* _ASMRISCV_SBI_H_ */
lib/riscv/sbi.c +10 -0
index 3c395cff..9cb5757e 100644
@@ -107,6 +107,16 @@ 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);
 }
 
+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);
+}
+
 struct sbiret sbi_get_spec_version(void)
 {
 	return sbi_ecall(SBI_EXT_BASE, SBI_EXT_BASE_GET_SPEC_VERSION, 0, 0, 0, 0, 0, 0);
Signature · 1 line
2.47.2
#7 lore raw

Re: [kvm-unit-tests PATCH v10 5/8] lib: riscv: add functions to get implementer ID and version

Quoted 16 lines · Clément Léger

These function will be used by SSE tests to check for a specific opensbi version. sbi_impl_check() is an helper allowing to check for a specific SBI implementor without needing to check for ret.error.

---
 lib/riscv/asm/sbi.h | 30 ++++++++++++++++++++++++++++++
 lib/riscv/sbi.c     | 10 ++++++++++
 2 files changed, 40 insertions(+)
lib/riscv/asm/sbi.h +0 -0
index 197288c7..06bcec16 100644
@@ -18,6 +18,19 @@
 #define SBI_ERR_IO			-13

lib/riscv/asm/sbi.h line 28

Quoted 10 lines
lib/riscv/asm/sbi.h +8 -0
 #define SBI_ERR_DENIED_LOCKED		-14
 
+#define SBI_IMPL_BBL		0
+#define SBI_IMPL_OPENSBI	1
+#define SBI_IMPL_XVISOR		2
+#define SBI_IMPL_KVM		3
+#define SBI_IMPL_RUSTSBI	4
+#define SBI_IMPL_DIOSIX		5
+#define SBI_IMPL_COFFER		6
+#define SBI_IMPL_XEN Project	7

s/Project//

Quoted 9 lines
lib/riscv/asm/sbi.h +5 -0
+#define SBI_IMPL_POLARFIRE_HSS	8
+#define SBI_IMPL_COREBOOT	9
+#define SBI_IMPL_OREBOOT	10
+#define SBI_IMPL_BHYVE		11
+
 /* SBI spec version fields */
 #define SBI_SPEC_VERSION_DEFAULT	0x1
 #define SBI_SPEC_VERSION_MAJOR_SHIFT	24

lib/riscv/asm/sbi.h static inline unsigned long sbi_mk_version(unsigned long major, unsigned long mi · line 141

Quoted 6 lines
lib/riscv/asm/sbi.h +3 -0
@@ -123,6 +136,10 @@ static inline unsigned long sbi_mk_version(unsigned long major, unsigned long mi
 		| (minor & SBI_SPEC_VERSION_MINOR_MASK);
 }
 
+static inline unsigned long sbi_impl_opensbi_mk_version(unsigned long major, unsigned long minor)
+{
+	return ((major << 16) | (minor));

Should at least mask minor, best to mask both.

Quoted 11 lines
lib/riscv/asm/sbi.h +3 -0
+}
 
 struct sbiret sbi_ecall(int ext, int fid, unsigned long arg0,
 			unsigned long arg1, unsigned long arg2,
@@ -139,7 +156,20 @@ 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);
+struct sbiret sbi_get_imp_version(void);
+struct sbiret sbi_get_imp_id(void);
 long sbi_probe(int ext);

lib/riscv/asm/sbi.h struct sbiret sbi_send_ipi_cpumask(const cpumask_t *mask); · line 171

Quoted 10 lines
lib/riscv/asm/sbi.h +9 -0
 
+static inline bool sbi_check_impl(unsigned long impl)
+{
+	struct sbiret ret;
+
+	ret = sbi_get_imp_id();
+	if (ret.error)
+		return false;
+
+	return ret.value == impl;

Or, more tersely,

struct sbiret ret = sbi_get_imp_id();
return !ret.error && ret.value == impl;

but an assert would make more sense, since get-impl-id really shouldn't fail, unless the SBI version is 0.1, which we don't support.

Quoted 11 lines
lib/riscv/asm/sbi.h +2 -0
+}
+
 #endif /* !__ASSEMBLER__ */
 #endif /* _ASMRISCV_SBI_H_ */
lib/riscv/sbi.c +0 -0
index 3c395cff..9cb5757e 100644
@@ -107,6 +107,16 @@ 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);
 }

lib/riscv/sbi.c struct sbiret sbi_set_timer(unsigned long stime_value) · line 118

Quoted 10 lines
lib/riscv/sbi.c +9 -0
 
+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);
+}

Going with error asserts, then we can just put the asserts in these functions and return ret.value directly, like sbi_probe() does, which means sbi_check_impl() can be dropped.

Thanks,
drew

Quoted 7 lines
lib/riscv/sbi.c +1 -0
+
 struct sbiret sbi_get_spec_version(void)
 {
 	return sbi_ecall(SBI_EXT_BASE, SBI_EXT_BASE_GET_SPEC_VERSION, 0, 0, 0, 0, 0, 0);
Signature · 1 line
2.47.2
#8 lore raw

Re: [kvm-unit-tests PATCH v10 5/8] lib: riscv: add functions to get implementer ID and version

Quoted 90 lines · Andrew Jones
Quoted 16 lines · Clément Léger

These function will be used by SSE tests to check for a specific opensbi version. sbi_impl_check() is an helper allowing to check for a specific SBI implementor without needing to check for ret.error.

---
 lib/riscv/asm/sbi.h | 30 ++++++++++++++++++++++++++++++
 lib/riscv/sbi.c     | 10 ++++++++++
 2 files changed, 40 insertions(+)
lib/riscv/asm/sbi.h +0 -0
index 197288c7..06bcec16 100644
@@ -18,6 +18,19 @@
 #define SBI_ERR_IO			-13

lib/riscv/asm/sbi.h line 28

Quoted 10 lines
lib/riscv/asm/sbi.h +8 -0
 #define SBI_ERR_DENIED_LOCKED		-14
 
+#define SBI_IMPL_BBL		0
+#define SBI_IMPL_OPENSBI	1
+#define SBI_IMPL_XVISOR		2
+#define SBI_IMPL_KVM		3
+#define SBI_IMPL_RUSTSBI	4
+#define SBI_IMPL_DIOSIX		5
+#define SBI_IMPL_COFFER		6
+#define SBI_IMPL_XEN Project	7

s/Project//

Quoted 9 lines
lib/riscv/asm/sbi.h +5 -0
+#define SBI_IMPL_POLARFIRE_HSS	8
+#define SBI_IMPL_COREBOOT	9
+#define SBI_IMPL_OREBOOT	10
+#define SBI_IMPL_BHYVE		11
+
 /* SBI spec version fields */
 #define SBI_SPEC_VERSION_DEFAULT	0x1
 #define SBI_SPEC_VERSION_MAJOR_SHIFT	24

lib/riscv/asm/sbi.h static inline unsigned long sbi_mk_version(unsigned long major, unsigned long mi · line 141

Quoted 6 lines
lib/riscv/asm/sbi.h +3 -0
@@ -123,6 +136,10 @@ static inline unsigned long sbi_mk_version(unsigned long major, unsigned long mi
 		| (minor & SBI_SPEC_VERSION_MINOR_MASK);
 }
 
+static inline unsigned long sbi_impl_opensbi_mk_version(unsigned long major, unsigned long minor)
+{
+	return ((major << 16) | (minor));

Should at least mask minor, best to mask both.

Quoted 11 lines
lib/riscv/asm/sbi.h +3 -0
+}
 
 struct sbiret sbi_ecall(int ext, int fid, unsigned long arg0,
 			unsigned long arg1, unsigned long arg2,
@@ -139,7 +156,20 @@ 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);
+struct sbiret sbi_get_imp_version(void);
+struct sbiret sbi_get_imp_id(void);
 long sbi_probe(int ext);

lib/riscv/asm/sbi.h struct sbiret sbi_send_ipi_cpumask(const cpumask_t *mask); · line 171

Quoted 10 lines
lib/riscv/asm/sbi.h +9 -0
 
+static inline bool sbi_check_impl(unsigned long impl)
+{
+	struct sbiret ret;
+
+	ret = sbi_get_imp_id();
+	if (ret.error)
+		return false;
+
+	return ret.value == impl;

Or, more tersely,

struct sbiret ret = sbi_get_imp_id();
return !ret.error && ret.value == impl;

but an assert would make more sense, since get-impl-id really shouldn't fail, unless the SBI version is 0.1, which we don't support.

Quoted 12 lines
lib/riscv/asm/sbi.h +2 -0
+}
+
 #endif /* !__ASSEMBLER__ */
 #endif /* _ASMRISCV_SBI_H_ */
lib/riscv/sbi.c +0 -0
index 3c395cff..9cb5757e 100644
@@ -107,6 +107,16 @@ 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);
 }
 
Quoted 13 lines

lib/riscv/sbi.c struct sbiret sbi_set_timer(unsigned long stime_value) · line 118

Quoted 9 lines
lib/riscv/sbi.c +9 -0
+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);
+}

Going with error asserts, then we can just put the asserts in these functions and return ret.value directly, like sbi_probe() does, which means sbi_check_impl() can be dropped.

Ack, I'll modify that.

Thanks,

Clément

Quoted 11 lines

Thanks,
drew

Quoted 7 lines
lib/riscv/sbi.c +1 -0
+
 struct sbiret sbi_get_spec_version(void)
 {
 	return sbi_ecall(SBI_EXT_BASE, SBI_EXT_BASE_GET_SPEC_VERSION, 0, 0, 0, 0, 0, 0);
Signature · 1 line
2.47.2
#9 lore raw

PATCH v10 6/8 riscv: lib: Add SBI SSE extension definitions

In reply to Clément Léger

Add SBI SSE extension definitions in sbi.h

---
 lib/riscv/asm/sbi.h | 106 +++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 105 insertions(+), 1 deletion(-)
lib/riscv/asm/sbi.h +105 -1
index 06bcec16..b8688e47 100644
@@ -49,6 +49,7 @@ enum sbi_ext_id {
 	SBI_EXT_DBCN = 0x4442434E,
 	SBI_EXT_SUSP = 0x53555350,
 	SBI_EXT_FWFT = 0x46574654,
+	SBI_EXT_SSE = 0x535345,
 };
 
 enum sbi_ext_base_fid {
@@ -97,7 +98,6 @@ enum sbi_ext_dbcn_fid {
 	SBI_EXT_DBCN_CONSOLE_WRITE_BYTE,
 };
 
-
 enum sbi_ext_fwft_fid {
 	SBI_EXT_FWFT_SET = 0,
 	SBI_EXT_FWFT_GET,
@@ -124,6 +124,110 @@ enum sbi_ext_fwft_fid {
 
 #define SBI_FWFT_SET_FLAG_LOCK			BIT(0)
 
+enum sbi_ext_sse_fid {
+	SBI_EXT_SSE_READ_ATTRS = 0,
+	SBI_EXT_SSE_WRITE_ATTRS,
+	SBI_EXT_SSE_REGISTER,
+	SBI_EXT_SSE_UNREGISTER,
+	SBI_EXT_SSE_ENABLE,
+	SBI_EXT_SSE_DISABLE,
+	SBI_EXT_SSE_COMPLETE,
+	SBI_EXT_SSE_INJECT,
+	SBI_EXT_SSE_HART_UNMASK,
+	SBI_EXT_SSE_HART_MASK,
+};
+
+/* SBI SSE Event Attributes. */
+enum sbi_sse_attr_id {
+	SBI_SSE_ATTR_STATUS		= 0x00000000,
+	SBI_SSE_ATTR_PRIORITY		= 0x00000001,
+	SBI_SSE_ATTR_CONFIG		= 0x00000002,
+	SBI_SSE_ATTR_PREFERRED_HART	= 0x00000003,
+	SBI_SSE_ATTR_ENTRY_PC		= 0x00000004,
+	SBI_SSE_ATTR_ENTRY_ARG		= 0x00000005,
+	SBI_SSE_ATTR_INTERRUPTED_SEPC	= 0x00000006,
+	SBI_SSE_ATTR_INTERRUPTED_FLAGS	= 0x00000007,
+	SBI_SSE_ATTR_INTERRUPTED_A6	= 0x00000008,
+	SBI_SSE_ATTR_INTERRUPTED_A7	= 0x00000009,
+};
+
+#define SBI_SSE_ATTR_STATUS_STATE_OFFSET	0
+#define SBI_SSE_ATTR_STATUS_STATE_MASK		0x3
+#define SBI_SSE_ATTR_STATUS_PENDING_OFFSET	2
+#define SBI_SSE_ATTR_STATUS_INJECT_OFFSET	3
+
+#define SBI_SSE_ATTR_CONFIG_ONESHOT		BIT(0)
+
+#define SBI_SSE_ATTR_INTERRUPTED_FLAGS_SSTATUS_SPP	BIT(0)
+#define SBI_SSE_ATTR_INTERRUPTED_FLAGS_SSTATUS_SPIE	BIT(1)
+#define SBI_SSE_ATTR_INTERRUPTED_FLAGS_HSTATUS_SPV	BIT(2)
+#define SBI_SSE_ATTR_INTERRUPTED_FLAGS_HSTATUS_SPVP	BIT(3)
+#define SBI_SSE_ATTR_INTERRUPTED_FLAGS_SSTATUS_SPELP	BIT(4)
+#define SBI_SSE_ATTR_INTERRUPTED_FLAGS_SSTATUS_SDT	BIT(5)
+
+enum sbi_sse_state {
+	SBI_SSE_STATE_UNUSED		= 0,
+	SBI_SSE_STATE_REGISTERED	= 1,
+	SBI_SSE_STATE_ENABLED		= 2,
+	SBI_SSE_STATE_RUNNING		= 3,
+};
+
+/* SBI SSE Event IDs. */
+/* Range 0x00000000 - 0x0000ffff */
+#define SBI_SSE_EVENT_LOCAL_HIGH_PRIO_RAS	0x00000000
+#define SBI_SSE_EVENT_LOCAL_DOUBLE_TRAP		0x00000001
+#define SBI_SSE_EVENT_LOCAL_RESERVED_0_START	0x00000002
+#define SBI_SSE_EVENT_LOCAL_RESERVED_0_END	0x00003fff
+#define SBI_SSE_EVENT_LOCAL_PLAT_0_START	0x00004000
+#define SBI_SSE_EVENT_LOCAL_PLAT_0_END		0x00007fff
+
+#define SBI_SSE_EVENT_GLOBAL_HIGH_PRIO_RAS	0x00008000
+#define SBI_SSE_EVENT_GLOBAL_RESERVED_0_START	0x00008001
+#define SBI_SSE_EVENT_GLOBAL_RESERVED_0_END	0x0000bfff
+#define SBI_SSE_EVENT_GLOBAL_PLAT_0_START	0x0000c000
+#define SBI_SSE_EVENT_GLOBAL_PLAT_0_END		0x0000ffff
+
+/* Range 0x00010000 - 0x0001ffff */
+#define SBI_SSE_EVENT_LOCAL_PMU_OVERFLOW	0x00010000
+#define SBI_SSE_EVENT_LOCAL_RESERVED_1_START	0x00010001
+#define SBI_SSE_EVENT_LOCAL_RESERVED_1_END	0x00013fff
+#define SBI_SSE_EVENT_LOCAL_PLAT_1_START	0x00014000
+#define SBI_SSE_EVENT_LOCAL_PLAT_1_END		0x00017fff
+
+#define SBI_SSE_EVENT_GLOBAL_RESERVED_1_START	0x00018000
+#define SBI_SSE_EVENT_GLOBAL_RESERVED_1_END	0x0001bfff
+#define SBI_SSE_EVENT_GLOBAL_PLAT_1_START	0x0001c000
+#define SBI_SSE_EVENT_GLOBAL_PLAT_1_END		0x0001ffff
+
+/* Range 0x00100000 - 0x0010ffff */
+#define SBI_SSE_EVENT_LOCAL_LOW_PRIO_RAS	0x00100000
+#define SBI_SSE_EVENT_LOCAL_RESERVED_2_START	0x00100001
+#define SBI_SSE_EVENT_LOCAL_RESERVED_2_END	0x00103fff
+#define SBI_SSE_EVENT_LOCAL_PLAT_2_START	0x00104000
+#define SBI_SSE_EVENT_LOCAL_PLAT_2_END		0x00107fff
+
+#define SBI_SSE_EVENT_GLOBAL_LOW_PRIO_RAS	0x00108000
+#define SBI_SSE_EVENT_GLOBAL_RESERVED_2_START	0x00108001
+#define SBI_SSE_EVENT_GLOBAL_RESERVED_2_END	0x0010bfff
+#define SBI_SSE_EVENT_GLOBAL_PLAT_2_START	0x0010c000
+#define SBI_SSE_EVENT_GLOBAL_PLAT_2_END		0x0010ffff
+
+/* Range 0xffff0000 - 0xffffffff */
+#define SBI_SSE_EVENT_LOCAL_SOFTWARE		0xffff0000
+#define SBI_SSE_EVENT_LOCAL_RESERVED_3_START	0xffff0001
+#define SBI_SSE_EVENT_LOCAL_RESERVED_3_END	0xffff3fff
+#define SBI_SSE_EVENT_LOCAL_PLAT_3_START	0xffff4000
+#define SBI_SSE_EVENT_LOCAL_PLAT_3_END		0xffff7fff
+
+#define SBI_SSE_EVENT_GLOBAL_SOFTWARE		0xffff8000
+#define SBI_SSE_EVENT_GLOBAL_RESERVED_3_START	0xffff8001
+#define SBI_SSE_EVENT_GLOBAL_RESERVED_3_END	0xffffbfff
+#define SBI_SSE_EVENT_GLOBAL_PLAT_3_START	0xffffc000
+#define SBI_SSE_EVENT_GLOBAL_PLAT_3_END		0xffffffff
+
+#define SBI_SSE_EVENT_PLATFORM_BIT		BIT(14)
+#define SBI_SSE_EVENT_GLOBAL_BIT		BIT(15)
+
 struct sbiret {
 	long error;
 	long value;
Signature · 1 line
2.47.2
#10 lore raw

PATCH v10 7/8 lib: riscv: Add SBI SSE support

In reply to Clément Léger

Add support for registering and handling SSE events. This will be used by sbi test as well as upcoming double trap tests.

---
 riscv/Makefile          |   1 +
 lib/riscv/asm/csr.h     |   1 +
 lib/riscv/asm/sbi.h     |  36 ++++++++++++++
 lib/riscv/sbi-sse-asm.S | 102 ++++++++++++++++++++++++++++++++++++++++
 lib/riscv/asm-offsets.c |   9 ++++
 lib/riscv/sbi.c         |  76 ++++++++++++++++++++++++++++++
 6 files changed, 225 insertions(+)
 create mode 100644 lib/riscv/sbi-sse-asm.S
riscv/Makefile +1 -0
index 02d2ac39..16fc125b 100644
@@ -43,6 +43,7 @@ cflatobjs += lib/riscv/setup.o
 cflatobjs += lib/riscv/smp.o
 cflatobjs += lib/riscv/stack.o
 cflatobjs += lib/riscv/timer.o
+cflatobjs += lib/riscv/sbi-sse-asm.o
 ifeq ($(ARCH),riscv32)
 cflatobjs += lib/ldiv32.o
 endif
lib/riscv/asm/csr.h +1 -0
index c7fc87a9..3e4b5fca 100644
@@ -17,6 +17,7 @@
 #define CSR_TIME		0xc01
 
 #define SR_SIE			_AC(0x00000002, UL)
+#define SR_SPP			_AC(0x00000100, UL)
 
 /* Exception cause high bit - is an interrupt if set */
 #define CAUSE_IRQ_FLAG		(_AC(1, UL) << (__riscv_xlen - 1))
lib/riscv/asm/sbi.h +36 -0
index b8688e47..ebc89c10 100644
@@ -275,5 +275,41 @@ static inline bool sbi_check_impl(unsigned long impl)
 	return ret.value == impl;
 }
 
+typedef void (*sbi_sse_handler_fn)(void *data, struct pt_regs *regs, unsigned int hartid);
+
+struct sbi_sse_handler_arg {
+	unsigned long reg_tmp;
+	sbi_sse_handler_fn handler;
+	void *handler_data;
+	void *stack;
+};
+
+extern void sbi_sse_entry(void);
+
+static inline bool sbi_sse_event_is_global(uint32_t event_id)
+{
+	return !!(event_id & SBI_SSE_EVENT_GLOBAL_BIT);
+}
+
+struct sbiret sbi_sse_read_attrs_raw(unsigned long event_id, unsigned long base_attr_id,
+				     unsigned long attr_count, unsigned long phys_lo,
+				     unsigned long phys_hi);
+struct sbiret sbi_sse_read_attrs(unsigned long event_id, unsigned long base_attr_id,
+				 unsigned long attr_count, unsigned long *values);
+struct sbiret sbi_sse_write_attrs_raw(unsigned long event_id, unsigned long base_attr_id,
+				      unsigned long attr_count, unsigned long phys_lo,
+				      unsigned long phys_hi);
+struct sbiret sbi_sse_write_attrs(unsigned long event_id, unsigned long base_attr_id,
+				  unsigned long attr_count, unsigned long *values);
+struct sbiret sbi_sse_register_raw(unsigned long event_id, unsigned long entry_pc,
+				   unsigned long entry_arg);
+struct sbiret sbi_sse_register(unsigned long event_id, struct sbi_sse_handler_arg *arg);
+struct sbiret sbi_sse_unregister(unsigned long event_id);
+struct sbiret sbi_sse_enable(unsigned long event_id);
+struct sbiret sbi_sse_disable(unsigned long event_id);
+struct sbiret sbi_sse_hart_mask(void);
+struct sbiret sbi_sse_hart_unmask(void);
+struct sbiret sbi_sse_inject(unsigned long event_id, unsigned long hart_id);
+
 #endif /* !__ASSEMBLER__ */
 #endif /* _ASMRISCV_SBI_H_ */
lib/riscv/sbi-sse-asm.S new file +102 -0

102 lines not on this page · raw message

lib/riscv/asm-offsets.c +9 -0
index 6c511c14..a96c6e97 100644
@@ -3,6 +3,7 @@
 #include <elf.h>
 #include <asm/processor.h>
 #include <asm/ptrace.h>
+#include <asm/sbi.h>
 #include <asm/smp.h>
 
 int main(void)
@@ -63,5 +64,13 @@ int main(void)
 	OFFSET(THREAD_INFO_HARTID, thread_info, hartid);
 	DEFINE(THREAD_INFO_SIZE, sizeof(struct thread_info));
 
+	DEFINE(ASM_SBI_EXT_SSE, SBI_EXT_SSE);
+	DEFINE(ASM_SBI_EXT_SSE_COMPLETE, SBI_EXT_SSE_COMPLETE);
+
+	OFFSET(SBI_SSE_REG_TMP, sbi_sse_handler_arg, reg_tmp);
+	OFFSET(SBI_SSE_HANDLER, sbi_sse_handler_arg, handler);
+	OFFSET(SBI_SSE_HANDLER_DATA, sbi_sse_handler_arg, handler_data);
+	OFFSET(SBI_SSE_HANDLER_STACK, sbi_sse_handler_arg, stack);
+
 	return 0;
 }
lib/riscv/sbi.c +76 -0

88 lines not on this page · raw message

Signature · 1 line
2.47.2
#11 lore raw

PATCH v10 8/8 riscv: sbi: Add SSE extension tests

In reply to Clément Léger

Add SBI SSE extension tests for the following features:
- Test attributes errors (invalid values, RO, etc)
- Registration errors
- Simple events (register, enable, inject)
- Events with different priorities
- Global events dispatch on different harts
- Local events on all harts
- Hart mask/unmask events

---
 riscv/Makefile    |    1 +
 riscv/sbi-tests.h |    1 +
 riscv/sbi-sse.c   | 1280 +++++++++++++++++++++++++++++++++++++++++++++
 riscv/sbi.c       |    2 +
 4 files changed, 1284 insertions(+)
 create mode 100644 riscv/sbi-sse.c
riscv/Makefile +1 -0
index 16fc125b..4fe2f1bb 100644
@@ -18,6 +18,7 @@ tests += $(TEST_DIR)/sieve.$(exe)
 all: $(tests)
 
 $(TEST_DIR)/sbi-deps = $(TEST_DIR)/sbi-asm.o $(TEST_DIR)/sbi-fwft.o
+$(TEST_DIR)/sbi-deps += $(TEST_DIR)/sbi-sse.o
 
 # When built for EFI sieve needs extra memory, run with e.g. '-m 256' on QEMU
 $(TEST_DIR)/sieve.$(exe): AUXFLAGS = 0x1
riscv/sbi-tests.h +1 -0
index b081464d..a71da809 100644
@@ -71,6 +71,7 @@
 	sbiret_report(ret, expected_error, expected_value, "check sbi.error and sbi.value")
 
 void sbi_bad_fid(int ext);
+void check_sse(void);
 
 #endif /* __ASSEMBLER__ */
 #endif /* _RISCV_SBI_TESTS_H_ */
riscv/sbi-sse.c new file +1280 -0

1,280 lines not on this page · raw message

riscv/sbi.c +2 -0
index 0404bb81..478cb35d 100644
@@ -32,6 +32,7 @@
 
 #define	HIGH_ADDR_BOUNDARY	((phys_addr_t)1 << 32)
 
+void check_sse(void);
 void check_fwft(void);
 
 static long __labs(long a)
@@ -1567,6 +1568,7 @@ int main(int argc, char **argv)
 	check_hsm();
 	check_dbcn();
 	check_susp();
+	check_sse();
 	check_fwft();
 
 	return report_summary();
Signature · 1 line
2.47.2
Reviewed-by on v10 8/8
#12 lore raw

Re: [kvm-unit-tests PATCH v10 8/8] riscv: sbi: Add SSE extension tests

Quoted 9 lines · Clément Léger

Add SBI SSE extension tests for the following features:
- Test attributes errors (invalid values, RO, etc)
- Registration errors
- Simple events (register, enable, inject)
- Events with different priorities
- Global events dispatch on different harts
- Local events on all harts
- Hart mask/unmask events

Quoted 9 lines
---
 riscv/Makefile    |    1 +
 riscv/sbi-tests.h |    1 +
 riscv/sbi-sse.c   | 1280 +++++++++++++++++++++++++++++++++++++++++++++
 riscv/sbi.c       |    2 +
 4 files changed, 1284 insertions(+)
 create mode 100644 riscv/sbi-sse.c