From 8251da342161767fe203627223ccd4a7026701c6 Mon Sep 17 00:00:00 2001 From: Jon Santmyer Date: Fri, 4 Sep 2026 11:31:40 -0400 Subject: initial commit. working on tasking --- arch/x86_64/hal/msr.h | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 arch/x86_64/hal/msr.h (limited to 'arch/x86_64/hal/msr.h') diff --git a/arch/x86_64/hal/msr.h b/arch/x86_64/hal/msr.h new file mode 100644 index 0000000..69d96be --- /dev/null +++ b/arch/x86_64/hal/msr.h @@ -0,0 +1,48 @@ +#ifndef _JOVE_x86_64_HAL_MSR_H +#define _JOVE_x86_64_HAL_MSR_H 1 + +#include + +#define MSR_FS_BASE 0xC0000100 +#define MSR_GS_BASE 0xC0000101 +#define MSR_KGS_BASE 0xC0000102 + +#define MSR_EFER 0xC0000080 +#define MSR_EFER_SCE 0b1 + +#define MSR_STAR 0xC0000081 +#define MSR_LSTAR 0xC0000082 +#define MSR_SFMASK 0xC0000084 + +union msr_gs_base +{ + uintptr_t gs; + uint32_t v[2]; +}; + +union msr_star +{ + struct { + uint32_t eip; + uint16_t kcs; + uint16_t ucs; + }; + uint16_t v[2]; +}; + +union msr_lstar +{ + void *rip; + uint32_t v[2]; +}; + +void msr_set_gs_base(uintptr_t gs_base); +uintptr_t msr_get_gs_base(void); + +void msr_enable_sce(void); +void msr_set_lstar(void *syscall_entry); + +void msr_read(uint32_t msr, uint32_t *lo, uint32_t *hi); +void msr_write(uint32_t msr, uint32_t lo, uint32_t hi); + +#endif -- cgit v1.2.3