* [Buildroot] [PATCH for-master] package/gcc: 11.3.0: fix glibc crash on G4 ppc cpus
@ 2022-09-04 13:05 Romain Naour
2022-09-06 4:14 ` Joel Stanley
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Romain Naour @ 2022-09-04 13:05 UTC (permalink / raw)
To: buildroot; +Cc: Romain Naour, Joel Stanley
gcc 11.3.0 contains a backported patch [1] that introduce
a regression for old powerpc cpus like the powerpc 7400 (G4).
The glibc crash the init process due to a wrong asm machine
directive (.machine).
Run /sbin/init as init process
init[1]: segfault (11) at 7369693e nip 6f6e08 lr 6f6a68 code 1 in libc.so.6[690000+18f000]
init[1]: code: 280a000c 41c1ffe0 811edb80 554a103a 7d48502e 7d4a4214 7d4903a6 4e800420
init[1]: code: 2c08007a 4bffffbc 89290000 5529103a <7d2a482e> 2c090000 41c2ff78 7fe4fb78
Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b
Backport two patches from the gcc-11 stable branch (the upcoming gcc
11.4.0).
[1] https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=3cb53c10831be59d967d9dce8e7980fee4703500
Fixes:
https://gitlab.com/kubu93/buildroot/-/jobs/2976071284
Signed-off-by: Romain Naour <romain.naour@gmail.com>
Cc: Joel Stanley <joel@jms.id.au>
---
.../11.3.0/0005-rs6000-Improve-.machine.patch | 120 ++++++++++++++++++
...e-rs6000_cpu-for-.machine-ppc-and-pp.patch | 68 ++++++++++
2 files changed, 188 insertions(+)
create mode 100644 package/gcc/11.3.0/0005-rs6000-Improve-.machine.patch
create mode 100644 package/gcc/11.3.0/0006-rs6000-Do-not-use-rs6000_cpu-for-.machine-ppc-and-pp.patch
diff --git a/package/gcc/11.3.0/0005-rs6000-Improve-.machine.patch b/package/gcc/11.3.0/0005-rs6000-Improve-.machine.patch
new file mode 100644
index 0000000000..7a4564b59e
--- /dev/null
+++ b/package/gcc/11.3.0/0005-rs6000-Improve-.machine.patch
@@ -0,0 +1,120 @@
+From ca2c3a7d3db7a699c358d3408f820396dd536fc8 Mon Sep 17 00:00:00 2001
+From: Segher Boessenkool <segher@kernel.crashing.org>
+Date: Tue, 1 Mar 2022 17:04:29 +0000
+Subject: [PATCH 5/6] rs6000: Improve .machine
+
+This adds more correct .machine for most older CPUs. It should be
+conservative in the sense that everything we handled before we handle at
+least as well now. This does not yet revamp the server CPU handling, it
+is too risky at this point in time.
+
+Tested on powerpc64-linux {-m32,-m64}. Also manually tested with all
+-mcpu=, and the output of that passed through the GNU assembler.
+
+2022-03-04 Segher Boessenkool <segher@kernel.crashing.org>
+
+ * config/rs6000/rs6000.c (rs6000_machine_from_flags): Restructure a
+ bit. Handle most older CPUs.
+
+(cherry picked from commit 77eccbf39ed55297802bb66dff5f62507a7239e3)
+(cherry picked from commit fc7e603edc67c66a14f893f3b5a0a34e7d26f77c)
+Signed-off-by: Romain Naour <romain.naour@gmail.com>
+---
+ gcc/config/rs6000/rs6000.c | 81 +++++++++++++++++++++++++-------------
+ 1 file changed, 54 insertions(+), 27 deletions(-)
+
+diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
+index 0421dc7adb3..0a55c979c36 100644
+--- a/gcc/config/rs6000/rs6000.c
++++ b/gcc/config/rs6000/rs6000.c
+@@ -5742,33 +5742,60 @@ const char *rs6000_machine;
+ const char *
+ rs6000_machine_from_flags (void)
+ {
+- /* For some CPUs, the machine cannot be determined by ISA flags. We have to
+- check them first. */
+- switch (rs6000_cpu)
+- {
+- case PROCESSOR_PPC8540:
+- case PROCESSOR_PPC8548:
+- return "e500";
+-
+- case PROCESSOR_PPCE300C2:
+- case PROCESSOR_PPCE300C3:
+- return "e300";
+-
+- case PROCESSOR_PPCE500MC:
+- return "e500mc";
+-
+- case PROCESSOR_PPCE500MC64:
+- return "e500mc64";
+-
+- case PROCESSOR_PPCE5500:
+- return "e5500";
+-
+- case PROCESSOR_PPCE6500:
+- return "e6500";
+-
+- default:
+- break;
+- }
++ /* e300 and e500 */
++ if (rs6000_cpu == PROCESSOR_PPCE300C2 || rs6000_cpu == PROCESSOR_PPCE300C3)
++ return "e300";
++ if (rs6000_cpu == PROCESSOR_PPC8540 || rs6000_cpu == PROCESSOR_PPC8548)
++ return "e500";
++ if (rs6000_cpu == PROCESSOR_PPCE500MC)
++ return "e500mc";
++ if (rs6000_cpu == PROCESSOR_PPCE500MC64)
++ return "e500mc64";
++ if (rs6000_cpu == PROCESSOR_PPCE5500)
++ return "e5500";
++ if (rs6000_cpu == PROCESSOR_PPCE6500)
++ return "e6500";
++
++ /* 400 series */
++ if (rs6000_cpu == PROCESSOR_PPC403)
++ return "\"403\"";
++ if (rs6000_cpu == PROCESSOR_PPC405)
++ return "\"405\"";
++ if (rs6000_cpu == PROCESSOR_PPC440)
++ return "\"440\"";
++ if (rs6000_cpu == PROCESSOR_PPC476)
++ return "\"476\"";
++
++ /* A2 */
++ if (rs6000_cpu == PROCESSOR_PPCA2)
++ return "a2";
++
++ /* Cell BE */
++ if (rs6000_cpu == PROCESSOR_CELL)
++ return "cell";
++
++ /* Titan */
++ if (rs6000_cpu == PROCESSOR_TITAN)
++ return "titan";
++
++ /* 500 series and 800 series */
++ if (rs6000_cpu == PROCESSOR_MPCCORE)
++ return "\"821\"";
++
++ /* 600 series and 700 series, "classic" */
++ if (rs6000_cpu == PROCESSOR_PPC601 || rs6000_cpu == PROCESSOR_PPC603
++ || rs6000_cpu == PROCESSOR_PPC604 || rs6000_cpu == PROCESSOR_PPC604e
++ || rs6000_cpu == PROCESSOR_PPC750 || rs6000_cpu == PROCESSOR_POWERPC)
++ return "ppc";
++
++ /* Classic with AltiVec, "G4" */
++ if (rs6000_cpu == PROCESSOR_PPC7400 || rs6000_cpu == PROCESSOR_PPC7450)
++ return "\"7450\"";
++
++ /* The older 64-bit CPUs */
++ if (rs6000_cpu == PROCESSOR_PPC620 || rs6000_cpu == PROCESSOR_PPC630
++ || rs6000_cpu == PROCESSOR_RS64A || rs6000_cpu == PROCESSOR_POWERPC64)
++ return "ppc64";
+
+ HOST_WIDE_INT flags = rs6000_isa_flags;
+
+--
+2.34.3
+
diff --git a/package/gcc/11.3.0/0006-rs6000-Do-not-use-rs6000_cpu-for-.machine-ppc-and-pp.patch b/package/gcc/11.3.0/0006-rs6000-Do-not-use-rs6000_cpu-for-.machine-ppc-and-pp.patch
new file mode 100644
index 0000000000..8e31c8241c
--- /dev/null
+++ b/package/gcc/11.3.0/0006-rs6000-Do-not-use-rs6000_cpu-for-.machine-ppc-and-pp.patch
@@ -0,0 +1,68 @@
+From 6de33ed642f119f1e2543095dd56e4a94f97c27f Mon Sep 17 00:00:00 2001
+From: Segher Boessenkool <segher@kernel.crashing.org>
+Date: Fri, 11 Mar 2022 21:15:18 +0000
+Subject: [PATCH 6/6] rs6000: Do not use rs6000_cpu for .machine ppc and ppc64
+ (PR104829)
+
+Fixes: 77eccbf39ed5
+
+rs6000.h has
+ #define PROCESSOR_POWERPC PROCESSOR_PPC604
+ #define PROCESSOR_POWERPC64 PROCESSOR_RS64A
+which means that if you use things like -mcpu=powerpc -mvsx it will no
+longer work after my latest .machine patch. This causes GCC build errors
+in some cases, not a good idea (even if the errors are actually
+pre-existing: using -mvsx with a machine that does not have VSX cannot
+work properly).
+
+2022-03-11 Segher Boessenkool <segher@kernel.crashing.org>
+
+ PR target/104829
+ * config/rs6000/rs6000.c (rs6000_machine_from_flags): Don't output
+ "ppc" and "ppc64" based on rs6000_cpu.
+
+(cherry picked from commit 80fcc4b6afee72443bef551064826b3b4b6785e6)
+(cherry picked from commit d87e0e297b1cba73a0c055d2a3e9267d288f435a)
+Signed-off-by: Romain Naour <romain.naour@gmail.com>
+---
+ gcc/config/rs6000/rs6000.c | 12 ++++++++++--
+ 1 file changed, 10 insertions(+), 2 deletions(-)
+
+diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
+index 0a55c979c36..7e5cdd34840 100644
+--- a/gcc/config/rs6000/rs6000.c
++++ b/gcc/config/rs6000/rs6000.c
+@@ -5782,20 +5782,28 @@ rs6000_machine_from_flags (void)
+ if (rs6000_cpu == PROCESSOR_MPCCORE)
+ return "\"821\"";
+
++#if 0
++ /* This (and ppc64 below) are disabled here (for now at least) because
++ PROCESSOR_POWERPC, PROCESSOR_POWERPC64, and PROCESSOR_COMMON
++ are #define'd as some of these. Untangling that is a job for later. */
++
+ /* 600 series and 700 series, "classic" */
+ if (rs6000_cpu == PROCESSOR_PPC601 || rs6000_cpu == PROCESSOR_PPC603
+ || rs6000_cpu == PROCESSOR_PPC604 || rs6000_cpu == PROCESSOR_PPC604e
+- || rs6000_cpu == PROCESSOR_PPC750 || rs6000_cpu == PROCESSOR_POWERPC)
++ || rs6000_cpu == PROCESSOR_PPC750)
+ return "ppc";
++#endif
+
+ /* Classic with AltiVec, "G4" */
+ if (rs6000_cpu == PROCESSOR_PPC7400 || rs6000_cpu == PROCESSOR_PPC7450)
+ return "\"7450\"";
+
++#if 0
+ /* The older 64-bit CPUs */
+ if (rs6000_cpu == PROCESSOR_PPC620 || rs6000_cpu == PROCESSOR_PPC630
+- || rs6000_cpu == PROCESSOR_RS64A || rs6000_cpu == PROCESSOR_POWERPC64)
++ || rs6000_cpu == PROCESSOR_RS64A)
+ return "ppc64";
++#endif
+
+ HOST_WIDE_INT flags = rs6000_isa_flags;
+
+--
+2.34.3
+
--
2.34.3
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Buildroot] [PATCH for-master] package/gcc: 11.3.0: fix glibc crash on G4 ppc cpus
2022-09-04 13:05 [Buildroot] [PATCH for-master] package/gcc: 11.3.0: fix glibc crash on G4 ppc cpus Romain Naour
@ 2022-09-06 4:14 ` Joel Stanley
2022-09-06 9:42 ` Yann E. MORIN
2022-09-18 8:55 ` Peter Korsgaard
2 siblings, 0 replies; 4+ messages in thread
From: Joel Stanley @ 2022-09-06 4:14 UTC (permalink / raw)
To: Romain Naour; +Cc: buildroot
On Sun, 4 Sept 2022 at 13:05, Romain Naour <romain.naour@gmail.com> wrote:
>
> gcc 11.3.0 contains a backported patch [1] that introduce
> a regression for old powerpc cpus like the powerpc 7400 (G4).
>
> The glibc crash the init process due to a wrong asm machine
> directive (.machine).
>
> Run /sbin/init as init process
> init[1]: segfault (11) at 7369693e nip 6f6e08 lr 6f6a68 code 1 in libc.so.6[690000+18f000]
> init[1]: code: 280a000c 41c1ffe0 811edb80 554a103a 7d48502e 7d4a4214 7d4903a6 4e800420
> init[1]: code: 2c08007a 4bffffbc 89290000 5529103a <7d2a482e> 2c090000 41c2ff78 7fe4fb78
> Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b
>
> Backport two patches from the gcc-11 stable branch (the upcoming gcc
> 11.4.0).
>
> [1] https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=3cb53c10831be59d967d9dce8e7980fee4703500
>
> Fixes:
> https://gitlab.com/kubu93/buildroot/-/jobs/2976071284
>
> Signed-off-by: Romain Naour <romain.naour@gmail.com>
I haven't come across this myself, but looking through the gcc 11
branch this looks like a reasonable fix.
Reviewed-by: Joel Stanley <joel@jms.id.au>
Cheers,
Joel
> Cc: Joel Stanley <joel@jms.id.au>
> ---
> .../11.3.0/0005-rs6000-Improve-.machine.patch | 120 ++++++++++++++++++
> ...e-rs6000_cpu-for-.machine-ppc-and-pp.patch | 68 ++++++++++
> 2 files changed, 188 insertions(+)
> create mode 100644 package/gcc/11.3.0/0005-rs6000-Improve-.machine.patch
> create mode 100644 package/gcc/11.3.0/0006-rs6000-Do-not-use-rs6000_cpu-for-.machine-ppc-and-pp.patch
>
> diff --git a/package/gcc/11.3.0/0005-rs6000-Improve-.machine.patch b/package/gcc/11.3.0/0005-rs6000-Improve-.machine.patch
> new file mode 100644
> index 0000000000..7a4564b59e
> --- /dev/null
> +++ b/package/gcc/11.3.0/0005-rs6000-Improve-.machine.patch
> @@ -0,0 +1,120 @@
> +From ca2c3a7d3db7a699c358d3408f820396dd536fc8 Mon Sep 17 00:00:00 2001
> +From: Segher Boessenkool <segher@kernel.crashing.org>
> +Date: Tue, 1 Mar 2022 17:04:29 +0000
> +Subject: [PATCH 5/6] rs6000: Improve .machine
> +
> +This adds more correct .machine for most older CPUs. It should be
> +conservative in the sense that everything we handled before we handle at
> +least as well now. This does not yet revamp the server CPU handling, it
> +is too risky at this point in time.
> +
> +Tested on powerpc64-linux {-m32,-m64}. Also manually tested with all
> +-mcpu=, and the output of that passed through the GNU assembler.
> +
> +2022-03-04 Segher Boessenkool <segher@kernel.crashing.org>
> +
> + * config/rs6000/rs6000.c (rs6000_machine_from_flags): Restructure a
> + bit. Handle most older CPUs.
> +
> +(cherry picked from commit 77eccbf39ed55297802bb66dff5f62507a7239e3)
> +(cherry picked from commit fc7e603edc67c66a14f893f3b5a0a34e7d26f77c)
> +Signed-off-by: Romain Naour <romain.naour@gmail.com>
> +---
> + gcc/config/rs6000/rs6000.c | 81 +++++++++++++++++++++++++-------------
> + 1 file changed, 54 insertions(+), 27 deletions(-)
> +
> +diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
> +index 0421dc7adb3..0a55c979c36 100644
> +--- a/gcc/config/rs6000/rs6000.c
> ++++ b/gcc/config/rs6000/rs6000.c
> +@@ -5742,33 +5742,60 @@ const char *rs6000_machine;
> + const char *
> + rs6000_machine_from_flags (void)
> + {
> +- /* For some CPUs, the machine cannot be determined by ISA flags. We have to
> +- check them first. */
> +- switch (rs6000_cpu)
> +- {
> +- case PROCESSOR_PPC8540:
> +- case PROCESSOR_PPC8548:
> +- return "e500";
> +-
> +- case PROCESSOR_PPCE300C2:
> +- case PROCESSOR_PPCE300C3:
> +- return "e300";
> +-
> +- case PROCESSOR_PPCE500MC:
> +- return "e500mc";
> +-
> +- case PROCESSOR_PPCE500MC64:
> +- return "e500mc64";
> +-
> +- case PROCESSOR_PPCE5500:
> +- return "e5500";
> +-
> +- case PROCESSOR_PPCE6500:
> +- return "e6500";
> +-
> +- default:
> +- break;
> +- }
> ++ /* e300 and e500 */
> ++ if (rs6000_cpu == PROCESSOR_PPCE300C2 || rs6000_cpu == PROCESSOR_PPCE300C3)
> ++ return "e300";
> ++ if (rs6000_cpu == PROCESSOR_PPC8540 || rs6000_cpu == PROCESSOR_PPC8548)
> ++ return "e500";
> ++ if (rs6000_cpu == PROCESSOR_PPCE500MC)
> ++ return "e500mc";
> ++ if (rs6000_cpu == PROCESSOR_PPCE500MC64)
> ++ return "e500mc64";
> ++ if (rs6000_cpu == PROCESSOR_PPCE5500)
> ++ return "e5500";
> ++ if (rs6000_cpu == PROCESSOR_PPCE6500)
> ++ return "e6500";
> ++
> ++ /* 400 series */
> ++ if (rs6000_cpu == PROCESSOR_PPC403)
> ++ return "\"403\"";
> ++ if (rs6000_cpu == PROCESSOR_PPC405)
> ++ return "\"405\"";
> ++ if (rs6000_cpu == PROCESSOR_PPC440)
> ++ return "\"440\"";
> ++ if (rs6000_cpu == PROCESSOR_PPC476)
> ++ return "\"476\"";
> ++
> ++ /* A2 */
> ++ if (rs6000_cpu == PROCESSOR_PPCA2)
> ++ return "a2";
> ++
> ++ /* Cell BE */
> ++ if (rs6000_cpu == PROCESSOR_CELL)
> ++ return "cell";
> ++
> ++ /* Titan */
> ++ if (rs6000_cpu == PROCESSOR_TITAN)
> ++ return "titan";
> ++
> ++ /* 500 series and 800 series */
> ++ if (rs6000_cpu == PROCESSOR_MPCCORE)
> ++ return "\"821\"";
> ++
> ++ /* 600 series and 700 series, "classic" */
> ++ if (rs6000_cpu == PROCESSOR_PPC601 || rs6000_cpu == PROCESSOR_PPC603
> ++ || rs6000_cpu == PROCESSOR_PPC604 || rs6000_cpu == PROCESSOR_PPC604e
> ++ || rs6000_cpu == PROCESSOR_PPC750 || rs6000_cpu == PROCESSOR_POWERPC)
> ++ return "ppc";
> ++
> ++ /* Classic with AltiVec, "G4" */
> ++ if (rs6000_cpu == PROCESSOR_PPC7400 || rs6000_cpu == PROCESSOR_PPC7450)
> ++ return "\"7450\"";
> ++
> ++ /* The older 64-bit CPUs */
> ++ if (rs6000_cpu == PROCESSOR_PPC620 || rs6000_cpu == PROCESSOR_PPC630
> ++ || rs6000_cpu == PROCESSOR_RS64A || rs6000_cpu == PROCESSOR_POWERPC64)
> ++ return "ppc64";
> +
> + HOST_WIDE_INT flags = rs6000_isa_flags;
> +
> +--
> +2.34.3
> +
> diff --git a/package/gcc/11.3.0/0006-rs6000-Do-not-use-rs6000_cpu-for-.machine-ppc-and-pp.patch b/package/gcc/11.3.0/0006-rs6000-Do-not-use-rs6000_cpu-for-.machine-ppc-and-pp.patch
> new file mode 100644
> index 0000000000..8e31c8241c
> --- /dev/null
> +++ b/package/gcc/11.3.0/0006-rs6000-Do-not-use-rs6000_cpu-for-.machine-ppc-and-pp.patch
> @@ -0,0 +1,68 @@
> +From 6de33ed642f119f1e2543095dd56e4a94f97c27f Mon Sep 17 00:00:00 2001
> +From: Segher Boessenkool <segher@kernel.crashing.org>
> +Date: Fri, 11 Mar 2022 21:15:18 +0000
> +Subject: [PATCH 6/6] rs6000: Do not use rs6000_cpu for .machine ppc and ppc64
> + (PR104829)
> +
> +Fixes: 77eccbf39ed5
> +
> +rs6000.h has
> + #define PROCESSOR_POWERPC PROCESSOR_PPC604
> + #define PROCESSOR_POWERPC64 PROCESSOR_RS64A
> +which means that if you use things like -mcpu=powerpc -mvsx it will no
> +longer work after my latest .machine patch. This causes GCC build errors
> +in some cases, not a good idea (even if the errors are actually
> +pre-existing: using -mvsx with a machine that does not have VSX cannot
> +work properly).
> +
> +2022-03-11 Segher Boessenkool <segher@kernel.crashing.org>
> +
> + PR target/104829
> + * config/rs6000/rs6000.c (rs6000_machine_from_flags): Don't output
> + "ppc" and "ppc64" based on rs6000_cpu.
> +
> +(cherry picked from commit 80fcc4b6afee72443bef551064826b3b4b6785e6)
> +(cherry picked from commit d87e0e297b1cba73a0c055d2a3e9267d288f435a)
> +Signed-off-by: Romain Naour <romain.naour@gmail.com>
> +---
> + gcc/config/rs6000/rs6000.c | 12 ++++++++++--
> + 1 file changed, 10 insertions(+), 2 deletions(-)
> +
> +diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
> +index 0a55c979c36..7e5cdd34840 100644
> +--- a/gcc/config/rs6000/rs6000.c
> ++++ b/gcc/config/rs6000/rs6000.c
> +@@ -5782,20 +5782,28 @@ rs6000_machine_from_flags (void)
> + if (rs6000_cpu == PROCESSOR_MPCCORE)
> + return "\"821\"";
> +
> ++#if 0
> ++ /* This (and ppc64 below) are disabled here (for now at least) because
> ++ PROCESSOR_POWERPC, PROCESSOR_POWERPC64, and PROCESSOR_COMMON
> ++ are #define'd as some of these. Untangling that is a job for later. */
> ++
> + /* 600 series and 700 series, "classic" */
> + if (rs6000_cpu == PROCESSOR_PPC601 || rs6000_cpu == PROCESSOR_PPC603
> + || rs6000_cpu == PROCESSOR_PPC604 || rs6000_cpu == PROCESSOR_PPC604e
> +- || rs6000_cpu == PROCESSOR_PPC750 || rs6000_cpu == PROCESSOR_POWERPC)
> ++ || rs6000_cpu == PROCESSOR_PPC750)
> + return "ppc";
> ++#endif
> +
> + /* Classic with AltiVec, "G4" */
> + if (rs6000_cpu == PROCESSOR_PPC7400 || rs6000_cpu == PROCESSOR_PPC7450)
> + return "\"7450\"";
> +
> ++#if 0
> + /* The older 64-bit CPUs */
> + if (rs6000_cpu == PROCESSOR_PPC620 || rs6000_cpu == PROCESSOR_PPC630
> +- || rs6000_cpu == PROCESSOR_RS64A || rs6000_cpu == PROCESSOR_POWERPC64)
> ++ || rs6000_cpu == PROCESSOR_RS64A)
> + return "ppc64";
> ++#endif
> +
> + HOST_WIDE_INT flags = rs6000_isa_flags;
> +
> +--
> +2.34.3
> +
> --
> 2.34.3
>
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Buildroot] [PATCH for-master] package/gcc: 11.3.0: fix glibc crash on G4 ppc cpus
2022-09-04 13:05 [Buildroot] [PATCH for-master] package/gcc: 11.3.0: fix glibc crash on G4 ppc cpus Romain Naour
2022-09-06 4:14 ` Joel Stanley
@ 2022-09-06 9:42 ` Yann E. MORIN
2022-09-18 8:55 ` Peter Korsgaard
2 siblings, 0 replies; 4+ messages in thread
From: Yann E. MORIN @ 2022-09-06 9:42 UTC (permalink / raw)
To: Romain Naour; +Cc: Joel Stanley, buildroot
Romain, All,
On 2022-09-04 15:05 +0200, Romain Naour spake thusly:
> gcc 11.3.0 contains a backported patch [1] that introduce
> a regression for old powerpc cpus like the powerpc 7400 (G4).
>
> The glibc crash the init process due to a wrong asm machine
> directive (.machine).
>
> Run /sbin/init as init process
> init[1]: segfault (11) at 7369693e nip 6f6e08 lr 6f6a68 code 1 in libc.so.6[690000+18f000]
> init[1]: code: 280a000c 41c1ffe0 811edb80 554a103a 7d48502e 7d4a4214 7d4903a6 4e800420
> init[1]: code: 2c08007a 4bffffbc 89290000 5529103a <7d2a482e> 2c090000 41c2ff78 7fe4fb78
> Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b
>
> Backport two patches from the gcc-11 stable branch (the upcoming gcc
> 11.4.0).
>
> [1] https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=3cb53c10831be59d967d9dce8e7980fee4703500
>
> Fixes:
> https://gitlab.com/kubu93/buildroot/-/jobs/2976071284
>
> Signed-off-by: Romain Naour <romain.naour@gmail.com>
> Cc: Joel Stanley <joel@jms.id.au>
Applied to master, thanks.
Regards,
Yann E. MORIN.
> ---
> .../11.3.0/0005-rs6000-Improve-.machine.patch | 120 ++++++++++++++++++
> ...e-rs6000_cpu-for-.machine-ppc-and-pp.patch | 68 ++++++++++
> 2 files changed, 188 insertions(+)
> create mode 100644 package/gcc/11.3.0/0005-rs6000-Improve-.machine.patch
> create mode 100644 package/gcc/11.3.0/0006-rs6000-Do-not-use-rs6000_cpu-for-.machine-ppc-and-pp.patch
>
> diff --git a/package/gcc/11.3.0/0005-rs6000-Improve-.machine.patch b/package/gcc/11.3.0/0005-rs6000-Improve-.machine.patch
> new file mode 100644
> index 0000000000..7a4564b59e
> --- /dev/null
> +++ b/package/gcc/11.3.0/0005-rs6000-Improve-.machine.patch
> @@ -0,0 +1,120 @@
> +From ca2c3a7d3db7a699c358d3408f820396dd536fc8 Mon Sep 17 00:00:00 2001
> +From: Segher Boessenkool <segher@kernel.crashing.org>
> +Date: Tue, 1 Mar 2022 17:04:29 +0000
> +Subject: [PATCH 5/6] rs6000: Improve .machine
> +
> +This adds more correct .machine for most older CPUs. It should be
> +conservative in the sense that everything we handled before we handle at
> +least as well now. This does not yet revamp the server CPU handling, it
> +is too risky at this point in time.
> +
> +Tested on powerpc64-linux {-m32,-m64}. Also manually tested with all
> +-mcpu=, and the output of that passed through the GNU assembler.
> +
> +2022-03-04 Segher Boessenkool <segher@kernel.crashing.org>
> +
> + * config/rs6000/rs6000.c (rs6000_machine_from_flags): Restructure a
> + bit. Handle most older CPUs.
> +
> +(cherry picked from commit 77eccbf39ed55297802bb66dff5f62507a7239e3)
> +(cherry picked from commit fc7e603edc67c66a14f893f3b5a0a34e7d26f77c)
> +Signed-off-by: Romain Naour <romain.naour@gmail.com>
> +---
> + gcc/config/rs6000/rs6000.c | 81 +++++++++++++++++++++++++-------------
> + 1 file changed, 54 insertions(+), 27 deletions(-)
> +
> +diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
> +index 0421dc7adb3..0a55c979c36 100644
> +--- a/gcc/config/rs6000/rs6000.c
> ++++ b/gcc/config/rs6000/rs6000.c
> +@@ -5742,33 +5742,60 @@ const char *rs6000_machine;
> + const char *
> + rs6000_machine_from_flags (void)
> + {
> +- /* For some CPUs, the machine cannot be determined by ISA flags. We have to
> +- check them first. */
> +- switch (rs6000_cpu)
> +- {
> +- case PROCESSOR_PPC8540:
> +- case PROCESSOR_PPC8548:
> +- return "e500";
> +-
> +- case PROCESSOR_PPCE300C2:
> +- case PROCESSOR_PPCE300C3:
> +- return "e300";
> +-
> +- case PROCESSOR_PPCE500MC:
> +- return "e500mc";
> +-
> +- case PROCESSOR_PPCE500MC64:
> +- return "e500mc64";
> +-
> +- case PROCESSOR_PPCE5500:
> +- return "e5500";
> +-
> +- case PROCESSOR_PPCE6500:
> +- return "e6500";
> +-
> +- default:
> +- break;
> +- }
> ++ /* e300 and e500 */
> ++ if (rs6000_cpu == PROCESSOR_PPCE300C2 || rs6000_cpu == PROCESSOR_PPCE300C3)
> ++ return "e300";
> ++ if (rs6000_cpu == PROCESSOR_PPC8540 || rs6000_cpu == PROCESSOR_PPC8548)
> ++ return "e500";
> ++ if (rs6000_cpu == PROCESSOR_PPCE500MC)
> ++ return "e500mc";
> ++ if (rs6000_cpu == PROCESSOR_PPCE500MC64)
> ++ return "e500mc64";
> ++ if (rs6000_cpu == PROCESSOR_PPCE5500)
> ++ return "e5500";
> ++ if (rs6000_cpu == PROCESSOR_PPCE6500)
> ++ return "e6500";
> ++
> ++ /* 400 series */
> ++ if (rs6000_cpu == PROCESSOR_PPC403)
> ++ return "\"403\"";
> ++ if (rs6000_cpu == PROCESSOR_PPC405)
> ++ return "\"405\"";
> ++ if (rs6000_cpu == PROCESSOR_PPC440)
> ++ return "\"440\"";
> ++ if (rs6000_cpu == PROCESSOR_PPC476)
> ++ return "\"476\"";
> ++
> ++ /* A2 */
> ++ if (rs6000_cpu == PROCESSOR_PPCA2)
> ++ return "a2";
> ++
> ++ /* Cell BE */
> ++ if (rs6000_cpu == PROCESSOR_CELL)
> ++ return "cell";
> ++
> ++ /* Titan */
> ++ if (rs6000_cpu == PROCESSOR_TITAN)
> ++ return "titan";
> ++
> ++ /* 500 series and 800 series */
> ++ if (rs6000_cpu == PROCESSOR_MPCCORE)
> ++ return "\"821\"";
> ++
> ++ /* 600 series and 700 series, "classic" */
> ++ if (rs6000_cpu == PROCESSOR_PPC601 || rs6000_cpu == PROCESSOR_PPC603
> ++ || rs6000_cpu == PROCESSOR_PPC604 || rs6000_cpu == PROCESSOR_PPC604e
> ++ || rs6000_cpu == PROCESSOR_PPC750 || rs6000_cpu == PROCESSOR_POWERPC)
> ++ return "ppc";
> ++
> ++ /* Classic with AltiVec, "G4" */
> ++ if (rs6000_cpu == PROCESSOR_PPC7400 || rs6000_cpu == PROCESSOR_PPC7450)
> ++ return "\"7450\"";
> ++
> ++ /* The older 64-bit CPUs */
> ++ if (rs6000_cpu == PROCESSOR_PPC620 || rs6000_cpu == PROCESSOR_PPC630
> ++ || rs6000_cpu == PROCESSOR_RS64A || rs6000_cpu == PROCESSOR_POWERPC64)
> ++ return "ppc64";
> +
> + HOST_WIDE_INT flags = rs6000_isa_flags;
> +
> +--
> +2.34.3
> +
> diff --git a/package/gcc/11.3.0/0006-rs6000-Do-not-use-rs6000_cpu-for-.machine-ppc-and-pp.patch b/package/gcc/11.3.0/0006-rs6000-Do-not-use-rs6000_cpu-for-.machine-ppc-and-pp.patch
> new file mode 100644
> index 0000000000..8e31c8241c
> --- /dev/null
> +++ b/package/gcc/11.3.0/0006-rs6000-Do-not-use-rs6000_cpu-for-.machine-ppc-and-pp.patch
> @@ -0,0 +1,68 @@
> +From 6de33ed642f119f1e2543095dd56e4a94f97c27f Mon Sep 17 00:00:00 2001
> +From: Segher Boessenkool <segher@kernel.crashing.org>
> +Date: Fri, 11 Mar 2022 21:15:18 +0000
> +Subject: [PATCH 6/6] rs6000: Do not use rs6000_cpu for .machine ppc and ppc64
> + (PR104829)
> +
> +Fixes: 77eccbf39ed5
> +
> +rs6000.h has
> + #define PROCESSOR_POWERPC PROCESSOR_PPC604
> + #define PROCESSOR_POWERPC64 PROCESSOR_RS64A
> +which means that if you use things like -mcpu=powerpc -mvsx it will no
> +longer work after my latest .machine patch. This causes GCC build errors
> +in some cases, not a good idea (even if the errors are actually
> +pre-existing: using -mvsx with a machine that does not have VSX cannot
> +work properly).
> +
> +2022-03-11 Segher Boessenkool <segher@kernel.crashing.org>
> +
> + PR target/104829
> + * config/rs6000/rs6000.c (rs6000_machine_from_flags): Don't output
> + "ppc" and "ppc64" based on rs6000_cpu.
> +
> +(cherry picked from commit 80fcc4b6afee72443bef551064826b3b4b6785e6)
> +(cherry picked from commit d87e0e297b1cba73a0c055d2a3e9267d288f435a)
> +Signed-off-by: Romain Naour <romain.naour@gmail.com>
> +---
> + gcc/config/rs6000/rs6000.c | 12 ++++++++++--
> + 1 file changed, 10 insertions(+), 2 deletions(-)
> +
> +diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
> +index 0a55c979c36..7e5cdd34840 100644
> +--- a/gcc/config/rs6000/rs6000.c
> ++++ b/gcc/config/rs6000/rs6000.c
> +@@ -5782,20 +5782,28 @@ rs6000_machine_from_flags (void)
> + if (rs6000_cpu == PROCESSOR_MPCCORE)
> + return "\"821\"";
> +
> ++#if 0
> ++ /* This (and ppc64 below) are disabled here (for now at least) because
> ++ PROCESSOR_POWERPC, PROCESSOR_POWERPC64, and PROCESSOR_COMMON
> ++ are #define'd as some of these. Untangling that is a job for later. */
> ++
> + /* 600 series and 700 series, "classic" */
> + if (rs6000_cpu == PROCESSOR_PPC601 || rs6000_cpu == PROCESSOR_PPC603
> + || rs6000_cpu == PROCESSOR_PPC604 || rs6000_cpu == PROCESSOR_PPC604e
> +- || rs6000_cpu == PROCESSOR_PPC750 || rs6000_cpu == PROCESSOR_POWERPC)
> ++ || rs6000_cpu == PROCESSOR_PPC750)
> + return "ppc";
> ++#endif
> +
> + /* Classic with AltiVec, "G4" */
> + if (rs6000_cpu == PROCESSOR_PPC7400 || rs6000_cpu == PROCESSOR_PPC7450)
> + return "\"7450\"";
> +
> ++#if 0
> + /* The older 64-bit CPUs */
> + if (rs6000_cpu == PROCESSOR_PPC620 || rs6000_cpu == PROCESSOR_PPC630
> +- || rs6000_cpu == PROCESSOR_RS64A || rs6000_cpu == PROCESSOR_POWERPC64)
> ++ || rs6000_cpu == PROCESSOR_RS64A)
> + return "ppc64";
> ++#endif
> +
> + HOST_WIDE_INT flags = rs6000_isa_flags;
> +
> +--
> +2.34.3
> +
> --
> 2.34.3
>
> _______________________________________________
> buildroot mailing list
> buildroot@buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot
--
.-----------------.--------------------.------------------.--------------------.
| Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ |
| +33 561 099 427 `------------.-------: X AGAINST | \e/ There is no |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Buildroot] [PATCH for-master] package/gcc: 11.3.0: fix glibc crash on G4 ppc cpus
2022-09-04 13:05 [Buildroot] [PATCH for-master] package/gcc: 11.3.0: fix glibc crash on G4 ppc cpus Romain Naour
2022-09-06 4:14 ` Joel Stanley
2022-09-06 9:42 ` Yann E. MORIN
@ 2022-09-18 8:55 ` Peter Korsgaard
2 siblings, 0 replies; 4+ messages in thread
From: Peter Korsgaard @ 2022-09-18 8:55 UTC (permalink / raw)
To: Romain Naour; +Cc: Joel Stanley, buildroot
>>>>> "Romain" == Romain Naour <romain.naour@gmail.com> writes:
> gcc 11.3.0 contains a backported patch [1] that introduce
> a regression for old powerpc cpus like the powerpc 7400 (G4).
> The glibc crash the init process due to a wrong asm machine
> directive (.machine).
> Run /sbin/init as init process
> init[1]: segfault (11) at 7369693e nip 6f6e08 lr 6f6a68 code 1 in libc.so.6[690000+18f000]
> init[1]: code: 280a000c 41c1ffe0 811edb80 554a103a 7d48502e 7d4a4214 7d4903a6 4e800420
> init[1]: code: 2c08007a 4bffffbc 89290000 5529103a <7d2a482e> 2c090000 41c2ff78 7fe4fb78
> Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b
> Backport two patches from the gcc-11 stable branch (the upcoming gcc
> 11.4.0).
> [1] https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=3cb53c10831be59d967d9dce8e7980fee4703500
> Fixes:
> https://gitlab.com/kubu93/buildroot/-/jobs/2976071284
> Signed-off-by: Romain Naour <romain.naour@gmail.com>
> Cc: Joel Stanley <joel@jms.id.au>
Committed to 2022.05.x and 2022.02.x, thanks.
--
Bye, Peter Korsgaard
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-09-18 8:55 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-04 13:05 [Buildroot] [PATCH for-master] package/gcc: 11.3.0: fix glibc crash on G4 ppc cpus Romain Naour
2022-09-06 4:14 ` Joel Stanley
2022-09-06 9:42 ` Yann E. MORIN
2022-09-18 8:55 ` Peter Korsgaard
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.