2018-09-19 06:08:53 +07:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
|
|
|
#ifndef _ASM_FSGSBASE_H
|
2018-10-08 15:41:59 +07:00
|
|
|
#define _ASM_FSGSBASE_H
|
2018-09-19 06:08:53 +07:00
|
|
|
|
|
|
|
#ifndef __ASSEMBLY__
|
|
|
|
|
|
|
|
#ifdef CONFIG_X86_64
|
|
|
|
|
|
|
|
#include <asm/msr-index.h>
|
|
|
|
|
|
|
|
/*
|
2018-10-08 15:41:59 +07:00
|
|
|
* Read/write a task's FSBASE or GSBASE. This returns the value that
|
2018-09-19 06:08:53 +07:00
|
|
|
* the FS/GS base would have (if the task were to be resumed). These
|
2018-10-08 15:41:59 +07:00
|
|
|
* work on the current task or on a non-running (typically stopped
|
|
|
|
* ptrace child) task.
|
2018-09-19 06:08:53 +07:00
|
|
|
*/
|
2018-10-08 15:41:59 +07:00
|
|
|
extern unsigned long x86_fsbase_read_task(struct task_struct *task);
|
|
|
|
extern unsigned long x86_gsbase_read_task(struct task_struct *task);
|
2018-11-27 02:55:24 +07:00
|
|
|
extern void x86_fsbase_write_task(struct task_struct *task, unsigned long fsbase);
|
|
|
|
extern void x86_gsbase_write_task(struct task_struct *task, unsigned long gsbase);
|
2018-09-19 06:08:53 +07:00
|
|
|
|
|
|
|
/* Helper functions for reading/writing FS/GS base */
|
|
|
|
|
|
|
|
static inline unsigned long x86_fsbase_read_cpu(void)
|
|
|
|
{
|
|
|
|
unsigned long fsbase;
|
|
|
|
|
|
|
|
rdmsrl(MSR_FS_BASE, fsbase);
|
2018-10-08 15:41:59 +07:00
|
|
|
|
2018-09-19 06:08:53 +07:00
|
|
|
return fsbase;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline unsigned long x86_gsbase_read_cpu_inactive(void)
|
|
|
|
{
|
|
|
|
unsigned long gsbase;
|
|
|
|
|
|
|
|
rdmsrl(MSR_KERNEL_GS_BASE, gsbase);
|
2018-10-08 15:41:59 +07:00
|
|
|
|
2018-09-19 06:08:53 +07:00
|
|
|
return gsbase;
|
|
|
|
}
|
|
|
|
|
2018-11-27 02:55:24 +07:00
|
|
|
static inline void x86_fsbase_write_cpu(unsigned long fsbase)
|
|
|
|
{
|
|
|
|
wrmsrl(MSR_FS_BASE, fsbase);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void x86_gsbase_write_cpu_inactive(unsigned long gsbase)
|
|
|
|
{
|
|
|
|
wrmsrl(MSR_KERNEL_GS_BASE, gsbase);
|
|
|
|
}
|
2018-09-19 06:08:53 +07:00
|
|
|
|
|
|
|
#endif /* CONFIG_X86_64 */
|
|
|
|
|
|
|
|
#endif /* __ASSEMBLY__ */
|
|
|
|
|
|
|
|
#endif /* _ASM_FSGSBASE_H */
|