mbox series

[v3,0/3] Add support for Supervisor Software Events extension

Message ID 20240321155720.1966860-1-cleger@rivosinc.com
Headers show
Series Add support for Supervisor Software Events extension | expand

Message

Clément Léger March 21, 2024, 3:57 p.m. UTC
The SBI Supervisor Software Events (SSE) extensions provides a mechanism
to inject software events from an SBI implementation to supervisor
software such that it preempts all other supervisor level traps and
interrupts [1]. This series implements the V3 version of the spec.

Various events are defined and can be send asynchronously to supervisor
software (RAS, PMU, DEBUG, Asynchronous page fault) from SBI as well
as platform specific events. Events can be either local (per-hart) or
global. Events can be nested on top of each other based on priority and
can interrupt the supervisor mode at any time.

This implementation can be tested using kvm-unit-tests [2] with the
following commands:

Build kvm-unit-tests:

$ git clone https://github.com/clementleger/kvm-unit-tests.git
$ cd kvm-unit-tests
$ git switch dev/cleger/sse
$ ./configure --arch=riscv64 --cross-prefix=$CROSS_COMPILE
$ make

Run using Qemu:

$ ./qemu-system-riscv64 \
        -smp 4 \
        -M virt \
        -cpu rv64 \
        -nographic \
        -serial mon:stdio \
        -bios <opensbi>/build/platform/generic/firmware/fw_jump.bin \
        -kernel <kvm-unit-tests>/riscv/sbi_sse.flat

An implementation of a SSE "client" in linux is available [3].
This series can be found on github [5].

Link: https://lists.riscv.org/g/tech-prs/message/798 [1]
Link: https://github.com/clementleger/kvm-unit-tests/tree/dev/cleger/sse [2]
Link: https://github.com/rivosinc/linux/tree/dev/cleger/sse [3]
Link: http://lists.infradead.org/pipermail/opensbi/2024-March/006670.html [4]
Link: https://github.com/rivosinc/opensbi/tree/dev/cleger/sse_v3 [5]

---

Changes from v3:
 - Changes to follow v3 SSE specification
 - Use masks instead of struct with bitfields for status
 - Rework locking
 - SSE pending event processing is now done upon returning to previous
   mode

v2: http://lists.infradead.org/pipermail/opensbi/2024-January/006223.html

Changes from v2:
 - Move local/global event count initialization out of sse_global_init()
 - Remove PMU_IRQ_CLEAR SBI call and clear IRQ on SSE event completion
 - Change SBI_ERR_X to SBI_EXX defines
 - Add guards for invalid __riscv_xlen values
 - Update parameters passing (a6, a7)

v1: http://lists.infradead.org/pipermail/opensbi/2023-November/006015.html

Changes from v1:
 - Implemented SSE Spec v2
 - Change event state checking (Xiang W)

Clément Léger (3):
  lib: sbi: Add support for Supervisor Software Events extension
  lib: sbi: Implement SBI SSE extension
  lib: sbi: Add SSE support for PMU events

 include/sbi/sbi_ecall_interface.h |   79 +-
 include/sbi/sbi_error.h           |    2 +
 include/sbi/sbi_pmu.h             |    3 +
 include/sbi/sbi_sse.h             |   94 +++
 lib/sbi/Kconfig                   |    4 +
 lib/sbi/objects.mk                |    4 +
 lib/sbi/sbi_ecall_sse.c           |   57 ++
 lib/sbi/sbi_init.c                |   13 +
 lib/sbi/sbi_pmu.c                 |   51 ++
 lib/sbi/sbi_sse.c                 | 1131 +++++++++++++++++++++++++++++
 lib/sbi/sbi_trap.c                |   11 +
 11 files changed, 1448 insertions(+), 1 deletion(-)
 create mode 100644 include/sbi/sbi_sse.h
 create mode 100644 lib/sbi/sbi_ecall_sse.c
 create mode 100644 lib/sbi/sbi_sse.c

Comments

