Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef _ASM_X86_FPU_XCR_H
0003 #define _ASM_X86_FPU_XCR_H
0004 
0005 #define XCR_XFEATURE_ENABLED_MASK   0x00000000
0006 #define XCR_XFEATURE_IN_USE_MASK    0x00000001
0007 
0008 static inline u64 xgetbv(u32 index)
0009 {
0010     u32 eax, edx;
0011 
0012     asm volatile("xgetbv" : "=a" (eax), "=d" (edx) : "c" (index));
0013     return eax + ((u64)edx << 32);
0014 }
0015 
0016 static inline void xsetbv(u32 index, u64 value)
0017 {
0018     u32 eax = value;
0019     u32 edx = value >> 32;
0020 
0021     asm volatile("xsetbv" :: "a" (eax), "d" (edx), "c" (index));
0022 }
0023 
0024 /*
0025  * Return a mask of xfeatures which are currently being tracked
0026  * by the processor as being in the initial configuration.
0027  *
0028  * Callers should check X86_FEATURE_XGETBV1.
0029  */
0030 static inline u64 xfeatures_in_use(void)
0031 {
0032     return xgetbv(XCR_XFEATURE_IN_USE_MASK);
0033 }
0034 
0035 #endif /* _ASM_X86_FPU_XCR_H */