visor/include/x86/msr.h

50 lines
1 KiB
C
Raw Normal View History

2025-03-10 19:19:53 +01:00
#ifndef _VISOR_MSR_H_
#define _VISOR_MSR_H_
#include <stdint.h>
#define IA32_FEATURE_CONTROL 0x3A
#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_VMCS_ENUM 0x48A
static inline uint32_t
rdmsr32(uint32_t msr)
{
uint32_t value;
2025-03-10 20:24:32 +01:00
__asm__ ("rdmsr\n\t" : "=a"(value) : "c"(msr) : "edx");
2025-03-10 19:19:53 +01:00
return value;
}
static inline uint64_t
rdmsr64(uint32_t msr)
{
uint64_t value;
__asm__ ("rdmsr\n\t" : "=A"(value) : "c"(msr));
return value;
}
static inline void
wrmsr32(uint32_t msr, uint32_t value)
{
uint32_t high = 0;
__asm__ ("wrmsr\n\t" :: "c"(msr), "a"(value), "d"(high));
}
static inline void
wrmsr64(uint32_t msr, uint64_t value)
{
__asm__ ("wrmsr\n\t" :: "c"(msr), "A"(value));
}
#endif