]> www.infradead.org Git - users/willy/pagecache.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)
committerMatt Turner <mattst88@gmail.com>
Fri, 14 Feb 2025 19:06:04 +0000 (14:06 -0500)
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>
arch/alpha/kernel/entry.S
arch/alpha/kernel/traps.c
arch/alpha/mm/fault.c

index 6fb38365539d45f3b596313e38a94fff047e8ba2..f4d41b4538c2e892b236e514e93639024dbfd7d8 100644 (file)
@@ -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
 
index a9a38c80c4a7af92c5504cdfa6f9110b0c34f0a9..7004397937cfda280e3640391cc023589f68c6a6 100644 (file)
@@ -649,7 +649,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 8c9850437e674451576c27388e0f6fe7b8780758..a9816bbc9f34d37e8fd78a362cbefaaf275865d2 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,