diff mbox series

[U-Boot,06/30] riscv: add Kconfig entries for the C and A ISA extensions

Message ID 20181019220743.15020-7-lukas.auer@aisec.fraunhofer.de
State Superseded
Delegated to: Andes
Headers show
Series General fixes / cleanup for RISC-V and improvements to qemu-riscv | expand

Commit Message

Lukas Auer Oct. 19, 2018, 10:07 p.m. UTC
Add Kconfig entries for the C (compressed instructions) and A (atomic
instructions) ISA extensions. Only the C ISA extension is selectable.
This matches the configuration in Linux.

The Kconfig entries are not used yet. A follow-up patch will select the
appropriate compiler flags based on the Kconfig configuration.

Signed-off-by: Lukas Auer <lukas.auer@aisec.fraunhofer.de>
---

 arch/riscv/Kconfig | 9 +++++++++
 1 file changed, 9 insertions(+)

Comments

Bin Meng Oct. 22, 2018, 7:21 a.m. UTC | #1
Hi Lukas,

On Sat, Oct 20, 2018 at 6:09 AM Lukas Auer
<lukas.auer@aisec.fraunhofer.de> wrote:
>
> Add Kconfig entries for the C (compressed instructions) and A (atomic
> instructions) ISA extensions. Only the C ISA extension is selectable.
> This matches the configuration in Linux.
>
> The Kconfig entries are not used yet. A follow-up patch will select the
> appropriate compiler flags based on the Kconfig configuration.
>
> Signed-off-by: Lukas Auer <lukas.auer@aisec.fraunhofer.de>
> ---
>
>  arch/riscv/Kconfig | 9 +++++++++
>  1 file changed, 9 insertions(+)
>
> diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
> index b81e0d990a..e15329c35e 100644
> --- a/arch/riscv/Kconfig
> +++ b/arch/riscv/Kconfig
> @@ -38,6 +38,15 @@ config ARCH_RV64I
>
>  endchoice
>
> +config RISCV_ISA_C
> +       bool "Emit compressed instructions"
> +       default y
> +       help
> +         This enables the compressed instructions ("C") ISA extension.

This is a little bit confusing. Can we use Linux kernel's description
instead like below?

          Adds "C" to the ISA subsets that the toolchain is allowed to emit
          when building U-Boot, which results in compressed instructions in the
          U-Boot binary.

> +
> +config RISCV_ISA_A
> +       def_bool y

I do not believe U-Boot need to care about 'A' extension. So this can
be dropped?

> +
>  config 32BIT
>         bool
>

Regards,
Bin
Lukas Auer Oct. 24, 2018, 3:21 p.m. UTC | #2
Hi Bin,

On Mon, 2018-10-22 at 15:21 +0800, Bin Meng wrote:
> Hi Lukas,
> 
> On Sat, Oct 20, 2018 at 6:09 AM Lukas Auer
> <lukas.auer@aisec.fraunhofer.de> wrote:
> > 
> > Add Kconfig entries for the C (compressed instructions) and A
> > (atomic
> > instructions) ISA extensions. Only the C ISA extension is
> > selectable.
> > This matches the configuration in Linux.
> > 
> > The Kconfig entries are not used yet. A follow-up patch will select
> > the
> > appropriate compiler flags based on the Kconfig configuration.
> > 
> > Signed-off-by: Lukas Auer <lukas.auer@aisec.fraunhofer.de>
> > ---
> > 
> >  arch/riscv/Kconfig | 9 +++++++++
> >  1 file changed, 9 insertions(+)
> > 
> > diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
> > index b81e0d990a..e15329c35e 100644
> > --- a/arch/riscv/Kconfig
> > +++ b/arch/riscv/Kconfig
> > @@ -38,6 +38,15 @@ config ARCH_RV64I
> > 
> >  endchoice
> > 
> > +config RISCV_ISA_C
> > +       bool "Emit compressed instructions"
> > +       default y
> > +       help
> > +         This enables the compressed instructions ("C") ISA
> > extension.
> 
> This is a little bit confusing. Can we use Linux kernel's description
> instead like below?
> 
>           Adds "C" to the ISA subsets that the toolchain is allowed
> to emit
>           when building U-Boot, which results in compressed
> instructions in the
>           U-Boot binary.
> 

