2019-09-27 00:15:57

by Atish Patra

[permalink] [raw]
Subject: [PATCH v2 0/3] Add support for SBI v0.2

The Supervisor Binary Interface(SBI) specification[1] now defines a
base extension that provides extendability to add future extensions
while maintaining backward compatibility with previous versions.
The new version is defined as 0.2 and older version is marked as 0.1.

This series adds support v0.2 and a unified calling convention
implementation between 0.1 and 0.2. It also adds minimal SBI functions
from 0.2 as well to keep the series lean.

[1] https://github.com/riscv/riscv-sbi-doc/blob/master/riscv-sbi.adoc

The SBI v0.2 support for OpenSBI is already available at

https://github.com/atishp04/opensbi/tree/sbi_v0.2_2
and in the OpenSBI mailing list.

Tested on both BBL, OpenSBI with/without the above patch series.

Changes from v1->v2
1. Removed the legacy calling convention.
2. Moved all SBI related calls to sbi.c.
3. Moved all SBI related macros to uapi.

Atish Patra (3):
RISC-V: Mark existing SBI as 0.1 SBI.
RISC-V: Add basic support for SBI v0.2
RISC-V: Move SBI related macros under uapi.

arch/riscv/include/asm/sbi.h | 109 +++++---------
arch/riscv/include/uapi/asm/sbi.h | 48 ++++++
arch/riscv/kernel/Makefile | 1 +
arch/riscv/kernel/sbi.c | 241 ++++++++++++++++++++++++++++++
arch/riscv/kernel/setup.c | 2 +
5 files changed, 328 insertions(+), 73 deletions(-)
create mode 100644 arch/riscv/include/uapi/asm/sbi.h
create mode 100644 arch/riscv/kernel/sbi.c

--
2.21.0


2019-09-27 22:21:59

by Christoph Hellwig

[permalink] [raw]
Subject: Re: [PATCH v2 0/3] Add support for SBI v0.2

On Thu, Sep 26, 2019 at 05:09:12PM -0700, Atish Patra wrote:
> The Supervisor Binary Interface(SBI) specification[1] now defines a
> base extension that provides extendability to add future extensions
> while maintaining backward compatibility with previous versions.
> The new version is defined as 0.2 and older version is marked as 0.1.
>
> This series adds support v0.2 and a unified calling convention
> implementation between 0.1 and 0.2. It also adds minimal SBI functions
> from 0.2 as well to keep the series lean.

So before we do this game can be please make sure we have a clean 0.2
environment that never uses the legacy extensions as discussed before?
Without that all this work is rather futile.

2019-09-27 22:58:35

by Atish Patra

[permalink] [raw]
Subject: Re: [PATCH v2 0/3] Add support for SBI v0.2

On Fri, 2019-09-27 at 15:19 -0700, Christoph Hellwig wrote:
> On Thu, Sep 26, 2019 at 05:09:12PM -0700, Atish Patra wrote:
> > The Supervisor Binary Interface(SBI) specification[1] now defines a
> > base extension that provides extendability to add future extensions
> > while maintaining backward compatibility with previous versions.
> > The new version is defined as 0.2 and older version is marked as
> > 0.1.
> >
> > This series adds support v0.2 and a unified calling convention
> > implementation between 0.1 and 0.2. It also adds minimal SBI
> > functions
> > from 0.2 as well to keep the series lean.
>
> So before we do this game can be please make sure we have a clean 0.2
> environment that never uses the legacy extensions as discussed
> before?
> Without that all this work is rather futile.
>

As per our discussion offline, here are things need to be done to
achieve that.

1. Replace timer, sfence and ipi with better alternative APIs
- sbi_set_timer will be same but with new calling convention
- send_ipi and sfence_* apis can be modified in such a way that
- we don't have to use unprivileged load anymore
- Make it scalable

2. Drop clear_ipi, console, and shutdown in 0.2.

We will have a new kernel config (LEGACY_SBI) that can be manually
enabled if older firmware need to be used. By default, LEGACY_SBI will
be disabled and kernel with new SBI will be built. We will have to set
a flag day in a year or so when we can remove the LEGACY_SBI
completely.

Let us know if it is not an acceptable approach to anybody.
I will post a RFC patch with new alternate v0.2 APIs sometime next
week.

> _______________________________________________
> linux-riscv mailing list
> [email protected]
> http://lists.infradead.org/mailman/listinfo/linux-riscv

--
Regards,
Atish

2019-10-01 05:01:15

by Alan Kao

[permalink] [raw]
Subject: Re: [PATCH v2 0/3] Add support for SBI v0.2

