2025-03-10 19:19:53 +01:00
|
|
|
#ifndef _VISOR_CR_H_
|
|
|
|
|
#define _VISOR_CR_H_
|
|
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
2025-03-10 20:24:32 +01:00
|
|
|
#define CR4_VMXE (1 << 13)
|
|
|
|
|
|
2025-03-10 19:19:53 +01:00
|
|
|
static inline uint64_t
|
|
|
|
|
readcr0(void)
|
|
|
|
|
{
|
|
|
|
|
uint64_t v;
|
|
|
|
|
__asm__ ("mov %%cr0, %0\n\t" : "=a"(v));
|
|
|
|
|
return v;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline uint64_t
|
|
|
|
|
readcr3(void)
|
|
|
|
|
{
|
|
|
|
|
uint64_t v;
|
|
|
|
|
__asm__ ("mov %%cr3, %0\n\t" : "=a"(v));
|
|
|
|
|
return v;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline uint64_t
|
|
|
|
|
readcr4(void)
|
|
|
|
|
{
|
|
|
|
|
uint64_t v;
|
|
|
|
|
__asm__ ("mov %%cr4, %0\n\t" : "=a"(v));
|
|
|
|
|
return v;
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-10 20:24:32 +01:00
|
|
|
static inline void
|
|
|
|
|
writecr4(uint64_t v)
|
|
|
|
|
{
|
|
|
|
|
__asm__ ("mov %0, %%cr4\n\t" :: "a"(v));
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-10 19:19:53 +01:00
|
|
|
#endif
|