Sure, I will change it in v2.

> > +
> > +config RISCV_ISA_A
> > +       def_bool y
> 
> I do not believe U-Boot need to care about 'A' extension. So this can
> be dropped?
> 

That's right. The only reason it might be used in U-Boot is on multi-
core systems. Linux chooses the hart to boot on with the hart lottery,
which requires atomics. The first core to increment a flag wins and
starts the boot process. We could do something similar in U-Boot, but I
don't think it's necessary. In my patches (for the next patch series) I
have added CONFIG_MAIN_HART to select the hart U-Boot should run on.

I have included it here so that I can use it in the next patch to build
the ISA string. I can remove it, but that would change the current
behavior, which has atomics enabled.

Thanks,
Lukas

> > +
> >  config 32BIT
> >         bool
> > 
> 
> Regards,
> Bin
Bin Meng Oct. 24, 2018, 3:32 p.m. UTC | #3
Hi Lukas,

On Wed, Oct 24, 2018 at 11:21 PM Auer, Lukas
<lukas.auer@aisec.fraunhofer.de> wrote:
>
> Hi Bin,
>
> On Mon, 2018-10-22 at 15:21 +0800, Bin Meng wrote:
> > Hi Lukas,
> >
> > On Sat, Oct 20, 2018 at 6:09 AM Lukas Auer
> > <lukas.auer@aisec.fraunhofer.de> wrote:
> > >
> > > Add Kconfig entries for the C (compressed instructions) and A
> > > (atomic
> > > instructions) ISA extensions. Only the C ISA extension is
> > > selectable.
> > > This matches the configuration in Linux.
> > >
> > > The Kconfig entries are not used yet. A follow-up patch will select
> > > the
> > > appropriate compiler flags based on the Kconfig configuration.
> > >
> > > Signed-off-by: Lukas Auer <lukas.auer@aisec.fraunhofer.de>
> > > ---
> > >
> > >  arch/riscv/Kconfig | 9 +++++++++
> > >  1 file changed, 9 insertions(+)
> > >
> > > diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
> > > index b81e0d990a..e15329c35e 100644
> > > --- a/arch/riscv/Kconfig
> > > +++ b/arch/riscv/Kconfig
> > > @@ -38,6 +38,15 @@ config ARCH_RV64I
> > >
> > >  endchoice
> > >
> > > +config RISCV_ISA_C
> > > +       bool "Emit compressed instructions"
> > > +       default y
> > > +       help
> > > +         This enables the compressed instructions ("C") ISA
> > > extension.
> >
> > This is a little bit confusing. Can we use Linux kernel's description
> > instead like below?
> >
> >           Adds "C" to the ISA subsets that the toolchain is allowed
> > to emit
> >           when building U-Boot, which results in compressed
> > instructions in the
> >           U-Boot binary.
> >
>
> Sure, I will change it in v2.
>
> > > +
> > > +config RISCV_ISA_A
> > > +       def_bool y
> >
> > I do not believe U-Boot need to care about 'A' extension. So this can
> > be dropped?
> >
>
> That's right. The only reason it might be used in U-Boot is on multi-
> core systems. Linux chooses the hart to boot on with the hart lottery,
> which requires atomics. The first core to increment a flag wins and
> starts the boot process. We could do something similar in U-Boot, but I
> don't think it's necessary. In my patches (for the next patch series) I
> have added CONFIG_MAIN_HART to select the hart U-Boot should run on.
>

Thanks for the additional details. I think we will need
CONFIG_MAIN_HART to select the hart U-Boot should run on instead of
Linux's lottery game, since we need handle situation like SiFive
Freedom U540 where hart0 is something that does not run Linux. But
even with CONFIG_MAIN_HART, U-Boot still doesn't need support 'A',
right?

> I have included it here so that I can use it in the next patch to build
> the ISA string. I can remove it, but that would change the current
> behavior, which has atomics enabled.
>