Anup Patel April 5, 2024, 11:46 a.m. UTC | #1
On Thu, Mar 21, 2024 at 9:27 PM Clément Léger <cleger@rivosinc.com> wrote:
>
> The SBI Supervisor Software Events (SSE) extensions provides a mechanism
> to inject software events from an SBI implementation to supervisor
> software such that it preempts all other supervisor level traps and
> interrupts [1]. This series implements the V3 version of the spec.
>
> Various events are defined and can be send asynchronously to supervisor
> software (RAS, PMU, DEBUG, Asynchronous page fault) from SBI as well
> as platform specific events. Events can be either local (per-hart) or
> global. Events can be nested on top of each other based on priority and
> can interrupt the supervisor mode at any time.
>
> This implementation can be tested using kvm-unit-tests [2] with the
> following commands:
>
> Build kvm-unit-tests:
>
> $ git clone https://github.com/clementleger/kvm-unit-tests.git
> $ cd kvm-unit-tests
> $ git switch dev/cleger/sse
> $ ./configure --arch=riscv64 --cross-prefix=$CROSS_COMPILE
> $ make
>
> Run using Qemu:
>
> $ ./qemu-system-riscv64 \
>         -smp 4 \
>         -M virt \
>         -cpu rv64 \
>         -nographic \
>         -serial mon:stdio \
>         -bios <opensbi>/build/platform/generic/firmware/fw_jump.bin \
>         -kernel <kvm-unit-tests>/riscv/sbi_sse.flat
>
> An implementation of a SSE "client" in linux is available [3].
> This series can be found on github [5].
>
> Link: https://lists.riscv.org/g/tech-prs/message/798 [1]
> Link: https://github.com/clementleger/kvm-unit-tests/tree/dev/cleger/sse [2]
> Link: https://github.com/rivosinc/linux/tree/dev/cleger/sse [3]
> Link: http://lists.infradead.org/pipermail/opensbi/2024-March/006670.html [4]
> Link: https://github.com/rivosinc/opensbi/tree/dev/cleger/sse_v3 [5]
>
> ---
>
> Changes from v3:
>  - Changes to follow v3 SSE specification
>  - Use masks instead of struct with bitfields for status
>  - Rework locking
>  - SSE pending event processing is now done upon returning to previous
>    mode
>
> v2: http://lists.infradead.org/pipermail/opensbi/2024-January/006223.html
>
> Changes from v2:
>  - Move local/global event count initialization out of sse_global_init()
>  - Remove PMU_IRQ_CLEAR SBI call and clear IRQ on SSE event completion
>  - Change SBI_ERR_X to SBI_EXX defines
>  - Add guards for invalid __riscv_xlen values
>  - Update parameters passing (a6, a7)
>
> v1: http://lists.infradead.org/pipermail/opensbi/2023-November/006015.html
>
> Changes from v1:
>  - Implemented SSE Spec v2
>  - Change event state checking (Xiang W)
>
> Clément Léger (3):
>   lib: sbi: Add support for Supervisor Software Events extension
>   lib: sbi: Implement SBI SSE extension
>   lib: sbi: Add SSE support for PMU events

Reviewed-by: Anup Patel <anup@brainfault.org>

Applied this series to the riscv/opensbi repo.

Thanks,
Anup

>
>  include/sbi/sbi_ecall_interface.h |   79 +-
>  include/sbi/sbi_error.h           |    2 +
>  include/sbi/sbi_pmu.h             |    3 +
>  include/sbi/sbi_sse.h             |   94 +++
>  lib/sbi/Kconfig                   |    4 +
>  lib/sbi/objects.mk                |    4 +
>  lib/sbi/sbi_ecall_sse.c           |   57 ++
>  lib/sbi/sbi_init.c                |   13 +
>  lib/sbi/sbi_pmu.c                 |   51 ++
>  lib/sbi/sbi_sse.c                 | 1131 +++++++++++++++++++++++++++++
>  lib/sbi/sbi_trap.c                |   11 +
>  11 files changed, 1448 insertions(+), 1 deletion(-)
>  create mode 100644 include/sbi/sbi_sse.h
>  create mode 100644 lib/sbi/sbi_ecall_sse.c
>  create mode 100644 lib/sbi/sbi_sse.c
>
> --
> 2.43.0
>
>
> --
> opensbi mailing list
> opensbi@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/opensbi
Samuel Holland April 5, 2024, 4:58 p.m. UTC | #2
Hi Anup,

