]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
alpha: align stack for page fault and user unaligned trap handlers
authorIvan Kokshaysky <ink@unseen.parts>
Tue, 4 Feb 2025 22:35:24 +0000 (23:35 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 13 Mar 2025 11:47:19 +0000 (12:47 +0100)
commit 3b35a171060f846b08b48646b38c30b5d57d17ff upstream.

do_page_fault() and do_entUna() are special because they use
non-standard stack frame layout. Fix them manually.

Cc: stable@vger.kernel.org
Tested-by: Maciej W. Rozycki <macro@orcam.me.uk>
Tested-by: Magnus Lindholm <linmag7@gmail.com>
Tested-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Maciej W. Rozycki <macro@orcam.me.uk>
Suggested-by: Maciej W. Rozycki <macro@orcam.me.uk>
Signed-off-by: Ivan Kokshaysky <ink@unseen.parts>
Signed-off-by: Matt Turner <mattst88@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/alpha/kernel/entry.S
arch/alpha/kernel/traps.c
arch/alpha/mm/fault.c

index c41a5a9c3b9f2351ad8c95b38820e9bd9e069d9d..351d6e60e566969d33130fd534180d42479168d7 100644 (file)
@@ -199,8 +199,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)
@@ -215,7 +215,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
@@ -228,7 +228,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
@@ -236,7 +236,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
@@ -383,8 +383,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)
@@ -400,7 +400,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)
@@ -410,7 +410,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
@@ -418,7 +418,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
 
index 751d3197ca766c4d6c7bde82cee27383f327c20b..381d026660b1518628fb5928a9103610435fd29a 100644 (file)
@@ -709,7 +709,7 @@ s_reg_to_mem (unsigned long s_reg)
 static int unauser_reg_offsets[32] = {
        R(r0), R(r1), R(r2), R(r3), R(r4), R(r5), R(r6), R(r7), R(r8),
        /* r9 ... r15 are stored in front of regs.  */
-       -56, -48, -40, -32, -24, -16, -8,
+       -64, -56, -48, -40, -32, -24, -16,      /* padding at -8 */
        R(r16), R(r17), R(r18),
        R(r19), R(r20), R(r21), R(r22), R(r23), R(r24), R(r25), R(r26),
        R(r27), R(r28), R(gp),
index 5d42f94887daf36f9cbf4c0fa5ff7cca1d404106..5fe289f115382bbafebba7186e71bb0ff0822412 100644 (file)
@@ -78,8 +78,8 @@ __load_new_mm_context(struct mm_struct *next_mm)
 
 /* Macro for exception fixup code to access integer registers.  */
 #define dpf_reg(r)                                                     \
-       (((unsigned long *)regs)[(r) <= 8 ? (r) : (r) <= 15 ? (r)-16 :  \
-                                (r) <= 18 ? (r)+10 : (r)-10])
+       (((unsigned long *)regs)[(r) <= 8 ? (r) : (r) <= 15 ? (r)-17 :  \
+                                (r) <= 18 ? (r)+11 : (r)-10])
 
 asmlinkage void
 do_page_fault(unsigned long address, unsigned long mmcsr,