All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH u-boot] powerpc/mpc85xx: Pass correct cpu compiler flags
@ 2022-12-11 14:12 Pali Rohár
  2022-12-13 21:02 ` Pali Rohár
  2022-12-19 21:41 ` [PATCH v2] " Pali Rohár
  0 siblings, 2 replies; 6+ messages in thread
From: Pali Rohár @ 2022-12-11 14:12 UTC (permalink / raw
  To: Vagrant Cascadian; +Cc: u-boot

When gcc's default cpu (selected by --with-cpu= during gcc's configure
phase) does not match target u-boot board cpu then u-boot binary does not
have to be compiled correctly. Lot of distributions sets gcc's default cpu
to generic powerpc variant which works fine.

U-Boot already pass -Wa,-me500 flag to gcc which instructs GNU AS to accept
e500 specific instructions when processing assembler source files (.S).

This affects also assembly files generated by gcc from C source files. And
because gcc for generic powerpc cpu puts '.machine ppc' at the beginning of
the generated assembly file, it basically overwrites -me500 flag by which
was GNU AS invoked (from U-boot build system).

It started to be an issue since binutils 2.38 which does not keep enabled
extra functional units selected by previous cpu. Hence issuing directive
'.machine ppc' (generated by gcc for generic powerpc) after '.machine e500'
(specifying at command line) disables usage of e500 specific instructions.