On 2024-04-05 6:46 AM, Anup Patel wrote:
> On Thu, Mar 21, 2024 at 9:27 PM Clément Léger <cleger@rivosinc.com> wrote:
>>
>> The SBI Supervisor Software Events (SSE) extensions provides a mechanism
>> to inject software events from an SBI implementation to supervisor
>> software such that it preempts all other supervisor level traps and
>> interrupts [1]. This series implements the V3 version of the spec.
>>
>> Various events are defined and can be send asynchronously to supervisor
>> software (RAS, PMU, DEBUG, Asynchronous page fault) from SBI as well
>> as platform specific events. Events can be either local (per-hart) or
>> global. Events can be nested on top of each other based on priority and
>> can interrupt the supervisor mode at any time.
>>
>> This implementation can be tested using kvm-unit-tests [2] with the
>> following commands:
>>
>> Build kvm-unit-tests:
>>
>> $ git clone https://github.com/clementleger/kvm-unit-tests.git
>> $ cd kvm-unit-tests
>> $ git switch dev/cleger/sse
>> $ ./configure --arch=riscv64 --cross-prefix=$CROSS_COMPILE
>> $ make
>>
>> Run using Qemu:
>>
>> $ ./qemu-system-riscv64 \
>>         -smp 4 \
>>         -M virt \
>>         -cpu rv64 \
>>         -nographic \
>>         -serial mon:stdio \
>>         -bios <opensbi>/build/platform/generic/firmware/fw_jump.bin \
>>         -kernel <kvm-unit-tests>/riscv/sbi_sse.flat
>>
>> An implementation of a SSE "client" in linux is available [3].
>> This series can be found on github [5].
>>
>> Link: https://lists.riscv.org/g/tech-prs/message/798 [1]
>> Link: https://github.com/clementleger/kvm-unit-tests/tree/dev/cleger/sse [2]
>> Link: https://github.com/rivosinc/linux/tree/dev/cleger/sse [3]
>> Link: http://lists.infradead.org/pipermail/opensbi/2024-March/006670.html [4]
>> Link: https://github.com/rivosinc/opensbi/tree/dev/cleger/sse_v3 [5]
>>
>> ---
>>
>> Changes from v3:
>>  - Changes to follow v3 SSE specification
>>  - Use masks instead of struct with bitfields for status
>>  - Rework locking
>>  - SSE pending event processing is now done upon returning to previous
>>    mode
>>
>> v2: http://lists.infradead.org/pipermail/opensbi/2024-January/006223.html
>>
>> Changes from v2:
>>  - Move local/global event count initialization out of sse_global_init()
>>  - Remove PMU_IRQ_CLEAR SBI call and clear IRQ on SSE event completion
>>  - Change SBI_ERR_X to SBI_EXX defines
>>  - Add guards for invalid __riscv_xlen values
>>  - Update parameters passing (a6, a7)
>>
>> v1: http://lists.infradead.org/pipermail/opensbi/2023-November/006015.html
>>
>> Changes from v1:
>>  - Implemented SSE Spec v2
>>  - Change event state checking (Xiang W)
>>
>> Clément Léger (3):
>>   lib: sbi: Add support for Supervisor Software Events extension
>>   lib: sbi: Implement SBI SSE extension
>>   lib: sbi: Add SSE support for PMU events
> 
> Reviewed-by: Anup Patel <anup@brainfault.org>
> 
> Applied this series to the riscv/opensbi repo.

I don't think this series is ready to apply yet, considering that the extension
specification has not even been merged. Or is the master branch not expected to
be forward-compatible with the SBI spec?

Regards,
Samuel

