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

thunk_64.S (1159B)


      1/* SPDX-License-Identifier: GPL-2.0-only */
      2/*
      3 * Save registers before calling assembly functions. This avoids
      4 * disturbance of register allocation in some inline assembly constructs.
      5 * Copyright 2001,2002 by Andi Kleen, SuSE Labs.
      6 */
      7#include <linux/linkage.h>
      8#include "calling.h"
      9#include <asm/asm.h>
     10#include <asm/export.h>
     11
     12	/* rdi:	arg1 ... normal C conventions. rax is saved/restored. */
     13	.macro THUNK name, func
     14SYM_FUNC_START_NOALIGN(\name)
     15	pushq %rbp
     16	movq %rsp, %rbp
     17
     18	pushq %rdi
     19	pushq %rsi
     20	pushq %rdx
     21	pushq %rcx
     22	pushq %rax
     23	pushq %r8
     24	pushq %r9
     25	pushq %r10
     26	pushq %r11
     27
     28	call \func
     29	jmp  __thunk_restore
     30SYM_FUNC_END(\name)
     31	_ASM_NOKPROBE(\name)
     32	.endm
     33
     34#ifdef CONFIG_PREEMPTION
     35	THUNK preempt_schedule_thunk, preempt_schedule
     36	THUNK preempt_schedule_notrace_thunk, preempt_schedule_notrace
     37	EXPORT_SYMBOL(preempt_schedule_thunk)
     38	EXPORT_SYMBOL(preempt_schedule_notrace_thunk)
     39#endif
     40
     41#ifdef CONFIG_PREEMPTION
     42SYM_CODE_START_LOCAL_NOALIGN(__thunk_restore)
     43	popq %r11
     44	popq %r10
     45	popq %r9
     46	popq %r8
     47	popq %rax
     48	popq %rcx
     49	popq %rdx
     50	popq %rsi
     51	popq %rdi
     52	popq %rbp
     53	RET
     54	_ASM_NOKPROBE(__thunk_restore)
     55SYM_CODE_END(__thunk_restore)
     56#endif