msr.h 662 B

1234567891011121314151617181920212223242526
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Helpers/definitions related to MSR access.
  4. */
  5. #ifndef BOOT_MSR_H
  6. #define BOOT_MSR_H
  7. #include <asm/shared/msr.h>
  8. /*
  9. * The kernel proper already defines rdmsr()/wrmsr(), but they are not for the
  10. * boot kernel since they rely on tracepoint/exception handling infrastructure
  11. * that's not available here.
  12. */
  13. static inline void boot_rdmsr(unsigned int reg, struct msr *m)
  14. {
  15. asm volatile("rdmsr" : "=a" (m->l), "=d" (m->h) : "c" (reg));
  16. }
  17. static inline void boot_wrmsr(unsigned int reg, const struct msr *m)
  18. {
  19. asm volatile("wrmsr" : : "c" (reg), "a"(m->l), "d" (m->h) : "memory");
  20. }
  21. #endif /* BOOT_MSR_H */