#ifndef _VISOR_MSR_H_ #define _VISOR_MSR_H_ #include #define IA32_FEATURE_CONTROL 0x03A #define IA32_DEBUGCTL 0x1D9 #define IA32_PAT 0x277 #define IA32_VMX_BASIC 0x480 #define IA32_VMX_PINBASED_CTLS 0x481 #define IA32_VMX_PROCBASED_CTLS 0x482 #define IA32_VMX_EXIT_CTLS 0x483 #define IA32_VMX_ENTRY_CTLS 0x484 #define IA32_VMX_MISC 0x485 #define IA32_VMX_CR0_FIXED0 0x486 #define IA32_VMX_CR0_FIXED1 0x487 #define IA32_VMX_CR4_FIXED0 0x488 #define IA32_VMX_CR4_FIXED1 0x489 #define IA32_VMX_TRUE_ENTRY_CTLS 0x490 #define IA32_VMX_VMCS_ENUM 0x48A #define IA32_VMX_PROCBASED_CTLS2 0x48B #define IA32_VMX_TRUE_PINBASED_CTLS 0x48D #define IA32_VMX_TRUE_PROCBASED_CTLS 0x48E #define IA32_VMX_TRUE_EXIT_CTLS 0x48F #define IA32_EFER 0xC0000080 #define IA32_FS_BASE 0xC0000100 #define IA32_GS_BASE 0xC0000101 #define IA32_KERNEL_GS_BASE 0xC0000102 static inline uint32_t readmsr32(uint32_t msr) { uint32_t value; __asm__ ("rdmsr\n\t" : "=a"(value) : "c"(msr) : "edx"); return value; } static inline uint64_t readmsr64(uint32_t msr) { uint32_t lo, hi; __asm__ ("rdmsr\n\t" : "=a"(lo), "=d"(hi) : "c"(msr)); return lo | ((uint64_t)hi << 32); } static inline void writemsr32(uint32_t msr, uint32_t value) { uint32_t hi = 0; __asm__ ("wrmsr\n\t" :: "c"(msr), "a"(value), "d"(hi)); } static inline void writemsr64(uint32_t msr, uint64_t value) { uint32_t lo = value, hi = value >> 32; __asm__ ("wrmsr\n\t" :: "c"(msr), "a"(lo), "d"(hi)); } #endif