Re: Kernel Oops on alpha with kernel version >=6.9.x

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

 



Hi,

Attempting to summarize the findings relating to this bug as well as
the comments in the mail thread, my understanding is this: In order to
conform to the psABI, gcc was changed (back in 2004?) to assume
16-byte stack alignment on Linux/alpha. This seems to be the case for
user-mode processes stacks, however not for the stack in kernel-mode.
Some simple printouts of stack pointers in kernel mode suggest that
the kernel stack is in fact only 8-byte aligned on Linux/alpha. In
comparison, I've made similar checks on hppa, sparc and x86_64 and on
these platforms the kernel stack seems to be 16-byte aligned (at
least). If gcc assumes 16-byte alignment, and the code uses
__attribute__((__aligned__(x))) gcc will generate assembly code that
may cause stack corruption, if the stack at run-time is in fact only
8-byte aligned. A quick-fix/workaround for this might be to avoid
using the __attribute__((__aligned__(x))) directive on
variables/structs declared on the stack in the kernel code (at least
for alpha), but to really get to the bottom of this, the kernel needs
to be fixed so that the kernel stack is in fact always 16-byte aligned
on alpha. This means that this bug is not really related to rcu or smp
but rather a mismatch between gcc and linux-alpha regarding psABI
compliance.

/Magnus

On Mon, Jan 13, 2025 at 5:52 PM Magnus Lindholm <linmag7@xxxxxxxxx> wrote:
>
> Hi, I've sprinkled some stack pointer printouts and its seems like (as
> suspected) the kernel stack pointer is not 16-byte aligned, at least
> not in kernel-mode.
>
> Example printouts:
> SP: fffffc00059dfc08
> SP: fffffc00059dfe48
> SP: fffffc00059dfc08
>
> I found some ML threads that seemed relevant one on stack alignment in
> NetBSD-alpha after changes in GCC and one on x86_64 with linux/gcc
>
> https://mail-index.netbsd.org/port-alpha/2021/07/05/msg001145.html
>
> https://patchwork.kernel.org/project/linux-crypto/patch/20170110143340.GA3787@xxxxxxxxxxxxxxxxxxx/
>
>
>
> /Magnus
>
> On Mon, Jan 13, 2025 at 6:59 AM Magnus Lindholm <linmag7@xxxxxxxxx> wrote:
> >
> > >  Can you please retrieve the value of SP in `smp_call_function_single'?
> > > Just something such as:
> > >
> > >         printk("SP: %016lx\n", __builtin_frame_address(0));
> > >
> >
> >
> > I will check!
> >
> > Also wondering if this may be relevant?
> >
> >  https://gcc.gnu.org/bugzilla/show_bug.cgi?id=16660





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux