From 6b6133186d9eb1fb076e63013b1ed3bdaebea973 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Mon, 29 Jul 2024 01:28:58 -0400 Subject: kernel/amd64: Facilitate IA32_FS_BASE reads/writes Signed-off-by: Ian Moffett --- sys/include/arch/amd64/asm.h | 12 ++++++++++++ sys/include/arch/amd64/msr.h | 1 + 2 files changed, 13 insertions(+) (limited to 'sys/include') diff --git a/sys/include/arch/amd64/asm.h b/sys/include/arch/amd64/asm.h index e85dd87..04d5e42 100644 --- a/sys/include/arch/amd64/asm.h +++ b/sys/include/arch/amd64/asm.h @@ -70,6 +70,18 @@ amd64_read_gs_base(void) return rdmsr(IA32_KERNEL_GS_BASE); } +static inline void +amd64_write_fs_base(uintptr_t val) +{ + wrmsr(IA32_FS_BASE, val); +} + +static inline uintptr_t +amd64_read_fs_base(uintptr_t val) +{ + return rdmsr(IA32_FS_BASE); +} + static inline uint64_t amd64_read_cr0(void) { diff --git a/sys/include/arch/amd64/msr.h b/sys/include/arch/amd64/msr.h index d3d0c9a..fe5814b 100644 --- a/sys/include/arch/amd64/msr.h +++ b/sys/include/arch/amd64/msr.h @@ -32,6 +32,7 @@ #define IA32_SPEC_CTL 0x00000048 #define IA32_KERNEL_GS_BASE 0xC0000102 +#define IA32_FS_BASE 0xC0000100 #define IA32_APIC_BASE_MSR 0x0000001B #if !defined(__ASSEMBLER__) -- cgit v1.2.3