xcr.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /* -*- linux-c -*- ------------------------------------------------------- *
  2. *
  3. * Copyright 2008 rPath, Inc. - All Rights Reserved
  4. *
  5. * This file is part of the Linux kernel, and is made available under
  6. * the terms of the GNU General Public License version 2 or (at your
  7. * option) any later version; incorporated herein by reference.
  8. *
  9. * ----------------------------------------------------------------------- */
  10. /*
  11. * asm-x86/xcr.h
  12. *
  13. * Definitions for the eXtended Control Register instructions
  14. */
  15. #ifndef _ASM_X86_XCR_H
  16. #define _ASM_X86_XCR_H
  17. #define XCR_XFEATURE_ENABLED_MASK 0x00000000
  18. #ifdef __KERNEL__
  19. # ifndef __ASSEMBLY__
  20. #include <linux/types.h>
  21. static inline u64 xgetbv(u32 index)
  22. {
  23. u32 eax, edx;
  24. asm volatile(".byte 0x0f,0x01,0xd0" /* xgetbv */
  25. : "=a" (eax), "=d" (edx)
  26. : "c" (index));
  27. return eax + ((u64)edx << 32);
  28. }
  29. static inline void xsetbv(u32 index, u64 value)
  30. {
  31. u32 eax = value;
  32. u32 edx = value >> 32;
  33. asm volatile(".byte 0x0f,0x01,0xd1" /* xsetbv */
  34. : : "a" (eax), "d" (edx), "c" (index));
  35. }
  36. # endif /* __ASSEMBLY__ */
  37. #endif /* __KERNEL__ */
  38. #endif /* _ASM_X86_XCR_H */