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

Merge branch 'x86/cpu' into x86/fpu, to pick up dependent commits

Signed-off-by: Ingo Molnar <mingo@kernel.org>

Ingo Molnar 4e254750 e3a52b67

+2193 -1718
+3 -3
MAINTAINERS
··· 1097 1097 L: platform-driver-x86@vger.kernel.org 1098 1098 S: Maintained 1099 1099 F: Documentation/arch/x86/amd_hsmp.rst 1100 - F: arch/x86/include/asm/amd_hsmp.h 1100 + F: arch/x86/include/asm/amd/hsmp.h 1101 1101 F: arch/x86/include/uapi/asm/amd_hsmp.h 1102 1102 F: drivers/platform/x86/amd/hsmp/ 1103 1103 ··· 1142 1142 M: Yazen Ghannam <yazen.ghannam@amd.com> 1143 1143 L: linux-kernel@vger.kernel.org 1144 1144 S: Supported 1145 - F: arch/x86/include/asm/amd_node.h 1145 + F: arch/x86/include/asm/amd/node.h 1146 1146 F: arch/x86/kernel/amd_node.c 1147 1147 1148 1148 AMD PDS CORE DRIVER ··· 26139 26139 L: x86-cpuid@lists.linux.dev 26140 26140 S: Maintained 26141 26141 W: https://x86-cpuid.org 26142 - F: tools/arch/x86/kcpuid/cpuid.csv 26142 + F: tools/arch/x86/kcpuid/ 26143 26143 26144 26144 X86 ENTRY CODE 26145 26145 M: Andy Lutomirski <luto@kernel.org>
+1 -1
arch/x86/events/amd/ibs.c
··· 26 26 #include <linux/hardirq.h> 27 27 28 28 #include <asm/nmi.h> 29 - #include <asm/amd-ibs.h> 29 + #include <asm/amd/ibs.h> 30 30 31 31 /* attr.config2 */ 32 32 #define IBS_SW_FILTER_MASK 1
+5
arch/x86/include/asm/amd-ibs.h arch/x86/include/asm/amd/ibs.h
··· 1 1 /* SPDX-License-Identifier: GPL-2.0 */ 2 + #ifndef _ASM_X86_AMD_IBS_H 3 + #define _ASM_X86_AMD_IBS_H 4 + 2 5 /* 3 6 * From PPR Vol 1 for AMD Family 19h Model 01h B1 4 7 * 55898 Rev 0.35 - Feb 5, 2021 ··· 154 151 }; 155 152 u64 regs[MSR_AMD64_IBS_REG_COUNT_MAX]; 156 153 }; 154 + 155 + #endif /* _ASM_X86_AMD_IBS_H */
+1 -1
arch/x86/include/asm/amd_hsmp.h arch/x86/include/asm/amd/hsmp.h
··· 1 1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 - 3 2 #ifndef _ASM_X86_AMD_HSMP_H_ 4 3 #define _ASM_X86_AMD_HSMP_H_ 5 4 ··· 12 13 return -ENODEV; 13 14 } 14 15 #endif 16 + 15 17 #endif /*_ASM_X86_AMD_HSMP_H_*/
+1 -1
arch/x86/include/asm/amd_nb.h arch/x86/include/asm/amd/nb.h
··· 4 4 5 5 #include <linux/ioport.h> 6 6 #include <linux/pci.h> 7 - #include <asm/amd_node.h> 7 + #include <asm/amd/node.h> 8 8 9 9 struct amd_nb_bus_dev_range { 10 10 u8 bus;
arch/x86/include/asm/amd_node.h arch/x86/include/asm/amd/node.h
+12 -12
arch/x86/include/asm/cpufeatures.h
··· 476 476 #define X86_FEATURE_CLEAR_BHB_LOOP (21*32+ 1) /* Clear branch history at syscall entry using SW loop */ 477 477 #define X86_FEATURE_BHI_CTRL (21*32+ 2) /* BHI_DIS_S HW control available */ 478 478 #define X86_FEATURE_CLEAR_BHB_HW (21*32+ 3) /* BHI_DIS_S HW control enabled */ 479 - #define X86_FEATURE_CLEAR_BHB_LOOP_ON_VMEXIT (21*32+ 4) /* Clear branch history at vmexit using SW loop */ 480 - #define X86_FEATURE_AMD_FAST_CPPC (21*32 + 5) /* Fast CPPC */ 481 - #define X86_FEATURE_AMD_HETEROGENEOUS_CORES (21*32 + 6) /* Heterogeneous Core Topology */ 482 - #define X86_FEATURE_AMD_WORKLOAD_CLASS (21*32 + 7) /* Workload Classification */ 483 - #define X86_FEATURE_PREFER_YMM (21*32 + 8) /* Avoid ZMM registers due to downclocking */ 479 + #define X86_FEATURE_CLEAR_BHB_VMEXIT (21*32+ 4) /* Clear branch history at vmexit using SW loop */ 480 + #define X86_FEATURE_AMD_FAST_CPPC (21*32+ 5) /* Fast CPPC */ 481 + #define X86_FEATURE_AMD_HTR_CORES (21*32+ 6) /* Heterogeneous Core Topology */ 482 + #define X86_FEATURE_AMD_WORKLOAD_CLASS (21*32+ 7) /* Workload Classification */ 483 + #define X86_FEATURE_PREFER_YMM (21*32+ 8) /* Avoid ZMM registers due to downclocking */ 484 484 485 485 /* 486 486 * BUG word(s) ··· 519 519 #define X86_BUG_ITLB_MULTIHIT X86_BUG(23) /* "itlb_multihit" CPU may incur MCE during certain page attribute changes */ 520 520 #define X86_BUG_SRBDS X86_BUG(24) /* "srbds" CPU may leak RNG bits if not mitigated */ 521 521 #define X86_BUG_MMIO_STALE_DATA X86_BUG(25) /* "mmio_stale_data" CPU is affected by Processor MMIO Stale Data vulnerabilities */ 522 - #define X86_BUG_MMIO_UNKNOWN X86_BUG(26) /* "mmio_unknown" CPU is too old and its MMIO Stale Data status is unknown */ 522 + /* unused, was #define X86_BUG_MMIO_UNKNOWN X86_BUG(26) "mmio_unknown" CPU is too old and its MMIO Stale Data status is unknown */ 523 523 #define X86_BUG_RETBLEED X86_BUG(27) /* "retbleed" CPU is affected by RETBleed */ 524 524 #define X86_BUG_EIBRS_PBRSB X86_BUG(28) /* "eibrs_pbrsb" EIBRS is vulnerable to Post Barrier RSB Predictions */ 525 525 #define X86_BUG_SMT_RSB X86_BUG(29) /* "smt_rsb" CPU is vulnerable to Cross-Thread Return Address Predictions */ ··· 527 527 #define X86_BUG_TDX_PW_MCE X86_BUG(31) /* "tdx_pw_mce" CPU may incur #MC if non-TD software does partial write to TDX private memory */ 528 528 529 529 /* BUG word 2 */ 530 - #define X86_BUG_SRSO X86_BUG(1*32 + 0) /* "srso" AMD SRSO bug */ 531 - #define X86_BUG_DIV0 X86_BUG(1*32 + 1) /* "div0" AMD DIV0 speculation bug */ 532 - #define X86_BUG_RFDS X86_BUG(1*32 + 2) /* "rfds" CPU is vulnerable to Register File Data Sampling */ 533 - #define X86_BUG_BHI X86_BUG(1*32 + 3) /* "bhi" CPU is affected by Branch History Injection */ 534 - #define X86_BUG_IBPB_NO_RET X86_BUG(1*32 + 4) /* "ibpb_no_ret" IBPB omits return target predictions */ 535 - #define X86_BUG_SPECTRE_V2_USER X86_BUG(1*32 + 5) /* "spectre_v2_user" CPU is affected by Spectre variant 2 attack between user processes */ 530 + #define X86_BUG_SRSO X86_BUG( 1*32+ 0) /* "srso" AMD SRSO bug */ 531 + #define X86_BUG_DIV0 X86_BUG( 1*32+ 1) /* "div0" AMD DIV0 speculation bug */ 532 + #define X86_BUG_RFDS X86_BUG( 1*32+ 2) /* "rfds" CPU is vulnerable to Register File Data Sampling */ 533 + #define X86_BUG_BHI X86_BUG( 1*32+ 3) /* "bhi" CPU is affected by Branch History Injection */ 534 + #define X86_BUG_IBPB_NO_RET X86_BUG( 1*32+ 4) /* "ibpb_no_ret" IBPB omits return target predictions */ 535 + #define X86_BUG_SPECTRE_V2_USER X86_BUG( 1*32+ 5) /* "spectre_v2_user" CPU is affected by Spectre variant 2 attack between user processes */ 536 536 #endif /* _ASM_X86_CPUFEATURES_H */
+1
arch/x86/include/asm/cpuid.h
··· 4 4 #define _ASM_X86_CPUID_H 5 5 6 6 #include <asm/cpuid/api.h> 7 + #include <asm/cpuid/leaf_0x2_api.h> 7 8 8 9 #endif /* _ASM_X86_CPUID_H */
+11 -2
arch/x86/include/asm/cpuid/api.h
··· 36 36 } 37 37 38 38 #define NATIVE_CPUID_REG(reg) \ 39 - static inline u32 native_cpuid_##reg(u32 op) \ 39 + static inline u32 native_cpuid_##reg(u32 op) \ 40 40 { \ 41 - u32 eax = op, ebx, ecx = 0, edx; \ 41 + u32 eax = op, ebx, ecx = 0, edx; \ 42 42 \ 43 43 native_cpuid(&eax, &ebx, &ecx, &edx); \ 44 44 \ ··· 205 205 } 206 206 207 207 return 0; 208 + } 209 + 210 + /* 211 + * CPUID(0x80000006) parsing helpers 212 + */ 213 + 214 + static inline bool cpuid_amd_hygon_has_l3_cache(void) 215 + { 216 + return cpuid_edx(0x80000006); 208 217 } 209 218 210 219 #endif /* _ASM_X86_CPUID_API_H */
+73
arch/x86/include/asm/cpuid/leaf_0x2_api.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + #ifndef _ASM_X86_CPUID_LEAF_0x2_API_H 3 + #define _ASM_X86_CPUID_LEAF_0x2_API_H 4 + 5 + #include <asm/cpuid/api.h> 6 + #include <asm/cpuid/types.h> 7 + 8 + /** 9 + * cpuid_get_leaf_0x2_regs() - Return sanitized leaf 0x2 register output 10 + * @regs: Output parameter 11 + * 12 + * Query CPUID leaf 0x2 and store its output in @regs. Force set any 13 + * invalid 1-byte descriptor returned by the hardware to zero (the NULL 14 + * cache/TLB descriptor) before returning it to the caller. 15 + * 16 + * Use for_each_leaf_0x2_entry() to iterate over the register output in 17 + * parsed form. 18 + */ 19 + static inline void cpuid_get_leaf_0x2_regs(union leaf_0x2_regs *regs) 20 + { 21 + cpuid_leaf(0x2, regs); 22 + 23 + /* 24 + * All Intel CPUs must report an iteration count of 1. In case 25 + * of bogus hardware, treat all returned descriptors as NULL. 26 + */ 27 + if (regs->desc[0] != 0x01) { 28 + for (int i = 0; i < 4; i++) 29 + regs->regv[i] = 0; 30 + return; 31 + } 32 + 33 + /* 34 + * The most significant bit (MSB) of each register must be clear. 35 + * If a register is invalid, replace its descriptors with NULL. 36 + */ 37 + for (int i = 0; i < 4; i++) { 38 + if (regs->reg[i].invalid) 39 + regs->regv[i] = 0; 40 + } 41 + } 42 + 43 + /** 44 + * for_each_leaf_0x2_entry() - Iterator for parsed leaf 0x2 descriptors 45 + * @regs: Leaf 0x2 register output, returned by cpuid_get_leaf_0x2_regs() 46 + * @__ptr: u8 pointer, for macro internal use only 47 + * @entry: Pointer to parsed descriptor information at each iteration 48 + * 49 + * Loop over the 1-byte descriptors in the passed leaf 0x2 output registers 50 + * @regs. Provide the parsed information for each descriptor through @entry. 51 + * 52 + * To handle cache-specific descriptors, switch on @entry->c_type. For TLB 53 + * descriptors, switch on @entry->t_type. 54 + * 55 + * Example usage for cache descriptors:: 56 + * 57 + * const struct leaf_0x2_table *entry; 58 + * union leaf_0x2_regs regs; 59 + * u8 *ptr; 60 + * 61 + * cpuid_get_leaf_0x2_regs(&regs); 62 + * for_each_leaf_0x2_entry(regs, ptr, entry) { 63 + * switch (entry->c_type) { 64 + * ... 65 + * } 66 + * } 67 + */ 68 + #define for_each_leaf_0x2_entry(regs, __ptr, entry) \ 69 + for (__ptr = &(regs).desc[1]; \ 70 + __ptr < &(regs).desc[16] && (entry = &cpuid_0x2_table[*__ptr]); \ 71 + __ptr++) 72 + 73 + #endif /* _ASM_X86_CPUID_LEAF_0x2_API_H */
+96
arch/x86/include/asm/cpuid/types.h
··· 2 2 #ifndef _ASM_X86_CPUID_TYPES_H 3 3 #define _ASM_X86_CPUID_TYPES_H 4 4 5 + #include <linux/build_bug.h> 5 6 #include <linux/types.h> 6 7 7 8 /* ··· 29 28 #define CPUID_LEAF_TSC 0x15 30 29 #define CPUID_LEAF_FREQ 0x16 31 30 #define CPUID_LEAF_TILE 0x1d 31 + 32 + /* 33 + * Types for CPUID(0x2) parsing 34 + * Check <asm/cpuid/leaf_0x2_api.h> 35 + */ 36 + 37 + struct leaf_0x2_reg { 38 + u32 : 31, 39 + invalid : 1; 40 + }; 41 + 42 + union leaf_0x2_regs { 43 + struct leaf_0x2_reg reg[4]; 44 + u32 regv[4]; 45 + u8 desc[16]; 46 + }; 47 + 48 + /* 49 + * Leaf 0x2 1-byte descriptors' cache types 50 + * To be used for their mappings at cpuid_0x2_table[] 51 + * 52 + * Start at 1 since type 0 is reserved for HW byte descriptors which are 53 + * not recognized by the kernel; i.e., those without an explicit mapping. 54 + */ 55 + enum _cache_table_type { 56 + CACHE_L1_INST = 1, 57 + CACHE_L1_DATA, 58 + CACHE_L2, 59 + CACHE_L3 60 + /* Adjust __TLB_TABLE_TYPE_BEGIN before adding more types */ 61 + } __packed; 62 + #ifndef __CHECKER__ 63 + static_assert(sizeof(enum _cache_table_type) == 1); 64 + #endif 65 + 66 + /* 67 + * Ensure that leaf 0x2 cache and TLB type values do not intersect, 68 + * since they share the same type field at struct cpuid_0x2_table. 69 + */ 70 + #define __TLB_TABLE_TYPE_BEGIN (CACHE_L3 + 1) 71 + 72 + /* 73 + * Leaf 0x2 1-byte descriptors' TLB types 74 + * To be used for their mappings at cpuid_0x2_table[] 75 + */ 76 + enum _tlb_table_type { 77 + TLB_INST_4K = __TLB_TABLE_TYPE_BEGIN, 78 + TLB_INST_4M, 79 + TLB_INST_2M_4M, 80 + TLB_INST_ALL, 81 + 82 + TLB_DATA_4K, 83 + TLB_DATA_4M, 84 + TLB_DATA_2M_4M, 85 + TLB_DATA_4K_4M, 86 + TLB_DATA_1G, 87 + TLB_DATA_1G_2M_4M, 88 + 89 + TLB_DATA0_4K, 90 + TLB_DATA0_4M, 91 + TLB_DATA0_2M_4M, 92 + 93 + STLB_4K, 94 + STLB_4K_2M, 95 + } __packed; 96 + #ifndef __CHECKER__ 97 + static_assert(sizeof(enum _tlb_table_type) == 1); 98 + #endif 99 + 100 + /* 101 + * Combined parsing table for leaf 0x2 cache and TLB descriptors. 102 + */ 103 + 104 + struct leaf_0x2_table { 105 + union { 106 + enum _cache_table_type c_type; 107 + enum _tlb_table_type t_type; 108 + }; 109 + union { 110 + short c_size; 111 + short entries; 112 + }; 113 + }; 114 + 115 + extern const struct leaf_0x2_table cpuid_0x2_table[256]; 116 + 117 + /* 118 + * All of leaf 0x2's one-byte TLB descriptors implies the same number of entries 119 + * for their respective TLB types. TLB descriptor 0x63 is an exception: it 120 + * implies 4 dTLB entries for 1GB pages and 32 dTLB entries for 2MB or 4MB pages. 121 + * 122 + * Encode that descriptor's dTLB entry count for 2MB/4MB pages here, as the entry 123 + * count for dTLB 1GB pages is already encoded at the cpuid_0x2_table[]'s mapping. 124 + */ 125 + #define TLB_0x63_2M_4M_ENTRIES 32 32 126 33 127 #endif /* _ASM_X86_CPUID_TYPES_H */
+1 -1
arch/x86/include/asm/nospec-branch.h
··· 327 327 .endm 328 328 329 329 .macro CLEAR_BRANCH_HISTORY_VMEXIT 330 - ALTERNATIVE "", "call clear_bhb_loop", X86_FEATURE_CLEAR_BHB_LOOP_ON_VMEXIT 330 + ALTERNATIVE "", "call clear_bhb_loop", X86_FEATURE_CLEAR_BHB_VMEXIT 331 331 .endm 332 332 #else 333 333 #define CLEAR_BRANCH_HISTORY
+1 -1
arch/x86/kernel/acpi/cppc.c
··· 272 272 } 273 273 274 274 /* detect if running on heterogeneous design */ 275 - if (cpu_feature_enabled(X86_FEATURE_AMD_HETEROGENEOUS_CORES)) { 275 + if (cpu_feature_enabled(X86_FEATURE_AMD_HTR_CORES)) { 276 276 switch (core_type) { 277 277 case TOPO_CPU_TYPE_UNKNOWN: 278 278 pr_warn("Undefined core type found for cpu %d\n", cpu);
+1 -1
arch/x86/kernel/amd_gart_64.c
··· 39 39 #include <asm/gart.h> 40 40 #include <asm/set_memory.h> 41 41 #include <asm/dma.h> 42 - #include <asm/amd_nb.h> 42 + #include <asm/amd/nb.h> 43 43 #include <asm/x86_init.h> 44 44 45 45 static unsigned long iommu_bus_base; /* GART remapping area (physical) */
+4 -5
arch/x86/kernel/amd_nb.c
··· 13 13 #include <linux/export.h> 14 14 #include <linux/spinlock.h> 15 15 #include <linux/pci_ids.h> 16 - #include <asm/amd_nb.h> 16 + 17 + #include <asm/amd/nb.h> 18 + #include <asm/cpuid.h> 17 19 18 20 static u32 *flush_words; 19 21 ··· 93 91 if (amd_gart_present()) 94 92 amd_northbridges.flags |= AMD_NB_GART; 95 93 96 - /* 97 - * Check for L3 cache presence. 98 - */ 99 - if (!cpuid_edx(0x80000006)) 94 + if (!cpuid_amd_hygon_has_l3_cache()) 100 95 return 0; 101 96 102 97 /*
+1 -1
arch/x86/kernel/amd_node.c
··· 9 9 */ 10 10 11 11 #include <linux/debugfs.h> 12 - #include <asm/amd_node.h> 12 + #include <asm/amd/node.h> 13 13 14 14 /* 15 15 * AMD Nodes are a physical collection of I/O devices within an SoC. There can be one
+1 -1
arch/x86/kernel/aperture_64.c
··· 29 29 #include <asm/gart.h> 30 30 #include <asm/pci-direct.h> 31 31 #include <asm/dma.h> 32 - #include <asm/amd_nb.h> 32 + #include <asm/amd/nb.h> 33 33 #include <asm/x86_init.h> 34 34 #include <linux/crash_dump.h> 35 35
+4 -1
arch/x86/kernel/cpu/Makefile
··· 24 24 obj-y += match.o 25 25 obj-y += bugs.o 26 26 obj-y += aperfmperf.o 27 - obj-y += cpuid-deps.o 27 + obj-y += cpuid-deps.o cpuid_0x2_table.o 28 28 obj-y += umwait.o 29 29 obj-y += capflags.o powerflags.o 30 30 ··· 38 38 obj-$(CONFIG_PM) += intel_epb.o 39 39 endif 40 40 obj-$(CONFIG_CPU_SUP_AMD) += amd.o 41 + ifeq ($(CONFIG_AMD_NB)$(CONFIG_SYSFS),yy) 42 + obj-y += amd_cache_disable.o 43 + endif 41 44 obj-$(CONFIG_CPU_SUP_HYGON) += hygon.o 42 45 obj-$(CONFIG_CPU_SUP_CYRIX_32) += cyrix.o 43 46 obj-$(CONFIG_CPU_SUP_CENTAUR) += centaur.o
+301
arch/x86/kernel/cpu/amd_cache_disable.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* 3 + * AMD L3 cache_disable_{0,1} sysfs handling 4 + * Documentation/ABI/testing/sysfs-devices-system-cpu 5 + */ 6 + 7 + #include <linux/cacheinfo.h> 8 + #include <linux/capability.h> 9 + #include <linux/pci.h> 10 + #include <linux/sysfs.h> 11 + 12 + #include <asm/amd/nb.h> 13 + 14 + #include "cpu.h" 15 + 16 + /* 17 + * L3 cache descriptors 18 + */ 19 + static void amd_calc_l3_indices(struct amd_northbridge *nb) 20 + { 21 + struct amd_l3_cache *l3 = &nb->l3_cache; 22 + unsigned int sc0, sc1, sc2, sc3; 23 + u32 val = 0; 24 + 25 + pci_read_config_dword(nb->misc, 0x1C4, &val); 26 + 27 + /* calculate subcache sizes */ 28 + l3->subcaches[0] = sc0 = !(val & BIT(0)); 29 + l3->subcaches[1] = sc1 = !(val & BIT(4)); 30 + 31 + if (boot_cpu_data.x86 == 0x15) { 32 + l3->subcaches[0] = sc0 += !(val & BIT(1)); 33 + l3->subcaches[1] = sc1 += !(val & BIT(5)); 34 + } 35 + 36 + l3->subcaches[2] = sc2 = !(val & BIT(8)) + !(val & BIT(9)); 37 + l3->subcaches[3] = sc3 = !(val & BIT(12)) + !(val & BIT(13)); 38 + 39 + l3->indices = (max(max3(sc0, sc1, sc2), sc3) << 10) - 1; 40 + } 41 + 42 + /* 43 + * check whether a slot used for disabling an L3 index is occupied. 44 + * @l3: L3 cache descriptor 45 + * @slot: slot number (0..1) 46 + * 47 + * @returns: the disabled index if used or negative value if slot free. 48 + */ 49 + static int amd_get_l3_disable_slot(struct amd_northbridge *nb, unsigned int slot) 50 + { 51 + unsigned int reg = 0; 52 + 53 + pci_read_config_dword(nb->misc, 0x1BC + slot * 4, &reg); 54 + 55 + /* check whether this slot is activated already */ 56 + if (reg & (3UL << 30)) 57 + return reg & 0xfff; 58 + 59 + return -1; 60 + } 61 + 62 + static ssize_t show_cache_disable(struct cacheinfo *ci, char *buf, unsigned int slot) 63 + { 64 + int index; 65 + struct amd_northbridge *nb = ci->priv; 66 + 67 + index = amd_get_l3_disable_slot(nb, slot); 68 + if (index >= 0) 69 + return sysfs_emit(buf, "%d\n", index); 70 + 71 + return sysfs_emit(buf, "FREE\n"); 72 + } 73 + 74 + #define SHOW_CACHE_DISABLE(slot) \ 75 + static ssize_t \ 76 + cache_disable_##slot##_show(struct device *dev, \ 77 + struct device_attribute *attr, char *buf) \ 78 + { \ 79 + struct cacheinfo *ci = dev_get_drvdata(dev); \ 80 + return show_cache_disable(ci, buf, slot); \ 81 + } 82 + 83 + SHOW_CACHE_DISABLE(0) 84 + SHOW_CACHE_DISABLE(1) 85 + 86 + static void amd_l3_disable_index(struct amd_northbridge *nb, int cpu, 87 + unsigned int slot, unsigned long idx) 88 + { 89 + int i; 90 + 91 + idx |= BIT(30); 92 + 93 + /* 94 + * disable index in all 4 subcaches 95 + */ 96 + for (i = 0; i < 4; i++) { 97 + u32 reg = idx | (i << 20); 98 + 99 + if (!nb->l3_cache.subcaches[i]) 100 + continue; 101 + 102 + pci_write_config_dword(nb->misc, 0x1BC + slot * 4, reg); 103 + 104 + /* 105 + * We need to WBINVD on a core on the node containing the L3 106 + * cache which indices we disable therefore a simple wbinvd() 107 + * is not sufficient. 108 + */ 109 + wbinvd_on_cpu(cpu); 110 + 111 + reg |= BIT(31); 112 + pci_write_config_dword(nb->misc, 0x1BC + slot * 4, reg); 113 + } 114 + } 115 + 116 + /* 117 + * disable a L3 cache index by using a disable-slot 118 + * 119 + * @l3: L3 cache descriptor 120 + * @cpu: A CPU on the node containing the L3 cache 121 + * @slot: slot number (0..1) 122 + * @index: index to disable 123 + * 124 + * @return: 0 on success, error status on failure 125 + */ 126 + static int amd_set_l3_disable_slot(struct amd_northbridge *nb, int cpu, 127 + unsigned int slot, unsigned long index) 128 + { 129 + int ret = 0; 130 + 131 + /* check if @slot is already used or the index is already disabled */ 132 + ret = amd_get_l3_disable_slot(nb, slot); 133 + if (ret >= 0) 134 + return -EEXIST; 135 + 136 + if (index > nb->l3_cache.indices) 137 + return -EINVAL; 138 + 139 + /* check whether the other slot has disabled the same index already */ 140 + if (index == amd_get_l3_disable_slot(nb, !slot)) 141 + return -EEXIST; 142 + 143 + amd_l3_disable_index(nb, cpu, slot, index); 144 + 145 + return 0; 146 + } 147 + 148 + static ssize_t store_cache_disable(struct cacheinfo *ci, const char *buf, 149 + size_t count, unsigned int slot) 150 + { 151 + struct amd_northbridge *nb = ci->priv; 152 + unsigned long val = 0; 153 + int cpu, err = 0; 154 + 155 + if (!capable(CAP_SYS_ADMIN)) 156 + return -EPERM; 157 + 158 + cpu = cpumask_first(&ci->shared_cpu_map); 159 + 160 + if (kstrtoul(buf, 10, &val) < 0) 161 + return -EINVAL; 162 + 163 + err = amd_set_l3_disable_slot(nb, cpu, slot, val); 164 + if (err) { 165 + if (err == -EEXIST) 166 + pr_warn("L3 slot %d in use/index already disabled!\n", 167 + slot); 168 + return err; 169 + } 170 + return count; 171 + } 172 + 173 + #define STORE_CACHE_DISABLE(slot) \ 174 + static ssize_t \ 175 + cache_disable_##slot##_store(struct device *dev, \ 176 + struct device_attribute *attr, \ 177 + const char *buf, size_t count) \ 178 + { \ 179 + struct cacheinfo *ci = dev_get_drvdata(dev); \ 180 + return store_cache_disable(ci, buf, count, slot); \ 181 + } 182 + 183 + STORE_CACHE_DISABLE(0) 184 + STORE_CACHE_DISABLE(1) 185 + 186 + static ssize_t subcaches_show(struct device *dev, struct device_attribute *attr, 187 + char *buf) 188 + { 189 + struct cacheinfo *ci = dev_get_drvdata(dev); 190 + int cpu = cpumask_first(&ci->shared_cpu_map); 191 + 192 + return sysfs_emit(buf, "%x\n", amd_get_subcaches(cpu)); 193 + } 194 + 195 + static ssize_t subcaches_store(struct device *dev, 196 + struct device_attribute *attr, 197 + const char *buf, size_t count) 198 + { 199 + struct cacheinfo *ci = dev_get_drvdata(dev); 200 + int cpu = cpumask_first(&ci->shared_cpu_map); 201 + unsigned long val; 202 + 203 + if (!capable(CAP_SYS_ADMIN)) 204 + return -EPERM; 205 + 206 + if (kstrtoul(buf, 16, &val) < 0) 207 + return -EINVAL; 208 + 209 + if (amd_set_subcaches(cpu, val)) 210 + return -EINVAL; 211 + 212 + return count; 213 + } 214 + 215 + static DEVICE_ATTR_RW(cache_disable_0); 216 + static DEVICE_ATTR_RW(cache_disable_1); 217 + static DEVICE_ATTR_RW(subcaches); 218 + 219 + static umode_t cache_private_attrs_is_visible(struct kobject *kobj, 220 + struct attribute *attr, int unused) 221 + { 222 + struct device *dev = kobj_to_dev(kobj); 223 + struct cacheinfo *ci = dev_get_drvdata(dev); 224 + umode_t mode = attr->mode; 225 + 226 + if (!ci->priv) 227 + return 0; 228 + 229 + if ((attr == &dev_attr_subcaches.attr) && 230 + amd_nb_has_feature(AMD_NB_L3_PARTITIONING)) 231 + return mode; 232 + 233 + if ((attr == &dev_attr_cache_disable_0.attr || 234 + attr == &dev_attr_cache_disable_1.attr) && 235 + amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE)) 236 + return mode; 237 + 238 + return 0; 239 + } 240 + 241 + static struct attribute_group cache_private_group = { 242 + .is_visible = cache_private_attrs_is_visible, 243 + }; 244 + 245 + static void init_amd_l3_attrs(void) 246 + { 247 + static struct attribute **amd_l3_attrs; 248 + int n = 1; 249 + 250 + if (amd_l3_attrs) /* already initialized */ 251 + return; 252 + 253 + if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE)) 254 + n += 2; 255 + if (amd_nb_has_feature(AMD_NB_L3_PARTITIONING)) 256 + n += 1; 257 + 258 + amd_l3_attrs = kcalloc(n, sizeof(*amd_l3_attrs), GFP_KERNEL); 259 + if (!amd_l3_attrs) 260 + return; 261 + 262 + n = 0; 263 + if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE)) { 264 + amd_l3_attrs[n++] = &dev_attr_cache_disable_0.attr; 265 + amd_l3_attrs[n++] = &dev_attr_cache_disable_1.attr; 266 + } 267 + if (amd_nb_has_feature(AMD_NB_L3_PARTITIONING)) 268 + amd_l3_attrs[n++] = &dev_attr_subcaches.attr; 269 + 270 + cache_private_group.attrs = amd_l3_attrs; 271 + } 272 + 273 + const struct attribute_group *cache_get_priv_group(struct cacheinfo *ci) 274 + { 275 + struct amd_northbridge *nb = ci->priv; 276 + 277 + if (ci->level < 3 || !nb) 278 + return NULL; 279 + 280 + if (nb && nb->l3_cache.indices) 281 + init_amd_l3_attrs(); 282 + 283 + return &cache_private_group; 284 + } 285 + 286 + struct amd_northbridge *amd_init_l3_cache(int index) 287 + { 288 + struct amd_northbridge *nb; 289 + int node; 290 + 291 + /* only for L3, and not in virtualized environments */ 292 + if (index < 3) 293 + return NULL; 294 + 295 + node = topology_amd_node_id(smp_processor_id()); 296 + nb = node_to_amd_nb(node); 297 + if (nb && !nb->l3_cache.indices) 298 + amd_calc_l3_indices(nb); 299 + 300 + return nb; 301 + }
+4 -14
arch/x86/kernel/cpu/bugs.c
··· 427 427 static void __init mmio_select_mitigation(void) 428 428 { 429 429 if (!boot_cpu_has_bug(X86_BUG_MMIO_STALE_DATA) || 430 - boot_cpu_has_bug(X86_BUG_MMIO_UNKNOWN) || 431 430 cpu_mitigations_off()) { 432 431 mmio_mitigation = MMIO_MITIGATION_OFF; 433 432 return; ··· 589 590 pr_info("TAA: %s\n", taa_strings[taa_mitigation]); 590 591 if (boot_cpu_has_bug(X86_BUG_MMIO_STALE_DATA)) 591 592 pr_info("MMIO Stale Data: %s\n", mmio_strings[mmio_mitigation]); 592 - else if (boot_cpu_has_bug(X86_BUG_MMIO_UNKNOWN)) 593 - pr_info("MMIO Stale Data: Unknown: No mitigations\n"); 594 593 if (boot_cpu_has_bug(X86_BUG_RFDS)) 595 594 pr_info("Register File Data Sampling: %s\n", rfds_strings[rfds_mitigation]); 596 595 } ··· 1703 1706 1704 1707 if (bhi_mitigation == BHI_MITIGATION_VMEXIT_ONLY) { 1705 1708 pr_info("Spectre BHI mitigation: SW BHB clearing on VM exit only\n"); 1706 - setup_force_cpu_cap(X86_FEATURE_CLEAR_BHB_LOOP_ON_VMEXIT); 1709 + setup_force_cpu_cap(X86_FEATURE_CLEAR_BHB_VMEXIT); 1707 1710 return; 1708 1711 } 1709 1712 1710 1713 pr_info("Spectre BHI mitigation: SW BHB clearing on syscall and VM exit\n"); 1711 1714 setup_force_cpu_cap(X86_FEATURE_CLEAR_BHB_LOOP); 1712 - setup_force_cpu_cap(X86_FEATURE_CLEAR_BHB_LOOP_ON_VMEXIT); 1715 + setup_force_cpu_cap(X86_FEATURE_CLEAR_BHB_VMEXIT); 1713 1716 } 1714 1717 1715 1718 static void __init spectre_v2_select_mitigation(void) ··· 2777 2780 2778 2781 static ssize_t mmio_stale_data_show_state(char *buf) 2779 2782 { 2780 - if (boot_cpu_has_bug(X86_BUG_MMIO_UNKNOWN)) 2781 - return sysfs_emit(buf, "Unknown: No mitigations\n"); 2782 - 2783 2783 if (mmio_mitigation == MMIO_MITIGATION_OFF) 2784 2784 return sysfs_emit(buf, "%s\n", mmio_strings[mmio_mitigation]); 2785 2785 ··· 2852 2858 !boot_cpu_has(X86_FEATURE_RETPOLINE_LFENCE) && 2853 2859 rrsba_disabled) 2854 2860 return "; BHI: Retpoline"; 2855 - else if (boot_cpu_has(X86_FEATURE_CLEAR_BHB_LOOP_ON_VMEXIT)) 2861 + else if (boot_cpu_has(X86_FEATURE_CLEAR_BHB_VMEXIT)) 2856 2862 return "; BHI: Vulnerable, KVM: SW loop"; 2857 2863 2858 2864 return "; BHI: Vulnerable"; ··· 2961 2967 return srbds_show_state(buf); 2962 2968 2963 2969 case X86_BUG_MMIO_STALE_DATA: 2964 - case X86_BUG_MMIO_UNKNOWN: 2965 2970 return mmio_stale_data_show_state(buf); 2966 2971 2967 2972 case X86_BUG_RETBLEED: ··· 3029 3036 3030 3037 ssize_t cpu_show_mmio_stale_data(struct device *dev, struct device_attribute *attr, char *buf) 3031 3038 { 3032 - if (boot_cpu_has_bug(X86_BUG_MMIO_UNKNOWN)) 3033 - return cpu_show_common(dev, attr, buf, X86_BUG_MMIO_UNKNOWN); 3034 - else 3035 - return cpu_show_common(dev, attr, buf, X86_BUG_MMIO_STALE_DATA); 3039 + return cpu_show_common(dev, attr, buf, X86_BUG_MMIO_STALE_DATA); 3036 3040 } 3037 3041 3038 3042 ssize_t cpu_show_retbleed(struct device *dev, struct device_attribute *attr, char *buf)
+362 -743
arch/x86/kernel/cpu/cacheinfo.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 2 2 /* 3 - * Routines to identify caches on Intel CPU. 3 + * x86 CPU caches detection and configuration 4 4 * 5 - * Changes: 6 - * Venkatesh Pallipadi : Adding cache identification through cpuid(4) 7 - * Ashok Raj <ashok.raj@intel.com>: Work with CPU hotplug infrastructure. 8 - * Andi Kleen / Andreas Herrmann : CPUID4 emulation on AMD. 5 + * Previous changes 6 + * - Venkatesh Pallipadi: Cache identification through CPUID(0x4) 7 + * - Ashok Raj <ashok.raj@intel.com>: Work with CPU hotplug infrastructure 8 + * - Andi Kleen / Andreas Herrmann: CPUID(0x4) emulation on AMD 9 9 */ 10 10 11 11 #include <linux/cacheinfo.h> 12 - #include <linux/capability.h> 13 12 #include <linux/cpu.h> 14 13 #include <linux/cpuhotplug.h> 15 - #include <linux/pci.h> 16 14 #include <linux/stop_machine.h> 17 - #include <linux/sysfs.h> 18 15 19 - #include <asm/amd_nb.h> 16 + #include <asm/amd/nb.h> 20 17 #include <asm/cacheinfo.h> 21 18 #include <asm/cpufeature.h> 19 + #include <asm/cpuid.h> 22 20 #include <asm/mtrr.h> 23 21 #include <asm/smp.h> 24 22 #include <asm/tlbflush.h> 25 23 26 24 #include "cpu.h" 27 - 28 - #define LVL_1_INST 1 29 - #define LVL_1_DATA 2 30 - #define LVL_2 3 31 - #define LVL_3 4 32 25 33 26 /* Shared last level cache maps */ 34 27 DEFINE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_llc_shared_map); ··· 34 41 /* Kernel controls MTRR and/or PAT MSRs. */ 35 42 unsigned int memory_caching_control __ro_after_init; 36 43 37 - struct _cache_table { 38 - unsigned char descriptor; 39 - char cache_type; 40 - short size; 41 - }; 42 - 43 - #define MB(x) ((x) * 1024) 44 - 45 - /* All the cache descriptor types we care about (no TLB or 46 - trace cache entries) */ 47 - 48 - static const struct _cache_table cache_table[] = 49 - { 50 - { 0x06, LVL_1_INST, 8 }, /* 4-way set assoc, 32 byte line size */ 51 - { 0x08, LVL_1_INST, 16 }, /* 4-way set assoc, 32 byte line size */ 52 - { 0x09, LVL_1_INST, 32 }, /* 4-way set assoc, 64 byte line size */ 53 - { 0x0a, LVL_1_DATA, 8 }, /* 2 way set assoc, 32 byte line size */ 54 - { 0x0c, LVL_1_DATA, 16 }, /* 4-way set assoc, 32 byte line size */ 55 - { 0x0d, LVL_1_DATA, 16 }, /* 4-way set assoc, 64 byte line size */ 56 - { 0x0e, LVL_1_DATA, 24 }, /* 6-way set assoc, 64 byte line size */ 57 - { 0x21, LVL_2, 256 }, /* 8-way set assoc, 64 byte line size */ 58 - { 0x22, LVL_3, 512 }, /* 4-way set assoc, sectored cache, 64 byte line size */ 59 - { 0x23, LVL_3, MB(1) }, /* 8-way set assoc, sectored cache, 64 byte line size */ 60 - { 0x25, LVL_3, MB(2) }, /* 8-way set assoc, sectored cache, 64 byte line size */ 61 - { 0x29, LVL_3, MB(4) }, /* 8-way set assoc, sectored cache, 64 byte line size */ 62 - { 0x2c, LVL_1_DATA, 32 }, /* 8-way set assoc, 64 byte line size */ 63 - { 0x30, LVL_1_INST, 32 }, /* 8-way set assoc, 64 byte line size */ 64 - { 0x39, LVL_2, 128 }, /* 4-way set assoc, sectored cache, 64 byte line size */ 65 - { 0x3a, LVL_2, 192 }, /* 6-way set assoc, sectored cache, 64 byte line size */ 66 - { 0x3b, LVL_2, 128 }, /* 2-way set assoc, sectored cache, 64 byte line size */ 67 - { 0x3c, LVL_2, 256 }, /* 4-way set assoc, sectored cache, 64 byte line size */ 68 - { 0x3d, LVL_2, 384 }, /* 6-way set assoc, sectored cache, 64 byte line size */ 69 - { 0x3e, LVL_2, 512 }, /* 4-way set assoc, sectored cache, 64 byte line size */ 70 - { 0x3f, LVL_2, 256 }, /* 2-way set assoc, 64 byte line size */ 71 - { 0x41, LVL_2, 128 }, /* 4-way set assoc, 32 byte line size */ 72 - { 0x42, LVL_2, 256 }, /* 4-way set assoc, 32 byte line size */ 73 - { 0x43, LVL_2, 512 }, /* 4-way set assoc, 32 byte line size */ 74 - { 0x44, LVL_2, MB(1) }, /* 4-way set assoc, 32 byte line size */ 75 - { 0x45, LVL_2, MB(2) }, /* 4-way set assoc, 32 byte line size */ 76 - { 0x46, LVL_3, MB(4) }, /* 4-way set assoc, 64 byte line size */ 77 - { 0x47, LVL_3, MB(8) }, /* 8-way set assoc, 64 byte line size */ 78 - { 0x48, LVL_2, MB(3) }, /* 12-way set assoc, 64 byte line size */ 79 - { 0x49, LVL_3, MB(4) }, /* 16-way set assoc, 64 byte line size */ 80 - { 0x4a, LVL_3, MB(6) }, /* 12-way set assoc, 64 byte line size */ 81 - { 0x4b, LVL_3, MB(8) }, /* 16-way set assoc, 64 byte line size */ 82 - { 0x4c, LVL_3, MB(12) }, /* 12-way set assoc, 64 byte line size */ 83 - { 0x4d, LVL_3, MB(16) }, /* 16-way set assoc, 64 byte line size */ 84 - { 0x4e, LVL_2, MB(6) }, /* 24-way set assoc, 64 byte line size */ 85 - { 0x60, LVL_1_DATA, 16 }, /* 8-way set assoc, sectored cache, 64 byte line size */ 86 - { 0x66, LVL_1_DATA, 8 }, /* 4-way set assoc, sectored cache, 64 byte line size */ 87 - { 0x67, LVL_1_DATA, 16 }, /* 4-way set assoc, sectored cache, 64 byte line size */ 88 - { 0x68, LVL_1_DATA, 32 }, /* 4-way set assoc, sectored cache, 64 byte line size */ 89 - { 0x78, LVL_2, MB(1) }, /* 4-way set assoc, 64 byte line size */ 90 - { 0x79, LVL_2, 128 }, /* 8-way set assoc, sectored cache, 64 byte line size */ 91 - { 0x7a, LVL_2, 256 }, /* 8-way set assoc, sectored cache, 64 byte line size */ 92 - { 0x7b, LVL_2, 512 }, /* 8-way set assoc, sectored cache, 64 byte line size */ 93 - { 0x7c, LVL_2, MB(1) }, /* 8-way set assoc, sectored cache, 64 byte line size */ 94 - { 0x7d, LVL_2, MB(2) }, /* 8-way set assoc, 64 byte line size */ 95 - { 0x7f, LVL_2, 512 }, /* 2-way set assoc, 64 byte line size */ 96 - { 0x80, LVL_2, 512 }, /* 8-way set assoc, 64 byte line size */ 97 - { 0x82, LVL_2, 256 }, /* 8-way set assoc, 32 byte line size */ 98 - { 0x83, LVL_2, 512 }, /* 8-way set assoc, 32 byte line size */ 99 - { 0x84, LVL_2, MB(1) }, /* 8-way set assoc, 32 byte line size */ 100 - { 0x85, LVL_2, MB(2) }, /* 8-way set assoc, 32 byte line size */ 101 - { 0x86, LVL_2, 512 }, /* 4-way set assoc, 64 byte line size */ 102 - { 0x87, LVL_2, MB(1) }, /* 8-way set assoc, 64 byte line size */ 103 - { 0xd0, LVL_3, 512 }, /* 4-way set assoc, 64 byte line size */ 104 - { 0xd1, LVL_3, MB(1) }, /* 4-way set assoc, 64 byte line size */ 105 - { 0xd2, LVL_3, MB(2) }, /* 4-way set assoc, 64 byte line size */ 106 - { 0xd6, LVL_3, MB(1) }, /* 8-way set assoc, 64 byte line size */ 107 - { 0xd7, LVL_3, MB(2) }, /* 8-way set assoc, 64 byte line size */ 108 - { 0xd8, LVL_3, MB(4) }, /* 12-way set assoc, 64 byte line size */ 109 - { 0xdc, LVL_3, MB(2) }, /* 12-way set assoc, 64 byte line size */ 110 - { 0xdd, LVL_3, MB(4) }, /* 12-way set assoc, 64 byte line size */ 111 - { 0xde, LVL_3, MB(8) }, /* 12-way set assoc, 64 byte line size */ 112 - { 0xe2, LVL_3, MB(2) }, /* 16-way set assoc, 64 byte line size */ 113 - { 0xe3, LVL_3, MB(4) }, /* 16-way set assoc, 64 byte line size */ 114 - { 0xe4, LVL_3, MB(8) }, /* 16-way set assoc, 64 byte line size */ 115 - { 0xea, LVL_3, MB(12) }, /* 24-way set assoc, 64 byte line size */ 116 - { 0xeb, LVL_3, MB(18) }, /* 24-way set assoc, 64 byte line size */ 117 - { 0xec, LVL_3, MB(24) }, /* 24-way set assoc, 64 byte line size */ 118 - { 0x00, 0, 0} 119 - }; 120 - 121 - 122 44 enum _cache_type { 123 - CTYPE_NULL = 0, 124 - CTYPE_DATA = 1, 125 - CTYPE_INST = 2, 126 - CTYPE_UNIFIED = 3 45 + CTYPE_NULL = 0, 46 + CTYPE_DATA = 1, 47 + CTYPE_INST = 2, 48 + CTYPE_UNIFIED = 3 127 49 }; 128 50 129 51 union _cpuid4_leaf_eax { 130 52 struct { 131 - enum _cache_type type:5; 132 - unsigned int level:3; 133 - unsigned int is_self_initializing:1; 134 - unsigned int is_fully_associative:1; 135 - unsigned int reserved:4; 136 - unsigned int num_threads_sharing:12; 137 - unsigned int num_cores_on_die:6; 53 + enum _cache_type type :5; 54 + unsigned int level :3; 55 + unsigned int is_self_initializing :1; 56 + unsigned int is_fully_associative :1; 57 + unsigned int reserved :4; 58 + unsigned int num_threads_sharing :12; 59 + unsigned int num_cores_on_die :6; 138 60 } split; 139 61 u32 full; 140 62 }; 141 63 142 64 union _cpuid4_leaf_ebx { 143 65 struct { 144 - unsigned int coherency_line_size:12; 145 - unsigned int physical_line_partition:10; 146 - unsigned int ways_of_associativity:10; 66 + unsigned int coherency_line_size :12; 67 + unsigned int physical_line_partition :10; 68 + unsigned int ways_of_associativity :10; 147 69 } split; 148 70 u32 full; 149 71 }; 150 72 151 73 union _cpuid4_leaf_ecx { 152 74 struct { 153 - unsigned int number_of_sets:32; 75 + unsigned int number_of_sets :32; 154 76 } split; 155 77 u32 full; 156 78 }; 157 79 158 - struct _cpuid4_info_regs { 80 + struct _cpuid4_info { 159 81 union _cpuid4_leaf_eax eax; 160 82 union _cpuid4_leaf_ebx ebx; 161 83 union _cpuid4_leaf_ecx ecx; 162 84 unsigned int id; 163 85 unsigned long size; 164 - struct amd_northbridge *nb; 165 86 }; 166 87 167 - /* AMD doesn't have CPUID4. Emulate it here to report the same 168 - information to the user. This makes some assumptions about the machine: 169 - L2 not shared, no SMT etc. that is currently true on AMD CPUs. 88 + /* Map CPUID(0x4) EAX.cache_type to <linux/cacheinfo.h> types */ 89 + static const enum cache_type cache_type_map[] = { 90 + [CTYPE_NULL] = CACHE_TYPE_NOCACHE, 91 + [CTYPE_DATA] = CACHE_TYPE_DATA, 92 + [CTYPE_INST] = CACHE_TYPE_INST, 93 + [CTYPE_UNIFIED] = CACHE_TYPE_UNIFIED, 94 + }; 170 95 171 - In theory the TLBs could be reported as fake type (they are in "dummy"). 172 - Maybe later */ 96 + /* 97 + * Fallback AMD CPUID(0x4) emulation 98 + * AMD CPUs with TOPOEXT can just use CPUID(0x8000001d) 99 + * 100 + * @AMD_L2_L3_INVALID_ASSOC: cache info for the respective L2/L3 cache should 101 + * be determined from CPUID(0x8000001d) instead of CPUID(0x80000006). 102 + */ 103 + 104 + #define AMD_CPUID4_FULLY_ASSOCIATIVE 0xffff 105 + #define AMD_L2_L3_INVALID_ASSOC 0x9 106 + 173 107 union l1_cache { 174 108 struct { 175 - unsigned line_size:8; 176 - unsigned lines_per_tag:8; 177 - unsigned assoc:8; 178 - unsigned size_in_kb:8; 109 + unsigned line_size :8; 110 + unsigned lines_per_tag :8; 111 + unsigned assoc :8; 112 + unsigned size_in_kb :8; 179 113 }; 180 - unsigned val; 114 + unsigned int val; 181 115 }; 182 116 183 117 union l2_cache { 184 118 struct { 185 - unsigned line_size:8; 186 - unsigned lines_per_tag:4; 187 - unsigned assoc:4; 188 - unsigned size_in_kb:16; 119 + unsigned line_size :8; 120 + unsigned lines_per_tag :4; 121 + unsigned assoc :4; 122 + unsigned size_in_kb :16; 189 123 }; 190 - unsigned val; 124 + unsigned int val; 191 125 }; 192 126 193 127 union l3_cache { 194 128 struct { 195 - unsigned line_size:8; 196 - unsigned lines_per_tag:4; 197 - unsigned assoc:4; 198 - unsigned res:2; 199 - unsigned size_encoded:14; 129 + unsigned line_size :8; 130 + unsigned lines_per_tag :4; 131 + unsigned assoc :4; 132 + unsigned res :2; 133 + unsigned size_encoded :14; 200 134 }; 201 - unsigned val; 135 + unsigned int val; 202 136 }; 203 137 138 + /* L2/L3 associativity mapping */ 204 139 static const unsigned short assocs[] = { 205 - [1] = 1, 206 - [2] = 2, 207 - [4] = 4, 208 - [6] = 8, 209 - [8] = 16, 210 - [0xa] = 32, 211 - [0xb] = 48, 212 - [0xc] = 64, 213 - [0xd] = 96, 214 - [0xe] = 128, 215 - [0xf] = 0xffff /* fully associative - no way to show this currently */ 140 + [1] = 1, 141 + [2] = 2, 142 + [3] = 3, 143 + [4] = 4, 144 + [5] = 6, 145 + [6] = 8, 146 + [8] = 16, 147 + [0xa] = 32, 148 + [0xb] = 48, 149 + [0xc] = 64, 150 + [0xd] = 96, 151 + [0xe] = 128, 152 + [0xf] = AMD_CPUID4_FULLY_ASSOCIATIVE 216 153 }; 217 154 218 155 static const unsigned char levels[] = { 1, 1, 2, 3 }; 219 - static const unsigned char types[] = { 1, 2, 3, 3 }; 156 + static const unsigned char types[] = { 1, 2, 3, 3 }; 220 157 221 - static const enum cache_type cache_type_map[] = { 222 - [CTYPE_NULL] = CACHE_TYPE_NOCACHE, 223 - [CTYPE_DATA] = CACHE_TYPE_DATA, 224 - [CTYPE_INST] = CACHE_TYPE_INST, 225 - [CTYPE_UNIFIED] = CACHE_TYPE_UNIFIED, 226 - }; 227 - 228 - static void 229 - amd_cpuid4(int leaf, union _cpuid4_leaf_eax *eax, 230 - union _cpuid4_leaf_ebx *ebx, 231 - union _cpuid4_leaf_ecx *ecx) 158 + static void legacy_amd_cpuid4(int index, union _cpuid4_leaf_eax *eax, 159 + union _cpuid4_leaf_ebx *ebx, union _cpuid4_leaf_ecx *ecx) 232 160 { 233 - unsigned dummy; 234 - unsigned line_size, lines_per_tag, assoc, size_in_kb; 235 - union l1_cache l1i, l1d; 161 + unsigned int dummy, line_size, lines_per_tag, assoc, size_in_kb; 162 + union l1_cache l1i, l1d, *l1; 236 163 union l2_cache l2; 237 164 union l3_cache l3; 238 - union l1_cache *l1 = &l1d; 239 165 240 166 eax->full = 0; 241 167 ebx->full = 0; ··· 163 251 cpuid(0x80000005, &dummy, &dummy, &l1d.val, &l1i.val); 164 252 cpuid(0x80000006, &dummy, &dummy, &l2.val, &l3.val); 165 253 166 - switch (leaf) { 254 + l1 = &l1d; 255 + switch (index) { 167 256 case 1: 168 257 l1 = &l1i; 169 258 fallthrough; 170 259 case 0: 171 260 if (!l1->val) 172 261 return; 173 - assoc = assocs[l1->assoc]; 174 - line_size = l1->line_size; 175 - lines_per_tag = l1->lines_per_tag; 176 - size_in_kb = l1->size_in_kb; 262 + 263 + assoc = (l1->assoc == 0xff) ? AMD_CPUID4_FULLY_ASSOCIATIVE : l1->assoc; 264 + line_size = l1->line_size; 265 + lines_per_tag = l1->lines_per_tag; 266 + size_in_kb = l1->size_in_kb; 177 267 break; 178 268 case 2: 179 - if (!l2.val) 269 + if (!l2.assoc || l2.assoc == AMD_L2_L3_INVALID_ASSOC) 180 270 return; 181 - assoc = assocs[l2.assoc]; 182 - line_size = l2.line_size; 183 - lines_per_tag = l2.lines_per_tag; 184 - /* cpu_data has errata corrections for K7 applied */ 185 - size_in_kb = __this_cpu_read(cpu_info.x86_cache_size); 271 + 272 + /* Use x86_cache_size as it might have K7 errata fixes */ 273 + assoc = assocs[l2.assoc]; 274 + line_size = l2.line_size; 275 + lines_per_tag = l2.lines_per_tag; 276 + size_in_kb = __this_cpu_read(cpu_info.x86_cache_size); 186 277 break; 187 278 case 3: 188 - if (!l3.val) 279 + if (!l3.assoc || l3.assoc == AMD_L2_L3_INVALID_ASSOC) 189 280 return; 190 - assoc = assocs[l3.assoc]; 191 - line_size = l3.line_size; 192 - lines_per_tag = l3.lines_per_tag; 193 - size_in_kb = l3.size_encoded * 512; 281 + 282 + assoc = assocs[l3.assoc]; 283 + line_size = l3.line_size; 284 + lines_per_tag = l3.lines_per_tag; 285 + size_in_kb = l3.size_encoded * 512; 194 286 if (boot_cpu_has(X86_FEATURE_AMD_DCM)) { 195 - size_in_kb = size_in_kb >> 1; 196 - assoc = assoc >> 1; 287 + size_in_kb = size_in_kb >> 1; 288 + assoc = assoc >> 1; 197 289 } 198 290 break; 199 291 default: 200 292 return; 201 293 } 202 294 203 - eax->split.is_self_initializing = 1; 204 - eax->split.type = types[leaf]; 205 - eax->split.level = levels[leaf]; 206 - eax->split.num_threads_sharing = 0; 207 - eax->split.num_cores_on_die = topology_num_cores_per_package(); 295 + eax->split.is_self_initializing = 1; 296 + eax->split.type = types[index]; 297 + eax->split.level = levels[index]; 298 + eax->split.num_threads_sharing = 0; 299 + eax->split.num_cores_on_die = topology_num_cores_per_package(); 208 300 209 - 210 - if (assoc == 0xffff) 301 + if (assoc == AMD_CPUID4_FULLY_ASSOCIATIVE) 211 302 eax->split.is_fully_associative = 1; 212 - ebx->split.coherency_line_size = line_size - 1; 213 - ebx->split.ways_of_associativity = assoc - 1; 214 - ebx->split.physical_line_partition = lines_per_tag - 1; 215 - ecx->split.number_of_sets = (size_in_kb * 1024) / line_size / 303 + 304 + ebx->split.coherency_line_size = line_size - 1; 305 + ebx->split.ways_of_associativity = assoc - 1; 306 + ebx->split.physical_line_partition = lines_per_tag - 1; 307 + ecx->split.number_of_sets = (size_in_kb * 1024) / line_size / 216 308 (ebx->split.ways_of_associativity + 1) - 1; 217 309 } 218 310 219 - #if defined(CONFIG_AMD_NB) && defined(CONFIG_SYSFS) 220 - 221 - /* 222 - * L3 cache descriptors 223 - */ 224 - static void amd_calc_l3_indices(struct amd_northbridge *nb) 311 + static int cpuid4_info_fill_done(struct _cpuid4_info *id4, union _cpuid4_leaf_eax eax, 312 + union _cpuid4_leaf_ebx ebx, union _cpuid4_leaf_ecx ecx) 225 313 { 226 - struct amd_l3_cache *l3 = &nb->l3_cache; 227 - unsigned int sc0, sc1, sc2, sc3; 228 - u32 val = 0; 229 - 230 - pci_read_config_dword(nb->misc, 0x1C4, &val); 231 - 232 - /* calculate subcache sizes */ 233 - l3->subcaches[0] = sc0 = !(val & BIT(0)); 234 - l3->subcaches[1] = sc1 = !(val & BIT(4)); 235 - 236 - if (boot_cpu_data.x86 == 0x15) { 237 - l3->subcaches[0] = sc0 += !(val & BIT(1)); 238 - l3->subcaches[1] = sc1 += !(val & BIT(5)); 239 - } 240 - 241 - l3->subcaches[2] = sc2 = !(val & BIT(8)) + !(val & BIT(9)); 242 - l3->subcaches[3] = sc3 = !(val & BIT(12)) + !(val & BIT(13)); 243 - 244 - l3->indices = (max(max3(sc0, sc1, sc2), sc3) << 10) - 1; 245 - } 246 - 247 - /* 248 - * check whether a slot used for disabling an L3 index is occupied. 249 - * @l3: L3 cache descriptor 250 - * @slot: slot number (0..1) 251 - * 252 - * @returns: the disabled index if used or negative value if slot free. 253 - */ 254 - static int amd_get_l3_disable_slot(struct amd_northbridge *nb, unsigned slot) 255 - { 256 - unsigned int reg = 0; 257 - 258 - pci_read_config_dword(nb->misc, 0x1BC + slot * 4, &reg); 259 - 260 - /* check whether this slot is activated already */ 261 - if (reg & (3UL << 30)) 262 - return reg & 0xfff; 263 - 264 - return -1; 265 - } 266 - 267 - static ssize_t show_cache_disable(struct cacheinfo *this_leaf, char *buf, 268 - unsigned int slot) 269 - { 270 - int index; 271 - struct amd_northbridge *nb = this_leaf->priv; 272 - 273 - index = amd_get_l3_disable_slot(nb, slot); 274 - if (index >= 0) 275 - return sprintf(buf, "%d\n", index); 276 - 277 - return sprintf(buf, "FREE\n"); 278 - } 279 - 280 - #define SHOW_CACHE_DISABLE(slot) \ 281 - static ssize_t \ 282 - cache_disable_##slot##_show(struct device *dev, \ 283 - struct device_attribute *attr, char *buf) \ 284 - { \ 285 - struct cacheinfo *this_leaf = dev_get_drvdata(dev); \ 286 - return show_cache_disable(this_leaf, buf, slot); \ 287 - } 288 - SHOW_CACHE_DISABLE(0) 289 - SHOW_CACHE_DISABLE(1) 290 - 291 - static void amd_l3_disable_index(struct amd_northbridge *nb, int cpu, 292 - unsigned slot, unsigned long idx) 293 - { 294 - int i; 295 - 296 - idx |= BIT(30); 297 - 298 - /* 299 - * disable index in all 4 subcaches 300 - */ 301 - for (i = 0; i < 4; i++) { 302 - u32 reg = idx | (i << 20); 303 - 304 - if (!nb->l3_cache.subcaches[i]) 305 - continue; 306 - 307 - pci_write_config_dword(nb->misc, 0x1BC + slot * 4, reg); 308 - 309 - /* 310 - * We need to WBINVD on a core on the node containing the L3 311 - * cache which indices we disable therefore a simple wbinvd() 312 - * is not sufficient. 313 - */ 314 - wbinvd_on_cpu(cpu); 315 - 316 - reg |= BIT(31); 317 - pci_write_config_dword(nb->misc, 0x1BC + slot * 4, reg); 318 - } 319 - } 320 - 321 - /* 322 - * disable a L3 cache index by using a disable-slot 323 - * 324 - * @l3: L3 cache descriptor 325 - * @cpu: A CPU on the node containing the L3 cache 326 - * @slot: slot number (0..1) 327 - * @index: index to disable 328 - * 329 - * @return: 0 on success, error status on failure 330 - */ 331 - static int amd_set_l3_disable_slot(struct amd_northbridge *nb, int cpu, 332 - unsigned slot, unsigned long index) 333 - { 334 - int ret = 0; 335 - 336 - /* check if @slot is already used or the index is already disabled */ 337 - ret = amd_get_l3_disable_slot(nb, slot); 338 - if (ret >= 0) 339 - return -EEXIST; 340 - 341 - if (index > nb->l3_cache.indices) 342 - return -EINVAL; 343 - 344 - /* check whether the other slot has disabled the same index already */ 345 - if (index == amd_get_l3_disable_slot(nb, !slot)) 346 - return -EEXIST; 347 - 348 - amd_l3_disable_index(nb, cpu, slot, index); 349 - 350 - return 0; 351 - } 352 - 353 - static ssize_t store_cache_disable(struct cacheinfo *this_leaf, 354 - const char *buf, size_t count, 355 - unsigned int slot) 356 - { 357 - unsigned long val = 0; 358 - int cpu, err = 0; 359 - struct amd_northbridge *nb = this_leaf->priv; 360 - 361 - if (!capable(CAP_SYS_ADMIN)) 362 - return -EPERM; 363 - 364 - cpu = cpumask_first(&this_leaf->shared_cpu_map); 365 - 366 - if (kstrtoul(buf, 10, &val) < 0) 367 - return -EINVAL; 368 - 369 - err = amd_set_l3_disable_slot(nb, cpu, slot, val); 370 - if (err) { 371 - if (err == -EEXIST) 372 - pr_warn("L3 slot %d in use/index already disabled!\n", 373 - slot); 374 - return err; 375 - } 376 - return count; 377 - } 378 - 379 - #define STORE_CACHE_DISABLE(slot) \ 380 - static ssize_t \ 381 - cache_disable_##slot##_store(struct device *dev, \ 382 - struct device_attribute *attr, \ 383 - const char *buf, size_t count) \ 384 - { \ 385 - struct cacheinfo *this_leaf = dev_get_drvdata(dev); \ 386 - return store_cache_disable(this_leaf, buf, count, slot); \ 387 - } 388 - STORE_CACHE_DISABLE(0) 389 - STORE_CACHE_DISABLE(1) 390 - 391 - static ssize_t subcaches_show(struct device *dev, 392 - struct device_attribute *attr, char *buf) 393 - { 394 - struct cacheinfo *this_leaf = dev_get_drvdata(dev); 395 - int cpu = cpumask_first(&this_leaf->shared_cpu_map); 396 - 397 - return sprintf(buf, "%x\n", amd_get_subcaches(cpu)); 398 - } 399 - 400 - static ssize_t subcaches_store(struct device *dev, 401 - struct device_attribute *attr, 402 - const char *buf, size_t count) 403 - { 404 - struct cacheinfo *this_leaf = dev_get_drvdata(dev); 405 - int cpu = cpumask_first(&this_leaf->shared_cpu_map); 406 - unsigned long val; 407 - 408 - if (!capable(CAP_SYS_ADMIN)) 409 - return -EPERM; 410 - 411 - if (kstrtoul(buf, 16, &val) < 0) 412 - return -EINVAL; 413 - 414 - if (amd_set_subcaches(cpu, val)) 415 - return -EINVAL; 416 - 417 - return count; 418 - } 419 - 420 - static DEVICE_ATTR_RW(cache_disable_0); 421 - static DEVICE_ATTR_RW(cache_disable_1); 422 - static DEVICE_ATTR_RW(subcaches); 423 - 424 - static umode_t 425 - cache_private_attrs_is_visible(struct kobject *kobj, 426 - struct attribute *attr, int unused) 427 - { 428 - struct device *dev = kobj_to_dev(kobj); 429 - struct cacheinfo *this_leaf = dev_get_drvdata(dev); 430 - umode_t mode = attr->mode; 431 - 432 - if (!this_leaf->priv) 433 - return 0; 434 - 435 - if ((attr == &dev_attr_subcaches.attr) && 436 - amd_nb_has_feature(AMD_NB_L3_PARTITIONING)) 437 - return mode; 438 - 439 - if ((attr == &dev_attr_cache_disable_0.attr || 440 - attr == &dev_attr_cache_disable_1.attr) && 441 - amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE)) 442 - return mode; 443 - 444 - return 0; 445 - } 446 - 447 - static struct attribute_group cache_private_group = { 448 - .is_visible = cache_private_attrs_is_visible, 449 - }; 450 - 451 - static void init_amd_l3_attrs(void) 452 - { 453 - int n = 1; 454 - static struct attribute **amd_l3_attrs; 455 - 456 - if (amd_l3_attrs) /* already initialized */ 457 - return; 458 - 459 - if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE)) 460 - n += 2; 461 - if (amd_nb_has_feature(AMD_NB_L3_PARTITIONING)) 462 - n += 1; 463 - 464 - amd_l3_attrs = kcalloc(n, sizeof(*amd_l3_attrs), GFP_KERNEL); 465 - if (!amd_l3_attrs) 466 - return; 467 - 468 - n = 0; 469 - if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE)) { 470 - amd_l3_attrs[n++] = &dev_attr_cache_disable_0.attr; 471 - amd_l3_attrs[n++] = &dev_attr_cache_disable_1.attr; 472 - } 473 - if (amd_nb_has_feature(AMD_NB_L3_PARTITIONING)) 474 - amd_l3_attrs[n++] = &dev_attr_subcaches.attr; 475 - 476 - cache_private_group.attrs = amd_l3_attrs; 477 - } 478 - 479 - const struct attribute_group * 480 - cache_get_priv_group(struct cacheinfo *this_leaf) 481 - { 482 - struct amd_northbridge *nb = this_leaf->priv; 483 - 484 - if (this_leaf->level < 3 || !nb) 485 - return NULL; 486 - 487 - if (nb && nb->l3_cache.indices) 488 - init_amd_l3_attrs(); 489 - 490 - return &cache_private_group; 491 - } 492 - 493 - static void amd_init_l3_cache(struct _cpuid4_info_regs *this_leaf, int index) 494 - { 495 - int node; 496 - 497 - /* only for L3, and not in virtualized environments */ 498 - if (index < 3) 499 - return; 500 - 501 - node = topology_amd_node_id(smp_processor_id()); 502 - this_leaf->nb = node_to_amd_nb(node); 503 - if (this_leaf->nb && !this_leaf->nb->l3_cache.indices) 504 - amd_calc_l3_indices(this_leaf->nb); 505 - } 506 - #else 507 - #define amd_init_l3_cache(x, y) 508 - #endif /* CONFIG_AMD_NB && CONFIG_SYSFS */ 509 - 510 - static int 511 - cpuid4_cache_lookup_regs(int index, struct _cpuid4_info_regs *this_leaf) 512 - { 513 - union _cpuid4_leaf_eax eax; 514 - union _cpuid4_leaf_ebx ebx; 515 - union _cpuid4_leaf_ecx ecx; 516 - unsigned edx; 517 - 518 - if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD) { 519 - if (boot_cpu_has(X86_FEATURE_TOPOEXT)) 520 - cpuid_count(0x8000001d, index, &eax.full, 521 - &ebx.full, &ecx.full, &edx); 522 - else 523 - amd_cpuid4(index, &eax, &ebx, &ecx); 524 - amd_init_l3_cache(this_leaf, index); 525 - } else if (boot_cpu_data.x86_vendor == X86_VENDOR_HYGON) { 526 - cpuid_count(0x8000001d, index, &eax.full, 527 - &ebx.full, &ecx.full, &edx); 528 - amd_init_l3_cache(this_leaf, index); 529 - } else { 530 - cpuid_count(4, index, &eax.full, &ebx.full, &ecx.full, &edx); 531 - } 532 - 533 314 if (eax.split.type == CTYPE_NULL) 534 - return -EIO; /* better error ? */ 315 + return -EIO; 535 316 536 - this_leaf->eax = eax; 537 - this_leaf->ebx = ebx; 538 - this_leaf->ecx = ecx; 539 - this_leaf->size = (ecx.split.number_of_sets + 1) * 540 - (ebx.split.coherency_line_size + 1) * 541 - (ebx.split.physical_line_partition + 1) * 542 - (ebx.split.ways_of_associativity + 1); 317 + id4->eax = eax; 318 + id4->ebx = ebx; 319 + id4->ecx = ecx; 320 + id4->size = (ecx.split.number_of_sets + 1) * 321 + (ebx.split.coherency_line_size + 1) * 322 + (ebx.split.physical_line_partition + 1) * 323 + (ebx.split.ways_of_associativity + 1); 324 + 543 325 return 0; 326 + } 327 + 328 + static int amd_fill_cpuid4_info(int index, struct _cpuid4_info *id4) 329 + { 330 + union _cpuid4_leaf_eax eax; 331 + union _cpuid4_leaf_ebx ebx; 332 + union _cpuid4_leaf_ecx ecx; 333 + u32 ignored; 334 + 335 + if (boot_cpu_has(X86_FEATURE_TOPOEXT) || boot_cpu_data.x86_vendor == X86_VENDOR_HYGON) 336 + cpuid_count(0x8000001d, index, &eax.full, &ebx.full, &ecx.full, &ignored); 337 + else 338 + legacy_amd_cpuid4(index, &eax, &ebx, &ecx); 339 + 340 + return cpuid4_info_fill_done(id4, eax, ebx, ecx); 341 + } 342 + 343 + static int intel_fill_cpuid4_info(int index, struct _cpuid4_info *id4) 344 + { 345 + union _cpuid4_leaf_eax eax; 346 + union _cpuid4_leaf_ebx ebx; 347 + union _cpuid4_leaf_ecx ecx; 348 + u32 ignored; 349 + 350 + cpuid_count(4, index, &eax.full, &ebx.full, &ecx.full, &ignored); 351 + 352 + return cpuid4_info_fill_done(id4, eax, ebx, ecx); 353 + } 354 + 355 + static int fill_cpuid4_info(int index, struct _cpuid4_info *id4) 356 + { 357 + u8 cpu_vendor = boot_cpu_data.x86_vendor; 358 + 359 + return (cpu_vendor == X86_VENDOR_AMD || cpu_vendor == X86_VENDOR_HYGON) ? 360 + amd_fill_cpuid4_info(index, id4) : 361 + intel_fill_cpuid4_info(index, id4); 544 362 } 545 363 546 364 static int find_num_cache_leaves(struct cpuinfo_x86 *c) 547 365 { 548 - unsigned int eax, ebx, ecx, edx, op; 549 - union _cpuid4_leaf_eax cache_eax; 550 - int i = -1; 366 + unsigned int eax, ebx, ecx, edx, op; 367 + union _cpuid4_leaf_eax cache_eax; 368 + int i = -1; 551 369 552 - if (c->x86_vendor == X86_VENDOR_AMD || 553 - c->x86_vendor == X86_VENDOR_HYGON) 554 - op = 0x8000001d; 555 - else 556 - op = 4; 557 - 370 + /* Do a CPUID(op) loop to calculate num_cache_leaves */ 371 + op = (c->x86_vendor == X86_VENDOR_AMD || c->x86_vendor == X86_VENDOR_HYGON) ? 0x8000001d : 4; 558 372 do { 559 373 ++i; 560 - /* Do cpuid(op) loop to find out num_cache_leaves */ 561 374 cpuid_count(op, i, &eax, &ebx, &ecx, &edx); 562 375 cache_eax.full = eax; 563 376 } while (cache_eax.split.type != CTYPE_NULL); 564 377 return i; 565 378 } 566 379 380 + /* 381 + * AMD/Hygon CPUs may have multiple LLCs if L3 caches exist. 382 + */ 383 + 567 384 void cacheinfo_amd_init_llc_id(struct cpuinfo_x86 *c, u16 die_id) 568 385 { 569 - /* 570 - * We may have multiple LLCs if L3 caches exist, so check if we 571 - * have an L3 cache by looking at the L3 cache CPUID leaf. 572 - */ 573 - if (!cpuid_edx(0x80000006)) 386 + if (!cpuid_amd_hygon_has_l3_cache()) 574 387 return; 575 388 576 389 if (c->x86 < 0x17) { 577 - /* LLC is at the node level. */ 390 + /* Pre-Zen: LLC is at the node level */ 578 391 c->topo.llc_id = die_id; 579 392 } else if (c->x86 == 0x17 && c->x86_model <= 0x1F) { 580 393 /* 581 - * LLC is at the core complex level. 582 - * Core complex ID is ApicId[3] for these processors. 394 + * Family 17h up to 1F models: LLC is at the core 395 + * complex level. Core complex ID is ApicId[3]. 583 396 */ 584 397 c->topo.llc_id = c->topo.apicid >> 3; 585 398 } else { 586 399 /* 587 - * LLC ID is calculated from the number of threads sharing the 588 - * cache. 589 - * */ 400 + * Newer families: LLC ID is calculated from the number 401 + * of threads sharing the L3 cache. 402 + */ 590 403 u32 eax, ebx, ecx, edx, num_sharing_cache = 0; 591 404 u32 llc_index = find_num_cache_leaves(c) - 1; 592 405 ··· 320 683 num_sharing_cache = ((eax >> 14) & 0xfff) + 1; 321 684 322 685 if (num_sharing_cache) { 323 - int bits = get_count_order(num_sharing_cache); 686 + int index_msb = get_count_order(num_sharing_cache); 324 687 325 - c->topo.llc_id = c->topo.apicid >> bits; 688 + c->topo.llc_id = c->topo.apicid >> index_msb; 326 689 } 327 690 } 328 691 } 329 692 330 693 void cacheinfo_hygon_init_llc_id(struct cpuinfo_x86 *c) 331 694 { 332 - /* 333 - * We may have multiple LLCs if L3 caches exist, so check if we 334 - * have an L3 cache by looking at the L3 cache CPUID leaf. 335 - */ 336 - if (!cpuid_edx(0x80000006)) 695 + if (!cpuid_amd_hygon_has_l3_cache()) 337 696 return; 338 697 339 698 /* 340 - * LLC is at the core complex level. 341 - * Core complex ID is ApicId[3] for these processors. 699 + * Hygons are similar to AMD Family 17h up to 1F models: LLC is 700 + * at the core complex level. Core complex ID is ApicId[3]. 342 701 */ 343 702 c->topo.llc_id = c->topo.apicid >> 3; 344 703 } ··· 343 710 { 344 711 struct cpu_cacheinfo *ci = get_cpu_cacheinfo(c->cpu_index); 345 712 346 - if (boot_cpu_has(X86_FEATURE_TOPOEXT)) { 713 + if (boot_cpu_has(X86_FEATURE_TOPOEXT)) 347 714 ci->num_leaves = find_num_cache_leaves(c); 348 - } else if (c->extended_cpuid_level >= 0x80000006) { 349 - if (cpuid_edx(0x80000006) & 0xf000) 350 - ci->num_leaves = 4; 351 - else 352 - ci->num_leaves = 3; 353 - } 715 + else if (c->extended_cpuid_level >= 0x80000006) 716 + ci->num_leaves = (cpuid_edx(0x80000006) & 0xf000) ? 4 : 3; 354 717 } 355 718 356 719 void init_hygon_cacheinfo(struct cpuinfo_x86 *c) ··· 356 727 ci->num_leaves = find_num_cache_leaves(c); 357 728 } 358 729 359 - void init_intel_cacheinfo(struct cpuinfo_x86 *c) 730 + static void intel_cacheinfo_done(struct cpuinfo_x86 *c, unsigned int l3, 731 + unsigned int l2, unsigned int l1i, unsigned int l1d) 360 732 { 361 - /* Cache sizes */ 362 - unsigned int l1i = 0, l1d = 0, l2 = 0, l3 = 0; 363 - unsigned int new_l1d = 0, new_l1i = 0; /* Cache sizes from cpuid(4) */ 364 - unsigned int new_l2 = 0, new_l3 = 0, i; /* Cache sizes from cpuid(4) */ 365 - unsigned int l2_id = 0, l3_id = 0, num_threads_sharing, index_msb; 366 - struct cpu_cacheinfo *ci = get_cpu_cacheinfo(c->cpu_index); 367 - 368 - if (c->cpuid_level > 3) { 369 - /* 370 - * There should be at least one leaf. A non-zero value means 371 - * that the number of leaves has been initialized. 372 - */ 373 - if (!ci->num_leaves) 374 - ci->num_leaves = find_num_cache_leaves(c); 375 - 376 - /* 377 - * Whenever possible use cpuid(4), deterministic cache 378 - * parameters cpuid leaf to find the cache details 379 - */ 380 - for (i = 0; i < ci->num_leaves; i++) { 381 - struct _cpuid4_info_regs this_leaf = {}; 382 - int retval; 383 - 384 - retval = cpuid4_cache_lookup_regs(i, &this_leaf); 385 - if (retval < 0) 386 - continue; 387 - 388 - switch (this_leaf.eax.split.level) { 389 - case 1: 390 - if (this_leaf.eax.split.type == CTYPE_DATA) 391 - new_l1d = this_leaf.size/1024; 392 - else if (this_leaf.eax.split.type == CTYPE_INST) 393 - new_l1i = this_leaf.size/1024; 394 - break; 395 - case 2: 396 - new_l2 = this_leaf.size/1024; 397 - num_threads_sharing = 1 + this_leaf.eax.split.num_threads_sharing; 398 - index_msb = get_count_order(num_threads_sharing); 399 - l2_id = c->topo.apicid & ~((1 << index_msb) - 1); 400 - break; 401 - case 3: 402 - new_l3 = this_leaf.size/1024; 403 - num_threads_sharing = 1 + this_leaf.eax.split.num_threads_sharing; 404 - index_msb = get_count_order(num_threads_sharing); 405 - l3_id = c->topo.apicid & ~((1 << index_msb) - 1); 406 - break; 407 - default: 408 - break; 409 - } 410 - } 411 - } 412 - 413 - /* Don't use CPUID(2) if CPUID(4) is supported. */ 414 - if (!ci->num_leaves && c->cpuid_level > 1) { 415 - /* supports eax=2 call */ 416 - int j, n; 417 - unsigned int regs[4]; 418 - unsigned char *dp = (unsigned char *)regs; 419 - 420 - /* Number of times to iterate */ 421 - n = cpuid_eax(2) & 0xFF; 422 - 423 - for (i = 0 ; i < n ; i++) { 424 - cpuid(2, &regs[0], &regs[1], &regs[2], &regs[3]); 425 - 426 - /* If bit 31 is set, this is an unknown format */ 427 - for (j = 0 ; j < 4 ; j++) 428 - if (regs[j] & (1 << 31)) 429 - regs[j] = 0; 430 - 431 - /* Byte 0 is level count, not a descriptor */ 432 - for (j = 1 ; j < 16 ; j++) { 433 - unsigned char des = dp[j]; 434 - unsigned char k = 0; 435 - 436 - /* look up this descriptor in the table */ 437 - while (cache_table[k].descriptor != 0) { 438 - if (cache_table[k].descriptor == des) { 439 - switch (cache_table[k].cache_type) { 440 - case LVL_1_INST: 441 - l1i += cache_table[k].size; 442 - break; 443 - case LVL_1_DATA: 444 - l1d += cache_table[k].size; 445 - break; 446 - case LVL_2: 447 - l2 += cache_table[k].size; 448 - break; 449 - case LVL_3: 450 - l3 += cache_table[k].size; 451 - break; 452 - } 453 - 454 - break; 455 - } 456 - 457 - k++; 458 - } 459 - } 460 - } 461 - } 462 - 463 - if (new_l1d) 464 - l1d = new_l1d; 465 - 466 - if (new_l1i) 467 - l1i = new_l1i; 468 - 469 - if (new_l2) { 470 - l2 = new_l2; 471 - c->topo.llc_id = l2_id; 472 - c->topo.l2c_id = l2_id; 473 - } 474 - 475 - if (new_l3) { 476 - l3 = new_l3; 477 - c->topo.llc_id = l3_id; 478 - } 479 - 480 733 /* 481 - * If llc_id is not yet set, this means cpuid_level < 4 which in 482 - * turns means that the only possibility is SMT (as indicated in 483 - * cpuid1). Since cpuid2 doesn't specify shared caches, and we know 484 - * that SMT shares all caches, we can unconditionally set cpu_llc_id to 485 - * c->topo.pkg_id. 734 + * If llc_id is still unset, then cpuid_level < 4, which implies 735 + * that the only possibility left is SMT. Since CPUID(0x2) doesn't 736 + * specify any shared caches and SMT shares all caches, we can 737 + * unconditionally set LLC ID to the package ID so that all 738 + * threads share it. 486 739 */ 487 740 if (c->topo.llc_id == BAD_APICID) 488 741 c->topo.llc_id = c->topo.pkg_id; 489 742 490 - c->x86_cache_size = l3 ? l3 : (l2 ? l2 : (l1i+l1d)); 743 + c->x86_cache_size = l3 ? l3 : (l2 ? l2 : l1i + l1d); 491 744 492 745 if (!l2) 493 746 cpu_detect_cache_sizes(c); 494 747 } 495 748 749 + /* 750 + * Legacy Intel CPUID(0x2) path if CPUID(0x4) is not available. 751 + */ 752 + static void intel_cacheinfo_0x2(struct cpuinfo_x86 *c) 753 + { 754 + unsigned int l1i = 0, l1d = 0, l2 = 0, l3 = 0; 755 + const struct leaf_0x2_table *entry; 756 + union leaf_0x2_regs regs; 757 + u8 *ptr; 758 + 759 + if (c->cpuid_level < 2) 760 + return; 761 + 762 + cpuid_get_leaf_0x2_regs(&regs); 763 + for_each_leaf_0x2_entry(regs, ptr, entry) { 764 + switch (entry->c_type) { 765 + case CACHE_L1_INST: l1i += entry->c_size; break; 766 + case CACHE_L1_DATA: l1d += entry->c_size; break; 767 + case CACHE_L2: l2 += entry->c_size; break; 768 + case CACHE_L3: l3 += entry->c_size; break; 769 + } 770 + } 771 + 772 + intel_cacheinfo_done(c, l3, l2, l1i, l1d); 773 + } 774 + 775 + static unsigned int calc_cache_topo_id(struct cpuinfo_x86 *c, const struct _cpuid4_info *id4) 776 + { 777 + unsigned int num_threads_sharing; 778 + int index_msb; 779 + 780 + num_threads_sharing = 1 + id4->eax.split.num_threads_sharing; 781 + index_msb = get_count_order(num_threads_sharing); 782 + return c->topo.apicid & ~((1 << index_msb) - 1); 783 + } 784 + 785 + static bool intel_cacheinfo_0x4(struct cpuinfo_x86 *c) 786 + { 787 + struct cpu_cacheinfo *ci = get_cpu_cacheinfo(c->cpu_index); 788 + unsigned int l2_id = BAD_APICID, l3_id = BAD_APICID; 789 + unsigned int l1d = 0, l1i = 0, l2 = 0, l3 = 0; 790 + 791 + if (c->cpuid_level < 4) 792 + return false; 793 + 794 + /* 795 + * There should be at least one leaf. A non-zero value means 796 + * that the number of leaves has been previously initialized. 797 + */ 798 + if (!ci->num_leaves) 799 + ci->num_leaves = find_num_cache_leaves(c); 800 + 801 + if (!ci->num_leaves) 802 + return false; 803 + 804 + for (int i = 0; i < ci->num_leaves; i++) { 805 + struct _cpuid4_info id4 = {}; 806 + int ret; 807 + 808 + ret = intel_fill_cpuid4_info(i, &id4); 809 + if (ret < 0) 810 + continue; 811 + 812 + switch (id4.eax.split.level) { 813 + case 1: 814 + if (id4.eax.split.type == CTYPE_DATA) 815 + l1d = id4.size / 1024; 816 + else if (id4.eax.split.type == CTYPE_INST) 817 + l1i = id4.size / 1024; 818 + break; 819 + case 2: 820 + l2 = id4.size / 1024; 821 + l2_id = calc_cache_topo_id(c, &id4); 822 + break; 823 + case 3: 824 + l3 = id4.size / 1024; 825 + l3_id = calc_cache_topo_id(c, &id4); 826 + break; 827 + default: 828 + break; 829 + } 830 + } 831 + 832 + c->topo.l2c_id = l2_id; 833 + c->topo.llc_id = (l3_id == BAD_APICID) ? l2_id : l3_id; 834 + intel_cacheinfo_done(c, l3, l2, l1i, l1d); 835 + return true; 836 + } 837 + 838 + void init_intel_cacheinfo(struct cpuinfo_x86 *c) 839 + { 840 + /* Don't use CPUID(0x2) if CPUID(0x4) is supported. */ 841 + if (intel_cacheinfo_0x4(c)) 842 + return; 843 + 844 + intel_cacheinfo_0x2(c); 845 + } 846 + 847 + /* 848 + * <linux/cacheinfo.h> shared_cpu_map setup, AMD/Hygon 849 + */ 496 850 static int __cache_amd_cpumap_setup(unsigned int cpu, int index, 497 - struct _cpuid4_info_regs *base) 851 + const struct _cpuid4_info *id4) 498 852 { 499 853 struct cpu_cacheinfo *this_cpu_ci; 500 - struct cacheinfo *this_leaf; 854 + struct cacheinfo *ci; 501 855 int i, sibling; 502 856 503 857 /* ··· 492 880 this_cpu_ci = get_cpu_cacheinfo(i); 493 881 if (!this_cpu_ci->info_list) 494 882 continue; 495 - this_leaf = this_cpu_ci->info_list + index; 883 + 884 + ci = this_cpu_ci->info_list + index; 496 885 for_each_cpu(sibling, cpu_llc_shared_mask(cpu)) { 497 886 if (!cpu_online(sibling)) 498 887 continue; 499 - cpumask_set_cpu(sibling, 500 - &this_leaf->shared_cpu_map); 888 + cpumask_set_cpu(sibling, &ci->shared_cpu_map); 501 889 } 502 890 } 503 891 } else if (boot_cpu_has(X86_FEATURE_TOPOEXT)) { 504 892 unsigned int apicid, nshared, first, last; 505 893 506 - nshared = base->eax.split.num_threads_sharing + 1; 894 + nshared = id4->eax.split.num_threads_sharing + 1; 507 895 apicid = cpu_data(cpu).topo.apicid; 508 896 first = apicid - (apicid % nshared); 509 897 last = first + nshared - 1; ··· 517 905 if ((apicid < first) || (apicid > last)) 518 906 continue; 519 907 520 - this_leaf = this_cpu_ci->info_list + index; 908 + ci = this_cpu_ci->info_list + index; 521 909 522 910 for_each_online_cpu(sibling) { 523 911 apicid = cpu_data(sibling).topo.apicid; 524 912 if ((apicid < first) || (apicid > last)) 525 913 continue; 526 - cpumask_set_cpu(sibling, 527 - &this_leaf->shared_cpu_map); 914 + cpumask_set_cpu(sibling, &ci->shared_cpu_map); 528 915 } 529 916 } 530 917 } else ··· 532 921 return 1; 533 922 } 534 923 924 + /* 925 + * <linux/cacheinfo.h> shared_cpu_map setup, Intel + fallback AMD/Hygon 926 + */ 535 927 static void __cache_cpumap_setup(unsigned int cpu, int index, 536 - struct _cpuid4_info_regs *base) 928 + const struct _cpuid4_info *id4) 537 929 { 538 930 struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(cpu); 539 - struct cacheinfo *this_leaf, *sibling_leaf; 931 + struct cpuinfo_x86 *c = &cpu_data(cpu); 932 + struct cacheinfo *ci, *sibling_ci; 540 933 unsigned long num_threads_sharing; 541 934 int index_msb, i; 542 - struct cpuinfo_x86 *c = &cpu_data(cpu); 543 935 544 - if (c->x86_vendor == X86_VENDOR_AMD || 545 - c->x86_vendor == X86_VENDOR_HYGON) { 546 - if (__cache_amd_cpumap_setup(cpu, index, base)) 936 + if (c->x86_vendor == X86_VENDOR_AMD || c->x86_vendor == X86_VENDOR_HYGON) { 937 + if (__cache_amd_cpumap_setup(cpu, index, id4)) 547 938 return; 548 939 } 549 940 550 - this_leaf = this_cpu_ci->info_list + index; 551 - num_threads_sharing = 1 + base->eax.split.num_threads_sharing; 941 + ci = this_cpu_ci->info_list + index; 942 + num_threads_sharing = 1 + id4->eax.split.num_threads_sharing; 552 943 553 - cpumask_set_cpu(cpu, &this_leaf->shared_cpu_map); 944 + cpumask_set_cpu(cpu, &ci->shared_cpu_map); 554 945 if (num_threads_sharing == 1) 555 946 return; 556 947 ··· 562 949 if (cpu_data(i).topo.apicid >> index_msb == c->topo.apicid >> index_msb) { 563 950 struct cpu_cacheinfo *sib_cpu_ci = get_cpu_cacheinfo(i); 564 951 952 + /* Skip if itself or no cacheinfo */ 565 953 if (i == cpu || !sib_cpu_ci->info_list) 566 - continue;/* skip if itself or no cacheinfo */ 567 - sibling_leaf = sib_cpu_ci->info_list + index; 568 - cpumask_set_cpu(i, &this_leaf->shared_cpu_map); 569 - cpumask_set_cpu(cpu, &sibling_leaf->shared_cpu_map); 954 + continue; 955 + 956 + sibling_ci = sib_cpu_ci->info_list + index; 957 + cpumask_set_cpu(i, &ci->shared_cpu_map); 958 + cpumask_set_cpu(cpu, &sibling_ci->shared_cpu_map); 570 959 } 571 960 } 572 961 573 - static void ci_leaf_init(struct cacheinfo *this_leaf, 574 - struct _cpuid4_info_regs *base) 962 + static void ci_info_init(struct cacheinfo *ci, const struct _cpuid4_info *id4, 963 + struct amd_northbridge *nb) 575 964 { 576 - this_leaf->id = base->id; 577 - this_leaf->attributes = CACHE_ID; 578 - this_leaf->level = base->eax.split.level; 579 - this_leaf->type = cache_type_map[base->eax.split.type]; 580 - this_leaf->coherency_line_size = 581 - base->ebx.split.coherency_line_size + 1; 582 - this_leaf->ways_of_associativity = 583 - base->ebx.split.ways_of_associativity + 1; 584 - this_leaf->size = base->size; 585 - this_leaf->number_of_sets = base->ecx.split.number_of_sets + 1; 586 - this_leaf->physical_line_partition = 587 - base->ebx.split.physical_line_partition + 1; 588 - this_leaf->priv = base->nb; 965 + ci->id = id4->id; 966 + ci->attributes = CACHE_ID; 967 + ci->level = id4->eax.split.level; 968 + ci->type = cache_type_map[id4->eax.split.type]; 969 + ci->coherency_line_size = id4->ebx.split.coherency_line_size + 1; 970 + ci->ways_of_associativity = id4->ebx.split.ways_of_associativity + 1; 971 + ci->size = id4->size; 972 + ci->number_of_sets = id4->ecx.split.number_of_sets + 1; 973 + ci->physical_line_partition = id4->ebx.split.physical_line_partition + 1; 974 + ci->priv = nb; 589 975 } 590 976 591 977 int init_cache_level(unsigned int cpu) ··· 599 987 } 600 988 601 989 /* 602 - * The max shared threads number comes from CPUID.4:EAX[25-14] with input 990 + * The max shared threads number comes from CPUID(0x4) EAX[25-14] with input 603 991 * ECX as cache index. Then right shift apicid by the number's order to get 604 992 * cache id for this cache node. 605 993 */ 606 - static void get_cache_id(int cpu, struct _cpuid4_info_regs *id4_regs) 994 + static void get_cache_id(int cpu, struct _cpuid4_info *id4) 607 995 { 608 996 struct cpuinfo_x86 *c = &cpu_data(cpu); 609 997 unsigned long num_threads_sharing; 610 998 int index_msb; 611 999 612 - num_threads_sharing = 1 + id4_regs->eax.split.num_threads_sharing; 1000 + num_threads_sharing = 1 + id4->eax.split.num_threads_sharing; 613 1001 index_msb = get_count_order(num_threads_sharing); 614 - id4_regs->id = c->topo.apicid >> index_msb; 1002 + id4->id = c->topo.apicid >> index_msb; 615 1003 } 616 1004 617 1005 int populate_cache_leaves(unsigned int cpu) 618 1006 { 619 - unsigned int idx, ret; 620 1007 struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(cpu); 621 - struct cacheinfo *this_leaf = this_cpu_ci->info_list; 622 - struct _cpuid4_info_regs id4_regs = {}; 1008 + struct cacheinfo *ci = this_cpu_ci->info_list; 1009 + u8 cpu_vendor = boot_cpu_data.x86_vendor; 1010 + struct amd_northbridge *nb = NULL; 1011 + struct _cpuid4_info id4 = {}; 1012 + int idx, ret; 623 1013 624 1014 for (idx = 0; idx < this_cpu_ci->num_leaves; idx++) { 625 - ret = cpuid4_cache_lookup_regs(idx, &id4_regs); 1015 + ret = fill_cpuid4_info(idx, &id4); 626 1016 if (ret) 627 1017 return ret; 628 - get_cache_id(cpu, &id4_regs); 629 - ci_leaf_init(this_leaf++, &id4_regs); 630 - __cache_cpumap_setup(cpu, idx, &id4_regs); 631 - } 632 - this_cpu_ci->cpu_map_populated = true; 633 1018 1019 + get_cache_id(cpu, &id4); 1020 + 1021 + if (cpu_vendor == X86_VENDOR_AMD || cpu_vendor == X86_VENDOR_HYGON) 1022 + nb = amd_init_l3_cache(idx); 1023 + 1024 + ci_info_init(ci++, &id4, nb); 1025 + __cache_cpumap_setup(cpu, idx, &id4); 1026 + } 1027 + 1028 + this_cpu_ci->cpu_map_populated = true; 634 1029 return 0; 635 1030 } 636 1031 ··· 653 1034 static unsigned long saved_cr4; 654 1035 static DEFINE_RAW_SPINLOCK(cache_disable_lock); 655 1036 1037 + /* 1038 + * Cache flushing is the most time-consuming step when programming the 1039 + * MTRRs. On many Intel CPUs without known erratas, it can be skipped 1040 + * if the CPU declares cache self-snooping support. 1041 + */ 1042 + static void maybe_flush_caches(void) 1043 + { 1044 + if (!static_cpu_has(X86_FEATURE_SELFSNOOP)) 1045 + wbinvd(); 1046 + } 1047 + 656 1048 void cache_disable(void) __acquires(cache_disable_lock) 657 1049 { 658 1050 unsigned long cr0; 659 1051 660 1052 /* 661 - * Note that this is not ideal 662 - * since the cache is only flushed/disabled for this CPU while the 663 - * MTRRs are changed, but changing this requires more invasive 664 - * changes to the way the kernel boots 1053 + * This is not ideal since the cache is only flushed/disabled 1054 + * for this CPU while the MTRRs are changed, but changing this 1055 + * requires more invasive changes to the way the kernel boots. 665 1056 */ 666 - 667 1057 raw_spin_lock(&cache_disable_lock); 668 1058 669 1059 /* Enter the no-fill (CD=1, NW=0) cache mode and flush caches. */ 670 1060 cr0 = read_cr0() | X86_CR0_CD; 671 1061 write_cr0(cr0); 672 1062 673 - /* 674 - * Cache flushing is the most time-consuming step when programming 675 - * the MTRRs. Fortunately, as per the Intel Software Development 676 - * Manual, we can skip it if the processor supports cache self- 677 - * snooping. 678 - */ 679 - if (!static_cpu_has(X86_FEATURE_SELFSNOOP)) 680 - wbinvd(); 1063 + maybe_flush_caches(); 681 1064 682 1065 /* Save value of CR4 and clear Page Global Enable (bit 7) */ 683 1066 if (cpu_feature_enabled(X86_FEATURE_PGE)) { ··· 694 1073 if (cpu_feature_enabled(X86_FEATURE_MTRR)) 695 1074 mtrr_disable(); 696 1075 697 - /* Again, only flush caches if we have to. */ 698 - if (!static_cpu_has(X86_FEATURE_SELFSNOOP)) 699 - wbinvd(); 1076 + maybe_flush_caches(); 700 1077 } 701 1078 702 1079 void cache_enable(void) __releases(cache_disable_lock)
-5
arch/x86/kernel/cpu/common.c
··· 1402 1402 * Affected CPU list is generally enough to enumerate the vulnerability, 1403 1403 * but for virtualization case check for ARCH_CAP MSR bits also, VMM may 1404 1404 * not want the guest to enumerate the bug. 1405 - * 1406 - * Set X86_BUG_MMIO_UNKNOWN for CPUs that are neither in the blacklist, 1407 - * nor in the whitelist and also don't enumerate MSR ARCH_CAP MMIO bits. 1408 1405 */ 1409 1406 if (!arch_cap_mmio_immune(x86_arch_cap_msr)) { 1410 1407 if (cpu_matches(cpu_vuln_blacklist, MMIO)) 1411 1408 setup_force_cpu_bug(X86_BUG_MMIO_STALE_DATA); 1412 - else if (!cpu_matches(cpu_vuln_whitelist, NO_MMIO)) 1413 - setup_force_cpu_bug(X86_BUG_MMIO_UNKNOWN); 1414 1409 } 1415 1410 1416 1411 if (!cpu_has(c, X86_FEATURE_BTC_NO)) {
+9
arch/x86/kernel/cpu/cpu.h
··· 75 75 void cacheinfo_amd_init_llc_id(struct cpuinfo_x86 *c, u16 die_id); 76 76 void cacheinfo_hygon_init_llc_id(struct cpuinfo_x86 *c); 77 77 78 + #if defined(CONFIG_AMD_NB) && defined(CONFIG_SYSFS) 79 + struct amd_northbridge *amd_init_l3_cache(int index); 80 + #else 81 + static inline struct amd_northbridge *amd_init_l3_cache(int index) 82 + { 83 + return NULL; 84 + } 85 + #endif 86 + 78 87 unsigned int aperfmperf_get_khz(int cpu); 79 88 void cpu_select_mitigations(void); 80 89
+4
arch/x86/kernel/cpu/cpuid-deps.c
··· 82 82 { X86_FEATURE_XFD, X86_FEATURE_XSAVES }, 83 83 { X86_FEATURE_XFD, X86_FEATURE_XGETBV1 }, 84 84 { X86_FEATURE_AMX_TILE, X86_FEATURE_XFD }, 85 + { X86_FEATURE_AMX_FP16, X86_FEATURE_AMX_TILE }, 86 + { X86_FEATURE_AMX_BF16, X86_FEATURE_AMX_TILE }, 87 + { X86_FEATURE_AMX_INT8, X86_FEATURE_AMX_TILE }, 85 88 { X86_FEATURE_SHSTK, X86_FEATURE_XSAVES }, 86 89 { X86_FEATURE_FRED, X86_FEATURE_LKGS }, 90 + { X86_FEATURE_SPEC_CTRL_SSBD, X86_FEATURE_SPEC_CTRL }, 87 91 {} 88 92 }; 89 93
+128
arch/x86/kernel/cpu/cpuid_0x2_table.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + 3 + #include <linux/sizes.h> 4 + 5 + #include <asm/cpuid/types.h> 6 + 7 + #include "cpu.h" 8 + 9 + #define CACHE_ENTRY(_desc, _type, _size) \ 10 + [_desc] = { \ 11 + .c_type = (_type), \ 12 + .c_size = (_size) / SZ_1K, \ 13 + } 14 + 15 + #define TLB_ENTRY(_desc, _type, _entries) \ 16 + [_desc] = { \ 17 + .t_type = (_type), \ 18 + .entries = (_entries), \ 19 + } 20 + 21 + const struct leaf_0x2_table cpuid_0x2_table[256] = { 22 + CACHE_ENTRY(0x06, CACHE_L1_INST, SZ_8K ), /* 4-way set assoc, 32 byte line size */ 23 + CACHE_ENTRY(0x08, CACHE_L1_INST, SZ_16K ), /* 4-way set assoc, 32 byte line size */ 24 + CACHE_ENTRY(0x09, CACHE_L1_INST, SZ_32K ), /* 4-way set assoc, 64 byte line size */ 25 + CACHE_ENTRY(0x0a, CACHE_L1_DATA, SZ_8K ), /* 2 way set assoc, 32 byte line size */ 26 + CACHE_ENTRY(0x0c, CACHE_L1_DATA, SZ_16K ), /* 4-way set assoc, 32 byte line size */ 27 + CACHE_ENTRY(0x0d, CACHE_L1_DATA, SZ_16K ), /* 4-way set assoc, 64 byte line size */ 28 + CACHE_ENTRY(0x0e, CACHE_L1_DATA, SZ_24K ), /* 6-way set assoc, 64 byte line size */ 29 + CACHE_ENTRY(0x21, CACHE_L2, SZ_256K ), /* 8-way set assoc, 64 byte line size */ 30 + CACHE_ENTRY(0x22, CACHE_L3, SZ_512K ), /* 4-way set assoc, sectored cache, 64 byte line size */ 31 + CACHE_ENTRY(0x23, CACHE_L3, SZ_1M ), /* 8-way set assoc, sectored cache, 64 byte line size */ 32 + CACHE_ENTRY(0x25, CACHE_L3, SZ_2M ), /* 8-way set assoc, sectored cache, 64 byte line size */ 33 + CACHE_ENTRY(0x29, CACHE_L3, SZ_4M ), /* 8-way set assoc, sectored cache, 64 byte line size */ 34 + CACHE_ENTRY(0x2c, CACHE_L1_DATA, SZ_32K ), /* 8-way set assoc, 64 byte line size */ 35 + CACHE_ENTRY(0x30, CACHE_L1_INST, SZ_32K ), /* 8-way set assoc, 64 byte line size */ 36 + CACHE_ENTRY(0x39, CACHE_L2, SZ_128K ), /* 4-way set assoc, sectored cache, 64 byte line size */ 37 + CACHE_ENTRY(0x3a, CACHE_L2, SZ_192K ), /* 6-way set assoc, sectored cache, 64 byte line size */ 38 + CACHE_ENTRY(0x3b, CACHE_L2, SZ_128K ), /* 2-way set assoc, sectored cache, 64 byte line size */ 39 + CACHE_ENTRY(0x3c, CACHE_L2, SZ_256K ), /* 4-way set assoc, sectored cache, 64 byte line size */ 40 + CACHE_ENTRY(0x3d, CACHE_L2, SZ_384K ), /* 6-way set assoc, sectored cache, 64 byte line size */ 41 + CACHE_ENTRY(0x3e, CACHE_L2, SZ_512K ), /* 4-way set assoc, sectored cache, 64 byte line size */ 42 + CACHE_ENTRY(0x3f, CACHE_L2, SZ_256K ), /* 2-way set assoc, 64 byte line size */ 43 + CACHE_ENTRY(0x41, CACHE_L2, SZ_128K ), /* 4-way set assoc, 32 byte line size */ 44 + CACHE_ENTRY(0x42, CACHE_L2, SZ_256K ), /* 4-way set assoc, 32 byte line size */ 45 + CACHE_ENTRY(0x43, CACHE_L2, SZ_512K ), /* 4-way set assoc, 32 byte line size */ 46 + CACHE_ENTRY(0x44, CACHE_L2, SZ_1M ), /* 4-way set assoc, 32 byte line size */ 47 + CACHE_ENTRY(0x45, CACHE_L2, SZ_2M ), /* 4-way set assoc, 32 byte line size */ 48 + CACHE_ENTRY(0x46, CACHE_L3, SZ_4M ), /* 4-way set assoc, 64 byte line size */ 49 + CACHE_ENTRY(0x47, CACHE_L3, SZ_8M ), /* 8-way set assoc, 64 byte line size */ 50 + CACHE_ENTRY(0x48, CACHE_L2, SZ_3M ), /* 12-way set assoc, 64 byte line size */ 51 + CACHE_ENTRY(0x49, CACHE_L3, SZ_4M ), /* 16-way set assoc, 64 byte line size */ 52 + CACHE_ENTRY(0x4a, CACHE_L3, SZ_6M ), /* 12-way set assoc, 64 byte line size */ 53 + CACHE_ENTRY(0x4b, CACHE_L3, SZ_8M ), /* 16-way set assoc, 64 byte line size */ 54 + CACHE_ENTRY(0x4c, CACHE_L3, SZ_12M ), /* 12-way set assoc, 64 byte line size */ 55 + CACHE_ENTRY(0x4d, CACHE_L3, SZ_16M ), /* 16-way set assoc, 64 byte line size */ 56 + CACHE_ENTRY(0x4e, CACHE_L2, SZ_6M ), /* 24-way set assoc, 64 byte line size */ 57 + CACHE_ENTRY(0x60, CACHE_L1_DATA, SZ_16K ), /* 8-way set assoc, sectored cache, 64 byte line size */ 58 + CACHE_ENTRY(0x66, CACHE_L1_DATA, SZ_8K ), /* 4-way set assoc, sectored cache, 64 byte line size */ 59 + CACHE_ENTRY(0x67, CACHE_L1_DATA, SZ_16K ), /* 4-way set assoc, sectored cache, 64 byte line size */ 60 + CACHE_ENTRY(0x68, CACHE_L1_DATA, SZ_32K ), /* 4-way set assoc, sectored cache, 64 byte line size */ 61 + CACHE_ENTRY(0x78, CACHE_L2, SZ_1M ), /* 4-way set assoc, 64 byte line size */ 62 + CACHE_ENTRY(0x79, CACHE_L2, SZ_128K ), /* 8-way set assoc, sectored cache, 64 byte line size */ 63 + CACHE_ENTRY(0x7a, CACHE_L2, SZ_256K ), /* 8-way set assoc, sectored cache, 64 byte line size */ 64 + CACHE_ENTRY(0x7b, CACHE_L2, SZ_512K ), /* 8-way set assoc, sectored cache, 64 byte line size */ 65 + CACHE_ENTRY(0x7c, CACHE_L2, SZ_1M ), /* 8-way set assoc, sectored cache, 64 byte line size */ 66 + CACHE_ENTRY(0x7d, CACHE_L2, SZ_2M ), /* 8-way set assoc, 64 byte line size */ 67 + CACHE_ENTRY(0x7f, CACHE_L2, SZ_512K ), /* 2-way set assoc, 64 byte line size */ 68 + CACHE_ENTRY(0x80, CACHE_L2, SZ_512K ), /* 8-way set assoc, 64 byte line size */ 69 + CACHE_ENTRY(0x82, CACHE_L2, SZ_256K ), /* 8-way set assoc, 32 byte line size */ 70 + CACHE_ENTRY(0x83, CACHE_L2, SZ_512K ), /* 8-way set assoc, 32 byte line size */ 71 + CACHE_ENTRY(0x84, CACHE_L2, SZ_1M ), /* 8-way set assoc, 32 byte line size */ 72 + CACHE_ENTRY(0x85, CACHE_L2, SZ_2M ), /* 8-way set assoc, 32 byte line size */ 73 + CACHE_ENTRY(0x86, CACHE_L2, SZ_512K ), /* 4-way set assoc, 64 byte line size */ 74 + CACHE_ENTRY(0x87, CACHE_L2, SZ_1M ), /* 8-way set assoc, 64 byte line size */ 75 + CACHE_ENTRY(0xd0, CACHE_L3, SZ_512K ), /* 4-way set assoc, 64 byte line size */ 76 + CACHE_ENTRY(0xd1, CACHE_L3, SZ_1M ), /* 4-way set assoc, 64 byte line size */ 77 + CACHE_ENTRY(0xd2, CACHE_L3, SZ_2M ), /* 4-way set assoc, 64 byte line size */ 78 + CACHE_ENTRY(0xd6, CACHE_L3, SZ_1M ), /* 8-way set assoc, 64 byte line size */ 79 + CACHE_ENTRY(0xd7, CACHE_L3, SZ_2M ), /* 8-way set assoc, 64 byte line size */ 80 + CACHE_ENTRY(0xd8, CACHE_L3, SZ_4M ), /* 12-way set assoc, 64 byte line size */ 81 + CACHE_ENTRY(0xdc, CACHE_L3, SZ_2M ), /* 12-way set assoc, 64 byte line size */ 82 + CACHE_ENTRY(0xdd, CACHE_L3, SZ_4M ), /* 12-way set assoc, 64 byte line size */ 83 + CACHE_ENTRY(0xde, CACHE_L3, SZ_8M ), /* 12-way set assoc, 64 byte line size */ 84 + CACHE_ENTRY(0xe2, CACHE_L3, SZ_2M ), /* 16-way set assoc, 64 byte line size */ 85 + CACHE_ENTRY(0xe3, CACHE_L3, SZ_4M ), /* 16-way set assoc, 64 byte line size */ 86 + CACHE_ENTRY(0xe4, CACHE_L3, SZ_8M ), /* 16-way set assoc, 64 byte line size */ 87 + CACHE_ENTRY(0xea, CACHE_L3, SZ_12M ), /* 24-way set assoc, 64 byte line size */ 88 + CACHE_ENTRY(0xeb, CACHE_L3, SZ_18M ), /* 24-way set assoc, 64 byte line size */ 89 + CACHE_ENTRY(0xec, CACHE_L3, SZ_24M ), /* 24-way set assoc, 64 byte line size */ 90 + 91 + TLB_ENTRY( 0x01, TLB_INST_4K, 32 ), /* TLB_INST 4 KByte pages, 4-way set associative */ 92 + TLB_ENTRY( 0x02, TLB_INST_4M, 2 ), /* TLB_INST 4 MByte pages, full associative */ 93 + TLB_ENTRY( 0x03, TLB_DATA_4K, 64 ), /* TLB_DATA 4 KByte pages, 4-way set associative */ 94 + TLB_ENTRY( 0x04, TLB_DATA_4M, 8 ), /* TLB_DATA 4 MByte pages, 4-way set associative */ 95 + TLB_ENTRY( 0x05, TLB_DATA_4M, 32 ), /* TLB_DATA 4 MByte pages, 4-way set associative */ 96 + TLB_ENTRY( 0x0b, TLB_INST_4M, 4 ), /* TLB_INST 4 MByte pages, 4-way set associative */ 97 + TLB_ENTRY( 0x4f, TLB_INST_4K, 32 ), /* TLB_INST 4 KByte pages */ 98 + TLB_ENTRY( 0x50, TLB_INST_ALL, 64 ), /* TLB_INST 4 KByte and 2-MByte or 4-MByte pages */ 99 + TLB_ENTRY( 0x51, TLB_INST_ALL, 128 ), /* TLB_INST 4 KByte and 2-MByte or 4-MByte pages */ 100 + TLB_ENTRY( 0x52, TLB_INST_ALL, 256 ), /* TLB_INST 4 KByte and 2-MByte or 4-MByte pages */ 101 + TLB_ENTRY( 0x55, TLB_INST_2M_4M, 7 ), /* TLB_INST 2-MByte or 4-MByte pages, fully associative */ 102 + TLB_ENTRY( 0x56, TLB_DATA0_4M, 16 ), /* TLB_DATA0 4 MByte pages, 4-way set associative */ 103 + TLB_ENTRY( 0x57, TLB_DATA0_4K, 16 ), /* TLB_DATA0 4 KByte pages, 4-way associative */ 104 + TLB_ENTRY( 0x59, TLB_DATA0_4K, 16 ), /* TLB_DATA0 4 KByte pages, fully associative */ 105 + TLB_ENTRY( 0x5a, TLB_DATA0_2M_4M, 32 ), /* TLB_DATA0 2-MByte or 4 MByte pages, 4-way set associative */ 106 + TLB_ENTRY( 0x5b, TLB_DATA_4K_4M, 64 ), /* TLB_DATA 4 KByte and 4 MByte pages */ 107 + TLB_ENTRY( 0x5c, TLB_DATA_4K_4M, 128 ), /* TLB_DATA 4 KByte and 4 MByte pages */ 108 + TLB_ENTRY( 0x5d, TLB_DATA_4K_4M, 256 ), /* TLB_DATA 4 KByte and 4 MByte pages */ 109 + TLB_ENTRY( 0x61, TLB_INST_4K, 48 ), /* TLB_INST 4 KByte pages, full associative */ 110 + TLB_ENTRY( 0x63, TLB_DATA_1G_2M_4M, 4 ), /* TLB_DATA 1 GByte pages, 4-way set associative 111 + * (plus 32 entries TLB_DATA 2 MByte or 4 MByte pages, not encoded here) */ 112 + TLB_ENTRY( 0x6b, TLB_DATA_4K, 256 ), /* TLB_DATA 4 KByte pages, 8-way associative */ 113 + TLB_ENTRY( 0x6c, TLB_DATA_2M_4M, 128 ), /* TLB_DATA 2 MByte or 4 MByte pages, 8-way associative */ 114 + TLB_ENTRY( 0x6d, TLB_DATA_1G, 16 ), /* TLB_DATA 1 GByte pages, fully associative */ 115 + TLB_ENTRY( 0x76, TLB_INST_2M_4M, 8 ), /* TLB_INST 2-MByte or 4-MByte pages, fully associative */ 116 + TLB_ENTRY( 0xb0, TLB_INST_4K, 128 ), /* TLB_INST 4 KByte pages, 4-way set associative */ 117 + TLB_ENTRY( 0xb1, TLB_INST_2M_4M, 4 ), /* TLB_INST 2M pages, 4-way, 8 entries or 4M pages, 4-way entries */ 118 + TLB_ENTRY( 0xb2, TLB_INST_4K, 64 ), /* TLB_INST 4KByte pages, 4-way set associative */ 119 + TLB_ENTRY( 0xb3, TLB_DATA_4K, 128 ), /* TLB_DATA 4 KByte pages, 4-way set associative */ 120 + TLB_ENTRY( 0xb4, TLB_DATA_4K, 256 ), /* TLB_DATA 4 KByte pages, 4-way associative */ 121 + TLB_ENTRY( 0xb5, TLB_INST_4K, 64 ), /* TLB_INST 4 KByte pages, 8-way set associative */ 122 + TLB_ENTRY( 0xb6, TLB_INST_4K, 128 ), /* TLB_INST 4 KByte pages, 8-way set associative */ 123 + TLB_ENTRY( 0xba, TLB_DATA_4K, 64 ), /* TLB_DATA 4 KByte pages, 4-way associative */ 124 + TLB_ENTRY( 0xc0, TLB_DATA_4K_4M, 8 ), /* TLB_DATA 4 KByte and 4 MByte pages, 4-way associative */ 125 + TLB_ENTRY( 0xc1, STLB_4K_2M, 1024 ), /* STLB 4 KByte and 2 MByte pages, 8-way associative */ 126 + TLB_ENTRY( 0xc2, TLB_DATA_2M_4M, 16 ), /* TLB_DATA 2 MByte/4MByte pages, 4-way associative */ 127 + TLB_ENTRY( 0xca, STLB_4K, 512 ), /* STLB 4 KByte pages, 4-way associative */ 128 + };
+11 -113
arch/x86/kernel/cpu/intel.c
··· 6 6 #include <linux/minmax.h> 7 7 #include <linux/smp.h> 8 8 #include <linux/string.h> 9 + #include <linux/types.h> 9 10 10 11 #ifdef CONFIG_X86_64 11 12 #include <linux/topology.h> ··· 16 15 #include <asm/cpu_device_id.h> 17 16 #include <asm/cpufeature.h> 18 17 #include <asm/cpu.h> 18 + #include <asm/cpuid.h> 19 19 #include <asm/hwcap2.h> 20 20 #include <asm/intel-family.h> 21 21 #include <asm/microcode.h> ··· 648 646 } 649 647 #endif 650 648 651 - #define TLB_INST_4K 0x01 652 - #define TLB_INST_4M 0x02 653 - #define TLB_INST_2M_4M 0x03 654 - 655 - #define TLB_INST_ALL 0x05 656 - #define TLB_INST_1G 0x06 657 - 658 - #define TLB_DATA_4K 0x11 659 - #define TLB_DATA_4M 0x12 660 - #define TLB_DATA_2M_4M 0x13 661 - #define TLB_DATA_4K_4M 0x14 662 - 663 - #define TLB_DATA_1G 0x16 664 - #define TLB_DATA_1G_2M_4M 0x17 665 - 666 - #define TLB_DATA0_4K 0x21 667 - #define TLB_DATA0_4M 0x22 668 - #define TLB_DATA0_2M_4M 0x23 669 - 670 - #define STLB_4K 0x41 671 - #define STLB_4K_2M 0x42 672 - 673 - /* 674 - * All of leaf 0x2's one-byte TLB descriptors implies the same number of 675 - * entries for their respective TLB types. The 0x63 descriptor is an 676 - * exception: it implies 4 dTLB entries for 1GB pages 32 dTLB entries 677 - * for 2MB or 4MB pages. Encode descriptor 0x63 dTLB entry count for 678 - * 2MB/4MB pages here, as its count for dTLB 1GB pages is already at the 679 - * intel_tlb_table[] mapping. 680 - */ 681 - #define TLB_0x63_2M_4M_ENTRIES 32 682 - 683 - struct _tlb_table { 684 - unsigned char descriptor; 685 - char tlb_type; 686 - unsigned int entries; 687 - }; 688 - 689 - static const struct _tlb_table intel_tlb_table[] = { 690 - { 0x01, TLB_INST_4K, 32}, /* TLB_INST 4 KByte pages, 4-way set associative */ 691 - { 0x02, TLB_INST_4M, 2}, /* TLB_INST 4 MByte pages, full associative */ 692 - { 0x03, TLB_DATA_4K, 64}, /* TLB_DATA 4 KByte pages, 4-way set associative */ 693 - { 0x04, TLB_DATA_4M, 8}, /* TLB_DATA 4 MByte pages, 4-way set associative */ 694 - { 0x05, TLB_DATA_4M, 32}, /* TLB_DATA 4 MByte pages, 4-way set associative */ 695 - { 0x0b, TLB_INST_4M, 4}, /* TLB_INST 4 MByte pages, 4-way set associative */ 696 - { 0x4f, TLB_INST_4K, 32}, /* TLB_INST 4 KByte pages */ 697 - { 0x50, TLB_INST_ALL, 64}, /* TLB_INST 4 KByte and 2-MByte or 4-MByte pages */ 698 - { 0x51, TLB_INST_ALL, 128}, /* TLB_INST 4 KByte and 2-MByte or 4-MByte pages */ 699 - { 0x52, TLB_INST_ALL, 256}, /* TLB_INST 4 KByte and 2-MByte or 4-MByte pages */ 700 - { 0x55, TLB_INST_2M_4M, 7}, /* TLB_INST 2-MByte or 4-MByte pages, fully associative */ 701 - { 0x56, TLB_DATA0_4M, 16}, /* TLB_DATA0 4 MByte pages, 4-way set associative */ 702 - { 0x57, TLB_DATA0_4K, 16}, /* TLB_DATA0 4 KByte pages, 4-way associative */ 703 - { 0x59, TLB_DATA0_4K, 16}, /* TLB_DATA0 4 KByte pages, fully associative */ 704 - { 0x5a, TLB_DATA0_2M_4M, 32}, /* TLB_DATA0 2-MByte or 4 MByte pages, 4-way set associative */ 705 - { 0x5b, TLB_DATA_4K_4M, 64}, /* TLB_DATA 4 KByte and 4 MByte pages */ 706 - { 0x5c, TLB_DATA_4K_4M, 128}, /* TLB_DATA 4 KByte and 4 MByte pages */ 707 - { 0x5d, TLB_DATA_4K_4M, 256}, /* TLB_DATA 4 KByte and 4 MByte pages */ 708 - { 0x61, TLB_INST_4K, 48}, /* TLB_INST 4 KByte pages, full associative */ 709 - { 0x63, TLB_DATA_1G_2M_4M, 4}, /* TLB_DATA 1 GByte pages, 4-way set associative 710 - * (plus 32 entries TLB_DATA 2 MByte or 4 MByte pages, not encoded here) */ 711 - { 0x6b, TLB_DATA_4K, 256}, /* TLB_DATA 4 KByte pages, 8-way associative */ 712 - { 0x6c, TLB_DATA_2M_4M, 128}, /* TLB_DATA 2 MByte or 4 MByte pages, 8-way associative */ 713 - { 0x6d, TLB_DATA_1G, 16}, /* TLB_DATA 1 GByte pages, fully associative */ 714 - { 0x76, TLB_INST_2M_4M, 8}, /* TLB_INST 2-MByte or 4-MByte pages, fully associative */ 715 - { 0xb0, TLB_INST_4K, 128}, /* TLB_INST 4 KByte pages, 4-way set associative */ 716 - { 0xb1, TLB_INST_2M_4M, 4}, /* TLB_INST 2M pages, 4-way, 8 entries or 4M pages, 4-way entries */ 717 - { 0xb2, TLB_INST_4K, 64}, /* TLB_INST 4KByte pages, 4-way set associative */ 718 - { 0xb3, TLB_DATA_4K, 128}, /* TLB_DATA 4 KByte pages, 4-way set associative */ 719 - { 0xb4, TLB_DATA_4K, 256}, /* TLB_DATA 4 KByte pages, 4-way associative */ 720 - { 0xb5, TLB_INST_4K, 64}, /* TLB_INST 4 KByte pages, 8-way set associative */ 721 - { 0xb6, TLB_INST_4K, 128}, /* TLB_INST 4 KByte pages, 8-way set associative */ 722 - { 0xba, TLB_DATA_4K, 64}, /* TLB_DATA 4 KByte pages, 4-way associative */ 723 - { 0xc0, TLB_DATA_4K_4M, 8}, /* TLB_DATA 4 KByte and 4 MByte pages, 4-way associative */ 724 - { 0xc1, STLB_4K_2M, 1024}, /* STLB 4 KByte and 2 MByte pages, 8-way associative */ 725 - { 0xc2, TLB_DATA_2M_4M, 16}, /* TLB_DATA 2 MByte/4MByte pages, 4-way associative */ 726 - { 0xca, STLB_4K, 512}, /* STLB 4 KByte pages, 4-way associative */ 727 - { 0x00, 0, 0 } 728 - }; 729 - 730 - static void intel_tlb_lookup(const unsigned char desc) 649 + static void intel_tlb_lookup(const struct leaf_0x2_table *entry) 731 650 { 732 - unsigned int entries; 733 - unsigned char k; 651 + short entries = entry->entries; 734 652 735 - if (desc == 0) 736 - return; 737 - 738 - /* look up this descriptor in the table */ 739 - for (k = 0; intel_tlb_table[k].descriptor != desc && 740 - intel_tlb_table[k].descriptor != 0; k++) 741 - ; 742 - 743 - if (intel_tlb_table[k].tlb_type == 0) 744 - return; 745 - 746 - entries = intel_tlb_table[k].entries; 747 - switch (intel_tlb_table[k].tlb_type) { 653 + switch (entry->t_type) { 748 654 case STLB_4K: 749 655 tlb_lli_4k = max(tlb_lli_4k, entries); 750 656 tlb_lld_4k = max(tlb_lld_4k, entries); ··· 709 799 710 800 static void intel_detect_tlb(struct cpuinfo_x86 *c) 711 801 { 712 - int i, j, n; 713 - unsigned int regs[4]; 714 - unsigned char *desc = (unsigned char *)regs; 802 + const struct leaf_0x2_table *entry; 803 + union leaf_0x2_regs regs; 804 + u8 *ptr; 715 805 716 806 if (c->cpuid_level < 2) 717 807 return; 718 808 719 - /* Number of times to iterate */ 720 - n = cpuid_eax(2) & 0xFF; 721 - 722 - for (i = 0 ; i < n ; i++) { 723 - cpuid(2, &regs[0], &regs[1], &regs[2], &regs[3]); 724 - 725 - /* If bit 31 is set, this is an unknown format */ 726 - for (j = 0 ; j < 4 ; j++) 727 - if (regs[j] & (1 << 31)) 728 - regs[j] = 0; 729 - 730 - /* Byte 0 is level count, not a descriptor */ 731 - for (j = 1 ; j < 16 ; j++) 732 - intel_tlb_lookup(desc[j]); 733 - } 809 + cpuid_get_leaf_0x2_regs(&regs); 810 + for_each_leaf_0x2_entry(regs, ptr, entry) 811 + intel_tlb_lookup(entry); 734 812 } 735 813 736 814 static const struct cpu_dev intel_cpu_dev = {
+1 -1
arch/x86/kernel/cpu/mce/inject.c
··· 24 24 #include <linux/pci.h> 25 25 #include <linux/uaccess.h> 26 26 27 - #include <asm/amd_nb.h> 27 + #include <asm/amd/nb.h> 28 28 #include <asm/apic.h> 29 29 #include <asm/irq_vectors.h> 30 30 #include <asm/mce.h>
+1 -1
arch/x86/kernel/cpu/scattered.c
··· 53 53 { X86_FEATURE_PERFMON_V2, CPUID_EAX, 0, 0x80000022, 0 }, 54 54 { X86_FEATURE_AMD_LBR_V2, CPUID_EAX, 1, 0x80000022, 0 }, 55 55 { X86_FEATURE_AMD_LBR_PMC_FREEZE, CPUID_EAX, 2, 0x80000022, 0 }, 56 - { X86_FEATURE_AMD_HETEROGENEOUS_CORES, CPUID_EAX, 30, 0x80000026, 0 }, 56 + { X86_FEATURE_AMD_HTR_CORES, CPUID_EAX, 30, 0x80000026, 0 }, 57 57 { 0, 0, 0, 0, 0 } 58 58 }; 59 59
+1 -1
arch/x86/kernel/cpu/topology_amd.c
··· 182 182 if (cpu_feature_enabled(X86_FEATURE_TOPOEXT)) 183 183 has_topoext = cpu_parse_topology_ext(tscan); 184 184 185 - if (cpu_feature_enabled(X86_FEATURE_AMD_HETEROGENEOUS_CORES)) 185 + if (cpu_feature_enabled(X86_FEATURE_AMD_HTR_CORES)) 186 186 tscan->c->topo.cpu_type = cpuid_ebx(0x80000026); 187 187 188 188 if (!has_topoext && !parse_8000_0008(tscan))
+1 -1
arch/x86/mm/amdtopology.c
··· 25 25 #include <asm/numa.h> 26 26 #include <asm/mpspec.h> 27 27 #include <asm/apic.h> 28 - #include <asm/amd_nb.h> 28 + #include <asm/amd/nb.h> 29 29 30 30 static unsigned char __initdata nodeids[8]; 31 31
+1 -1
arch/x86/mm/numa.c
··· 18 18 #include <asm/e820/api.h> 19 19 #include <asm/proto.h> 20 20 #include <asm/dma.h> 21 - #include <asm/amd_nb.h> 21 + #include <asm/amd/nb.h> 22 22 23 23 #include "numa_internal.h" 24 24
+1 -1
arch/x86/pci/amd_bus.c
··· 5 5 #include <linux/cpu.h> 6 6 #include <linux/range.h> 7 7 8 - #include <asm/amd_nb.h> 8 + #include <asm/amd/nb.h> 9 9 #include <asm/pci_x86.h> 10 10 11 11 #include <asm/pci-direct.h>
+1 -1
arch/x86/pci/fixup.c
··· 9 9 #include <linux/pci.h> 10 10 #include <linux/suspend.h> 11 11 #include <linux/vgaarb.h> 12 - #include <asm/amd_node.h> 12 + #include <asm/amd/node.h> 13 13 #include <asm/hpet.h> 14 14 #include <asm/pci_x86.h> 15 15
+1 -1
drivers/char/agp/amd64-agp.c
··· 16 16 #include <linux/mmzone.h> 17 17 #include <asm/page.h> /* PAGE_SIZE */ 18 18 #include <asm/e820/api.h> 19 - #include <asm/amd_nb.h> 19 + #include <asm/amd/nb.h> 20 20 #include <asm/gart.h> 21 21 #include "agp.h" 22 22
+2 -2
drivers/edac/amd64_edac.c
··· 2 2 #include <linux/ras.h> 3 3 #include <linux/string_choices.h> 4 4 #include "amd64_edac.h" 5 - #include <asm/amd_nb.h> 6 - #include <asm/amd_node.h> 5 + #include <asm/amd/nb.h> 6 + #include <asm/amd/node.h> 7 7 8 8 static struct edac_pci_ctl_info *pci_ctl; 9 9
+1 -1
drivers/hwmon/k10temp.c
··· 20 20 #include <linux/module.h> 21 21 #include <linux/pci.h> 22 22 #include <linux/pci_ids.h> 23 - #include <asm/amd_node.h> 23 + #include <asm/amd/node.h> 24 24 #include <asm/processor.h> 25 25 26 26 MODULE_DESCRIPTION("AMD Family 10h+ CPU core temperature monitor");
+3 -1
drivers/infiniband/core/cma.c
··· 72 72 static void cma_iboe_set_mgid(struct sockaddr *addr, union ib_gid *mgid, 73 73 enum ib_gid_type gid_type); 74 74 75 + static void cma_netevent_work_handler(struct work_struct *_work); 76 + 75 77 const char *__attribute_const__ rdma_event_msg(enum rdma_cm_event_type event) 76 78 { 77 79 size_t index = event; ··· 1049 1047 get_random_bytes(&id_priv->seq_num, sizeof id_priv->seq_num); 1050 1048 id_priv->id.route.addr.dev_addr.net = get_net(net); 1051 1049 id_priv->seq_num &= 0x00ffffff; 1050 + INIT_WORK(&id_priv->id.net_work, cma_netevent_work_handler); 1052 1051 1053 1052 rdma_restrack_new(&id_priv->res, RDMA_RESTRACK_CM_ID); 1054 1053 if (parent) ··· 5244 5241 if (!memcmp(current_id->id.route.addr.dev_addr.dst_dev_addr, 5245 5242 neigh->ha, ETH_ALEN)) 5246 5243 continue; 5247 - INIT_WORK(&current_id->id.net_work, cma_netevent_work_handler); 5248 5244 cma_id_get(current_id); 5249 5245 queue_work(cma_wq, &current_id->id.net_work); 5250 5246 }
+1 -1
drivers/infiniband/core/ucaps.c
··· 170 170 ucap->dev.class = &ucaps_class; 171 171 ucap->dev.devt = MKDEV(MAJOR(ucaps_base_dev), type); 172 172 ucap->dev.release = ucap_dev_release; 173 - ret = dev_set_name(&ucap->dev, ucap_names[type]); 173 + ret = dev_set_name(&ucap->dev, "%s", ucap_names[type]); 174 174 if (ret) 175 175 goto err_device; 176 176
+4 -2
drivers/infiniband/core/umem_odp.c
··· 76 76 77 77 npfns = (end - start) >> PAGE_SHIFT; 78 78 umem_odp->pfn_list = kvcalloc( 79 - npfns, sizeof(*umem_odp->pfn_list), GFP_KERNEL); 79 + npfns, sizeof(*umem_odp->pfn_list), 80 + GFP_KERNEL | __GFP_NOWARN); 80 81 if (!umem_odp->pfn_list) 81 82 return -ENOMEM; 82 83 83 84 umem_odp->dma_list = kvcalloc( 84 - ndmas, sizeof(*umem_odp->dma_list), GFP_KERNEL); 85 + ndmas, sizeof(*umem_odp->dma_list), 86 + GFP_KERNEL | __GFP_NOWARN); 85 87 if (!umem_odp->dma_list) { 86 88 ret = -ENOMEM; 87 89 goto out_pfn_list;
-10
drivers/infiniband/hw/bnxt_re/ib_verbs.c
··· 1774 1774 ib_srq); 1775 1775 struct bnxt_re_dev *rdev = srq->rdev; 1776 1776 struct bnxt_qplib_srq *qplib_srq = &srq->qplib_srq; 1777 - struct bnxt_qplib_nq *nq = NULL; 1778 1777 1779 - if (qplib_srq->cq) 1780 - nq = qplib_srq->cq->nq; 1781 1778 if (rdev->chip_ctx->modes.toggle_bits & BNXT_QPLIB_SRQ_TOGGLE_BIT) { 1782 1779 free_page((unsigned long)srq->uctx_srq_page); 1783 1780 hash_del(&srq->hash_entry); ··· 1782 1785 bnxt_qplib_destroy_srq(&rdev->qplib_res, qplib_srq); 1783 1786 ib_umem_release(srq->umem); 1784 1787 atomic_dec(&rdev->stats.res.srq_count); 1785 - if (nq) 1786 - nq->budget--; 1787 1788 return 0; 1788 1789 } 1789 1790 ··· 1822 1827 struct ib_udata *udata) 1823 1828 { 1824 1829 struct bnxt_qplib_dev_attr *dev_attr; 1825 - struct bnxt_qplib_nq *nq = NULL; 1826 1830 struct bnxt_re_ucontext *uctx; 1827 1831 struct bnxt_re_dev *rdev; 1828 1832 struct bnxt_re_srq *srq; ··· 1867 1873 srq->qplib_srq.eventq_hw_ring_id = rdev->nqr->nq[0].ring_id; 1868 1874 srq->qplib_srq.sg_info.pgsize = PAGE_SIZE; 1869 1875 srq->qplib_srq.sg_info.pgshft = PAGE_SHIFT; 1870 - nq = &rdev->nqr->nq[0]; 1871 1876 1872 1877 if (udata) { 1873 1878 rc = bnxt_re_init_user_srq(rdev, pd, srq, udata); ··· 1901 1908 goto fail; 1902 1909 } 1903 1910 } 1904 - if (nq) 1905 - nq->budget++; 1906 1911 active_srqs = atomic_inc_return(&rdev->stats.res.srq_count); 1907 1912 if (active_srqs > rdev->stats.res.srq_watermark) 1908 1913 rdev->stats.res.srq_watermark = active_srqs; ··· 3070 3079 ib_umem_release(cq->umem); 3071 3080 3072 3081 atomic_dec(&rdev->stats.res.cq_count); 3073 - nq->budget--; 3074 3082 kfree(cq->cql); 3075 3083 return 0; 3076 3084 }
+1 -1
drivers/infiniband/hw/hns/hns_roce_main.c
··· 763 763 if (ret) 764 764 return ret; 765 765 } 766 - dma_set_max_seg_size(dev, UINT_MAX); 766 + dma_set_max_seg_size(dev, SZ_2G); 767 767 ret = ib_register_device(ib_dev, "hns_%d", dev); 768 768 if (ret) { 769 769 dev_err(dev, "ib_register_device failed!\n");
-2
drivers/infiniband/hw/mlx5/fs.c
··· 3461 3461 &UVERBS_METHOD(MLX5_IB_METHOD_STEERING_ANCHOR_DESTROY)); 3462 3462 3463 3463 const struct uapi_definition mlx5_ib_flow_defs[] = { 3464 - #if IS_ENABLED(CONFIG_INFINIBAND_USER_ACCESS) 3465 3464 UAPI_DEF_CHAIN_OBJ_TREE_NAMED( 3466 3465 MLX5_IB_OBJECT_FLOW_MATCHER), 3467 3466 UAPI_DEF_CHAIN_OBJ_TREE( ··· 3471 3472 UAPI_DEF_CHAIN_OBJ_TREE_NAMED( 3472 3473 MLX5_IB_OBJECT_STEERING_ANCHOR, 3473 3474 UAPI_DEF_IS_OBJ_SUPPORTED(mlx5_ib_shared_ft_allowed)), 3474 - #endif 3475 3475 {}, 3476 3476 }; 3477 3477
+7 -7
drivers/infiniband/hw/usnic/usnic_ib_main.c
··· 397 397 if (!us_ibdev) { 398 398 usnic_err("Device %s context alloc failed\n", 399 399 netdev_name(pci_get_drvdata(dev))); 400 - return ERR_PTR(-EFAULT); 400 + return NULL; 401 401 } 402 402 403 403 us_ibdev->ufdev = usnic_fwd_dev_alloc(dev); ··· 517 517 } 518 518 519 519 us_ibdev = usnic_ib_device_add(parent_pci); 520 - if (IS_ERR_OR_NULL(us_ibdev)) { 521 - us_ibdev = us_ibdev ? us_ibdev : ERR_PTR(-EFAULT); 520 + if (!us_ibdev) { 521 + us_ibdev = ERR_PTR(-EFAULT); 522 522 goto out; 523 523 } 524 524 ··· 586 586 } 587 587 588 588 pf = usnic_ib_discover_pf(vf->vnic); 589 - if (IS_ERR_OR_NULL(pf)) { 590 - usnic_err("Failed to discover pf of vnic %s with err%ld\n", 591 - pci_name(pdev), PTR_ERR(pf)); 592 - err = pf ? PTR_ERR(pf) : -EFAULT; 589 + if (IS_ERR(pf)) { 590 + err = PTR_ERR(pf); 591 + usnic_err("Failed to discover pf of vnic %s with err%d\n", 592 + pci_name(pdev), err); 593 593 goto out_clean_vnic; 594 594 } 595 595
+6
drivers/infiniband/sw/rxe/rxe_loc.h
··· 140 140 return IB_MTU_4096; 141 141 } 142 142 143 + static inline bool is_odp_mr(struct rxe_mr *mr) 144 + { 145 + return IS_ENABLED(CONFIG_INFINIBAND_ON_DEMAND_PAGING) && mr->umem && 146 + mr->umem->is_odp; 147 + } 148 + 143 149 void free_rd_atomic_resource(struct resp_res *res); 144 150 145 151 static inline void rxe_advance_resp_resource(struct rxe_qp *qp)
+2 -2
drivers/infiniband/sw/rxe/rxe_mr.c
··· 323 323 return err; 324 324 } 325 325 326 - if (mr->umem->is_odp) 326 + if (is_odp_mr(mr)) 327 327 return rxe_odp_mr_copy(mr, iova, addr, length, dir); 328 328 else 329 329 return rxe_mr_copy_xarray(mr, iova, addr, length, dir); ··· 536 536 u64 *va; 537 537 538 538 /* ODP is not supported right now. WIP. */ 539 - if (mr->umem->is_odp) 539 + if (is_odp_mr(mr)) 540 540 return RESPST_ERR_UNSUPPORTED_OPCODE; 541 541 542 542 /* See IBA oA19-28 */
+2 -2
drivers/infiniband/sw/rxe/rxe_resp.c
··· 650 650 struct resp_res *res = qp->resp.res; 651 651 652 652 /* ODP is not supported right now. WIP. */ 653 - if (mr->umem->is_odp) 653 + if (is_odp_mr(mr)) 654 654 return RESPST_ERR_UNSUPPORTED_OPCODE; 655 655 656 656 /* oA19-14, oA19-15 */ ··· 706 706 if (!res->replay) { 707 707 u64 iova = qp->resp.va + qp->resp.offset; 708 708 709 - if (mr->umem->is_odp) 709 + if (is_odp_mr(mr)) 710 710 err = rxe_odp_atomic_op(mr, iova, pkt->opcode, 711 711 atmeth_comp(pkt), 712 712 atmeth_swap_add(pkt),
+2 -2
drivers/platform/x86/amd/hsmp/acpi.c
··· 9 9 10 10 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 11 11 12 - #include <asm/amd_hsmp.h> 12 + #include <asm/amd/hsmp.h> 13 13 14 14 #include <linux/acpi.h> 15 15 #include <linux/device.h> ··· 23 23 24 24 #include <uapi/asm-generic/errno-base.h> 25 25 26 - #include <asm/amd_node.h> 26 + #include <asm/amd/node.h> 27 27 28 28 #include "hsmp.h" 29 29
+1 -1
drivers/platform/x86/amd/hsmp/hsmp.c
··· 7 7 * This file provides a device implementation for HSMP interface 8 8 */ 9 9 10 - #include <asm/amd_hsmp.h> 10 + #include <asm/amd/hsmp.h> 11 11 12 12 #include <linux/acpi.h> 13 13 #include <linux/delay.h>
+2 -2
drivers/platform/x86/amd/hsmp/plat.c
··· 9 9 10 10 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 11 11 12 - #include <asm/amd_hsmp.h> 12 + #include <asm/amd/hsmp.h> 13 13 14 14 #include <linux/build_bug.h> 15 15 #include <linux/device.h> ··· 18 18 #include <linux/platform_device.h> 19 19 #include <linux/sysfs.h> 20 20 21 - #include <asm/amd_node.h> 21 + #include <asm/amd/node.h> 22 22 23 23 #include "hsmp.h" 24 24
+1 -1
drivers/platform/x86/amd/pmc/mp1_stb.c
··· 11 11 12 12 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 13 13 14 - #include <asm/amd_nb.h> 14 + #include <asm/amd/nb.h> 15 15 #include <linux/debugfs.h> 16 16 #include <linux/seq_file.h> 17 17 #include <linux/uaccess.h>
+1 -1
drivers/platform/x86/amd/pmc/pmc.c
··· 28 28 #include <linux/seq_file.h> 29 29 #include <linux/uaccess.h> 30 30 31 - #include <asm/amd_node.h> 31 + #include <asm/amd/node.h> 32 32 33 33 #include "pmc.h" 34 34
+1 -1
drivers/platform/x86/amd/pmf/core.c
··· 14 14 #include <linux/pci.h> 15 15 #include <linux/platform_device.h> 16 16 #include <linux/power_supply.h> 17 - #include <asm/amd_node.h> 17 + #include <asm/amd/node.h> 18 18 #include "pmf.h" 19 19 20 20 /* PMF-SMU communication registers */
+1 -1
drivers/pnp/quirks.c
··· 290 290 291 291 #ifdef CONFIG_AMD_NB 292 292 293 - #include <asm/amd_nb.h> 293 + #include <asm/amd/nb.h> 294 294 295 295 static void quirk_amd_mmconfig_area(struct pnp_dev *dev) 296 296 {
+5 -2
drivers/ras/amd/atl/internal.h
··· 17 17 #include <linux/bitops.h> 18 18 #include <linux/ras.h> 19 19 20 - #include <asm/amd_nb.h> 21 - #include <asm/amd_node.h> 20 + #include <asm/amd/nb.h> 21 + #include <asm/amd/node.h> 22 22 23 23 #include "reg_fields.h" 24 24 ··· 361 361 { 362 362 atl_debug(ctx, "Unrecognized interleave mode: %u", ctx->map.intlv_mode); 363 363 } 364 + 365 + #define MI300_UMC_MCA_COL GENMASK(5, 1) 366 + #define MI300_UMC_MCA_ROW13 BIT(23) 364 367 365 368 #endif /* __AMD_ATL_INTERNAL_H__ */
+17 -2
drivers/ras/amd/atl/umc.c
··· 229 229 * Additionally, the PC and Bank bits may be hashed. This must be accounted for before 230 230 * reconstructing the normalized address. 231 231 */ 232 - #define MI300_UMC_MCA_COL GENMASK(5, 1) 233 232 #define MI300_UMC_MCA_BANK GENMASK(9, 6) 234 233 #define MI300_UMC_MCA_ROW GENMASK(24, 10) 235 234 #define MI300_UMC_MCA_PC BIT(25) ··· 319 320 * See amd_atl::convert_dram_to_norm_addr_mi300() for MI300 address formats. 320 321 */ 321 322 #define MI300_NUM_COL BIT(HWEIGHT(MI300_UMC_MCA_COL)) 322 - static void retire_row_mi300(struct atl_err *a_err) 323 + static void _retire_row_mi300(struct atl_err *a_err) 323 324 { 324 325 unsigned long addr; 325 326 struct page *p; ··· 348 349 349 350 memory_failure(addr, 0); 350 351 } 352 + } 353 + 354 + /* 355 + * In addition to the column bits, the row[13] bit should also be included when 356 + * calculating addresses affected by a physical row. 357 + * 358 + * Instead of running through another loop over a single bit, just run through 359 + * the column bits twice and flip the row[13] bit in-between. 360 + * 361 + * See MI300_UMC_MCA_ROW for the row bits in MCA_ADDR_UMC value. 362 + */ 363 + static void retire_row_mi300(struct atl_err *a_err) 364 + { 365 + _retire_row_mi300(a_err); 366 + a_err->addr ^= MI300_UMC_MCA_ROW13; 367 + _retire_row_mi300(a_err); 351 368 } 352 369 353 370 void amd_retire_dram_row(struct atl_err *a_err)
+8 -1
drivers/ras/amd/fmpm.c
··· 250 250 return true; 251 251 } 252 252 253 + /* 254 + * Row retirement is done on MI300 systems, and some bits are 'don't 255 + * care' for comparing addresses with unique physical rows. This 256 + * includes all column bits and the row[13] bit. 257 + */ 258 + #define MASK_ADDR(addr) ((addr) & ~(MI300_UMC_MCA_ROW13 | MI300_UMC_MCA_COL)) 259 + 253 260 static bool fpds_equal(struct cper_fru_poison_desc *old, struct cper_fru_poison_desc *new) 254 261 { 255 262 /* ··· 265 258 * 266 259 * Also, order the checks from most->least likely to fail to shortcut the code. 267 260 */ 268 - if (old->addr != new->addr) 261 + if (MASK_ADDR(old->addr) != MASK_ADDR(new->addr)) 269 262 return false; 270 263 271 264 if (old->hw_id != new->hw_id)
+2 -2
fs/afs/dynroot.c
··· 348 348 } 349 349 350 350 if ((unsigned long long)ctx->pos <= AFS_MAX_DYNROOT_CELL_INO) { 351 - rcu_read_lock(); 351 + down_read(&net->cells_lock); 352 352 ret = afs_dynroot_readdir_cells(net, ctx); 353 - rcu_read_unlock(); 353 + up_read(&net->cells_lock); 354 354 } 355 355 return ret; 356 356 }
+2 -2
fs/devpts/inode.c
··· 89 89 }; 90 90 91 91 static const struct fs_parameter_spec devpts_param_specs[] = { 92 - fsparam_u32 ("gid", Opt_gid), 92 + fsparam_gid ("gid", Opt_gid), 93 93 fsparam_s32 ("max", Opt_max), 94 94 fsparam_u32oct ("mode", Opt_mode), 95 95 fsparam_flag ("newinstance", Opt_newinstance), 96 96 fsparam_u32oct ("ptmxmode", Opt_ptmxmode), 97 - fsparam_u32 ("uid", Opt_uid), 97 + fsparam_uid ("uid", Opt_uid), 98 98 {} 99 99 }; 100 100
+3
fs/fuse/virtio_fs.c
··· 1669 1669 unsigned int virtqueue_size; 1670 1670 int err = -EIO; 1671 1671 1672 + if (!fsc->source) 1673 + return invalf(fsc, "No source specified"); 1674 + 1672 1675 /* This gets a reference on virtio_fs object. This ptr gets installed 1673 1676 * in fc->iq->priv. Once fuse_conn is going away, it calls ->put() 1674 1677 * to drop the reference to this object.
+6
fs/hfs/bnode.c
··· 67 67 else 68 68 key_len = tree->max_key_len + 1; 69 69 70 + if (key_len > sizeof(hfs_btree_key) || key_len < 1) { 71 + memset(key, 0, sizeof(hfs_btree_key)); 72 + pr_err("hfs: Invalid key length: %d\n", key_len); 73 + return; 74 + } 75 + 70 76 hfs_bnode_read(node, key, off, key_len); 71 77 } 72 78
+6
fs/hfsplus/bnode.c
··· 67 67 else 68 68 key_len = tree->max_key_len + 2; 69 69 70 + if (key_len > sizeof(hfsplus_btree_key) || key_len < 1) { 71 + memset(key, 0, sizeof(hfsplus_btree_key)); 72 + pr_err("hfsplus: Invalid key length: %d\n", key_len); 73 + return; 74 + } 75 + 70 76 hfs_bnode_read(node, key, off, key_len); 71 77 } 72 78
+1 -1
fs/iomap/buffered-io.c
··· 259 259 } 260 260 261 261 /* truncate len if we find any trailing uptodate block(s) */ 262 - for ( ; i <= last; i++) { 262 + while (++i <= last) { 263 263 if (ifs_block_is_uptodate(ifs, i)) { 264 264 plen -= (last - i + 1) * block_size; 265 265 last = i - 1;
+1 -1
fs/isofs/export.c
··· 180 180 return NULL; 181 181 182 182 return isofs_export_iget(sb, 183 - fh_len > 2 ? ifid->parent_block : 0, 183 + fh_len > 3 ? ifid->parent_block : 0, 184 184 ifid->parent_offset, 185 185 fh_len > 4 ? ifid->parent_generation : 0); 186 186 }
+4 -4
fs/namei.c
··· 125 125 126 126 #define EMBEDDED_NAME_MAX (PATH_MAX - offsetof(struct filename, iname)) 127 127 128 - static inline void initname(struct filename *name) 128 + static inline void initname(struct filename *name, const char __user *uptr) 129 129 { 130 - name->uptr = NULL; 130 + name->uptr = uptr; 131 131 name->aname = NULL; 132 132 atomic_set(&name->refcnt, 1); 133 133 } ··· 210 210 return ERR_PTR(-ENAMETOOLONG); 211 211 } 212 212 } 213 - initname(result); 213 + initname(result, filename); 214 214 audit_getname(result); 215 215 return result; 216 216 } ··· 268 268 return ERR_PTR(-ENAMETOOLONG); 269 269 } 270 270 memcpy((char *)result->name, filename, len); 271 - initname(result); 271 + initname(result, NULL); 272 272 audit_getname(result); 273 273 return result; 274 274 }
+21 -13
fs/namespace.c
··· 1830 1830 down_write(&namespace_sem); 1831 1831 } 1832 1832 1833 + DEFINE_GUARD(namespace_lock, struct rw_semaphore *, namespace_lock(), namespace_unlock()) 1834 + 1833 1835 enum umount_tree_flags { 1834 1836 UMOUNT_SYNC = 1, 1835 1837 UMOUNT_PROPAGATE = 2, ··· 2385 2383 return; 2386 2384 } 2387 2385 2388 - scoped_guard(rwsem_write, &namespace_sem) { 2386 + scoped_guard(namespace_lock, &namespace_sem) { 2389 2387 ns = m->mnt_ns; 2390 2388 if (!must_dissolve(ns)) 2391 2389 return; ··· 5191 5189 mnt_idmap_put(kattr->mnt_idmap); 5192 5190 } 5193 5191 5194 - static int copy_mount_setattr(struct mount_attr __user *uattr, size_t usize, 5195 - struct mount_kattr *kattr) 5192 + static int wants_mount_setattr(struct mount_attr __user *uattr, size_t usize, 5193 + struct mount_kattr *kattr) 5196 5194 { 5197 5195 int ret; 5198 5196 struct mount_attr attr; ··· 5215 5213 if (attr.attr_set == 0 && 5216 5214 attr.attr_clr == 0 && 5217 5215 attr.propagation == 0) 5218 - return 0; 5216 + return 0; /* Tell caller to not bother. */ 5219 5217 5220 - return build_mount_kattr(&attr, usize, kattr); 5218 + ret = build_mount_kattr(&attr, usize, kattr); 5219 + if (ret < 0) 5220 + return ret; 5221 + 5222 + return 1; 5221 5223 } 5222 5224 5223 5225 SYSCALL_DEFINE5(mount_setattr, int, dfd, const char __user *, path, ··· 5253 5247 if (flags & AT_RECURSIVE) 5254 5248 kattr.kflags |= MOUNT_KATTR_RECURSE; 5255 5249 5256 - err = copy_mount_setattr(uattr, usize, &kattr); 5257 - if (err) 5250 + err = wants_mount_setattr(uattr, usize, &kattr); 5251 + if (err <= 0) 5258 5252 return err; 5259 5253 5260 5254 err = user_path_at(dfd, path, kattr.lookup_flags, &target); ··· 5288 5282 if (flags & AT_RECURSIVE) 5289 5283 kattr.kflags |= MOUNT_KATTR_RECURSE; 5290 5284 5291 - ret = copy_mount_setattr(uattr, usize, &kattr); 5292 - if (ret) 5285 + ret = wants_mount_setattr(uattr, usize, &kattr); 5286 + if (ret < 0) 5293 5287 return ret; 5294 5288 5295 - ret = do_mount_setattr(&file->f_path, &kattr); 5296 - if (ret) 5297 - return ret; 5289 + if (ret) { 5290 + ret = do_mount_setattr(&file->f_path, &kattr); 5291 + if (ret) 5292 + return ret; 5298 5293 5299 - finish_mount_kattr(&kattr); 5294 + finish_mount_kattr(&kattr); 5295 + } 5300 5296 } 5301 5297 5302 5298 fd = get_unused_fd_flags(flags & O_CLOEXEC);
+4
fs/netfs/main.c
··· 127 127 if (mempool_init_slab_pool(&netfs_subrequest_pool, 100, netfs_subrequest_slab) < 0) 128 128 goto error_subreqpool; 129 129 130 + #ifdef CONFIG_PROC_FS 130 131 if (!proc_mkdir("fs/netfs", NULL)) 131 132 goto error_proc; 132 133 if (!proc_create_seq("fs/netfs/requests", S_IFREG | 0444, NULL, 133 134 &netfs_requests_seq_ops)) 134 135 goto error_procfile; 136 + #endif 135 137 #ifdef CONFIG_FSCACHE_STATS 136 138 if (!proc_create_single("fs/netfs/stats", S_IFREG | 0444, NULL, 137 139 netfs_stats_show)) ··· 146 144 return 0; 147 145 148 146 error_fscache: 147 + #ifdef CONFIG_PROC_FS 149 148 error_procfile: 150 149 remove_proc_subtree("fs/netfs", NULL); 151 150 error_proc: 151 + #endif 152 152 mempool_exit(&netfs_subrequest_pool); 153 153 error_subreqpool: 154 154 kmem_cache_destroy(netfs_subrequest_slab);
-2
fs/overlayfs/overlayfs.h
··· 541 541 bool ovl_is_metacopy_dentry(struct dentry *dentry); 542 542 char *ovl_get_redirect_xattr(struct ovl_fs *ofs, const struct path *path, int padding); 543 543 int ovl_ensure_verity_loaded(struct path *path); 544 - int ovl_get_verity_xattr(struct ovl_fs *ofs, const struct path *path, 545 - u8 *digest_buf, int *buf_length); 546 544 int ovl_validate_verity(struct ovl_fs *ofs, 547 545 struct path *metapath, 548 546 struct path *datapath);
+5
fs/overlayfs/super.c
··· 1138 1138 return ERR_PTR(-EINVAL); 1139 1139 } 1140 1140 1141 + if (ctx->nr == ctx->nr_data) { 1142 + pr_err("at least one non-data lowerdir is required\n"); 1143 + return ERR_PTR(-EINVAL); 1144 + } 1145 + 1141 1146 err = -EINVAL; 1142 1147 for (i = 0; i < ctx->nr; i++) { 1143 1148 l = &ctx->lower[i];
+49 -55
include/linux/dcache.h
··· 173 173 */ 174 174 175 175 /* d_flags entries */ 176 - #define DCACHE_OP_HASH BIT(0) 177 - #define DCACHE_OP_COMPARE BIT(1) 178 - #define DCACHE_OP_REVALIDATE BIT(2) 179 - #define DCACHE_OP_DELETE BIT(3) 180 - #define DCACHE_OP_PRUNE BIT(4) 176 + enum dentry_flags { 177 + DCACHE_OP_HASH = BIT(0), 178 + DCACHE_OP_COMPARE = BIT(1), 179 + DCACHE_OP_REVALIDATE = BIT(2), 180 + DCACHE_OP_DELETE = BIT(3), 181 + DCACHE_OP_PRUNE = BIT(4), 182 + /* 183 + * This dentry is possibly not currently connected to the dcache tree, 184 + * in which case its parent will either be itself, or will have this 185 + * flag as well. nfsd will not use a dentry with this bit set, but will 186 + * first endeavour to clear the bit either by discovering that it is 187 + * connected, or by performing lookup operations. Any filesystem which 188 + * supports nfsd_operations MUST have a lookup function which, if it 189 + * finds a directory inode with a DCACHE_DISCONNECTED dentry, will 190 + * d_move that dentry into place and return that dentry rather than the 191 + * passed one, typically using d_splice_alias. 192 + */ 193 + DCACHE_DISCONNECTED = BIT(5), 194 + DCACHE_REFERENCED = BIT(6), /* Recently used, don't discard. */ 195 + DCACHE_DONTCACHE = BIT(7), /* Purge from memory on final dput() */ 196 + DCACHE_CANT_MOUNT = BIT(8), 197 + DCACHE_GENOCIDE = BIT(9), 198 + DCACHE_SHRINK_LIST = BIT(10), 199 + DCACHE_OP_WEAK_REVALIDATE = BIT(11), 200 + /* 201 + * this dentry has been "silly renamed" and has to be deleted on the 202 + * last dput() 203 + */ 204 + DCACHE_NFSFS_RENAMED = BIT(12), 205 + DCACHE_FSNOTIFY_PARENT_WATCHED = BIT(13), /* Parent inode is watched by some fsnotify listener */ 206 + DCACHE_DENTRY_KILLED = BIT(14), 207 + DCACHE_MOUNTED = BIT(15), /* is a mountpoint */ 208 + DCACHE_NEED_AUTOMOUNT = BIT(16), /* handle automount on this dir */ 209 + DCACHE_MANAGE_TRANSIT = BIT(17), /* manage transit from this dirent */ 210 + DCACHE_LRU_LIST = BIT(18), 211 + DCACHE_ENTRY_TYPE = (7 << 19), /* bits 19..21 are for storing type: */ 212 + DCACHE_MISS_TYPE = (0 << 19), /* Negative dentry */ 213 + DCACHE_WHITEOUT_TYPE = (1 << 19), /* Whiteout dentry (stop pathwalk) */ 214 + DCACHE_DIRECTORY_TYPE = (2 << 19), /* Normal directory */ 215 + DCACHE_AUTODIR_TYPE = (3 << 19), /* Lookupless directory (presumed automount) */ 216 + DCACHE_REGULAR_TYPE = (4 << 19), /* Regular file type */ 217 + DCACHE_SPECIAL_TYPE = (5 << 19), /* Other file type */ 218 + DCACHE_SYMLINK_TYPE = (6 << 19), /* Symlink */ 219 + DCACHE_NOKEY_NAME = BIT(22), /* Encrypted name encoded without key */ 220 + DCACHE_OP_REAL = BIT(23), 221 + DCACHE_PAR_LOOKUP = BIT(24), /* being looked up (with parent locked shared) */ 222 + DCACHE_DENTRY_CURSOR = BIT(25), 223 + DCACHE_NORCU = BIT(26), /* No RCU delay for freeing */ 224 + }; 181 225 182 - #define DCACHE_DISCONNECTED BIT(5) 183 - /* This dentry is possibly not currently connected to the dcache tree, in 184 - * which case its parent will either be itself, or will have this flag as 185 - * well. nfsd will not use a dentry with this bit set, but will first 186 - * endeavour to clear the bit either by discovering that it is connected, 187 - * or by performing lookup operations. Any filesystem which supports 188 - * nfsd_operations MUST have a lookup function which, if it finds a 189 - * directory inode with a DCACHE_DISCONNECTED dentry, will d_move that 190 - * dentry into place and return that dentry rather than the passed one, 191 - * typically using d_splice_alias. */ 192 - 193 - #define DCACHE_REFERENCED BIT(6) /* Recently used, don't discard. */ 194 - 195 - #define DCACHE_DONTCACHE BIT(7) /* Purge from memory on final dput() */ 196 - 197 - #define DCACHE_CANT_MOUNT BIT(8) 198 - #define DCACHE_GENOCIDE BIT(9) 199 - #define DCACHE_SHRINK_LIST BIT(10) 200 - 201 - #define DCACHE_OP_WEAK_REVALIDATE BIT(11) 202 - 203 - #define DCACHE_NFSFS_RENAMED BIT(12) 204 - /* this dentry has been "silly renamed" and has to be deleted on the last 205 - * dput() */ 206 - #define DCACHE_FSNOTIFY_PARENT_WATCHED BIT(13) 207 - /* Parent inode is watched by some fsnotify listener */ 208 - 209 - #define DCACHE_DENTRY_KILLED BIT(14) 210 - 211 - #define DCACHE_MOUNTED BIT(15) /* is a mountpoint */ 212 - #define DCACHE_NEED_AUTOMOUNT BIT(16) /* handle automount on this dir */ 213 - #define DCACHE_MANAGE_TRANSIT BIT(17) /* manage transit from this dirent */ 214 226 #define DCACHE_MANAGED_DENTRY \ 215 227 (DCACHE_MOUNTED|DCACHE_NEED_AUTOMOUNT|DCACHE_MANAGE_TRANSIT) 216 - 217 - #define DCACHE_LRU_LIST BIT(18) 218 - 219 - #define DCACHE_ENTRY_TYPE (7 << 19) /* bits 19..21 are for storing type: */ 220 - #define DCACHE_MISS_TYPE (0 << 19) /* Negative dentry */ 221 - #define DCACHE_WHITEOUT_TYPE (1 << 19) /* Whiteout dentry (stop pathwalk) */ 222 - #define DCACHE_DIRECTORY_TYPE (2 << 19) /* Normal directory */ 223 - #define DCACHE_AUTODIR_TYPE (3 << 19) /* Lookupless directory (presumed automount) */ 224 - #define DCACHE_REGULAR_TYPE (4 << 19) /* Regular file type */ 225 - #define DCACHE_SPECIAL_TYPE (5 << 19) /* Other file type */ 226 - #define DCACHE_SYMLINK_TYPE (6 << 19) /* Symlink */ 227 - 228 - #define DCACHE_NOKEY_NAME BIT(22) /* Encrypted name encoded without key */ 229 - #define DCACHE_OP_REAL BIT(23) 230 - 231 - #define DCACHE_PAR_LOOKUP BIT(24) /* being looked up (with parent locked shared) */ 232 - #define DCACHE_DENTRY_CURSOR BIT(25) 233 - #define DCACHE_NORCU BIT(26) /* No RCU delay for freeing */ 234 228 235 229 extern seqlock_t rename_lock; 236 230
+7
include/rdma/ib_verbs.h
··· 4790 4790 4791 4791 struct ib_ucontext *ib_uverbs_get_ucontext_file(struct ib_uverbs_file *ufile); 4792 4792 4793 + #if IS_ENABLED(CONFIG_INFINIBAND_USER_ACCESS) 4793 4794 int uverbs_destroy_def_handler(struct uverbs_attr_bundle *attrs); 4795 + #else 4796 + static inline int uverbs_destroy_def_handler(struct uverbs_attr_bundle *attrs) 4797 + { 4798 + return 0; 4799 + } 4800 + #endif 4794 4801 4795 4802 struct net_device *rdma_alloc_netdev(struct ib_device *device, u32 port_num, 4796 4803 enum rdma_netdev_t type, const char *name,
+1 -1
sound/soc/amd/acp/acp-rembrandt.c
··· 22 22 #include <linux/pci.h> 23 23 #include <linux/pm_runtime.h> 24 24 25 - #include <asm/amd_node.h> 25 + #include <asm/amd/node.h> 26 26 27 27 #include "amd.h" 28 28 #include "../mach-config.h"
+1 -1
sound/soc/amd/acp/acp63.c
··· 21 21 #include <linux/pm_runtime.h> 22 22 #include <linux/pci.h> 23 23 24 - #include <asm/amd_node.h> 24 + #include <asm/amd/node.h> 25 25 26 26 #include "amd.h" 27 27 #include "acp-mach.h"
+1 -1
sound/soc/amd/acp/acp70.c
··· 23 23 #include "amd.h" 24 24 #include "acp-mach.h" 25 25 26 - #include <asm/amd_node.h> 26 + #include <asm/amd/node.h> 27 27 28 28 #define DRV_NAME "acp_asoc_acp70" 29 29
+1 -1
sound/soc/sof/amd/acp.c
··· 16 16 #include <linux/module.h> 17 17 #include <linux/pci.h> 18 18 19 - #include <asm/amd_node.h> 19 + #include <asm/amd/node.h> 20 20 21 21 #include "../ops.h" 22 22 #include "acp.h"
+2 -3
tools/arch/arm64/include/uapi/asm/kvm.h
··· 43 43 #define KVM_COALESCED_MMIO_PAGE_OFFSET 1 44 44 #define KVM_DIRTY_LOG_PAGE_OFFSET 64 45 45 46 - #define KVM_REG_SIZE(id) \ 47 - (1U << (((id) & KVM_REG_SIZE_MASK) >> KVM_REG_SIZE_SHIFT)) 48 - 49 46 struct kvm_regs { 50 47 struct user_pt_regs regs; /* sp = sp_el0 */ 51 48 ··· 105 108 #define KVM_ARM_VCPU_PTRAUTH_ADDRESS 5 /* VCPU uses address authentication */ 106 109 #define KVM_ARM_VCPU_PTRAUTH_GENERIC 6 /* VCPU uses generic authentication */ 107 110 #define KVM_ARM_VCPU_HAS_EL2 7 /* Support nested virtualization */ 111 + #define KVM_ARM_VCPU_HAS_EL2_E2H0 8 /* Limit NV support to E2H RES0 */ 108 112 109 113 struct kvm_vcpu_init { 110 114 __u32 target; ··· 416 418 #define KVM_DEV_ARM_VGIC_GRP_CPU_SYSREGS 6 417 419 #define KVM_DEV_ARM_VGIC_GRP_LEVEL_INFO 7 418 420 #define KVM_DEV_ARM_VGIC_GRP_ITS_REGS 8 421 + #define KVM_DEV_ARM_VGIC_GRP_MAINT_IRQ 9 419 422 #define KVM_DEV_ARM_VGIC_LINE_LEVEL_INFO_SHIFT 10 420 423 #define KVM_DEV_ARM_VGIC_LINE_LEVEL_INFO_MASK \ 421 424 (0x3fffffULL << KVM_DEV_ARM_VGIC_LINE_LEVEL_INFO_SHIFT)
+1 -23
tools/arch/arm64/include/uapi/asm/unistd.h
··· 1 1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 - /* 3 - * Copyright (C) 2012 ARM Ltd. 4 - * 5 - * This program is free software; you can redistribute it and/or modify 6 - * it under the terms of the GNU General Public License version 2 as 7 - * published by the Free Software Foundation. 8 - * 9 - * This program is distributed in the hope that it will be useful, 10 - * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 - * GNU General Public License for more details. 13 - * 14 - * You should have received a copy of the GNU General Public License 15 - * along with this program. If not, see <http://www.gnu.org/licenses/>. 16 - */ 17 - 18 - #define __ARCH_WANT_RENAMEAT 19 - #define __ARCH_WANT_NEW_STAT 20 - #define __ARCH_WANT_SET_GET_RLIMIT 21 - #define __ARCH_WANT_TIME32_SYSCALLS 22 - #define __ARCH_WANT_MEMFD_SECRET 23 - 24 - #include <asm-generic/unistd.h> 2 + #include <asm/unistd_64.h>
+30 -18
tools/arch/x86/include/asm/cpufeatures.h
··· 75 75 #define X86_FEATURE_CENTAUR_MCR ( 3*32+ 3) /* "centaur_mcr" Centaur MCRs (= MTRRs) */ 76 76 #define X86_FEATURE_K8 ( 3*32+ 4) /* Opteron, Athlon64 */ 77 77 #define X86_FEATURE_ZEN5 ( 3*32+ 5) /* CPU based on Zen5 microarchitecture */ 78 - #define X86_FEATURE_P3 ( 3*32+ 6) /* P3 */ 79 - #define X86_FEATURE_P4 ( 3*32+ 7) /* P4 */ 78 + /* Free ( 3*32+ 6) */ 79 + /* Free ( 3*32+ 7) */ 80 80 #define X86_FEATURE_CONSTANT_TSC ( 3*32+ 8) /* "constant_tsc" TSC ticks at a constant rate */ 81 81 #define X86_FEATURE_UP ( 3*32+ 9) /* "up" SMP kernel running on UP */ 82 82 #define X86_FEATURE_ART ( 3*32+10) /* "art" Always running timer (ART) */ ··· 329 329 #define X86_FEATURE_CLZERO (13*32+ 0) /* "clzero" CLZERO instruction */ 330 330 #define X86_FEATURE_IRPERF (13*32+ 1) /* "irperf" Instructions Retired Count */ 331 331 #define X86_FEATURE_XSAVEERPTR (13*32+ 2) /* "xsaveerptr" Always save/restore FP error pointers */ 332 + #define X86_FEATURE_INVLPGB (13*32+ 3) /* INVLPGB and TLBSYNC instructions supported */ 332 333 #define X86_FEATURE_RDPRU (13*32+ 4) /* "rdpru" Read processor register at user level */ 333 334 #define X86_FEATURE_WBNOINVD (13*32+ 9) /* "wbnoinvd" WBNOINVD instruction */ 334 335 #define X86_FEATURE_AMD_IBPB (13*32+12) /* Indirect Branch Prediction Barrier */ ··· 378 377 #define X86_FEATURE_V_SPEC_CTRL (15*32+20) /* "v_spec_ctrl" Virtual SPEC_CTRL */ 379 378 #define X86_FEATURE_VNMI (15*32+25) /* "vnmi" Virtual NMI */ 380 379 #define X86_FEATURE_SVME_ADDR_CHK (15*32+28) /* SVME addr check */ 380 + #define X86_FEATURE_IDLE_HLT (15*32+30) /* IDLE HLT intercept */ 381 381 382 382 /* Intel-defined CPU features, CPUID level 0x00000007:0 (ECX), word 16 */ 383 383 #define X86_FEATURE_AVX512VBMI (16*32+ 1) /* "avx512vbmi" AVX512 Vector Bit Manipulation instructions*/ ··· 436 434 #define X86_FEATURE_SPEC_CTRL_SSBD (18*32+31) /* Speculative Store Bypass Disable */ 437 435 438 436 /* AMD-defined memory encryption features, CPUID level 0x8000001f (EAX), word 19 */ 439 - #define X86_FEATURE_SME (19*32+ 0) /* "sme" AMD Secure Memory Encryption */ 440 - #define X86_FEATURE_SEV (19*32+ 1) /* "sev" AMD Secure Encrypted Virtualization */ 437 + #define X86_FEATURE_SME (19*32+ 0) /* "sme" Secure Memory Encryption */ 438 + #define X86_FEATURE_SEV (19*32+ 1) /* "sev" Secure Encrypted Virtualization */ 441 439 #define X86_FEATURE_VM_PAGE_FLUSH (19*32+ 2) /* VM Page Flush MSR is supported */ 442 - #define X86_FEATURE_SEV_ES (19*32+ 3) /* "sev_es" AMD Secure Encrypted Virtualization - Encrypted State */ 443 - #define X86_FEATURE_SEV_SNP (19*32+ 4) /* "sev_snp" AMD Secure Encrypted Virtualization - Secure Nested Paging */ 440 + #define X86_FEATURE_SEV_ES (19*32+ 3) /* "sev_es" Secure Encrypted Virtualization - Encrypted State */ 441 + #define X86_FEATURE_SEV_SNP (19*32+ 4) /* "sev_snp" Secure Encrypted Virtualization - Secure Nested Paging */ 444 442 #define X86_FEATURE_V_TSC_AUX (19*32+ 9) /* Virtual TSC_AUX */ 445 - #define X86_FEATURE_SME_COHERENT (19*32+10) /* AMD hardware-enforced cache coherency */ 446 - #define X86_FEATURE_DEBUG_SWAP (19*32+14) /* "debug_swap" AMD SEV-ES full debug state swap support */ 443 + #define X86_FEATURE_SME_COHERENT (19*32+10) /* hardware-enforced cache coherency */ 444 + #define X86_FEATURE_DEBUG_SWAP (19*32+14) /* "debug_swap" SEV-ES full debug state swap support */ 445 + #define X86_FEATURE_RMPREAD (19*32+21) /* RMPREAD instruction */ 446 + #define X86_FEATURE_SEGMENTED_RMP (19*32+23) /* Segmented RMP support */ 447 447 #define X86_FEATURE_SVSM (19*32+28) /* "svsm" SVSM present */ 448 + #define X86_FEATURE_HV_INUSE_WR_ALLOWED (19*32+30) /* Allow Write to in-use hypervisor-owned pages */ 448 449 449 450 /* AMD-defined Extended Feature 2 EAX, CPUID level 0x80000021 (EAX), word 20 */ 450 451 #define X86_FEATURE_NO_NESTED_DATA_BP (20*32+ 0) /* No Nested Data Breakpoints */ ··· 460 455 #define X86_FEATURE_SBPB (20*32+27) /* Selective Branch Prediction Barrier */ 461 456 #define X86_FEATURE_IBPB_BRTYPE (20*32+28) /* MSR_PRED_CMD[IBPB] flushes all branch type predictions */ 462 457 #define X86_FEATURE_SRSO_NO (20*32+29) /* CPU is not affected by SRSO */ 458 + #define X86_FEATURE_SRSO_USER_KERNEL_NO (20*32+30) /* CPU is not affected by SRSO across user/kernel boundaries */ 459 + #define X86_FEATURE_SRSO_BP_SPEC_REDUCE (20*32+31) /* 460 + * BP_CFG[BpSpecReduce] can be used to mitigate SRSO for VMs. 461 + * (SRSO_MSR_FIX in the official doc). 462 + */ 463 463 464 464 /* 465 465 * Extended auxiliary flags: Linux defined - for features scattered in various ··· 476 466 #define X86_FEATURE_CLEAR_BHB_LOOP (21*32+ 1) /* Clear branch history at syscall entry using SW loop */ 477 467 #define X86_FEATURE_BHI_CTRL (21*32+ 2) /* BHI_DIS_S HW control available */ 478 468 #define X86_FEATURE_CLEAR_BHB_HW (21*32+ 3) /* BHI_DIS_S HW control enabled */ 479 - #define X86_FEATURE_CLEAR_BHB_LOOP_ON_VMEXIT (21*32+ 4) /* Clear branch history at vmexit using SW loop */ 480 - #define X86_FEATURE_AMD_FAST_CPPC (21*32 + 5) /* Fast CPPC */ 481 - #define X86_FEATURE_AMD_HETEROGENEOUS_CORES (21*32 + 6) /* Heterogeneous Core Topology */ 482 - #define X86_FEATURE_AMD_WORKLOAD_CLASS (21*32 + 7) /* Workload Classification */ 469 + #define X86_FEATURE_CLEAR_BHB_VMEXIT (21*32+ 4) /* Clear branch history at vmexit using SW loop */ 470 + #define X86_FEATURE_AMD_FAST_CPPC (21*32+ 5) /* Fast CPPC */ 471 + #define X86_FEATURE_AMD_HTR_CORES (21*32+ 6) /* Heterogeneous Core Topology */ 472 + #define X86_FEATURE_AMD_WORKLOAD_CLASS (21*32+ 7) /* Workload Classification */ 473 + #define X86_FEATURE_PREFER_YMM (21*32+ 8) /* Avoid ZMM registers due to downclocking */ 483 474 484 475 /* 485 476 * BUG word(s) ··· 519 508 #define X86_BUG_ITLB_MULTIHIT X86_BUG(23) /* "itlb_multihit" CPU may incur MCE during certain page attribute changes */ 520 509 #define X86_BUG_SRBDS X86_BUG(24) /* "srbds" CPU may leak RNG bits if not mitigated */ 521 510 #define X86_BUG_MMIO_STALE_DATA X86_BUG(25) /* "mmio_stale_data" CPU is affected by Processor MMIO Stale Data vulnerabilities */ 522 - #define X86_BUG_MMIO_UNKNOWN X86_BUG(26) /* "mmio_unknown" CPU is too old and its MMIO Stale Data status is unknown */ 511 + /* unused, was #define X86_BUG_MMIO_UNKNOWN X86_BUG(26) "mmio_unknown" CPU is too old and its MMIO Stale Data status is unknown */ 523 512 #define X86_BUG_RETBLEED X86_BUG(27) /* "retbleed" CPU is affected by RETBleed */ 524 513 #define X86_BUG_EIBRS_PBRSB X86_BUG(28) /* "eibrs_pbrsb" EIBRS is vulnerable to Post Barrier RSB Predictions */ 525 514 #define X86_BUG_SMT_RSB X86_BUG(29) /* "smt_rsb" CPU is vulnerable to Cross-Thread Return Address Predictions */ ··· 527 516 #define X86_BUG_TDX_PW_MCE X86_BUG(31) /* "tdx_pw_mce" CPU may incur #MC if non-TD software does partial write to TDX private memory */ 528 517 529 518 /* BUG word 2 */ 530 - #define X86_BUG_SRSO X86_BUG(1*32 + 0) /* "srso" AMD SRSO bug */ 531 - #define X86_BUG_DIV0 X86_BUG(1*32 + 1) /* "div0" AMD DIV0 speculation bug */ 532 - #define X86_BUG_RFDS X86_BUG(1*32 + 2) /* "rfds" CPU is vulnerable to Register File Data Sampling */ 533 - #define X86_BUG_BHI X86_BUG(1*32 + 3) /* "bhi" CPU is affected by Branch History Injection */ 534 - #define X86_BUG_IBPB_NO_RET X86_BUG(1*32 + 4) /* "ibpb_no_ret" IBPB omits return target predictions */ 519 + #define X86_BUG_SRSO X86_BUG( 1*32+ 0) /* "srso" AMD SRSO bug */ 520 + #define X86_BUG_DIV0 X86_BUG( 1*32+ 1) /* "div0" AMD DIV0 speculation bug */ 521 + #define X86_BUG_RFDS X86_BUG( 1*32+ 2) /* "rfds" CPU is vulnerable to Register File Data Sampling */ 522 + #define X86_BUG_BHI X86_BUG( 1*32+ 3) /* "bhi" CPU is affected by Branch History Injection */ 523 + #define X86_BUG_IBPB_NO_RET X86_BUG( 1*32+ 4) /* "ibpb_no_ret" IBPB omits return target predictions */ 524 + #define X86_BUG_SPECTRE_V2_USER X86_BUG( 1*32+ 5) /* "spectre_v2_user" CPU is affected by Spectre variant 2 attack between user processes */ 535 525 #endif /* _ASM_X86_CPUFEATURES_H */
+19 -12
tools/arch/x86/include/asm/msr-index.h
··· 397 397 #define MSR_IA32_PASID_VALID BIT_ULL(31) 398 398 399 399 /* DEBUGCTLMSR bits (others vary by model): */ 400 - #define DEBUGCTLMSR_LBR (1UL << 0) /* last branch recording */ 400 + #define DEBUGCTLMSR_LBR_BIT 0 /* last branch recording */ 401 + #define DEBUGCTLMSR_LBR (1UL << DEBUGCTLMSR_LBR_BIT) 401 402 #define DEBUGCTLMSR_BTF_SHIFT 1 402 403 #define DEBUGCTLMSR_BTF (1UL << 1) /* single-step on branches */ 403 404 #define DEBUGCTLMSR_BUS_LOCK_DETECT (1UL << 2) ··· 611 610 #define MSR_AMD_PERF_CTL 0xc0010062 612 611 #define MSR_AMD_PERF_STATUS 0xc0010063 613 612 #define MSR_AMD_PSTATE_DEF_BASE 0xc0010064 613 + #define MSR_AMD64_GUEST_TSC_FREQ 0xc0010134 614 614 #define MSR_AMD64_OSVW_ID_LENGTH 0xc0010140 615 615 #define MSR_AMD64_OSVW_STATUS 0xc0010141 616 616 #define MSR_AMD_PPIN_CTL 0xc00102f0 ··· 648 646 #define MSR_AMD64_IBS_REG_COUNT_MAX 8 /* includes MSR_AMD64_IBSBRTARGET */ 649 647 #define MSR_AMD64_SVM_AVIC_DOORBELL 0xc001011b 650 648 #define MSR_AMD64_VM_PAGE_FLUSH 0xc001011e 649 + #define MSR_AMD64_VIRT_SPEC_CTRL 0xc001011f 651 650 #define MSR_AMD64_SEV_ES_GHCB 0xc0010130 652 651 #define MSR_AMD64_SEV 0xc0010131 653 652 #define MSR_AMD64_SEV_ENABLED_BIT 0 ··· 687 684 #define MSR_AMD64_SNP_SMT_PROT BIT_ULL(MSR_AMD64_SNP_SMT_PROT_BIT) 688 685 #define MSR_AMD64_SNP_RESV_BIT 18 689 686 #define MSR_AMD64_SNP_RESERVED_MASK GENMASK_ULL(63, MSR_AMD64_SNP_RESV_BIT) 690 - 691 - #define MSR_AMD64_VIRT_SPEC_CTRL 0xc001011f 692 - 693 687 #define MSR_AMD64_RMP_BASE 0xc0010132 694 688 #define MSR_AMD64_RMP_END 0xc0010133 689 + #define MSR_AMD64_RMP_CFG 0xc0010136 690 + #define MSR_AMD64_SEG_RMP_ENABLED_BIT 0 691 + #define MSR_AMD64_SEG_RMP_ENABLED BIT_ULL(MSR_AMD64_SEG_RMP_ENABLED_BIT) 692 + #define MSR_AMD64_RMP_SEGMENT_SHIFT(x) (((x) & GENMASK_ULL(13, 8)) >> 8) 695 693 696 694 #define MSR_SVSM_CAA 0xc001f000 697 695 ··· 703 699 #define MSR_AMD_CPPC_REQ 0xc00102b3 704 700 #define MSR_AMD_CPPC_STATUS 0xc00102b4 705 701 706 - #define AMD_CPPC_LOWEST_PERF(x) (((x) >> 0) & 0xff) 707 - #define AMD_CPPC_LOWNONLIN_PERF(x) (((x) >> 8) & 0xff) 708 - #define AMD_CPPC_NOMINAL_PERF(x) (((x) >> 16) & 0xff) 709 - #define AMD_CPPC_HIGHEST_PERF(x) (((x) >> 24) & 0xff) 702 + /* Masks for use with MSR_AMD_CPPC_CAP1 */ 703 + #define AMD_CPPC_LOWEST_PERF_MASK GENMASK(7, 0) 704 + #define AMD_CPPC_LOWNONLIN_PERF_MASK GENMASK(15, 8) 705 + #define AMD_CPPC_NOMINAL_PERF_MASK GENMASK(23, 16) 706 + #define AMD_CPPC_HIGHEST_PERF_MASK GENMASK(31, 24) 710 707 711 - #define AMD_CPPC_MAX_PERF(x) (((x) & 0xff) << 0) 712 - #define AMD_CPPC_MIN_PERF(x) (((x) & 0xff) << 8) 713 - #define AMD_CPPC_DES_PERF(x) (((x) & 0xff) << 16) 714 - #define AMD_CPPC_ENERGY_PERF_PREF(x) (((x) & 0xff) << 24) 708 + /* Masks for use with MSR_AMD_CPPC_REQ */ 709 + #define AMD_CPPC_MAX_PERF_MASK GENMASK(7, 0) 710 + #define AMD_CPPC_MIN_PERF_MASK GENMASK(15, 8) 711 + #define AMD_CPPC_DES_PERF_MASK GENMASK(23, 16) 712 + #define AMD_CPPC_EPP_PERF_MASK GENMASK(31, 24) 715 713 716 714 /* AMD Performance Counter Global Status and Control MSRs */ 717 715 #define MSR_AMD64_PERF_CNTR_GLOBAL_STATUS 0xc0000300 ··· 725 719 726 720 /* Zen4 */ 727 721 #define MSR_ZEN4_BP_CFG 0xc001102e 722 + #define MSR_ZEN4_BP_CFG_BP_SPEC_REDUCE_BIT 4 728 723 #define MSR_ZEN4_BP_CFG_SHARED_BTB_FIX_BIT 5 729 724 730 725 /* Fam 19h MSRs */
+4
tools/arch/x86/include/uapi/asm/kvm.h
··· 559 559 #define KVM_XEN_HVM_CONFIG_PVCLOCK_TSC_UNSTABLE (1 << 7) 560 560 #define KVM_XEN_HVM_CONFIG_SHARED_INFO_HVA (1 << 8) 561 561 562 + #define KVM_XEN_MSR_MIN_INDEX 0x40000000u 563 + #define KVM_XEN_MSR_MAX_INDEX 0x4fffffffu 564 + 562 565 struct kvm_xen_hvm_config { 563 566 __u32 flags; 564 567 __u32 msr; ··· 928 925 #define KVM_X86_SEV_VM 2 929 926 #define KVM_X86_SEV_ES_VM 3 930 927 #define KVM_X86_SNP_VM 4 928 + #define KVM_X86_TDX_VM 5 931 929 932 930 #endif /* _ASM_X86_KVM_H */
+2
tools/arch/x86/include/uapi/asm/svm.h
··· 95 95 #define SVM_EXIT_CR14_WRITE_TRAP 0x09e 96 96 #define SVM_EXIT_CR15_WRITE_TRAP 0x09f 97 97 #define SVM_EXIT_INVPCID 0x0a2 98 + #define SVM_EXIT_IDLE_HLT 0x0a6 98 99 #define SVM_EXIT_NPF 0x400 99 100 #define SVM_EXIT_AVIC_INCOMPLETE_IPI 0x401 100 101 #define SVM_EXIT_AVIC_UNACCELERATED_ACCESS 0x402 ··· 225 224 { SVM_EXIT_CR4_WRITE_TRAP, "write_cr4_trap" }, \ 226 225 { SVM_EXIT_CR8_WRITE_TRAP, "write_cr8_trap" }, \ 227 226 { SVM_EXIT_INVPCID, "invpcid" }, \ 227 + { SVM_EXIT_IDLE_HLT, "idle-halt" }, \ 228 228 { SVM_EXIT_NPF, "npf" }, \ 229 229 { SVM_EXIT_AVIC_INCOMPLETE_IPI, "avic_incomplete_ipi" }, \ 230 230 { SVM_EXIT_AVIC_UNACCELERATED_ACCESS, "avic_unaccelerated_access" }, \
+455 -336
tools/arch/x86/kcpuid/cpuid.csv
··· 1 1 # SPDX-License-Identifier: CC0-1.0 2 - # Generator: x86-cpuid-db v1.0 2 + # Generator: x86-cpuid-db v2.3 3 3 4 4 # 5 5 # Auto-generated file. ··· 12 12 # Leaf 0H 13 13 # Maximum standard leaf number + CPU vendor string 14 14 15 - 0, 0, eax, 31:0, max_std_leaf , Highest cpuid standard leaf supported 16 - 0, 0, ebx, 31:0, cpu_vendorid_0 , CPU vendor ID string bytes 0 - 3 17 - 0, 0, ecx, 31:0, cpu_vendorid_2 , CPU vendor ID string bytes 8 - 11 18 - 0, 0, edx, 31:0, cpu_vendorid_1 , CPU vendor ID string bytes 4 - 7 15 + 0x0, 0, eax, 31:0, max_std_leaf , Highest standard CPUID leaf supported 16 + 0x0, 0, ebx, 31:0, cpu_vendorid_0 , CPU vendor ID string bytes 0 - 3 17 + 0x0, 0, ecx, 31:0, cpu_vendorid_2 , CPU vendor ID string bytes 8 - 11 18 + 0x0, 0, edx, 31:0, cpu_vendorid_1 , CPU vendor ID string bytes 4 - 7 19 19 20 20 # Leaf 1H 21 21 # CPU FMS (Family/Model/Stepping) + standard feature flags 22 22 23 - 1, 0, eax, 3:0, stepping , Stepping ID 24 - 1, 0, eax, 7:4, base_model , Base CPU model ID 25 - 1, 0, eax, 11:8, base_family_id , Base CPU family ID 26 - 1, 0, eax, 13:12, cpu_type , CPU type 27 - 1, 0, eax, 19:16, ext_model , Extended CPU model ID 28 - 1, 0, eax, 27:20, ext_family , Extended CPU family ID 29 - 1, 0, ebx, 7:0, brand_id , Brand index 30 - 1, 0, ebx, 15:8, clflush_size , CLFLUSH instruction cache line size 31 - 1, 0, ebx, 23:16, n_logical_cpu , Logical CPU (HW threads) count 32 - 1, 0, ebx, 31:24, local_apic_id , Initial local APIC physical ID 33 - 1, 0, ecx, 0, pni , Streaming SIMD Extensions 3 (SSE3) 34 - 1, 0, ecx, 1, pclmulqdq , PCLMULQDQ instruction support 35 - 1, 0, ecx, 2, dtes64 , 64-bit DS save area 36 - 1, 0, ecx, 3, monitor , MONITOR/MWAIT support 37 - 1, 0, ecx, 4, ds_cpl , CPL Qualified Debug Store 38 - 1, 0, ecx, 5, vmx , Virtual Machine Extensions 39 - 1, 0, ecx, 6, smx , Safer Mode Extensions 40 - 1, 0, ecx, 7, est , Enhanced Intel SpeedStep 41 - 1, 0, ecx, 8, tm2 , Thermal Monitor 2 42 - 1, 0, ecx, 9, ssse3 , Supplemental SSE3 43 - 1, 0, ecx, 10, cid , L1 Context ID 44 - 1, 0, ecx, 11, sdbg , Sillicon Debug 45 - 1, 0, ecx, 12, fma , FMA extensions using YMM state 46 - 1, 0, ecx, 13, cx16 , CMPXCHG16B instruction support 47 - 1, 0, ecx, 14, xtpr , xTPR Update Control 48 - 1, 0, ecx, 15, pdcm , Perfmon and Debug Capability 49 - 1, 0, ecx, 17, pcid , Process-context identifiers 50 - 1, 0, ecx, 18, dca , Direct Cache Access 51 - 1, 0, ecx, 19, sse4_1 , SSE4.1 52 - 1, 0, ecx, 20, sse4_2 , SSE4.2 53 - 1, 0, ecx, 21, x2apic , X2APIC support 54 - 1, 0, ecx, 22, movbe , MOVBE instruction support 55 - 1, 0, ecx, 23, popcnt , POPCNT instruction support 56 - 1, 0, ecx, 24, tsc_deadline_timer , APIC timer one-shot operation 57 - 1, 0, ecx, 25, aes , AES instructions 58 - 1, 0, ecx, 26, xsave , XSAVE (and related instructions) support 59 - 1, 0, ecx, 27, osxsave , XSAVE (and related instructions) are enabled by OS 60 - 1, 0, ecx, 28, avx , AVX instructions support 61 - 1, 0, ecx, 29, f16c , Half-precision floating-point conversion support 62 - 1, 0, ecx, 30, rdrand , RDRAND instruction support 63 - 1, 0, ecx, 31, guest_status , System is running as guest; (para-)virtualized system 64 - 1, 0, edx, 0, fpu , Floating-Point Unit on-chip (x87) 65 - 1, 0, edx, 1, vme , Virtual-8086 Mode Extensions 66 - 1, 0, edx, 2, de , Debugging Extensions 67 - 1, 0, edx, 3, pse , Page Size Extension 68 - 1, 0, edx, 4, tsc , Time Stamp Counter 69 - 1, 0, edx, 5, msr , Model-Specific Registers (RDMSR and WRMSR support) 70 - 1, 0, edx, 6, pae , Physical Address Extensions 71 - 1, 0, edx, 7, mce , Machine Check Exception 72 - 1, 0, edx, 8, cx8 , CMPXCHG8B instruction 73 - 1, 0, edx, 9, apic , APIC on-chip 74 - 1, 0, edx, 11, sep , SYSENTER, SYSEXIT, and associated MSRs 75 - 1, 0, edx, 12, mtrr , Memory Type Range Registers 76 - 1, 0, edx, 13, pge , Page Global Extensions 77 - 1, 0, edx, 14, mca , Machine Check Architecture 78 - 1, 0, edx, 15, cmov , Conditional Move Instruction 79 - 1, 0, edx, 16, pat , Page Attribute Table 80 - 1, 0, edx, 17, pse36 , Page Size Extension (36-bit) 81 - 1, 0, edx, 18, pn , Processor Serial Number 82 - 1, 0, edx, 19, clflush , CLFLUSH instruction 83 - 1, 0, edx, 21, dts , Debug Store 84 - 1, 0, edx, 22, acpi , Thermal monitor and clock control 85 - 1, 0, edx, 23, mmx , MMX instructions 86 - 1, 0, edx, 24, fxsr , FXSAVE and FXRSTOR instructions 87 - 1, 0, edx, 25, sse , SSE instructions 88 - 1, 0, edx, 26, sse2 , SSE2 instructions 89 - 1, 0, edx, 27, ss , Self Snoop 90 - 1, 0, edx, 28, ht , Hyper-threading 91 - 1, 0, edx, 29, tm , Thermal Monitor 92 - 1, 0, edx, 30, ia64 , Legacy IA-64 (Itanium) support bit, now resreved 93 - 1, 0, edx, 31, pbe , Pending Break Enable 23 + 0x1, 0, eax, 3:0, stepping , Stepping ID 24 + 0x1, 0, eax, 7:4, base_model , Base CPU model ID 25 + 0x1, 0, eax, 11:8, base_family_id , Base CPU family ID 26 + 0x1, 0, eax, 13:12, cpu_type , CPU type 27 + 0x1, 0, eax, 19:16, ext_model , Extended CPU model ID 28 + 0x1, 0, eax, 27:20, ext_family , Extended CPU family ID 29 + 0x1, 0, ebx, 7:0, brand_id , Brand index 30 + 0x1, 0, ebx, 15:8, clflush_size , CLFLUSH instruction cache line size 31 + 0x1, 0, ebx, 23:16, n_logical_cpu , Logical CPU count 32 + 0x1, 0, ebx, 31:24, local_apic_id , Initial local APIC physical ID 33 + 0x1, 0, ecx, 0, pni , Streaming SIMD Extensions 3 (SSE3) 34 + 0x1, 0, ecx, 1, pclmulqdq , PCLMULQDQ instruction support 35 + 0x1, 0, ecx, 2, dtes64 , 64-bit DS save area 36 + 0x1, 0, ecx, 3, monitor , MONITOR/MWAIT support 37 + 0x1, 0, ecx, 4, ds_cpl , CPL Qualified Debug Store 38 + 0x1, 0, ecx, 5, vmx , Virtual Machine Extensions 39 + 0x1, 0, ecx, 6, smx , Safer Mode Extensions 40 + 0x1, 0, ecx, 7, est , Enhanced Intel SpeedStep 41 + 0x1, 0, ecx, 8, tm2 , Thermal Monitor 2 42 + 0x1, 0, ecx, 9, ssse3 , Supplemental SSE3 43 + 0x1, 0, ecx, 10, cid , L1 Context ID 44 + 0x1, 0, ecx, 11, sdbg , Silicon Debug 45 + 0x1, 0, ecx, 12, fma , FMA extensions using YMM state 46 + 0x1, 0, ecx, 13, cx16 , CMPXCHG16B instruction support 47 + 0x1, 0, ecx, 14, xtpr , xTPR Update Control 48 + 0x1, 0, ecx, 15, pdcm , Perfmon and Debug Capability 49 + 0x1, 0, ecx, 17, pcid , Process-context identifiers 50 + 0x1, 0, ecx, 18, dca , Direct Cache Access 51 + 0x1, 0, ecx, 19, sse4_1 , SSE4.1 52 + 0x1, 0, ecx, 20, sse4_2 , SSE4.2 53 + 0x1, 0, ecx, 21, x2apic , X2APIC support 54 + 0x1, 0, ecx, 22, movbe , MOVBE instruction support 55 + 0x1, 0, ecx, 23, popcnt , POPCNT instruction support 56 + 0x1, 0, ecx, 24, tsc_deadline_timer , APIC timer one-shot operation 57 + 0x1, 0, ecx, 25, aes , AES instructions 58 + 0x1, 0, ecx, 26, xsave , XSAVE (and related instructions) support 59 + 0x1, 0, ecx, 27, osxsave , XSAVE (and related instructions) are enabled by OS 60 + 0x1, 0, ecx, 28, avx , AVX instructions support 61 + 0x1, 0, ecx, 29, f16c , Half-precision floating-point conversion support 62 + 0x1, 0, ecx, 30, rdrand , RDRAND instruction support 63 + 0x1, 0, ecx, 31, guest_status , System is running as guest; (para-)virtualized system 64 + 0x1, 0, edx, 0, fpu , Floating-Point Unit on-chip (x87) 65 + 0x1, 0, edx, 1, vme , Virtual-8086 Mode Extensions 66 + 0x1, 0, edx, 2, de , Debugging Extensions 67 + 0x1, 0, edx, 3, pse , Page Size Extension 68 + 0x1, 0, edx, 4, tsc , Time Stamp Counter 69 + 0x1, 0, edx, 5, msr , Model-Specific Registers (RDMSR and WRMSR support) 70 + 0x1, 0, edx, 6, pae , Physical Address Extensions 71 + 0x1, 0, edx, 7, mce , Machine Check Exception 72 + 0x1, 0, edx, 8, cx8 , CMPXCHG8B instruction 73 + 0x1, 0, edx, 9, apic , APIC on-chip 74 + 0x1, 0, edx, 11, sep , SYSENTER, SYSEXIT, and associated MSRs 75 + 0x1, 0, edx, 12, mtrr , Memory Type Range Registers 76 + 0x1, 0, edx, 13, pge , Page Global Extensions 77 + 0x1, 0, edx, 14, mca , Machine Check Architecture 78 + 0x1, 0, edx, 15, cmov , Conditional Move Instruction 79 + 0x1, 0, edx, 16, pat , Page Attribute Table 80 + 0x1, 0, edx, 17, pse36 , Page Size Extension (36-bit) 81 + 0x1, 0, edx, 18, pn , Processor Serial Number 82 + 0x1, 0, edx, 19, clflush , CLFLUSH instruction 83 + 0x1, 0, edx, 21, dts , Debug Store 84 + 0x1, 0, edx, 22, acpi , Thermal monitor and clock control 85 + 0x1, 0, edx, 23, mmx , MMX instructions 86 + 0x1, 0, edx, 24, fxsr , FXSAVE and FXRSTOR instructions 87 + 0x1, 0, edx, 25, sse , SSE instructions 88 + 0x1, 0, edx, 26, sse2 , SSE2 instructions 89 + 0x1, 0, edx, 27, ss , Self Snoop 90 + 0x1, 0, edx, 28, ht , Hyper-threading 91 + 0x1, 0, edx, 29, tm , Thermal Monitor 92 + 0x1, 0, edx, 30, ia64 , Legacy IA-64 (Itanium) support bit, now reserved 93 + 0x1, 0, edx, 31, pbe , Pending Break Enable 94 94 95 95 # Leaf 2H 96 96 # Intel cache and TLB information one-byte descriptors 97 97 98 - 2, 0, eax, 7:0, iteration_count , Number of times this CPUD leaf must be queried 99 - 2, 0, eax, 15:8, desc1 , Descriptor #1 100 - 2, 0, eax, 23:16, desc2 , Descriptor #2 101 - 2, 0, eax, 30:24, desc3 , Descriptor #3 102 - 2, 0, eax, 31, eax_invalid , Descriptors 1-3 are invalid if set 103 - 2, 0, ebx, 7:0, desc4 , Descriptor #4 104 - 2, 0, ebx, 15:8, desc5 , Descriptor #5 105 - 2, 0, ebx, 23:16, desc6 , Descriptor #6 106 - 2, 0, ebx, 30:24, desc7 , Descriptor #7 107 - 2, 0, ebx, 31, ebx_invalid , Descriptors 4-7 are invalid if set 108 - 2, 0, ecx, 7:0, desc8 , Descriptor #8 109 - 2, 0, ecx, 15:8, desc9 , Descriptor #9 110 - 2, 0, ecx, 23:16, desc10 , Descriptor #10 111 - 2, 0, ecx, 30:24, desc11 , Descriptor #11 112 - 2, 0, ecx, 31, ecx_invalid , Descriptors 8-11 are invalid if set 113 - 2, 0, edx, 7:0, desc12 , Descriptor #12 114 - 2, 0, edx, 15:8, desc13 , Descriptor #13 115 - 2, 0, edx, 23:16, desc14 , Descriptor #14 116 - 2, 0, edx, 30:24, desc15 , Descriptor #15 117 - 2, 0, edx, 31, edx_invalid , Descriptors 12-15 are invalid if set 98 + 0x2, 0, eax, 7:0, iteration_count , Number of times this leaf must be queried 99 + 0x2, 0, eax, 15:8, desc1 , Descriptor #1 100 + 0x2, 0, eax, 23:16, desc2 , Descriptor #2 101 + 0x2, 0, eax, 30:24, desc3 , Descriptor #3 102 + 0x2, 0, eax, 31, eax_invalid , Descriptors 1-3 are invalid if set 103 + 0x2, 0, ebx, 7:0, desc4 , Descriptor #4 104 + 0x2, 0, ebx, 15:8, desc5 , Descriptor #5 105 + 0x2, 0, ebx, 23:16, desc6 , Descriptor #6 106 + 0x2, 0, ebx, 30:24, desc7 , Descriptor #7 107 + 0x2, 0, ebx, 31, ebx_invalid , Descriptors 4-7 are invalid if set 108 + 0x2, 0, ecx, 7:0, desc8 , Descriptor #8 109 + 0x2, 0, ecx, 15:8, desc9 , Descriptor #9 110 + 0x2, 0, ecx, 23:16, desc10 , Descriptor #10 111 + 0x2, 0, ecx, 30:24, desc11 , Descriptor #11 112 + 0x2, 0, ecx, 31, ecx_invalid , Descriptors 8-11 are invalid if set 113 + 0x2, 0, edx, 7:0, desc12 , Descriptor #12 114 + 0x2, 0, edx, 15:8, desc13 , Descriptor #13 115 + 0x2, 0, edx, 23:16, desc14 , Descriptor #14 116 + 0x2, 0, edx, 30:24, desc15 , Descriptor #15 117 + 0x2, 0, edx, 31, edx_invalid , Descriptors 12-15 are invalid if set 118 118 119 119 # Leaf 4H 120 120 # Intel deterministic cache parameters 121 121 122 - 4, 31:0, eax, 4:0, cache_type , Cache type field 123 - 4, 31:0, eax, 7:5, cache_level , Cache level (1-based) 124 - 4, 31:0, eax, 8, cache_self_init , Self-initialializing cache level 125 - 4, 31:0, eax, 9, fully_associative , Fully-associative cache 126 - 4, 31:0, eax, 25:14, num_threads_sharing , Number logical CPUs sharing this cache 127 - 4, 31:0, eax, 31:26, num_cores_on_die , Number of cores in the physical package 128 - 4, 31:0, ebx, 11:0, cache_linesize , System coherency line size (0-based) 129 - 4, 31:0, ebx, 21:12, cache_npartitions , Physical line partitions (0-based) 130 - 4, 31:0, ebx, 31:22, cache_nways , Ways of associativity (0-based) 131 - 4, 31:0, ecx, 30:0, cache_nsets , Cache number of sets (0-based) 132 - 4, 31:0, edx, 0, wbinvd_rll_no_guarantee, WBINVD/INVD not guaranteed for Remote Lower-Level caches 133 - 4, 31:0, edx, 1, ll_inclusive , Cache is inclusive of Lower-Level caches 134 - 4, 31:0, edx, 2, complex_indexing , Not a direct-mapped cache (complex function) 122 + 0x4, 31:0, eax, 4:0, cache_type , Cache type field 123 + 0x4, 31:0, eax, 7:5, cache_level , Cache level (1-based) 124 + 0x4, 31:0, eax, 8, cache_self_init , Self-initializing cache level 125 + 0x4, 31:0, eax, 9, fully_associative , Fully-associative cache 126 + 0x4, 31:0, eax, 25:14, num_threads_sharing , Number logical CPUs sharing this cache 127 + 0x4, 31:0, eax, 31:26, num_cores_on_die , Number of cores in the physical package 128 + 0x4, 31:0, ebx, 11:0, cache_linesize , System coherency line size (0-based) 129 + 0x4, 31:0, ebx, 21:12, cache_npartitions , Physical line partitions (0-based) 130 + 0x4, 31:0, ebx, 31:22, cache_nways , Ways of associativity (0-based) 131 + 0x4, 31:0, ecx, 30:0, cache_nsets , Cache number of sets (0-based) 132 + 0x4, 31:0, edx, 0, wbinvd_rll_no_guarantee, WBINVD/INVD not guaranteed for Remote Lower-Level caches 133 + 0x4, 31:0, edx, 1, ll_inclusive , Cache is inclusive of Lower-Level caches 134 + 0x4, 31:0, edx, 2, complex_indexing , Not a direct-mapped cache (complex function) 135 135 136 136 # Leaf 5H 137 137 # MONITOR/MWAIT instructions enumeration 138 138 139 - 5, 0, eax, 15:0, min_mon_size , Smallest monitor-line size, in bytes 140 - 5, 0, ebx, 15:0, max_mon_size , Largest monitor-line size, in bytes 141 - 5, 0, ecx, 0, mwait_ext , Enumeration of MONITOR/MWAIT extensions is supported 142 - 5, 0, ecx, 1, mwait_irq_break , Interrupts as a break-event for MWAIT is supported 143 - 5, 0, edx, 3:0, n_c0_substates , Number of C0 sub C-states supported using MWAIT 144 - 5, 0, edx, 7:4, n_c1_substates , Number of C1 sub C-states supported using MWAIT 145 - 5, 0, edx, 11:8, n_c2_substates , Number of C2 sub C-states supported using MWAIT 146 - 5, 0, edx, 15:12, n_c3_substates , Number of C3 sub C-states supported using MWAIT 147 - 5, 0, edx, 19:16, n_c4_substates , Number of C4 sub C-states supported using MWAIT 148 - 5, 0, edx, 23:20, n_c5_substates , Number of C5 sub C-states supported using MWAIT 149 - 5, 0, edx, 27:24, n_c6_substates , Number of C6 sub C-states supported using MWAIT 150 - 5, 0, edx, 31:28, n_c7_substates , Number of C7 sub C-states supported using MWAIT 139 + 0x5, 0, eax, 15:0, min_mon_size , Smallest monitor-line size, in bytes 140 + 0x5, 0, ebx, 15:0, max_mon_size , Largest monitor-line size, in bytes 141 + 0x5, 0, ecx, 0, mwait_ext , Enumeration of MONITOR/MWAIT extensions is supported 142 + 0x5, 0, ecx, 1, mwait_irq_break , Interrupts as a break-event for MWAIT is supported 143 + 0x5, 0, edx, 3:0, n_c0_substates , Number of C0 sub C-states supported using MWAIT 144 + 0x5, 0, edx, 7:4, n_c1_substates , Number of C1 sub C-states supported using MWAIT 145 + 0x5, 0, edx, 11:8, n_c2_substates , Number of C2 sub C-states supported using MWAIT 146 + 0x5, 0, edx, 15:12, n_c3_substates , Number of C3 sub C-states supported using MWAIT 147 + 0x5, 0, edx, 19:16, n_c4_substates , Number of C4 sub C-states supported using MWAIT 148 + 0x5, 0, edx, 23:20, n_c5_substates , Number of C5 sub C-states supported using MWAIT 149 + 0x5, 0, edx, 27:24, n_c6_substates , Number of C6 sub C-states supported using MWAIT 150 + 0x5, 0, edx, 31:28, n_c7_substates , Number of C7 sub C-states supported using MWAIT 151 151 152 152 # Leaf 6H 153 153 # Thermal and Power Management enumeration 154 154 155 - 6, 0, eax, 0, dtherm , Digital temprature sensor 156 - 6, 0, eax, 1, turbo_boost , Intel Turbo Boost 157 - 6, 0, eax, 2, arat , Always-Running APIC Timer (not affected by p-state) 158 - 6, 0, eax, 4, pln , Power Limit Notification (PLN) event 159 - 6, 0, eax, 5, ecmd , Clock modulation duty cycle extension 160 - 6, 0, eax, 6, pts , Package thermal management 161 - 6, 0, eax, 7, hwp , HWP (Hardware P-states) base registers are supported 162 - 6, 0, eax, 8, hwp_notify , HWP notification (IA32_HWP_INTERRUPT MSR) 163 - 6, 0, eax, 9, hwp_act_window , HWP activity window (IA32_HWP_REQUEST[bits 41:32]) supported 164 - 6, 0, eax, 10, hwp_epp , HWP Energy Performance Preference 165 - 6, 0, eax, 11, hwp_pkg_req , HWP Package Level Request 166 - 6, 0, eax, 13, hdc_base_regs , HDC base registers are supported 167 - 6, 0, eax, 14, turbo_boost_3_0 , Intel Turbo Boost Max 3.0 168 - 6, 0, eax, 15, hwp_capabilities , HWP Highest Performance change 169 - 6, 0, eax, 16, hwp_peci_override , HWP PECI override 170 - 6, 0, eax, 17, hwp_flexible , Flexible HWP 171 - 6, 0, eax, 18, hwp_fast , IA32_HWP_REQUEST MSR fast access mode 172 - 6, 0, eax, 19, hfi , HW_FEEDBACK MSRs supported 173 - 6, 0, eax, 20, hwp_ignore_idle , Ignoring idle logical CPU HWP req is supported 174 - 6, 0, eax, 23, thread_director , Intel thread director support 175 - 6, 0, eax, 24, therm_interrupt_bit25 , IA32_THERM_INTERRUPT MSR bit 25 is supported 176 - 6, 0, ebx, 3:0, n_therm_thresholds , Digital thermometer thresholds 177 - 6, 0, ecx, 0, aperfmperf , MPERF/APERF MSRs (effective frequency interface) 178 - 6, 0, ecx, 3, epb , IA32_ENERGY_PERF_BIAS MSR support 179 - 6, 0, ecx, 15:8, thrd_director_nclasses , Number of classes, Intel thread director 180 - 6, 0, edx, 0, perfcap_reporting , Performance capability reporting 181 - 6, 0, edx, 1, encap_reporting , Energy efficiency capability reporting 182 - 6, 0, edx, 11:8, feedback_sz , HW feedback interface struct size, in 4K pages 183 - 6, 0, edx, 31:16, this_lcpu_hwfdbk_idx , This logical CPU index @ HW feedback struct, 0-based 155 + 0x6, 0, eax, 0, dtherm , Digital temperature sensor 156 + 0x6, 0, eax, 1, turbo_boost , Intel Turbo Boost 157 + 0x6, 0, eax, 2, arat , Always-Running APIC Timer (not affected by p-state) 158 + 0x6, 0, eax, 4, pln , Power Limit Notification (PLN) event 159 + 0x6, 0, eax, 5, ecmd , Clock modulation duty cycle extension 160 + 0x6, 0, eax, 6, pts , Package thermal management 161 + 0x6, 0, eax, 7, hwp , HWP (Hardware P-states) base registers are supported 162 + 0x6, 0, eax, 8, hwp_notify , HWP notification (IA32_HWP_INTERRUPT MSR) 163 + 0x6, 0, eax, 9, hwp_act_window , HWP activity window (IA32_HWP_REQUEST[bits 41:32]) supported 164 + 0x6, 0, eax, 10, hwp_epp , HWP Energy Performance Preference 165 + 0x6, 0, eax, 11, hwp_pkg_req , HWP Package Level Request 166 + 0x6, 0, eax, 13, hdc_base_regs , HDC base registers are supported 167 + 0x6, 0, eax, 14, turbo_boost_3_0 , Intel Turbo Boost Max 3.0 168 + 0x6, 0, eax, 15, hwp_capabilities , HWP Highest Performance change 169 + 0x6, 0, eax, 16, hwp_peci_override , HWP PECI override 170 + 0x6, 0, eax, 17, hwp_flexible , Flexible HWP 171 + 0x6, 0, eax, 18, hwp_fast , IA32_HWP_REQUEST MSR fast access mode 172 + 0x6, 0, eax, 19, hfi , HW_FEEDBACK MSRs supported 173 + 0x6, 0, eax, 20, hwp_ignore_idle , Ignoring idle logical CPU HWP req is supported 174 + 0x6, 0, eax, 23, thread_director , Intel thread director support 175 + 0x6, 0, eax, 24, therm_interrupt_bit25 , IA32_THERM_INTERRUPT MSR bit 25 is supported 176 + 0x6, 0, ebx, 3:0, n_therm_thresholds , Digital thermometer thresholds 177 + 0x6, 0, ecx, 0, aperfmperf , MPERF/APERF MSRs (effective frequency interface) 178 + 0x6, 0, ecx, 3, epb , IA32_ENERGY_PERF_BIAS MSR support 179 + 0x6, 0, ecx, 15:8, thrd_director_nclasses , Number of classes, Intel thread director 180 + 0x6, 0, edx, 0, perfcap_reporting , Performance capability reporting 181 + 0x6, 0, edx, 1, encap_reporting , Energy efficiency capability reporting 182 + 0x6, 0, edx, 11:8, feedback_sz , Feedback interface structure size, in 4K pages 183 + 0x6, 0, edx, 31:16, this_lcpu_hwfdbk_idx , This logical CPU hardware feedback interface index 184 184 185 185 # Leaf 7H 186 186 # Extended CPU features enumeration 187 187 188 - 7, 0, eax, 31:0, leaf7_n_subleaves , Number of cpuid 0x7 subleaves 189 - 7, 0, ebx, 0, fsgsbase , FSBASE/GSBASE read/write support 190 - 7, 0, ebx, 1, tsc_adjust , IA32_TSC_ADJUST MSR supported 191 - 7, 0, ebx, 2, sgx , Intel SGX (Software Guard Extensions) 192 - 7, 0, ebx, 3, bmi1 , Bit manipulation extensions group 1 193 - 7, 0, ebx, 4, hle , Hardware Lock Elision 194 - 7, 0, ebx, 5, avx2 , AVX2 instruction set 195 - 7, 0, ebx, 6, fdp_excptn_only , FPU Data Pointer updated only on x87 exceptions 196 - 7, 0, ebx, 7, smep , Supervisor Mode Execution Protection 197 - 7, 0, ebx, 8, bmi2 , Bit manipulation extensions group 2 198 - 7, 0, ebx, 9, erms , Enhanced REP MOVSB/STOSB 199 - 7, 0, ebx, 10, invpcid , INVPCID instruction (Invalidate Processor Context ID) 200 - 7, 0, ebx, 11, rtm , Intel restricted transactional memory 201 - 7, 0, ebx, 12, cqm , Intel RDT-CMT / AMD Platform-QoS cache monitoring 202 - 7, 0, ebx, 13, zero_fcs_fds , Deprecated FPU CS/DS (stored as zero) 203 - 7, 0, ebx, 14, mpx , Intel memory protection extensions 204 - 7, 0, ebx, 15, rdt_a , Intel RDT / AMD Platform-QoS Enforcemeent 205 - 7, 0, ebx, 16, avx512f , AVX-512 foundation instructions 206 - 7, 0, ebx, 17, avx512dq , AVX-512 double/quadword instructions 207 - 7, 0, ebx, 18, rdseed , RDSEED instruction 208 - 7, 0, ebx, 19, adx , ADCX/ADOX instructions 209 - 7, 0, ebx, 20, smap , Supervisor mode access prevention 210 - 7, 0, ebx, 21, avx512ifma , AVX-512 integer fused multiply add 211 - 7, 0, ebx, 23, clflushopt , CLFLUSHOPT instruction 212 - 7, 0, ebx, 24, clwb , CLWB instruction 213 - 7, 0, ebx, 25, intel_pt , Intel processor trace 214 - 7, 0, ebx, 26, avx512pf , AVX-512 prefetch instructions 215 - 7, 0, ebx, 27, avx512er , AVX-512 exponent/reciprocal instrs 216 - 7, 0, ebx, 28, avx512cd , AVX-512 conflict detection instrs 217 - 7, 0, ebx, 29, sha_ni , SHA/SHA256 instructions 218 - 7, 0, ebx, 30, avx512bw , AVX-512 BW (byte/word granular) instructions 219 - 7, 0, ebx, 31, avx512vl , AVX-512 VL (128/256 vector length) extensions 220 - 7, 0, ecx, 0, prefetchwt1 , PREFETCHWT1 (Intel Xeon Phi only) 221 - 7, 0, ecx, 1, avx512vbmi , AVX-512 Vector byte manipulation instrs 222 - 7, 0, ecx, 2, umip , User mode instruction protection 223 - 7, 0, ecx, 3, pku , Protection keys for user-space 224 - 7, 0, ecx, 4, ospke , OS protection keys enable 225 - 7, 0, ecx, 5, waitpkg , WAITPKG instructions 226 - 7, 0, ecx, 6, avx512_vbmi2 , AVX-512 vector byte manipulation instrs group 2 227 - 7, 0, ecx, 7, cet_ss , CET shadow stack features 228 - 7, 0, ecx, 8, gfni , Galois field new instructions 229 - 7, 0, ecx, 9, vaes , Vector AES instrs 230 - 7, 0, ecx, 10, vpclmulqdq , VPCLMULQDQ 256-bit instruction support 231 - 7, 0, ecx, 11, avx512_vnni , Vector neural network instructions 232 - 7, 0, ecx, 12, avx512_bitalg , AVX-512 bit count/shiffle 233 - 7, 0, ecx, 13, tme , Intel total memory encryption 234 - 7, 0, ecx, 14, avx512_vpopcntdq , AVX-512: POPCNT for vectors of DW/QW 235 - 7, 0, ecx, 16, la57 , 57-bit linear addreses (five-level paging) 236 - 7, 0, ecx, 21:17, mawau_val_lm , BNDLDX/BNDSTX MAWAU value in 64-bit mode 237 - 7, 0, ecx, 22, rdpid , RDPID instruction 238 - 7, 0, ecx, 23, key_locker , Intel key locker support 239 - 7, 0, ecx, 24, bus_lock_detect , OS bus-lock detection 240 - 7, 0, ecx, 25, cldemote , CLDEMOTE instruction 241 - 7, 0, ecx, 27, movdiri , MOVDIRI instruction 242 - 7, 0, ecx, 28, movdir64b , MOVDIR64B instruction 243 - 7, 0, ecx, 29, enqcmd , Enqueue stores supported (ENQCMD{,S}) 244 - 7, 0, ecx, 30, sgx_lc , Intel SGX launch configuration 245 - 7, 0, ecx, 31, pks , Protection keys for supervisor-mode pages 246 - 7, 0, edx, 1, sgx_keys , Intel SGX attestation services 247 - 7, 0, edx, 2, avx512_4vnniw , AVX-512 neural network instructions 248 - 7, 0, edx, 3, avx512_4fmaps , AVX-512 multiply accumulation single precision 249 - 7, 0, edx, 4, fsrm , Fast short REP MOV 250 - 7, 0, edx, 5, uintr , CPU supports user interrupts 251 - 7, 0, edx, 8, avx512_vp2intersect , VP2INTERSECT{D,Q} instructions 252 - 7, 0, edx, 9, srdbs_ctrl , SRBDS mitigation MSR available 253 - 7, 0, edx, 10, md_clear , VERW MD_CLEAR microcode support 254 - 7, 0, edx, 11, rtm_always_abort , XBEGIN (RTM transaction) always aborts 255 - 7, 0, edx, 13, tsx_force_abort , MSR TSX_FORCE_ABORT, RTM_ABORT bit, supported 256 - 7, 0, edx, 14, serialize , SERIALIZE instruction 257 - 7, 0, edx, 15, hybrid_cpu , The CPU is identified as a 'hybrid part' 258 - 7, 0, edx, 16, tsxldtrk , TSX suspend/resume load address tracking 259 - 7, 0, edx, 18, pconfig , PCONFIG instruction 260 - 7, 0, edx, 19, arch_lbr , Intel architectural LBRs 261 - 7, 0, edx, 20, ibt , CET indirect branch tracking 262 - 7, 0, edx, 22, amx_bf16 , AMX-BF16: tile bfloat16 support 263 - 7, 0, edx, 23, avx512_fp16 , AVX-512 FP16 instructions 264 - 7, 0, edx, 24, amx_tile , AMX-TILE: tile architecture support 265 - 7, 0, edx, 25, amx_int8 , AMX-INT8: tile 8-bit integer support 266 - 7, 0, edx, 26, spec_ctrl , Speculation Control (IBRS/IBPB: indirect branch restrictions) 267 - 7, 0, edx, 27, intel_stibp , Single thread indirect branch predictors 268 - 7, 0, edx, 28, flush_l1d , FLUSH L1D cache: IA32_FLUSH_CMD MSR 269 - 7, 0, edx, 29, arch_capabilities , Intel IA32_ARCH_CAPABILITIES MSR 270 - 7, 0, edx, 30, core_capabilities , IA32_CORE_CAPABILITIES MSR 271 - 7, 0, edx, 31, spec_ctrl_ssbd , Speculative store bypass disable 272 - 7, 1, eax, 4, avx_vnni , AVX-VNNI instructions 273 - 7, 1, eax, 5, avx512_bf16 , AVX-512 bFloat16 instructions 274 - 7, 1, eax, 6, lass , Linear address space separation 275 - 7, 1, eax, 7, cmpccxadd , CMPccXADD instructions 276 - 7, 1, eax, 8, arch_perfmon_ext , ArchPerfmonExt: CPUID leaf 0x23 is supported 277 - 7, 1, eax, 10, fzrm , Fast zero-length REP MOVSB 278 - 7, 1, eax, 11, fsrs , Fast short REP STOSB 279 - 7, 1, eax, 12, fsrc , Fast Short REP CMPSB/SCASB 280 - 7, 1, eax, 17, fred , FRED: Flexible return and event delivery transitions 281 - 7, 1, eax, 18, lkgs , LKGS: Load 'kernel' (userspace) GS 282 - 7, 1, eax, 19, wrmsrns , WRMSRNS instr (WRMSR-non-serializing) 283 - 7, 1, eax, 21, amx_fp16 , AMX-FP16: FP16 tile operations 284 - 7, 1, eax, 22, hreset , History reset support 285 - 7, 1, eax, 23, avx_ifma , Integer fused multiply add 286 - 7, 1, eax, 26, lam , Linear address masking 287 - 7, 1, eax, 27, rd_wr_msrlist , RDMSRLIST/WRMSRLIST instructions 288 - 7, 1, ebx, 0, intel_ppin , Protected processor inventory number (PPIN{,_CTL} MSRs) 289 - 7, 1, edx, 4, avx_vnni_int8 , AVX-VNNI-INT8 instructions 290 - 7, 1, edx, 5, avx_ne_convert , AVX-NE-CONVERT instructions 291 - 7, 1, edx, 8, amx_complex , AMX-COMPLEX instructions (starting from Granite Rapids) 292 - 7, 1, edx, 14, prefetchit_0_1 , PREFETCHIT0/1 instructions 293 - 7, 1, edx, 18, cet_sss , CET supervisor shadow stacks safe to use 294 - 7, 2, edx, 0, intel_psfd , Intel predictive store forward disable 295 - 7, 2, edx, 1, ipred_ctrl , MSR bits IA32_SPEC_CTRL.IPRED_DIS_{U,S} 296 - 7, 2, edx, 2, rrsba_ctrl , MSR bits IA32_SPEC_CTRL.RRSBA_DIS_{U,S} 297 - 7, 2, edx, 3, ddp_ctrl , MSR bit IA32_SPEC_CTRL.DDPD_U 298 - 7, 2, edx, 4, bhi_ctrl , MSR bit IA32_SPEC_CTRL.BHI_DIS_S 299 - 7, 2, edx, 5, mcdt_no , MCDT mitigation not needed 300 - 7, 2, edx, 6, uclock_disable , UC-lock disable is supported 188 + 0x7, 0, eax, 31:0, leaf7_n_subleaves , Number of leaf 0x7 subleaves 189 + 0x7, 0, ebx, 0, fsgsbase , FSBASE/GSBASE read/write support 190 + 0x7, 0, ebx, 1, tsc_adjust , IA32_TSC_ADJUST MSR supported 191 + 0x7, 0, ebx, 2, sgx , Intel SGX (Software Guard Extensions) 192 + 0x7, 0, ebx, 3, bmi1 , Bit manipulation extensions group 1 193 + 0x7, 0, ebx, 4, hle , Hardware Lock Elision 194 + 0x7, 0, ebx, 5, avx2 , AVX2 instruction set 195 + 0x7, 0, ebx, 6, fdp_excptn_only , FPU Data Pointer updated only on x87 exceptions 196 + 0x7, 0, ebx, 7, smep , Supervisor Mode Execution Protection 197 + 0x7, 0, ebx, 8, bmi2 , Bit manipulation extensions group 2 198 + 0x7, 0, ebx, 9, erms , Enhanced REP MOVSB/STOSB 199 + 0x7, 0, ebx, 10, invpcid , INVPCID instruction (Invalidate Processor Context ID) 200 + 0x7, 0, ebx, 11, rtm , Intel restricted transactional memory 201 + 0x7, 0, ebx, 12, cqm , Intel RDT-CMT / AMD Platform-QoS cache monitoring 202 + 0x7, 0, ebx, 13, zero_fcs_fds , Deprecated FPU CS/DS (stored as zero) 203 + 0x7, 0, ebx, 14, mpx , Intel memory protection extensions 204 + 0x7, 0, ebx, 15, rdt_a , Intel RDT / AMD Platform-QoS Enforcement 205 + 0x7, 0, ebx, 16, avx512f , AVX-512 foundation instructions 206 + 0x7, 0, ebx, 17, avx512dq , AVX-512 double/quadword instructions 207 + 0x7, 0, ebx, 18, rdseed , RDSEED instruction 208 + 0x7, 0, ebx, 19, adx , ADCX/ADOX instructions 209 + 0x7, 0, ebx, 20, smap , Supervisor mode access prevention 210 + 0x7, 0, ebx, 21, avx512ifma , AVX-512 integer fused multiply add 211 + 0x7, 0, ebx, 23, clflushopt , CLFLUSHOPT instruction 212 + 0x7, 0, ebx, 24, clwb , CLWB instruction 213 + 0x7, 0, ebx, 25, intel_pt , Intel processor trace 214 + 0x7, 0, ebx, 26, avx512pf , AVX-512 prefetch instructions 215 + 0x7, 0, ebx, 27, avx512er , AVX-512 exponent/reciprocal instructions 216 + 0x7, 0, ebx, 28, avx512cd , AVX-512 conflict detection instructions 217 + 0x7, 0, ebx, 29, sha_ni , SHA/SHA256 instructions 218 + 0x7, 0, ebx, 30, avx512bw , AVX-512 byte/word instructions 219 + 0x7, 0, ebx, 31, avx512vl , AVX-512 VL (128/256 vector length) extensions 220 + 0x7, 0, ecx, 0, prefetchwt1 , PREFETCHWT1 (Intel Xeon Phi only) 221 + 0x7, 0, ecx, 1, avx512vbmi , AVX-512 Vector byte manipulation instructions 222 + 0x7, 0, ecx, 2, umip , User mode instruction protection 223 + 0x7, 0, ecx, 3, pku , Protection keys for user-space 224 + 0x7, 0, ecx, 4, ospke , OS protection keys enable 225 + 0x7, 0, ecx, 5, waitpkg , WAITPKG instructions 226 + 0x7, 0, ecx, 6, avx512_vbmi2 , AVX-512 vector byte manipulation instructions group 2 227 + 0x7, 0, ecx, 7, cet_ss , CET shadow stack features 228 + 0x7, 0, ecx, 8, gfni , Galois field new instructions 229 + 0x7, 0, ecx, 9, vaes , Vector AES instructions 230 + 0x7, 0, ecx, 10, vpclmulqdq , VPCLMULQDQ 256-bit instruction support 231 + 0x7, 0, ecx, 11, avx512_vnni , Vector neural network instructions 232 + 0x7, 0, ecx, 12, avx512_bitalg , AVX-512 bitwise algorithms 233 + 0x7, 0, ecx, 13, tme , Intel total memory encryption 234 + 0x7, 0, ecx, 14, avx512_vpopcntdq , AVX-512: POPCNT for vectors of DWORD/QWORD 235 + 0x7, 0, ecx, 16, la57 , 57-bit linear addresses (five-level paging) 236 + 0x7, 0, ecx, 21:17, mawau_val_lm , BNDLDX/BNDSTX MAWAU value in 64-bit mode 237 + 0x7, 0, ecx, 22, rdpid , RDPID instruction 238 + 0x7, 0, ecx, 23, key_locker , Intel key locker support 239 + 0x7, 0, ecx, 24, bus_lock_detect , OS bus-lock detection 240 + 0x7, 0, ecx, 25, cldemote , CLDEMOTE instruction 241 + 0x7, 0, ecx, 27, movdiri , MOVDIRI instruction 242 + 0x7, 0, ecx, 28, movdir64b , MOVDIR64B instruction 243 + 0x7, 0, ecx, 29, enqcmd , Enqueue stores supported (ENQCMD{,S}) 244 + 0x7, 0, ecx, 30, sgx_lc , Intel SGX launch configuration 245 + 0x7, 0, ecx, 31, pks , Protection keys for supervisor-mode pages 246 + 0x7, 0, edx, 1, sgx_keys , Intel SGX attestation services 247 + 0x7, 0, edx, 2, avx512_4vnniw , AVX-512 neural network instructions 248 + 0x7, 0, edx, 3, avx512_4fmaps , AVX-512 multiply accumulation single precision 249 + 0x7, 0, edx, 4, fsrm , Fast short REP MOV 250 + 0x7, 0, edx, 5, uintr , CPU supports user interrupts 251 + 0x7, 0, edx, 8, avx512_vp2intersect , VP2INTERSECT{D,Q} instructions 252 + 0x7, 0, edx, 9, srdbs_ctrl , SRBDS mitigation MSR available 253 + 0x7, 0, edx, 10, md_clear , VERW MD_CLEAR microcode support 254 + 0x7, 0, edx, 11, rtm_always_abort , XBEGIN (RTM transaction) always aborts 255 + 0x7, 0, edx, 13, tsx_force_abort , MSR TSX_FORCE_ABORT, RTM_ABORT bit, supported 256 + 0x7, 0, edx, 14, serialize , SERIALIZE instruction 257 + 0x7, 0, edx, 15, hybrid_cpu , The CPU is identified as a 'hybrid part' 258 + 0x7, 0, edx, 16, tsxldtrk , TSX suspend/resume load address tracking 259 + 0x7, 0, edx, 18, pconfig , PCONFIG instruction 260 + 0x7, 0, edx, 19, arch_lbr , Intel architectural LBRs 261 + 0x7, 0, edx, 20, ibt , CET indirect branch tracking 262 + 0x7, 0, edx, 22, amx_bf16 , AMX-BF16: tile bfloat16 support 263 + 0x7, 0, edx, 23, avx512_fp16 , AVX-512 FP16 instructions 264 + 0x7, 0, edx, 24, amx_tile , AMX-TILE: tile architecture support 265 + 0x7, 0, edx, 25, amx_int8 , AMX-INT8: tile 8-bit integer support 266 + 0x7, 0, edx, 26, spec_ctrl , Speculation Control (IBRS/IBPB: indirect branch restrictions) 267 + 0x7, 0, edx, 27, intel_stibp , Single thread indirect branch predictors 268 + 0x7, 0, edx, 28, flush_l1d , FLUSH L1D cache: IA32_FLUSH_CMD MSR 269 + 0x7, 0, edx, 29, arch_capabilities , Intel IA32_ARCH_CAPABILITIES MSR 270 + 0x7, 0, edx, 30, core_capabilities , IA32_CORE_CAPABILITIES MSR 271 + 0x7, 0, edx, 31, spec_ctrl_ssbd , Speculative store bypass disable 272 + 0x7, 1, eax, 4, avx_vnni , AVX-VNNI instructions 273 + 0x7, 1, eax, 5, avx512_bf16 , AVX-512 bfloat16 instructions 274 + 0x7, 1, eax, 6, lass , Linear address space separation 275 + 0x7, 1, eax, 7, cmpccxadd , CMPccXADD instructions 276 + 0x7, 1, eax, 8, arch_perfmon_ext , ArchPerfmonExt: leaf 0x23 is supported 277 + 0x7, 1, eax, 10, fzrm , Fast zero-length REP MOVSB 278 + 0x7, 1, eax, 11, fsrs , Fast short REP STOSB 279 + 0x7, 1, eax, 12, fsrc , Fast Short REP CMPSB/SCASB 280 + 0x7, 1, eax, 17, fred , FRED: Flexible return and event delivery transitions 281 + 0x7, 1, eax, 18, lkgs , LKGS: Load 'kernel' (userspace) GS 282 + 0x7, 1, eax, 19, wrmsrns , WRMSRNS instruction (WRMSR-non-serializing) 283 + 0x7, 1, eax, 20, nmi_src , NMI-source reporting with FRED event data 284 + 0x7, 1, eax, 21, amx_fp16 , AMX-FP16: FP16 tile operations 285 + 0x7, 1, eax, 22, hreset , History reset support 286 + 0x7, 1, eax, 23, avx_ifma , Integer fused multiply add 287 + 0x7, 1, eax, 26, lam , Linear address masking 288 + 0x7, 1, eax, 27, rd_wr_msrlist , RDMSRLIST/WRMSRLIST instructions 289 + 0x7, 1, ebx, 0, intel_ppin , Protected processor inventory number (PPIN{,_CTL} MSRs) 290 + 0x7, 1, edx, 4, avx_vnni_int8 , AVX-VNNI-INT8 instructions 291 + 0x7, 1, edx, 5, avx_ne_convert , AVX-NE-CONVERT instructions 292 + 0x7, 1, edx, 8, amx_complex , AMX-COMPLEX instructions (starting from Granite Rapids) 293 + 0x7, 1, edx, 14, prefetchit_0_1 , PREFETCHIT0/1 instructions 294 + 0x7, 1, edx, 18, cet_sss , CET supervisor shadow stacks safe to use 295 + 0x7, 2, edx, 0, intel_psfd , Intel predictive store forward disable 296 + 0x7, 2, edx, 1, ipred_ctrl , MSR bits IA32_SPEC_CTRL.IPRED_DIS_{U,S} 297 + 0x7, 2, edx, 2, rrsba_ctrl , MSR bits IA32_SPEC_CTRL.RRSBA_DIS_{U,S} 298 + 0x7, 2, edx, 3, ddp_ctrl , MSR bit IA32_SPEC_CTRL.DDPD_U 299 + 0x7, 2, edx, 4, bhi_ctrl , MSR bit IA32_SPEC_CTRL.BHI_DIS_S 300 + 0x7, 2, edx, 5, mcdt_no , MCDT mitigation not needed 301 + 0x7, 2, edx, 6, uclock_disable , UC-lock disable is supported 301 302 302 303 # Leaf 9H 303 304 # Intel DCA (Direct Cache Access) enumeration 304 305 305 - 9, 0, eax, 0, dca_enabled_in_bios , DCA is enabled in BIOS 306 + 0x9, 0, eax, 0, dca_enabled_in_bios , DCA is enabled in BIOS 306 307 307 308 # Leaf AH 308 309 # Intel PMU (Performance Monitoring Unit) enumeration ··· 311 310 0xa, 0, eax, 7:0, pmu_version , Performance monitoring unit version ID 312 311 0xa, 0, eax, 15:8, pmu_n_gcounters , Number of general PMU counters per logical CPU 313 312 0xa, 0, eax, 23:16, pmu_gcounters_nbits , Bitwidth of PMU general counters 314 - 0xa, 0, eax, 31:24, pmu_cpuid_ebx_bits , Length of cpuid leaf 0xa EBX bit vector 313 + 0xa, 0, eax, 31:24, pmu_cpuid_ebx_bits , Length of leaf 0xa EBX bit vector 315 314 0xa, 0, ebx, 0, no_core_cycle_evt , Core cycle event not available 316 315 0xa, 0, ebx, 1, no_insn_retired_evt , Instruction retired event not available 317 316 0xa, 0, ebx, 2, no_refcycle_evt , Reference cycles event not available ··· 340 339 0xd, 0, eax, 0, xcr0_x87 , XCR0.X87 (bit 0) supported 341 340 0xd, 0, eax, 1, xcr0_sse , XCR0.SEE (bit 1) supported 342 341 0xd, 0, eax, 2, xcr0_avx , XCR0.AVX (bit 2) supported 343 - 0xd, 0, eax, 3, xcr0_mpx_bndregs , XCR0.BNDREGS (bit 3) supported (MPX BND0-BND3 regs) 344 - 0xd, 0, eax, 4, xcr0_mpx_bndcsr , XCR0.BNDCSR (bit 4) supported (MPX BNDCFGU/BNDSTATUS regs) 345 - 0xd, 0, eax, 5, xcr0_avx512_opmask , XCR0.OPMASK (bit 5) supported (AVX-512 k0-k7 regs) 346 - 0xd, 0, eax, 6, xcr0_avx512_zmm_hi256 , XCR0.ZMM_Hi256 (bit 6) supported (AVX-512 ZMM0->ZMM7/15 regs) 347 - 0xd, 0, eax, 7, xcr0_avx512_hi16_zmm , XCR0.HI16_ZMM (bit 7) supported (AVX-512 ZMM16->ZMM31 regs) 348 - 0xd, 0, eax, 9, xcr0_pkru , XCR0.PKRU (bit 9) supported (XSAVE PKRU reg) 349 - 0xd, 0, eax, 11, xcr0_cet_u , AMD XCR0.CET_U (bit 11) supported (CET supervisor state) 350 - 0xd, 0, eax, 12, xcr0_cet_s , AMD XCR0.CET_S (bit 12) support (CET user state) 342 + 0xd, 0, eax, 3, xcr0_mpx_bndregs , XCR0.BNDREGS (bit 3) supported (MPX BND0-BND3 registers) 343 + 0xd, 0, eax, 4, xcr0_mpx_bndcsr , XCR0.BNDCSR (bit 4) supported (MPX BNDCFGU/BNDSTATUS registers) 344 + 0xd, 0, eax, 5, xcr0_avx512_opmask , XCR0.OPMASK (bit 5) supported (AVX-512 k0-k7 registers) 345 + 0xd, 0, eax, 6, xcr0_avx512_zmm_hi256 , XCR0.ZMM_Hi256 (bit 6) supported (AVX-512 ZMM0->ZMM7/15 registers) 346 + 0xd, 0, eax, 7, xcr0_avx512_hi16_zmm , XCR0.HI16_ZMM (bit 7) supported (AVX-512 ZMM16->ZMM31 registers) 347 + 0xd, 0, eax, 9, xcr0_pkru , XCR0.PKRU (bit 9) supported (XSAVE PKRU registers) 348 + 0xd, 0, eax, 11, xcr0_cet_u , XCR0.CET_U (bit 11) supported (CET user state) 349 + 0xd, 0, eax, 12, xcr0_cet_s , XCR0.CET_S (bit 12) supported (CET supervisor state) 351 350 0xd, 0, eax, 17, xcr0_tileconfig , XCR0.TILECONFIG (bit 17) supported (AMX can manage TILECONFIG) 352 351 0xd, 0, eax, 18, xcr0_tiledata , XCR0.TILEDATA (bit 18) supported (AMX can manage TILEDATA) 353 - 0xd, 0, ebx, 31:0, xsave_sz_xcr0_enabled , XSAVE/XRSTR area byte size, for XCR0 enabled features 354 - 0xd, 0, ecx, 31:0, xsave_sz_max , XSAVE/XRSTR area max byte size, all CPU features 352 + 0xd, 0, ebx, 31:0, xsave_sz_xcr0_enabled , XSAVE/XRSTOR area byte size, for XCR0 enabled features 353 + 0xd, 0, ecx, 31:0, xsave_sz_max , XSAVE/XRSTOR area max byte size, all CPU features 355 354 0xd, 0, edx, 30, xcr0_lwp , AMD XCR0.LWP (bit 62) supported (Light-weight Profiling) 356 355 0xd, 1, eax, 0, xsaveopt , XSAVEOPT instruction 357 356 0xd, 1, eax, 1, xsavec , XSAVEC instruction ··· 370 369 0xd, 63:2, eax, 31:0, xsave_sz , Size of save area for subleaf-N feature, in bytes 371 370 0xd, 63:2, ebx, 31:0, xsave_offset , Offset of save area for subleaf-N feature, in bytes 372 371 0xd, 63:2, ecx, 0, is_xss_bit , Subleaf N describes an XSS bit, otherwise XCR0 bit 373 - 0xd, 63:2, ecx, 1, compacted_xsave_64byte_aligned, When compacted, subleaf-N feature xsave area is 64-byte aligned 372 + 0xd, 63:2, ecx, 1, compacted_xsave_64byte_aligned, When compacted, subleaf-N feature XSAVE area is 64-byte aligned 374 373 375 374 # Leaf FH 376 375 # Intel RDT / AMD PQoS resource monitoring ··· 427 426 0x12, 1, ecx, 0, xfrm_x87 , Enclave XFRM.X87 (bit 0) supported 428 427 0x12, 1, ecx, 1, xfrm_sse , Enclave XFRM.SEE (bit 1) supported 429 428 0x12, 1, ecx, 2, xfrm_avx , Enclave XFRM.AVX (bit 2) supported 430 - 0x12, 1, ecx, 3, xfrm_mpx_bndregs , Enclave XFRM.BNDREGS (bit 3) supported (MPX BND0-BND3 regs) 431 - 0x12, 1, ecx, 4, xfrm_mpx_bndcsr , Enclave XFRM.BNDCSR (bit 4) supported (MPX BNDCFGU/BNDSTATUS regs) 432 - 0x12, 1, ecx, 5, xfrm_avx512_opmask , Enclave XFRM.OPMASK (bit 5) supported (AVX-512 k0-k7 regs) 433 - 0x12, 1, ecx, 6, xfrm_avx512_zmm_hi256 , Enclave XFRM.ZMM_Hi256 (bit 6) supported (AVX-512 ZMM0->ZMM7/15 regs) 434 - 0x12, 1, ecx, 7, xfrm_avx512_hi16_zmm , Enclave XFRM.HI16_ZMM (bit 7) supported (AVX-512 ZMM16->ZMM31 regs) 435 - 0x12, 1, ecx, 9, xfrm_pkru , Enclave XFRM.PKRU (bit 9) supported (XSAVE PKRU reg) 429 + 0x12, 1, ecx, 3, xfrm_mpx_bndregs , Enclave XFRM.BNDREGS (bit 3) supported (MPX BND0-BND3 registers) 430 + 0x12, 1, ecx, 4, xfrm_mpx_bndcsr , Enclave XFRM.BNDCSR (bit 4) supported (MPX BNDCFGU/BNDSTATUS registers) 431 + 0x12, 1, ecx, 5, xfrm_avx512_opmask , Enclave XFRM.OPMASK (bit 5) supported (AVX-512 k0-k7 registers) 432 + 0x12, 1, ecx, 6, xfrm_avx512_zmm_hi256 , Enclave XFRM.ZMM_Hi256 (bit 6) supported (AVX-512 ZMM0->ZMM7/15 registers) 433 + 0x12, 1, ecx, 7, xfrm_avx512_hi16_zmm , Enclave XFRM.HI16_ZMM (bit 7) supported (AVX-512 ZMM16->ZMM31 registers) 434 + 0x12, 1, ecx, 9, xfrm_pkru , Enclave XFRM.PKRU (bit 9) supported (XSAVE PKRU registers) 436 435 0x12, 1, ecx, 17, xfrm_tileconfig , Enclave XFRM.TILECONFIG (bit 17) supported (AMX can manage TILECONFIG) 437 436 0x12, 1, ecx, 18, xfrm_tiledata , Enclave XFRM.TILEDATA (bit 18) supported (AMX can manage TILEDATA) 438 437 0x12, 31:2, eax, 3:0, subleaf_type , Subleaf type (dictates output layout) 439 - 0x12, 31:2, eax, 31:12, epc_sec_base_addr_0 , EPC section base addr, bits[12:31] 440 - 0x12, 31:2, ebx, 19:0, epc_sec_base_addr_1 , EPC section base addr, bits[32:51] 438 + 0x12, 31:2, eax, 31:12, epc_sec_base_addr_0 , EPC section base address, bits[12:31] 439 + 0x12, 31:2, ebx, 19:0, epc_sec_base_addr_1 , EPC section base address, bits[32:51] 441 440 0x12, 31:2, ecx, 3:0, epc_sec_type , EPC section type / property encoding 442 441 0x12, 31:2, ecx, 31:12, epc_sec_size_0 , EPC section size, bits[12:31] 443 442 0x12, 31:2, edx, 19:0, epc_sec_size_1 , EPC section size, bits[32:51] ··· 445 444 # Leaf 14H 446 445 # Intel Processor Trace enumeration 447 446 448 - 0x14, 0, eax, 31:0, pt_max_subleaf , Max cpuid 0x14 subleaf 447 + 0x14, 0, eax, 31:0, pt_max_subleaf , Maximum leaf 0x14 subleaf 449 448 0x14, 0, ebx, 0, cr3_filtering , IA32_RTIT_CR3_MATCH is accessible 450 449 0x14, 0, ebx, 1, psb_cyc , Configurable PSB and cycle-accurate mode 451 450 0x14, 0, ebx, 2, ip_filtering , IP/TraceStop filtering; Warm-reset PT MSRs preservation ··· 473 472 0x15, 0, ecx, 31:0, cpu_crystal_hz , Core crystal clock nominal frequency, in Hz 474 473 475 474 # Leaf 16H 476 - # Intel processor fequency enumeration 475 + # Intel processor frequency enumeration 477 476 478 477 0x16, 0, eax, 15:0, cpu_base_mhz , Processor base frequency, in MHz 479 478 0x16, 0, ebx, 15:0, cpu_max_mhz , Processor max frequency, in MHz ··· 482 481 # Leaf 17H 483 482 # Intel SoC vendor attributes enumeration 484 483 485 - 0x17, 0, eax, 31:0, soc_max_subleaf , Max cpuid leaf 0x17 subleaf 484 + 0x17, 0, eax, 31:0, soc_max_subleaf , Maximum leaf 0x17 subleaf 486 485 0x17, 0, ebx, 15:0, soc_vendor_id , SoC vendor ID 487 - 0x17, 0, ebx, 16, is_vendor_scheme , Assigned by industry enumaeratoion scheme (not Intel) 486 + 0x17, 0, ebx, 16, is_vendor_scheme , Assigned by industry enumeration scheme (not Intel) 488 487 0x17, 0, ecx, 31:0, soc_proj_id , SoC project ID, assigned by vendor 489 488 0x17, 0, edx, 31:0, soc_stepping_id , Soc project stepping ID, assigned by vendor 490 489 0x17, 3:1, eax, 31:0, vendor_brand_a , Vendor Brand ID string, bytes subleaf_nr * (0 -> 3) ··· 495 494 # Leaf 18H 496 495 # Intel determenestic address translation (TLB) parameters 497 496 498 - 0x18, 31:0, eax, 31:0, tlb_max_subleaf , Max cpuid 0x18 subleaf 497 + 0x18, 31:0, eax, 31:0, tlb_max_subleaf , Maximum leaf 0x18 subleaf 499 498 0x18, 31:0, ebx, 0, tlb_4k_page , TLB 4KB-page entries supported 500 499 0x18, 31:0, ebx, 1, tlb_2m_page , TLB 2MB-page entries supported 501 500 0x18, 31:0, ebx, 2, tlb_4m_page , TLB 4MB-page entries supported 502 501 0x18, 31:0, ebx, 3, tlb_1g_page , TLB 1GB-page entries supported 503 - 0x18, 31:0, ebx, 10:8, hard_partitioning , (Hard/Soft) partitioning between logical CPUs sharing this struct 502 + 0x18, 31:0, ebx, 10:8, hard_partitioning , (Hard/Soft) partitioning between logical CPUs sharing this structure 504 503 0x18, 31:0, ebx, 31:16, n_way_associative , Ways of associativity 505 504 0x18, 31:0, ecx, 31:0, n_sets , Number of sets 506 505 0x18, 31:0, edx, 4:0, tlb_type , Translation cache type (TLB type) 507 506 0x18, 31:0, edx, 7:5, tlb_cache_level , Translation cache level (1-based) 508 507 0x18, 31:0, edx, 8, is_fully_associative , Fully-associative structure 509 - 0x18, 31:0, edx, 25:14, tlb_max_addressible_ids, Max num of addressible IDs for logical CPUs sharing this TLB - 1 508 + 0x18, 31:0, edx, 25:14, tlb_max_addressible_ids, Max number of addressable IDs for logical CPUs sharing this TLB - 1 510 509 511 510 # Leaf 19H 512 511 # Intel Key Locker enumeration ··· 569 568 # Intel AMX, TMUL (Tile-matrix MULtiply) accelerator unit enumeration 570 569 571 570 0x1e, 0, ebx, 7:0, tmul_maxk , TMUL unit maximum height, K (rows or columns) 572 - 0x1e, 0, ebx, 23:8, tmul_maxn , TMUL unit maxiumum SIMD dimension, N (column bytes) 571 + 0x1e, 0, ebx, 23:8, tmul_maxn , TMUL unit maximum SIMD dimension, N (column bytes) 573 572 574 573 # Leaf 1FH 575 574 # Intel extended topology enumeration v2 ··· 624 623 0x40000000, 0, edx, 31:0, hypervisor_id_2 , Hypervisor ID string bytes 8 - 11 625 624 626 625 # Leaf 80000000H 627 - # Maximum extended leaf number + CPU vendor string (AMD) 626 + # Maximum extended leaf number + AMD/Transmeta CPU vendor string 628 627 629 - 0x80000000, 0, eax, 31:0, max_ext_leaf , Maximum extended cpuid leaf supported 628 + 0x80000000, 0, eax, 31:0, max_ext_leaf , Maximum extended CPUID leaf supported 630 629 0x80000000, 0, ebx, 31:0, cpu_vendorid_0 , Vendor ID string bytes 0 - 3 631 630 0x80000000, 0, ecx, 31:0, cpu_vendorid_2 , Vendor ID string bytes 8 - 11 632 631 0x80000000, 0, edx, 31:0, cpu_vendorid_1 , Vendor ID string bytes 4 - 7 ··· 637 636 0x80000001, 0, eax, 3:0, e_stepping_id , Stepping ID 638 637 0x80000001, 0, eax, 7:4, e_base_model , Base processor model 639 638 0x80000001, 0, eax, 11:8, e_base_family , Base processor family 639 + 0x80000001, 0, eax, 13:12, e_base_type , Base processor type (Transmeta) 640 640 0x80000001, 0, eax, 19:16, e_ext_model , Extended processor model 641 641 0x80000001, 0, eax, 27:20, e_ext_family , Extended processor family 642 642 0x80000001, 0, ebx, 15:0, brand_id , Brand ID ··· 661 659 0x80000001, 0, ecx, 17, tce , Translation cache extension 662 660 0x80000001, 0, ecx, 19, nodeid_msr , NodeId MSR (0xc001100c) 663 661 0x80000001, 0, ecx, 21, tbm , Trailing bit manipulations 664 - 0x80000001, 0, ecx, 22, topoext , Topology Extensions (cpuid leaf 0x8000001d) 662 + 0x80000001, 0, ecx, 22, topoext , Topology Extensions (leaf 0x8000001d) 665 663 0x80000001, 0, ecx, 23, perfctr_core , Core performance counter extensions 666 664 0x80000001, 0, ecx, 24, perfctr_nb , NB/DF performance counter extensions 667 665 0x80000001, 0, ecx, 26, bpext , Data access breakpoint extension ··· 689 687 0x80000001, 0, edx, 19, mp , Out-of-spec AMD Multiprocessing bit 690 688 0x80000001, 0, edx, 20, nx , No-execute page protection 691 689 0x80000001, 0, edx, 22, mmxext , AMD MMX extensions 690 + 0x80000001, 0, edx, 23, e_mmx , MMX instructions (Transmeta) 692 691 0x80000001, 0, edx, 24, e_fxsr , FXSAVE and FXRSTOR instructions 693 692 0x80000001, 0, edx, 25, fxsr_opt , FXSAVE and FXRSTOR optimizations 694 693 0x80000001, 0, edx, 26, pdpe1gb , 1-GB large page support ··· 723 720 0x80000004, 0, edx, 31:0, cpu_brandid_11 , CPU brand ID string, bytes 44 - 47 724 721 725 722 # Leaf 80000005H 726 - # AMD L1 cache and L1 TLB enumeration 723 + # AMD/Transmeta L1 cache and L1 TLB enumeration 727 724 728 - 0x80000005, 0, eax, 7:0, l1_itlb_2m_4m_nentries , L1 ITLB #entires, 2M and 4M pages 725 + 0x80000005, 0, eax, 7:0, l1_itlb_2m_4m_nentries , L1 ITLB #entries, 2M and 4M pages 729 726 0x80000005, 0, eax, 15:8, l1_itlb_2m_4m_assoc , L1 ITLB associativity, 2M and 4M pages 730 - 0x80000005, 0, eax, 23:16, l1_dtlb_2m_4m_nentries , L1 DTLB #entires, 2M and 4M pages 727 + 0x80000005, 0, eax, 23:16, l1_dtlb_2m_4m_nentries , L1 DTLB #entries, 2M and 4M pages 731 728 0x80000005, 0, eax, 31:24, l1_dtlb_2m_4m_assoc , L1 DTLB associativity, 2M and 4M pages 732 729 0x80000005, 0, ebx, 7:0, l1_itlb_4k_nentries , L1 ITLB #entries, 4K pages 733 730 0x80000005, 0, ebx, 15:8, l1_itlb_4k_assoc , L1 ITLB associativity, 4K pages ··· 766 763 # CPU power management (mostly AMD) and AMD RAS enumeration 767 764 768 765 0x80000007, 0, ebx, 0, overflow_recov , MCA overflow conditions not fatal 769 - 0x80000007, 0, ebx, 1, succor , Software containment of UnCORRectable errors 766 + 0x80000007, 0, ebx, 1, succor , Software containment of uncorrectable errors 770 767 0x80000007, 0, ebx, 2, hw_assert , Hardware assert MSRs 771 768 0x80000007, 0, ebx, 3, smca , Scalable MCA (MCAX MSRs) 772 769 0x80000007, 0, ecx, 31:0, cpu_pwr_sample_ratio , CPU power sample time ratio 773 - 0x80000007, 0, edx, 0, digital_temp , Digital temprature sensor 770 + 0x80000007, 0, edx, 0, digital_temp , Digital temperature sensor 774 771 0x80000007, 0, edx, 1, powernow_freq_id , PowerNOW! frequency scaling 775 772 0x80000007, 0, edx, 2, powernow_volt_id , PowerNOW! voltage scaling 776 773 0x80000007, 0, edx, 3, thermal_trip , THERMTRIP (Thermal Trip) ··· 813 810 0x80000008, 0, ebx, 23, amd_ppin , Protected Processor Inventory Number 814 811 0x80000008, 0, ebx, 24, amd_ssbd , Speculative Store Bypass Disable 815 812 0x80000008, 0, ebx, 25, virt_ssbd , virtualized SSBD (Speculative Store Bypass Disable) 816 - 0x80000008, 0, ebx, 26, amd_ssb_no , SSBD not needed (fixed in HW) 813 + 0x80000008, 0, ebx, 26, amd_ssb_no , SSBD is not needed (fixed in hardware) 817 814 0x80000008, 0, ebx, 27, cppc , Collaborative Processor Performance Control 818 815 0x80000008, 0, ebx, 28, amd_psfd , Predictive Store Forward Disable 819 816 0x80000008, 0, ebx, 29, btc_no , CPU not affected by Branch Type Confusion ··· 841 838 0x8000000a, 0, edx, 10, pausefilter , Pause intercept filter 842 839 0x8000000a, 0, edx, 12, pfthreshold , Pause filter threshold 843 840 0x8000000a, 0, edx, 13, avic , Advanced virtual interrupt controller 844 - 0x8000000a, 0, edx, 15, v_vmsave_vmload , Virtual VMSAVE/VMLOAD (nested virt) 841 + 0x8000000a, 0, edx, 15, v_vmsave_vmload , Virtual VMSAVE/VMLOAD (nested virtualization) 845 842 0x8000000a, 0, edx, 16, vgif , Virtualize the Global Interrupt Flag 846 843 0x8000000a, 0, edx, 17, gmet , Guest mode execution trap 847 844 0x8000000a, 0, edx, 18, x2avic , Virtual x2APIC ··· 853 850 0x8000000a, 0, edx, 25, vnmi , NMI virtualization 854 851 0x8000000a, 0, edx, 26, ibs_virt , IBS Virtualization 855 852 0x8000000a, 0, edx, 27, ext_lvt_off_chg , Extended LVT offset fault change 856 - 0x8000000a, 0, edx, 28, svme_addr_chk , Guest SVME addr check 853 + 0x8000000a, 0, edx, 28, svme_addr_chk , Guest SVME address check 857 854 858 855 # Leaf 80000019H 859 856 # AMD TLB 1G-pages enumeration ··· 894 891 # AMD LWP (Lightweight Profiling) 895 892 896 893 0x8000001c, 0, eax, 0, os_lwp_avail , LWP is available to application programs (supported by OS) 897 - 0x8000001c, 0, eax, 1, os_lpwval , LWPVAL instruction (EventId=1) is supported by OS 898 - 0x8000001c, 0, eax, 2, os_lwp_ire , Instructions Retired Event (EventId=2) is supported by OS 899 - 0x8000001c, 0, eax, 3, os_lwp_bre , Branch Retired Event (EventId=3) is supported by OS 900 - 0x8000001c, 0, eax, 4, os_lwp_dme , DCache Miss Event (EventId=4) is supported by OS 901 - 0x8000001c, 0, eax, 5, os_lwp_cnh , CPU Clocks Not Halted event (EventId=5) is supported by OS 902 - 0x8000001c, 0, eax, 6, os_lwp_rnh , CPU Reference clocks Not Halted event (EventId=6) is supported by OS 894 + 0x8000001c, 0, eax, 1, os_lpwval , LWPVAL instruction is supported by OS 895 + 0x8000001c, 0, eax, 2, os_lwp_ire , Instructions Retired Event is supported by OS 896 + 0x8000001c, 0, eax, 3, os_lwp_bre , Branch Retired Event is supported by OS 897 + 0x8000001c, 0, eax, 4, os_lwp_dme , Dcache Miss Event is supported by OS 898 + 0x8000001c, 0, eax, 5, os_lwp_cnh , CPU Clocks Not Halted event is supported by OS 899 + 0x8000001c, 0, eax, 6, os_lwp_rnh , CPU Reference clocks Not Halted event is supported by OS 903 900 0x8000001c, 0, eax, 29, os_lwp_cont , LWP sampling in continuous mode is supported by OS 904 901 0x8000001c, 0, eax, 30, os_lwp_ptsc , Performance Time Stamp Counter in event records is supported by OS 905 902 0x8000001c, 0, eax, 31, os_lwp_int , Interrupt on threshold overflow is supported by OS 906 903 0x8000001c, 0, ebx, 7:0, lwp_lwpcb_sz , LWP Control Block size, in quadwords 907 904 0x8000001c, 0, ebx, 15:8, lwp_event_sz , LWP event record size, in bytes 908 - 0x8000001c, 0, ebx, 23:16, lwp_max_events , LWP max supported EventId value (EventID 255 not included) 905 + 0x8000001c, 0, ebx, 23:16, lwp_max_events , LWP max supported EventID value (EventID 255 not included) 909 906 0x8000001c, 0, ebx, 31:24, lwp_event_offset , LWP events area offset in the LWP Control Block 910 - 0x8000001c, 0, ecx, 4:0, lwp_latency_max , Num of bits in cache latency counters (10 to 31) 907 + 0x8000001c, 0, ecx, 4:0, lwp_latency_max , Number of bits in cache latency counters (10 to 31) 911 908 0x8000001c, 0, ecx, 5, lwp_data_adddr , Cache miss events report the data address of the reference 912 909 0x8000001c, 0, ecx, 8:6, lwp_latency_rnd , Amount by which cache latency is rounded 913 910 0x8000001c, 0, ecx, 15:9, lwp_version , LWP implementation version ··· 916 913 0x8000001c, 0, ecx, 29, lwp_ip_filtering , IP filtering (IPI, IPF, BaseIP, and LimitIP @ LWPCP) supported 917 914 0x8000001c, 0, ecx, 30, lwp_cache_levels , Cache-related events can be filtered by cache level 918 915 0x8000001c, 0, ecx, 31, lwp_cache_latency , Cache-related events can be filtered by latency 919 - 0x8000001c, 0, edx, 0, hw_lwp_avail , LWP is available in Hardware 920 - 0x8000001c, 0, edx, 1, hw_lpwval , LWPVAL instruction (EventId=1) is available in HW 921 - 0x8000001c, 0, edx, 2, hw_lwp_ire , Instructions Retired Event (EventId=2) is available in HW 922 - 0x8000001c, 0, edx, 3, hw_lwp_bre , Branch Retired Event (EventId=3) is available in HW 923 - 0x8000001c, 0, edx, 4, hw_lwp_dme , DCache Miss Event (EventId=4) is available in HW 924 - 0x8000001c, 0, edx, 5, hw_lwp_cnh , CPU Clocks Not Halted event (EventId=5) is available in HW 925 - 0x8000001c, 0, edx, 6, hw_lwp_rnh , CPU Reference clocks Not Halted event (EventId=6) is available in HW 926 - 0x8000001c, 0, edx, 29, hw_lwp_cont , LWP sampling in continuous mode is available in HW 927 - 0x8000001c, 0, edx, 30, hw_lwp_ptsc , Performance Time Stamp Counter in event records is available in HW 928 - 0x8000001c, 0, edx, 31, hw_lwp_int , Interrupt on threshold overflow is available in HW 916 + 0x8000001c, 0, edx, 0, hw_lwp_avail , LWP is available in hardware 917 + 0x8000001c, 0, edx, 1, hw_lpwval , LWPVAL instruction is available in hardware 918 + 0x8000001c, 0, edx, 2, hw_lwp_ire , Instructions Retired Event is available in hardware 919 + 0x8000001c, 0, edx, 3, hw_lwp_bre , Branch Retired Event is available in hardware 920 + 0x8000001c, 0, edx, 4, hw_lwp_dme , Dcache Miss Event is available in hardware 921 + 0x8000001c, 0, edx, 5, hw_lwp_cnh , Clocks Not Halted event is available in hardware 922 + 0x8000001c, 0, edx, 6, hw_lwp_rnh , Reference clocks Not Halted event is available in hardware 923 + 0x8000001c, 0, edx, 29, hw_lwp_cont , LWP sampling in continuous mode is available in hardware 924 + 0x8000001c, 0, edx, 30, hw_lwp_ptsc , Performance Time Stamp Counter in event records is available in hardware 925 + 0x8000001c, 0, edx, 31, hw_lwp_int , Interrupt on threshold overflow is available in hardware 929 926 930 927 # Leaf 8000001DH 931 928 # AMD deterministic cache parameters ··· 961 958 0x8000001f, 0, eax, 4, sev_nested_paging , SEV secure nested paging supported 962 959 0x8000001f, 0, eax, 5, vm_permission_levels , VMPL supported 963 960 0x8000001f, 0, eax, 6, rpmquery , RPMQUERY instruction supported 964 - 0x8000001f, 0, eax, 7, vmpl_sss , VMPL supervisor shadwo stack supported 961 + 0x8000001f, 0, eax, 7, vmpl_sss , VMPL supervisor shadow stack supported 965 962 0x8000001f, 0, eax, 8, secure_tsc , Secure TSC supported 966 963 0x8000001f, 0, eax, 9, v_tsc_aux , Hardware virtualizes TSC_AUX 967 - 0x8000001f, 0, eax, 10, sme_coherent , HW enforces cache coherency across encryption domains 964 + 0x8000001f, 0, eax, 10, sme_coherent , Cache coherency is enforced across encryption domains 968 965 0x8000001f, 0, eax, 11, req_64bit_hypervisor , SEV guest mandates 64-bit hypervisor 969 966 0x8000001f, 0, eax, 12, restricted_injection , Restricted Injection supported 970 967 0x8000001f, 0, eax, 13, alternate_injection , Alternate Injection supported ··· 976 973 0x8000001f, 0, eax, 19, virt_ibs , IBS state virtualization is supported for SEV-ES guests 977 974 0x8000001f, 0, eax, 24, vmsa_reg_protection , VMSA register protection is supported 978 975 0x8000001f, 0, eax, 25, smt_protection , SMT protection is supported 979 - 0x8000001f, 0, eax, 28, svsm_page_msr , SVSM communication page MSR (0xc001f000h) is supported 976 + 0x8000001f, 0, eax, 28, svsm_page_msr , SVSM communication page MSR (0xc001f000) is supported 980 977 0x8000001f, 0, eax, 29, nested_virt_snp_msr , VIRT_RMPUPDATE/VIRT_PSMASH MSRs are supported 981 978 0x8000001f, 0, ebx, 5:0, pte_cbit_pos , PTE bit number used to enable memory encryption 982 979 0x8000001f, 0, ebx, 11:6, phys_addr_reduction_nbits, Reduction of phys address space when encryption is enabled, in bits 983 980 0x8000001f, 0, ebx, 15:12, vmpl_count , Number of VM permission levels (VMPL) supported 984 981 0x8000001f, 0, ecx, 31:0, enc_guests_max , Max supported number of simultaneous encrypted guests 985 - 0x8000001f, 0, edx, 31:0, min_sev_asid_no_sev_es , Mininum ASID for SEV-enabled SEV-ES-disabled guest 982 + 0x8000001f, 0, edx, 31:0, min_sev_asid_no_sev_es , Minimum ASID for SEV-enabled SEV-ES-disabled guest 986 983 987 984 # Leaf 80000020H 988 985 # AMD Platform QoS extended feature IDs ··· 991 988 0x80000020, 0, ebx, 2, smba , Slow Memory Bandwidth Allocation support 992 989 0x80000020, 0, ebx, 3, bmec , Bandwidth Monitoring Event Configuration support 993 990 0x80000020, 0, ebx, 4, l3rr , L3 Range Reservation support 991 + 0x80000020, 0, ebx, 5, abmc , Assignable Bandwidth Monitoring Counters 992 + 0x80000020, 0, ebx, 6, sdciae , Smart Data Cache Injection (SDCI) Allocation Enforcement 994 993 0x80000020, 1, eax, 31:0, mba_limit_len , MBA enforcement limit size 995 994 0x80000020, 1, edx, 31:0, mba_cos_max , MBA max Class of Service number (zero-based) 996 995 0x80000020, 2, eax, 31:0, smba_limit_len , SMBA enforcement limit size ··· 1012 1007 0x80000021, 0, eax, 0, no_nested_data_bp , No nested data breakpoints 1013 1008 0x80000021, 0, eax, 1, fsgs_non_serializing , WRMSR to {FS,GS,KERNEL_GS}_BASE is non-serializing 1014 1009 0x80000021, 0, eax, 2, lfence_rdtsc , LFENCE always serializing / synchronizes RDTSC 1015 - 0x80000021, 0, eax, 3, smm_page_cfg_lock , SMM paging configuration lock is supported 1010 + 0x80000021, 0, eax, 3, smm_page_cfg_lock , SMM paging configuration lock 1016 1011 0x80000021, 0, eax, 6, null_sel_clr_base , Null selector clears base 1017 - 0x80000021, 0, eax, 7, upper_addr_ignore , EFER MSR Upper Address Ignore Enable bit supported 1018 - 0x80000021, 0, eax, 8, autoibrs , EFER MSR Automatic IBRS enable bit supported 1019 - 0x80000021, 0, eax, 9, no_smm_ctl_msr , SMM_CTL MSR (0xc0010116) is not present 1020 - 0x80000021, 0, eax, 10, fsrs_supported , Fast Short Rep Stosb (FSRS) is supported 1021 - 0x80000021, 0, eax, 11, fsrc_supported , Fast Short Repe Cmpsb (FSRC) is supported 1022 - 0x80000021, 0, eax, 13, prefetch_ctl_msr , Prefetch control MSR is supported 1012 + 0x80000021, 0, eax, 7, upper_addr_ignore , EFER MSR Upper Address Ignore 1013 + 0x80000021, 0, eax, 8, autoibrs , EFER MSR Automatic IBRS 1014 + 0x80000021, 0, eax, 9, no_smm_ctl_msr , SMM_CTL MSR (0xc0010116) is not available 1015 + 0x80000021, 0, eax, 10, fsrs , Fast Short Rep STOSB 1016 + 0x80000021, 0, eax, 11, fsrc , Fast Short Rep CMPSB 1017 + 0x80000021, 0, eax, 13, prefetch_ctl_msr , Prefetch control MSR is available 1018 + 0x80000021, 0, eax, 16, opcode_reclaim , Reserves opcode space 1023 1019 0x80000021, 0, eax, 17, user_cpuid_disable , #GP when executing CPUID at CPL > 0 is supported 1024 - 0x80000021, 0, eax, 18, epsf_supported , Enhanced Predictive Store Forwarding (EPSF) is supported 1025 - 0x80000021, 0, ebx, 11:0, microcode_patch_size , Size of microcode patch, in 16-byte units 1020 + 0x80000021, 0, eax, 18, epsf , Enhanced Predictive Store Forwarding 1021 + 0x80000021, 0, eax, 22, wl_feedback , Workload-based heuristic feedback to OS 1022 + 0x80000021, 0, eax, 24, eraps , Enhanced Return Address Predictor Security 1023 + 0x80000021, 0, eax, 27, sbpb , Selective Branch Predictor Barrier 1024 + 0x80000021, 0, eax, 28, ibpb_brtype , Branch predictions flushed from CPU branch predictor 1025 + 0x80000021, 0, eax, 29, srso_no , CPU is not subject to the SRSO vulnerability 1026 + 0x80000021, 0, eax, 30, srso_uk_no , CPU is not vulnerable to SRSO at user-kernel boundary 1027 + 0x80000021, 0, eax, 31, srso_msr_fix , Software may use MSR BP_CFG[BpSpecReduce] to mitigate SRSO 1028 + 0x80000021, 0, ebx, 15:0, microcode_patch_size , Size of microcode patch, in 16-byte units 1029 + 0x80000021, 0, ebx, 23:16, rap_size , Return Address Predictor size 1026 1030 1027 1031 # Leaf 80000022H 1028 1032 # AMD Performance Monitoring v2 enumeration ··· 1039 1025 0x80000022, 0, eax, 0, perfmon_v2 , Performance monitoring v2 supported 1040 1026 0x80000022, 0, eax, 1, lbr_v2 , Last Branch Record v2 extensions (LBR Stack) 1041 1027 0x80000022, 0, eax, 2, lbr_pmc_freeze , Freezing core performance counters / LBR Stack supported 1042 - 0x80000022, 0, ebx, 3:0, n_pmc_core , Number of core perfomance counters 1028 + 0x80000022, 0, ebx, 3:0, n_pmc_core , Number of core performance counters 1043 1029 0x80000022, 0, ebx, 9:4, lbr_v2_stack_size , Number of available LBR stack entries 1044 1030 0x80000022, 0, ebx, 15:10, n_pmc_northbridge , Number of available northbridge (data fabric) performance counters 1045 1031 0x80000022, 0, ebx, 21:16, n_pmc_umc , Number of available UMC performance counters ··· 1049 1035 # AMD Secure Multi-key Encryption enumeration 1050 1036 1051 1037 0x80000023, 0, eax, 0, mem_hmk_mode , MEM-HMK encryption mode is supported 1052 - 0x80000023, 0, ebx, 15:0, mem_hmk_avail_keys , MEM-HMK mode: total num of available encryption keys 1038 + 0x80000023, 0, ebx, 15:0, mem_hmk_avail_keys , MEM-HMK mode: total number of available encryption keys 1053 1039 1054 1040 # Leaf 80000026H 1055 1041 # AMD extended topology enumeration v2 ··· 1065 1051 0x80000026, 3:0, ecx, 7:0, domain_level , This domain level (subleaf ID) 1066 1052 0x80000026, 3:0, ecx, 15:8, domain_type , This domain type 1067 1053 0x80000026, 3:0, edx, 31:0, x2apic_id , x2APIC ID of current logical CPU 1054 + 1055 + # Leaf 80860000H 1056 + # Maximum Transmeta leaf number + CPU vendor ID string 1057 + 1058 + 0x80860000, 0, eax, 31:0, max_tra_leaf , Maximum supported Transmeta leaf number 1059 + 0x80860000, 0, ebx, 31:0, cpu_vendorid_0 , Transmeta Vendor ID string bytes 0 - 3 1060 + 0x80860000, 0, ecx, 31:0, cpu_vendorid_2 , Transmeta Vendor ID string bytes 8 - 11 1061 + 0x80860000, 0, edx, 31:0, cpu_vendorid_1 , Transmeta Vendor ID string bytes 4 - 7 1062 + 1063 + # Leaf 80860001H 1064 + # Transmeta extended CPU information 1065 + 1066 + 0x80860001, 0, eax, 3:0, stepping , Stepping ID 1067 + 0x80860001, 0, eax, 7:4, base_model , Base CPU model ID 1068 + 0x80860001, 0, eax, 11:8, base_family_id , Base CPU family ID 1069 + 0x80860001, 0, eax, 13:12, cpu_type , CPU type 1070 + 0x80860001, 0, ebx, 7:0, cpu_rev_mask_minor , CPU revision ID, mask minor 1071 + 0x80860001, 0, ebx, 15:8, cpu_rev_mask_major , CPU revision ID, mask major 1072 + 0x80860001, 0, ebx, 23:16, cpu_rev_minor , CPU revision ID, minor 1073 + 0x80860001, 0, ebx, 31:24, cpu_rev_major , CPU revision ID, major 1074 + 0x80860001, 0, ecx, 31:0, cpu_base_mhz , CPU nominal frequency, in MHz 1075 + 0x80860001, 0, edx, 0, recovery , Recovery CMS is active (after bad flush) 1076 + 0x80860001, 0, edx, 1, longrun , LongRun power management capabilities 1077 + 0x80860001, 0, edx, 3, lrti , LongRun Table Interface 1078 + 1079 + # Leaf 80860002H 1080 + # Transmeta Code Morphing Software (CMS) enumeration 1081 + 1082 + 0x80860002, 0, eax, 31:0, cpu_rev_id , CPU revision ID 1083 + 0x80860002, 0, ebx, 7:0, cms_rev_mask_2 , CMS revision ID, mask component 2 1084 + 0x80860002, 0, ebx, 15:8, cms_rev_mask_1 , CMS revision ID, mask component 1 1085 + 0x80860002, 0, ebx, 23:16, cms_rev_minor , CMS revision ID, minor 1086 + 0x80860002, 0, ebx, 31:24, cms_rev_major , CMS revision ID, major 1087 + 0x80860002, 0, ecx, 31:0, cms_rev_mask_3 , CMS revision ID, mask component 3 1088 + 1089 + # Leaf 80860003H 1090 + # Transmeta CPU information string, bytes 0 - 15 1091 + 1092 + 0x80860003, 0, eax, 31:0, cpu_info_0 , CPU info string bytes 0 - 3 1093 + 0x80860003, 0, ebx, 31:0, cpu_info_1 , CPU info string bytes 4 - 7 1094 + 0x80860003, 0, ecx, 31:0, cpu_info_2 , CPU info string bytes 8 - 11 1095 + 0x80860003, 0, edx, 31:0, cpu_info_3 , CPU info string bytes 12 - 15 1096 + 1097 + # Leaf 80860004H 1098 + # Transmeta CPU information string, bytes 16 - 31 1099 + 1100 + 0x80860004, 0, eax, 31:0, cpu_info_4 , CPU info string bytes 16 - 19 1101 + 0x80860004, 0, ebx, 31:0, cpu_info_5 , CPU info string bytes 20 - 23 1102 + 0x80860004, 0, ecx, 31:0, cpu_info_6 , CPU info string bytes 24 - 27 1103 + 0x80860004, 0, edx, 31:0, cpu_info_7 , CPU info string bytes 28 - 31 1104 + 1105 + # Leaf 80860005H 1106 + # Transmeta CPU information string, bytes 32 - 47 1107 + 1108 + 0x80860005, 0, eax, 31:0, cpu_info_8 , CPU info string bytes 32 - 35 1109 + 0x80860005, 0, ebx, 31:0, cpu_info_9 , CPU info string bytes 36 - 39 1110 + 0x80860005, 0, ecx, 31:0, cpu_info_10 , CPU info string bytes 40 - 43 1111 + 0x80860005, 0, edx, 31:0, cpu_info_11 , CPU info string bytes 44 - 47 1112 + 1113 + # Leaf 80860006H 1114 + # Transmeta CPU information string, bytes 48 - 63 1115 + 1116 + 0x80860006, 0, eax, 31:0, cpu_info_12 , CPU info string bytes 48 - 51 1117 + 0x80860006, 0, ebx, 31:0, cpu_info_13 , CPU info string bytes 52 - 55 1118 + 0x80860006, 0, ecx, 31:0, cpu_info_14 , CPU info string bytes 56 - 59 1119 + 0x80860006, 0, edx, 31:0, cpu_info_15 , CPU info string bytes 60 - 63 1120 + 1121 + # Leaf 80860007H 1122 + # Transmeta live CPU information 1123 + 1124 + 0x80860007, 0, eax, 31:0, cpu_cur_mhz , Current CPU frequency, in MHz 1125 + 0x80860007, 0, ebx, 31:0, cpu_cur_voltage , Current CPU voltage, in millivolts 1126 + 0x80860007, 0, ecx, 31:0, cpu_cur_perf_pctg , Current CPU performance percentage, 0 - 100 1127 + 0x80860007, 0, edx, 31:0, cpu_cur_gate_delay , Current CPU gate delay, in femtoseconds 1128 + 1129 + # Leaf C0000000H 1130 + # Maximum Centaur/Zhaoxin leaf number 1131 + 1132 + 0xc0000000, 0, eax, 31:0, max_cntr_leaf , Maximum Centaur/Zhaoxin leaf number 1133 + 1134 + # Leaf C0000001H 1135 + # Centaur/Zhaoxin extended CPU features 1136 + 1137 + 0xc0000001, 0, edx, 0, ccs_sm2 , CCS SM2 instructions 1138 + 0xc0000001, 0, edx, 1, ccs_sm2_en , CCS SM2 enabled 1139 + 0xc0000001, 0, edx, 2, xstore , Random Number Generator 1140 + 0xc0000001, 0, edx, 3, xstore_en , RNG enabled 1141 + 0xc0000001, 0, edx, 4, ccs_sm3_sm4 , CCS SM3 and SM4 instructions 1142 + 0xc0000001, 0, edx, 5, ccs_sm3_sm4_en , CCS SM3/SM4 enabled 1143 + 0xc0000001, 0, edx, 6, ace , Advanced Cryptography Engine 1144 + 0xc0000001, 0, edx, 7, ace_en , ACE enabled 1145 + 0xc0000001, 0, edx, 8, ace2 , Advanced Cryptography Engine v2 1146 + 0xc0000001, 0, edx, 9, ace2_en , ACE v2 enabled 1147 + 0xc0000001, 0, edx, 10, phe , PadLock Hash Engine 1148 + 0xc0000001, 0, edx, 11, phe_en , PHE enabled 1149 + 0xc0000001, 0, edx, 12, pmm , PadLock Montgomery Multiplier 1150 + 0xc0000001, 0, edx, 13, pmm_en , PMM enabled 1151 + 0xc0000001, 0, edx, 16, parallax , Parallax auto adjust processor voltage 1152 + 0xc0000001, 0, edx, 17, parallax_en , Parallax enabled 1153 + 0xc0000001, 0, edx, 20, tm3 , Thermal Monitor v3 1154 + 0xc0000001, 0, edx, 21, tm3_en , TM v3 enabled 1155 + 0xc0000001, 0, edx, 25, phe2 , PadLock Hash Engine v2 (SHA384/SHA512) 1156 + 0xc0000001, 0, edx, 26, phe2_en , PHE v2 enabled 1157 + 0xc0000001, 0, edx, 27, rsa , RSA instructions (XMODEXP/MONTMUL2) 1158 + 0xc0000001, 0, edx, 28, rsa_en , RSA instructions enabled
+180 -195
tools/arch/x86/kcpuid/kcpuid.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 2 2 #define _GNU_SOURCE 3 3 4 - #include <stdio.h> 4 + #include <cpuid.h> 5 + #include <err.h> 6 + #include <getopt.h> 5 7 #include <stdbool.h> 8 + #include <stdio.h> 6 9 #include <stdlib.h> 7 10 #include <string.h> 8 - #include <getopt.h> 9 11 10 12 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) 11 13 #define min(a, b) (((a) < (b)) ? (a) : (b)) 14 + #define __noreturn __attribute__((__noreturn__)) 12 15 13 16 typedef unsigned int u32; 14 17 typedef unsigned long long u64; ··· 52 49 struct subleaf { 53 50 u32 index; 54 51 u32 sub; 55 - u32 eax, ebx, ecx, edx; 52 + u32 output[NR_REGS]; 56 53 struct reg_desc info[NR_REGS]; 57 54 }; 58 55 ··· 66 63 int nr; 67 64 }; 68 65 66 + enum range_index { 67 + RANGE_STD = 0, /* Standard */ 68 + RANGE_EXT = 0x80000000, /* Extended */ 69 + RANGE_TSM = 0x80860000, /* Transmeta */ 70 + RANGE_CTR = 0xc0000000, /* Centaur/Zhaoxin */ 71 + }; 72 + 73 + #define CPUID_INDEX_MASK 0xffff0000 74 + #define CPUID_FUNCTION_MASK (~CPUID_INDEX_MASK) 75 + 69 76 struct cpuid_range { 70 77 /* array of main leafs */ 71 78 struct cpuid_func *funcs; 72 79 /* number of valid leafs */ 73 80 int nr; 74 - bool is_ext; 81 + enum range_index index; 75 82 }; 76 83 77 - /* 78 - * basic: basic functions range: [0... ] 79 - * ext: extended functions range: [0x80000000... ] 80 - */ 81 - struct cpuid_range *leafs_basic, *leafs_ext; 84 + static struct cpuid_range ranges[] = { 85 + { .index = RANGE_STD, }, 86 + { .index = RANGE_EXT, }, 87 + { .index = RANGE_TSM, }, 88 + { .index = RANGE_CTR, }, 89 + }; 82 90 83 - static bool is_amd; 91 + static char *range_to_str(struct cpuid_range *range) 92 + { 93 + switch (range->index) { 94 + case RANGE_STD: return "Standard"; 95 + case RANGE_EXT: return "Extended"; 96 + case RANGE_TSM: return "Transmeta"; 97 + case RANGE_CTR: return "Centaur"; 98 + default: return NULL; 99 + } 100 + } 101 + 102 + #define __for_each_cpuid_range(range, __condition) \ 103 + for (unsigned int i = 0; \ 104 + i < ARRAY_SIZE(ranges) && ((range) = &ranges[i]) && (__condition); \ 105 + i++) 106 + 107 + #define for_each_valid_cpuid_range(range) __for_each_cpuid_range(range, (range)->nr != 0) 108 + #define for_each_cpuid_range(range) __for_each_cpuid_range(range, true) 109 + 110 + struct cpuid_range *index_to_cpuid_range(u32 index) 111 + { 112 + u32 func_idx = index & CPUID_FUNCTION_MASK; 113 + u32 range_idx = index & CPUID_INDEX_MASK; 114 + struct cpuid_range *range; 115 + 116 + for_each_valid_cpuid_range(range) { 117 + if (range->index == range_idx && (u32)range->nr > func_idx) 118 + return range; 119 + } 120 + 121 + return NULL; 122 + } 123 + 84 124 static bool show_details; 85 125 static bool show_raw; 86 126 static bool show_flags_only = true; ··· 131 85 static u32 user_sub = 0xFFFFFFFF; 132 86 static int flines; 133 87 134 - static inline void cpuid(u32 *eax, u32 *ebx, u32 *ecx, u32 *edx) 135 - { 136 - /* ecx is often an input as well as an output. */ 137 - asm volatile("cpuid" 138 - : "=a" (*eax), 139 - "=b" (*ebx), 140 - "=c" (*ecx), 141 - "=d" (*edx) 142 - : "0" (*eax), "2" (*ecx)); 143 - } 88 + /* 89 + * Force using <cpuid.h> __cpuid_count() instead of __cpuid(). The 90 + * latter leaves ECX uninitialized, which can break CPUID queries. 91 + */ 92 + 93 + #define cpuid(leaf, a, b, c, d) \ 94 + __cpuid_count(leaf, 0, a, b, c, d) 95 + 96 + #define cpuid_count(leaf, subleaf, a, b, c, d) \ 97 + __cpuid_count(leaf, subleaf, a, b, c, d) 144 98 145 99 static inline bool has_subleafs(u32 f) 146 100 { ··· 163 117 if (leaf->sub == 0) 164 118 printf("0x%08x: subleafs:\n", leaf->index); 165 119 166 - printf(" %2d: EAX=0x%08x, EBX=0x%08x, ECX=0x%08x, EDX=0x%08x\n", 167 - leaf->sub, leaf->eax, leaf->ebx, leaf->ecx, leaf->edx); 120 + printf(" %2d: EAX=0x%08x, EBX=0x%08x, ECX=0x%08x, EDX=0x%08x\n", leaf->sub, 121 + leaf->output[0], leaf->output[1], leaf->output[2], leaf->output[3]); 168 122 } else { 169 - printf("0x%08x: EAX=0x%08x, EBX=0x%08x, ECX=0x%08x, EDX=0x%08x\n", 170 - leaf->index, leaf->eax, leaf->ebx, leaf->ecx, leaf->edx); 123 + printf("0x%08x: EAX=0x%08x, EBX=0x%08x, ECX=0x%08x, EDX=0x%08x\n", leaf->index, 124 + leaf->output[0], leaf->output[1], leaf->output[2], leaf->output[3]); 171 125 } 172 126 } 173 127 ··· 186 140 * Cut off vendor-prefix from CPUID function as we're using it as an 187 141 * index into ->funcs. 188 142 */ 189 - func = &range->funcs[f & 0xffff]; 143 + func = &range->funcs[f & CPUID_FUNCTION_MASK]; 190 144 191 145 if (!func->leafs) { 192 146 func->leafs = malloc(sizeof(struct subleaf)); 193 147 if (!func->leafs) 194 - perror("malloc func leaf"); 148 + err(EXIT_FAILURE, NULL); 195 149 196 150 func->nr = 1; 197 151 } else { 198 152 s = func->nr; 199 153 func->leafs = realloc(func->leafs, (s + 1) * sizeof(*leaf)); 200 154 if (!func->leafs) 201 - perror("realloc f->leafs"); 155 + err(EXIT_FAILURE, NULL); 202 156 203 157 func->nr++; 204 158 } ··· 207 161 208 162 leaf->index = f; 209 163 leaf->sub = subleaf; 210 - leaf->eax = a; 211 - leaf->ebx = b; 212 - leaf->ecx = c; 213 - leaf->edx = d; 164 + leaf->output[R_EAX] = a; 165 + leaf->output[R_EBX] = b; 166 + leaf->output[R_ECX] = c; 167 + leaf->output[R_EDX] = d; 214 168 215 169 return false; 216 170 } 217 171 218 172 static void raw_dump_range(struct cpuid_range *range) 219 173 { 220 - u32 f; 221 - int i; 222 - 223 - printf("%s Leafs :\n", range->is_ext ? "Extended" : "Basic"); 174 + printf("%s Leafs :\n", range_to_str(range)); 224 175 printf("================\n"); 225 176 226 - for (f = 0; (int)f < range->nr; f++) { 177 + for (u32 f = 0; (int)f < range->nr; f++) { 227 178 struct cpuid_func *func = &range->funcs[f]; 228 - u32 index = f; 229 - 230 - if (range->is_ext) 231 - index += 0x80000000; 232 179 233 180 /* Skip leaf without valid items */ 234 181 if (!func->nr) 235 182 continue; 236 183 237 184 /* First item is the main leaf, followed by all subleafs */ 238 - for (i = 0; i < func->nr; i++) 185 + for (int i = 0; i < func->nr; i++) 239 186 leaf_print_raw(&func->leafs[i]); 240 187 } 241 188 } 242 189 243 190 #define MAX_SUBLEAF_NUM 64 244 - struct cpuid_range *setup_cpuid_range(u32 input_eax) 191 + #define MAX_RANGE_INDEX_OFFSET 0xff 192 + void setup_cpuid_range(struct cpuid_range *range) 245 193 { 246 - u32 max_func, idx_func, subleaf, max_subleaf; 247 - u32 eax, ebx, ecx, edx, f = input_eax; 248 - struct cpuid_range *range; 249 - bool allzero; 194 + u32 max_func, range_funcs_sz; 195 + u32 eax, ebx, ecx, edx; 250 196 251 - eax = input_eax; 252 - ebx = ecx = edx = 0; 197 + cpuid(range->index, max_func, ebx, ecx, edx); 253 198 254 - cpuid(&eax, &ebx, &ecx, &edx); 255 - max_func = eax; 256 - idx_func = (max_func & 0xffff) + 1; 199 + /* 200 + * If the CPUID range's maximum function value is garbage, then it 201 + * is not recognized by this CPU. Set the range's number of valid 202 + * leaves to zero so that for_each_valid_cpu_range() can ignore it. 203 + */ 204 + if (max_func < range->index || max_func > (range->index + MAX_RANGE_INDEX_OFFSET)) { 205 + range->nr = 0; 206 + return; 207 + } 257 208 258 - range = malloc(sizeof(struct cpuid_range)); 259 - if (!range) 260 - perror("malloc range"); 209 + range->nr = (max_func & CPUID_FUNCTION_MASK) + 1; 210 + range_funcs_sz = range->nr * sizeof(struct cpuid_func); 261 211 262 - if (input_eax & 0x80000000) 263 - range->is_ext = true; 264 - else 265 - range->is_ext = false; 266 - 267 - range->funcs = malloc(sizeof(struct cpuid_func) * idx_func); 212 + range->funcs = malloc(range_funcs_sz); 268 213 if (!range->funcs) 269 - perror("malloc range->funcs"); 214 + err(EXIT_FAILURE, NULL); 270 215 271 - range->nr = idx_func; 272 - memset(range->funcs, 0, sizeof(struct cpuid_func) * idx_func); 216 + memset(range->funcs, 0, range_funcs_sz); 273 217 274 - for (; f <= max_func; f++) { 275 - eax = f; 276 - subleaf = ecx = 0; 218 + for (u32 f = range->index; f <= max_func; f++) { 219 + u32 max_subleaf = MAX_SUBLEAF_NUM; 220 + bool allzero; 277 221 278 - cpuid(&eax, &ebx, &ecx, &edx); 279 - allzero = cpuid_store(range, f, subleaf, eax, ebx, ecx, edx); 222 + cpuid(f, eax, ebx, ecx, edx); 223 + 224 + allzero = cpuid_store(range, f, 0, eax, ebx, ecx, edx); 280 225 if (allzero) 281 226 continue; 282 227 283 228 if (!has_subleafs(f)) 284 229 continue; 285 - 286 - max_subleaf = MAX_SUBLEAF_NUM; 287 230 288 231 /* 289 232 * Some can provide the exact number of subleafs, ··· 291 256 if (f == 0x80000026) 292 257 max_subleaf = 5; 293 258 294 - for (subleaf = 1; subleaf < max_subleaf; subleaf++) { 295 - eax = f; 296 - ecx = subleaf; 259 + for (u32 subleaf = 1; subleaf < max_subleaf; subleaf++) { 260 + cpuid_count(f, subleaf, eax, ebx, ecx, edx); 297 261 298 - cpuid(&eax, &ebx, &ecx, &edx); 299 - allzero = cpuid_store(range, f, subleaf, 300 - eax, ebx, ecx, edx); 262 + allzero = cpuid_store(range, f, subleaf, eax, ebx, ecx, edx); 301 263 if (allzero) 302 264 continue; 303 265 } 304 266 305 267 } 306 - 307 - return range; 308 268 } 309 269 310 270 /* ··· 310 280 * 0, 0, EAX, 31:0, max_basic_leafs, Max input value for supported subleafs 311 281 * 1, 0, ECX, 0, sse3, Streaming SIMD Extensions 3(SSE3) 312 282 */ 313 - static int parse_line(char *line) 283 + static void parse_line(char *line) 314 284 { 315 285 char *str; 316 - int i; 317 286 struct cpuid_range *range; 318 287 struct cpuid_func *func; 319 288 struct subleaf *leaf; 320 289 u32 index; 321 - u32 sub; 322 290 char buffer[512]; 323 291 char *buf; 324 292 /* ··· 338 310 339 311 /* Skip comments and NULL line */ 340 312 if (line[0] == '#' || line[0] == '\n') 341 - return 0; 313 + return; 342 314 343 315 strncpy(buffer, line, 511); 344 316 buffer[511] = 0; 345 317 str = buffer; 346 - for (i = 0; i < 5; i++) { 318 + for (int i = 0; i < 5; i++) { 347 319 tokens[i] = strtok(str, ","); 348 320 if (!tokens[i]) 349 321 goto err_exit; ··· 356 328 /* index/main-leaf */ 357 329 index = strtoull(tokens[0], NULL, 0); 358 330 359 - if (index & 0x80000000) 360 - range = leafs_ext; 361 - else 362 - range = leafs_basic; 331 + /* 332 + * Skip line parsing if the index is not covered by known-valid 333 + * CPUID ranges on this CPU. 334 + */ 335 + range = index_to_cpuid_range(index); 336 + if (!range) 337 + return; 363 338 364 - index &= 0x7FFFFFFF; 365 - /* Skip line parsing for non-existing indexes */ 366 - if ((int)index >= range->nr) 367 - return -1; 368 - 339 + /* Skip line parsing if the index CPUID output is all zero */ 340 + index &= CPUID_FUNCTION_MASK; 369 341 func = &range->funcs[index]; 370 - 371 - /* Return if the index has no valid item on this platform */ 372 342 if (!func->nr) 373 - return 0; 343 + return; 374 344 375 345 /* subleaf */ 376 346 buf = tokens[1]; ··· 381 355 subleaf_start = strtoul(start, NULL, 0); 382 356 subleaf_end = min(subleaf_end, (u32)(func->nr - 1)); 383 357 if (subleaf_start > subleaf_end) 384 - return 0; 358 + return; 385 359 } else { 386 360 subleaf_start = subleaf_end; 387 361 if (subleaf_start > (u32)(func->nr - 1)) 388 - return 0; 362 + return; 389 363 } 390 364 391 365 /* register */ ··· 408 382 bit_end = strtoul(end, NULL, 0); 409 383 bit_start = (start) ? strtoul(start, NULL, 0) : bit_end; 410 384 411 - for (sub = subleaf_start; sub <= subleaf_end; sub++) { 385 + for (u32 sub = subleaf_start; sub <= subleaf_end; sub++) { 412 386 leaf = &func->leafs[sub]; 413 387 reg = &leaf->info[reg_index]; 414 388 bdesc = &reg->descs[reg->nr++]; ··· 418 392 strcpy(bdesc->simp, strtok(tokens[4], " \t")); 419 393 strcpy(bdesc->detail, tokens[5]); 420 394 } 421 - return 0; 395 + return; 422 396 423 397 err_exit: 424 - printf("Warning: wrong line format:\n"); 425 - printf("\tline[%d]: %s\n", flines, line); 426 - return -1; 398 + warnx("Wrong line format:\n" 399 + "\tline[%d]: %s", flines, line); 427 400 } 428 401 429 402 /* Parse csv file, and construct the array of all leafs and subleafs */ ··· 443 418 file = fopen("./cpuid.csv", "r"); 444 419 } 445 420 446 - if (!file) { 447 - printf("Fail to open '%s'\n", filename); 448 - return; 449 - } 421 + if (!file) 422 + err(EXIT_FAILURE, "%s", filename); 450 423 451 424 while (1) { 452 425 ret = getline(&line, &len, file); ··· 459 436 fclose(file); 460 437 } 461 438 462 - 463 - /* Decode every eax/ebx/ecx/edx */ 464 - static void decode_bits(u32 value, struct reg_desc *rdesc, enum cpuid_reg reg) 439 + static void show_reg(const struct reg_desc *rdesc, u32 value) 465 440 { 466 - struct bits_desc *bdesc; 467 - int start, end, i; 441 + const struct bits_desc *bdesc; 442 + int start, end; 468 443 u32 mask; 469 444 470 - if (!rdesc->nr) { 471 - if (show_details) 472 - printf("\t %s: 0x%08x\n", reg_names[reg], value); 473 - return; 474 - } 475 - 476 - for (i = 0; i < rdesc->nr; i++) { 445 + for (int i = 0; i < rdesc->nr; i++) { 477 446 bdesc = &rdesc->descs[i]; 478 447 479 448 start = bdesc->start; ··· 495 480 } 496 481 } 497 482 483 + static void show_reg_header(bool has_entries, u32 leaf, u32 subleaf, const char *reg_name) 484 + { 485 + if (show_details && has_entries) 486 + printf("CPUID_0x%x_%s[0x%x]:\n", leaf, reg_name, subleaf); 487 + } 488 + 498 489 static void show_leaf(struct subleaf *leaf) 499 490 { 500 - if (!leaf) 501 - return; 502 - 503 - if (show_raw) { 491 + if (show_raw) 504 492 leaf_print_raw(leaf); 505 - } else { 506 - if (show_details) 507 - printf("CPUID_0x%x_ECX[0x%x]:\n", 508 - leaf->index, leaf->sub); 509 - } 510 493 511 - decode_bits(leaf->eax, &leaf->info[R_EAX], R_EAX); 512 - decode_bits(leaf->ebx, &leaf->info[R_EBX], R_EBX); 513 - decode_bits(leaf->ecx, &leaf->info[R_ECX], R_ECX); 514 - decode_bits(leaf->edx, &leaf->info[R_EDX], R_EDX); 494 + for (int i = R_EAX; i < NR_REGS; i++) { 495 + show_reg_header((leaf->info[i].nr > 0), leaf->index, leaf->sub, reg_names[i]); 496 + show_reg(&leaf->info[i], leaf->output[i]); 497 + } 515 498 516 499 if (!show_raw && show_details) 517 500 printf("\n"); ··· 517 504 518 505 static void show_func(struct cpuid_func *func) 519 506 { 520 - int i; 521 - 522 - if (!func) 523 - return; 524 - 525 - for (i = 0; i < func->nr; i++) 507 + for (int i = 0; i < func->nr; i++) 526 508 show_leaf(&func->leafs[i]); 527 509 } 528 510 529 511 static void show_range(struct cpuid_range *range) 530 512 { 531 - int i; 532 - 533 - for (i = 0; i < range->nr; i++) 513 + for (int i = 0; i < range->nr; i++) 534 514 show_func(&range->funcs[i]); 535 515 } 536 516 537 517 static inline struct cpuid_func *index_to_func(u32 index) 538 518 { 519 + u32 func_idx = index & CPUID_FUNCTION_MASK; 539 520 struct cpuid_range *range; 540 - u32 func_idx; 541 521 542 - range = (index & 0x80000000) ? leafs_ext : leafs_basic; 543 - func_idx = index & 0xffff; 544 - 545 - if ((func_idx + 1) > (u32)range->nr) { 546 - printf("ERR: invalid input index (0x%x)\n", index); 522 + range = index_to_cpuid_range(index); 523 + if (!range) 547 524 return NULL; 548 - } 525 + 549 526 return &range->funcs[func_idx]; 550 527 } 551 528 552 529 static void show_info(void) 553 530 { 531 + struct cpuid_range *range; 554 532 struct cpuid_func *func; 555 533 556 534 if (show_raw) { 557 535 /* Show all of the raw output of 'cpuid' instr */ 558 - raw_dump_range(leafs_basic); 559 - raw_dump_range(leafs_ext); 536 + for_each_valid_cpuid_range(range) 537 + raw_dump_range(range); 560 538 return; 561 539 } 562 540 ··· 555 551 /* Only show specific leaf/subleaf info */ 556 552 func = index_to_func(user_index); 557 553 if (!func) 558 - return; 554 + errx(EXIT_FAILURE, "Invalid input leaf (0x%x)", user_index); 559 555 560 556 /* Dump the raw data also */ 561 557 show_raw = true; 562 558 563 559 if (user_sub != 0xFFFFFFFF) { 564 - if (user_sub + 1 <= (u32)func->nr) { 565 - show_leaf(&func->leafs[user_sub]); 566 - return; 560 + if (user_sub + 1 > (u32)func->nr) { 561 + errx(EXIT_FAILURE, "Leaf 0x%x has no valid subleaf = 0x%x", 562 + user_index, user_sub); 567 563 } 568 564 569 - printf("ERR: invalid input subleaf (0x%x)\n", user_sub); 565 + show_leaf(&func->leafs[user_sub]); 566 + return; 570 567 } 571 568 572 569 show_func(func); ··· 575 570 } 576 571 577 572 printf("CPU features:\n=============\n\n"); 578 - show_range(leafs_basic); 579 - show_range(leafs_ext); 573 + for_each_valid_cpuid_range(range) 574 + show_range(range); 580 575 } 581 576 582 - static void setup_platform_cpuid(void) 577 + static void __noreturn usage(int exit_code) 583 578 { 584 - u32 eax, ebx, ecx, edx; 585 - 586 - /* Check vendor */ 587 - eax = ebx = ecx = edx = 0; 588 - cpuid(&eax, &ebx, &ecx, &edx); 589 - 590 - /* "htuA" */ 591 - if (ebx == 0x68747541) 592 - is_amd = true; 593 - 594 - /* Setup leafs for the basic and extended range */ 595 - leafs_basic = setup_cpuid_range(0x0); 596 - leafs_ext = setup_cpuid_range(0x80000000); 597 - } 598 - 599 - static void usage(void) 600 - { 601 - printf("kcpuid [-abdfhr] [-l leaf] [-s subleaf]\n" 602 - "\t-a|--all Show both bit flags and complex bit fields info\n" 603 - "\t-b|--bitflags Show boolean flags only\n" 604 - "\t-d|--detail Show details of the flag/fields (default)\n" 605 - "\t-f|--flags Specify the cpuid csv file\n" 606 - "\t-h|--help Show usage info\n" 607 - "\t-l|--leaf=index Specify the leaf you want to check\n" 608 - "\t-r|--raw Show raw cpuid data\n" 609 - "\t-s|--subleaf=sub Specify the subleaf you want to check\n" 579 + errx(exit_code, "kcpuid [-abdfhr] [-l leaf] [-s subleaf]\n" 580 + "\t-a|--all Show both bit flags and complex bit fields info\n" 581 + "\t-b|--bitflags Show boolean flags only\n" 582 + "\t-d|--detail Show details of the flag/fields (default)\n" 583 + "\t-f|--flags Specify the CPUID CSV file\n" 584 + "\t-h|--help Show usage info\n" 585 + "\t-l|--leaf=index Specify the leaf you want to check\n" 586 + "\t-r|--raw Show raw CPUID data\n" 587 + "\t-s|--subleaf=sub Specify the subleaf you want to check" 610 588 ); 611 589 } 612 590 ··· 605 617 { NULL, 0, NULL, 0 } 606 618 }; 607 619 608 - static int parse_options(int argc, char *argv[]) 620 + static void parse_options(int argc, char *argv[]) 609 621 { 610 622 int c; 611 623 ··· 625 637 user_csv = optarg; 626 638 break; 627 639 case 'h': 628 - usage(); 629 - exit(1); 630 - break; 640 + usage(EXIT_SUCCESS); 631 641 case 'l': 632 642 /* main leaf */ 633 643 user_index = strtoul(optarg, NULL, 0); ··· 638 652 user_sub = strtoul(optarg, NULL, 0); 639 653 break; 640 654 default: 641 - printf("%s: Invalid option '%c'\n", argv[0], optopt); 642 - return -1; 643 - } 644 - 645 - return 0; 655 + usage(EXIT_FAILURE); 656 + } 646 657 } 647 658 648 659 /* ··· 652 669 */ 653 670 int main(int argc, char *argv[]) 654 671 { 655 - if (parse_options(argc, argv)) 656 - return -1; 672 + struct cpuid_range *range; 673 + 674 + parse_options(argc, argv); 657 675 658 676 /* Setup the cpuid leafs of current platform */ 659 - setup_platform_cpuid(); 677 + for_each_cpuid_range(range) 678 + setup_cpuid_range(range); 660 679 661 680 /* Read and parse the 'cpuid.csv' */ 662 681 parse_text();
+2 -1
tools/arch/x86/lib/memset_64.S
··· 3 3 4 4 #include <linux/export.h> 5 5 #include <linux/linkage.h> 6 + #include <linux/cfi_types.h> 6 7 #include <asm/cpufeatures.h> 7 8 #include <asm/alternative.h> 8 9 ··· 29 28 * only for the return value that is the same as the source input, 30 29 * which the compiler could/should do much better anyway. 31 30 */ 32 - SYM_FUNC_START(__memset) 31 + SYM_TYPED_FUNC_START(__memset) 33 32 ALTERNATIVE "jmp memset_orig", "", X86_FEATURE_FSRS 34 33 35 34 movq %rdi,%r9
+45
tools/include/linux/cfi_types.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + /* 3 + * Clang Control Flow Integrity (CFI) type definitions. 4 + */ 5 + #ifndef _LINUX_CFI_TYPES_H 6 + #define _LINUX_CFI_TYPES_H 7 + 8 + #ifdef __ASSEMBLY__ 9 + #include <linux/linkage.h> 10 + 11 + #ifdef CONFIG_CFI_CLANG 12 + /* 13 + * Use the __kcfi_typeid_<function> type identifier symbol to 14 + * annotate indirectly called assembly functions. The compiler emits 15 + * these symbols for all address-taken function declarations in C 16 + * code. 17 + */ 18 + #ifndef __CFI_TYPE 19 + #define __CFI_TYPE(name) \ 20 + .4byte __kcfi_typeid_##name 21 + #endif 22 + 23 + #define SYM_TYPED_ENTRY(name, linkage, align...) \ 24 + linkage(name) ASM_NL \ 25 + align ASM_NL \ 26 + __CFI_TYPE(name) ASM_NL \ 27 + name: 28 + 29 + #define SYM_TYPED_START(name, linkage, align...) \ 30 + SYM_TYPED_ENTRY(name, linkage, align) 31 + 32 + #else /* CONFIG_CFI_CLANG */ 33 + 34 + #define SYM_TYPED_START(name, linkage, align...) \ 35 + SYM_START(name, linkage, align) 36 + 37 + #endif /* CONFIG_CFI_CLANG */ 38 + 39 + #ifndef SYM_TYPED_FUNC_START 40 + #define SYM_TYPED_FUNC_START(name) \ 41 + SYM_TYPED_START(name, SYM_L_GLOBAL, SYM_A_ALIGN) 42 + #endif 43 + 44 + #endif /* __ASSEMBLY__ */ 45 + #endif /* _LINUX_CFI_TYPES_H */
+1
tools/include/uapi/asm-generic/mman-common.h
··· 85 85 /* compatibility flags */ 86 86 #define MAP_FILE 0 87 87 88 + #define PKEY_UNRESTRICTED 0x0 88 89 #define PKEY_DISABLE_ACCESS 0x1 89 90 #define PKEY_DISABLE_WRITE 0x2 90 91 #define PKEY_ACCESS_MASK (PKEY_DISABLE_ACCESS |\
+3 -1
tools/include/uapi/asm-generic/unistd.h
··· 849 849 __SYSCALL(__NR_listxattrat, sys_listxattrat) 850 850 #define __NR_removexattrat 466 851 851 __SYSCALL(__NR_removexattrat, sys_removexattrat) 852 + #define __NR_open_tree_attr 467 853 + __SYSCALL(__NR_open_tree_attr, sys_open_tree_attr) 852 854 853 855 #undef __NR_syscalls 854 - #define __NR_syscalls 467 856 + #define __NR_syscalls 468 855 857 856 858 /* 857 859 * 32 bit systems traditionally used different
+2
tools/include/uapi/linux/in.h
··· 79 79 #define IPPROTO_MPLS IPPROTO_MPLS 80 80 IPPROTO_ETHERNET = 143, /* Ethernet-within-IPv6 Encapsulation */ 81 81 #define IPPROTO_ETHERNET IPPROTO_ETHERNET 82 + IPPROTO_AGGFRAG = 144, /* AGGFRAG in ESP (RFC 9347) */ 83 + #define IPPROTO_AGGFRAG IPPROTO_AGGFRAG 82 84 IPPROTO_RAW = 255, /* Raw IP packets */ 83 85 #define IPPROTO_RAW IPPROTO_RAW 84 86 IPPROTO_SMC = 256, /* Shared Memory Communications */
+5 -4
tools/include/uapi/linux/kvm.h
··· 617 617 #define KVM_X86_DISABLE_EXITS_HLT (1 << 1) 618 618 #define KVM_X86_DISABLE_EXITS_PAUSE (1 << 2) 619 619 #define KVM_X86_DISABLE_EXITS_CSTATE (1 << 3) 620 - #define KVM_X86_DISABLE_VALID_EXITS (KVM_X86_DISABLE_EXITS_MWAIT | \ 621 - KVM_X86_DISABLE_EXITS_HLT | \ 622 - KVM_X86_DISABLE_EXITS_PAUSE | \ 623 - KVM_X86_DISABLE_EXITS_CSTATE) 624 620 625 621 /* for KVM_ENABLE_CAP */ 626 622 struct kvm_enable_cap { ··· 929 933 #define KVM_CAP_PRE_FAULT_MEMORY 236 930 934 #define KVM_CAP_X86_APIC_BUS_CYCLES_NS 237 931 935 #define KVM_CAP_X86_GUEST_MODE 238 936 + #define KVM_CAP_ARM_WRITABLE_IMP_ID_REGS 239 932 937 933 938 struct kvm_irq_routing_irqchip { 934 939 __u32 irqchip; ··· 1067 1070 1068 1071 #define KVM_REG_SIZE_SHIFT 52 1069 1072 #define KVM_REG_SIZE_MASK 0x00f0000000000000ULL 1073 + 1074 + #define KVM_REG_SIZE(id) \ 1075 + (1U << (((id) & KVM_REG_SIZE_MASK) >> KVM_REG_SIZE_SHIFT)) 1076 + 1070 1077 #define KVM_REG_SIZE_U8 0x0000000000000000ULL 1071 1078 #define KVM_REG_SIZE_U16 0x0010000000000000ULL 1072 1079 #define KVM_REG_SIZE_U32 0x0020000000000000ULL
+2
tools/include/uapi/linux/perf_event.h
··· 385 385 * 386 386 * @sample_max_stack: Max number of frame pointers in a callchain, 387 387 * should be < /proc/sys/kernel/perf_event_max_stack 388 + * Max number of entries of branch stack 389 + * should be < hardware limit 388 390 */ 389 391 struct perf_event_attr { 390 392
+75 -24
tools/include/uapi/linux/stat.h
··· 98 98 */ 99 99 struct statx { 100 100 /* 0x00 */ 101 - __u32 stx_mask; /* What results were written [uncond] */ 102 - __u32 stx_blksize; /* Preferred general I/O size [uncond] */ 103 - __u64 stx_attributes; /* Flags conveying information about the file [uncond] */ 101 + /* What results were written [uncond] */ 102 + __u32 stx_mask; 103 + 104 + /* Preferred general I/O size [uncond] */ 105 + __u32 stx_blksize; 106 + 107 + /* Flags conveying information about the file [uncond] */ 108 + __u64 stx_attributes; 109 + 104 110 /* 0x10 */ 105 - __u32 stx_nlink; /* Number of hard links */ 106 - __u32 stx_uid; /* User ID of owner */ 107 - __u32 stx_gid; /* Group ID of owner */ 108 - __u16 stx_mode; /* File mode */ 111 + /* Number of hard links */ 112 + __u32 stx_nlink; 113 + 114 + /* User ID of owner */ 115 + __u32 stx_uid; 116 + 117 + /* Group ID of owner */ 118 + __u32 stx_gid; 119 + 120 + /* File mode */ 121 + __u16 stx_mode; 109 122 __u16 __spare0[1]; 123 + 110 124 /* 0x20 */ 111 - __u64 stx_ino; /* Inode number */ 112 - __u64 stx_size; /* File size */ 113 - __u64 stx_blocks; /* Number of 512-byte blocks allocated */ 114 - __u64 stx_attributes_mask; /* Mask to show what's supported in stx_attributes */ 125 + /* Inode number */ 126 + __u64 stx_ino; 127 + 128 + /* File size */ 129 + __u64 stx_size; 130 + 131 + /* Number of 512-byte blocks allocated */ 132 + __u64 stx_blocks; 133 + 134 + /* Mask to show what's supported in stx_attributes */ 135 + __u64 stx_attributes_mask; 136 + 115 137 /* 0x40 */ 116 - struct statx_timestamp stx_atime; /* Last access time */ 117 - struct statx_timestamp stx_btime; /* File creation time */ 118 - struct statx_timestamp stx_ctime; /* Last attribute change time */ 119 - struct statx_timestamp stx_mtime; /* Last data modification time */ 138 + /* Last access time */ 139 + struct statx_timestamp stx_atime; 140 + 141 + /* File creation time */ 142 + struct statx_timestamp stx_btime; 143 + 144 + /* Last attribute change time */ 145 + struct statx_timestamp stx_ctime; 146 + 147 + /* Last data modification time */ 148 + struct statx_timestamp stx_mtime; 149 + 120 150 /* 0x80 */ 121 - __u32 stx_rdev_major; /* Device ID of special file [if bdev/cdev] */ 151 + /* Device ID of special file [if bdev/cdev] */ 152 + __u32 stx_rdev_major; 122 153 __u32 stx_rdev_minor; 123 - __u32 stx_dev_major; /* ID of device containing file [uncond] */ 154 + 155 + /* ID of device containing file [uncond] */ 156 + __u32 stx_dev_major; 124 157 __u32 stx_dev_minor; 158 + 125 159 /* 0x90 */ 126 160 __u64 stx_mnt_id; 127 - __u32 stx_dio_mem_align; /* Memory buffer alignment for direct I/O */ 128 - __u32 stx_dio_offset_align; /* File offset alignment for direct I/O */ 161 + 162 + /* Memory buffer alignment for direct I/O */ 163 + __u32 stx_dio_mem_align; 164 + 165 + /* File offset alignment for direct I/O */ 166 + __u32 stx_dio_offset_align; 167 + 129 168 /* 0xa0 */ 130 - __u64 stx_subvol; /* Subvolume identifier */ 131 - __u32 stx_atomic_write_unit_min; /* Min atomic write unit in bytes */ 132 - __u32 stx_atomic_write_unit_max; /* Max atomic write unit in bytes */ 169 + /* Subvolume identifier */ 170 + __u64 stx_subvol; 171 + 172 + /* Min atomic write unit in bytes */ 173 + __u32 stx_atomic_write_unit_min; 174 + 175 + /* Max atomic write unit in bytes */ 176 + __u32 stx_atomic_write_unit_max; 177 + 133 178 /* 0xb0 */ 134 - __u32 stx_atomic_write_segments_max; /* Max atomic write segment count */ 135 - __u32 __spare1[1]; 179 + /* Max atomic write segment count */ 180 + __u32 stx_atomic_write_segments_max; 181 + 182 + /* File offset alignment for direct I/O reads */ 183 + __u32 stx_dio_read_offset_align; 184 + 136 185 /* 0xb8 */ 137 186 __u64 __spare3[9]; /* Spare space for future expansion */ 187 + 138 188 /* 0x100 */ 139 189 }; 140 190 ··· 214 164 #define STATX_MNT_ID_UNIQUE 0x00004000U /* Want/got extended stx_mount_id */ 215 165 #define STATX_SUBVOL 0x00008000U /* Want/got stx_subvol */ 216 166 #define STATX_WRITE_ATOMIC 0x00010000U /* Want/got atomic_write_* fields */ 167 + #define STATX_DIO_READ_ALIGN 0x00020000U /* Want/got dio read alignment info */ 217 168 218 169 #define STATX__RESERVED 0x80000000U /* Reserved for future struct statx expansion */ 219 170
+1
tools/perf/arch/arm/entry/syscalls/syscall.tbl
··· 481 481 464 common getxattrat sys_getxattrat 482 482 465 common listxattrat sys_listxattrat 483 483 466 common removexattrat sys_removexattrat 484 + 467 common open_tree_attr sys_open_tree_attr
+1
tools/perf/arch/mips/entry/syscalls/syscall_n64.tbl
··· 381 381 464 n64 getxattrat sys_getxattrat 382 382 465 n64 listxattrat sys_listxattrat 383 383 466 n64 removexattrat sys_removexattrat 384 + 467 n64 open_tree_attr sys_open_tree_attr
+1
tools/perf/arch/powerpc/entry/syscalls/syscall.tbl
··· 557 557 464 common getxattrat sys_getxattrat 558 558 465 common listxattrat sys_listxattrat 559 559 466 common removexattrat sys_removexattrat 560 + 467 common open_tree_attr sys_open_tree_attr
+1
tools/perf/arch/s390/entry/syscalls/syscall.tbl
··· 469 469 464 common getxattrat sys_getxattrat sys_getxattrat 470 470 465 common listxattrat sys_listxattrat sys_listxattrat 471 471 466 common removexattrat sys_removexattrat sys_removexattrat 472 + 467 common open_tree_attr sys_open_tree_attr sys_open_tree_attr
+1
tools/perf/arch/sh/entry/syscalls/syscall.tbl
··· 470 470 464 common getxattrat sys_getxattrat 471 471 465 common listxattrat sys_listxattrat 472 472 466 common removexattrat sys_removexattrat 473 + 467 common open_tree_attr sys_open_tree_attr
+1
tools/perf/arch/sparc/entry/syscalls/syscall.tbl
··· 512 512 464 common getxattrat sys_getxattrat 513 513 465 common listxattrat sys_listxattrat 514 514 466 common removexattrat sys_removexattrat 515 + 467 common open_tree_attr sys_open_tree_attr
+2 -1
tools/perf/arch/x86/entry/syscalls/syscall_32.tbl
··· 396 396 381 i386 pkey_alloc sys_pkey_alloc 397 397 382 i386 pkey_free sys_pkey_free 398 398 383 i386 statx sys_statx 399 - 384 i386 arch_prctl sys_arch_prctl compat_sys_arch_prctl 399 + 384 i386 arch_prctl sys_arch_prctl 400 400 385 i386 io_pgetevents sys_io_pgetevents_time32 compat_sys_io_pgetevents 401 401 386 i386 rseq sys_rseq 402 402 393 i386 semget sys_semget ··· 472 472 464 i386 getxattrat sys_getxattrat 473 473 465 i386 listxattrat sys_listxattrat 474 474 466 i386 removexattrat sys_removexattrat 475 + 467 i386 open_tree_attr sys_open_tree_attr
+1
tools/perf/arch/x86/entry/syscalls/syscall_64.tbl
··· 390 390 464 common getxattrat sys_getxattrat 391 391 465 common listxattrat sys_listxattrat 392 392 466 common removexattrat sys_removexattrat 393 + 467 common open_tree_attr sys_open_tree_attr 393 394 394 395 # 395 396 # Due to a historical design error, certain syscalls are numbered differently
+1
tools/perf/arch/xtensa/entry/syscalls/syscall.tbl
··· 437 437 464 common getxattrat sys_getxattrat 438 438 465 common listxattrat sys_listxattrat 439 439 466 common removexattrat sys_removexattrat 440 + 467 common open_tree_attr sys_open_tree_attr
+2 -1
tools/perf/check-headers.sh
··· 20 20 "include/uapi/linux/stat.h" 21 21 "include/linux/bits.h" 22 22 "include/vdso/bits.h" 23 + "include/linux/cfi_types.h" 23 24 "include/linux/const.h" 24 25 "include/vdso/const.h" 25 26 "include/vdso/unaligned.h" ··· 186 185 # diff with extra ignore lines 187 186 check arch/x86/lib/memcpy_64.S '-I "^EXPORT_SYMBOL" -I "^#include <asm/export.h>" -I"^SYM_FUNC_START\(_LOCAL\)*(memcpy_\(erms\|orig\))" -I"^#include <linux/cfi_types.h>"' 188 187 check arch/x86/lib/memset_64.S '-I "^EXPORT_SYMBOL" -I "^#include <asm/export.h>" -I"^SYM_FUNC_START\(_LOCAL\)*(memset_\(erms\|orig\))"' 189 - check arch/x86/include/asm/amd-ibs.h '-I "^#include [<\"]\(asm/\)*msr-index.h"' 188 + check arch/x86/include/asm/amd/ibs.h '-I "^#include [<\"]\(asm/\)*msr-index.h"' 190 189 check arch/arm64/include/asm/cputype.h '-I "^#include [<\"]\(asm/\)*sysreg.h"' 191 190 check include/linux/unaligned.h '-I "^#include <linux/unaligned/packed_struct.h>" -I "^#include <asm/byteorder.h>" -I "^#pragma GCC diagnostic"' 192 191 check include/uapi/asm-generic/mman.h '-I "^#include <\(uapi/\)*asm-generic/mman-common\(-tools\)*.h>"'
+2
tools/perf/trace/beauty/include/linux/socket.h
··· 392 392 393 393 extern int move_addr_to_kernel(void __user *uaddr, int ulen, struct sockaddr_storage *kaddr); 394 394 extern int put_cmsg(struct msghdr*, int level, int type, int len, void *data); 395 + extern int put_cmsg_notrunc(struct msghdr *msg, int level, int type, int len, 396 + void *data); 395 397 396 398 struct timespec64; 397 399 struct __kernel_timespec;
+4
tools/perf/trace/beauty/include/uapi/linux/fcntl.h
··· 155 155 #define AT_HANDLE_MNT_ID_UNIQUE 0x001 /* Return the u64 unique mount ID. */ 156 156 #define AT_HANDLE_CONNECTABLE 0x002 /* Request a connectable file handle */ 157 157 158 + /* Flags for execveat2(2). */ 159 + #define AT_EXECVE_CHECK 0x10000 /* Only perform a check if execution 160 + would be allowed. */ 161 + 158 162 #endif /* _UAPI_LINUX_FCNTL_H */
+16 -5
tools/perf/trace/beauty/include/uapi/linux/fs.h
··· 40 40 #define BLOCK_SIZE_BITS 10 41 41 #define BLOCK_SIZE (1<<BLOCK_SIZE_BITS) 42 42 43 + /* flags for integrity meta */ 44 + #define IO_INTEGRITY_CHK_GUARD (1U << 0) /* enforce guard check */ 45 + #define IO_INTEGRITY_CHK_REFTAG (1U << 1) /* enforce ref check */ 46 + #define IO_INTEGRITY_CHK_APPTAG (1U << 2) /* enforce app check */ 47 + 48 + #define IO_INTEGRITY_VALID_FLAGS (IO_INTEGRITY_CHK_GUARD | \ 49 + IO_INTEGRITY_CHK_REFTAG | \ 50 + IO_INTEGRITY_CHK_APPTAG) 51 + 43 52 #define SEEK_SET 0 /* seek relative to beginning of file */ 44 53 #define SEEK_CUR 1 /* seek relative to current file position */ 45 54 #define SEEK_END 2 /* seek relative to end of file */ ··· 212 203 #define BLKROTATIONAL _IO(0x12,126) 213 204 #define BLKZEROOUT _IO(0x12,127) 214 205 #define BLKGETDISKSEQ _IOR(0x12,128,__u64) 215 - /* 216 - * A jump here: 130-136 are reserved for zoned block devices 217 - * (see uapi/linux/blkzoned.h) 218 - */ 206 + /* 130-136 are used by zoned block device ioctls (uapi/linux/blkzoned.h) */ 207 + /* 137-141 are used by blk-crypto ioctls (uapi/linux/blk-crypto.h) */ 219 208 220 209 #define BMAP_IOCTL 1 /* obsolete - kept for compatibility */ 221 210 #define FIBMAP _IO(0x00,1) /* bmap access */ ··· 339 332 /* Atomic Write */ 340 333 #define RWF_ATOMIC ((__force __kernel_rwf_t)0x00000040) 341 334 335 + /* buffered IO that drops the cache after reading or writing data */ 336 + #define RWF_DONTCACHE ((__force __kernel_rwf_t)0x00000080) 337 + 342 338 /* mask of flags supported by the kernel */ 343 339 #define RWF_SUPPORTED (RWF_HIPRI | RWF_DSYNC | RWF_SYNC | RWF_NOWAIT |\ 344 - RWF_APPEND | RWF_NOAPPEND | RWF_ATOMIC) 340 + RWF_APPEND | RWF_NOAPPEND | RWF_ATOMIC |\ 341 + RWF_DONTCACHE) 345 342 346 343 #define PROCFS_IOCTL_MAGIC 'f' 347 344
+9 -1
tools/perf/trace/beauty/include/uapi/linux/mount.h
··· 179 179 __u32 opt_array; /* [str] Array of nul terminated fs options */ 180 180 __u32 opt_sec_num; /* Number of security options */ 181 181 __u32 opt_sec_array; /* [str] Array of nul terminated security options */ 182 - __u64 __spare2[46]; 182 + __u64 supported_mask; /* Mask flags that this kernel supports */ 183 + __u32 mnt_uidmap_num; /* Number of uid mappings */ 184 + __u32 mnt_uidmap; /* [str] Array of uid mappings (as seen from callers namespace) */ 185 + __u32 mnt_gidmap_num; /* Number of gid mappings */ 186 + __u32 mnt_gidmap; /* [str] Array of gid mappings (as seen from callers namespace) */ 187 + __u64 __spare2[43]; 183 188 char str[]; /* Variable size part containing strings */ 184 189 }; 185 190 ··· 222 217 #define STATMOUNT_SB_SOURCE 0x00000200U /* Want/got sb_source */ 223 218 #define STATMOUNT_OPT_ARRAY 0x00000400U /* Want/got opt_... */ 224 219 #define STATMOUNT_OPT_SEC_ARRAY 0x00000800U /* Want/got opt_sec... */ 220 + #define STATMOUNT_SUPPORTED_MASK 0x00001000U /* Want/got supported mask flags */ 221 + #define STATMOUNT_MNT_UIDMAP 0x00002000U /* Want/got uidmap... */ 222 + #define STATMOUNT_MNT_GIDMAP 0x00004000U /* Want/got gidmap... */ 225 223 226 224 /* 227 225 * Special @mnt_id values that can be passed to listmount
+11
tools/perf/trace/beauty/include/uapi/linux/prctl.h
··· 353 353 */ 354 354 #define PR_LOCK_SHADOW_STACK_STATUS 76 355 355 356 + /* 357 + * Controls the mode of timer_create() for CRIU restore operations. 358 + * Enabling this allows CRIU to restore timers with explicit IDs. 359 + * 360 + * Don't use for normal operations as the result might be undefined. 361 + */ 362 + #define PR_TIMER_CREATE_RESTORE_IDS 77 363 + # define PR_TIMER_CREATE_RESTORE_IDS_OFF 0 364 + # define PR_TIMER_CREATE_RESTORE_IDS_ON 1 365 + # define PR_TIMER_CREATE_RESTORE_IDS_GET 2 366 + 356 367 #endif /* _LINUX_PRCTL_H */
+75 -24
tools/perf/trace/beauty/include/uapi/linux/stat.h
··· 98 98 */ 99 99 struct statx { 100 100 /* 0x00 */ 101 - __u32 stx_mask; /* What results were written [uncond] */ 102 - __u32 stx_blksize; /* Preferred general I/O size [uncond] */ 103 - __u64 stx_attributes; /* Flags conveying information about the file [uncond] */ 101 + /* What results were written [uncond] */ 102 + __u32 stx_mask; 103 + 104 + /* Preferred general I/O size [uncond] */ 105 + __u32 stx_blksize; 106 + 107 + /* Flags conveying information about the file [uncond] */ 108 + __u64 stx_attributes; 109 + 104 110 /* 0x10 */ 105 - __u32 stx_nlink; /* Number of hard links */ 106 - __u32 stx_uid; /* User ID of owner */ 107 - __u32 stx_gid; /* Group ID of owner */ 108 - __u16 stx_mode; /* File mode */ 111 + /* Number of hard links */ 112 + __u32 stx_nlink; 113 + 114 + /* User ID of owner */ 115 + __u32 stx_uid; 116 + 117 + /* Group ID of owner */ 118 + __u32 stx_gid; 119 + 120 + /* File mode */ 121 + __u16 stx_mode; 109 122 __u16 __spare0[1]; 123 + 110 124 /* 0x20 */ 111 - __u64 stx_ino; /* Inode number */ 112 - __u64 stx_size; /* File size */ 113 - __u64 stx_blocks; /* Number of 512-byte blocks allocated */ 114 - __u64 stx_attributes_mask; /* Mask to show what's supported in stx_attributes */ 125 + /* Inode number */ 126 + __u64 stx_ino; 127 + 128 + /* File size */ 129 + __u64 stx_size; 130 + 131 + /* Number of 512-byte blocks allocated */ 132 + __u64 stx_blocks; 133 + 134 + /* Mask to show what's supported in stx_attributes */ 135 + __u64 stx_attributes_mask; 136 + 115 137 /* 0x40 */ 116 - struct statx_timestamp stx_atime; /* Last access time */ 117 - struct statx_timestamp stx_btime; /* File creation time */ 118 - struct statx_timestamp stx_ctime; /* Last attribute change time */ 119 - struct statx_timestamp stx_mtime; /* Last data modification time */ 138 + /* Last access time */ 139 + struct statx_timestamp stx_atime; 140 + 141 + /* File creation time */ 142 + struct statx_timestamp stx_btime; 143 + 144 + /* Last attribute change time */ 145 + struct statx_timestamp stx_ctime; 146 + 147 + /* Last data modification time */ 148 + struct statx_timestamp stx_mtime; 149 + 120 150 /* 0x80 */ 121 - __u32 stx_rdev_major; /* Device ID of special file [if bdev/cdev] */ 151 + /* Device ID of special file [if bdev/cdev] */ 152 + __u32 stx_rdev_major; 122 153 __u32 stx_rdev_minor; 123 - __u32 stx_dev_major; /* ID of device containing file [uncond] */ 154 + 155 + /* ID of device containing file [uncond] */ 156 + __u32 stx_dev_major; 124 157 __u32 stx_dev_minor; 158 + 125 159 /* 0x90 */ 126 160 __u64 stx_mnt_id; 127 - __u32 stx_dio_mem_align; /* Memory buffer alignment for direct I/O */ 128 - __u32 stx_dio_offset_align; /* File offset alignment for direct I/O */ 161 + 162 + /* Memory buffer alignment for direct I/O */ 163 + __u32 stx_dio_mem_align; 164 + 165 + /* File offset alignment for direct I/O */ 166 + __u32 stx_dio_offset_align; 167 + 129 168 /* 0xa0 */ 130 - __u64 stx_subvol; /* Subvolume identifier */ 131 - __u32 stx_atomic_write_unit_min; /* Min atomic write unit in bytes */ 132 - __u32 stx_atomic_write_unit_max; /* Max atomic write unit in bytes */ 169 + /* Subvolume identifier */ 170 + __u64 stx_subvol; 171 + 172 + /* Min atomic write unit in bytes */ 173 + __u32 stx_atomic_write_unit_min; 174 + 175 + /* Max atomic write unit in bytes */ 176 + __u32 stx_atomic_write_unit_max; 177 + 133 178 /* 0xb0 */ 134 - __u32 stx_atomic_write_segments_max; /* Max atomic write segment count */ 135 - __u32 __spare1[1]; 179 + /* Max atomic write segment count */ 180 + __u32 stx_atomic_write_segments_max; 181 + 182 + /* File offset alignment for direct I/O reads */ 183 + __u32 stx_dio_read_offset_align; 184 + 136 185 /* 0xb8 */ 137 186 __u64 __spare3[9]; /* Spare space for future expansion */ 187 + 138 188 /* 0x100 */ 139 189 }; 140 190 ··· 214 164 #define STATX_MNT_ID_UNIQUE 0x00004000U /* Want/got extended stx_mount_id */ 215 165 #define STATX_SUBVOL 0x00008000U /* Want/got stx_subvol */ 216 166 #define STATX_WRITE_ATOMIC 0x00010000U /* Want/got atomic_write_* fields */ 167 + #define STATX_DIO_READ_ALIGN 0x00020000U /* Want/got dio read alignment info */ 217 168 218 169 #define STATX__RESERVED 0x80000000U /* Reserved for future struct statx expansion */ 219 170
+6 -2
tools/perf/trace/beauty/include/uapi/sound/asound.h
··· 716 716 * Raw MIDI section - /dev/snd/midi?? 717 717 */ 718 718 719 - #define SNDRV_RAWMIDI_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 4) 719 + #define SNDRV_RAWMIDI_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 5) 720 720 721 721 enum { 722 722 SNDRV_RAWMIDI_STREAM_OUTPUT = 0, ··· 728 728 #define SNDRV_RAWMIDI_INFO_INPUT 0x00000002 729 729 #define SNDRV_RAWMIDI_INFO_DUPLEX 0x00000004 730 730 #define SNDRV_RAWMIDI_INFO_UMP 0x00000008 731 + #define SNDRV_RAWMIDI_INFO_STREAM_INACTIVE 0x00000010 732 + 733 + #define SNDRV_RAWMIDI_DEVICE_UNKNOWN 0 731 734 732 735 struct snd_rawmidi_info { 733 736 unsigned int device; /* RO/WR (control): device number */ ··· 743 740 unsigned char subname[32]; /* name of active or selected subdevice */ 744 741 unsigned int subdevices_count; 745 742 unsigned int subdevices_avail; 746 - unsigned char reserved[64]; /* reserved for future use */ 743 + int tied_device; /* R: tied rawmidi device (UMP/legacy) */ 744 + unsigned char reserved[60]; /* reserved for future use */ 747 745 }; 748 746 749 747 #define SNDRV_RAWMIDI_MODE_FRAMING_MASK (7<<0)
+1 -1
tools/perf/util/amd-sample-raw.c
··· 9 9 #include <inttypes.h> 10 10 11 11 #include <linux/string.h> 12 - #include "../../arch/x86/include/asm/amd-ibs.h" 12 + #include "../../arch/x86/include/asm/amd/ibs.h" 13 13 14 14 #include "debug.h" 15 15 #include "session.h"
-22
tools/perf/util/evsel.c
··· 2566 2566 return false; 2567 2567 } 2568 2568 2569 - static bool evsel__handle_error_quirks(struct evsel *evsel, int error) 2570 - { 2571 - /* 2572 - * AMD core PMU tries to forward events with precise_ip to IBS PMU 2573 - * implicitly. But IBS PMU has more restrictions so it can fail with 2574 - * supported event attributes. Let's forward it back to the core PMU 2575 - * by clearing precise_ip only if it's from precise_max (:P). 2576 - */ 2577 - if ((error == -EINVAL || error == -ENOENT) && x86__is_amd_cpu() && 2578 - evsel->core.attr.precise_ip && evsel->precise_max) { 2579 - evsel->core.attr.precise_ip = 0; 2580 - pr_debug2_peo("removing precise_ip on AMD\n"); 2581 - display_attr(&evsel->core.attr); 2582 - return true; 2583 - } 2584 - 2585 - return false; 2586 - } 2587 - 2588 2569 static int evsel__open_cpu(struct evsel *evsel, struct perf_cpu_map *cpus, 2589 2570 struct perf_thread_map *threads, 2590 2571 int start_cpu_map_idx, int end_cpu_map_idx) ··· 2709 2728 goto fallback_missing_features; 2710 2729 2711 2730 if (evsel__precise_ip_fallback(evsel)) 2712 - goto retry_open; 2713 - 2714 - if (evsel__handle_error_quirks(evsel, err)) 2715 2731 goto retry_open; 2716 2732 2717 2733 out_close:
+1 -1
tools/perf/util/unwind-libunwind-local.c
··· 371 371 * has to be pointed by symsrc_filename 372 372 */ 373 373 if (ofs == 0) { 374 - if (dso__data_get_fd(dso, machine, &fd) { 374 + if (dso__data_get_fd(dso, machine, &fd)) { 375 375 ofs = elf_section_offset(fd, ".debug_frame"); 376 376 dso__data_put_fd(dso); 377 377 }
+1
tools/scripts/syscall.tbl
··· 407 407 464 common getxattrat sys_getxattrat 408 408 465 common listxattrat sys_listxattrat 409 409 466 common removexattrat sys_removexattrat 410 + 467 common open_tree_attr sys_open_tree_attr