1*c7bc2a8fSRichard Henderson/* 2*c7bc2a8fSRichard Henderson * hppa linux kernel vdso replacement. 3*c7bc2a8fSRichard Henderson * 4*c7bc2a8fSRichard Henderson * Copyright 2023 Linaro, Ltd. 5*c7bc2a8fSRichard Henderson * 6*c7bc2a8fSRichard Henderson * SPDX-License-Identifier: GPL-2.0-or-later 7*c7bc2a8fSRichard Henderson */ 8*c7bc2a8fSRichard Henderson 9*c7bc2a8fSRichard Henderson#include <asm/unistd.h> 10*c7bc2a8fSRichard Henderson#include "vdso-asmoffset.h" 11*c7bc2a8fSRichard Henderson 12*c7bc2a8fSRichard Henderson .text 13*c7bc2a8fSRichard Henderson 14*c7bc2a8fSRichard Henderson 15*c7bc2a8fSRichard Henderson/* 16*c7bc2a8fSRichard Henderson * arch/parisc/kernel/vdso32/sigtramp.S: 17*c7bc2a8fSRichard Henderson * Gdb expects the trampoline is on the stack and the pc is offset from 18*c7bc2a8fSRichard Henderson * a 64-byte boundary by 0, 4 or 5 instructions. Since the vdso trampoline 19*c7bc2a8fSRichard Henderson * is not on the stack, we need a new variant with different offsets and 20*c7bc2a8fSRichard Henderson * data to tell gdb where to find the signal context on the stack. 21*c7bc2a8fSRichard Henderson * 22*c7bc2a8fSRichard Henderson * Here we put the offset to the context data at the start of the trampoline 23*c7bc2a8fSRichard Henderson * region and offset the first trampoline by 2 instructions. Please do 24*c7bc2a8fSRichard Henderson * not change the trampoline as the code in gdb depends on the following 25*c7bc2a8fSRichard Henderson * instruction sequence exactly. 26*c7bc2a8fSRichard Henderson */ 27*c7bc2a8fSRichard Henderson 28*c7bc2a8fSRichard Henderson/* arch/parisc/kernel/asm-offsets.c */ 29*c7bc2a8fSRichard Henderson#define SIGFRAME_CONTEXT_REGS32 \ 30*c7bc2a8fSRichard Henderson (offsetof_sigcontext - PARISC_RT_SIGFRAME_SIZE32) 31*c7bc2a8fSRichard Henderson 32*c7bc2a8fSRichard Henderson .align 64 33*c7bc2a8fSRichard Henderson .word SIGFRAME_CONTEXT_REGS32 34*c7bc2a8fSRichard Henderson 35*c7bc2a8fSRichard Henderson/* 36*c7bc2a8fSRichard Henderson * All that said, we can provide a proper unwind record, which means that 37*c7bc2a8fSRichard Henderson * GDB should not actually need the offset magic. 38*c7bc2a8fSRichard Henderson * 39*c7bc2a8fSRichard Henderson * The return address that arrived here, from the inner frame, is 40*c7bc2a8fSRichard Henderson * not marked as a signal frame and so the unwinder still tries to 41*c7bc2a8fSRichard Henderson * subtract 1 to examine the presumed call insn. Thus we must 42*c7bc2a8fSRichard Henderson * extend the unwind info to a nop before the start. 43*c7bc2a8fSRichard Henderson */ 44*c7bc2a8fSRichard Henderson 45*c7bc2a8fSRichard Henderson .cfi_startproc simple 46*c7bc2a8fSRichard Henderson .cfi_signal_frame 47*c7bc2a8fSRichard Henderson 48*c7bc2a8fSRichard Henderson /* Compare pa32_fallback_frame_state from libgcc. */ 49*c7bc2a8fSRichard Henderson 50*c7bc2a8fSRichard Henderson /* 51*c7bc2a8fSRichard Henderson * Place the CFA at the start of sigcontext for convenience. 52*c7bc2a8fSRichard Henderson * The previous CFA will be restored from the saved stack pointer. 53*c7bc2a8fSRichard Henderson */ 54*c7bc2a8fSRichard Henderson .cfi_def_cfa 30, -PARISC_RT_SIGFRAME_SIZE32 + offsetof_sigcontext 55*c7bc2a8fSRichard Henderson 56*c7bc2a8fSRichard Henderson /* Record save offset of general registers. */ 57*c7bc2a8fSRichard Henderson .cfi_offset 1, offsetof_sigcontext_gr + 1 * 4 58*c7bc2a8fSRichard Henderson .cfi_offset 2, offsetof_sigcontext_gr + 2 * 4 59*c7bc2a8fSRichard Henderson .cfi_offset 3, offsetof_sigcontext_gr + 3 * 4 60*c7bc2a8fSRichard Henderson .cfi_offset 4, offsetof_sigcontext_gr + 4 * 4 61*c7bc2a8fSRichard Henderson .cfi_offset 5, offsetof_sigcontext_gr + 5 * 4 62*c7bc2a8fSRichard Henderson .cfi_offset 6, offsetof_sigcontext_gr + 6 * 4 63*c7bc2a8fSRichard Henderson .cfi_offset 7, offsetof_sigcontext_gr + 7 * 4 64*c7bc2a8fSRichard Henderson .cfi_offset 8, offsetof_sigcontext_gr + 8 * 4 65*c7bc2a8fSRichard Henderson .cfi_offset 9, offsetof_sigcontext_gr + 9 * 4 66*c7bc2a8fSRichard Henderson .cfi_offset 10, offsetof_sigcontext_gr + 10 * 4 67*c7bc2a8fSRichard Henderson .cfi_offset 11, offsetof_sigcontext_gr + 11 * 4 68*c7bc2a8fSRichard Henderson .cfi_offset 12, offsetof_sigcontext_gr + 12 * 4 69*c7bc2a8fSRichard Henderson .cfi_offset 13, offsetof_sigcontext_gr + 13 * 4 70*c7bc2a8fSRichard Henderson .cfi_offset 14, offsetof_sigcontext_gr + 14 * 4 71*c7bc2a8fSRichard Henderson .cfi_offset 15, offsetof_sigcontext_gr + 15 * 4 72*c7bc2a8fSRichard Henderson .cfi_offset 16, offsetof_sigcontext_gr + 16 * 4 73*c7bc2a8fSRichard Henderson .cfi_offset 17, offsetof_sigcontext_gr + 17 * 4 74*c7bc2a8fSRichard Henderson .cfi_offset 18, offsetof_sigcontext_gr + 18 * 4 75*c7bc2a8fSRichard Henderson .cfi_offset 19, offsetof_sigcontext_gr + 19 * 4 76*c7bc2a8fSRichard Henderson .cfi_offset 20, offsetof_sigcontext_gr + 20 * 4 77*c7bc2a8fSRichard Henderson .cfi_offset 21, offsetof_sigcontext_gr + 21 * 4 78*c7bc2a8fSRichard Henderson .cfi_offset 22, offsetof_sigcontext_gr + 22 * 4 79*c7bc2a8fSRichard Henderson .cfi_offset 23, offsetof_sigcontext_gr + 23 * 4 80*c7bc2a8fSRichard Henderson .cfi_offset 24, offsetof_sigcontext_gr + 24 * 4 81*c7bc2a8fSRichard Henderson .cfi_offset 25, offsetof_sigcontext_gr + 25 * 4 82*c7bc2a8fSRichard Henderson .cfi_offset 26, offsetof_sigcontext_gr + 26 * 4 83*c7bc2a8fSRichard Henderson .cfi_offset 27, offsetof_sigcontext_gr + 27 * 4 84*c7bc2a8fSRichard Henderson .cfi_offset 28, offsetof_sigcontext_gr + 28 * 4 85*c7bc2a8fSRichard Henderson .cfi_offset 29, offsetof_sigcontext_gr + 29 * 4 86*c7bc2a8fSRichard Henderson .cfi_offset 30, offsetof_sigcontext_gr + 30 * 4 87*c7bc2a8fSRichard Henderson .cfi_offset 31, offsetof_sigcontext_gr + 31 * 4 88*c7bc2a8fSRichard Henderson 89*c7bc2a8fSRichard Henderson /* Record save offset of fp registers, left and right halves. */ 90*c7bc2a8fSRichard Henderson .cfi_offset 32, offsetof_sigcontext_fr + 4 * 8 91*c7bc2a8fSRichard Henderson .cfi_offset 33, offsetof_sigcontext_fr + 4 * 8 + 4 92*c7bc2a8fSRichard Henderson .cfi_offset 34, offsetof_sigcontext_fr + 5 * 8 93*c7bc2a8fSRichard Henderson .cfi_offset 35, offsetof_sigcontext_fr + 5 * 8 + 4 94*c7bc2a8fSRichard Henderson .cfi_offset 36, offsetof_sigcontext_fr + 6 * 8 95*c7bc2a8fSRichard Henderson .cfi_offset 37, offsetof_sigcontext_fr + 6 * 8 + 4 96*c7bc2a8fSRichard Henderson .cfi_offset 38, offsetof_sigcontext_fr + 7 * 8 97*c7bc2a8fSRichard Henderson .cfi_offset 39, offsetof_sigcontext_fr + 7 * 8 + 4 98*c7bc2a8fSRichard Henderson .cfi_offset 40, offsetof_sigcontext_fr + 8 * 8 99*c7bc2a8fSRichard Henderson .cfi_offset 41, offsetof_sigcontext_fr + 8 * 8 + 4 100*c7bc2a8fSRichard Henderson .cfi_offset 42, offsetof_sigcontext_fr + 9 * 8 101*c7bc2a8fSRichard Henderson .cfi_offset 43, offsetof_sigcontext_fr + 9 * 8 + 4 102*c7bc2a8fSRichard Henderson .cfi_offset 44, offsetof_sigcontext_fr + 10 * 8 103*c7bc2a8fSRichard Henderson .cfi_offset 45, offsetof_sigcontext_fr + 10 * 8 + 4 104*c7bc2a8fSRichard Henderson .cfi_offset 46, offsetof_sigcontext_fr + 11 * 8 105*c7bc2a8fSRichard Henderson .cfi_offset 47, offsetof_sigcontext_fr + 11 * 8 + 4 106*c7bc2a8fSRichard Henderson .cfi_offset 48, offsetof_sigcontext_fr + 12 * 8 107*c7bc2a8fSRichard Henderson .cfi_offset 49, offsetof_sigcontext_fr + 12 * 8 + 4 108*c7bc2a8fSRichard Henderson .cfi_offset 50, offsetof_sigcontext_fr + 13 * 8 109*c7bc2a8fSRichard Henderson .cfi_offset 51, offsetof_sigcontext_fr + 13 * 8 + 4 110*c7bc2a8fSRichard Henderson .cfi_offset 52, offsetof_sigcontext_fr + 14 * 8 111*c7bc2a8fSRichard Henderson .cfi_offset 53, offsetof_sigcontext_fr + 14 * 8 + 4 112*c7bc2a8fSRichard Henderson .cfi_offset 54, offsetof_sigcontext_fr + 15 * 8 113*c7bc2a8fSRichard Henderson .cfi_offset 55, offsetof_sigcontext_fr + 15 * 8 + 4 114*c7bc2a8fSRichard Henderson .cfi_offset 56, offsetof_sigcontext_fr + 16 * 8 115*c7bc2a8fSRichard Henderson .cfi_offset 57, offsetof_sigcontext_fr + 16 * 8 + 4 116*c7bc2a8fSRichard Henderson .cfi_offset 58, offsetof_sigcontext_fr + 17 * 8 117*c7bc2a8fSRichard Henderson .cfi_offset 59, offsetof_sigcontext_fr + 17 * 8 + 4 118*c7bc2a8fSRichard Henderson .cfi_offset 60, offsetof_sigcontext_fr + 18 * 8 119*c7bc2a8fSRichard Henderson .cfi_offset 61, offsetof_sigcontext_fr + 18 * 8 + 4 120*c7bc2a8fSRichard Henderson .cfi_offset 62, offsetof_sigcontext_fr + 19 * 8 121*c7bc2a8fSRichard Henderson .cfi_offset 63, offsetof_sigcontext_fr + 19 * 8 + 4 122*c7bc2a8fSRichard Henderson .cfi_offset 64, offsetof_sigcontext_fr + 20 * 8 123*c7bc2a8fSRichard Henderson .cfi_offset 65, offsetof_sigcontext_fr + 20 * 8 + 4 124*c7bc2a8fSRichard Henderson .cfi_offset 66, offsetof_sigcontext_fr + 21 * 8 125*c7bc2a8fSRichard Henderson .cfi_offset 67, offsetof_sigcontext_fr + 21 * 8 + 4 126*c7bc2a8fSRichard Henderson .cfi_offset 68, offsetof_sigcontext_fr + 22 * 8 127*c7bc2a8fSRichard Henderson .cfi_offset 69, offsetof_sigcontext_fr + 22 * 8 + 4 128*c7bc2a8fSRichard Henderson .cfi_offset 70, offsetof_sigcontext_fr + 23 * 8 129*c7bc2a8fSRichard Henderson .cfi_offset 71, offsetof_sigcontext_fr + 23 * 8 + 4 130*c7bc2a8fSRichard Henderson .cfi_offset 72, offsetof_sigcontext_fr + 24 * 8 131*c7bc2a8fSRichard Henderson .cfi_offset 73, offsetof_sigcontext_fr + 24 * 8 + 4 132*c7bc2a8fSRichard Henderson .cfi_offset 74, offsetof_sigcontext_fr + 25 * 8 133*c7bc2a8fSRichard Henderson .cfi_offset 75, offsetof_sigcontext_fr + 25 * 8 + 4 134*c7bc2a8fSRichard Henderson .cfi_offset 76, offsetof_sigcontext_fr + 26 * 8 135*c7bc2a8fSRichard Henderson .cfi_offset 77, offsetof_sigcontext_fr + 26 * 8 + 4 136*c7bc2a8fSRichard Henderson .cfi_offset 78, offsetof_sigcontext_fr + 27 * 8 137*c7bc2a8fSRichard Henderson .cfi_offset 79, offsetof_sigcontext_fr + 27 * 8 + 4 138*c7bc2a8fSRichard Henderson .cfi_offset 80, offsetof_sigcontext_fr + 28 * 8 139*c7bc2a8fSRichard Henderson .cfi_offset 81, offsetof_sigcontext_fr + 28 * 8 + 4 140*c7bc2a8fSRichard Henderson .cfi_offset 82, offsetof_sigcontext_fr + 29 * 8 141*c7bc2a8fSRichard Henderson .cfi_offset 83, offsetof_sigcontext_fr + 29 * 8 + 4 142*c7bc2a8fSRichard Henderson .cfi_offset 84, offsetof_sigcontext_fr + 30 * 8 143*c7bc2a8fSRichard Henderson .cfi_offset 85, offsetof_sigcontext_fr + 30 * 8 + 4 144*c7bc2a8fSRichard Henderson .cfi_offset 86, offsetof_sigcontext_fr + 31 * 8 145*c7bc2a8fSRichard Henderson .cfi_offset 87, offsetof_sigcontext_fr + 31 * 8 + 4 146*c7bc2a8fSRichard Henderson 147*c7bc2a8fSRichard Henderson /* Record save offset of %sar */ 148*c7bc2a8fSRichard Henderson .cfi_offset 88, offsetof_sigcontext_sar 149*c7bc2a8fSRichard Henderson 150*c7bc2a8fSRichard Henderson /* Record save offset of return address, iaoq[0]. */ 151*c7bc2a8fSRichard Henderson .cfi_return_column 89 152*c7bc2a8fSRichard Henderson .cfi_offset 89, offsetof_sigcontext_iaoq 153*c7bc2a8fSRichard Henderson 154*c7bc2a8fSRichard Henderson nop 155*c7bc2a8fSRichard Henderson 156*c7bc2a8fSRichard Henderson__kernel_sigtramp_rt: 157*c7bc2a8fSRichard Henderson ldi 0, %r25 158*c7bc2a8fSRichard Henderson ldi __NR_rt_sigreturn, %r20 159*c7bc2a8fSRichard Henderson be,l 0x100(%sr2, %r0), %sr0, %r31 160*c7bc2a8fSRichard Henderson nop 161*c7bc2a8fSRichard Henderson 162*c7bc2a8fSRichard Henderson .cfi_endproc 163*c7bc2a8fSRichard Henderson .size __kernel_sigtramp_rt, . - __kernel_sigtramp_rt 164*c7bc2a8fSRichard Henderson .type __kernel_sigtramp_rt, @function 165*c7bc2a8fSRichard Henderson .globl __kernel_sigtramp_rt 166