1 /* Portions taken from Linux arch arm64 */ 2 #ifndef __ASM_ARM64_NOSPEC_H 3 #define __ASM_ARM64_NOSPEC_H 4 5 #define csdb() asm volatile ( "hint #20" : : : "memory" ) 6 7 /* 8 * Generate a mask for array_index__nospec() that is ~0UL when 0 <= idx < sz 9 * and 0 otherwise. 10 */ array_index_mask_nospec(unsigned long idx,unsigned long sz)11static inline unsigned long array_index_mask_nospec(unsigned long idx, 12 unsigned long sz) 13 { 14 unsigned long mask; 15 16 asm volatile ( "cmp %1, %2\n" 17 "sbc %0, xzr, xzr\n" 18 : "=r" (mask) 19 : "r" (idx), "Ir" (sz) 20 : "cc" ); 21 csdb(); 22 23 return mask; 24 } 25 #define array_index_mask_nospec array_index_mask_nospec 26 27 #endif /* __ASM_ARM64_NOSPEC_H */ 28 /* 29 * Local variables: 30 * mode: C 31 * c-file-style: "BSD" 32 * c-basic-offset: 4 33 * indent-tabs-mode: nil 34 * End: 35 */ 36