From: Christophe Leroy <christophe.leroy@csgroup.eu>
To: Joel Stanley <joel@jms.id.au>,
"linuxppc-dev@lists.ozlabs.org" <linuxppc-dev@lists.ozlabs.org>
Subject: Re: [PATCH] powerpc/boot: Build wrapper for an appropriate CPU
Date: Wed, 30 Mar 2022 11:33:29 +0000 [thread overview]
Message-ID: <e0776e34-7efa-f42c-c194-1fc3fc5cf445@csgroup.eu> (raw)
In-Reply-To: <20220330112437.540214-1-joel@jms.id.au>
Le 30/03/2022 à 13:24, Joel Stanley a écrit :
> Currently the boot wrapper lacks a -mcpu option, so it will be built for
> the toolchain's default cpu. This is a problem if the toolchain defaults
> to a cpu with newer instructions.
>
> We could wire in TARGET_CPU but instead use the oldest supported option
> so the wrapper runs anywhere.
>
> The GCC documentation stays that -mcpu=powerpc64le will give us a
> generic 64 bit powerpc machine:
>
> -mcpu=powerpc, -mcpu=powerpc64, and -mcpu=powerpc64le specify pure
> 32-bit PowerPC (either endian), 64-bit big endian PowerPC and 64-bit
> little endian PowerPC architecture machine types, with an appropriate,
> generic processor model assumed for scheduling purposes.
>
> So do that for each of the three machines.
>
> This bug was found when building the kernel with a toolchain that
> defaulted to powre10, resulting in a pcrel enabled wrapper which fails
> to link:
>
> arch/powerpc/boot/wrapper.a(crt0.o): in function `p_base':
> (.text+0x150): call to `platform_init' lacks nop, can't restore toc; (toc save/adjust stub)
> (.text+0x154): call to `start' lacks nop, can't restore toc; (toc save/adjust stub)
> powerpc64le-buildroot-linux-gnu-ld: final link failed: bad value
>
> Even with tha bug worked around the resulting kernel would crash on a
> power9 box:
>
> $ qemu-system-ppc64 -nographic -nodefaults -M powernv9 -kernel arch/powerpc/boot/zImage.epapr -serial mon:stdio
> [ 7.069331356,5] INIT: Starting kernel at 0x20010020, fdt at 0x3068c628 25694 bytes
> [ 7.130374661,3] ***********************************************
> [ 7.131072886,3] Fatal Exception 0xe40 at 00000000200101e4 MSR 9000000000000001
> [ 7.131290613,3] CFAR : 000000002001027c MSR : 9000000000000001
> [ 7.131433759,3] SRR0 : 0000000020010050 SRR1 : 9000000000000001
> [ 7.131577775,3] HSRR0: 00000000200101e4 HSRR1: 9000000000000001
> [ 7.131733687,3] DSISR: 00000000 DAR : 0000000000000000
> [ 7.131905162,3] LR : 0000000020010280 CTR : 0000000000000000
> [ 7.132068356,3] CR : 44002004 XER : 00000000
>
> Link: https://github.com/linuxppc/issues/issues/400
> Signed-off-by: Joel Stanley <joel@jms.id.au>
> ---
> Tested:
>
> - ppc64le_defconfig
> - pseries and powernv qemu, for power8, power9, power10 cpus
> - buildroot compiler that defaults to -mcpu=power10 (gcc 10.3.0, ld 2.36.1)
> - RHEL9 cross compilers (gcc 11.2.1-1, ld 2.35.2-17.el9)
>
> All decompressed and made it into the kernel ok.
>
> ppc64_defconfig did not work, as we've got a regression when the wrapper
> is built for big endian. It hasn't worked for zImage.pseries for a long
> time (at least v4.14), and broke some time between v5.4 and v5.17 for
> zImage.epapr.
>
> arch/powerpc/boot/Makefile | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
> index 9993c6256ad2..1f5cc401bfc0 100644
> --- a/arch/powerpc/boot/Makefile
> +++ b/arch/powerpc/boot/Makefile
> @@ -38,9 +38,13 @@ BOOTCFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
> $(LINUXINCLUDE)
>
> ifdef CONFIG_PPC64_BOOT_WRAPPER
> -BOOTCFLAGS += -m64
> +ifdef CONFIG_CPU_LITTLE_ENDIAN
> +BOOTCFLAGS += -m64 -mcpu=powerpc64le
> else
> -BOOTCFLAGS += -m32
> +BOOTCFLAGS += -m64 -mcpu=powerpc64
> +endif
> +else
> +BOOTCFLAGS += -m32 -mcpu=powerpc
How does that interracts with the following lines ? Isn't it an issue to
have two -mcpu ?
arch/powerpc/boot/Makefile:$(obj)/4xx.o: BOOTCFLAGS += -mcpu=405
arch/powerpc/boot/Makefile:$(obj)/ebony.o: BOOTCFLAGS += -mcpu=440
arch/powerpc/boot/Makefile:$(obj)/cuboot-hotfoot.o: BOOTCFLAGS += -mcpu=405
arch/powerpc/boot/Makefile:$(obj)/cuboot-taishan.o: BOOTCFLAGS += -mcpu=440
arch/powerpc/boot/Makefile:$(obj)/cuboot-katmai.o: BOOTCFLAGS += -mcpu=440
arch/powerpc/boot/Makefile:$(obj)/cuboot-acadia.o: BOOTCFLAGS += -mcpu=405
arch/powerpc/boot/Makefile:$(obj)/treeboot-iss4xx.o: BOOTCFLAGS += -mcpu=405
arch/powerpc/boot/Makefile:$(obj)/treeboot-currituck.o: BOOTCFLAGS +=
-mcpu=405
arch/powerpc/boot/Makefile:$(obj)/treeboot-akebono.o: BOOTCFLAGS +=
-mcpu=405
> endif
>
> BOOTCFLAGS += -isystem $(shell $(BOOTCC) -print-file-name=include)
next prev parent reply other threads:[~2022-03-30 11:34 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-30 11:24 [PATCH] powerpc/boot: Build wrapper for an appropriate CPU Joel Stanley
2022-03-30 11:33 ` Christophe Leroy [this message]
2022-03-30 11:39 ` Joel Stanley
2022-03-31 23:00 ` Segher Boessenkool
2022-03-31 2:05 ` Murilo Opsfelder Araújo
2022-03-31 5:01 ` Joel Stanley
2022-03-31 15:19 ` Murilo Opsfelder Araújo
2022-03-31 23:44 ` Segher Boessenkool
2022-04-06 7:08 ` Joel Stanley
2022-04-07 18:43 ` Murilo Opsfelder Araújo
2022-04-07 20:33 ` Segher Boessenkool
2022-03-31 23:09 ` Segher Boessenkool
2022-05-15 10:12 ` Michael Ellerman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e0776e34-7efa-f42c-c194-1fc3fc5cf445@csgroup.eu \
--to=christophe.leroy@csgroup.eu \
--cc=joel@jms.id.au \
--cc=linuxppc-dev@lists.ozlabs.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).