1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_FSGSBASE_H
3 #define _ASM_FSGSBASE_H
9 #include <asm/msr-index.h>
12 * Read/write a task's FSBASE or GSBASE. This returns the value that
13 * the FS/GS base would have (if the task were to be resumed). These
14 * work on the current task or on a non-running (typically stopped
17 extern unsigned long x86_fsbase_read_task(struct task_struct
*task
);
18 extern unsigned long x86_gsbase_read_task(struct task_struct
*task
);
19 extern void x86_fsbase_write_task(struct task_struct
*task
, unsigned long fsbase
);
20 extern void x86_gsbase_write_task(struct task_struct
*task
, unsigned long gsbase
);
22 /* Helper functions for reading/writing FS/GS base */
24 static inline unsigned long x86_fsbase_read_cpu(void)
28 rdmsrl(MSR_FS_BASE
, fsbase
);
33 static inline unsigned long x86_gsbase_read_cpu_inactive(void)
37 rdmsrl(MSR_KERNEL_GS_BASE
, gsbase
);
42 static inline void x86_fsbase_write_cpu(unsigned long fsbase
)
44 wrmsrl(MSR_FS_BASE
, fsbase
);
47 static inline void x86_gsbase_write_cpu_inactive(unsigned long gsbase
)
49 wrmsrl(MSR_KERNEL_GS_BASE
, gsbase
);
52 #endif /* CONFIG_X86_64 */
54 #endif /* __ASSEMBLY__ */
56 #endif /* _ASM_FSGSBASE_H */