Regards,
Bin
Lukas Auer Oct. 24, 2018, 3:41 p.m. UTC | #4
Hi Bin,

On Wed, 2018-10-24 at 23:32 +0800, Bin Meng wrote:
> Hi Lukas,
> 
> On Wed, Oct 24, 2018 at 11:21 PM Auer, Lukas
> <lukas.auer@aisec.fraunhofer.de> wrote:
> > 
> > Hi Bin,
> > 
> > On Mon, 2018-10-22 at 15:21 +0800, Bin Meng wrote:
> > > Hi Lukas,
> > > 
> > > On Sat, Oct 20, 2018 at 6:09 AM Lukas Auer
> > > <lukas.auer@aisec.fraunhofer.de> wrote:
> > > > 
> > > > Add Kconfig entries for the C (compressed instructions) and A
> > > > (atomic
> > > > instructions) ISA extensions. Only the C ISA extension is
> > > > selectable.
> > > > This matches the configuration in Linux.
> > > > 
> > > > The Kconfig entries are not used yet. A follow-up patch will
> > > > select
> > > > the
> > > > appropriate compiler flags based on the Kconfig configuration.
> > > > 
> > > > Signed-off-by: Lukas Auer <lukas.auer@aisec.fraunhofer.de>
> > > > ---
> > > > 
> > > >  arch/riscv/Kconfig | 9 +++++++++
> > > >  1 file changed, 9 insertions(+)
> > > > 
> > > > diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
> > > > index b81e0d990a..e15329c35e 100644
> > > > --- a/arch/riscv/Kconfig
> > > > +++ b/arch/riscv/Kconfig
> > > > @@ -38,6 +38,15 @@ config ARCH_RV64I
> > > > 
> > > >  endchoice
> > > > 
> > > > +config RISCV_ISA_C
> > > > +       bool "Emit compressed instructions"
> > > > +       default y
> > > > +       help
> > > > +         This enables the compressed instructions ("C") ISA
> > > > extension.
> > > 
> > > This is a little bit confusing. Can we use Linux kernel's
> > > description
> > > instead like below?
> > > 
> > >           Adds "C" to the ISA subsets that the toolchain is
> > > allowed
> > > to emit
> > >           when building U-Boot, which results in compressed
> > > instructions in the
> > >           U-Boot binary.
> > > 
> > 
> > Sure, I will change it in v2.
> > 
> > > > +
> > > > +config RISCV_ISA_A
> > > > +       def_bool y
> > > 
> > > I do not believe U-Boot need to care about 'A' extension. So this
> > > can
> > > be dropped?
> > > 
> > 
> > That's right. The only reason it might be used in U-Boot is on
> > multi-
> > core systems. Linux chooses the hart to boot on with the hart
> > lottery,
> > which requires atomics. The first core to increment a flag wins and
> > starts the boot process. We could do something similar in U-Boot,
> > but I
> > don't think it's necessary. In my patches (for the next patch
> > series) I
> > have added CONFIG_MAIN_HART to select the hart U-Boot should run
> > on.
> > 
> 
> Thanks for the additional details. I think we will need
> CONFIG_MAIN_HART to select the hart U-Boot should run on instead of
> Linux's lottery game, since we need handle situation like SiFive
> Freedom U540 where hart0 is something that does not run Linux. But
> even with CONFIG_MAIN_HART, U-Boot still doesn't need support 'A',
> right?
> 

Yes that's right, at least I can't think of a reason for why we might
need it. Should I drop it then?

Thanks,
Lukas

> > I have included it here so that I can use it in the next patch to
> > build
> > the ISA string. I can remove it, but that would change the current
> > behavior, which has atomics enabled.
> > 
> 
> Regards,
> Bin
Bin Meng Oct. 25, 2018, 2:12 a.m. UTC | #5
Hi Lukas,

