]> Git Repo - linux.git/commitdiff
Merge tag 'x86-cleanups-2023-02-20' of git://git.kernel.org/pub/scm/linux/kernel...
authorLinus Torvalds <[email protected]>
Tue, 21 Feb 2023 17:24:08 +0000 (09:24 -0800)
committerLinus Torvalds <[email protected]>
Tue, 21 Feb 2023 17:24:08 +0000 (09:24 -0800)
Pull miscellaneous x86 cleanups from Thomas Gleixner:

 - Correct the common copy and pasted mishandling of kstrtobool() in the
   strict_sas_size() setup function

 - Make recalibrate_cpu_khz() an GPL only export

 - Check TSC feature before doing anything else which avoids pointless
   code execution if TSC is not available

 - Remove or fixup stale and misleading comments

 - Remove unused or pointelessly duplicated variables

 - Spelling and typo fixes

* tag 'x86-cleanups-2023-02-20' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  x86/hotplug: Remove incorrect comment about mwait_play_dead()
  x86/tsc: Do feature check as the very first thing
  x86/tsc: Make recalibrate_cpu_khz() export GPL only
  x86/cacheinfo: Remove unused trace variable
  x86/Kconfig: Fix spellos & punctuation
  x86/signal: Fix the value returned by strict_sas_size()
  x86/cpu: Remove misleading comment
  x86/setup: Move duplicate boot_cpu_data definition out of the ifdeffery
  x86/boot/e820: Fix typo in e820.c comment

1  2 
arch/x86/kernel/cpu/common.c
arch/x86/kernel/tsc.c

index a539c8fbe334c730deaa2ce69586cf51e406c193,7670397438c64af41a20cca086d9eb9758deb20d..65ceabb2e114d69cf977c8c039d67e4cff69e62d
@@@ -567,7 -567,7 +567,7 @@@ static __init int setup_disable_pku(cha
        return 1;
  }
  __setup("nopku", setup_disable_pku);
- #endif /* CONFIG_X86_64 */
+ #endif
  
  #ifdef CONFIG_X86_KERNEL_IBT
  
@@@ -1256,8 -1256,6 +1256,8 @@@ static const __initconst struct x86_cpu
  #define MMIO_SBDS     BIT(2)
  /* CPU is affected by RETbleed, speculating where you would not expect it */
  #define RETBLEED      BIT(3)
 +/* CPU is affected by SMT (cross-thread) return predictions */
 +#define SMT_RSB               BIT(4)
  
  static const struct x86_cpu_id cpu_vuln_blacklist[] __initconst = {
        VULNBL_INTEL_STEPPINGS(IVYBRIDGE,       X86_STEPPING_ANY,               SRBDS),
  
        VULNBL_AMD(0x15, RETBLEED),
        VULNBL_AMD(0x16, RETBLEED),
 -      VULNBL_AMD(0x17, RETBLEED),
 -      VULNBL_HYGON(0x18, RETBLEED),
 +      VULNBL_AMD(0x17, RETBLEED | SMT_RSB),
 +      VULNBL_HYGON(0x18, RETBLEED | SMT_RSB),
        {}
  };
  
@@@ -1408,9 -1406,6 +1408,9 @@@ static void __init cpu_set_bug_bits(str
            !(ia32_cap & ARCH_CAP_PBRSB_NO))
                setup_force_cpu_bug(X86_BUG_EIBRS_PBRSB);
  
 +      if (cpu_matches(cpu_vuln_blacklist, SMT_RSB))
 +              setup_force_cpu_bug(X86_BUG_SMT_RSB);
 +
        if (cpu_matches(cpu_vuln_whitelist, NO_MELTDOWN))
                return;
  