> Thanks,
> Anup
> 
>>
>>  include/sbi/sbi_ecall_interface.h |   79 +-
>>  include/sbi/sbi_error.h           |    2 +
>>  include/sbi/sbi_pmu.h             |    3 +
>>  include/sbi/sbi_sse.h             |   94 +++
>>  lib/sbi/Kconfig                   |    4 +
>>  lib/sbi/objects.mk                |    4 +
>>  lib/sbi/sbi_ecall_sse.c           |   57 ++
>>  lib/sbi/sbi_init.c                |   13 +
>>  lib/sbi/sbi_pmu.c                 |   51 ++
>>  lib/sbi/sbi_sse.c                 | 1131 +++++++++++++++++++++++++++++
>>  lib/sbi/sbi_trap.c                |   11 +
>>  11 files changed, 1448 insertions(+), 1 deletion(-)
>>  create mode 100644 include/sbi/sbi_sse.h
>>  create mode 100644 lib/sbi/sbi_ecall_sse.c
>>  create mode 100644 lib/sbi/sbi_sse.c
>>
>> --
>> 2.43.0
>>
>>
>> --
>> opensbi mailing list
>> opensbi@lists.infradead.org
>> http://lists.infradead.org/mailman/listinfo/opensbi
>
Atish Kumar Patra April 5, 2024, 5 p.m. UTC | #3
On Fri, Apr 5, 2024 at 9:58 AM Samuel Holland <samuel.holland@sifive.com> wrote:
>
> Hi Anup,
>
> On 2024-04-05 6:46 AM, Anup Patel wrote:
> > On Thu, Mar 21, 2024 at 9:27 PM Clément Léger <cleger@rivosinc.com> wrote:
> >>
> >> The SBI Supervisor Software Events (SSE) extensions provides a mechanism
> >> to inject software events from an SBI implementation to supervisor
> >> software such that it preempts all other supervisor level traps and
> >> interrupts [1]. This series implements the V3 version of the spec.
> >>
> >> Various events are defined and can be send asynchronously to supervisor
> >> software (RAS, PMU, DEBUG, Asynchronous page fault) from SBI as well
> >> as platform specific events. Events can be either local (per-hart) or
> >> global. Events can be nested on top of each other based on priority and
> >> can interrupt the supervisor mode at any time.
> >>
> >> This implementation can be tested using kvm-unit-tests [2] with the
> >> following commands:
> >>
> >> Build kvm-unit-tests:
> >>
> >> $ git clone https://github.com/clementleger/kvm-unit-tests.git
> >> $ cd kvm-unit-tests
> >> $ git switch dev/cleger/sse
> >> $ ./configure --arch=riscv64 --cross-prefix=$CROSS_COMPILE
> >> $ make
> >>
> >> Run using Qemu:
> >>
> >> $ ./qemu-system-riscv64 \
> >>         -smp 4 \
> >>         -M virt \
> >>         -cpu rv64 \
> >>         -nographic \
> >>         -serial mon:stdio \
> >>         -bios <opensbi>/build/platform/generic/firmware/fw_jump.bin \
> >>         -kernel <kvm-unit-tests>/riscv/sbi_sse.flat
> >>
> >> An implementation of a SSE "client" in linux is available [3].
> >> This series can be found on github [5].
> >>
> >> Link: https://lists.riscv.org/g/tech-prs/message/798 [1]
> >> Link: https://github.com/clementleger/kvm-unit-tests/tree/dev/cleger/sse [2]
> >> Link: https://github.com/rivosinc/linux/tree/dev/cleger/sse [3]
> >> Link: http://lists.infradead.org/pipermail/opensbi/2024-March/006670.html [4]
> >> Link: https://github.com/rivosinc/opensbi/tree/dev/cleger/sse_v3 [5]
> >>
> >> ---
> >>
> >> Changes from v3:
> >>  - Changes to follow v3 SSE specification
> >>  - Use masks instead of struct with bitfields for status
> >>  - Rework locking
> >>  - SSE pending event processing is now done upon returning to previous
> >>    mode
> >>
> >> v2: http://lists.infradead.org/pipermail/opensbi/2024-January/006223.html
> >>
> >> Changes from v2:
> >>  - Move local/global event count initialization out of sse_global_init()
> >>  - Remove PMU_IRQ_CLEAR SBI call and clear IRQ on SSE event completion
> >>  - Change SBI_ERR_X to SBI_EXX defines
> >>  - Add guards for invalid __riscv_xlen values
> >>  - Update parameters passing (a6, a7)
> >>
> >> v1: http://lists.infradead.org/pipermail/opensbi/2023-November/006015.html
> >>
> >> Changes from v1:
> >>  - Implemented SSE Spec v2
> >>  - Change event state checking (Xiang W)
> >>
> >> Clément Léger (3):
> >>   lib: sbi: Add support for Supervisor Software Events extension
> >>   lib: sbi: Implement SBI SSE extension
> >>   lib: sbi: Add SSE support for PMU events
> >
> > Reviewed-by: Anup Patel <anup@brainfault.org>
> >
> > Applied this series to the riscv/opensbi repo.
>
> I don't think this series is ready to apply yet, considering that the extension
> specification has not even been merged. Or is the master branch not expected to
> be forward-compatible with the SBI spec?
>

I have merged it locally and was supposed to push it this week. I will
push the changes today.

