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

jump_label.h (1195B)


      1/* SPDX-License-Identifier: GPL-2.0-only */
      2/*
      3 * Copyright (C) 2013 Huawei Ltd.
      4 * Author: Jiang Liu <liuj97@gmail.com>
      5 *
      6 * Based on arch/arm/include/asm/jump_label.h
      7 */
      8#ifndef __ASM_JUMP_LABEL_H
      9#define __ASM_JUMP_LABEL_H
     10
     11#ifndef __ASSEMBLY__
     12
     13#include <linux/types.h>
     14#include <asm/insn.h>
     15
     16#define JUMP_LABEL_NOP_SIZE		AARCH64_INSN_SIZE
     17
     18static __always_inline bool arch_static_branch(struct static_key *key,
     19					       bool branch)
     20{
     21	asm_volatile_goto(
     22		"1:	nop					\n\t"
     23		 "	.pushsection	__jump_table, \"aw\"	\n\t"
     24		 "	.align		3			\n\t"
     25		 "	.long		1b - ., %l[l_yes] - .	\n\t"
     26		 "	.quad		%c0 - .			\n\t"
     27		 "	.popsection				\n\t"
     28		 :  :  "i"(&((char *)key)[branch]) :  : l_yes);
     29
     30	return false;
     31l_yes:
     32	return true;
     33}
     34
     35static __always_inline bool arch_static_branch_jump(struct static_key *key,
     36						    bool branch)
     37{
     38	asm_volatile_goto(
     39		"1:	b		%l[l_yes]		\n\t"
     40		 "	.pushsection	__jump_table, \"aw\"	\n\t"
     41		 "	.align		3			\n\t"
     42		 "	.long		1b - ., %l[l_yes] - .	\n\t"
     43		 "	.quad		%c0 - .			\n\t"
     44		 "	.popsection				\n\t"
     45		 :  :  "i"(&((char *)key)[branch]) :  : l_yes);
     46
     47	return false;
     48l_yes:
     49	return true;
     50}
     51
     52#endif  /* __ASSEMBLY__ */
     53#endif	/* __ASM_JUMP_LABEL_H */