@@@ -1958,6 -1953,7 +1958,6 @@@ void __init identify_boot_cpu(void
        if (HAS_KERNEL_IBT && cpu_feature_enabled(X86_FEATURE_IBT))
                pr_info("CET detected: Indirect Branch Tracking enabled\n");
  #ifdef CONFIG_X86_32
 -      sysenter_setup();
        enable_sep_cpu();
  #endif
        cpu_detect_tlb(&boot_cpu_data);
@@@ -2129,6 -2125,7 +2129,6 @@@ static void wait_for_master_cpu(int cpu
  #endif
  }
  
 -#ifdef CONFIG_X86_64
  static inline void setup_getcpu(int cpu)
  {
        unsigned long cpudata = vdso_encode_cpunode(cpu, early_cpu_to_node(cpu));
        write_gdt_entry(get_cpu_gdt_rw(cpu), GDT_ENTRY_CPUNODE, &d, DESCTYPE_S);
  }
  
 +#ifdef CONFIG_X86_64
  static inline void ucode_cpu_init(int cpu)
  {
        if (cpu)
@@@ -2170,6 -2166,8 +2170,6 @@@ static inline void tss_setup_ist(struc
  
  #else /* CONFIG_X86_64 */
  
 -static inline void setup_getcpu(int cpu) { }
 -
  static inline void ucode_cpu_init(int cpu)
  {
        show_ucode_info_early();
@@@ -2299,45 -2297,30 +2299,45 @@@ void cpu_init_secondary(void
  #endif
  
  #ifdef CONFIG_MICROCODE_LATE_LOADING
 -/*
 +/**
 + * store_cpu_caps() - Store a snapshot of CPU capabilities
 + * @curr_info: Pointer where to store it
 + *
 + * Returns: None
 + */
 +void store_cpu_caps(struct cpuinfo_x86 *curr_info)
 +{
 +      /* Reload CPUID max function as it might've changed. */
 +      curr_info->cpuid_level = cpuid_eax(0);
 +
 +      /* Copy all capability leafs and pick up the synthetic ones. */
 +      memcpy(&curr_info->x86_capability, &boot_cpu_data.x86_capability,
 +             sizeof(curr_info->x86_capability));
 +
 +      /* Get the hardware CPUID leafs */
 +      get_cpu_cap(curr_info);
 +}
 +
 +/**
 + * microcode_check() - Check if any CPU capabilities changed after an update.
 + * @prev_info:        CPU capabilities stored before an update.
 + *
   * The microcode loader calls this upon late microcode load to recheck features,
   * only when microcode has been updated. Caller holds microcode_mutex and CPU
   * hotplug lock.
 + *
 + * Return: None
   */
 -void microcode_check(void)
 +void microcode_check(struct cpuinfo_x86 *prev_info)
  {
 -      struct cpuinfo_x86 info;
 +      struct cpuinfo_x86 curr_info;
  
        perf_check_microcode();
  
 -      /* Reload CPUID max function as it might've changed. */
 -      info.cpuid_level = cpuid_eax(0);
 -
 -      /*
 -       * Copy all capability leafs to pick up the synthetic ones so that
 -       * memcmp() below doesn't fail on that. The ones coming from CPUID will
 -       * get overwritten in get_cpu_cap().
 -       */
 -      memcpy(&info.x86_capability, &boot_cpu_data.x86_capability, sizeof(info.x86_capability));
 -
 -      get_cpu_cap(&info);
 +      store_cpu_caps(&curr_info);
  
 -      if (!memcmp(&info.x86_capability, &boot_cpu_data.x86_capability, sizeof(info.x86_capability)))
 +      if (!memcmp(&prev_info->x86_capability, &curr_info.x86_capability,
 +                  sizeof(prev_info->x86_capability)))
                return;
  
        pr_warn("x86/CPU: CPU features have changed after loading microcode, but might not take effect.\n");
diff --combined arch/x86/kernel/tsc.c
index 8c33936b017debf22664c921c9510ab6c8ad5f6f,aff1d79dd6ba20864c51a91068bf292b330a4674..4c6d69c6a94a361a60c65445cbb077adecfa811a
@@@ -215,7 -215,7 +215,7 @@@ static void __init cyc2ns_init_secondar
  /*
   * Scheduler clock - returns current time in nanosec units.
   */
 -u64 native_sched_clock(void)
 +noinstr u64 native_sched_clock(void)
  {
        if (static_branch_likely(&__use_tsc)) {
                u64 tsc_now = rdtsc();
@@@ -248,7 -248,7 +248,7 @@@ u64 native_sched_clock_from_tsc(u64 tsc
  /* We need to define a real function for sched_clock, to override the
     weak default version */
  #ifdef CONFIG_PARAVIRT
 -unsigned long long sched_clock(void)
 +noinstr u64 sched_clock(void)
  {
        return paravirt_sched_clock();
  }
@@@ -258,7 -258,8 +258,7 @@@ bool using_native_sched_clock(void
        return static_call_query(pv_sched_clock) == native_sched_clock;
  }
  #else
 -unsigned long long
 -sched_clock(void) __attribute__((alias("native_sched_clock")));
 +u64 sched_clock(void) __attribute__((alias("native_sched_clock")));
  
  bool using_native_sched_clock(void) { return true; }
  #endif
@@@ -911,8 -912,7 +911,7 @@@ void recalibrate_cpu_khz(void
                                                    cpu_khz_old, cpu_khz);
  #endif
  }
- EXPORT_SYMBOL(recalibrate_cpu_khz);
+ EXPORT_SYMBOL_GPL(recalibrate_cpu_khz);
  
  
  static unsigned long long cyc2ns_suspend;
@@@ -1509,6 -1509,11 +1508,11 @@@ void __init tsc_early_init(void
  
  void __init tsc_init(void)
  {
+       if (!cpu_feature_enabled(X86_FEATURE_TSC)) {
+               setup_clear_cpu_cap(X86_FEATURE_TSC_DEADLINE_TIMER);
+               return;
+       }
        /*
         * native_calibrate_cpu_early can only calibrate using methods that are
         * available early in boot.
        if (x86_platform.calibrate_cpu == native_calibrate_cpu_early)
                x86_platform.calibrate_cpu = native_calibrate_cpu;
  
-       if (!boot_cpu_has(X86_FEATURE_TSC)) {
-               setup_clear_cpu_cap(X86_FEATURE_TSC_DEADLINE_TIMER);
-               return;
-       }
        if (!tsc_khz) {
                /* We failed to determine frequencies earlier, try again */
                if (!determine_cpu_tsc_frequencies(false)) {
This page took 0.076155 seconds and 4 git commands to generate.