> Regards,
> Samuel
>
> > Thanks,
> > Anup
> >
> >>
> >>  include/sbi/sbi_ecall_interface.h |   79 +-
> >>  include/sbi/sbi_error.h           |    2 +
> >>  include/sbi/sbi_pmu.h             |    3 +
> >>  include/sbi/sbi_sse.h             |   94 +++
> >>  lib/sbi/Kconfig                   |    4 +
> >>  lib/sbi/objects.mk                |    4 +
> >>  lib/sbi/sbi_ecall_sse.c           |   57 ++
> >>  lib/sbi/sbi_init.c                |   13 +
> >>  lib/sbi/sbi_pmu.c                 |   51 ++
> >>  lib/sbi/sbi_sse.c                 | 1131 +++++++++++++++++++++++++++++
> >>  lib/sbi/sbi_trap.c                |   11 +
> >>  11 files changed, 1448 insertions(+), 1 deletion(-)
> >>  create mode 100644 include/sbi/sbi_sse.h
> >>  create mode 100644 lib/sbi/sbi_ecall_sse.c
> >>  create mode 100644 lib/sbi/sbi_sse.c
> >>
> >> --
> >> 2.43.0
> >>
> >>
> >> --
> >> opensbi mailing list
> >> opensbi@lists.infradead.org
> >> http://lists.infradead.org/mailman/listinfo/opensbi
> >
>
Anup Patel April 6, 2024, 6:07 a.m. UTC | #4
On Fri, Apr 5, 2024 at 10:28 PM Samuel Holland
<samuel.holland@sifive.com> wrote:
>
> Hi Anup,
>
> On 2024-04-05 6:46 AM, Anup Patel wrote:
> > On Thu, Mar 21, 2024 at 9:27 PM Clément Léger <cleger@rivosinc.com> wrote:
> >>
> >> The SBI Supervisor Software Events (SSE) extensions provides a mechanism
> >> to inject software events from an SBI implementation to supervisor
> >> software such that it preempts all other supervisor level traps and
> >> interrupts [1]. This series implements the V3 version of the spec.
> >>
> >> Various events are defined and can be send asynchronously to supervisor
> >> software (RAS, PMU, DEBUG, Asynchronous page fault) from SBI as well
> >> as platform specific events. Events can be either local (per-hart) or
> >> global. Events can be nested on top of each other based on priority and
> >> can interrupt the supervisor mode at any time.
> >>
> >> This implementation can be tested using kvm-unit-tests [2] with the
> >> following commands:
> >>
> >> Build kvm-unit-tests:
> >>
> >> $ git clone https://github.com/clementleger/kvm-unit-tests.git
> >> $ cd kvm-unit-tests
> >> $ git switch dev/cleger/sse
> >> $ ./configure --arch=riscv64 --cross-prefix=$CROSS_COMPILE
> >> $ make
> >>
> >> Run using Qemu:
> >>
> >> $ ./qemu-system-riscv64 \
> >>         -smp 4 \
> >>         -M virt \
> >>         -cpu rv64 \
> >>         -nographic \
> >>         -serial mon:stdio \
> >>         -bios <opensbi>/build/platform/generic/firmware/fw_jump.bin \
> >>         -kernel <kvm-unit-tests>/riscv/sbi_sse.flat
> >>
> >> An implementation of a SSE "client" in linux is available [3].
> >> This series can be found on github [5].
> >>
> >> Link: https://lists.riscv.org/g/tech-prs/message/798 [1]
> >> Link: https://github.com/clementleger/kvm-unit-tests/tree/dev/cleger/sse [2]
> >> Link: https://github.com/rivosinc/linux/tree/dev/cleger/sse [3]
> >> Link: http://lists.infradead.org/pipermail/opensbi/2024-March/006670.html [4]
> >> Link: https://github.com/rivosinc/opensbi/tree/dev/cleger/sse_v3 [5]
> >>
> >> ---
> >>
> >> Changes from v3:
> >>  - Changes to follow v3 SSE specification
> >>  - Use masks instead of struct with bitfields for status
> >>  - Rework locking
> >>  - SSE pending event processing is now done upon returning to previous
> >>    mode
> >>
> >> v2: http://lists.infradead.org/pipermail/opensbi/2024-January/006223.html
> >>
> >> Changes from v2:
> >>  - Move local/global event count initialization out of sse_global_init()
> >>  - Remove PMU_IRQ_CLEAR SBI call and clear IRQ on SSE event completion
> >>  - Change SBI_ERR_X to SBI_EXX defines
> >>  - Add guards for invalid __riscv_xlen values
> >>  - Update parameters passing (a6, a7)
> >>
> >> v1: http://lists.infradead.org/pipermail/opensbi/2023-November/006015.html
> >>
> >> Changes from v1:
> >>  - Implemented SSE Spec v2
> >>  - Change event state checking (Xiang W)
> >>
> >> Clément Léger (3):
> >>   lib: sbi: Add support for Supervisor Software Events extension
> >>   lib: sbi: Implement SBI SSE extension
> >>   lib: sbi: Add SSE support for PMU events
> >
> > Reviewed-by: Anup Patel <anup@brainfault.org>
> >
> > Applied this series to the riscv/opensbi repo.
>
> I don't think this series is ready to apply yet, considering that the extension
> specification has not even been merged. Or is the master branch not expected to
> be forward-compatible with the SBI spec?

