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

TOMOYO Linux Cross Reference
Linux/arch/x86/include/asm/runtime-const.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_RUNTIME_CONST_H
  3 #define _ASM_RUNTIME_CONST_H
  4 
  5 #define runtime_const_ptr(sym) ({                               \
  6         typeof(sym) __ret;                                      \
  7         asm_inline("mov %1,%0\n1:\n"                            \
  8                 ".pushsection runtime_ptr_" #sym ",\"a\"\n\t"   \
  9                 ".long 1b - %c2 - .\n\t"                        \
 10                 ".popsection"                                   \
 11                 :"=r" (__ret)                                   \
 12                 :"i" ((unsigned long)0x0123456789abcdefull),    \
 13                  "i" (sizeof(long)));                           \
 14         __ret; })
 15 
 16 // The 'typeof' will create at _least_ a 32-bit type, but
 17 // will happily also take a bigger type and the 'shrl' will
 18 // clear the upper bits
 19 #define runtime_const_shift_right_32(val, sym) ({               \
 20         typeof(0u+(val)) __ret = (val);                         \
 21         asm_inline("shrl $12,%k0\n1:\n"                         \
 22                 ".pushsection runtime_shift_" #sym ",\"a\"\n\t" \
 23                 ".long 1b - 1 - .\n\t"                          \
 24                 ".popsection"                                   \
 25                 :"+r" (__ret));                                 \
 26         __ret; })
 27 
 28 #define runtime_const_init(type, sym) do {              \
 29         extern s32 __start_runtime_##type##_##sym[];    \
 30         extern s32 __stop_runtime_##type##_##sym[];     \
 31         runtime_const_fixup(__runtime_fixup_##type,     \
 32                 (unsigned long)(sym),                   \
 33                 __start_runtime_##type##_##sym,         \
 34                 __stop_runtime_##type##_##sym);         \
 35 } while (0)
 36 
 37 /*
 38  * The text patching is trivial - you can only do this at init time,
 39  * when the text section hasn't been marked RO, and before the text
 40  * has ever been executed.
 41  */
 42 static inline void __runtime_fixup_ptr(void *where, unsigned long val)
 43 {
 44         *(unsigned long *)where = val;
 45 }
 46 
 47 static inline void __runtime_fixup_shift(void *where, unsigned long val)
 48 {
 49         *(unsigned char *)where = val;
 50 }
 51 
 52 static inline void runtime_const_fixup(void (*fn)(void *, unsigned long),
 53         unsigned long val, s32 *start, s32 *end)
 54 {
 55         while (start < end) {
 56                 fn(*start + (void *)start, val);
 57                 start++;
 58         }
 59 }
 60 
 61 #endif
 62 

~ [ 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