Skip to content

Commit

Permalink
x86/fsgsbase: Replace static_cpu_has() with boot_cpu_has()
Browse files Browse the repository at this point in the history
ptrace and prctl() are not really fast paths to warrant the use of
static_cpu_has() and cause alternatives patching for no good reason.
Replace with boot_cpu_has() which is simple and fast enough.

No functional changes.

Signed-off-by: Borislav Petkov <[email protected]>
Link: https://lkml.kernel.org/r/[email protected]
  • Loading branch information
suryasaimadhu committed Aug 24, 2020
1 parent 0b2c605 commit 5f1dd4d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions arch/x86/include/asm/fsgsbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ static inline unsigned long x86_fsbase_read_cpu(void)
{
unsigned long fsbase;

if (static_cpu_has(X86_FEATURE_FSGSBASE))
if (boot_cpu_has(X86_FEATURE_FSGSBASE))
fsbase = rdfsbase();
else
rdmsrl(MSR_FS_BASE, fsbase);
Expand All @@ -67,7 +67,7 @@ static inline unsigned long x86_fsbase_read_cpu(void)

static inline void x86_fsbase_write_cpu(unsigned long fsbase)
{
if (static_cpu_has(X86_FEATURE_FSGSBASE))
if (boot_cpu_has(X86_FEATURE_FSGSBASE))
wrfsbase(fsbase);
else
wrmsrl(MSR_FS_BASE, fsbase);
Expand Down
8 changes: 4 additions & 4 deletions arch/x86/kernel/process_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ unsigned long x86_gsbase_read_cpu_inactive(void)
{
unsigned long gsbase;

if (static_cpu_has(X86_FEATURE_FSGSBASE)) {
if (boot_cpu_has(X86_FEATURE_FSGSBASE)) {
unsigned long flags;

local_irq_save(flags);
Expand All @@ -422,7 +422,7 @@ unsigned long x86_gsbase_read_cpu_inactive(void)

void x86_gsbase_write_cpu_inactive(unsigned long gsbase)
{
if (static_cpu_has(X86_FEATURE_FSGSBASE)) {
if (boot_cpu_has(X86_FEATURE_FSGSBASE)) {
unsigned long flags;

local_irq_save(flags);
Expand All @@ -439,7 +439,7 @@ unsigned long x86_fsbase_read_task(struct task_struct *task)

if (task == current)
fsbase = x86_fsbase_read_cpu();
else if (static_cpu_has(X86_FEATURE_FSGSBASE) ||
else if (boot_cpu_has(X86_FEATURE_FSGSBASE) ||
(task->thread.fsindex == 0))
fsbase = task->thread.fsbase;
else
Expand All @@ -454,7 +454,7 @@ unsigned long x86_gsbase_read_task(struct task_struct *task)

if (task == current)
gsbase = x86_gsbase_read_cpu_inactive();
else if (static_cpu_has(X86_FEATURE_FSGSBASE) ||
else if (boot_cpu_has(X86_FEATURE_FSGSBASE) ||
(task->thread.gsindex == 0))
gsbase = task->thread.gsbase;
else
Expand Down

0 comments on commit 5f1dd4d

Please sign in to comment.