And compiling arch/powerpc/cpu/mpc85xx/tlb.c code throws following
assembler errors:

    {standard input}: Assembler messages:
    {standard input}:127: Error: unrecognized opcode: `tlbre'
    {standard input}:418: Error: unrecognized opcode: `tlbre'
    {standard input}:821: Error: unrecognized opcode: `msync'
    {standard input}:821: Error: unrecognized opcode: `tlbwe'
    {standard input}:884: Error: unrecognized opcode: `tlbsx'

This issue was already hit by Debian people and is reported in bug tracker:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1003490

Calling gcc with -mcpu=8540 flag fixes this issue because -mcpu=8540 tells
gcc to compile code for e500 core/cpu (overwriting gcc's default cpu) and
does not put '.machine ppc' directive into assembly anymore.

Also if gcc is invoked with -mpcu=8540 then it pass -me500 flag to GNU AS.
So it is needed to specify -Wa,-me500 flag because it is implicitly added.

Fix this issue properly by specifying correct -mcpu compiler flag for all
supported powerpc cores in U-Boot mpc85xx platform, which are: e500v1,
e500v2, e500mc, e5500 and e6500. For specifying e500v1 and e500v2 cores,
gcc has unintuitive -mcpu=8540 flag name, for other cores -mcpu matches
core name.

Older gcc versions (up to gcc 8) had also -mcpu=8548 flag for specifying
e500v2 cores but the only difference between -mcpu=8540 and -mcpu=8548 was
HW support of double precision floating point. So it is fine to use
-mcpu=8540 for both e500v1 and e500v2 cores as u-boot does not use floating
point arithmetic.

Note that U-Boot's CONFIG_E500 option is set also for other cpus, not only
for e500v1 and e500v2. So do not check for CONFIG_E500 and rather set e500
as last fallback value when no other mpc85xx cpu matches.

Signed-off-by: Pali Rohár <pali@kernel.org>
---
 arch/powerpc/cpu/mpc85xx/config.mk | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/cpu/mpc85xx/config.mk b/arch/powerpc/cpu/mpc85xx/config.mk
index 7a1d81cf2d76..b6b5d2053aea 100644
--- a/arch/powerpc/cpu/mpc85xx/config.mk
+++ b/arch/powerpc/cpu/mpc85xx/config.mk
@@ -3,7 +3,7 @@
 # (C) Copyright 2002,2003 Motorola Inc.
 # Xianghua Xiao, X.Xiao@motorola.com
 
-PLATFORM_CPPFLAGS += -Wa,-me500 -msoft-float -mno-string
+PLATFORM_CPPFLAGS += -msoft-float -mno-string
 PLATFORM_RELFLAGS += -msingle-pic-base -fno-jump-tables
 
 # -mspe=yes is needed to have -mno-spe accepted by a buggy GCC;
@@ -11,3 +11,13 @@ PLATFORM_RELFLAGS += -msingle-pic-base -fno-jump-tables
 # http://gcc.gnu.org/ml/gcc-patches/2008-04/msg00311.html
 PLATFORM_CPPFLAGS += $(call cc-option,-mspe=yes) \
 		   $(call cc-option,-mno-spe)
+
+ifdef CONFIG_E6500
+PLATFORM_CPPFLAGS += -mcpu=e6500
+else ifdef CONFIG_E5500
+PLATFORM_CPPFLAGS += -mcpu=e5500
+else ifdef CONFIG_E500MC
+PLATFORM_CPPFLAGS += -mcpu=e500mc
+else
+PLATFORM_CPPFLAGS += -mcpu=8540
+endif
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH u-boot] powerpc/mpc85xx: Pass correct cpu compiler flags
  2022-12-11 14:12 [PATCH u-boot] powerpc/mpc85xx: Pass correct cpu compiler flags Pali Rohár
@ 2022-12-13 21:02 ` Pali Rohár
  2022-12-13 21:33   ` Tom Rini
  2022-12-19  3:12   ` Vagrant Cascadian
  2022-12-19 21:41 ` [PATCH v2] " Pali Rohár
  1 sibling, 2 replies; 6+ messages in thread
From: Pali Rohár @ 2022-12-13 21:02 UTC (permalink / raw
  To: Vagrant Cascadian, Aurelien Jarno, Tom Rini; +Cc: u-boot

Vagrant and Aurelien, could you test if this change fully fixes your
Debian issue?

Tom, do you have any opinion for this change? It should help building
with binutils 2.38.

On Sunday 11 December 2022 15:12:04 Pali Rohár wrote:
> When gcc's default cpu (selected by --with-cpu= during gcc's configure
> phase) does not match target u-boot board cpu then u-boot binary does not
> have to be compiled correctly. Lot of distributions sets gcc's default cpu
> to generic powerpc variant which works fine.
> 
> U-Boot already pass -Wa,-me500 flag to gcc which instructs GNU AS to accept
> e500 specific instructions when processing assembler source files (.S).
> 
> This affects also assembly files generated by gcc from C source files. And
> because gcc for generic powerpc cpu puts '.machine ppc' at the beginning of
> the generated assembly file, it basically overwrites -me500 flag by which
> was GNU AS invoked (from U-boot build system).
> 
> It started to be an issue since binutils 2.38 which does not keep enabled
> extra functional units selected by previous cpu. Hence issuing directive
> '.machine ppc' (generated by gcc for generic powerpc) after '.machine e500'
> (specifying at command line) disables usage of e500 specific instructions.
> 
> And compiling arch/powerpc/cpu/mpc85xx/tlb.c code throws following
> assembler errors:
> 
>     {standard input}: Assembler messages:
>     {standard input}:127: Error: unrecognized opcode: `tlbre'
>     {standard input}:418: Error: unrecognized opcode: `tlbre'
>     {standard input}:821: Error: unrecognized opcode: `msync'
>     {standard input}:821: Error: unrecognized opcode: `tlbwe'
>     {standard input}:884: Error: unrecognized opcode: `tlbsx'
> 
> This issue was already hit by Debian people and is reported in bug tracker:
> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1003490
> 
> Calling gcc with -mcpu=8540 flag fixes this issue because -mcpu=8540 tells
> gcc to compile code for e500 core/cpu (overwriting gcc's default cpu) and
> does not put '.machine ppc' directive into assembly anymore.
> 
> Also if gcc is invoked with -mpcu=8540 then it pass -me500 flag to GNU AS.
> So it is needed to specify -Wa,-me500 flag because it is implicitly added.
> 
> Fix this issue properly by specifying correct -mcpu compiler flag for all
> supported powerpc cores in U-Boot mpc85xx platform, which are: e500v1,
> e500v2, e500mc, e5500 and e6500. For specifying e500v1 and e500v2 cores,
> gcc has unintuitive -mcpu=8540 flag name, for other cores -mcpu matches
> core name.
> 
> Older gcc versions (up to gcc 8) had also -mcpu=8548 flag for specifying
> e500v2 cores but the only difference between -mcpu=8540 and -mcpu=8548 was
> HW support of double precision floating point. So it is fine to use
> -mcpu=8540 for both e500v1 and e500v2 cores as u-boot does not use floating
> point arithmetic.
> 
> Note that U-Boot's CONFIG_E500 option is set also for other cpus, not only
> for e500v1 and e500v2. So do not check for CONFIG_E500 and rather set e500
> as last fallback value when no other mpc85xx cpu matches.
> 
> Signed-off-by: Pali Rohár <pali@kernel.org>
> ---
>  arch/powerpc/cpu/mpc85xx/config.mk | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/powerpc/cpu/mpc85xx/config.mk b/arch/powerpc/cpu/mpc85xx/config.mk
> index 7a1d81cf2d76..b6b5d2053aea 100644
> --- a/arch/powerpc/cpu/mpc85xx/config.mk
> +++ b/arch/powerpc/cpu/mpc85xx/config.mk
> @@ -3,7 +3,7 @@
>  # (C) Copyright 2002,2003 Motorola Inc.
>  # Xianghua Xiao, X.Xiao@motorola.com
>  
> -PLATFORM_CPPFLAGS += -Wa,-me500 -msoft-float -mno-string
> +PLATFORM_CPPFLAGS += -msoft-float -mno-string
>  PLATFORM_RELFLAGS += -msingle-pic-base -fno-jump-tables
>  
>  # -mspe=yes is needed to have -mno-spe accepted by a buggy GCC;
> @@ -11,3 +11,13 @@ PLATFORM_RELFLAGS += -msingle-pic-base -fno-jump-tables
>  # http://gcc.gnu.org/ml/gcc-patches/2008-04/msg00311.html
>  PLATFORM_CPPFLAGS += $(call cc-option,-mspe=yes) \
>  		   $(call cc-option,-mno-spe)
> +
> +ifdef CONFIG_E6500
> +PLATFORM_CPPFLAGS += -mcpu=e6500
> +else ifdef CONFIG_E5500
> +PLATFORM_CPPFLAGS += -mcpu=e5500
> +else ifdef CONFIG_E500MC
> +PLATFORM_CPPFLAGS += -mcpu=e500mc
> +else
> +PLATFORM_CPPFLAGS += -mcpu=8540
> +endif
> -- 
> 2.20.1
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH u-boot] powerpc/mpc85xx: Pass correct cpu compiler flags
  2022-12-13 21:02 ` Pali Rohár
@ 2022-12-13 21:33   ` Tom Rini
  2022-12-19  3:12   ` Vagrant Cascadian
  1 sibling, 0 replies; 6+ messages in thread
From: Tom Rini @ 2022-12-13 21:33 UTC (permalink / raw
  To: Pali Rohár; +Cc: Vagrant Cascadian, Aurelien Jarno, u-boot

[-- Attachment #1: Type: text/plain, Size: 4740 bytes --]

On Tue, Dec 13, 2022 at 10:02:38PM +0100, Pali Rohár wrote:
> Vagrant and Aurelien, could you test if this change fully fixes your
> Debian issue?
> 
> Tom, do you have any opinion for this change? It should help building
> with binutils 2.38.

I have both of your toolchain flag patches in my queue to not forget for
v2023.01.

> 
> On Sunday 11 December 2022 15:12:04 Pali Rohár wrote:
> > When gcc's default cpu (selected by --with-cpu= during gcc's configure
> > phase) does not match target u-boot board cpu then u-boot binary does not
> > have to be compiled correctly. Lot of distributions sets gcc's default cpu
> > to generic powerpc variant which works fine.
> > 
> > U-Boot already pass -Wa,-me500 flag to gcc which instructs GNU AS to accept
> > e500 specific instructions when processing assembler source files (.S).
> > 
> > This affects also assembly files generated by gcc from C source files. And
> > because gcc for generic powerpc cpu puts '.machine ppc' at the beginning of
> > the generated assembly file, it basically overwrites -me500 flag by which
> > was GNU AS invoked (from U-boot build system).
> > 
> > It started to be an issue since binutils 2.38 which does not keep enabled
> > extra functional units selected by previous cpu. Hence issuing directive
> > '.machine ppc' (generated by gcc for generic powerpc) after '.machine e500'
> > (specifying at command line) disables usage of e500 specific instructions.
> > 
> > And compiling arch/powerpc/cpu/mpc85xx/tlb.c code throws following
> > assembler errors:
> > 
> >     {standard input}: Assembler messages:
> >     {standard input}:127: Error: unrecognized opcode: `tlbre'
> >     {standard input}:418: Error: unrecognized opcode: `tlbre'
> >     {standard input}:821: Error: unrecognized opcode: `msync'
> >     {standard input}:821: Error: unrecognized opcode: `tlbwe'
> >     {standard input}:884: Error: unrecognized opcode: `tlbsx'
> > 
> > This issue was already hit by Debian people and is reported in bug tracker:
> > https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1003490
> > 
> > Calling gcc with -mcpu=8540 flag fixes this issue because -mcpu=8540 tells
> > gcc to compile code for e500 core/cpu (overwriting gcc's default cpu) and
> > does not put '.machine ppc' directive into assembly anymore.
> > 
> > Also if gcc is invoked with -mpcu=8540 then it pass -me500 flag to GNU AS.
> > So it is needed to specify -Wa,-me500 flag because it is implicitly added.
> > 
> > Fix this issue properly by specifying correct -mcpu compiler flag for all
> > supported powerpc cores in U-Boot mpc85xx platform, which are: e500v1,
> > e500v2, e500mc, e5500 and e6500. For specifying e500v1 and e500v2 cores,
> > gcc has unintuitive -mcpu=8540 flag name, for other cores -mcpu matches
> > core name.
> > 
> > Older gcc versions (up to gcc 8) had also -mcpu=8548 flag for specifying
> > e500v2 cores but the only difference between -mcpu=8540 and -mcpu=8548 was
> > HW support of double precision floating point. So it is fine to use
> > -mcpu=8540 for both e500v1 and e500v2 cores as u-boot does not use floating
> > point arithmetic.
> > 
> > Note that U-Boot's CONFIG_E500 option is set also for other cpus, not only
> > for e500v1 and e500v2. So do not check for CONFIG_E500 and rather set e500
> > as last fallback value when no other mpc85xx cpu matches.
> > 
> > Signed-off-by: Pali Rohár <pali@kernel.org>
> > ---
> >  arch/powerpc/cpu/mpc85xx/config.mk | 12 +++++++++++-
> >  1 file changed, 11 insertions(+), 1 deletion(-)
> > 
> > diff --git a/arch/powerpc/cpu/mpc85xx/config.mk b/arch/powerpc/cpu/mpc85xx/config.mk
> > index 7a1d81cf2d76..b6b5d2053aea 100644
> > --- a/arch/powerpc/cpu/mpc85xx/config.mk
> > +++ b/arch/powerpc/cpu/mpc85xx/config.mk
> > @@ -3,7 +3,7 @@
> >  # (C) Copyright 2002,2003 Motorola Inc.
> >  # Xianghua Xiao, X.Xiao@motorola.com
> >  
> > -PLATFORM_CPPFLAGS += -Wa,-me500 -msoft-float -mno-string
> > +PLATFORM_CPPFLAGS += -msoft-float -mno-string
> >  PLATFORM_RELFLAGS += -msingle-pic-base -fno-jump-tables
> >  
> >  # -mspe=yes is needed to have -mno-spe accepted by a buggy GCC;
> > @@ -11,3 +11,13 @@ PLATFORM_RELFLAGS += -msingle-pic-base -fno-jump-tables
> >  # http://gcc.gnu.org/ml/gcc-patches/2008-04/msg00311.html
> >  PLATFORM_CPPFLAGS += $(call cc-option,-mspe=yes) \
> >  		   $(call cc-option,-mno-spe)
> > +
> > +ifdef CONFIG_E6500
> > +PLATFORM_CPPFLAGS += -mcpu=e6500
> > +else ifdef CONFIG_E5500
> > +PLATFORM_CPPFLAGS += -mcpu=e5500
> > +else ifdef CONFIG_E500MC
> > +PLATFORM_CPPFLAGS += -mcpu=e500mc
> > +else
> > +PLATFORM_CPPFLAGS += -mcpu=8540
> > +endif
> > -- 
> > 2.20.1
> > 

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH u-boot] powerpc/mpc85xx: Pass correct cpu compiler flags
  2022-12-13 21:02 ` Pali Rohár
  2022-12-13 21:33   ` Tom Rini
