cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

kprobes_trampoline.S (1852B)


      1/* SPDX-License-Identifier: GPL-2.0 */
      2/*
      3 * trampoline entry and return code for kretprobes.
      4 */
      5
      6#include <linux/linkage.h>
      7#include <asm/asm-offsets.h>
      8#include <asm/assembler.h>
      9
     10	.text
     11
     12	.macro	save_all_base_regs
     13	stp x0, x1, [sp, #S_X0]
     14	stp x2, x3, [sp, #S_X2]
     15	stp x4, x5, [sp, #S_X4]
     16	stp x6, x7, [sp, #S_X6]
     17	stp x8, x9, [sp, #S_X8]
     18	stp x10, x11, [sp, #S_X10]
     19	stp x12, x13, [sp, #S_X12]
     20	stp x14, x15, [sp, #S_X14]
     21	stp x16, x17, [sp, #S_X16]
     22	stp x18, x19, [sp, #S_X18]
     23	stp x20, x21, [sp, #S_X20]
     24	stp x22, x23, [sp, #S_X22]
     25	stp x24, x25, [sp, #S_X24]
     26	stp x26, x27, [sp, #S_X26]
     27	stp x28, x29, [sp, #S_X28]
     28	add x0, sp, #PT_REGS_SIZE
     29	stp lr, x0, [sp, #S_LR]
     30	/*
     31	 * Construct a useful saved PSTATE
     32	 */
     33	mrs x0, nzcv
     34	mrs x1, daif
     35	orr x0, x0, x1
     36	mrs x1, CurrentEL
     37	orr x0, x0, x1
     38	mrs x1, SPSel
     39	orr x0, x0, x1
     40	stp xzr, x0, [sp, #S_PC]
     41	.endm
     42
     43	.macro	restore_all_base_regs
     44	ldr x0, [sp, #S_PSTATE]
     45	and x0, x0, #(PSR_N_BIT | PSR_Z_BIT | PSR_C_BIT | PSR_V_BIT)
     46	msr nzcv, x0
     47	ldp x0, x1, [sp, #S_X0]
     48	ldp x2, x3, [sp, #S_X2]
     49	ldp x4, x5, [sp, #S_X4]
     50	ldp x6, x7, [sp, #S_X6]
     51	ldp x8, x9, [sp, #S_X8]
     52	ldp x10, x11, [sp, #S_X10]
     53	ldp x12, x13, [sp, #S_X12]
     54	ldp x14, x15, [sp, #S_X14]
     55	ldp x16, x17, [sp, #S_X16]
     56	ldp x18, x19, [sp, #S_X18]
     57	ldp x20, x21, [sp, #S_X20]
     58	ldp x22, x23, [sp, #S_X22]
     59	ldp x24, x25, [sp, #S_X24]
     60	ldp x26, x27, [sp, #S_X26]
     61	ldp x28, x29, [sp, #S_X28]
     62	.endm
     63
     64SYM_CODE_START(__kretprobe_trampoline)
     65	sub sp, sp, #PT_REGS_SIZE
     66
     67	save_all_base_regs
     68
     69	/* Setup a frame pointer. */
     70	add x29, sp, #S_FP
     71
     72	mov x0, sp
     73	bl trampoline_probe_handler
     74	/*
     75	 * Replace trampoline address in lr with actual orig_ret_addr return
     76	 * address.
     77	 */
     78	mov lr, x0
     79
     80	/* The frame pointer (x29) is restored with other registers. */
     81	restore_all_base_regs
     82
     83	add sp, sp, #PT_REGS_SIZE
     84	ret
     85
     86SYM_CODE_END(__kretprobe_trampoline)