This source file includes following definitions.
- clac
- stac
- smap_save
- smap_restore
- clac
- stac
- smap_save
- smap_restore
   1 
   2 
   3 
   4 
   5 
   6 
   7 
   8 
   9 #ifndef _ASM_X86_SMAP_H
  10 #define _ASM_X86_SMAP_H
  11 
  12 #include <asm/nops.h>
  13 #include <asm/cpufeatures.h>
  14 
  15 
  16 #define __ASM_CLAC      ".byte 0x0f,0x01,0xca"
  17 #define __ASM_STAC      ".byte 0x0f,0x01,0xcb"
  18 
  19 #ifdef __ASSEMBLY__
  20 
  21 #include <asm/alternative-asm.h>
  22 
  23 #ifdef CONFIG_X86_SMAP
  24 
  25 #define ASM_CLAC \
  26         ALTERNATIVE "", __ASM_CLAC, X86_FEATURE_SMAP
  27 
  28 #define ASM_STAC \
  29         ALTERNATIVE "", __ASM_STAC, X86_FEATURE_SMAP
  30 
  31 #else 
  32 
  33 #define ASM_CLAC
  34 #define ASM_STAC
  35 
  36 #endif 
  37 
  38 #else 
  39 
  40 #include <asm/alternative.h>
  41 
  42 #ifdef CONFIG_X86_SMAP
  43 
  44 static __always_inline void clac(void)
  45 {
  46         
  47         alternative("", __ASM_CLAC, X86_FEATURE_SMAP);
  48 }
  49 
  50 static __always_inline void stac(void)
  51 {
  52         
  53         alternative("", __ASM_STAC, X86_FEATURE_SMAP);
  54 }
  55 
  56 static __always_inline unsigned long smap_save(void)
  57 {
  58         unsigned long flags;
  59 
  60         asm volatile (ALTERNATIVE("", "pushf; pop %0; " __ASM_CLAC,
  61                                   X86_FEATURE_SMAP)
  62                       : "=rm" (flags) : : "memory", "cc");
  63 
  64         return flags;
  65 }
  66 
  67 static __always_inline void smap_restore(unsigned long flags)
  68 {
  69         asm volatile (ALTERNATIVE("", "push %0; popf", X86_FEATURE_SMAP)
  70                       : : "g" (flags) : "memory", "cc");
  71 }
  72 
  73 
  74 #define ASM_CLAC \
  75         ALTERNATIVE("", __ASM_CLAC, X86_FEATURE_SMAP)
  76 #define ASM_STAC \
  77         ALTERNATIVE("", __ASM_STAC, X86_FEATURE_SMAP)
  78 
  79 #else 
  80 
  81 static inline void clac(void) { }
  82 static inline void stac(void) { }
  83 
  84 static inline unsigned long smap_save(void) { return 0; }
  85 static inline void smap_restore(unsigned long flags) { }
  86 
  87 #define ASM_CLAC
  88 #define ASM_STAC
  89 
  90 #endif 
  91 
  92 #endif 
  93 
  94 #endif