@ 2022-12-19  3:12   ` Vagrant Cascadian
  1 sibling, 0 replies; 6+ messages in thread
From: Vagrant Cascadian @ 2022-12-19  3:12 UTC (permalink / raw
  To: Pali Rohár, Aurelien Jarno, Tom Rini; +Cc: u-boot

[-- Attachment #1: Type: text/plain, Size: 582 bytes --]

On 2022-12-13, Pali Rohár wrote:
> Vagrant and Aurelien, could you test if this change fully fixes your
> Debian issue?

Well, apparently the issue has been fixed some other way, as u-boot
2022.03-rc3 builds the qemu-ppce500 target fine in Debian with binutils
2.39.50.20221208-5 even without the old patch applied...

... that said, it also builds with this proposed patch applied, so if it
is more correct, that seems ok to me too.

I haven't tested the resulting u-boot binaries, just that they build
successfully.

Hope that is helpful!

live well,
  vagrant

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 227 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2] powerpc/mpc85xx: Pass correct cpu compiler flags
  2022-12-11 14:12 [PATCH u-boot] powerpc/mpc85xx: Pass correct cpu compiler flags Pali Rohár
  2022-12-13 21:02 ` Pali Rohár
@ 2022-12-19 21:41 ` Pali Rohár
  2022-12-23 15:01   ` Tom Rini
  1 sibling, 1 reply; 6+ messages in thread