In OpenSBI, we treat SBI extensions in draft state as experimental. The
Linux kernel anyway does not accept patches for draft specifications so
keeping it experiential in OpenSBI is fine.

Further, we only increment the advertised SBI spec version in OpenSBI
after the SBI spec is frozen.

This approach has helped us make progress on other dependent work.
For example, RAS efforts in OpenSBI depend heavily on the SBI SSE
series (this series).

Regards,
Anup

>
> Regards,
> Samuel
>
> > Thanks,
> > Anup
> >
> >>
> >>  include/sbi/sbi_ecall_interface.h |   79 +-
> >>  include/sbi/sbi_error.h           |    2 +
> >>  include/sbi/sbi_pmu.h             |    3 +
> >>  include/sbi/sbi_sse.h             |   94 +++
> >>  lib/sbi/Kconfig                   |    4 +
> >>  lib/sbi/objects.mk                |    4 +
> >>  lib/sbi/sbi_ecall_sse.c           |   57 ++
> >>  lib/sbi/sbi_init.c                |   13 +
> >>  lib/sbi/sbi_pmu.c                 |   51 ++
> >>  lib/sbi/sbi_sse.c                 | 1131 +++++++++++++++++++++++++++++
> >>  lib/sbi/sbi_trap.c                |   11 +
> >>  11 files changed, 1448 insertions(+), 1 deletion(-)
> >>  create mode 100644 include/sbi/sbi_sse.h
> >>  create mode 100644 lib/sbi/sbi_ecall_sse.c
> >>  create mode 100644 lib/sbi/sbi_sse.c
> >>
> >> --
> >> 2.43.0
> >>
> >>
> >> --
> >> opensbi mailing list
> >> opensbi@lists.infradead.org
> >> http://lists.infradead.org/mailman/listinfo/opensbi
> >
>
Anup Patel April 6, 2024, 6:10 a.m. UTC | #5
On Fri, Apr 5, 2024 at 10:28 PM Samuel Holland
<samuel.holland@sifive.com> wrote:
>
> Hi Anup,
>
> On 2024-04-05 6:46 AM, Anup Patel wrote:
> > On Thu, Mar 21, 2024 at 9:27 PM Clément Léger <cleger@rivosinc.com> wrote:
> >>
> >> The SBI Supervisor Software Events (SSE) extensions provides a mechanism
> >> to inject software events from an SBI implementation to supervisor
> >> software such that it preempts all other supervisor level traps and
> >> interrupts [1]. This series implements the V3 version of the spec.
> >>
> >> Various events are defined and can be send asynchronously to supervisor
> >> software (RAS, PMU, DEBUG, Asynchronous page fault) from SBI as well
> >> as platform specific events. Events can be either local (per-hart) or
> >> global. Events can be nested on top of each other based on priority and
> >> can interrupt the supervisor mode at any time.
> >>
> >> This implementation can be tested using kvm-unit-tests [2] with the
> >> following commands:
> >>
> >> Build kvm-unit-tests:
> >>
> >> $ git clone https://github.com/clementleger/kvm-unit-tests.git
> >> $ cd kvm-unit-tests
> >> $ git switch dev/cleger/sse
> >> $ ./configure --arch=riscv64 --cross-prefix=$CROSS_COMPILE
> >> $ make
> >>
> >> Run using Qemu:
> >>
> >> $ ./qemu-system-riscv64 \
> >>         -smp 4 \
> >>         -M virt \
> >>         -cpu rv64 \
> >>         -nographic \
> >>         -serial mon:stdio \
> >>         -bios <opensbi>/build/platform/generic/firmware/fw_jump.bin \
> >>         -kernel <kvm-unit-tests>/riscv/sbi_sse.flat
> >>
> >> An implementation of a SSE "client" in linux is available [3].
> >> This series can be found on github [5].
> >>
> >> Link: https://lists.riscv.org/g/tech-prs/message/798 [1]
> >> Link: https://github.com/clementleger/kvm-unit-tests/tree/dev/cleger/sse [2]
> >> Link: https://github.com/rivosinc/linux/tree/dev/cleger/sse [3]
> >> Link: http://lists.infradead.org/pipermail/opensbi/2024-March/006670.html [4]
> >> Link: https://github.com/rivosinc/opensbi/tree/dev/cleger/sse_v3 [5]
> >>
> >> ---
> >>
> >> Changes from v3:
> >>  - Changes to follow v3 SSE specification
> >>  - Use masks instead of struct with bitfields for status
> >>  - Rework locking
> >>  - SSE pending event processing is now done upon returning to previous
> >>    mode
> >>
> >> v2: http://lists.infradead.org/pipermail/opensbi/2024-January/006223.html
> >>
> >> Changes from v2:
> >>  - Move local/global event count initialization out of sse_global_init()
> >>  - Remove PMU_IRQ_CLEAR SBI call and clear IRQ on SSE event completion
> >>  - Change SBI_ERR_X to SBI_EXX defines
> >>  - Add guards for invalid __riscv_xlen values
> >>  - Update parameters passing (a6, a7)
> >>
> >> v1: http://lists.infradead.org/pipermail/opensbi/2023-November/006015.html
> >>
> >> Changes from v1:
> >>  - Implemented SSE Spec v2
> >>  - Change event state checking (Xiang W)
> >>
> >> Clément Léger (3):
> >>   lib: sbi: Add support for Supervisor Software Events extension
> >>   lib: sbi: Implement SBI SSE extension
> >>   lib: sbi: Add SSE support for PMU events
> >
> > Reviewed-by: Anup Patel <anup@brainfault.org>
> >
> > Applied this series to the riscv/opensbi repo.
>
> I don't think this series is ready to apply yet, considering that the extension
> specification has not even been merged. Or is the master branch not expected to
> be forward-compatible with the SBI spec?