On Fri, Sep 27, 2019 at 10:57:45PM +0000, Atish Patra wrote:
> On Fri, 2019-09-27 at 15:19 -0700, Christoph Hellwig wrote:
> > On Thu, Sep 26, 2019 at 05:09:12PM -0700, Atish Patra wrote:
> > > The Supervisor Binary Interface(SBI) specification[1] now defines a
> > > base extension that provides extendability to add future extensions
> > > while maintaining backward compatibility with previous versions.
> > > The new version is defined as 0.2 and older version is marked as
> > > 0.1.
> > >
> > > This series adds support v0.2 and a unified calling convention
> > > implementation between 0.1 and 0.2. It also adds minimal SBI
> > > functions
> > > from 0.2 as well to keep the series lean.
> >
> > So before we do this game can be please make sure we have a clean 0.2
> > environment that never uses the legacy extensions as discussed
> > before?
> > Without that all this work is rather futile.
> >
>
> As per our discussion offline, here are things need to be done to
> achieve that.
>
> 1. Replace timer, sfence and ipi with better alternative APIs
> - sbi_set_timer will be same but with new calling convention
> - send_ipi and sfence_* apis can be modified in such a way that
> - we don't have to use unprivileged load anymore
> - Make it scalable
>
> 2. Drop clear_ipi, console, and shutdown in 0.2.
>
> We will have a new kernel config (LEGACY_SBI) that can be manually
> enabled if older firmware need to be used. By default, LEGACY_SBI will
> be disabled and kernel with new SBI will be built. We will have to set
> a flag day in a year or so when we can remove the LEGACY_SBI
> completely.
>
> Let us know if it is not an acceptable approach to anybody.
> I will post a RFC patch with new alternate v0.2 APIs sometime next
> week.
>

Will this legacy option be compatible will bbl? says, version 1.0.0 or
any earlier ones?

> > _______________________________________________
> > linux-riscv mailing list
> > [email protected]
> > http://lists.infradead.org/mailman/listinfo/linux-riscv
>
> --
> Regards,
> Atish

2019-10-01 07:33:13

by Atish Patra

[permalink] [raw]
Subject: Re: [PATCH v2 0/3] Add support for SBI v0.2

On Tue, 2019-10-01 at 12:58 +0800, Alan Kao wrote:
> On Fri, Sep 27, 2019 at 10:57:45PM +0000, Atish Patra wrote:
> > On Fri, 2019-09-27 at 15:19 -0700, Christoph Hellwig wrote:
> > > On Thu, Sep 26, 2019 at 05:09:12PM -0700, Atish Patra wrote:
> > > > The Supervisor Binary Interface(SBI) specification[1] now
> > > > defines a
> > > > base extension that provides extendability to add future
> > > > extensions
> > > > while maintaining backward compatibility with previous
> > > > versions.
> > > > The new version is defined as 0.2 and older version is marked
> > > > as
> > > > 0.1.
> > > >
> > > > This series adds support v0.2 and a unified calling convention
> > > > implementation between 0.1 and 0.2. It also adds minimal SBI
> > > > functions
> > > > from 0.2 as well to keep the series lean.
> > >
> > > So before we do this game can be please make sure we have a clean
> > > 0.2
> > > environment that never uses the legacy extensions as discussed
> > > before?
> > > Without that all this work is rather futile.
> > >
> >
> > As per our discussion offline, here are things need to be done to
> > achieve that.
> >
> > 1. Replace timer, sfence and ipi with better alternative APIs
> > - sbi_set_timer will be same but with new calling convention
> > - send_ipi and sfence_* apis can be modified in such a way that
> > - we don't have to use unprivileged load anymore
> > - Make it scalable
> >
> > 2. Drop clear_ipi, console, and shutdown in 0.2.
> >
> > We will have a new kernel config (LEGACY_SBI) that can be manually
> > enabled if older firmware need to be used. By default, LEGACY_SBI
> > will
> > be disabled and kernel with new SBI will be built. We will have to
> > set
> > a flag day in a year or so when we can remove the LEGACY_SBI
> > completely.
> >
> > Let us know if it is not an acceptable approach to anybody.
> > I will post a RFC patch with new alternate v0.2 APIs sometime next
> > week.
> >
>
> Will this legacy option be compatible will bbl? says, version 1.0.0
> or
> any earlier ones?
>

Yes. The config option will just need to be enabled in kernel to make
it compatible with bbl or older opensbi versions.

Eventually, we will get rid of the legacy ones sometime in future when
everybody has migrated to updated compatible version (at least a year
or so).

> > > _______________________________________________
> > > linux-riscv mailing list
> > > [email protected]
> > > http://lists.infradead.org/mailman/listinfo/linux-riscv
> >
> > --
> > Regards,
> > Atish

--
Regards,
Atish