From: Pali Rohár @ 2022-12-19 21:41 UTC (permalink / raw
  To: Tom Rini; +Cc: u-boot

When gcc's default cpu (selected by --with-cpu= during gcc's configure
phase) does not match target U-Boot board cpu then U-Boot binary does not
have to be compiled correctly. Lot of distributions sets gcc's default cpu
to generic powerpc variant which works fine.

U-Boot already pass -Wa,-me500 flag to gcc which instructs GNU AS to accept
e500 specific instructions when processing assembler source files (.S).

This affects also assembly files generated by gcc from C source files. And
because gcc for generic powerpc cpu puts '.machine ppc' at the beginning of
the generated assembly file, it basically overwrites -me500 flag by which
was GNU AS invoked (from U-boot build system).

It started to be an issue since binutils 2.38 which does not keep enabled
extra functional units selected by previous cpu. Hence issuing directive
'.machine ppc' (generated by gcc for generic powerpc) after '.machine e500'
(specifying at command line) disables usage of e500 specific instructions.

And compiling arch/powerpc/cpu/mpc85xx/tlb.c code throws following
assembler errors:

    {standard input}: Assembler messages:
    {standard input}:127: Error: unrecognized opcode: `tlbre'
    {standard input}:418: Error: unrecognized opcode: `tlbre'
    {standard input}:821: Error: unrecognized opcode: `msync'
    {standard input}:821: Error: unrecognized opcode: `tlbwe'
    {standard input}:884: Error: unrecognized opcode: `tlbsx'

This issue was already hit by Debian people and is reported in bug tracker:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1003490

Calling gcc with -mcpu=8540 flag fixes this issue because -mcpu=8540 tells
gcc to compile code for e500 core/cpu (overwriting gcc's default cpu) and
does not put '.machine ppc' directive into assembly anymore.

Also if gcc is invoked with -mcpu=8540 then it pass -me500 flag to GNU AS.
So it is unnecessary to manually specify -Wa,-me500 flag because it is
implicitly added.

Fix this issue properly by specifying correct -mcpu compiler flag for all
supported powerpc cores in U-Boot mpc85xx platform, which are: e500v1,
e500v2, e500mc, e5500 and e6500. For specifying e500v1 and e500v2 cores,
gcc has unintuitive -mcpu=8540 and -mcpu=8548 flag names, for other cores
-mcpu matches core name.

The only difference between gcc's -mcpu=8540 and -mcpu=8548 flags is
support for double precision floating point SPE instructions. As U-Boot
does not use floating point, it is fine to use -mcpu=8540 for both e500v1
and e500v2 cores. Moreover gcc 9 completely removed e500 floating point
support, so since gcc 9 -mcpu=8548 is just alias to -mcpu=8540.

Note that U-Boot's CONFIG_E500 option is set also for other cpus, not only
for e500v1 and e500v2. So do not check for CONFIG_E500 and rather set e500
as last fallback value when no other mpc85xx cpu matches.

Signed-off-by: Pali Rohár <pali@kernel.org>

---
Changes in v2:
* Fix commit message and fact that -mcpu=8548 flag works also with last gcc
---
 arch/powerpc/cpu/mpc85xx/config.mk | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/cpu/mpc85xx/config.mk b/arch/powerpc/cpu/mpc85xx/config.mk
index 7a1d81cf2d76..b6b5d2053aea 100644
--- a/arch/powerpc/cpu/mpc85xx/config.mk
+++ b/arch/powerpc/cpu/mpc85xx/config.mk
@@ -3,7 +3,7 @@
 # (C) Copyright 2002,2003 Motorola Inc.
 # Xianghua Xiao, X.Xiao@motorola.com
 
-PLATFORM_CPPFLAGS += -Wa,-me500 -msoft-float -mno-string
+PLATFORM_CPPFLAGS += -msoft-float -mno-string
 PLATFORM_RELFLAGS += -msingle-pic-base -fno-jump-tables
 
 # -mspe=yes is needed to have -mno-spe accepted by a buggy GCC;
@@ -11,3 +11,13 @@ PLATFORM_RELFLAGS += -msingle-pic-base -fno-jump-tables
 # http://gcc.gnu.org/ml/gcc-patches/2008-04/msg00311.html
 PLATFORM_CPPFLAGS += $(call cc-option,-mspe=yes) \
 		   $(call cc-option,-mno-spe)
+
+ifdef CONFIG_E6500
+PLATFORM_CPPFLAGS += -mcpu=e6500
+else ifdef CONFIG_E5500
+PLATFORM_CPPFLAGS += -mcpu=e5500
+else ifdef CONFIG_E500MC
+PLATFORM_CPPFLAGS += -mcpu=e500mc
+else
+PLATFORM_CPPFLAGS += -mcpu=8540
+endif
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] powerpc/mpc85xx: Pass correct cpu compiler flags
  2022-12-19 21:41 ` [PATCH v2] " Pali Rohár