Please go ahead and send patches for your recent comments
on this series. There was no comment on this series for quite
some time and Himanshu already tested it hence it was merged.

Regards,
Anup


>
> Regards,
> Samuel
>
> > Thanks,
> > Anup
> >
> >>
> >>  include/sbi/sbi_ecall_interface.h |   79 +-
> >>  include/sbi/sbi_error.h           |    2 +
> >>  include/sbi/sbi_pmu.h             |    3 +
> >>  include/sbi/sbi_sse.h             |   94 +++
> >>  lib/sbi/Kconfig                   |    4 +
> >>  lib/sbi/objects.mk                |    4 +
> >>  lib/sbi/sbi_ecall_sse.c           |   57 ++
> >>  lib/sbi/sbi_init.c                |   13 +
> >>  lib/sbi/sbi_pmu.c                 |   51 ++
> >>  lib/sbi/sbi_sse.c                 | 1131 +++++++++++++++++++++++++++++
> >>  lib/sbi/sbi_trap.c                |   11 +
> >>  11 files changed, 1448 insertions(+), 1 deletion(-)
> >>  create mode 100644 include/sbi/sbi_sse.h
> >>  create mode 100644 lib/sbi/sbi_ecall_sse.c
> >>  create mode 100644 lib/sbi/sbi_sse.c
> >>
> >> --
> >> 2.43.0
> >>
> >>
> >> --
> >> opensbi mailing list
> >> opensbi@lists.infradead.org
> >> http://lists.infradead.org/mailman/listinfo/opensbi
> >
>
Clément Léger April 8, 2024, 2:56 p.m. UTC | #6
On 06/04/2024 08:10, Anup Patel wrote:
> On Fri, Apr 5, 2024 at 10:28 PM Samuel Holland
> <samuel.holland@sifive.com> wrote:
>>
>> Hi Anup,
>>
>> On 2024-04-05 6:46 AM, Anup Patel wrote:
>>> On Thu, Mar 21, 2024 at 9:27 PM Clément Léger <cleger@rivosinc.com> wrote:
>>>>
>>>> The SBI Supervisor Software Events (SSE) extensions provides a mechanism
>>>> to inject software events from an SBI implementation to supervisor
>>>> software such that it preempts all other supervisor level traps and
>>>> interrupts [1]. This series implements the V3 version of the spec.
>>>>
>>>> Various events are defined and can be send asynchronously to supervisor
>>>> software (RAS, PMU, DEBUG, Asynchronous page fault) from SBI as well
>>>> as platform specific events. Events can be either local (per-hart) or
>>>> global. Events can be nested on top of each other based on priority and
>>>> can interrupt the supervisor mode at any time.
>>>>
>>>> This implementation can be tested using kvm-unit-tests [2] with the
>>>> following commands:
>>>>
>>>> Build kvm-unit-tests:
>>>>
>>>> $ git clone https://github.com/clementleger/kvm-unit-tests.git
>>>> $ cd kvm-unit-tests
>>>> $ git switch dev/cleger/sse
>>>> $ ./configure --arch=riscv64 --cross-prefix=$CROSS_COMPILE
>>>> $ make
>>>>
>>>> Run using Qemu:
>>>>
>>>> $ ./qemu-system-riscv64 \
>>>>         -smp 4 \
>>>>         -M virt \
>>>>         -cpu rv64 \
>>>>         -nographic \
>>>>         -serial mon:stdio \
>>>>         -bios <opensbi>/build/platform/generic/firmware/fw_jump.bin \
>>>>         -kernel <kvm-unit-tests>/riscv/sbi_sse.flat
>>>>
>>>> An implementation of a SSE "client" in linux is available [3].
>>>> This series can be found on github [5].
>>>>
>>>> Link: https://lists.riscv.org/g/tech-prs/message/798 [1]
>>>> Link: https://github.com/clementleger/kvm-unit-tests/tree/dev/cleger/sse [2]
>>>> Link: https://github.com/rivosinc/linux/tree/dev/cleger/sse [3]
>>>> Link: http://lists.infradead.org/pipermail/opensbi/2024-March/006670.html [4]
>>>> Link: https://github.com/rivosinc/opensbi/tree/dev/cleger/sse_v3 [5]
>>>>
>>>> ---
>>>>
>>>> Changes from v3:
>>>>  - Changes to follow v3 SSE specification
>>>>  - Use masks instead of struct with bitfields for status
>>>>  - Rework locking
>>>>  - SSE pending event processing is now done upon returning to previous
>>>>    mode
>>>>
>>>> v2: http://lists.infradead.org/pipermail/opensbi/2024-January/006223.html
>>>>
>>>> Changes from v2:
>>>>  - Move local/global event count initialization out of sse_global_init()
>>>>  - Remove PMU_IRQ_CLEAR SBI call and clear IRQ on SSE event completion
>>>>  - Change SBI_ERR_X to SBI_EXX defines
>>>>  - Add guards for invalid __riscv_xlen values
>>>>  - Update parameters passing (a6, a7)
>>>>
>>>> v1: http://lists.infradead.org/pipermail/opensbi/2023-November/006015.html
>>>>
>>>> Changes from v1:
>>>>  - Implemented SSE Spec v2
>>>>  - Change event state checking (Xiang W)
>>>>
>>>> Clément Léger (3):
>>>>   lib: sbi: Add support for Supervisor Software Events extension
>>>>   lib: sbi: Implement SBI SSE extension
>>>>   lib: sbi: Add SSE support for PMU events
>>>
>>> Reviewed-by: Anup Patel <anup@brainfault.org>
>>>
>>> Applied this series to the riscv/opensbi repo.
>>
>> I don't think this series is ready to apply yet, considering that the extension
>> specification has not even been merged. Or is the master branch not expected to
>> be forward-compatible with the SBI spec?
> 
> Please go ahead and send patches for your recent comments
> on this series. There was no comment on this series for quite
> some time and Himanshu already tested it hence it was merged.
> 
> Regards,
> Anup


