mbox series

[kvm-unit-tests,v9,0/6] riscv: add SBI SSE extension tests

Message ID 20250314111030.3728671-1-cleger@rivosinc.com (mailing list archive)
Headers show
Series riscv: add SBI SSE extension tests | expand

Message

Clément Léger March 14, 2025, 11:10 a.m. UTC
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.

---

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 (6):
  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: 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     |  142 ++++-
 lib/riscv/sbi-sse-asm.S |  102 ++++
 lib/riscv/asm-offsets.c |    9 +
 lib/riscv/sbi.c         |   76 +++
 riscv/sbi-tests.h       |    1 +
 riscv/sbi-asm.S         |    6 +-
 riscv/sbi-asm-offsets.c |   11 +
 riscv/sbi-sse.c         | 1263 +++++++++++++++++++++++++++++++++++++++
 riscv/sbi.c             |    2 +
 riscv/.gitignore        |    1 +
 13 files changed, 1630 insertions(+), 11 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

Comments

Andrew Jones March 14, 2025, 2:19 p.m. UTC | #1
On Fri, Mar 14, 2025 at 12:10:23PM +0100, Clément Léger wrote:
> 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.

Is there an opensbi branch I should be using to test this? There are
currently 54 failures reported with opensbi's master branch, and, with
opensbi v1.5.1, which is the version provided by qemu's master branch,
I get a crash which leads to a recursive stack walk. The crash occurs
in what I'm guessing is sbi_sse_inject() by the last successful output.

I can't merge this without it skipping/kfailing with qemu's opensbi,
otherwise it'll fail CI. We could change CI to be more tolerant, but I'd
rather use kfail instead, and of course not crash.

Thanks,
drew
Clément Léger March 14, 2025, 2:23 p.m. UTC | #2
On 14/03/2025 15:19, Andrew Jones wrote:
> On Fri, Mar 14, 2025 at 12:10:23PM +0100, Clément Léger wrote:
>> 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.
> 
> Is there an opensbi branch I should be using to test this? There are
> currently 54 failures reported with opensbi's master branch, and, with
> opensbi v1.5.1, which is the version provided by qemu's master branch,
> I get a crash which leads to a recursive stack walk. The crash occurs
> in what I'm guessing is sbi_sse_inject() by the last successful output.

Yeah that's due to a6/a7 being inverted at injection time.

> 
> I can't merge this without it skipping/kfailing with qemu's opensbi,
> otherwise it'll fail CI. We could change CI to be more tolerant, but I'd
> rather use kfail instead, and of course not crash.

Yes, the branch dev/cleger/sse on github can be used:

https://github.com/rivosinc/opensbi/tree/dev/cleger/sse

I'm waiting for the specification error changes to be merged before
sending this one.

Thanks,

Clément

> 
> Thanks,
> drew
Andrew Jones March 14, 2025, 2:34 p.m. UTC | #3
On Fri, Mar 14, 2025 at 03:23:39PM +0100, Clément Léger wrote:
> 
> 
> On 14/03/2025 15:19, Andrew Jones wrote:
> > On Fri, Mar 14, 2025 at 12:10:23PM +0100, Clément Léger wrote:
> >> 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.
> > 
> > Is there an opensbi branch I should be using to test this? There are
> > currently 54 failures reported with opensbi's master branch, and, with
> > opensbi v1.5.1, which is the version provided by qemu's master branch,
> > I get a crash which leads to a recursive stack walk. The crash occurs
> > in what I'm guessing is sbi_sse_inject() by the last successful output.
> 
> Yeah that's due to a6/a7 being inverted at injection time.
> 
> > 
> > I can't merge this without it skipping/kfailing with qemu's opensbi,
> > otherwise it'll fail CI. We could change CI to be more tolerant, but I'd
> > rather use kfail instead, and of course not crash.
> 
> Yes, the branch dev/cleger/sse on github can be used:
> 
> https://github.com/rivosinc/opensbi/tree/dev/cleger/sse
> 
> I'm waiting for the specification error changes to be merged before
> sending this one.

While ugly, I'm not opposed to doing an SBI implementation ID and
version check at the entry of the SSE tests and then just SKIP
when we detect opensbi and not a late enough version of it. If we
go that route, then please create a separate patch that adds a
couple functions in lib/riscv/sbi allowing all sbi unit tests to
easily check for specific SBI implementations and versions. (We'll
probably want to steal the kernel's sbi_mk_version and add an enum
or defines for the SBI implementation IDs.)

Thanks,
drew
Clément Léger March 14, 2025, 2:40 p.m. UTC | #4
On 14/03/2025 15:34, Andrew Jones wrote:
> On Fri, Mar 14, 2025 at 03:23:39PM +0100, Clément Léger wrote:
>>
>>
>> On 14/03/2025 15:19, Andrew Jones wrote:
>>> On Fri, Mar 14, 2025 at 12:10:23PM +0100, Clément Léger wrote:
>>>> 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.
>>>
>>> Is there an opensbi branch I should be using to test this? There are
>>> currently 54 failures reported with opensbi's master branch, and, with
>>> opensbi v1.5.1, which is the version provided by qemu's master branch,
>>> I get a crash which leads to a recursive stack walk. The crash occurs
>>> in what I'm guessing is sbi_sse_inject() by the last successful output.
>>
>> Yeah that's due to a6/a7 being inverted at injection time.
>>
>>>
>>> I can't merge this without it skipping/kfailing with qemu's opensbi,
>>> otherwise it'll fail CI. We could change CI to be more tolerant, but I'd
>>> rather use kfail instead, and of course not crash.
>>
>> Yes, the branch dev/cleger/sse on github can be used:
>>
>> https://github.com/rivosinc/opensbi/tree/dev/cleger/sse
>>
>> I'm waiting for the specification error changes to be merged before
>> sending this one.
> 
> While ugly, I'm not opposed to doing an SBI implementation ID and
> version check at the entry of the SSE tests and then just SKIP
> when we detect opensbi and not a late enough version of it. If we
> go that route, then please create a separate patch that adds a
> couple functions in lib/riscv/sbi allowing all sbi unit tests to
> easily check for specific SBI implementations and versions. (We'll
> probably want to steal the kernel's sbi_mk_version and add an enum
> or defines for the SBI implementation IDs.)

Based on the fact that it actually crashes on earlier OpenSBI version, I
feel like we are not going to cut it if we want it to be reliable on all
OpenSBI versions. I'll take a look at what you propose.

Thanks,

Clément

> 
> Thanks,
> drew