Skip to content

Commit 5f1dd4d

Browse files
committed
x86/fsgsbase: Replace static_cpu_has() with boot_cpu_has()
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 <bp@suse.de> Link: https://lkml.kernel.org/r/20200818103715.32736-1-bp@alien8.de
1 parent 0b2c605 commit 5f1dd4d

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

arch/x86/include/asm/fsgsbase.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ static inline unsigned long x86_fsbase_read_cpu(void)
5757
{
5858
unsigned long fsbase;
5959

60-
if (static_cpu_has(X86_FEATURE_FSGSBASE))
60+
if (boot_cpu_has(X86_FEATURE_FSGSBASE))
6161
fsbase = rdfsbase();
6262
else
6363
rdmsrl(MSR_FS_BASE, fsbase);
@@ -67,7 +67,7 @@ static inline unsigned long x86_fsbase_read_cpu(void)
6767

6868
static inline void x86_fsbase_write_cpu(unsigned long fsbase)
6969
{
70-
if (static_cpu_has(X86_FEATURE_FSGSBASE))
70+
if (boot_cpu_has(X86_FEATURE_FSGSBASE))
7171
wrfsbase(fsbase);
7272
else
7373
wrmsrl(MSR_FS_BASE, fsbase);

arch/x86/kernel/process_64.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ unsigned long x86_gsbase_read_cpu_inactive(void)
407407
{
408408
unsigned long gsbase;
409409

410-
if (static_cpu_has(X86_FEATURE_FSGSBASE)) {
410+
if (boot_cpu_has(X86_FEATURE_FSGSBASE)) {
411411
unsigned long flags;
412412

413413
local_irq_save(flags);
@@ -422,7 +422,7 @@ unsigned long x86_gsbase_read_cpu_inactive(void)
422422

423423
void x86_gsbase_write_cpu_inactive(unsigned long gsbase)
424424
{
425-
if (static_cpu_has(X86_FEATURE_FSGSBASE)) {
425+
if (boot_cpu_has(X86_FEATURE_FSGSBASE)) {
426426
unsigned long flags;
427427

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

440440
if (task == current)
441441
fsbase = x86_fsbase_read_cpu();
442-
else if (static_cpu_has(X86_FEATURE_FSGSBASE) ||
442+
else if (boot_cpu_has(X86_FEATURE_FSGSBASE) ||
443443
(task->thread.fsindex == 0))
444444
fsbase = task->thread.fsbase;
445445
else
@@ -454,7 +454,7 @@ unsigned long x86_gsbase_read_task(struct task_struct *task)
454454

455455
if (task == current)
456456
gsbase = x86_gsbase_read_cpu_inactive();
457-
else if (static_cpu_has(X86_FEATURE_FSGSBASE) ||
457+
else if (boot_cpu_has(X86_FEATURE_FSGSBASE) ||
458458
(task->thread.gsindex == 0))
459459
gsbase = task->thread.gsbase;
460460
else

0 commit comments

Comments
 (0)