Iros
 
Loading...
Searching...
No Matches
msr.h
Go to the documentation of this file.
1#pragma once
2
3#include "di/types/prelude.h"
4
5namespace iris::x86::amd64 {
7 LocalApicBase = 0x1BU,
8 Star = 0xC0000081U,
9 LStar = 0xC0000082U,
10 CStar = 0xC0000083U,
11 SfMask = 0xC0000084U,
12 FsBase = 0xC0000100U,
13 GsBase = 0xC0000101U,
14 KernelGsBase = 0xC0000102U,
15};
16
17static inline auto read_msr(ModelSpecificRegister msr) -> u64 {
18 u32 low;
19 u32 high;
20 asm volatile("rdmsr\n" : "=a"(low), "=d"(high) : "c"(msr));
21 return u64(low) | (u64(high) << 32);
22}
23
24static inline void write_msr(ModelSpecificRegister msr, u64 value) {
25 u32 low = value;
26 u32 high = value >> 32;
27 asm volatile("wrmsr" : : "a"(low), "d"(high), "c"(msr));
28}
29}
__UINT64_TYPE__ u64
Definition integers.h:12
__UINT32_TYPE__ u32
Definition integers.h:11
Definition gdt.cpp:38
ModelSpecificRegister
Definition msr.h:6