On Wed, Oct 24, 2018 at 11:41 PM Auer, Lukas
<lukas.auer@aisec.fraunhofer.de> wrote:
>
> Hi Bin,
>
> On Wed, 2018-10-24 at 23:32 +0800, Bin Meng wrote:
> > Hi Lukas,
> >
> > On Wed, Oct 24, 2018 at 11:21 PM Auer, Lukas
> > <lukas.auer@aisec.fraunhofer.de> wrote:
> > >
> > > Hi Bin,
> > >
> > > On Mon, 2018-10-22 at 15:21 +0800, Bin Meng wrote:
> > > > Hi Lukas,
> > > >
> > > > On Sat, Oct 20, 2018 at 6:09 AM Lukas Auer
> > > > <lukas.auer@aisec.fraunhofer.de> wrote:
> > > > >
> > > > > Add Kconfig entries for the C (compressed instructions) and A
> > > > > (atomic
> > > > > instructions) ISA extensions. Only the C ISA extension is
> > > > > selectable.
> > > > > This matches the configuration in Linux.
> > > > >
> > > > > The Kconfig entries are not used yet. A follow-up patch will
> > > > > select
> > > > > the
> > > > > appropriate compiler flags based on the Kconfig configuration.
> > > > >
> > > > > Signed-off-by: Lukas Auer <lukas.auer@aisec.fraunhofer.de>
> > > > > ---
> > > > >
> > > > >  arch/riscv/Kconfig | 9 +++++++++
> > > > >  1 file changed, 9 insertions(+)
> > > > >
> > > > > diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
> > > > > index b81e0d990a..e15329c35e 100644
> > > > > --- a/arch/riscv/Kconfig
> > > > > +++ b/arch/riscv/Kconfig
> > > > > @@ -38,6 +38,15 @@ config ARCH_RV64I
> > > > >
> > > > >  endchoice
> > > > >
> > > > > +config RISCV_ISA_C
> > > > > +       bool "Emit compressed instructions"
> > > > > +       default y
> > > > > +       help
> > > > > +         This enables the compressed instructions ("C") ISA
> > > > > extension.
> > > >
> > > > This is a little bit confusing. Can we use Linux kernel's
> > > > description
> > > > instead like below?
> > > >
> > > >           Adds "C" to the ISA subsets that the toolchain is
> > > > allowed
> > > > to emit
> > > >           when building U-Boot, which results in compressed
> > > > instructions in the
> > > >           U-Boot binary.
> > > >
> > >
> > > Sure, I will change it in v2.
> > >
> > > > > +
> > > > > +config RISCV_ISA_A
> > > > > +       def_bool y
> > > >
> > > > I do not believe U-Boot need to care about 'A' extension. So this
> > > > can
> > > > be dropped?
> > > >
> > >
> > > That's right. The only reason it might be used in U-Boot is on
> > > multi-
> > > core systems. Linux chooses the hart to boot on with the hart
> > > lottery,
> > > which requires atomics. The first core to increment a flag wins and
> > > starts the boot process. We could do something similar in U-Boot,
> > > but I
> > > don't think it's necessary. In my patches (for the next patch
> > > series) I
> > > have added CONFIG_MAIN_HART to select the hart U-Boot should run
> > > on.
> > >
> >
> > Thanks for the additional details. I think we will need
> > CONFIG_MAIN_HART to select the hart U-Boot should run on instead of
> > Linux's lottery game, since we need handle situation like SiFive
> > Freedom U540 where hart0 is something that does not run Linux. But
> > even with CONFIG_MAIN_HART, U-Boot still doesn't need support 'A',
> > right?
> >
>
> Yes that's right, at least I can't think of a reason for why we might
> need it. Should I drop it then?
>

Since we can use such to construct the "-march" string, let's keep this.

Regards,
Bin
diff mbox series

Patch

diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index b81e0d990a..e15329c35e 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -38,6 +38,15 @@  config ARCH_RV64I
 
 endchoice
 
+config RISCV_ISA_C
+	bool "Emit compressed instructions"
+	default y
+	help
+	  This enables the compressed instructions ("C") ISA extension.
+
+config RISCV_ISA_A
+	def_bool y
+
 config 32BIT
 	bool