@ 2022-12-23 15:01   ` Tom Rini
  0 siblings, 0 replies; 6+ messages in thread
From: Tom Rini @ 2022-12-23 15:01 UTC (permalink / raw
  To: Pali Rohár; +Cc: u-boot

[-- Attachment #1: Type: text/plain, Size: 3140 bytes --]

On Mon, Dec 19, 2022 at 10:41:52PM +0100, Pali Rohár wrote:

> When gcc's default cpu (selected by --with-cpu= during gcc's configure
> phase) does not match target U-Boot board cpu then U-Boot binary does not
> have to be compiled correctly. Lot of distributions sets gcc's default cpu
> to generic powerpc variant which works fine.
> 
> U-Boot already pass -Wa,-me500 flag to gcc which instructs GNU AS to accept
> e500 specific instructions when processing assembler source files (.S).
> 
> This affects also assembly files generated by gcc from C source files. And
> because gcc for generic powerpc cpu puts '.machine ppc' at the beginning of
> the generated assembly file, it basically overwrites -me500 flag by which
> was GNU AS invoked (from U-boot build system).
> 
> It started to be an issue since binutils 2.38 which does not keep enabled
> extra functional units selected by previous cpu. Hence issuing directive
> '.machine ppc' (generated by gcc for generic powerpc) after '.machine e500'
> (specifying at command line) disables usage of e500 specific instructions.
> 
> And compiling arch/powerpc/cpu/mpc85xx/tlb.c code throws following
> assembler errors:
> 
>     {standard input}: Assembler messages:
>     {standard input}:127: Error: unrecognized opcode: `tlbre'
>     {standard input}:418: Error: unrecognized opcode: `tlbre'
>     {standard input}:821: Error: unrecognized opcode: `msync'
>     {standard input}:821: Error: unrecognized opcode: `tlbwe'
>     {standard input}:884: Error: unrecognized opcode: `tlbsx'
> 
> This issue was already hit by Debian people and is reported in bug tracker:
> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1003490
> 
> Calling gcc with -mcpu=8540 flag fixes this issue because -mcpu=8540 tells
> gcc to compile code for e500 core/cpu (overwriting gcc's default cpu) and
> does not put '.machine ppc' directive into assembly anymore.
> 
> Also if gcc is invoked with -mcpu=8540 then it pass -me500 flag to GNU AS.
> So it is unnecessary to manually specify -Wa,-me500 flag because it is
> implicitly added.
> 
> Fix this issue properly by specifying correct -mcpu compiler flag for all
> supported powerpc cores in U-Boot mpc85xx platform, which are: e500v1,
> e500v2, e500mc, e5500 and e6500. For specifying e500v1 and e500v2 cores,
> gcc has unintuitive -mcpu=8540 and -mcpu=8548 flag names, for other cores
> -mcpu matches core name.
> 
> The only difference between gcc's -mcpu=8540 and -mcpu=8548 flags is
> support for double precision floating point SPE instructions. As U-Boot
> does not use floating point, it is fine to use -mcpu=8540 for both e500v1
> and e500v2 cores. Moreover gcc 9 completely removed e500 floating point
> support, so since gcc 9 -mcpu=8548 is just alias to -mcpu=8540.
> 
> Note that U-Boot's CONFIG_E500 option is set also for other cpus, not only
> for e500v1 and e500v2. So do not check for CONFIG_E500 and rather set e500
> as last fallback value when no other mpc85xx cpu matches.
> 
> Signed-off-by: Pali Rohár <pali@kernel.org>

Applied to u-boot/master, thanks!

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-12-23 15:02 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-11 14:12 [PATCH u-boot] powerpc/mpc85xx: Pass correct cpu compiler flags Pali Rohár
2022-12-13 21:02 ` Pali Rohár
2022-12-13 21:33   ` Tom Rini
2022-12-19  3:12   ` Vagrant Cascadian
2022-12-19 21:41 ` [PATCH v2] " Pali Rohár
2022-12-23 15:01   ` Tom Rini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.