~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/loongarch/include/asm/alternative-asm.h

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0 */
  2 #ifndef _ASM_ALTERNATIVE_ASM_H
  3 #define _ASM_ALTERNATIVE_ASM_H
  4 
  5 #ifdef __ASSEMBLY__
  6 
  7 #include <asm/asm.h>
  8 
  9 /*
 10  * Issue one struct alt_instr descriptor entry (need to put it into
 11  * the section .altinstructions, see below). This entry contains
 12  * enough information for the alternatives patching code to patch an
 13  * instruction. See apply_alternatives().
 14  */
 15 .macro altinstruction_entry orig alt feature orig_len alt_len
 16         .long \orig - .
 17         .long \alt - .
 18         .short \feature
 19         .byte \orig_len
 20         .byte \alt_len
 21 .endm
 22 
 23 /*
 24  * Define an alternative between two instructions. If @feature is
 25  * present, early code in apply_alternatives() replaces @oldinstr with
 26  * @newinstr. ".fill" directive takes care of proper instruction padding
 27  * in case @newinstr is longer than @oldinstr.
 28  */
 29 .macro ALTERNATIVE oldinstr, newinstr, feature
 30 140 :
 31         \oldinstr
 32 141 :
 33         .fill - (((144f-143f)-(141b-140b)) > 0) * ((144f-143f)-(141b-140b)) / 4, 4, 0x03400000
 34 142 :
 35 
 36         .pushsection .altinstructions, "a"
 37         altinstruction_entry 140b, 143f, \feature, 142b-140b, 144f-143f
 38         .popsection
 39 
 40         .subsection 1
 41 143 :
 42         \newinstr
 43 144 :
 44         .previous
 45 .endm
 46 
 47 #define old_len                 (141b-140b)
 48 #define new_len1                (144f-143f)
 49 #define new_len2                (145f-144f)
 50 
 51 #define alt_max_short(a, b)     ((a) ^ (((a) ^ (b)) & -(-((a) < (b)))))
 52 
 53 /*
 54  * Same as ALTERNATIVE macro above but for two alternatives. If CPU
 55  * has @feature1, it replaces @oldinstr with @newinstr1. If CPU has
 56  * @feature2, it replaces @oldinstr with @feature2.
 57  */
 58 .macro ALTERNATIVE_2 oldinstr, newinstr1, feature1, newinstr2, feature2
 59 140 :
 60         \oldinstr
 61 141 :
 62         .fill - ((alt_max_short(new_len1, new_len2) - (old_len)) > 0) * \
 63                 (alt_max_short(new_len1, new_len2) - (old_len)) / 4, 4, 0x03400000
 64 142 :
 65 
 66         .pushsection .altinstructions, "a"
 67         altinstruction_entry 140b, 143f, \feature1, 142b-140b, 144f-143f, 142b-141b
 68         altinstruction_entry 140b, 144f, \feature2, 142b-140b, 145f-144f, 142b-141b
 69         .popsection
 70 
 71         .subsection 1
 72 143 :
 73         \newinstr1
 74 144 :
 75         \newinstr2
 76 145 :
 77         .previous
 78 .endm
 79 
 80 #endif  /*  __ASSEMBLY__  */
 81 
 82 #endif /* _ASM_ALTERNATIVE_ASM_H */
 83 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php