Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

+6 -6
+2 -2
arch/x86/include/asm/fsgsbase.h
··· 57 57 { 58 58 unsigned long fsbase; 59 59 60 - if (static_cpu_has(X86_FEATURE_FSGSBASE)) 60 + if (boot_cpu_has(X86_FEATURE_FSGSBASE)) 61 61 fsbase = rdfsbase(); 62 62 else 63 63 rdmsrl(MSR_FS_BASE, fsbase); ··· 67 67 68 68 static inline void x86_fsbase_write_cpu(unsigned long fsbase) 69 69 { 70 - if (static_cpu_has(X86_FEATURE_FSGSBASE)) 70 + if (boot_cpu_has(X86_FEATURE_FSGSBASE)) 71 71 wrfsbase(fsbase); 72 72 else 73 73 wrmsrl(MSR_FS_BASE, fsbase);
+4 -4
arch/x86/kernel/process_64.c
··· 407 407 { 408 408 unsigned long gsbase; 409 409 410 - if (static_cpu_has(X86_FEATURE_FSGSBASE)) { 410 + if (boot_cpu_has(X86_FEATURE_FSGSBASE)) { 411 411 unsigned long flags; 412 412 413 413 local_irq_save(flags); ··· 422 422 423 423 void x86_gsbase_write_cpu_inactive(unsigned long gsbase) 424 424 { 425 - if (static_cpu_has(X86_FEATURE_FSGSBASE)) { 425 + if (boot_cpu_has(X86_FEATURE_FSGSBASE)) { 426 426 unsigned long flags; 427 427 428 428 local_irq_save(flags); ··· 439 439 440 440 if (task == current) 441 441 fsbase = x86_fsbase_read_cpu(); 442 - else if (static_cpu_has(X86_FEATURE_FSGSBASE) || 442 + else if (boot_cpu_has(X86_FEATURE_FSGSBASE) || 443 443 (task->thread.fsindex == 0)) 444 444 fsbase = task->thread.fsbase; 445 445 else ··· 454 454 455 455 if (task == current) 456 456 gsbase = x86_gsbase_read_cpu_inactive(); 457 - else if (static_cpu_has(X86_FEATURE_FSGSBASE) || 457 + else if (boot_cpu_has(X86_FEATURE_FSGSBASE) || 458 458 (task->thread.gsindex == 0)) 459 459 gsbase = task->thread.gsbase; 460 460 else