Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/gpl3/gcc/dist/gcc/config/m68k PR port-m68k/55556



details:   https://anonhg.NetBSD.org/src/rev/d0e18bfbcb45
branches:  trunk
changeset: 1012790:d0e18bfbcb45
user:      rin <rin%NetBSD.org@localhost>
date:      Mon Aug 10 06:24:39 2020 +0000

description:
PR port-m68k/55556

Reset STACK_BOUNDARY to default, 16, to fix strange freeze for amiga,
when kernel is compiled by GCC8.

For m68k, the stack pointer is required to be aligned to 16-bit boundary
by architecture. Whereas System V ABI demands it to be aligned to 32-bit
boundary.

According to the document, STACK_BOUNDARY is ``the minimum alignment
enforced by hardware for the stack pointer on this machine.'' Whereas,
PREFERRED_STACK_BOUNDARY should be used ``if you wish to preserve a
certain alignment for the stack pointer, greater than what the hardware
enforces.''

Therefore, STACK_BOUNDARY and PREFERRED_STACK_BOUNDARY should be 16 and
32, respectively, for m68k. This is how Linux/m68k does.

GCC 8 generates codes that wisely allocate 64-bit objects on stack by
using STACK_BOUNDARY. This corrupts the stack frame if it is not properly
aligned.

Since the architecture only guarantees the stack pointer to be aligned to
16-bit boundary, it is not aligned to 32-bit boundary in an instance in
general. If the interrupt occurs at this moment, the interrupt handler
spoils the stack frame as explained above, which results in the mysterious
kernel freezes.

I guess that similar failures can occur even for userland with signal.

With this setting, amiga kernel works just fine as far as I can see.
Furthermore, I've confirmed for amiga, mac68k, and sun3,

(1)   Kernel compiled by patched GCC8 works with
(1-a) userland built by GCC7 and non-modified GCC8, and
(1-b) userland built by patched GCC8.

(2)   Userland binaries compiled by GCC7 and non-modified GCC8 work fine
      with kernel and base libraries built by patched GCC8.

(3)   There's no regression observed for tests/kernel, tests/lib/libc/sys,
      and tests/lib/libc/gen.

This also fixes sun2 kernel to a considerable extent. With non-modified
GCC8, sun2 kernel crashes in strange ways during the early boot stages.
With this change, it boots singleuser.

OK mrg

diffstat:

 external/gpl3/gcc/dist/gcc/config/m68k/netbsd-elf.h |  2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diffs (12 lines):

diff -r 5fc6e43790f3 -r d0e18bfbcb45 external/gpl3/gcc/dist/gcc/config/m68k/netbsd-elf.h
--- a/external/gpl3/gcc/dist/gcc/config/m68k/netbsd-elf.h       Mon Aug 10 05:40:21 2020 +0000
+++ b/external/gpl3/gcc/dist/gcc/config/m68k/netbsd-elf.h       Mon Aug 10 06:24:39 2020 +0000
@@ -292,8 +292,6 @@
 /* Boundary (in *bits*) on which stack pointer should be aligned.
    The m68k/SVR4 convention is to keep the stack pointer longword aligned.  */
 
-#undef STACK_BOUNDARY
-#define STACK_BOUNDARY 32
 #undef PREFERRED_STACK_BOUNDARY
 #define PREFERRED_STACK_BOUNDARY 32
 



Home | Main Index | Thread Index | Old Index