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

mcount.S (1651B)


      1/*
      2 * arch/xtensa/kernel/mcount.S
      3 *
      4 * Xtensa specific mcount support
      5 *
      6 * This file is subject to the terms and conditions of the GNU General Public
      7 * License.  See the file "COPYING" in the main directory of this archive
      8 * for more details.
      9 *
     10 * Copyright (C) 2013 Tensilica Inc.
     11 */
     12
     13#include <linux/linkage.h>
     14#include <asm/asmmacro.h>
     15#include <asm/ftrace.h>
     16
     17/*
     18 * Entry condition:
     19 *
     20 *   a2:	a0 of the caller in windowed ABI
     21 *   a10:	a0 of the caller in call0 ABI
     22 *
     23 * In call0 ABI the function _mcount is called with the special ABI:
     24 * its argument is in a10 and all the usual argument registers (a2 - a7)
     25 * must be preserved in addition to callee-saved a12 - a15.
     26 */
     27
     28ENTRY(_mcount)
     29#if defined(__XTENSA_WINDOWED_ABI__)
     30	abi_entry_default
     31
     32	movi	a4, ftrace_trace_function
     33	l32i	a4, a4, 0
     34	movi	a3, ftrace_stub
     35	bne	a3, a4, 1f
     36	abi_ret_default
     37
     381: 	xor	a7, a2, a1
     39	movi	a3, 0x3fffffff
     40	and	a7, a7, a3
     41	xor	a7, a7, a1
     42
     43	xor	a6, a0, a1
     44	and	a6, a6, a3
     45	xor	a6, a6, a1
     46	addi	a6, a6, -MCOUNT_INSN_SIZE
     47	callx4	a4
     48
     49	abi_ret_default
     50#elif defined(__XTENSA_CALL0_ABI__)
     51	abi_entry_default
     52
     53	movi	a9, ftrace_trace_function
     54	l32i	a9, a9, 0
     55	movi	a11, ftrace_stub
     56	bne	a9, a11, 1f
     57	abi_ret_default
     58
     591:	abi_entry(28)
     60	s32i	a0, sp, 0
     61	s32i	a2, sp, 4
     62	s32i	a3, sp, 8
     63	s32i	a4, sp, 12
     64	s32i	a5, sp, 16
     65	s32i	a6, sp, 20
     66	s32i	a7, sp, 24
     67	addi	a2, a10, -MCOUNT_INSN_SIZE
     68	callx0	a9
     69	l32i	a0, sp, 0
     70	l32i	a2, sp, 4
     71	l32i	a3, sp, 8
     72	l32i	a4, sp, 12
     73	l32i	a5, sp, 16
     74	l32i	a6, sp, 20
     75	l32i	a7, sp, 24
     76	abi_ret(28)
     77#else
     78#error Unsupported Xtensa ABI
     79#endif
     80ENDPROC(_mcount)
     81
     82ENTRY(ftrace_stub)
     83	abi_entry_default
     84	abi_ret_default
     85ENDPROC(ftrace_stub)