xref: /openbmc/linux/arch/x86/entry/thunk_32.S (revision 4f2c0a4acffbec01079c28f839422e64ddeff004)
13f520cd2SThomas Gleixner/* SPDX-License-Identifier: GPL-2.0-only */
2e6b93f4eSIngo Molnar/*
3e6b93f4eSIngo Molnar * Trampoline to trace irqs off. (otherwise CALLER_ADDR1 might crash)
4e6b93f4eSIngo Molnar * Copyright 2008 by Steven Rostedt, Red Hat, Inc
5e6b93f4eSIngo Molnar *  (inspired by Andi Kleen's thunk_64.S)
6e6b93f4eSIngo Molnar */
7e6b93f4eSIngo Molnar	#include <linux/linkage.h>
8e6b93f4eSIngo Molnar	#include <asm/asm.h>
9784d5699SAl Viro	#include <asm/export.h>
10e6b93f4eSIngo Molnar
11e6b93f4eSIngo Molnar	/* put return address in eax (arg1) */
12e6b93f4eSIngo Molnar	.macro THUNK name, func, put_ret_addr_in_eax=0
1376dc6d60SJiri SlabySYM_CODE_START_NOALIGN(\name)
14e6b93f4eSIngo Molnar	pushl %eax
15e6b93f4eSIngo Molnar	pushl %ecx
16e6b93f4eSIngo Molnar	pushl %edx
17e6b93f4eSIngo Molnar
18e6b93f4eSIngo Molnar	.if \put_ret_addr_in_eax
19e6b93f4eSIngo Molnar	/* Place EIP in the arg1 */
20e6b93f4eSIngo Molnar	movl 3*4(%esp), %eax
21e6b93f4eSIngo Molnar	.endif
22e6b93f4eSIngo Molnar
23e6b93f4eSIngo Molnar	call \func
24e6b93f4eSIngo Molnar	popl %edx
25e6b93f4eSIngo Molnar	popl %ecx
26e6b93f4eSIngo Molnar	popl %eax
27*f94909ceSPeter Zijlstra	RET
28e6b93f4eSIngo Molnar	_ASM_NOKPROBE(\name)
2976dc6d60SJiri SlabySYM_CODE_END(\name)
30e6b93f4eSIngo Molnar	.endm
31e6b93f4eSIngo Molnar
3246db36abSPeter Zijlstra	THUNK preempt_schedule_thunk, preempt_schedule
3346db36abSPeter Zijlstra	THUNK preempt_schedule_notrace_thunk, preempt_schedule_notrace
3446db36abSPeter Zijlstra	EXPORT_SYMBOL(preempt_schedule_thunk)
3546db36abSPeter Zijlstra	EXPORT_SYMBOL(preempt_schedule_notrace_thunk)
36e6b93f4eSIngo Molnar
37