cpu.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef ARCH_X86_CPU_H
  3. #define ARCH_X86_CPU_H
  4. #include <asm/cpu.h>
  5. #include <asm/topology.h>
  6. #include "topology.h"
  7. /* attempt to consolidate cpu attributes */
  8. struct cpu_dev {
  9. const char *c_vendor;
  10. /* some have two possibilities for cpuid string */
  11. const char *c_ident[2];
  12. void (*c_early_init)(struct cpuinfo_x86 *);
  13. void (*c_bsp_init)(struct cpuinfo_x86 *);
  14. void (*c_init)(struct cpuinfo_x86 *);
  15. void (*c_identify)(struct cpuinfo_x86 *);
  16. void (*c_detect_tlb)(struct cpuinfo_x86 *);
  17. int c_x86_vendor;
  18. #ifdef CONFIG_X86_32
  19. /* Optional vendor specific routine to obtain the cache size. */
  20. unsigned int (*legacy_cache_size)(struct cpuinfo_x86 *,
  21. unsigned int);
  22. /* Family/stepping-based lookup table for model names. */
  23. struct legacy_cpu_model_info {
  24. int family;
  25. const char *model_names[16];
  26. } legacy_models[5];
  27. #endif
  28. };
  29. struct _tlb_table {
  30. unsigned char descriptor;
  31. char tlb_type;
  32. unsigned int entries;
  33. /* unsigned int ways; */
  34. char info[128];
  35. };
  36. #define cpu_dev_register(cpu_devX) \
  37. static const struct cpu_dev *const __cpu_dev_##cpu_devX __used \
  38. __section(".x86_cpu_dev.init") = \
  39. &cpu_devX;
  40. extern const struct cpu_dev *const __x86_cpu_dev_start[],
  41. *const __x86_cpu_dev_end[];
  42. #ifdef CONFIG_CPU_SUP_INTEL
  43. enum tsx_ctrl_states {
  44. TSX_CTRL_ENABLE,
  45. TSX_CTRL_DISABLE,
  46. TSX_CTRL_RTM_ALWAYS_ABORT,
  47. TSX_CTRL_NOT_SUPPORTED,
  48. };
  49. extern __ro_after_init enum tsx_ctrl_states tsx_ctrl_state;
  50. extern void __init tsx_init(void);
  51. void tsx_ap_init(void);
  52. void intel_unlock_cpuid_leafs(struct cpuinfo_x86 *c);
  53. #else
  54. static inline void tsx_init(void) { }
  55. static inline void tsx_ap_init(void) { }
  56. static inline void intel_unlock_cpuid_leafs(struct cpuinfo_x86 *c) { }
  57. #endif /* CONFIG_CPU_SUP_INTEL */
  58. extern void init_spectral_chicken(struct cpuinfo_x86 *c);
  59. extern void get_cpu_cap(struct cpuinfo_x86 *c);
  60. extern void get_cpu_address_sizes(struct cpuinfo_x86 *c);
  61. extern void cpu_detect_cache_sizes(struct cpuinfo_x86 *c);
  62. extern void init_scattered_cpuid_features(struct cpuinfo_x86 *c);
  63. extern void init_intel_cacheinfo(struct cpuinfo_x86 *c);
  64. extern void init_amd_cacheinfo(struct cpuinfo_x86 *c);
  65. extern void init_hygon_cacheinfo(struct cpuinfo_x86 *c);
  66. extern void check_null_seg_clears_base(struct cpuinfo_x86 *c);
  67. void cacheinfo_amd_init_llc_id(struct cpuinfo_x86 *c, u16 die_id);
  68. void cacheinfo_hygon_init_llc_id(struct cpuinfo_x86 *c);
  69. unsigned int aperfmperf_get_khz(int cpu);
  70. void cpu_select_mitigations(void);
  71. extern void x86_spec_ctrl_setup_ap(void);
  72. extern void update_srbds_msr(void);
  73. extern void update_gds_msr(void);
  74. extern enum spectre_v2_mitigation spectre_v2_enabled;
  75. static inline bool spectre_v2_in_eibrs_mode(enum spectre_v2_mitigation mode)
  76. {
  77. return mode == SPECTRE_V2_EIBRS ||
  78. mode == SPECTRE_V2_EIBRS_RETPOLINE ||
  79. mode == SPECTRE_V2_EIBRS_LFENCE;
  80. }
  81. #endif /* ARCH_X86_CPU_H */