Hi

I'll address Samuel comments in some new commits since it was merged. I
was not expecting it to be merged without a bit more reviewing though
but I guess it will allow us to make progress faster on SSE then.

Thanks,

Clément

> 
> 
>>
>> Regards,
>> Samuel
>>
>>> Thanks,
>>> Anup
>>>
>>>>
>>>>  include/sbi/sbi_ecall_interface.h |   79 +-
>>>>  include/sbi/sbi_error.h           |    2 +
>>>>  include/sbi/sbi_pmu.h             |    3 +
>>>>  include/sbi/sbi_sse.h             |   94 +++
>>>>  lib/sbi/Kconfig                   |    4 +
>>>>  lib/sbi/objects.mk                |    4 +
>>>>  lib/sbi/sbi_ecall_sse.c           |   57 ++
>>>>  lib/sbi/sbi_init.c                |   13 +
>>>>  lib/sbi/sbi_pmu.c                 |   51 ++
>>>>  lib/sbi/sbi_sse.c                 | 1131 +++++++++++++++++++++++++++++
>>>>  lib/sbi/sbi_trap.c                |   11 +
>>>>  11 files changed, 1448 insertions(+), 1 deletion(-)
>>>>  create mode 100644 include/sbi/sbi_sse.h
>>>>  create mode 100644 lib/sbi/sbi_ecall_sse.c
>>>>  create mode 100644 lib/sbi/sbi_sse.c
>>>>
>>>> --
>>>> 2.43.0
>>>>
>>>>
>>>> --
>>>> opensbi mailing list
>>>> opensbi@lists.infradead.org
>>>> http://lists.infradead.org/mailman/listinfo/opensbi
>>>
>>