From: Ivan Kokshaysky <ink@unseen.parts>
To: "Maciej W. Rozycki" <macro@orcam.me.uk>
Cc: Magnus Lindholm <linmag7@gmail.com>,
"Paul E. McKenney" <paulmck@kernel.org>,
Michael Cree <mcree@orcon.net.nz>,
John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>,
rcu@vger.kernel.org, linux-alpha@vger.kernel.org
Subject: Re: Kernel Oops on alpha with kernel version >=6.9.x
Date: Sat, 25 Jan 2025 20:48:14 +0100 [thread overview]
Message-ID: <Z5U__sztq2P2UKWk@minute> (raw)
In-Reply-To: <alpine.DEB.2.21.2501251839440.27203@angie.orcam.me.uk>
On Sat, Jan 25, 2025 at 06:59:32PM +0000, Maciej W. Rozycki wrote:
> On Sat, 25 Jan 2025, Maciej W. Rozycki wrote:
>
> > > Interesting. Perhaps these frames are aligned by PAL-code as well,
> > > the reference manual wasn't clear about that.
> >
> > I think it just boils down to the amount of exception nesting.
>
> Ah, actually most of these faults were entered from the user mode and the
> kernel stack starts at a page boundary, so once the stack frame has been
> allocated by PALcode and SAVE_ALL combined the stack pointer ends up
> misaligned. For faults entered from the kernel mode the opposite might be
> the case.
Indeed, sounds plausible.
> So unless we want to play (and we don't) with FP and the saving
> and restoration of SP, we just want to keep SP aligned at all times.
> > > I knew about entUna, I thought it's safe as it only deals with 64-bit data
> > > and not going to be changed in future, but missed entMM...
> > >
> > > I agree, better fix both.
> >
> > Well, we may get away with it in many cases, which is obviously why
> > this bug has survived so long, but in principle it is not safe to enter
> > C code with the stack misaligned, so yes, we need to fix all the code
> > paths, also because a nested exception will cause hell to break loose.
> >
> > Here just bumping up the frame size and adjusting offsets in assembly
> > code accordingly so as to account for the empty longword at the bottom
> > of the frame should do, just as I did across my change.
>
> ... or, depending on how you look at it, top of the frame and FAOD in any
> case the longword closest to the stack pointer will be the empty one.
Right. So if we agree on my variant, this addition patch is needed.
[No problems with gdb, as expected.]
Ivan.
diff --git a/arch/alpha/kernel/entry.S b/arch/alpha/kernel/entry.S
index 6fb38365539d..f4d41b4538c2 100644
--- a/arch/alpha/kernel/entry.S
+++ b/arch/alpha/kernel/entry.S
@@ -194,8 +194,8 @@ CFI_END_OSF_FRAME entArith
CFI_START_OSF_FRAME entMM
SAVE_ALL
/* save $9 - $15 so the inline exception code can manipulate them. */
- subq $sp, 56, $sp
- .cfi_adjust_cfa_offset 56
+ subq $sp, 64, $sp
+ .cfi_adjust_cfa_offset 64
stq $9, 0($sp)
stq $10, 8($sp)
stq $11, 16($sp)
@@ -210,7 +210,7 @@ CFI_START_OSF_FRAME entMM
.cfi_rel_offset $13, 32
.cfi_rel_offset $14, 40
.cfi_rel_offset $15, 48
- addq $sp, 56, $19
+ addq $sp, 64, $19
/* handle the fault */
lda $8, 0x3fff
bic $sp, $8, $8
@@ -223,7 +223,7 @@ CFI_START_OSF_FRAME entMM
ldq $13, 32($sp)
ldq $14, 40($sp)
ldq $15, 48($sp)
- addq $sp, 56, $sp
+ addq $sp, 64, $sp
.cfi_restore $9
.cfi_restore $10
.cfi_restore $11
@@ -231,7 +231,7 @@ CFI_START_OSF_FRAME entMM
.cfi_restore $13
.cfi_restore $14
.cfi_restore $15
- .cfi_adjust_cfa_offset -56
+ .cfi_adjust_cfa_offset -64
/* finish up the syscall as normal. */
br ret_from_sys_call
CFI_END_OSF_FRAME entMM
@@ -378,8 +378,8 @@ entUnaUser:
.cfi_restore $0
.cfi_adjust_cfa_offset -256
SAVE_ALL /* setup normal kernel stack */
- lda $sp, -56($sp)
- .cfi_adjust_cfa_offset 56
+ lda $sp, -64($sp)
+ .cfi_adjust_cfa_offset 64
stq $9, 0($sp)
stq $10, 8($sp)
stq $11, 16($sp)
@@ -395,7 +395,7 @@ entUnaUser:
.cfi_rel_offset $14, 40
.cfi_rel_offset $15, 48
lda $8, 0x3fff
- addq $sp, 56, $19
+ addq $sp, 64, $19
bic $sp, $8, $8
jsr $26, do_entUnaUser
ldq $9, 0($sp)
@@ -405,7 +405,7 @@ entUnaUser:
ldq $13, 32($sp)
ldq $14, 40($sp)
ldq $15, 48($sp)
- lda $sp, 56($sp)
+ lda $sp, 64($sp)
.cfi_restore $9
.cfi_restore $10
.cfi_restore $11
@@ -413,7 +413,7 @@ entUnaUser:
.cfi_restore $13
.cfi_restore $14
.cfi_restore $15
- .cfi_adjust_cfa_offset -56
+ .cfi_adjust_cfa_offset -64
br ret_from_sys_call
CFI_END_OSF_FRAME entUna
next prev parent reply other threads:[~2025-01-25 19:48 UTC|newest]
Thread overview: 62+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CA+=Fv5R9NG+1SHU9QV9hjmavycHKpnNyerQ=Ei90G98ukRcRJA@mail.gmail.com>
[not found] ` <f1561626-fde6-41c0-9d45-87a6a7b13816@paulmck-laptop>
[not found] ` <CA+=Fv5TMZ1bckob2VZ1AaNwdU3R+5a8REKg4aZR8novx7+dj-g@mail.gmail.com>
[not found] ` <8e365392-0e0d-4d78-bae7-69f27c8350f9@paulmck-laptop>
2024-12-04 22:22 ` Kernel Oops on alpha with kernel version >=6.9.x Magnus Lindholm
2024-12-05 15:39 ` John Paul Adrian Glaubitz
2024-12-05 17:02 ` Magnus Lindholm
2024-12-06 15:39 ` Magnus Lindholm
2024-12-06 17:05 ` John Paul Adrian Glaubitz
2024-12-07 12:33 ` Magnus Lindholm
2024-12-07 12:39 ` John Paul Adrian Glaubitz
2024-12-07 17:33 ` Magnus Lindholm
2024-12-07 18:38 ` John Paul Adrian Glaubitz
2024-12-08 9:43 ` Magnus Lindholm
2024-12-08 21:39 ` Magnus Lindholm
2024-12-08 23:18 ` Michael Cree
2024-12-08 23:31 ` John Paul Adrian Glaubitz
2024-12-09 8:11 ` Magnus Lindholm
2024-12-12 23:23 ` Magnus Lindholm
2024-12-09 8:05 ` Magnus Lindholm
2024-12-16 22:10 ` Michael Cree
2024-12-17 6:23 ` Magnus Lindholm
2024-12-18 19:33 ` Magnus Lindholm
2024-12-18 20:31 ` Paul E. McKenney
2024-12-18 21:54 ` Magnus Lindholm
2024-12-18 22:50 ` Paul E. McKenney
2024-12-19 22:38 ` Magnus Lindholm
2024-12-19 23:03 ` Paul E. McKenney
2024-12-20 0:00 ` Maciej W. Rozycki
2024-12-27 10:42 ` Magnus Lindholm
2024-12-27 11:48 ` John Paul Adrian Glaubitz
2024-12-27 16:30 ` Maciej W. Rozycki
2024-12-31 10:43 ` Magnus Lindholm
2025-01-12 23:25 ` Magnus Lindholm
2025-01-13 0:19 ` Maciej W. Rozycki
2025-01-13 3:08 ` Maciej W. Rozycki
2025-01-13 5:59 ` Magnus Lindholm
2025-01-13 8:04 ` Maciej W. Rozycki
2025-01-13 16:52 ` Magnus Lindholm
2025-01-20 13:01 ` Magnus Lindholm
2025-01-20 13:19 ` Maciej W. Rozycki
2025-01-21 13:39 ` Ivan Kokshaysky
2025-01-23 18:36 ` Ivan Kokshaysky
2025-01-23 23:00 ` Magnus Lindholm
2025-01-23 23:51 ` Michael Cree
2025-01-23 23:57 ` Maciej W. Rozycki
2025-01-24 6:06 ` Magnus Lindholm
2025-01-24 10:55 ` Ivan Kokshaysky
2025-01-24 16:57 ` Magnus Lindholm
2025-01-25 15:15 ` Ivan Kokshaysky
2025-01-25 17:01 ` Maciej W. Rozycki
2025-01-25 17:43 ` Ivan Kokshaysky
2025-01-25 18:25 ` Maciej W. Rozycki
2025-01-25 18:59 ` Maciej W. Rozycki
2025-01-25 19:48 ` Ivan Kokshaysky [this message]
2025-01-25 22:06 ` Maciej W. Rozycki
2025-01-25 23:02 ` Ivan Kokshaysky
2025-01-26 14:00 ` Ivan Kokshaysky
2025-01-26 19:15 ` Magnus Lindholm
2025-01-27 11:48 ` Ivan Kokshaysky
2025-01-27 11:56 ` John Paul Adrian Glaubitz
2025-01-25 18:07 ` Magnus Lindholm
2025-01-25 15:35 ` Maciej W. Rozycki
2025-01-25 17:09 ` Ivan Kokshaysky
2025-01-24 6:54 ` John Paul Adrian Glaubitz
2024-11-24 21:47 Magnus Lindholm
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=Z5U__sztq2P2UKWk@minute \
--to=ink@unseen.parts \
--cc=glaubitz@physik.fu-berlin.de \
--cc=linmag7@gmail.com \
--cc=linux-alpha@vger.kernel.org \
--cc=macro@orcam.me.uk \
--cc=mcree@orcon.net.nz \
--cc=paulmck@kernel.org \
--cc=rcu@vger.kernel.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