···476476#define X86_FEATURE_CLEAR_BHB_LOOP (21*32+ 1) /* Clear branch history at syscall entry using SW loop */477477#define X86_FEATURE_BHI_CTRL (21*32+ 2) /* BHI_DIS_S HW control available */478478#define X86_FEATURE_CLEAR_BHB_HW (21*32+ 3) /* BHI_DIS_S HW control enabled */479479-#define X86_FEATURE_CLEAR_BHB_LOOP_ON_VMEXIT (21*32+ 4) /* Clear branch history at vmexit using SW loop */480480-#define X86_FEATURE_AMD_FAST_CPPC (21*32 + 5) /* Fast CPPC */481481-#define X86_FEATURE_AMD_HETEROGENEOUS_CORES (21*32 + 6) /* Heterogeneous Core Topology */482482-#define X86_FEATURE_AMD_WORKLOAD_CLASS (21*32 + 7) /* Workload Classification */483483-#define X86_FEATURE_PREFER_YMM (21*32 + 8) /* Avoid ZMM registers due to downclocking */479479+#define X86_FEATURE_CLEAR_BHB_VMEXIT (21*32+ 4) /* Clear branch history at vmexit using SW loop */480480+#define X86_FEATURE_AMD_FAST_CPPC (21*32+ 5) /* Fast CPPC */481481+#define X86_FEATURE_AMD_HTR_CORES (21*32+ 6) /* Heterogeneous Core Topology */482482+#define X86_FEATURE_AMD_WORKLOAD_CLASS (21*32+ 7) /* Workload Classification */483483+#define X86_FEATURE_PREFER_YMM (21*32+ 8) /* Avoid ZMM registers due to downclocking */484484485485/*486486 * BUG word(s)···519519#define X86_BUG_ITLB_MULTIHIT X86_BUG(23) /* "itlb_multihit" CPU may incur MCE during certain page attribute changes */520520#define X86_BUG_SRBDS X86_BUG(24) /* "srbds" CPU may leak RNG bits if not mitigated */521521#define X86_BUG_MMIO_STALE_DATA X86_BUG(25) /* "mmio_stale_data" CPU is affected by Processor MMIO Stale Data vulnerabilities */522522-#define X86_BUG_MMIO_UNKNOWN X86_BUG(26) /* "mmio_unknown" CPU is too old and its MMIO Stale Data status is unknown */522522+/* unused, was #define X86_BUG_MMIO_UNKNOWN X86_BUG(26) "mmio_unknown" CPU is too old and its MMIO Stale Data status is unknown */523523#define X86_BUG_RETBLEED X86_BUG(27) /* "retbleed" CPU is affected by RETBleed */524524#define X86_BUG_EIBRS_PBRSB X86_BUG(28) /* "eibrs_pbrsb" EIBRS is vulnerable to Post Barrier RSB Predictions */525525#define X86_BUG_SMT_RSB X86_BUG(29) /* "smt_rsb" CPU is vulnerable to Cross-Thread Return Address Predictions */···527527#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 */528528529529/* BUG word 2 */530530-#define X86_BUG_SRSO X86_BUG(1*32 + 0) /* "srso" AMD SRSO bug */531531-#define X86_BUG_DIV0 X86_BUG(1*32 + 1) /* "div0" AMD DIV0 speculation bug */532532-#define X86_BUG_RFDS X86_BUG(1*32 + 2) /* "rfds" CPU is vulnerable to Register File Data Sampling */533533-#define X86_BUG_BHI X86_BUG(1*32 + 3) /* "bhi" CPU is affected by Branch History Injection */534534-#define X86_BUG_IBPB_NO_RET X86_BUG(1*32 + 4) /* "ibpb_no_ret" IBPB omits return target predictions */535535-#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 */530530+#define X86_BUG_SRSO X86_BUG( 1*32+ 0) /* "srso" AMD SRSO bug */531531+#define X86_BUG_DIV0 X86_BUG( 1*32+ 1) /* "div0" AMD DIV0 speculation bug */532532+#define X86_BUG_RFDS X86_BUG( 1*32+ 2) /* "rfds" CPU is vulnerable to Register File Data Sampling */533533+#define X86_BUG_BHI X86_BUG( 1*32+ 3) /* "bhi" CPU is affected by Branch History Injection */534534+#define X86_BUG_IBPB_NO_RET X86_BUG( 1*32+ 4) /* "ibpb_no_ret" IBPB omits return target predictions */535535+#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 */536536#endif /* _ASM_X86_CPUFEATURES_H */
···11+/* SPDX-License-Identifier: GPL-2.0 */22+#ifndef _ASM_X86_CPUID_LEAF_0x2_API_H33+#define _ASM_X86_CPUID_LEAF_0x2_API_H44+55+#include <asm/cpuid/api.h>66+#include <asm/cpuid/types.h>77+88+/**99+ * cpuid_get_leaf_0x2_regs() - Return sanitized leaf 0x2 register output1010+ * @regs: Output parameter1111+ *1212+ * Query CPUID leaf 0x2 and store its output in @regs. Force set any1313+ * invalid 1-byte descriptor returned by the hardware to zero (the NULL1414+ * cache/TLB descriptor) before returning it to the caller.1515+ *1616+ * Use for_each_leaf_0x2_entry() to iterate over the register output in1717+ * parsed form.1818+ */1919+static inline void cpuid_get_leaf_0x2_regs(union leaf_0x2_regs *regs)2020+{2121+ cpuid_leaf(0x2, regs);2222+2323+ /*2424+ * All Intel CPUs must report an iteration count of 1. In case2525+ * of bogus hardware, treat all returned descriptors as NULL.2626+ */2727+ if (regs->desc[0] != 0x01) {2828+ for (int i = 0; i < 4; i++)2929+ regs->regv[i] = 0;3030+ return;3131+ }3232+3333+ /*3434+ * The most significant bit (MSB) of each register must be clear.3535+ * If a register is invalid, replace its descriptors with NULL.3636+ */3737+ for (int i = 0; i < 4; i++) {3838+ if (regs->reg[i].invalid)3939+ regs->regv[i] = 0;4040+ }4141+}4242+4343+/**4444+ * for_each_leaf_0x2_entry() - Iterator for parsed leaf 0x2 descriptors4545+ * @regs: Leaf 0x2 register output, returned by cpuid_get_leaf_0x2_regs()4646+ * @__ptr: u8 pointer, for macro internal use only4747+ * @entry: Pointer to parsed descriptor information at each iteration4848+ *4949+ * Loop over the 1-byte descriptors in the passed leaf 0x2 output registers5050+ * @regs. Provide the parsed information for each descriptor through @entry.5151+ *5252+ * To handle cache-specific descriptors, switch on @entry->c_type. For TLB5353+ * descriptors, switch on @entry->t_type.5454+ *5555+ * Example usage for cache descriptors::5656+ *5757+ * const struct leaf_0x2_table *entry;5858+ * union leaf_0x2_regs regs;5959+ * u8 *ptr;6060+ *6161+ * cpuid_get_leaf_0x2_regs(®s);6262+ * for_each_leaf_0x2_entry(regs, ptr, entry) {6363+ * switch (entry->c_type) {6464+ * ...6565+ * }6666+ * }6767+ */6868+#define for_each_leaf_0x2_entry(regs, __ptr, entry) \6969+ for (__ptr = &(regs).desc[1]; \7070+ __ptr < &(regs).desc[16] && (entry = &cpuid_0x2_table[*__ptr]); \7171+ __ptr++)7272+7373+#endif /* _ASM_X86_CPUID_LEAF_0x2_API_H */
+96
arch/x86/include/asm/cpuid/types.h
···22#ifndef _ASM_X86_CPUID_TYPES_H33#define _ASM_X86_CPUID_TYPES_H4455+#include <linux/build_bug.h>56#include <linux/types.h>6778/*···2928#define CPUID_LEAF_TSC 0x153029#define CPUID_LEAF_FREQ 0x163130#define CPUID_LEAF_TILE 0x1d3131+3232+/*3333+ * Types for CPUID(0x2) parsing3434+ * Check <asm/cpuid/leaf_0x2_api.h>3535+ */3636+3737+struct leaf_0x2_reg {3838+ u32 : 31,3939+ invalid : 1;4040+};4141+4242+union leaf_0x2_regs {4343+ struct leaf_0x2_reg reg[4];4444+ u32 regv[4];4545+ u8 desc[16];4646+};4747+4848+/*4949+ * Leaf 0x2 1-byte descriptors' cache types5050+ * To be used for their mappings at cpuid_0x2_table[]5151+ *5252+ * Start at 1 since type 0 is reserved for HW byte descriptors which are5353+ * not recognized by the kernel; i.e., those without an explicit mapping.5454+ */5555+enum _cache_table_type {5656+ CACHE_L1_INST = 1,5757+ CACHE_L1_DATA,5858+ CACHE_L2,5959+ CACHE_L36060+ /* Adjust __TLB_TABLE_TYPE_BEGIN before adding more types */6161+} __packed;6262+#ifndef __CHECKER__6363+static_assert(sizeof(enum _cache_table_type) == 1);6464+#endif6565+6666+/*6767+ * Ensure that leaf 0x2 cache and TLB type values do not intersect,6868+ * since they share the same type field at struct cpuid_0x2_table.6969+ */7070+#define __TLB_TABLE_TYPE_BEGIN (CACHE_L3 + 1)7171+7272+/*7373+ * Leaf 0x2 1-byte descriptors' TLB types7474+ * To be used for their mappings at cpuid_0x2_table[]7575+ */7676+enum _tlb_table_type {7777+ TLB_INST_4K = __TLB_TABLE_TYPE_BEGIN,7878+ TLB_INST_4M,7979+ TLB_INST_2M_4M,8080+ TLB_INST_ALL,8181+8282+ TLB_DATA_4K,8383+ TLB_DATA_4M,8484+ TLB_DATA_2M_4M,8585+ TLB_DATA_4K_4M,8686+ TLB_DATA_1G,8787+ TLB_DATA_1G_2M_4M,8888+8989+ TLB_DATA0_4K,9090+ TLB_DATA0_4M,9191+ TLB_DATA0_2M_4M,9292+9393+ STLB_4K,9494+ STLB_4K_2M,9595+} __packed;9696+#ifndef __CHECKER__9797+static_assert(sizeof(enum _tlb_table_type) == 1);9898+#endif9999+100100+/*101101+ * Combined parsing table for leaf 0x2 cache and TLB descriptors.102102+ */103103+104104+struct leaf_0x2_table {105105+ union {106106+ enum _cache_table_type c_type;107107+ enum _tlb_table_type t_type;108108+ };109109+ union {110110+ short c_size;111111+ short entries;112112+ };113113+};114114+115115+extern const struct leaf_0x2_table cpuid_0x2_table[256];116116+117117+/*118118+ * All of leaf 0x2's one-byte TLB descriptors implies the same number of entries119119+ * for their respective TLB types. TLB descriptor 0x63 is an exception: it120120+ * implies 4 dTLB entries for 1GB pages and 32 dTLB entries for 2MB or 4MB pages.121121+ *122122+ * Encode that descriptor's dTLB entry count for 2MB/4MB pages here, as the entry123123+ * count for dTLB 1GB pages is already encoded at the cpuid_0x2_table[]'s mapping.124124+ */125125+#define TLB_0x63_2M_4M_ENTRIES 323212633127#endif /* _ASM_X86_CPUID_TYPES_H */
+1-1
arch/x86/include/asm/nospec-branch.h
···327327.endm328328329329.macro CLEAR_BRANCH_HISTORY_VMEXIT330330- ALTERNATIVE "", "call clear_bhb_loop", X86_FEATURE_CLEAR_BHB_LOOP_ON_VMEXIT330330+ ALTERNATIVE "", "call clear_bhb_loop", X86_FEATURE_CLEAR_BHB_VMEXIT331331.endm332332#else333333#define CLEAR_BRANCH_HISTORY
+1-1
arch/x86/kernel/acpi/cppc.c
···272272 }273273274274 /* detect if running on heterogeneous design */275275- if (cpu_feature_enabled(X86_FEATURE_AMD_HETEROGENEOUS_CORES)) {275275+ if (cpu_feature_enabled(X86_FEATURE_AMD_HTR_CORES)) {276276 switch (core_type) {277277 case TOPO_CPU_TYPE_UNKNOWN:278278 pr_warn("Undefined core type found for cpu %d\n", cpu);
+1-1
arch/x86/kernel/amd_gart_64.c
···3939#include <asm/gart.h>4040#include <asm/set_memory.h>4141#include <asm/dma.h>4242-#include <asm/amd_nb.h>4242+#include <asm/amd/nb.h>4343#include <asm/x86_init.h>44444545static unsigned long iommu_bus_base; /* GART remapping area (physical) */
+4-5
arch/x86/kernel/amd_nb.c
···1313#include <linux/export.h>1414#include <linux/spinlock.h>1515#include <linux/pci_ids.h>1616-#include <asm/amd_nb.h>1616+1717+#include <asm/amd/nb.h>1818+#include <asm/cpuid.h>17191820static u32 *flush_words;1921···9391 if (amd_gart_present())9492 amd_northbridges.flags |= AMD_NB_GART;95939696- /*9797- * Check for L3 cache presence.9898- */9999- if (!cpuid_edx(0x80000006))9494+ if (!cpuid_amd_hygon_has_l3_cache())10095 return 0;1019610297 /*
+1-1
arch/x86/kernel/amd_node.c
···99 */10101111#include <linux/debugfs.h>1212-#include <asm/amd_node.h>1212+#include <asm/amd/node.h>13131414/*1515 * AMD Nodes are a physical collection of I/O devices within an SoC. There can be one
···11+// SPDX-License-Identifier: GPL-2.022+/*33+ * AMD L3 cache_disable_{0,1} sysfs handling44+ * Documentation/ABI/testing/sysfs-devices-system-cpu55+ */66+77+#include <linux/cacheinfo.h>88+#include <linux/capability.h>99+#include <linux/pci.h>1010+#include <linux/sysfs.h>1111+1212+#include <asm/amd/nb.h>1313+1414+#include "cpu.h"1515+1616+/*1717+ * L3 cache descriptors1818+ */1919+static void amd_calc_l3_indices(struct amd_northbridge *nb)2020+{2121+ struct amd_l3_cache *l3 = &nb->l3_cache;2222+ unsigned int sc0, sc1, sc2, sc3;2323+ u32 val = 0;2424+2525+ pci_read_config_dword(nb->misc, 0x1C4, &val);2626+2727+ /* calculate subcache sizes */2828+ l3->subcaches[0] = sc0 = !(val & BIT(0));2929+ l3->subcaches[1] = sc1 = !(val & BIT(4));3030+3131+ if (boot_cpu_data.x86 == 0x15) {3232+ l3->subcaches[0] = sc0 += !(val & BIT(1));3333+ l3->subcaches[1] = sc1 += !(val & BIT(5));3434+ }3535+3636+ l3->subcaches[2] = sc2 = !(val & BIT(8)) + !(val & BIT(9));3737+ l3->subcaches[3] = sc3 = !(val & BIT(12)) + !(val & BIT(13));3838+3939+ l3->indices = (max(max3(sc0, sc1, sc2), sc3) << 10) - 1;4040+}4141+4242+/*4343+ * check whether a slot used for disabling an L3 index is occupied.4444+ * @l3: L3 cache descriptor4545+ * @slot: slot number (0..1)4646+ *4747+ * @returns: the disabled index if used or negative value if slot free.4848+ */4949+static int amd_get_l3_disable_slot(struct amd_northbridge *nb, unsigned int slot)5050+{5151+ unsigned int reg = 0;5252+5353+ pci_read_config_dword(nb->misc, 0x1BC + slot * 4, ®);5454+5555+ /* check whether this slot is activated already */5656+ if (reg & (3UL << 30))5757+ return reg & 0xfff;5858+5959+ return -1;6060+}6161+6262+static ssize_t show_cache_disable(struct cacheinfo *ci, char *buf, unsigned int slot)6363+{6464+ int index;6565+ struct amd_northbridge *nb = ci->priv;6666+6767+ index = amd_get_l3_disable_slot(nb, slot);6868+ if (index >= 0)6969+ return sysfs_emit(buf, "%d\n", index);7070+7171+ return sysfs_emit(buf, "FREE\n");7272+}7373+7474+#define SHOW_CACHE_DISABLE(slot) \7575+static ssize_t \7676+cache_disable_##slot##_show(struct device *dev, \7777+ struct device_attribute *attr, char *buf) \7878+{ \7979+ struct cacheinfo *ci = dev_get_drvdata(dev); \8080+ return show_cache_disable(ci, buf, slot); \8181+}8282+8383+SHOW_CACHE_DISABLE(0)8484+SHOW_CACHE_DISABLE(1)8585+8686+static void amd_l3_disable_index(struct amd_northbridge *nb, int cpu,8787+ unsigned int slot, unsigned long idx)8888+{8989+ int i;9090+9191+ idx |= BIT(30);9292+9393+ /*9494+ * disable index in all 4 subcaches9595+ */9696+ for (i = 0; i < 4; i++) {9797+ u32 reg = idx | (i << 20);9898+9999+ if (!nb->l3_cache.subcaches[i])100100+ continue;101101+102102+ pci_write_config_dword(nb->misc, 0x1BC + slot * 4, reg);103103+104104+ /*105105+ * We need to WBINVD on a core on the node containing the L3106106+ * cache which indices we disable therefore a simple wbinvd()107107+ * is not sufficient.108108+ */109109+ wbinvd_on_cpu(cpu);110110+111111+ reg |= BIT(31);112112+ pci_write_config_dword(nb->misc, 0x1BC + slot * 4, reg);113113+ }114114+}115115+116116+/*117117+ * disable a L3 cache index by using a disable-slot118118+ *119119+ * @l3: L3 cache descriptor120120+ * @cpu: A CPU on the node containing the L3 cache121121+ * @slot: slot number (0..1)122122+ * @index: index to disable123123+ *124124+ * @return: 0 on success, error status on failure125125+ */126126+static int amd_set_l3_disable_slot(struct amd_northbridge *nb, int cpu,127127+ unsigned int slot, unsigned long index)128128+{129129+ int ret = 0;130130+131131+ /* check if @slot is already used or the index is already disabled */132132+ ret = amd_get_l3_disable_slot(nb, slot);133133+ if (ret >= 0)134134+ return -EEXIST;135135+136136+ if (index > nb->l3_cache.indices)137137+ return -EINVAL;138138+139139+ /* check whether the other slot has disabled the same index already */140140+ if (index == amd_get_l3_disable_slot(nb, !slot))141141+ return -EEXIST;142142+143143+ amd_l3_disable_index(nb, cpu, slot, index);144144+145145+ return 0;146146+}147147+148148+static ssize_t store_cache_disable(struct cacheinfo *ci, const char *buf,149149+ size_t count, unsigned int slot)150150+{151151+ struct amd_northbridge *nb = ci->priv;152152+ unsigned long val = 0;153153+ int cpu, err = 0;154154+155155+ if (!capable(CAP_SYS_ADMIN))156156+ return -EPERM;157157+158158+ cpu = cpumask_first(&ci->shared_cpu_map);159159+160160+ if (kstrtoul(buf, 10, &val) < 0)161161+ return -EINVAL;162162+163163+ err = amd_set_l3_disable_slot(nb, cpu, slot, val);164164+ if (err) {165165+ if (err == -EEXIST)166166+ pr_warn("L3 slot %d in use/index already disabled!\n",167167+ slot);168168+ return err;169169+ }170170+ return count;171171+}172172+173173+#define STORE_CACHE_DISABLE(slot) \174174+static ssize_t \175175+cache_disable_##slot##_store(struct device *dev, \176176+ struct device_attribute *attr, \177177+ const char *buf, size_t count) \178178+{ \179179+ struct cacheinfo *ci = dev_get_drvdata(dev); \180180+ return store_cache_disable(ci, buf, count, slot); \181181+}182182+183183+STORE_CACHE_DISABLE(0)184184+STORE_CACHE_DISABLE(1)185185+186186+static ssize_t subcaches_show(struct device *dev, struct device_attribute *attr,187187+ char *buf)188188+{189189+ struct cacheinfo *ci = dev_get_drvdata(dev);190190+ int cpu = cpumask_first(&ci->shared_cpu_map);191191+192192+ return sysfs_emit(buf, "%x\n", amd_get_subcaches(cpu));193193+}194194+195195+static ssize_t subcaches_store(struct device *dev,196196+ struct device_attribute *attr,197197+ const char *buf, size_t count)198198+{199199+ struct cacheinfo *ci = dev_get_drvdata(dev);200200+ int cpu = cpumask_first(&ci->shared_cpu_map);201201+ unsigned long val;202202+203203+ if (!capable(CAP_SYS_ADMIN))204204+ return -EPERM;205205+206206+ if (kstrtoul(buf, 16, &val) < 0)207207+ return -EINVAL;208208+209209+ if (amd_set_subcaches(cpu, val))210210+ return -EINVAL;211211+212212+ return count;213213+}214214+215215+static DEVICE_ATTR_RW(cache_disable_0);216216+static DEVICE_ATTR_RW(cache_disable_1);217217+static DEVICE_ATTR_RW(subcaches);218218+219219+static umode_t cache_private_attrs_is_visible(struct kobject *kobj,220220+ struct attribute *attr, int unused)221221+{222222+ struct device *dev = kobj_to_dev(kobj);223223+ struct cacheinfo *ci = dev_get_drvdata(dev);224224+ umode_t mode = attr->mode;225225+226226+ if (!ci->priv)227227+ return 0;228228+229229+ if ((attr == &dev_attr_subcaches.attr) &&230230+ amd_nb_has_feature(AMD_NB_L3_PARTITIONING))231231+ return mode;232232+233233+ if ((attr == &dev_attr_cache_disable_0.attr ||234234+ attr == &dev_attr_cache_disable_1.attr) &&235235+ amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE))236236+ return mode;237237+238238+ return 0;239239+}240240+241241+static struct attribute_group cache_private_group = {242242+ .is_visible = cache_private_attrs_is_visible,243243+};244244+245245+static void init_amd_l3_attrs(void)246246+{247247+ static struct attribute **amd_l3_attrs;248248+ int n = 1;249249+250250+ if (amd_l3_attrs) /* already initialized */251251+ return;252252+253253+ if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE))254254+ n += 2;255255+ if (amd_nb_has_feature(AMD_NB_L3_PARTITIONING))256256+ n += 1;257257+258258+ amd_l3_attrs = kcalloc(n, sizeof(*amd_l3_attrs), GFP_KERNEL);259259+ if (!amd_l3_attrs)260260+ return;261261+262262+ n = 0;263263+ if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE)) {264264+ amd_l3_attrs[n++] = &dev_attr_cache_disable_0.attr;265265+ amd_l3_attrs[n++] = &dev_attr_cache_disable_1.attr;266266+ }267267+ if (amd_nb_has_feature(AMD_NB_L3_PARTITIONING))268268+ amd_l3_attrs[n++] = &dev_attr_subcaches.attr;269269+270270+ cache_private_group.attrs = amd_l3_attrs;271271+}272272+273273+const struct attribute_group *cache_get_priv_group(struct cacheinfo *ci)274274+{275275+ struct amd_northbridge *nb = ci->priv;276276+277277+ if (ci->level < 3 || !nb)278278+ return NULL;279279+280280+ if (nb && nb->l3_cache.indices)281281+ init_amd_l3_attrs();282282+283283+ return &cache_private_group;284284+}285285+286286+struct amd_northbridge *amd_init_l3_cache(int index)287287+{288288+ struct amd_northbridge *nb;289289+ int node;290290+291291+ /* only for L3, and not in virtualized environments */292292+ if (index < 3)293293+ return NULL;294294+295295+ node = topology_amd_node_id(smp_processor_id());296296+ nb = node_to_amd_nb(node);297297+ if (nb && !nb->l3_cache.indices)298298+ amd_calc_l3_indices(nb);299299+300300+ return nb;301301+}
+4-14
arch/x86/kernel/cpu/bugs.c
···427427static void __init mmio_select_mitigation(void)428428{429429 if (!boot_cpu_has_bug(X86_BUG_MMIO_STALE_DATA) ||430430- boot_cpu_has_bug(X86_BUG_MMIO_UNKNOWN) ||431430 cpu_mitigations_off()) {432431 mmio_mitigation = MMIO_MITIGATION_OFF;433432 return;···589590 pr_info("TAA: %s\n", taa_strings[taa_mitigation]);590591 if (boot_cpu_has_bug(X86_BUG_MMIO_STALE_DATA))591592 pr_info("MMIO Stale Data: %s\n", mmio_strings[mmio_mitigation]);592592- else if (boot_cpu_has_bug(X86_BUG_MMIO_UNKNOWN))593593- pr_info("MMIO Stale Data: Unknown: No mitigations\n");594593 if (boot_cpu_has_bug(X86_BUG_RFDS))595594 pr_info("Register File Data Sampling: %s\n", rfds_strings[rfds_mitigation]);596595}···1703170617041707 if (bhi_mitigation == BHI_MITIGATION_VMEXIT_ONLY) {17051708 pr_info("Spectre BHI mitigation: SW BHB clearing on VM exit only\n");17061706- setup_force_cpu_cap(X86_FEATURE_CLEAR_BHB_LOOP_ON_VMEXIT);17091709+ setup_force_cpu_cap(X86_FEATURE_CLEAR_BHB_VMEXIT);17071710 return;17081711 }1709171217101713 pr_info("Spectre BHI mitigation: SW BHB clearing on syscall and VM exit\n");17111714 setup_force_cpu_cap(X86_FEATURE_CLEAR_BHB_LOOP);17121712- setup_force_cpu_cap(X86_FEATURE_CLEAR_BHB_LOOP_ON_VMEXIT);17151715+ setup_force_cpu_cap(X86_FEATURE_CLEAR_BHB_VMEXIT);17131716}1714171717151718static void __init spectre_v2_select_mitigation(void)···2777278027782781static ssize_t mmio_stale_data_show_state(char *buf)27792782{27802780- if (boot_cpu_has_bug(X86_BUG_MMIO_UNKNOWN))27812781- return sysfs_emit(buf, "Unknown: No mitigations\n");27822782-27832783 if (mmio_mitigation == MMIO_MITIGATION_OFF)27842784 return sysfs_emit(buf, "%s\n", mmio_strings[mmio_mitigation]);27852785···28522858 !boot_cpu_has(X86_FEATURE_RETPOLINE_LFENCE) &&28532859 rrsba_disabled)28542860 return "; BHI: Retpoline";28552855- else if (boot_cpu_has(X86_FEATURE_CLEAR_BHB_LOOP_ON_VMEXIT))28612861+ else if (boot_cpu_has(X86_FEATURE_CLEAR_BHB_VMEXIT))28562862 return "; BHI: Vulnerable, KVM: SW loop";2857286328582864 return "; BHI: Vulnerable";···29612967 return srbds_show_state(buf);2962296829632969 case X86_BUG_MMIO_STALE_DATA:29642964- case X86_BUG_MMIO_UNKNOWN:29652970 return mmio_stale_data_show_state(buf);2966297129672972 case X86_BUG_RETBLEED:···3029303630303037ssize_t cpu_show_mmio_stale_data(struct device *dev, struct device_attribute *attr, char *buf)30313038{30323032- if (boot_cpu_has_bug(X86_BUG_MMIO_UNKNOWN))30333033- return cpu_show_common(dev, attr, buf, X86_BUG_MMIO_UNKNOWN);30343034- else30353035- return cpu_show_common(dev, attr, buf, X86_BUG_MMIO_STALE_DATA);30393039+ return cpu_show_common(dev, attr, buf, X86_BUG_MMIO_STALE_DATA);30363040}3037304130383042ssize_t cpu_show_retbleed(struct device *dev, struct device_attribute *attr, char *buf)
+362-743
arch/x86/kernel/cpu/cacheinfo.c
···11// SPDX-License-Identifier: GPL-2.022/*33- * Routines to identify caches on Intel CPU.33+ * x86 CPU caches detection and configuration44 *55- * Changes:66- * Venkatesh Pallipadi : Adding cache identification through cpuid(4)77- * Ashok Raj <ashok.raj@intel.com>: Work with CPU hotplug infrastructure.88- * Andi Kleen / Andreas Herrmann : CPUID4 emulation on AMD.55+ * Previous changes66+ * - Venkatesh Pallipadi: Cache identification through CPUID(0x4)77+ * - Ashok Raj <ashok.raj@intel.com>: Work with CPU hotplug infrastructure88+ * - Andi Kleen / Andreas Herrmann: CPUID(0x4) emulation on AMD99 */10101111#include <linux/cacheinfo.h>1212-#include <linux/capability.h>1312#include <linux/cpu.h>1413#include <linux/cpuhotplug.h>1515-#include <linux/pci.h>1614#include <linux/stop_machine.h>1717-#include <linux/sysfs.h>18151919-#include <asm/amd_nb.h>1616+#include <asm/amd/nb.h>2017#include <asm/cacheinfo.h>2118#include <asm/cpufeature.h>1919+#include <asm/cpuid.h>2220#include <asm/mtrr.h>2321#include <asm/smp.h>2422#include <asm/tlbflush.h>25232624#include "cpu.h"2727-2828-#define LVL_1_INST 12929-#define LVL_1_DATA 23030-#define LVL_2 33131-#define LVL_3 432253326/* Shared last level cache maps */3427DEFINE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_llc_shared_map);···3441/* Kernel controls MTRR and/or PAT MSRs. */3542unsigned int memory_caching_control __ro_after_init;36433737-struct _cache_table {3838- unsigned char descriptor;3939- char cache_type;4040- short size;4141-};4242-4343-#define MB(x) ((x) * 1024)4444-4545-/* All the cache descriptor types we care about (no TLB or4646- trace cache entries) */4747-4848-static const struct _cache_table cache_table[] =4949-{5050- { 0x06, LVL_1_INST, 8 }, /* 4-way set assoc, 32 byte line size */5151- { 0x08, LVL_1_INST, 16 }, /* 4-way set assoc, 32 byte line size */5252- { 0x09, LVL_1_INST, 32 }, /* 4-way set assoc, 64 byte line size */5353- { 0x0a, LVL_1_DATA, 8 }, /* 2 way set assoc, 32 byte line size */5454- { 0x0c, LVL_1_DATA, 16 }, /* 4-way set assoc, 32 byte line size */5555- { 0x0d, LVL_1_DATA, 16 }, /* 4-way set assoc, 64 byte line size */5656- { 0x0e, LVL_1_DATA, 24 }, /* 6-way set assoc, 64 byte line size */5757- { 0x21, LVL_2, 256 }, /* 8-way set assoc, 64 byte line size */5858- { 0x22, LVL_3, 512 }, /* 4-way set assoc, sectored cache, 64 byte line size */5959- { 0x23, LVL_3, MB(1) }, /* 8-way set assoc, sectored cache, 64 byte line size */6060- { 0x25, LVL_3, MB(2) }, /* 8-way set assoc, sectored cache, 64 byte line size */6161- { 0x29, LVL_3, MB(4) }, /* 8-way set assoc, sectored cache, 64 byte line size */6262- { 0x2c, LVL_1_DATA, 32 }, /* 8-way set assoc, 64 byte line size */6363- { 0x30, LVL_1_INST, 32 }, /* 8-way set assoc, 64 byte line size */6464- { 0x39, LVL_2, 128 }, /* 4-way set assoc, sectored cache, 64 byte line size */6565- { 0x3a, LVL_2, 192 }, /* 6-way set assoc, sectored cache, 64 byte line size */6666- { 0x3b, LVL_2, 128 }, /* 2-way set assoc, sectored cache, 64 byte line size */6767- { 0x3c, LVL_2, 256 }, /* 4-way set assoc, sectored cache, 64 byte line size */6868- { 0x3d, LVL_2, 384 }, /* 6-way set assoc, sectored cache, 64 byte line size */6969- { 0x3e, LVL_2, 512 }, /* 4-way set assoc, sectored cache, 64 byte line size */7070- { 0x3f, LVL_2, 256 }, /* 2-way set assoc, 64 byte line size */7171- { 0x41, LVL_2, 128 }, /* 4-way set assoc, 32 byte line size */7272- { 0x42, LVL_2, 256 }, /* 4-way set assoc, 32 byte line size */7373- { 0x43, LVL_2, 512 }, /* 4-way set assoc, 32 byte line size */7474- { 0x44, LVL_2, MB(1) }, /* 4-way set assoc, 32 byte line size */7575- { 0x45, LVL_2, MB(2) }, /* 4-way set assoc, 32 byte line size */7676- { 0x46, LVL_3, MB(4) }, /* 4-way set assoc, 64 byte line size */7777- { 0x47, LVL_3, MB(8) }, /* 8-way set assoc, 64 byte line size */7878- { 0x48, LVL_2, MB(3) }, /* 12-way set assoc, 64 byte line size */7979- { 0x49, LVL_3, MB(4) }, /* 16-way set assoc, 64 byte line size */8080- { 0x4a, LVL_3, MB(6) }, /* 12-way set assoc, 64 byte line size */8181- { 0x4b, LVL_3, MB(8) }, /* 16-way set assoc, 64 byte line size */8282- { 0x4c, LVL_3, MB(12) }, /* 12-way set assoc, 64 byte line size */8383- { 0x4d, LVL_3, MB(16) }, /* 16-way set assoc, 64 byte line size */8484- { 0x4e, LVL_2, MB(6) }, /* 24-way set assoc, 64 byte line size */8585- { 0x60, LVL_1_DATA, 16 }, /* 8-way set assoc, sectored cache, 64 byte line size */8686- { 0x66, LVL_1_DATA, 8 }, /* 4-way set assoc, sectored cache, 64 byte line size */8787- { 0x67, LVL_1_DATA, 16 }, /* 4-way set assoc, sectored cache, 64 byte line size */8888- { 0x68, LVL_1_DATA, 32 }, /* 4-way set assoc, sectored cache, 64 byte line size */8989- { 0x78, LVL_2, MB(1) }, /* 4-way set assoc, 64 byte line size */9090- { 0x79, LVL_2, 128 }, /* 8-way set assoc, sectored cache, 64 byte line size */9191- { 0x7a, LVL_2, 256 }, /* 8-way set assoc, sectored cache, 64 byte line size */9292- { 0x7b, LVL_2, 512 }, /* 8-way set assoc, sectored cache, 64 byte line size */9393- { 0x7c, LVL_2, MB(1) }, /* 8-way set assoc, sectored cache, 64 byte line size */9494- { 0x7d, LVL_2, MB(2) }, /* 8-way set assoc, 64 byte line size */9595- { 0x7f, LVL_2, 512 }, /* 2-way set assoc, 64 byte line size */9696- { 0x80, LVL_2, 512 }, /* 8-way set assoc, 64 byte line size */9797- { 0x82, LVL_2, 256 }, /* 8-way set assoc, 32 byte line size */9898- { 0x83, LVL_2, 512 }, /* 8-way set assoc, 32 byte line size */9999- { 0x84, LVL_2, MB(1) }, /* 8-way set assoc, 32 byte line size */100100- { 0x85, LVL_2, MB(2) }, /* 8-way set assoc, 32 byte line size */101101- { 0x86, LVL_2, 512 }, /* 4-way set assoc, 64 byte line size */102102- { 0x87, LVL_2, MB(1) }, /* 8-way set assoc, 64 byte line size */103103- { 0xd0, LVL_3, 512 }, /* 4-way set assoc, 64 byte line size */104104- { 0xd1, LVL_3, MB(1) }, /* 4-way set assoc, 64 byte line size */105105- { 0xd2, LVL_3, MB(2) }, /* 4-way set assoc, 64 byte line size */106106- { 0xd6, LVL_3, MB(1) }, /* 8-way set assoc, 64 byte line size */107107- { 0xd7, LVL_3, MB(2) }, /* 8-way set assoc, 64 byte line size */108108- { 0xd8, LVL_3, MB(4) }, /* 12-way set assoc, 64 byte line size */109109- { 0xdc, LVL_3, MB(2) }, /* 12-way set assoc, 64 byte line size */110110- { 0xdd, LVL_3, MB(4) }, /* 12-way set assoc, 64 byte line size */111111- { 0xde, LVL_3, MB(8) }, /* 12-way set assoc, 64 byte line size */112112- { 0xe2, LVL_3, MB(2) }, /* 16-way set assoc, 64 byte line size */113113- { 0xe3, LVL_3, MB(4) }, /* 16-way set assoc, 64 byte line size */114114- { 0xe4, LVL_3, MB(8) }, /* 16-way set assoc, 64 byte line size */115115- { 0xea, LVL_3, MB(12) }, /* 24-way set assoc, 64 byte line size */116116- { 0xeb, LVL_3, MB(18) }, /* 24-way set assoc, 64 byte line size */117117- { 0xec, LVL_3, MB(24) }, /* 24-way set assoc, 64 byte line size */118118- { 0x00, 0, 0}119119-};120120-121121-12244enum _cache_type {123123- CTYPE_NULL = 0,124124- CTYPE_DATA = 1,125125- CTYPE_INST = 2,126126- CTYPE_UNIFIED = 34545+ CTYPE_NULL = 0,4646+ CTYPE_DATA = 1,4747+ CTYPE_INST = 2,4848+ CTYPE_UNIFIED = 312749};1285012951union _cpuid4_leaf_eax {13052 struct {131131- enum _cache_type type:5;132132- unsigned int level:3;133133- unsigned int is_self_initializing:1;134134- unsigned int is_fully_associative:1;135135- unsigned int reserved:4;136136- unsigned int num_threads_sharing:12;137137- unsigned int num_cores_on_die:6;5353+ enum _cache_type type :5;5454+ unsigned int level :3;5555+ unsigned int is_self_initializing :1;5656+ unsigned int is_fully_associative :1;5757+ unsigned int reserved :4;5858+ unsigned int num_threads_sharing :12;5959+ unsigned int num_cores_on_die :6;13860 } split;13961 u32 full;14062};1416314264union _cpuid4_leaf_ebx {14365 struct {144144- unsigned int coherency_line_size:12;145145- unsigned int physical_line_partition:10;146146- unsigned int ways_of_associativity:10;6666+ unsigned int coherency_line_size :12;6767+ unsigned int physical_line_partition :10;6868+ unsigned int ways_of_associativity :10;14769 } split;14870 u32 full;14971};1507215173union _cpuid4_leaf_ecx {15274 struct {153153- unsigned int number_of_sets:32;7575+ unsigned int number_of_sets :32;15476 } split;15577 u32 full;15678};15779158158-struct _cpuid4_info_regs {8080+struct _cpuid4_info {15981 union _cpuid4_leaf_eax eax;16082 union _cpuid4_leaf_ebx ebx;16183 union _cpuid4_leaf_ecx ecx;16284 unsigned int id;16385 unsigned long size;164164- struct amd_northbridge *nb;16586};16687167167-/* AMD doesn't have CPUID4. Emulate it here to report the same168168- information to the user. This makes some assumptions about the machine:169169- L2 not shared, no SMT etc. that is currently true on AMD CPUs.8888+/* Map CPUID(0x4) EAX.cache_type to <linux/cacheinfo.h> types */8989+static const enum cache_type cache_type_map[] = {9090+ [CTYPE_NULL] = CACHE_TYPE_NOCACHE,9191+ [CTYPE_DATA] = CACHE_TYPE_DATA,9292+ [CTYPE_INST] = CACHE_TYPE_INST,9393+ [CTYPE_UNIFIED] = CACHE_TYPE_UNIFIED,9494+};17095171171- In theory the TLBs could be reported as fake type (they are in "dummy").172172- Maybe later */9696+/*9797+ * Fallback AMD CPUID(0x4) emulation9898+ * AMD CPUs with TOPOEXT can just use CPUID(0x8000001d)9999+ *100100+ * @AMD_L2_L3_INVALID_ASSOC: cache info for the respective L2/L3 cache should101101+ * be determined from CPUID(0x8000001d) instead of CPUID(0x80000006).102102+ */103103+104104+#define AMD_CPUID4_FULLY_ASSOCIATIVE 0xffff105105+#define AMD_L2_L3_INVALID_ASSOC 0x9106106+173107union l1_cache {174108 struct {175175- unsigned line_size:8;176176- unsigned lines_per_tag:8;177177- unsigned assoc:8;178178- unsigned size_in_kb:8;109109+ unsigned line_size :8;110110+ unsigned lines_per_tag :8;111111+ unsigned assoc :8;112112+ unsigned size_in_kb :8;179113 };180180- unsigned val;114114+ unsigned int val;181115};182116183117union l2_cache {184118 struct {185185- unsigned line_size:8;186186- unsigned lines_per_tag:4;187187- unsigned assoc:4;188188- unsigned size_in_kb:16;119119+ unsigned line_size :8;120120+ unsigned lines_per_tag :4;121121+ unsigned assoc :4;122122+ unsigned size_in_kb :16;189123 };190190- unsigned val;124124+ unsigned int val;191125};192126193127union l3_cache {194128 struct {195195- unsigned line_size:8;196196- unsigned lines_per_tag:4;197197- unsigned assoc:4;198198- unsigned res:2;199199- unsigned size_encoded:14;129129+ unsigned line_size :8;130130+ unsigned lines_per_tag :4;131131+ unsigned assoc :4;132132+ unsigned res :2;133133+ unsigned size_encoded :14;200134 };201201- unsigned val;135135+ unsigned int val;202136};203137138138+/* L2/L3 associativity mapping */204139static const unsigned short assocs[] = {205205- [1] = 1,206206- [2] = 2,207207- [4] = 4,208208- [6] = 8,209209- [8] = 16,210210- [0xa] = 32,211211- [0xb] = 48,212212- [0xc] = 64,213213- [0xd] = 96,214214- [0xe] = 128,215215- [0xf] = 0xffff /* fully associative - no way to show this currently */140140+ [1] = 1,141141+ [2] = 2,142142+ [3] = 3,143143+ [4] = 4,144144+ [5] = 6,145145+ [6] = 8,146146+ [8] = 16,147147+ [0xa] = 32,148148+ [0xb] = 48,149149+ [0xc] = 64,150150+ [0xd] = 96,151151+ [0xe] = 128,152152+ [0xf] = AMD_CPUID4_FULLY_ASSOCIATIVE216153};217154218155static const unsigned char levels[] = { 1, 1, 2, 3 };219219-static const unsigned char types[] = { 1, 2, 3, 3 };156156+static const unsigned char types[] = { 1, 2, 3, 3 };220157221221-static const enum cache_type cache_type_map[] = {222222- [CTYPE_NULL] = CACHE_TYPE_NOCACHE,223223- [CTYPE_DATA] = CACHE_TYPE_DATA,224224- [CTYPE_INST] = CACHE_TYPE_INST,225225- [CTYPE_UNIFIED] = CACHE_TYPE_UNIFIED,226226-};227227-228228-static void229229-amd_cpuid4(int leaf, union _cpuid4_leaf_eax *eax,230230- union _cpuid4_leaf_ebx *ebx,231231- union _cpuid4_leaf_ecx *ecx)158158+static void legacy_amd_cpuid4(int index, union _cpuid4_leaf_eax *eax,159159+ union _cpuid4_leaf_ebx *ebx, union _cpuid4_leaf_ecx *ecx)232160{233233- unsigned dummy;234234- unsigned line_size, lines_per_tag, assoc, size_in_kb;235235- union l1_cache l1i, l1d;161161+ unsigned int dummy, line_size, lines_per_tag, assoc, size_in_kb;162162+ union l1_cache l1i, l1d, *l1;236163 union l2_cache l2;237164 union l3_cache l3;238238- union l1_cache *l1 = &l1d;239165240166 eax->full = 0;241167 ebx->full = 0;···163251 cpuid(0x80000005, &dummy, &dummy, &l1d.val, &l1i.val);164252 cpuid(0x80000006, &dummy, &dummy, &l2.val, &l3.val);165253166166- switch (leaf) {254254+ l1 = &l1d;255255+ switch (index) {167256 case 1:168257 l1 = &l1i;169258 fallthrough;170259 case 0:171260 if (!l1->val)172261 return;173173- assoc = assocs[l1->assoc];174174- line_size = l1->line_size;175175- lines_per_tag = l1->lines_per_tag;176176- size_in_kb = l1->size_in_kb;262262+263263+ assoc = (l1->assoc == 0xff) ? AMD_CPUID4_FULLY_ASSOCIATIVE : l1->assoc;264264+ line_size = l1->line_size;265265+ lines_per_tag = l1->lines_per_tag;266266+ size_in_kb = l1->size_in_kb;177267 break;178268 case 2:179179- if (!l2.val)269269+ if (!l2.assoc || l2.assoc == AMD_L2_L3_INVALID_ASSOC)180270 return;181181- assoc = assocs[l2.assoc];182182- line_size = l2.line_size;183183- lines_per_tag = l2.lines_per_tag;184184- /* cpu_data has errata corrections for K7 applied */185185- size_in_kb = __this_cpu_read(cpu_info.x86_cache_size);271271+272272+ /* Use x86_cache_size as it might have K7 errata fixes */273273+ assoc = assocs[l2.assoc];274274+ line_size = l2.line_size;275275+ lines_per_tag = l2.lines_per_tag;276276+ size_in_kb = __this_cpu_read(cpu_info.x86_cache_size);186277 break;187278 case 3:188188- if (!l3.val)279279+ if (!l3.assoc || l3.assoc == AMD_L2_L3_INVALID_ASSOC)189280 return;190190- assoc = assocs[l3.assoc];191191- line_size = l3.line_size;192192- lines_per_tag = l3.lines_per_tag;193193- size_in_kb = l3.size_encoded * 512;281281+282282+ assoc = assocs[l3.assoc];283283+ line_size = l3.line_size;284284+ lines_per_tag = l3.lines_per_tag;285285+ size_in_kb = l3.size_encoded * 512;194286 if (boot_cpu_has(X86_FEATURE_AMD_DCM)) {195195- size_in_kb = size_in_kb >> 1;196196- assoc = assoc >> 1;287287+ size_in_kb = size_in_kb >> 1;288288+ assoc = assoc >> 1;197289 }198290 break;199291 default:200292 return;201293 }202294203203- eax->split.is_self_initializing = 1;204204- eax->split.type = types[leaf];205205- eax->split.level = levels[leaf];206206- eax->split.num_threads_sharing = 0;207207- eax->split.num_cores_on_die = topology_num_cores_per_package();295295+ eax->split.is_self_initializing = 1;296296+ eax->split.type = types[index];297297+ eax->split.level = levels[index];298298+ eax->split.num_threads_sharing = 0;299299+ eax->split.num_cores_on_die = topology_num_cores_per_package();208300209209-210210- if (assoc == 0xffff)301301+ if (assoc == AMD_CPUID4_FULLY_ASSOCIATIVE)211302 eax->split.is_fully_associative = 1;212212- ebx->split.coherency_line_size = line_size - 1;213213- ebx->split.ways_of_associativity = assoc - 1;214214- ebx->split.physical_line_partition = lines_per_tag - 1;215215- ecx->split.number_of_sets = (size_in_kb * 1024) / line_size /303303+304304+ ebx->split.coherency_line_size = line_size - 1;305305+ ebx->split.ways_of_associativity = assoc - 1;306306+ ebx->split.physical_line_partition = lines_per_tag - 1;307307+ ecx->split.number_of_sets = (size_in_kb * 1024) / line_size /216308 (ebx->split.ways_of_associativity + 1) - 1;217309}218310219219-#if defined(CONFIG_AMD_NB) && defined(CONFIG_SYSFS)220220-221221-/*222222- * L3 cache descriptors223223- */224224-static void amd_calc_l3_indices(struct amd_northbridge *nb)311311+static int cpuid4_info_fill_done(struct _cpuid4_info *id4, union _cpuid4_leaf_eax eax,312312+ union _cpuid4_leaf_ebx ebx, union _cpuid4_leaf_ecx ecx)225313{226226- struct amd_l3_cache *l3 = &nb->l3_cache;227227- unsigned int sc0, sc1, sc2, sc3;228228- u32 val = 0;229229-230230- pci_read_config_dword(nb->misc, 0x1C4, &val);231231-232232- /* calculate subcache sizes */233233- l3->subcaches[0] = sc0 = !(val & BIT(0));234234- l3->subcaches[1] = sc1 = !(val & BIT(4));235235-236236- if (boot_cpu_data.x86 == 0x15) {237237- l3->subcaches[0] = sc0 += !(val & BIT(1));238238- l3->subcaches[1] = sc1 += !(val & BIT(5));239239- }240240-241241- l3->subcaches[2] = sc2 = !(val & BIT(8)) + !(val & BIT(9));242242- l3->subcaches[3] = sc3 = !(val & BIT(12)) + !(val & BIT(13));243243-244244- l3->indices = (max(max3(sc0, sc1, sc2), sc3) << 10) - 1;245245-}246246-247247-/*248248- * check whether a slot used for disabling an L3 index is occupied.249249- * @l3: L3 cache descriptor250250- * @slot: slot number (0..1)251251- *252252- * @returns: the disabled index if used or negative value if slot free.253253- */254254-static int amd_get_l3_disable_slot(struct amd_northbridge *nb, unsigned slot)255255-{256256- unsigned int reg = 0;257257-258258- pci_read_config_dword(nb->misc, 0x1BC + slot * 4, ®);259259-260260- /* check whether this slot is activated already */261261- if (reg & (3UL << 30))262262- return reg & 0xfff;263263-264264- return -1;265265-}266266-267267-static ssize_t show_cache_disable(struct cacheinfo *this_leaf, char *buf,268268- unsigned int slot)269269-{270270- int index;271271- struct amd_northbridge *nb = this_leaf->priv;272272-273273- index = amd_get_l3_disable_slot(nb, slot);274274- if (index >= 0)275275- return sprintf(buf, "%d\n", index);276276-277277- return sprintf(buf, "FREE\n");278278-}279279-280280-#define SHOW_CACHE_DISABLE(slot) \281281-static ssize_t \282282-cache_disable_##slot##_show(struct device *dev, \283283- struct device_attribute *attr, char *buf) \284284-{ \285285- struct cacheinfo *this_leaf = dev_get_drvdata(dev); \286286- return show_cache_disable(this_leaf, buf, slot); \287287-}288288-SHOW_CACHE_DISABLE(0)289289-SHOW_CACHE_DISABLE(1)290290-291291-static void amd_l3_disable_index(struct amd_northbridge *nb, int cpu,292292- unsigned slot, unsigned long idx)293293-{294294- int i;295295-296296- idx |= BIT(30);297297-298298- /*299299- * disable index in all 4 subcaches300300- */301301- for (i = 0; i < 4; i++) {302302- u32 reg = idx | (i << 20);303303-304304- if (!nb->l3_cache.subcaches[i])305305- continue;306306-307307- pci_write_config_dword(nb->misc, 0x1BC + slot * 4, reg);308308-309309- /*310310- * We need to WBINVD on a core on the node containing the L3311311- * cache which indices we disable therefore a simple wbinvd()312312- * is not sufficient.313313- */314314- wbinvd_on_cpu(cpu);315315-316316- reg |= BIT(31);317317- pci_write_config_dword(nb->misc, 0x1BC + slot * 4, reg);318318- }319319-}320320-321321-/*322322- * disable a L3 cache index by using a disable-slot323323- *324324- * @l3: L3 cache descriptor325325- * @cpu: A CPU on the node containing the L3 cache326326- * @slot: slot number (0..1)327327- * @index: index to disable328328- *329329- * @return: 0 on success, error status on failure330330- */331331-static int amd_set_l3_disable_slot(struct amd_northbridge *nb, int cpu,332332- unsigned slot, unsigned long index)333333-{334334- int ret = 0;335335-336336- /* check if @slot is already used or the index is already disabled */337337- ret = amd_get_l3_disable_slot(nb, slot);338338- if (ret >= 0)339339- return -EEXIST;340340-341341- if (index > nb->l3_cache.indices)342342- return -EINVAL;343343-344344- /* check whether the other slot has disabled the same index already */345345- if (index == amd_get_l3_disable_slot(nb, !slot))346346- return -EEXIST;347347-348348- amd_l3_disable_index(nb, cpu, slot, index);349349-350350- return 0;351351-}352352-353353-static ssize_t store_cache_disable(struct cacheinfo *this_leaf,354354- const char *buf, size_t count,355355- unsigned int slot)356356-{357357- unsigned long val = 0;358358- int cpu, err = 0;359359- struct amd_northbridge *nb = this_leaf->priv;360360-361361- if (!capable(CAP_SYS_ADMIN))362362- return -EPERM;363363-364364- cpu = cpumask_first(&this_leaf->shared_cpu_map);365365-366366- if (kstrtoul(buf, 10, &val) < 0)367367- return -EINVAL;368368-369369- err = amd_set_l3_disable_slot(nb, cpu, slot, val);370370- if (err) {371371- if (err == -EEXIST)372372- pr_warn("L3 slot %d in use/index already disabled!\n",373373- slot);374374- return err;375375- }376376- return count;377377-}378378-379379-#define STORE_CACHE_DISABLE(slot) \380380-static ssize_t \381381-cache_disable_##slot##_store(struct device *dev, \382382- struct device_attribute *attr, \383383- const char *buf, size_t count) \384384-{ \385385- struct cacheinfo *this_leaf = dev_get_drvdata(dev); \386386- return store_cache_disable(this_leaf, buf, count, slot); \387387-}388388-STORE_CACHE_DISABLE(0)389389-STORE_CACHE_DISABLE(1)390390-391391-static ssize_t subcaches_show(struct device *dev,392392- struct device_attribute *attr, char *buf)393393-{394394- struct cacheinfo *this_leaf = dev_get_drvdata(dev);395395- int cpu = cpumask_first(&this_leaf->shared_cpu_map);396396-397397- return sprintf(buf, "%x\n", amd_get_subcaches(cpu));398398-}399399-400400-static ssize_t subcaches_store(struct device *dev,401401- struct device_attribute *attr,402402- const char *buf, size_t count)403403-{404404- struct cacheinfo *this_leaf = dev_get_drvdata(dev);405405- int cpu = cpumask_first(&this_leaf->shared_cpu_map);406406- unsigned long val;407407-408408- if (!capable(CAP_SYS_ADMIN))409409- return -EPERM;410410-411411- if (kstrtoul(buf, 16, &val) < 0)412412- return -EINVAL;413413-414414- if (amd_set_subcaches(cpu, val))415415- return -EINVAL;416416-417417- return count;418418-}419419-420420-static DEVICE_ATTR_RW(cache_disable_0);421421-static DEVICE_ATTR_RW(cache_disable_1);422422-static DEVICE_ATTR_RW(subcaches);423423-424424-static umode_t425425-cache_private_attrs_is_visible(struct kobject *kobj,426426- struct attribute *attr, int unused)427427-{428428- struct device *dev = kobj_to_dev(kobj);429429- struct cacheinfo *this_leaf = dev_get_drvdata(dev);430430- umode_t mode = attr->mode;431431-432432- if (!this_leaf->priv)433433- return 0;434434-435435- if ((attr == &dev_attr_subcaches.attr) &&436436- amd_nb_has_feature(AMD_NB_L3_PARTITIONING))437437- return mode;438438-439439- if ((attr == &dev_attr_cache_disable_0.attr ||440440- attr == &dev_attr_cache_disable_1.attr) &&441441- amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE))442442- return mode;443443-444444- return 0;445445-}446446-447447-static struct attribute_group cache_private_group = {448448- .is_visible = cache_private_attrs_is_visible,449449-};450450-451451-static void init_amd_l3_attrs(void)452452-{453453- int n = 1;454454- static struct attribute **amd_l3_attrs;455455-456456- if (amd_l3_attrs) /* already initialized */457457- return;458458-459459- if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE))460460- n += 2;461461- if (amd_nb_has_feature(AMD_NB_L3_PARTITIONING))462462- n += 1;463463-464464- amd_l3_attrs = kcalloc(n, sizeof(*amd_l3_attrs), GFP_KERNEL);465465- if (!amd_l3_attrs)466466- return;467467-468468- n = 0;469469- if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE)) {470470- amd_l3_attrs[n++] = &dev_attr_cache_disable_0.attr;471471- amd_l3_attrs[n++] = &dev_attr_cache_disable_1.attr;472472- }473473- if (amd_nb_has_feature(AMD_NB_L3_PARTITIONING))474474- amd_l3_attrs[n++] = &dev_attr_subcaches.attr;475475-476476- cache_private_group.attrs = amd_l3_attrs;477477-}478478-479479-const struct attribute_group *480480-cache_get_priv_group(struct cacheinfo *this_leaf)481481-{482482- struct amd_northbridge *nb = this_leaf->priv;483483-484484- if (this_leaf->level < 3 || !nb)485485- return NULL;486486-487487- if (nb && nb->l3_cache.indices)488488- init_amd_l3_attrs();489489-490490- return &cache_private_group;491491-}492492-493493-static void amd_init_l3_cache(struct _cpuid4_info_regs *this_leaf, int index)494494-{495495- int node;496496-497497- /* only for L3, and not in virtualized environments */498498- if (index < 3)499499- return;500500-501501- node = topology_amd_node_id(smp_processor_id());502502- this_leaf->nb = node_to_amd_nb(node);503503- if (this_leaf->nb && !this_leaf->nb->l3_cache.indices)504504- amd_calc_l3_indices(this_leaf->nb);505505-}506506-#else507507-#define amd_init_l3_cache(x, y)508508-#endif /* CONFIG_AMD_NB && CONFIG_SYSFS */509509-510510-static int511511-cpuid4_cache_lookup_regs(int index, struct _cpuid4_info_regs *this_leaf)512512-{513513- union _cpuid4_leaf_eax eax;514514- union _cpuid4_leaf_ebx ebx;515515- union _cpuid4_leaf_ecx ecx;516516- unsigned edx;517517-518518- if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD) {519519- if (boot_cpu_has(X86_FEATURE_TOPOEXT))520520- cpuid_count(0x8000001d, index, &eax.full,521521- &ebx.full, &ecx.full, &edx);522522- else523523- amd_cpuid4(index, &eax, &ebx, &ecx);524524- amd_init_l3_cache(this_leaf, index);525525- } else if (boot_cpu_data.x86_vendor == X86_VENDOR_HYGON) {526526- cpuid_count(0x8000001d, index, &eax.full,527527- &ebx.full, &ecx.full, &edx);528528- amd_init_l3_cache(this_leaf, index);529529- } else {530530- cpuid_count(4, index, &eax.full, &ebx.full, &ecx.full, &edx);531531- }532532-533314 if (eax.split.type == CTYPE_NULL)534534- return -EIO; /* better error ? */315315+ return -EIO;535316536536- this_leaf->eax = eax;537537- this_leaf->ebx = ebx;538538- this_leaf->ecx = ecx;539539- this_leaf->size = (ecx.split.number_of_sets + 1) *540540- (ebx.split.coherency_line_size + 1) *541541- (ebx.split.physical_line_partition + 1) *542542- (ebx.split.ways_of_associativity + 1);317317+ id4->eax = eax;318318+ id4->ebx = ebx;319319+ id4->ecx = ecx;320320+ id4->size = (ecx.split.number_of_sets + 1) *321321+ (ebx.split.coherency_line_size + 1) *322322+ (ebx.split.physical_line_partition + 1) *323323+ (ebx.split.ways_of_associativity + 1);324324+543325 return 0;326326+}327327+328328+static int amd_fill_cpuid4_info(int index, struct _cpuid4_info *id4)329329+{330330+ union _cpuid4_leaf_eax eax;331331+ union _cpuid4_leaf_ebx ebx;332332+ union _cpuid4_leaf_ecx ecx;333333+ u32 ignored;334334+335335+ if (boot_cpu_has(X86_FEATURE_TOPOEXT) || boot_cpu_data.x86_vendor == X86_VENDOR_HYGON)336336+ cpuid_count(0x8000001d, index, &eax.full, &ebx.full, &ecx.full, &ignored);337337+ else338338+ legacy_amd_cpuid4(index, &eax, &ebx, &ecx);339339+340340+ return cpuid4_info_fill_done(id4, eax, ebx, ecx);341341+}342342+343343+static int intel_fill_cpuid4_info(int index, struct _cpuid4_info *id4)344344+{345345+ union _cpuid4_leaf_eax eax;346346+ union _cpuid4_leaf_ebx ebx;347347+ union _cpuid4_leaf_ecx ecx;348348+ u32 ignored;349349+350350+ cpuid_count(4, index, &eax.full, &ebx.full, &ecx.full, &ignored);351351+352352+ return cpuid4_info_fill_done(id4, eax, ebx, ecx);353353+}354354+355355+static int fill_cpuid4_info(int index, struct _cpuid4_info *id4)356356+{357357+ u8 cpu_vendor = boot_cpu_data.x86_vendor;358358+359359+ return (cpu_vendor == X86_VENDOR_AMD || cpu_vendor == X86_VENDOR_HYGON) ?360360+ amd_fill_cpuid4_info(index, id4) :361361+ intel_fill_cpuid4_info(index, id4);544362}545363546364static int find_num_cache_leaves(struct cpuinfo_x86 *c)547365{548548- unsigned int eax, ebx, ecx, edx, op;549549- union _cpuid4_leaf_eax cache_eax;550550- int i = -1;366366+ unsigned int eax, ebx, ecx, edx, op;367367+ union _cpuid4_leaf_eax cache_eax;368368+ int i = -1;551369552552- if (c->x86_vendor == X86_VENDOR_AMD ||553553- c->x86_vendor == X86_VENDOR_HYGON)554554- op = 0x8000001d;555555- else556556- op = 4;557557-370370+ /* Do a CPUID(op) loop to calculate num_cache_leaves */371371+ op = (c->x86_vendor == X86_VENDOR_AMD || c->x86_vendor == X86_VENDOR_HYGON) ? 0x8000001d : 4;558372 do {559373 ++i;560560- /* Do cpuid(op) loop to find out num_cache_leaves */561374 cpuid_count(op, i, &eax, &ebx, &ecx, &edx);562375 cache_eax.full = eax;563376 } while (cache_eax.split.type != CTYPE_NULL);564377 return i;565378}566379380380+/*381381+ * AMD/Hygon CPUs may have multiple LLCs if L3 caches exist.382382+ */383383+567384void cacheinfo_amd_init_llc_id(struct cpuinfo_x86 *c, u16 die_id)568385{569569- /*570570- * We may have multiple LLCs if L3 caches exist, so check if we571571- * have an L3 cache by looking at the L3 cache CPUID leaf.572572- */573573- if (!cpuid_edx(0x80000006))386386+ if (!cpuid_amd_hygon_has_l3_cache())574387 return;575388576389 if (c->x86 < 0x17) {577577- /* LLC is at the node level. */390390+ /* Pre-Zen: LLC is at the node level */578391 c->topo.llc_id = die_id;579392 } else if (c->x86 == 0x17 && c->x86_model <= 0x1F) {580393 /*581581- * LLC is at the core complex level.582582- * Core complex ID is ApicId[3] for these processors.394394+ * Family 17h up to 1F models: LLC is at the core395395+ * complex level. Core complex ID is ApicId[3].583396 */584397 c->topo.llc_id = c->topo.apicid >> 3;585398 } else {586399 /*587587- * LLC ID is calculated from the number of threads sharing the588588- * cache.589589- * */400400+ * Newer families: LLC ID is calculated from the number401401+ * of threads sharing the L3 cache.402402+ */590403 u32 eax, ebx, ecx, edx, num_sharing_cache = 0;591404 u32 llc_index = find_num_cache_leaves(c) - 1;592405···320683 num_sharing_cache = ((eax >> 14) & 0xfff) + 1;321684322685 if (num_sharing_cache) {323323- int bits = get_count_order(num_sharing_cache);686686+ int index_msb = get_count_order(num_sharing_cache);324687325325- c->topo.llc_id = c->topo.apicid >> bits;688688+ c->topo.llc_id = c->topo.apicid >> index_msb;326689 }327690 }328691}329692330693void cacheinfo_hygon_init_llc_id(struct cpuinfo_x86 *c)331694{332332- /*333333- * We may have multiple LLCs if L3 caches exist, so check if we334334- * have an L3 cache by looking at the L3 cache CPUID leaf.335335- */336336- if (!cpuid_edx(0x80000006))695695+ if (!cpuid_amd_hygon_has_l3_cache())337696 return;338697339698 /*340340- * LLC is at the core complex level.341341- * Core complex ID is ApicId[3] for these processors.699699+ * Hygons are similar to AMD Family 17h up to 1F models: LLC is700700+ * at the core complex level. Core complex ID is ApicId[3].342701 */343702 c->topo.llc_id = c->topo.apicid >> 3;344703}···343710{344711 struct cpu_cacheinfo *ci = get_cpu_cacheinfo(c->cpu_index);345712346346- if (boot_cpu_has(X86_FEATURE_TOPOEXT)) {713713+ if (boot_cpu_has(X86_FEATURE_TOPOEXT))347714 ci->num_leaves = find_num_cache_leaves(c);348348- } else if (c->extended_cpuid_level >= 0x80000006) {349349- if (cpuid_edx(0x80000006) & 0xf000)350350- ci->num_leaves = 4;351351- else352352- ci->num_leaves = 3;353353- }715715+ else if (c->extended_cpuid_level >= 0x80000006)716716+ ci->num_leaves = (cpuid_edx(0x80000006) & 0xf000) ? 4 : 3;354717}355718356719void init_hygon_cacheinfo(struct cpuinfo_x86 *c)···356727 ci->num_leaves = find_num_cache_leaves(c);357728}358729359359-void init_intel_cacheinfo(struct cpuinfo_x86 *c)730730+static void intel_cacheinfo_done(struct cpuinfo_x86 *c, unsigned int l3,731731+ unsigned int l2, unsigned int l1i, unsigned int l1d)360732{361361- /* Cache sizes */362362- unsigned int l1i = 0, l1d = 0, l2 = 0, l3 = 0;363363- unsigned int new_l1d = 0, new_l1i = 0; /* Cache sizes from cpuid(4) */364364- unsigned int new_l2 = 0, new_l3 = 0, i; /* Cache sizes from cpuid(4) */365365- unsigned int l2_id = 0, l3_id = 0, num_threads_sharing, index_msb;366366- struct cpu_cacheinfo *ci = get_cpu_cacheinfo(c->cpu_index);367367-368368- if (c->cpuid_level > 3) {369369- /*370370- * There should be at least one leaf. A non-zero value means371371- * that the number of leaves has been initialized.372372- */373373- if (!ci->num_leaves)374374- ci->num_leaves = find_num_cache_leaves(c);375375-376376- /*377377- * Whenever possible use cpuid(4), deterministic cache378378- * parameters cpuid leaf to find the cache details379379- */380380- for (i = 0; i < ci->num_leaves; i++) {381381- struct _cpuid4_info_regs this_leaf = {};382382- int retval;383383-384384- retval = cpuid4_cache_lookup_regs(i, &this_leaf);385385- if (retval < 0)386386- continue;387387-388388- switch (this_leaf.eax.split.level) {389389- case 1:390390- if (this_leaf.eax.split.type == CTYPE_DATA)391391- new_l1d = this_leaf.size/1024;392392- else if (this_leaf.eax.split.type == CTYPE_INST)393393- new_l1i = this_leaf.size/1024;394394- break;395395- case 2:396396- new_l2 = this_leaf.size/1024;397397- num_threads_sharing = 1 + this_leaf.eax.split.num_threads_sharing;398398- index_msb = get_count_order(num_threads_sharing);399399- l2_id = c->topo.apicid & ~((1 << index_msb) - 1);400400- break;401401- case 3:402402- new_l3 = this_leaf.size/1024;403403- num_threads_sharing = 1 + this_leaf.eax.split.num_threads_sharing;404404- index_msb = get_count_order(num_threads_sharing);405405- l3_id = c->topo.apicid & ~((1 << index_msb) - 1);406406- break;407407- default:408408- break;409409- }410410- }411411- }412412-413413- /* Don't use CPUID(2) if CPUID(4) is supported. */414414- if (!ci->num_leaves && c->cpuid_level > 1) {415415- /* supports eax=2 call */416416- int j, n;417417- unsigned int regs[4];418418- unsigned char *dp = (unsigned char *)regs;419419-420420- /* Number of times to iterate */421421- n = cpuid_eax(2) & 0xFF;422422-423423- for (i = 0 ; i < n ; i++) {424424- cpuid(2, ®s[0], ®s[1], ®s[2], ®s[3]);425425-426426- /* If bit 31 is set, this is an unknown format */427427- for (j = 0 ; j < 4 ; j++)428428- if (regs[j] & (1 << 31))429429- regs[j] = 0;430430-431431- /* Byte 0 is level count, not a descriptor */432432- for (j = 1 ; j < 16 ; j++) {433433- unsigned char des = dp[j];434434- unsigned char k = 0;435435-436436- /* look up this descriptor in the table */437437- while (cache_table[k].descriptor != 0) {438438- if (cache_table[k].descriptor == des) {439439- switch (cache_table[k].cache_type) {440440- case LVL_1_INST:441441- l1i += cache_table[k].size;442442- break;443443- case LVL_1_DATA:444444- l1d += cache_table[k].size;445445- break;446446- case LVL_2:447447- l2 += cache_table[k].size;448448- break;449449- case LVL_3:450450- l3 += cache_table[k].size;451451- break;452452- }453453-454454- break;455455- }456456-457457- k++;458458- }459459- }460460- }461461- }462462-463463- if (new_l1d)464464- l1d = new_l1d;465465-466466- if (new_l1i)467467- l1i = new_l1i;468468-469469- if (new_l2) {470470- l2 = new_l2;471471- c->topo.llc_id = l2_id;472472- c->topo.l2c_id = l2_id;473473- }474474-475475- if (new_l3) {476476- l3 = new_l3;477477- c->topo.llc_id = l3_id;478478- }479479-480733 /*481481- * If llc_id is not yet set, this means cpuid_level < 4 which in482482- * turns means that the only possibility is SMT (as indicated in483483- * cpuid1). Since cpuid2 doesn't specify shared caches, and we know484484- * that SMT shares all caches, we can unconditionally set cpu_llc_id to485485- * c->topo.pkg_id.734734+ * If llc_id is still unset, then cpuid_level < 4, which implies735735+ * that the only possibility left is SMT. Since CPUID(0x2) doesn't736736+ * specify any shared caches and SMT shares all caches, we can737737+ * unconditionally set LLC ID to the package ID so that all738738+ * threads share it.486739 */487740 if (c->topo.llc_id == BAD_APICID)488741 c->topo.llc_id = c->topo.pkg_id;489742490490- c->x86_cache_size = l3 ? l3 : (l2 ? l2 : (l1i+l1d));743743+ c->x86_cache_size = l3 ? l3 : (l2 ? l2 : l1i + l1d);491744492745 if (!l2)493746 cpu_detect_cache_sizes(c);494747}495748749749+/*750750+ * Legacy Intel CPUID(0x2) path if CPUID(0x4) is not available.751751+ */752752+static void intel_cacheinfo_0x2(struct cpuinfo_x86 *c)753753+{754754+ unsigned int l1i = 0, l1d = 0, l2 = 0, l3 = 0;755755+ const struct leaf_0x2_table *entry;756756+ union leaf_0x2_regs regs;757757+ u8 *ptr;758758+759759+ if (c->cpuid_level < 2)760760+ return;761761+762762+ cpuid_get_leaf_0x2_regs(®s);763763+ for_each_leaf_0x2_entry(regs, ptr, entry) {764764+ switch (entry->c_type) {765765+ case CACHE_L1_INST: l1i += entry->c_size; break;766766+ case CACHE_L1_DATA: l1d += entry->c_size; break;767767+ case CACHE_L2: l2 += entry->c_size; break;768768+ case CACHE_L3: l3 += entry->c_size; break;769769+ }770770+ }771771+772772+ intel_cacheinfo_done(c, l3, l2, l1i, l1d);773773+}774774+775775+static unsigned int calc_cache_topo_id(struct cpuinfo_x86 *c, const struct _cpuid4_info *id4)776776+{777777+ unsigned int num_threads_sharing;778778+ int index_msb;779779+780780+ num_threads_sharing = 1 + id4->eax.split.num_threads_sharing;781781+ index_msb = get_count_order(num_threads_sharing);782782+ return c->topo.apicid & ~((1 << index_msb) - 1);783783+}784784+785785+static bool intel_cacheinfo_0x4(struct cpuinfo_x86 *c)786786+{787787+ struct cpu_cacheinfo *ci = get_cpu_cacheinfo(c->cpu_index);788788+ unsigned int l2_id = BAD_APICID, l3_id = BAD_APICID;789789+ unsigned int l1d = 0, l1i = 0, l2 = 0, l3 = 0;790790+791791+ if (c->cpuid_level < 4)792792+ return false;793793+794794+ /*795795+ * There should be at least one leaf. A non-zero value means796796+ * that the number of leaves has been previously initialized.797797+ */798798+ if (!ci->num_leaves)799799+ ci->num_leaves = find_num_cache_leaves(c);800800+801801+ if (!ci->num_leaves)802802+ return false;803803+804804+ for (int i = 0; i < ci->num_leaves; i++) {805805+ struct _cpuid4_info id4 = {};806806+ int ret;807807+808808+ ret = intel_fill_cpuid4_info(i, &id4);809809+ if (ret < 0)810810+ continue;811811+812812+ switch (id4.eax.split.level) {813813+ case 1:814814+ if (id4.eax.split.type == CTYPE_DATA)815815+ l1d = id4.size / 1024;816816+ else if (id4.eax.split.type == CTYPE_INST)817817+ l1i = id4.size / 1024;818818+ break;819819+ case 2:820820+ l2 = id4.size / 1024;821821+ l2_id = calc_cache_topo_id(c, &id4);822822+ break;823823+ case 3:824824+ l3 = id4.size / 1024;825825+ l3_id = calc_cache_topo_id(c, &id4);826826+ break;827827+ default:828828+ break;829829+ }830830+ }831831+832832+ c->topo.l2c_id = l2_id;833833+ c->topo.llc_id = (l3_id == BAD_APICID) ? l2_id : l3_id;834834+ intel_cacheinfo_done(c, l3, l2, l1i, l1d);835835+ return true;836836+}837837+838838+void init_intel_cacheinfo(struct cpuinfo_x86 *c)839839+{840840+ /* Don't use CPUID(0x2) if CPUID(0x4) is supported. */841841+ if (intel_cacheinfo_0x4(c))842842+ return;843843+844844+ intel_cacheinfo_0x2(c);845845+}846846+847847+/*848848+ * <linux/cacheinfo.h> shared_cpu_map setup, AMD/Hygon849849+ */496850static int __cache_amd_cpumap_setup(unsigned int cpu, int index,497497- struct _cpuid4_info_regs *base)851851+ const struct _cpuid4_info *id4)498852{499853 struct cpu_cacheinfo *this_cpu_ci;500500- struct cacheinfo *this_leaf;854854+ struct cacheinfo *ci;501855 int i, sibling;502856503857 /*···492880 this_cpu_ci = get_cpu_cacheinfo(i);493881 if (!this_cpu_ci->info_list)494882 continue;495495- this_leaf = this_cpu_ci->info_list + index;883883+884884+ ci = this_cpu_ci->info_list + index;496885 for_each_cpu(sibling, cpu_llc_shared_mask(cpu)) {497886 if (!cpu_online(sibling))498887 continue;499499- cpumask_set_cpu(sibling,500500- &this_leaf->shared_cpu_map);888888+ cpumask_set_cpu(sibling, &ci->shared_cpu_map);501889 }502890 }503891 } else if (boot_cpu_has(X86_FEATURE_TOPOEXT)) {504892 unsigned int apicid, nshared, first, last;505893506506- nshared = base->eax.split.num_threads_sharing + 1;894894+ nshared = id4->eax.split.num_threads_sharing + 1;507895 apicid = cpu_data(cpu).topo.apicid;508896 first = apicid - (apicid % nshared);509897 last = first + nshared - 1;···517905 if ((apicid < first) || (apicid > last))518906 continue;519907520520- this_leaf = this_cpu_ci->info_list + index;908908+ ci = this_cpu_ci->info_list + index;521909522910 for_each_online_cpu(sibling) {523911 apicid = cpu_data(sibling).topo.apicid;524912 if ((apicid < first) || (apicid > last))525913 continue;526526- cpumask_set_cpu(sibling,527527- &this_leaf->shared_cpu_map);914914+ cpumask_set_cpu(sibling, &ci->shared_cpu_map);528915 }529916 }530917 } else···532921 return 1;533922}534923924924+/*925925+ * <linux/cacheinfo.h> shared_cpu_map setup, Intel + fallback AMD/Hygon926926+ */535927static void __cache_cpumap_setup(unsigned int cpu, int index,536536- struct _cpuid4_info_regs *base)928928+ const struct _cpuid4_info *id4)537929{538930 struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(cpu);539539- struct cacheinfo *this_leaf, *sibling_leaf;931931+ struct cpuinfo_x86 *c = &cpu_data(cpu);932932+ struct cacheinfo *ci, *sibling_ci;540933 unsigned long num_threads_sharing;541934 int index_msb, i;542542- struct cpuinfo_x86 *c = &cpu_data(cpu);543935544544- if (c->x86_vendor == X86_VENDOR_AMD ||545545- c->x86_vendor == X86_VENDOR_HYGON) {546546- if (__cache_amd_cpumap_setup(cpu, index, base))936936+ if (c->x86_vendor == X86_VENDOR_AMD || c->x86_vendor == X86_VENDOR_HYGON) {937937+ if (__cache_amd_cpumap_setup(cpu, index, id4))547938 return;548939 }549940550550- this_leaf = this_cpu_ci->info_list + index;551551- num_threads_sharing = 1 + base->eax.split.num_threads_sharing;941941+ ci = this_cpu_ci->info_list + index;942942+ num_threads_sharing = 1 + id4->eax.split.num_threads_sharing;552943553553- cpumask_set_cpu(cpu, &this_leaf->shared_cpu_map);944944+ cpumask_set_cpu(cpu, &ci->shared_cpu_map);554945 if (num_threads_sharing == 1)555946 return;556947···562949 if (cpu_data(i).topo.apicid >> index_msb == c->topo.apicid >> index_msb) {563950 struct cpu_cacheinfo *sib_cpu_ci = get_cpu_cacheinfo(i);564951952952+ /* Skip if itself or no cacheinfo */565953 if (i == cpu || !sib_cpu_ci->info_list)566566- continue;/* skip if itself or no cacheinfo */567567- sibling_leaf = sib_cpu_ci->info_list + index;568568- cpumask_set_cpu(i, &this_leaf->shared_cpu_map);569569- cpumask_set_cpu(cpu, &sibling_leaf->shared_cpu_map);954954+ continue;955955+956956+ sibling_ci = sib_cpu_ci->info_list + index;957957+ cpumask_set_cpu(i, &ci->shared_cpu_map);958958+ cpumask_set_cpu(cpu, &sibling_ci->shared_cpu_map);570959 }571960}572961573573-static void ci_leaf_init(struct cacheinfo *this_leaf,574574- struct _cpuid4_info_regs *base)962962+static void ci_info_init(struct cacheinfo *ci, const struct _cpuid4_info *id4,963963+ struct amd_northbridge *nb)575964{576576- this_leaf->id = base->id;577577- this_leaf->attributes = CACHE_ID;578578- this_leaf->level = base->eax.split.level;579579- this_leaf->type = cache_type_map[base->eax.split.type];580580- this_leaf->coherency_line_size =581581- base->ebx.split.coherency_line_size + 1;582582- this_leaf->ways_of_associativity =583583- base->ebx.split.ways_of_associativity + 1;584584- this_leaf->size = base->size;585585- this_leaf->number_of_sets = base->ecx.split.number_of_sets + 1;586586- this_leaf->physical_line_partition =587587- base->ebx.split.physical_line_partition + 1;588588- this_leaf->priv = base->nb;965965+ ci->id = id4->id;966966+ ci->attributes = CACHE_ID;967967+ ci->level = id4->eax.split.level;968968+ ci->type = cache_type_map[id4->eax.split.type];969969+ ci->coherency_line_size = id4->ebx.split.coherency_line_size + 1;970970+ ci->ways_of_associativity = id4->ebx.split.ways_of_associativity + 1;971971+ ci->size = id4->size;972972+ ci->number_of_sets = id4->ecx.split.number_of_sets + 1;973973+ ci->physical_line_partition = id4->ebx.split.physical_line_partition + 1;974974+ ci->priv = nb;589975}590976591977int init_cache_level(unsigned int cpu)···599987}600988601989/*602602- * The max shared threads number comes from CPUID.4:EAX[25-14] with input990990+ * The max shared threads number comes from CPUID(0x4) EAX[25-14] with input603991 * ECX as cache index. Then right shift apicid by the number's order to get604992 * cache id for this cache node.605993 */606606-static void get_cache_id(int cpu, struct _cpuid4_info_regs *id4_regs)994994+static void get_cache_id(int cpu, struct _cpuid4_info *id4)607995{608996 struct cpuinfo_x86 *c = &cpu_data(cpu);609997 unsigned long num_threads_sharing;610998 int index_msb;611999612612- num_threads_sharing = 1 + id4_regs->eax.split.num_threads_sharing;10001000+ num_threads_sharing = 1 + id4->eax.split.num_threads_sharing;6131001 index_msb = get_count_order(num_threads_sharing);614614- id4_regs->id = c->topo.apicid >> index_msb;10021002+ id4->id = c->topo.apicid >> index_msb;6151003}61610046171005int populate_cache_leaves(unsigned int cpu)6181006{619619- unsigned int idx, ret;6201007 struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(cpu);621621- struct cacheinfo *this_leaf = this_cpu_ci->info_list;622622- struct _cpuid4_info_regs id4_regs = {};10081008+ struct cacheinfo *ci = this_cpu_ci->info_list;10091009+ u8 cpu_vendor = boot_cpu_data.x86_vendor;10101010+ struct amd_northbridge *nb = NULL;10111011+ struct _cpuid4_info id4 = {};10121012+ int idx, ret;62310136241014 for (idx = 0; idx < this_cpu_ci->num_leaves; idx++) {625625- ret = cpuid4_cache_lookup_regs(idx, &id4_regs);10151015+ ret = fill_cpuid4_info(idx, &id4);6261016 if (ret)6271017 return ret;628628- get_cache_id(cpu, &id4_regs);629629- ci_leaf_init(this_leaf++, &id4_regs);630630- __cache_cpumap_setup(cpu, idx, &id4_regs);631631- }632632- this_cpu_ci->cpu_map_populated = true;633101810191019+ get_cache_id(cpu, &id4);10201020+10211021+ if (cpu_vendor == X86_VENDOR_AMD || cpu_vendor == X86_VENDOR_HYGON)10221022+ nb = amd_init_l3_cache(idx);10231023+10241024+ ci_info_init(ci++, &id4, nb);10251025+ __cache_cpumap_setup(cpu, idx, &id4);10261026+ }10271027+10281028+ this_cpu_ci->cpu_map_populated = true;6341029 return 0;6351030}6361031···6531034static unsigned long saved_cr4;6541035static DEFINE_RAW_SPINLOCK(cache_disable_lock);655103610371037+/*10381038+ * Cache flushing is the most time-consuming step when programming the10391039+ * MTRRs. On many Intel CPUs without known erratas, it can be skipped10401040+ * if the CPU declares cache self-snooping support.10411041+ */10421042+static void maybe_flush_caches(void)10431043+{10441044+ if (!static_cpu_has(X86_FEATURE_SELFSNOOP))10451045+ wbinvd();10461046+}10471047+6561048void cache_disable(void) __acquires(cache_disable_lock)6571049{6581050 unsigned long cr0;65910516601052 /*661661- * Note that this is not ideal662662- * since the cache is only flushed/disabled for this CPU while the663663- * MTRRs are changed, but changing this requires more invasive664664- * changes to the way the kernel boots10531053+ * This is not ideal since the cache is only flushed/disabled10541054+ * for this CPU while the MTRRs are changed, but changing this10551055+ * requires more invasive changes to the way the kernel boots.6651056 */666666-6671057 raw_spin_lock(&cache_disable_lock);66810586691059 /* Enter the no-fill (CD=1, NW=0) cache mode and flush caches. */6701060 cr0 = read_cr0() | X86_CR0_CD;6711061 write_cr0(cr0);6721062673673- /*674674- * Cache flushing is the most time-consuming step when programming675675- * the MTRRs. Fortunately, as per the Intel Software Development676676- * Manual, we can skip it if the processor supports cache self-677677- * snooping.678678- */679679- if (!static_cpu_has(X86_FEATURE_SELFSNOOP))680680- wbinvd();10631063+ maybe_flush_caches();68110646821065 /* Save value of CR4 and clear Page Global Enable (bit 7) */6831066 if (cpu_feature_enabled(X86_FEATURE_PGE)) {···6941073 if (cpu_feature_enabled(X86_FEATURE_MTRR))6951074 mtrr_disable();6961075697697- /* Again, only flush caches if we have to. */698698- if (!static_cpu_has(X86_FEATURE_SELFSNOOP))699699- wbinvd();10761076+ maybe_flush_caches();7001077}70110787021079void cache_enable(void) __releases(cache_disable_lock)
-5
arch/x86/kernel/cpu/common.c
···14021402 * Affected CPU list is generally enough to enumerate the vulnerability,14031403 * but for virtualization case check for ARCH_CAP MSR bits also, VMM may14041404 * not want the guest to enumerate the bug.14051405- *14061406- * Set X86_BUG_MMIO_UNKNOWN for CPUs that are neither in the blacklist,14071407- * nor in the whitelist and also don't enumerate MSR ARCH_CAP MMIO bits.14081405 */14091406 if (!arch_cap_mmio_immune(x86_arch_cap_msr)) {14101407 if (cpu_matches(cpu_vuln_blacklist, MMIO))14111408 setup_force_cpu_bug(X86_BUG_MMIO_STALE_DATA);14121412- else if (!cpu_matches(cpu_vuln_whitelist, NO_MMIO))14131413- setup_force_cpu_bug(X86_BUG_MMIO_UNKNOWN);14141409 }1415141014161411 if (!cpu_has(c, X86_FEATURE_BTC_NO)) {
···182182 if (cpu_feature_enabled(X86_FEATURE_TOPOEXT))183183 has_topoext = cpu_parse_topology_ext(tscan);184184185185- if (cpu_feature_enabled(X86_FEATURE_AMD_HETEROGENEOUS_CORES))185185+ if (cpu_feature_enabled(X86_FEATURE_AMD_HTR_CORES))186186 tscan->c->topo.cpu_type = cpuid_ebx(0x80000026);187187188188 if (!has_topoext && !parse_8000_0008(tscan))
···2020#include <linux/module.h>2121#include <linux/pci.h>2222#include <linux/pci_ids.h>2323-#include <asm/amd_node.h>2323+#include <asm/amd/node.h>2424#include <asm/processor.h>25252626MODULE_DESCRIPTION("AMD Family 10h+ CPU core temperature monitor");
···323323 return err;324324 }325325326326- if (mr->umem->is_odp)326326+ if (is_odp_mr(mr))327327 return rxe_odp_mr_copy(mr, iova, addr, length, dir);328328 else329329 return rxe_mr_copy_xarray(mr, iova, addr, length, dir);···536536 u64 *va;537537538538 /* ODP is not supported right now. WIP. */539539- if (mr->umem->is_odp)539539+ if (is_odp_mr(mr))540540 return RESPST_ERR_UNSUPPORTED_OPCODE;541541542542 /* See IBA oA19-28 */
+2-2
drivers/infiniband/sw/rxe/rxe_resp.c
···650650 struct resp_res *res = qp->resp.res;651651652652 /* ODP is not supported right now. WIP. */653653- if (mr->umem->is_odp)653653+ if (is_odp_mr(mr))654654 return RESPST_ERR_UNSUPPORTED_OPCODE;655655656656 /* oA19-14, oA19-15 */···706706 if (!res->replay) {707707 u64 iova = qp->resp.va + qp->resp.offset;708708709709- if (mr->umem->is_odp)709709+ if (is_odp_mr(mr))710710 err = rxe_odp_atomic_op(mr, iova, pkt->opcode,711711 atmeth_comp(pkt),712712 atmeth_swap_add(pkt),
···229229 * Additionally, the PC and Bank bits may be hashed. This must be accounted for before230230 * reconstructing the normalized address.231231 */232232-#define MI300_UMC_MCA_COL GENMASK(5, 1)233232#define MI300_UMC_MCA_BANK GENMASK(9, 6)234233#define MI300_UMC_MCA_ROW GENMASK(24, 10)235234#define MI300_UMC_MCA_PC BIT(25)···319320 * See amd_atl::convert_dram_to_norm_addr_mi300() for MI300 address formats.320321 */321322#define MI300_NUM_COL BIT(HWEIGHT(MI300_UMC_MCA_COL))322322-static void retire_row_mi300(struct atl_err *a_err)323323+static void _retire_row_mi300(struct atl_err *a_err)323324{324325 unsigned long addr;325326 struct page *p;···348349349350 memory_failure(addr, 0);350351 }352352+}353353+354354+/*355355+ * In addition to the column bits, the row[13] bit should also be included when356356+ * calculating addresses affected by a physical row.357357+ *358358+ * Instead of running through another loop over a single bit, just run through359359+ * the column bits twice and flip the row[13] bit in-between.360360+ *361361+ * See MI300_UMC_MCA_ROW for the row bits in MCA_ADDR_UMC value.362362+ */363363+static void retire_row_mi300(struct atl_err *a_err)364364+{365365+ _retire_row_mi300(a_err);366366+ a_err->addr ^= MI300_UMC_MCA_ROW13;367367+ _retire_row_mi300(a_err);351368}352369353370void amd_retire_dram_row(struct atl_err *a_err)
+8-1
drivers/ras/amd/fmpm.c
···250250 return true;251251}252252253253+/*254254+ * Row retirement is done on MI300 systems, and some bits are 'don't255255+ * care' for comparing addresses with unique physical rows. This256256+ * includes all column bits and the row[13] bit.257257+ */258258+#define MASK_ADDR(addr) ((addr) & ~(MI300_UMC_MCA_ROW13 | MI300_UMC_MCA_COL))259259+253260static bool fpds_equal(struct cper_fru_poison_desc *old, struct cper_fru_poison_desc *new)254261{255262 /*···265258 *266259 * Also, order the checks from most->least likely to fail to shortcut the code.267260 */268268- if (old->addr != new->addr)261261+ if (MASK_ADDR(old->addr) != MASK_ADDR(new->addr))269262 return false;270263271264 if (old->hw_id != new->hw_id)
+2-2
fs/afs/dynroot.c
···348348 }349349350350 if ((unsigned long long)ctx->pos <= AFS_MAX_DYNROOT_CELL_INO) {351351- rcu_read_lock();351351+ down_read(&net->cells_lock);352352 ret = afs_dynroot_readdir_cells(net, ctx);353353- rcu_read_unlock();353353+ up_read(&net->cells_lock);354354 }355355 return ret;356356}
···16691669 unsigned int virtqueue_size;16701670 int err = -EIO;1671167116721672+ if (!fsc->source)16731673+ return invalf(fsc, "No source specified");16741674+16721675 /* This gets a reference on virtio_fs object. This ptr gets installed16731676 * in fc->iq->priv. Once fuse_conn is going away, it calls ->put()16741677 * to drop the reference to this object.
···259259 }260260261261 /* truncate len if we find any trailing uptodate block(s) */262262- for ( ; i <= last; i++) {262262+ while (++i <= last) {263263 if (ifs_block_is_uptodate(ifs, i)) {264264 plen -= (last - i + 1) * block_size;265265 last = i - 1;
···11381138 return ERR_PTR(-EINVAL);11391139 }1140114011411141+ if (ctx->nr == ctx->nr_data) {11421142+ pr_err("at least one non-data lowerdir is required\n");11431143+ return ERR_PTR(-EINVAL);11441144+ }11451145+11411146 err = -EINVAL;11421147 for (i = 0; i < ctx->nr; i++) {11431148 l = &ctx->lower[i];
+49-55
include/linux/dcache.h
···173173 */174174175175/* d_flags entries */176176-#define DCACHE_OP_HASH BIT(0)177177-#define DCACHE_OP_COMPARE BIT(1)178178-#define DCACHE_OP_REVALIDATE BIT(2)179179-#define DCACHE_OP_DELETE BIT(3)180180-#define DCACHE_OP_PRUNE BIT(4)176176+enum dentry_flags {177177+ DCACHE_OP_HASH = BIT(0),178178+ DCACHE_OP_COMPARE = BIT(1),179179+ DCACHE_OP_REVALIDATE = BIT(2),180180+ DCACHE_OP_DELETE = BIT(3),181181+ DCACHE_OP_PRUNE = BIT(4),182182+ /*183183+ * This dentry is possibly not currently connected to the dcache tree,184184+ * in which case its parent will either be itself, or will have this185185+ * flag as well. nfsd will not use a dentry with this bit set, but will186186+ * first endeavour to clear the bit either by discovering that it is187187+ * connected, or by performing lookup operations. Any filesystem which188188+ * supports nfsd_operations MUST have a lookup function which, if it189189+ * finds a directory inode with a DCACHE_DISCONNECTED dentry, will190190+ * d_move that dentry into place and return that dentry rather than the191191+ * passed one, typically using d_splice_alias.192192+ */193193+ DCACHE_DISCONNECTED = BIT(5),194194+ DCACHE_REFERENCED = BIT(6), /* Recently used, don't discard. */195195+ DCACHE_DONTCACHE = BIT(7), /* Purge from memory on final dput() */196196+ DCACHE_CANT_MOUNT = BIT(8),197197+ DCACHE_GENOCIDE = BIT(9),198198+ DCACHE_SHRINK_LIST = BIT(10),199199+ DCACHE_OP_WEAK_REVALIDATE = BIT(11),200200+ /*201201+ * this dentry has been "silly renamed" and has to be deleted on the202202+ * last dput()203203+ */204204+ DCACHE_NFSFS_RENAMED = BIT(12),205205+ DCACHE_FSNOTIFY_PARENT_WATCHED = BIT(13), /* Parent inode is watched by some fsnotify listener */206206+ DCACHE_DENTRY_KILLED = BIT(14),207207+ DCACHE_MOUNTED = BIT(15), /* is a mountpoint */208208+ DCACHE_NEED_AUTOMOUNT = BIT(16), /* handle automount on this dir */209209+ DCACHE_MANAGE_TRANSIT = BIT(17), /* manage transit from this dirent */210210+ DCACHE_LRU_LIST = BIT(18),211211+ DCACHE_ENTRY_TYPE = (7 << 19), /* bits 19..21 are for storing type: */212212+ DCACHE_MISS_TYPE = (0 << 19), /* Negative dentry */213213+ DCACHE_WHITEOUT_TYPE = (1 << 19), /* Whiteout dentry (stop pathwalk) */214214+ DCACHE_DIRECTORY_TYPE = (2 << 19), /* Normal directory */215215+ DCACHE_AUTODIR_TYPE = (3 << 19), /* Lookupless directory (presumed automount) */216216+ DCACHE_REGULAR_TYPE = (4 << 19), /* Regular file type */217217+ DCACHE_SPECIAL_TYPE = (5 << 19), /* Other file type */218218+ DCACHE_SYMLINK_TYPE = (6 << 19), /* Symlink */219219+ DCACHE_NOKEY_NAME = BIT(22), /* Encrypted name encoded without key */220220+ DCACHE_OP_REAL = BIT(23),221221+ DCACHE_PAR_LOOKUP = BIT(24), /* being looked up (with parent locked shared) */222222+ DCACHE_DENTRY_CURSOR = BIT(25),223223+ DCACHE_NORCU = BIT(26), /* No RCU delay for freeing */224224+};181225182182-#define DCACHE_DISCONNECTED BIT(5)183183- /* This dentry is possibly not currently connected to the dcache tree, in184184- * which case its parent will either be itself, or will have this flag as185185- * well. nfsd will not use a dentry with this bit set, but will first186186- * endeavour to clear the bit either by discovering that it is connected,187187- * or by performing lookup operations. Any filesystem which supports188188- * nfsd_operations MUST have a lookup function which, if it finds a189189- * directory inode with a DCACHE_DISCONNECTED dentry, will d_move that190190- * dentry into place and return that dentry rather than the passed one,191191- * typically using d_splice_alias. */192192-193193-#define DCACHE_REFERENCED BIT(6) /* Recently used, don't discard. */194194-195195-#define DCACHE_DONTCACHE BIT(7) /* Purge from memory on final dput() */196196-197197-#define DCACHE_CANT_MOUNT BIT(8)198198-#define DCACHE_GENOCIDE BIT(9)199199-#define DCACHE_SHRINK_LIST BIT(10)200200-201201-#define DCACHE_OP_WEAK_REVALIDATE BIT(11)202202-203203-#define DCACHE_NFSFS_RENAMED BIT(12)204204- /* this dentry has been "silly renamed" and has to be deleted on the last205205- * dput() */206206-#define DCACHE_FSNOTIFY_PARENT_WATCHED BIT(13)207207- /* Parent inode is watched by some fsnotify listener */208208-209209-#define DCACHE_DENTRY_KILLED BIT(14)210210-211211-#define DCACHE_MOUNTED BIT(15) /* is a mountpoint */212212-#define DCACHE_NEED_AUTOMOUNT BIT(16) /* handle automount on this dir */213213-#define DCACHE_MANAGE_TRANSIT BIT(17) /* manage transit from this dirent */214226#define DCACHE_MANAGED_DENTRY \215227 (DCACHE_MOUNTED|DCACHE_NEED_AUTOMOUNT|DCACHE_MANAGE_TRANSIT)216216-217217-#define DCACHE_LRU_LIST BIT(18)218218-219219-#define DCACHE_ENTRY_TYPE (7 << 19) /* bits 19..21 are for storing type: */220220-#define DCACHE_MISS_TYPE (0 << 19) /* Negative dentry */221221-#define DCACHE_WHITEOUT_TYPE (1 << 19) /* Whiteout dentry (stop pathwalk) */222222-#define DCACHE_DIRECTORY_TYPE (2 << 19) /* Normal directory */223223-#define DCACHE_AUTODIR_TYPE (3 << 19) /* Lookupless directory (presumed automount) */224224-#define DCACHE_REGULAR_TYPE (4 << 19) /* Regular file type */225225-#define DCACHE_SPECIAL_TYPE (5 << 19) /* Other file type */226226-#define DCACHE_SYMLINK_TYPE (6 << 19) /* Symlink */227227-228228-#define DCACHE_NOKEY_NAME BIT(22) /* Encrypted name encoded without key */229229-#define DCACHE_OP_REAL BIT(23)230230-231231-#define DCACHE_PAR_LOOKUP BIT(24) /* being looked up (with parent locked shared) */232232-#define DCACHE_DENTRY_CURSOR BIT(25)233233-#define DCACHE_NORCU BIT(26) /* No RCU delay for freeing */234228235229extern seqlock_t rename_lock;236230
···11/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */22-/*33- * Copyright (C) 2012 ARM Ltd.44- *55- * This program is free software; you can redistribute it and/or modify66- * it under the terms of the GNU General Public License version 2 as77- * published by the Free Software Foundation.88- *99- * This program is distributed in the hope that it will be useful,1010- * but WITHOUT ANY WARRANTY; without even the implied warranty of1111- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1212- * GNU General Public License for more details.1313- *1414- * You should have received a copy of the GNU General Public License1515- * along with this program. If not, see <http://www.gnu.org/licenses/>.1616- */1717-1818-#define __ARCH_WANT_RENAMEAT1919-#define __ARCH_WANT_NEW_STAT2020-#define __ARCH_WANT_SET_GET_RLIMIT2121-#define __ARCH_WANT_TIME32_SYSCALLS2222-#define __ARCH_WANT_MEMFD_SECRET2323-2424-#include <asm-generic/unistd.h>22+#include <asm/unistd_64.h>
+30-18
tools/arch/x86/include/asm/cpufeatures.h
···7575#define X86_FEATURE_CENTAUR_MCR ( 3*32+ 3) /* "centaur_mcr" Centaur MCRs (= MTRRs) */7676#define X86_FEATURE_K8 ( 3*32+ 4) /* Opteron, Athlon64 */7777#define X86_FEATURE_ZEN5 ( 3*32+ 5) /* CPU based on Zen5 microarchitecture */7878-#define X86_FEATURE_P3 ( 3*32+ 6) /* P3 */7979-#define X86_FEATURE_P4 ( 3*32+ 7) /* P4 */7878+/* Free ( 3*32+ 6) */7979+/* Free ( 3*32+ 7) */8080#define X86_FEATURE_CONSTANT_TSC ( 3*32+ 8) /* "constant_tsc" TSC ticks at a constant rate */8181#define X86_FEATURE_UP ( 3*32+ 9) /* "up" SMP kernel running on UP */8282#define X86_FEATURE_ART ( 3*32+10) /* "art" Always running timer (ART) */···329329#define X86_FEATURE_CLZERO (13*32+ 0) /* "clzero" CLZERO instruction */330330#define X86_FEATURE_IRPERF (13*32+ 1) /* "irperf" Instructions Retired Count */331331#define X86_FEATURE_XSAVEERPTR (13*32+ 2) /* "xsaveerptr" Always save/restore FP error pointers */332332+#define X86_FEATURE_INVLPGB (13*32+ 3) /* INVLPGB and TLBSYNC instructions supported */332333#define X86_FEATURE_RDPRU (13*32+ 4) /* "rdpru" Read processor register at user level */333334#define X86_FEATURE_WBNOINVD (13*32+ 9) /* "wbnoinvd" WBNOINVD instruction */334335#define X86_FEATURE_AMD_IBPB (13*32+12) /* Indirect Branch Prediction Barrier */···378377#define X86_FEATURE_V_SPEC_CTRL (15*32+20) /* "v_spec_ctrl" Virtual SPEC_CTRL */379378#define X86_FEATURE_VNMI (15*32+25) /* "vnmi" Virtual NMI */380379#define X86_FEATURE_SVME_ADDR_CHK (15*32+28) /* SVME addr check */380380+#define X86_FEATURE_IDLE_HLT (15*32+30) /* IDLE HLT intercept */381381382382/* Intel-defined CPU features, CPUID level 0x00000007:0 (ECX), word 16 */383383#define X86_FEATURE_AVX512VBMI (16*32+ 1) /* "avx512vbmi" AVX512 Vector Bit Manipulation instructions*/···436434#define X86_FEATURE_SPEC_CTRL_SSBD (18*32+31) /* Speculative Store Bypass Disable */437435438436/* AMD-defined memory encryption features, CPUID level 0x8000001f (EAX), word 19 */439439-#define X86_FEATURE_SME (19*32+ 0) /* "sme" AMD Secure Memory Encryption */440440-#define X86_FEATURE_SEV (19*32+ 1) /* "sev" AMD Secure Encrypted Virtualization */437437+#define X86_FEATURE_SME (19*32+ 0) /* "sme" Secure Memory Encryption */438438+#define X86_FEATURE_SEV (19*32+ 1) /* "sev" Secure Encrypted Virtualization */441439#define X86_FEATURE_VM_PAGE_FLUSH (19*32+ 2) /* VM Page Flush MSR is supported */442442-#define X86_FEATURE_SEV_ES (19*32+ 3) /* "sev_es" AMD Secure Encrypted Virtualization - Encrypted State */443443-#define X86_FEATURE_SEV_SNP (19*32+ 4) /* "sev_snp" AMD Secure Encrypted Virtualization - Secure Nested Paging */440440+#define X86_FEATURE_SEV_ES (19*32+ 3) /* "sev_es" Secure Encrypted Virtualization - Encrypted State */441441+#define X86_FEATURE_SEV_SNP (19*32+ 4) /* "sev_snp" Secure Encrypted Virtualization - Secure Nested Paging */444442#define X86_FEATURE_V_TSC_AUX (19*32+ 9) /* Virtual TSC_AUX */445445-#define X86_FEATURE_SME_COHERENT (19*32+10) /* AMD hardware-enforced cache coherency */446446-#define X86_FEATURE_DEBUG_SWAP (19*32+14) /* "debug_swap" AMD SEV-ES full debug state swap support */443443+#define X86_FEATURE_SME_COHERENT (19*32+10) /* hardware-enforced cache coherency */444444+#define X86_FEATURE_DEBUG_SWAP (19*32+14) /* "debug_swap" SEV-ES full debug state swap support */445445+#define X86_FEATURE_RMPREAD (19*32+21) /* RMPREAD instruction */446446+#define X86_FEATURE_SEGMENTED_RMP (19*32+23) /* Segmented RMP support */447447#define X86_FEATURE_SVSM (19*32+28) /* "svsm" SVSM present */448448+#define X86_FEATURE_HV_INUSE_WR_ALLOWED (19*32+30) /* Allow Write to in-use hypervisor-owned pages */448449449450/* AMD-defined Extended Feature 2 EAX, CPUID level 0x80000021 (EAX), word 20 */450451#define X86_FEATURE_NO_NESTED_DATA_BP (20*32+ 0) /* No Nested Data Breakpoints */···460455#define X86_FEATURE_SBPB (20*32+27) /* Selective Branch Prediction Barrier */461456#define X86_FEATURE_IBPB_BRTYPE (20*32+28) /* MSR_PRED_CMD[IBPB] flushes all branch type predictions */462457#define X86_FEATURE_SRSO_NO (20*32+29) /* CPU is not affected by SRSO */458458+#define X86_FEATURE_SRSO_USER_KERNEL_NO (20*32+30) /* CPU is not affected by SRSO across user/kernel boundaries */459459+#define X86_FEATURE_SRSO_BP_SPEC_REDUCE (20*32+31) /*460460+ * BP_CFG[BpSpecReduce] can be used to mitigate SRSO for VMs.461461+ * (SRSO_MSR_FIX in the official doc).462462+ */463463464464/*465465 * Extended auxiliary flags: Linux defined - for features scattered in various···476466#define X86_FEATURE_CLEAR_BHB_LOOP (21*32+ 1) /* Clear branch history at syscall entry using SW loop */477467#define X86_FEATURE_BHI_CTRL (21*32+ 2) /* BHI_DIS_S HW control available */478468#define X86_FEATURE_CLEAR_BHB_HW (21*32+ 3) /* BHI_DIS_S HW control enabled */479479-#define X86_FEATURE_CLEAR_BHB_LOOP_ON_VMEXIT (21*32+ 4) /* Clear branch history at vmexit using SW loop */480480-#define X86_FEATURE_AMD_FAST_CPPC (21*32 + 5) /* Fast CPPC */481481-#define X86_FEATURE_AMD_HETEROGENEOUS_CORES (21*32 + 6) /* Heterogeneous Core Topology */482482-#define X86_FEATURE_AMD_WORKLOAD_CLASS (21*32 + 7) /* Workload Classification */469469+#define X86_FEATURE_CLEAR_BHB_VMEXIT (21*32+ 4) /* Clear branch history at vmexit using SW loop */470470+#define X86_FEATURE_AMD_FAST_CPPC (21*32+ 5) /* Fast CPPC */471471+#define X86_FEATURE_AMD_HTR_CORES (21*32+ 6) /* Heterogeneous Core Topology */472472+#define X86_FEATURE_AMD_WORKLOAD_CLASS (21*32+ 7) /* Workload Classification */473473+#define X86_FEATURE_PREFER_YMM (21*32+ 8) /* Avoid ZMM registers due to downclocking */483474484475/*485476 * BUG word(s)···519508#define X86_BUG_ITLB_MULTIHIT X86_BUG(23) /* "itlb_multihit" CPU may incur MCE during certain page attribute changes */520509#define X86_BUG_SRBDS X86_BUG(24) /* "srbds" CPU may leak RNG bits if not mitigated */521510#define X86_BUG_MMIO_STALE_DATA X86_BUG(25) /* "mmio_stale_data" CPU is affected by Processor MMIO Stale Data vulnerabilities */522522-#define X86_BUG_MMIO_UNKNOWN X86_BUG(26) /* "mmio_unknown" CPU is too old and its MMIO Stale Data status is unknown */511511+/* unused, was #define X86_BUG_MMIO_UNKNOWN X86_BUG(26) "mmio_unknown" CPU is too old and its MMIO Stale Data status is unknown */523512#define X86_BUG_RETBLEED X86_BUG(27) /* "retbleed" CPU is affected by RETBleed */524513#define X86_BUG_EIBRS_PBRSB X86_BUG(28) /* "eibrs_pbrsb" EIBRS is vulnerable to Post Barrier RSB Predictions */525514#define X86_BUG_SMT_RSB X86_BUG(29) /* "smt_rsb" CPU is vulnerable to Cross-Thread Return Address Predictions */···527516#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 */528517529518/* BUG word 2 */530530-#define X86_BUG_SRSO X86_BUG(1*32 + 0) /* "srso" AMD SRSO bug */531531-#define X86_BUG_DIV0 X86_BUG(1*32 + 1) /* "div0" AMD DIV0 speculation bug */532532-#define X86_BUG_RFDS X86_BUG(1*32 + 2) /* "rfds" CPU is vulnerable to Register File Data Sampling */533533-#define X86_BUG_BHI X86_BUG(1*32 + 3) /* "bhi" CPU is affected by Branch History Injection */534534-#define X86_BUG_IBPB_NO_RET X86_BUG(1*32 + 4) /* "ibpb_no_ret" IBPB omits return target predictions */519519+#define X86_BUG_SRSO X86_BUG( 1*32+ 0) /* "srso" AMD SRSO bug */520520+#define X86_BUG_DIV0 X86_BUG( 1*32+ 1) /* "div0" AMD DIV0 speculation bug */521521+#define X86_BUG_RFDS X86_BUG( 1*32+ 2) /* "rfds" CPU is vulnerable to Register File Data Sampling */522522+#define X86_BUG_BHI X86_BUG( 1*32+ 3) /* "bhi" CPU is affected by Branch History Injection */523523+#define X86_BUG_IBPB_NO_RET X86_BUG( 1*32+ 4) /* "ibpb_no_ret" IBPB omits return target predictions */524524+#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 */535525#endif /* _ASM_X86_CPUFEATURES_H */
···11# SPDX-License-Identifier: CC0-1.022-# Generator: x86-cpuid-db v1.022+# Generator: x86-cpuid-db v2.33344#55# Auto-generated file.···1212# Leaf 0H1313# Maximum standard leaf number + CPU vendor string14141515- 0, 0, eax, 31:0, max_std_leaf , Highest cpuid standard leaf supported1616- 0, 0, ebx, 31:0, cpu_vendorid_0 , CPU vendor ID string bytes 0 - 31717- 0, 0, ecx, 31:0, cpu_vendorid_2 , CPU vendor ID string bytes 8 - 111818- 0, 0, edx, 31:0, cpu_vendorid_1 , CPU vendor ID string bytes 4 - 71515+ 0x0, 0, eax, 31:0, max_std_leaf , Highest standard CPUID leaf supported1616+ 0x0, 0, ebx, 31:0, cpu_vendorid_0 , CPU vendor ID string bytes 0 - 31717+ 0x0, 0, ecx, 31:0, cpu_vendorid_2 , CPU vendor ID string bytes 8 - 111818+ 0x0, 0, edx, 31:0, cpu_vendorid_1 , CPU vendor ID string bytes 4 - 719192020# Leaf 1H2121# CPU FMS (Family/Model/Stepping) + standard feature flags22222323- 1, 0, eax, 3:0, stepping , Stepping ID2424- 1, 0, eax, 7:4, base_model , Base CPU model ID2525- 1, 0, eax, 11:8, base_family_id , Base CPU family ID2626- 1, 0, eax, 13:12, cpu_type , CPU type2727- 1, 0, eax, 19:16, ext_model , Extended CPU model ID2828- 1, 0, eax, 27:20, ext_family , Extended CPU family ID2929- 1, 0, ebx, 7:0, brand_id , Brand index3030- 1, 0, ebx, 15:8, clflush_size , CLFLUSH instruction cache line size3131- 1, 0, ebx, 23:16, n_logical_cpu , Logical CPU (HW threads) count3232- 1, 0, ebx, 31:24, local_apic_id , Initial local APIC physical ID3333- 1, 0, ecx, 0, pni , Streaming SIMD Extensions 3 (SSE3)3434- 1, 0, ecx, 1, pclmulqdq , PCLMULQDQ instruction support3535- 1, 0, ecx, 2, dtes64 , 64-bit DS save area3636- 1, 0, ecx, 3, monitor , MONITOR/MWAIT support3737- 1, 0, ecx, 4, ds_cpl , CPL Qualified Debug Store3838- 1, 0, ecx, 5, vmx , Virtual Machine Extensions3939- 1, 0, ecx, 6, smx , Safer Mode Extensions4040- 1, 0, ecx, 7, est , Enhanced Intel SpeedStep4141- 1, 0, ecx, 8, tm2 , Thermal Monitor 24242- 1, 0, ecx, 9, ssse3 , Supplemental SSE34343- 1, 0, ecx, 10, cid , L1 Context ID4444- 1, 0, ecx, 11, sdbg , Sillicon Debug4545- 1, 0, ecx, 12, fma , FMA extensions using YMM state4646- 1, 0, ecx, 13, cx16 , CMPXCHG16B instruction support4747- 1, 0, ecx, 14, xtpr , xTPR Update Control4848- 1, 0, ecx, 15, pdcm , Perfmon and Debug Capability4949- 1, 0, ecx, 17, pcid , Process-context identifiers5050- 1, 0, ecx, 18, dca , Direct Cache Access5151- 1, 0, ecx, 19, sse4_1 , SSE4.15252- 1, 0, ecx, 20, sse4_2 , SSE4.25353- 1, 0, ecx, 21, x2apic , X2APIC support5454- 1, 0, ecx, 22, movbe , MOVBE instruction support5555- 1, 0, ecx, 23, popcnt , POPCNT instruction support5656- 1, 0, ecx, 24, tsc_deadline_timer , APIC timer one-shot operation5757- 1, 0, ecx, 25, aes , AES instructions5858- 1, 0, ecx, 26, xsave , XSAVE (and related instructions) support5959- 1, 0, ecx, 27, osxsave , XSAVE (and related instructions) are enabled by OS6060- 1, 0, ecx, 28, avx , AVX instructions support6161- 1, 0, ecx, 29, f16c , Half-precision floating-point conversion support6262- 1, 0, ecx, 30, rdrand , RDRAND instruction support6363- 1, 0, ecx, 31, guest_status , System is running as guest; (para-)virtualized system6464- 1, 0, edx, 0, fpu , Floating-Point Unit on-chip (x87)6565- 1, 0, edx, 1, vme , Virtual-8086 Mode Extensions6666- 1, 0, edx, 2, de , Debugging Extensions6767- 1, 0, edx, 3, pse , Page Size Extension6868- 1, 0, edx, 4, tsc , Time Stamp Counter6969- 1, 0, edx, 5, msr , Model-Specific Registers (RDMSR and WRMSR support)7070- 1, 0, edx, 6, pae , Physical Address Extensions7171- 1, 0, edx, 7, mce , Machine Check Exception7272- 1, 0, edx, 8, cx8 , CMPXCHG8B instruction7373- 1, 0, edx, 9, apic , APIC on-chip7474- 1, 0, edx, 11, sep , SYSENTER, SYSEXIT, and associated MSRs7575- 1, 0, edx, 12, mtrr , Memory Type Range Registers7676- 1, 0, edx, 13, pge , Page Global Extensions7777- 1, 0, edx, 14, mca , Machine Check Architecture7878- 1, 0, edx, 15, cmov , Conditional Move Instruction7979- 1, 0, edx, 16, pat , Page Attribute Table8080- 1, 0, edx, 17, pse36 , Page Size Extension (36-bit)8181- 1, 0, edx, 18, pn , Processor Serial Number8282- 1, 0, edx, 19, clflush , CLFLUSH instruction8383- 1, 0, edx, 21, dts , Debug Store8484- 1, 0, edx, 22, acpi , Thermal monitor and clock control8585- 1, 0, edx, 23, mmx , MMX instructions8686- 1, 0, edx, 24, fxsr , FXSAVE and FXRSTOR instructions8787- 1, 0, edx, 25, sse , SSE instructions8888- 1, 0, edx, 26, sse2 , SSE2 instructions8989- 1, 0, edx, 27, ss , Self Snoop9090- 1, 0, edx, 28, ht , Hyper-threading9191- 1, 0, edx, 29, tm , Thermal Monitor9292- 1, 0, edx, 30, ia64 , Legacy IA-64 (Itanium) support bit, now resreved9393- 1, 0, edx, 31, pbe , Pending Break Enable2323+ 0x1, 0, eax, 3:0, stepping , Stepping ID2424+ 0x1, 0, eax, 7:4, base_model , Base CPU model ID2525+ 0x1, 0, eax, 11:8, base_family_id , Base CPU family ID2626+ 0x1, 0, eax, 13:12, cpu_type , CPU type2727+ 0x1, 0, eax, 19:16, ext_model , Extended CPU model ID2828+ 0x1, 0, eax, 27:20, ext_family , Extended CPU family ID2929+ 0x1, 0, ebx, 7:0, brand_id , Brand index3030+ 0x1, 0, ebx, 15:8, clflush_size , CLFLUSH instruction cache line size3131+ 0x1, 0, ebx, 23:16, n_logical_cpu , Logical CPU count3232+ 0x1, 0, ebx, 31:24, local_apic_id , Initial local APIC physical ID3333+ 0x1, 0, ecx, 0, pni , Streaming SIMD Extensions 3 (SSE3)3434+ 0x1, 0, ecx, 1, pclmulqdq , PCLMULQDQ instruction support3535+ 0x1, 0, ecx, 2, dtes64 , 64-bit DS save area3636+ 0x1, 0, ecx, 3, monitor , MONITOR/MWAIT support3737+ 0x1, 0, ecx, 4, ds_cpl , CPL Qualified Debug Store3838+ 0x1, 0, ecx, 5, vmx , Virtual Machine Extensions3939+ 0x1, 0, ecx, 6, smx , Safer Mode Extensions4040+ 0x1, 0, ecx, 7, est , Enhanced Intel SpeedStep4141+ 0x1, 0, ecx, 8, tm2 , Thermal Monitor 24242+ 0x1, 0, ecx, 9, ssse3 , Supplemental SSE34343+ 0x1, 0, ecx, 10, cid , L1 Context ID4444+ 0x1, 0, ecx, 11, sdbg , Silicon Debug4545+ 0x1, 0, ecx, 12, fma , FMA extensions using YMM state4646+ 0x1, 0, ecx, 13, cx16 , CMPXCHG16B instruction support4747+ 0x1, 0, ecx, 14, xtpr , xTPR Update Control4848+ 0x1, 0, ecx, 15, pdcm , Perfmon and Debug Capability4949+ 0x1, 0, ecx, 17, pcid , Process-context identifiers5050+ 0x1, 0, ecx, 18, dca , Direct Cache Access5151+ 0x1, 0, ecx, 19, sse4_1 , SSE4.15252+ 0x1, 0, ecx, 20, sse4_2 , SSE4.25353+ 0x1, 0, ecx, 21, x2apic , X2APIC support5454+ 0x1, 0, ecx, 22, movbe , MOVBE instruction support5555+ 0x1, 0, ecx, 23, popcnt , POPCNT instruction support5656+ 0x1, 0, ecx, 24, tsc_deadline_timer , APIC timer one-shot operation5757+ 0x1, 0, ecx, 25, aes , AES instructions5858+ 0x1, 0, ecx, 26, xsave , XSAVE (and related instructions) support5959+ 0x1, 0, ecx, 27, osxsave , XSAVE (and related instructions) are enabled by OS6060+ 0x1, 0, ecx, 28, avx , AVX instructions support6161+ 0x1, 0, ecx, 29, f16c , Half-precision floating-point conversion support6262+ 0x1, 0, ecx, 30, rdrand , RDRAND instruction support6363+ 0x1, 0, ecx, 31, guest_status , System is running as guest; (para-)virtualized system6464+ 0x1, 0, edx, 0, fpu , Floating-Point Unit on-chip (x87)6565+ 0x1, 0, edx, 1, vme , Virtual-8086 Mode Extensions6666+ 0x1, 0, edx, 2, de , Debugging Extensions6767+ 0x1, 0, edx, 3, pse , Page Size Extension6868+ 0x1, 0, edx, 4, tsc , Time Stamp Counter6969+ 0x1, 0, edx, 5, msr , Model-Specific Registers (RDMSR and WRMSR support)7070+ 0x1, 0, edx, 6, pae , Physical Address Extensions7171+ 0x1, 0, edx, 7, mce , Machine Check Exception7272+ 0x1, 0, edx, 8, cx8 , CMPXCHG8B instruction7373+ 0x1, 0, edx, 9, apic , APIC on-chip7474+ 0x1, 0, edx, 11, sep , SYSENTER, SYSEXIT, and associated MSRs7575+ 0x1, 0, edx, 12, mtrr , Memory Type Range Registers7676+ 0x1, 0, edx, 13, pge , Page Global Extensions7777+ 0x1, 0, edx, 14, mca , Machine Check Architecture7878+ 0x1, 0, edx, 15, cmov , Conditional Move Instruction7979+ 0x1, 0, edx, 16, pat , Page Attribute Table8080+ 0x1, 0, edx, 17, pse36 , Page Size Extension (36-bit)8181+ 0x1, 0, edx, 18, pn , Processor Serial Number8282+ 0x1, 0, edx, 19, clflush , CLFLUSH instruction8383+ 0x1, 0, edx, 21, dts , Debug Store8484+ 0x1, 0, edx, 22, acpi , Thermal monitor and clock control8585+ 0x1, 0, edx, 23, mmx , MMX instructions8686+ 0x1, 0, edx, 24, fxsr , FXSAVE and FXRSTOR instructions8787+ 0x1, 0, edx, 25, sse , SSE instructions8888+ 0x1, 0, edx, 26, sse2 , SSE2 instructions8989+ 0x1, 0, edx, 27, ss , Self Snoop9090+ 0x1, 0, edx, 28, ht , Hyper-threading9191+ 0x1, 0, edx, 29, tm , Thermal Monitor9292+ 0x1, 0, edx, 30, ia64 , Legacy IA-64 (Itanium) support bit, now reserved9393+ 0x1, 0, edx, 31, pbe , Pending Break Enable94949595# Leaf 2H9696# Intel cache and TLB information one-byte descriptors97979898- 2, 0, eax, 7:0, iteration_count , Number of times this CPUD leaf must be queried9999- 2, 0, eax, 15:8, desc1 , Descriptor #1100100- 2, 0, eax, 23:16, desc2 , Descriptor #2101101- 2, 0, eax, 30:24, desc3 , Descriptor #3102102- 2, 0, eax, 31, eax_invalid , Descriptors 1-3 are invalid if set103103- 2, 0, ebx, 7:0, desc4 , Descriptor #4104104- 2, 0, ebx, 15:8, desc5 , Descriptor #5105105- 2, 0, ebx, 23:16, desc6 , Descriptor #6106106- 2, 0, ebx, 30:24, desc7 , Descriptor #7107107- 2, 0, ebx, 31, ebx_invalid , Descriptors 4-7 are invalid if set108108- 2, 0, ecx, 7:0, desc8 , Descriptor #8109109- 2, 0, ecx, 15:8, desc9 , Descriptor #9110110- 2, 0, ecx, 23:16, desc10 , Descriptor #10111111- 2, 0, ecx, 30:24, desc11 , Descriptor #11112112- 2, 0, ecx, 31, ecx_invalid , Descriptors 8-11 are invalid if set113113- 2, 0, edx, 7:0, desc12 , Descriptor #12114114- 2, 0, edx, 15:8, desc13 , Descriptor #13115115- 2, 0, edx, 23:16, desc14 , Descriptor #14116116- 2, 0, edx, 30:24, desc15 , Descriptor #15117117- 2, 0, edx, 31, edx_invalid , Descriptors 12-15 are invalid if set9898+ 0x2, 0, eax, 7:0, iteration_count , Number of times this leaf must be queried9999+ 0x2, 0, eax, 15:8, desc1 , Descriptor #1100100+ 0x2, 0, eax, 23:16, desc2 , Descriptor #2101101+ 0x2, 0, eax, 30:24, desc3 , Descriptor #3102102+ 0x2, 0, eax, 31, eax_invalid , Descriptors 1-3 are invalid if set103103+ 0x2, 0, ebx, 7:0, desc4 , Descriptor #4104104+ 0x2, 0, ebx, 15:8, desc5 , Descriptor #5105105+ 0x2, 0, ebx, 23:16, desc6 , Descriptor #6106106+ 0x2, 0, ebx, 30:24, desc7 , Descriptor #7107107+ 0x2, 0, ebx, 31, ebx_invalid , Descriptors 4-7 are invalid if set108108+ 0x2, 0, ecx, 7:0, desc8 , Descriptor #8109109+ 0x2, 0, ecx, 15:8, desc9 , Descriptor #9110110+ 0x2, 0, ecx, 23:16, desc10 , Descriptor #10111111+ 0x2, 0, ecx, 30:24, desc11 , Descriptor #11112112+ 0x2, 0, ecx, 31, ecx_invalid , Descriptors 8-11 are invalid if set113113+ 0x2, 0, edx, 7:0, desc12 , Descriptor #12114114+ 0x2, 0, edx, 15:8, desc13 , Descriptor #13115115+ 0x2, 0, edx, 23:16, desc14 , Descriptor #14116116+ 0x2, 0, edx, 30:24, desc15 , Descriptor #15117117+ 0x2, 0, edx, 31, edx_invalid , Descriptors 12-15 are invalid if set118118119119# Leaf 4H120120# Intel deterministic cache parameters121121122122- 4, 31:0, eax, 4:0, cache_type , Cache type field123123- 4, 31:0, eax, 7:5, cache_level , Cache level (1-based)124124- 4, 31:0, eax, 8, cache_self_init , Self-initialializing cache level125125- 4, 31:0, eax, 9, fully_associative , Fully-associative cache126126- 4, 31:0, eax, 25:14, num_threads_sharing , Number logical CPUs sharing this cache127127- 4, 31:0, eax, 31:26, num_cores_on_die , Number of cores in the physical package128128- 4, 31:0, ebx, 11:0, cache_linesize , System coherency line size (0-based)129129- 4, 31:0, ebx, 21:12, cache_npartitions , Physical line partitions (0-based)130130- 4, 31:0, ebx, 31:22, cache_nways , Ways of associativity (0-based)131131- 4, 31:0, ecx, 30:0, cache_nsets , Cache number of sets (0-based)132132- 4, 31:0, edx, 0, wbinvd_rll_no_guarantee, WBINVD/INVD not guaranteed for Remote Lower-Level caches133133- 4, 31:0, edx, 1, ll_inclusive , Cache is inclusive of Lower-Level caches134134- 4, 31:0, edx, 2, complex_indexing , Not a direct-mapped cache (complex function)122122+ 0x4, 31:0, eax, 4:0, cache_type , Cache type field123123+ 0x4, 31:0, eax, 7:5, cache_level , Cache level (1-based)124124+ 0x4, 31:0, eax, 8, cache_self_init , Self-initializing cache level125125+ 0x4, 31:0, eax, 9, fully_associative , Fully-associative cache126126+ 0x4, 31:0, eax, 25:14, num_threads_sharing , Number logical CPUs sharing this cache127127+ 0x4, 31:0, eax, 31:26, num_cores_on_die , Number of cores in the physical package128128+ 0x4, 31:0, ebx, 11:0, cache_linesize , System coherency line size (0-based)129129+ 0x4, 31:0, ebx, 21:12, cache_npartitions , Physical line partitions (0-based)130130+ 0x4, 31:0, ebx, 31:22, cache_nways , Ways of associativity (0-based)131131+ 0x4, 31:0, ecx, 30:0, cache_nsets , Cache number of sets (0-based)132132+ 0x4, 31:0, edx, 0, wbinvd_rll_no_guarantee, WBINVD/INVD not guaranteed for Remote Lower-Level caches133133+ 0x4, 31:0, edx, 1, ll_inclusive , Cache is inclusive of Lower-Level caches134134+ 0x4, 31:0, edx, 2, complex_indexing , Not a direct-mapped cache (complex function)135135136136# Leaf 5H137137# MONITOR/MWAIT instructions enumeration138138139139- 5, 0, eax, 15:0, min_mon_size , Smallest monitor-line size, in bytes140140- 5, 0, ebx, 15:0, max_mon_size , Largest monitor-line size, in bytes141141- 5, 0, ecx, 0, mwait_ext , Enumeration of MONITOR/MWAIT extensions is supported142142- 5, 0, ecx, 1, mwait_irq_break , Interrupts as a break-event for MWAIT is supported143143- 5, 0, edx, 3:0, n_c0_substates , Number of C0 sub C-states supported using MWAIT144144- 5, 0, edx, 7:4, n_c1_substates , Number of C1 sub C-states supported using MWAIT145145- 5, 0, edx, 11:8, n_c2_substates , Number of C2 sub C-states supported using MWAIT146146- 5, 0, edx, 15:12, n_c3_substates , Number of C3 sub C-states supported using MWAIT147147- 5, 0, edx, 19:16, n_c4_substates , Number of C4 sub C-states supported using MWAIT148148- 5, 0, edx, 23:20, n_c5_substates , Number of C5 sub C-states supported using MWAIT149149- 5, 0, edx, 27:24, n_c6_substates , Number of C6 sub C-states supported using MWAIT150150- 5, 0, edx, 31:28, n_c7_substates , Number of C7 sub C-states supported using MWAIT139139+ 0x5, 0, eax, 15:0, min_mon_size , Smallest monitor-line size, in bytes140140+ 0x5, 0, ebx, 15:0, max_mon_size , Largest monitor-line size, in bytes141141+ 0x5, 0, ecx, 0, mwait_ext , Enumeration of MONITOR/MWAIT extensions is supported142142+ 0x5, 0, ecx, 1, mwait_irq_break , Interrupts as a break-event for MWAIT is supported143143+ 0x5, 0, edx, 3:0, n_c0_substates , Number of C0 sub C-states supported using MWAIT144144+ 0x5, 0, edx, 7:4, n_c1_substates , Number of C1 sub C-states supported using MWAIT145145+ 0x5, 0, edx, 11:8, n_c2_substates , Number of C2 sub C-states supported using MWAIT146146+ 0x5, 0, edx, 15:12, n_c3_substates , Number of C3 sub C-states supported using MWAIT147147+ 0x5, 0, edx, 19:16, n_c4_substates , Number of C4 sub C-states supported using MWAIT148148+ 0x5, 0, edx, 23:20, n_c5_substates , Number of C5 sub C-states supported using MWAIT149149+ 0x5, 0, edx, 27:24, n_c6_substates , Number of C6 sub C-states supported using MWAIT150150+ 0x5, 0, edx, 31:28, n_c7_substates , Number of C7 sub C-states supported using MWAIT151151152152# Leaf 6H153153# Thermal and Power Management enumeration154154155155- 6, 0, eax, 0, dtherm , Digital temprature sensor156156- 6, 0, eax, 1, turbo_boost , Intel Turbo Boost157157- 6, 0, eax, 2, arat , Always-Running APIC Timer (not affected by p-state)158158- 6, 0, eax, 4, pln , Power Limit Notification (PLN) event159159- 6, 0, eax, 5, ecmd , Clock modulation duty cycle extension160160- 6, 0, eax, 6, pts , Package thermal management161161- 6, 0, eax, 7, hwp , HWP (Hardware P-states) base registers are supported162162- 6, 0, eax, 8, hwp_notify , HWP notification (IA32_HWP_INTERRUPT MSR)163163- 6, 0, eax, 9, hwp_act_window , HWP activity window (IA32_HWP_REQUEST[bits 41:32]) supported164164- 6, 0, eax, 10, hwp_epp , HWP Energy Performance Preference165165- 6, 0, eax, 11, hwp_pkg_req , HWP Package Level Request166166- 6, 0, eax, 13, hdc_base_regs , HDC base registers are supported167167- 6, 0, eax, 14, turbo_boost_3_0 , Intel Turbo Boost Max 3.0168168- 6, 0, eax, 15, hwp_capabilities , HWP Highest Performance change169169- 6, 0, eax, 16, hwp_peci_override , HWP PECI override170170- 6, 0, eax, 17, hwp_flexible , Flexible HWP171171- 6, 0, eax, 18, hwp_fast , IA32_HWP_REQUEST MSR fast access mode172172- 6, 0, eax, 19, hfi , HW_FEEDBACK MSRs supported173173- 6, 0, eax, 20, hwp_ignore_idle , Ignoring idle logical CPU HWP req is supported174174- 6, 0, eax, 23, thread_director , Intel thread director support175175- 6, 0, eax, 24, therm_interrupt_bit25 , IA32_THERM_INTERRUPT MSR bit 25 is supported176176- 6, 0, ebx, 3:0, n_therm_thresholds , Digital thermometer thresholds177177- 6, 0, ecx, 0, aperfmperf , MPERF/APERF MSRs (effective frequency interface)178178- 6, 0, ecx, 3, epb , IA32_ENERGY_PERF_BIAS MSR support179179- 6, 0, ecx, 15:8, thrd_director_nclasses , Number of classes, Intel thread director180180- 6, 0, edx, 0, perfcap_reporting , Performance capability reporting181181- 6, 0, edx, 1, encap_reporting , Energy efficiency capability reporting182182- 6, 0, edx, 11:8, feedback_sz , HW feedback interface struct size, in 4K pages183183- 6, 0, edx, 31:16, this_lcpu_hwfdbk_idx , This logical CPU index @ HW feedback struct, 0-based155155+ 0x6, 0, eax, 0, dtherm , Digital temperature sensor156156+ 0x6, 0, eax, 1, turbo_boost , Intel Turbo Boost157157+ 0x6, 0, eax, 2, arat , Always-Running APIC Timer (not affected by p-state)158158+ 0x6, 0, eax, 4, pln , Power Limit Notification (PLN) event159159+ 0x6, 0, eax, 5, ecmd , Clock modulation duty cycle extension160160+ 0x6, 0, eax, 6, pts , Package thermal management161161+ 0x6, 0, eax, 7, hwp , HWP (Hardware P-states) base registers are supported162162+ 0x6, 0, eax, 8, hwp_notify , HWP notification (IA32_HWP_INTERRUPT MSR)163163+ 0x6, 0, eax, 9, hwp_act_window , HWP activity window (IA32_HWP_REQUEST[bits 41:32]) supported164164+ 0x6, 0, eax, 10, hwp_epp , HWP Energy Performance Preference165165+ 0x6, 0, eax, 11, hwp_pkg_req , HWP Package Level Request166166+ 0x6, 0, eax, 13, hdc_base_regs , HDC base registers are supported167167+ 0x6, 0, eax, 14, turbo_boost_3_0 , Intel Turbo Boost Max 3.0168168+ 0x6, 0, eax, 15, hwp_capabilities , HWP Highest Performance change169169+ 0x6, 0, eax, 16, hwp_peci_override , HWP PECI override170170+ 0x6, 0, eax, 17, hwp_flexible , Flexible HWP171171+ 0x6, 0, eax, 18, hwp_fast , IA32_HWP_REQUEST MSR fast access mode172172+ 0x6, 0, eax, 19, hfi , HW_FEEDBACK MSRs supported173173+ 0x6, 0, eax, 20, hwp_ignore_idle , Ignoring idle logical CPU HWP req is supported174174+ 0x6, 0, eax, 23, thread_director , Intel thread director support175175+ 0x6, 0, eax, 24, therm_interrupt_bit25 , IA32_THERM_INTERRUPT MSR bit 25 is supported176176+ 0x6, 0, ebx, 3:0, n_therm_thresholds , Digital thermometer thresholds177177+ 0x6, 0, ecx, 0, aperfmperf , MPERF/APERF MSRs (effective frequency interface)178178+ 0x6, 0, ecx, 3, epb , IA32_ENERGY_PERF_BIAS MSR support179179+ 0x6, 0, ecx, 15:8, thrd_director_nclasses , Number of classes, Intel thread director180180+ 0x6, 0, edx, 0, perfcap_reporting , Performance capability reporting181181+ 0x6, 0, edx, 1, encap_reporting , Energy efficiency capability reporting182182+ 0x6, 0, edx, 11:8, feedback_sz , Feedback interface structure size, in 4K pages183183+ 0x6, 0, edx, 31:16, this_lcpu_hwfdbk_idx , This logical CPU hardware feedback interface index184184185185# Leaf 7H186186# Extended CPU features enumeration187187188188- 7, 0, eax, 31:0, leaf7_n_subleaves , Number of cpuid 0x7 subleaves189189- 7, 0, ebx, 0, fsgsbase , FSBASE/GSBASE read/write support190190- 7, 0, ebx, 1, tsc_adjust , IA32_TSC_ADJUST MSR supported191191- 7, 0, ebx, 2, sgx , Intel SGX (Software Guard Extensions)192192- 7, 0, ebx, 3, bmi1 , Bit manipulation extensions group 1193193- 7, 0, ebx, 4, hle , Hardware Lock Elision194194- 7, 0, ebx, 5, avx2 , AVX2 instruction set195195- 7, 0, ebx, 6, fdp_excptn_only , FPU Data Pointer updated only on x87 exceptions196196- 7, 0, ebx, 7, smep , Supervisor Mode Execution Protection197197- 7, 0, ebx, 8, bmi2 , Bit manipulation extensions group 2198198- 7, 0, ebx, 9, erms , Enhanced REP MOVSB/STOSB199199- 7, 0, ebx, 10, invpcid , INVPCID instruction (Invalidate Processor Context ID)200200- 7, 0, ebx, 11, rtm , Intel restricted transactional memory201201- 7, 0, ebx, 12, cqm , Intel RDT-CMT / AMD Platform-QoS cache monitoring202202- 7, 0, ebx, 13, zero_fcs_fds , Deprecated FPU CS/DS (stored as zero)203203- 7, 0, ebx, 14, mpx , Intel memory protection extensions204204- 7, 0, ebx, 15, rdt_a , Intel RDT / AMD Platform-QoS Enforcemeent205205- 7, 0, ebx, 16, avx512f , AVX-512 foundation instructions206206- 7, 0, ebx, 17, avx512dq , AVX-512 double/quadword instructions207207- 7, 0, ebx, 18, rdseed , RDSEED instruction208208- 7, 0, ebx, 19, adx , ADCX/ADOX instructions209209- 7, 0, ebx, 20, smap , Supervisor mode access prevention210210- 7, 0, ebx, 21, avx512ifma , AVX-512 integer fused multiply add211211- 7, 0, ebx, 23, clflushopt , CLFLUSHOPT instruction212212- 7, 0, ebx, 24, clwb , CLWB instruction213213- 7, 0, ebx, 25, intel_pt , Intel processor trace214214- 7, 0, ebx, 26, avx512pf , AVX-512 prefetch instructions215215- 7, 0, ebx, 27, avx512er , AVX-512 exponent/reciprocal instrs216216- 7, 0, ebx, 28, avx512cd , AVX-512 conflict detection instrs217217- 7, 0, ebx, 29, sha_ni , SHA/SHA256 instructions218218- 7, 0, ebx, 30, avx512bw , AVX-512 BW (byte/word granular) instructions219219- 7, 0, ebx, 31, avx512vl , AVX-512 VL (128/256 vector length) extensions220220- 7, 0, ecx, 0, prefetchwt1 , PREFETCHWT1 (Intel Xeon Phi only)221221- 7, 0, ecx, 1, avx512vbmi , AVX-512 Vector byte manipulation instrs222222- 7, 0, ecx, 2, umip , User mode instruction protection223223- 7, 0, ecx, 3, pku , Protection keys for user-space224224- 7, 0, ecx, 4, ospke , OS protection keys enable225225- 7, 0, ecx, 5, waitpkg , WAITPKG instructions226226- 7, 0, ecx, 6, avx512_vbmi2 , AVX-512 vector byte manipulation instrs group 2227227- 7, 0, ecx, 7, cet_ss , CET shadow stack features228228- 7, 0, ecx, 8, gfni , Galois field new instructions229229- 7, 0, ecx, 9, vaes , Vector AES instrs230230- 7, 0, ecx, 10, vpclmulqdq , VPCLMULQDQ 256-bit instruction support231231- 7, 0, ecx, 11, avx512_vnni , Vector neural network instructions232232- 7, 0, ecx, 12, avx512_bitalg , AVX-512 bit count/shiffle233233- 7, 0, ecx, 13, tme , Intel total memory encryption234234- 7, 0, ecx, 14, avx512_vpopcntdq , AVX-512: POPCNT for vectors of DW/QW235235- 7, 0, ecx, 16, la57 , 57-bit linear addreses (five-level paging)236236- 7, 0, ecx, 21:17, mawau_val_lm , BNDLDX/BNDSTX MAWAU value in 64-bit mode237237- 7, 0, ecx, 22, rdpid , RDPID instruction238238- 7, 0, ecx, 23, key_locker , Intel key locker support239239- 7, 0, ecx, 24, bus_lock_detect , OS bus-lock detection240240- 7, 0, ecx, 25, cldemote , CLDEMOTE instruction241241- 7, 0, ecx, 27, movdiri , MOVDIRI instruction242242- 7, 0, ecx, 28, movdir64b , MOVDIR64B instruction243243- 7, 0, ecx, 29, enqcmd , Enqueue stores supported (ENQCMD{,S})244244- 7, 0, ecx, 30, sgx_lc , Intel SGX launch configuration245245- 7, 0, ecx, 31, pks , Protection keys for supervisor-mode pages246246- 7, 0, edx, 1, sgx_keys , Intel SGX attestation services247247- 7, 0, edx, 2, avx512_4vnniw , AVX-512 neural network instructions248248- 7, 0, edx, 3, avx512_4fmaps , AVX-512 multiply accumulation single precision249249- 7, 0, edx, 4, fsrm , Fast short REP MOV250250- 7, 0, edx, 5, uintr , CPU supports user interrupts251251- 7, 0, edx, 8, avx512_vp2intersect , VP2INTERSECT{D,Q} instructions252252- 7, 0, edx, 9, srdbs_ctrl , SRBDS mitigation MSR available253253- 7, 0, edx, 10, md_clear , VERW MD_CLEAR microcode support254254- 7, 0, edx, 11, rtm_always_abort , XBEGIN (RTM transaction) always aborts255255- 7, 0, edx, 13, tsx_force_abort , MSR TSX_FORCE_ABORT, RTM_ABORT bit, supported256256- 7, 0, edx, 14, serialize , SERIALIZE instruction257257- 7, 0, edx, 15, hybrid_cpu , The CPU is identified as a 'hybrid part'258258- 7, 0, edx, 16, tsxldtrk , TSX suspend/resume load address tracking259259- 7, 0, edx, 18, pconfig , PCONFIG instruction260260- 7, 0, edx, 19, arch_lbr , Intel architectural LBRs261261- 7, 0, edx, 20, ibt , CET indirect branch tracking262262- 7, 0, edx, 22, amx_bf16 , AMX-BF16: tile bfloat16 support263263- 7, 0, edx, 23, avx512_fp16 , AVX-512 FP16 instructions264264- 7, 0, edx, 24, amx_tile , AMX-TILE: tile architecture support265265- 7, 0, edx, 25, amx_int8 , AMX-INT8: tile 8-bit integer support266266- 7, 0, edx, 26, spec_ctrl , Speculation Control (IBRS/IBPB: indirect branch restrictions)267267- 7, 0, edx, 27, intel_stibp , Single thread indirect branch predictors268268- 7, 0, edx, 28, flush_l1d , FLUSH L1D cache: IA32_FLUSH_CMD MSR269269- 7, 0, edx, 29, arch_capabilities , Intel IA32_ARCH_CAPABILITIES MSR270270- 7, 0, edx, 30, core_capabilities , IA32_CORE_CAPABILITIES MSR271271- 7, 0, edx, 31, spec_ctrl_ssbd , Speculative store bypass disable272272- 7, 1, eax, 4, avx_vnni , AVX-VNNI instructions273273- 7, 1, eax, 5, avx512_bf16 , AVX-512 bFloat16 instructions274274- 7, 1, eax, 6, lass , Linear address space separation275275- 7, 1, eax, 7, cmpccxadd , CMPccXADD instructions276276- 7, 1, eax, 8, arch_perfmon_ext , ArchPerfmonExt: CPUID leaf 0x23 is supported277277- 7, 1, eax, 10, fzrm , Fast zero-length REP MOVSB278278- 7, 1, eax, 11, fsrs , Fast short REP STOSB279279- 7, 1, eax, 12, fsrc , Fast Short REP CMPSB/SCASB280280- 7, 1, eax, 17, fred , FRED: Flexible return and event delivery transitions281281- 7, 1, eax, 18, lkgs , LKGS: Load 'kernel' (userspace) GS282282- 7, 1, eax, 19, wrmsrns , WRMSRNS instr (WRMSR-non-serializing)283283- 7, 1, eax, 21, amx_fp16 , AMX-FP16: FP16 tile operations284284- 7, 1, eax, 22, hreset , History reset support285285- 7, 1, eax, 23, avx_ifma , Integer fused multiply add286286- 7, 1, eax, 26, lam , Linear address masking287287- 7, 1, eax, 27, rd_wr_msrlist , RDMSRLIST/WRMSRLIST instructions288288- 7, 1, ebx, 0, intel_ppin , Protected processor inventory number (PPIN{,_CTL} MSRs)289289- 7, 1, edx, 4, avx_vnni_int8 , AVX-VNNI-INT8 instructions290290- 7, 1, edx, 5, avx_ne_convert , AVX-NE-CONVERT instructions291291- 7, 1, edx, 8, amx_complex , AMX-COMPLEX instructions (starting from Granite Rapids)292292- 7, 1, edx, 14, prefetchit_0_1 , PREFETCHIT0/1 instructions293293- 7, 1, edx, 18, cet_sss , CET supervisor shadow stacks safe to use294294- 7, 2, edx, 0, intel_psfd , Intel predictive store forward disable295295- 7, 2, edx, 1, ipred_ctrl , MSR bits IA32_SPEC_CTRL.IPRED_DIS_{U,S}296296- 7, 2, edx, 2, rrsba_ctrl , MSR bits IA32_SPEC_CTRL.RRSBA_DIS_{U,S}297297- 7, 2, edx, 3, ddp_ctrl , MSR bit IA32_SPEC_CTRL.DDPD_U298298- 7, 2, edx, 4, bhi_ctrl , MSR bit IA32_SPEC_CTRL.BHI_DIS_S299299- 7, 2, edx, 5, mcdt_no , MCDT mitigation not needed300300- 7, 2, edx, 6, uclock_disable , UC-lock disable is supported188188+ 0x7, 0, eax, 31:0, leaf7_n_subleaves , Number of leaf 0x7 subleaves189189+ 0x7, 0, ebx, 0, fsgsbase , FSBASE/GSBASE read/write support190190+ 0x7, 0, ebx, 1, tsc_adjust , IA32_TSC_ADJUST MSR supported191191+ 0x7, 0, ebx, 2, sgx , Intel SGX (Software Guard Extensions)192192+ 0x7, 0, ebx, 3, bmi1 , Bit manipulation extensions group 1193193+ 0x7, 0, ebx, 4, hle , Hardware Lock Elision194194+ 0x7, 0, ebx, 5, avx2 , AVX2 instruction set195195+ 0x7, 0, ebx, 6, fdp_excptn_only , FPU Data Pointer updated only on x87 exceptions196196+ 0x7, 0, ebx, 7, smep , Supervisor Mode Execution Protection197197+ 0x7, 0, ebx, 8, bmi2 , Bit manipulation extensions group 2198198+ 0x7, 0, ebx, 9, erms , Enhanced REP MOVSB/STOSB199199+ 0x7, 0, ebx, 10, invpcid , INVPCID instruction (Invalidate Processor Context ID)200200+ 0x7, 0, ebx, 11, rtm , Intel restricted transactional memory201201+ 0x7, 0, ebx, 12, cqm , Intel RDT-CMT / AMD Platform-QoS cache monitoring202202+ 0x7, 0, ebx, 13, zero_fcs_fds , Deprecated FPU CS/DS (stored as zero)203203+ 0x7, 0, ebx, 14, mpx , Intel memory protection extensions204204+ 0x7, 0, ebx, 15, rdt_a , Intel RDT / AMD Platform-QoS Enforcement205205+ 0x7, 0, ebx, 16, avx512f , AVX-512 foundation instructions206206+ 0x7, 0, ebx, 17, avx512dq , AVX-512 double/quadword instructions207207+ 0x7, 0, ebx, 18, rdseed , RDSEED instruction208208+ 0x7, 0, ebx, 19, adx , ADCX/ADOX instructions209209+ 0x7, 0, ebx, 20, smap , Supervisor mode access prevention210210+ 0x7, 0, ebx, 21, avx512ifma , AVX-512 integer fused multiply add211211+ 0x7, 0, ebx, 23, clflushopt , CLFLUSHOPT instruction212212+ 0x7, 0, ebx, 24, clwb , CLWB instruction213213+ 0x7, 0, ebx, 25, intel_pt , Intel processor trace214214+ 0x7, 0, ebx, 26, avx512pf , AVX-512 prefetch instructions215215+ 0x7, 0, ebx, 27, avx512er , AVX-512 exponent/reciprocal instructions216216+ 0x7, 0, ebx, 28, avx512cd , AVX-512 conflict detection instructions217217+ 0x7, 0, ebx, 29, sha_ni , SHA/SHA256 instructions218218+ 0x7, 0, ebx, 30, avx512bw , AVX-512 byte/word instructions219219+ 0x7, 0, ebx, 31, avx512vl , AVX-512 VL (128/256 vector length) extensions220220+ 0x7, 0, ecx, 0, prefetchwt1 , PREFETCHWT1 (Intel Xeon Phi only)221221+ 0x7, 0, ecx, 1, avx512vbmi , AVX-512 Vector byte manipulation instructions222222+ 0x7, 0, ecx, 2, umip , User mode instruction protection223223+ 0x7, 0, ecx, 3, pku , Protection keys for user-space224224+ 0x7, 0, ecx, 4, ospke , OS protection keys enable225225+ 0x7, 0, ecx, 5, waitpkg , WAITPKG instructions226226+ 0x7, 0, ecx, 6, avx512_vbmi2 , AVX-512 vector byte manipulation instructions group 2227227+ 0x7, 0, ecx, 7, cet_ss , CET shadow stack features228228+ 0x7, 0, ecx, 8, gfni , Galois field new instructions229229+ 0x7, 0, ecx, 9, vaes , Vector AES instructions230230+ 0x7, 0, ecx, 10, vpclmulqdq , VPCLMULQDQ 256-bit instruction support231231+ 0x7, 0, ecx, 11, avx512_vnni , Vector neural network instructions232232+ 0x7, 0, ecx, 12, avx512_bitalg , AVX-512 bitwise algorithms233233+ 0x7, 0, ecx, 13, tme , Intel total memory encryption234234+ 0x7, 0, ecx, 14, avx512_vpopcntdq , AVX-512: POPCNT for vectors of DWORD/QWORD235235+ 0x7, 0, ecx, 16, la57 , 57-bit linear addresses (five-level paging)236236+ 0x7, 0, ecx, 21:17, mawau_val_lm , BNDLDX/BNDSTX MAWAU value in 64-bit mode237237+ 0x7, 0, ecx, 22, rdpid , RDPID instruction238238+ 0x7, 0, ecx, 23, key_locker , Intel key locker support239239+ 0x7, 0, ecx, 24, bus_lock_detect , OS bus-lock detection240240+ 0x7, 0, ecx, 25, cldemote , CLDEMOTE instruction241241+ 0x7, 0, ecx, 27, movdiri , MOVDIRI instruction242242+ 0x7, 0, ecx, 28, movdir64b , MOVDIR64B instruction243243+ 0x7, 0, ecx, 29, enqcmd , Enqueue stores supported (ENQCMD{,S})244244+ 0x7, 0, ecx, 30, sgx_lc , Intel SGX launch configuration245245+ 0x7, 0, ecx, 31, pks , Protection keys for supervisor-mode pages246246+ 0x7, 0, edx, 1, sgx_keys , Intel SGX attestation services247247+ 0x7, 0, edx, 2, avx512_4vnniw , AVX-512 neural network instructions248248+ 0x7, 0, edx, 3, avx512_4fmaps , AVX-512 multiply accumulation single precision249249+ 0x7, 0, edx, 4, fsrm , Fast short REP MOV250250+ 0x7, 0, edx, 5, uintr , CPU supports user interrupts251251+ 0x7, 0, edx, 8, avx512_vp2intersect , VP2INTERSECT{D,Q} instructions252252+ 0x7, 0, edx, 9, srdbs_ctrl , SRBDS mitigation MSR available253253+ 0x7, 0, edx, 10, md_clear , VERW MD_CLEAR microcode support254254+ 0x7, 0, edx, 11, rtm_always_abort , XBEGIN (RTM transaction) always aborts255255+ 0x7, 0, edx, 13, tsx_force_abort , MSR TSX_FORCE_ABORT, RTM_ABORT bit, supported256256+ 0x7, 0, edx, 14, serialize , SERIALIZE instruction257257+ 0x7, 0, edx, 15, hybrid_cpu , The CPU is identified as a 'hybrid part'258258+ 0x7, 0, edx, 16, tsxldtrk , TSX suspend/resume load address tracking259259+ 0x7, 0, edx, 18, pconfig , PCONFIG instruction260260+ 0x7, 0, edx, 19, arch_lbr , Intel architectural LBRs261261+ 0x7, 0, edx, 20, ibt , CET indirect branch tracking262262+ 0x7, 0, edx, 22, amx_bf16 , AMX-BF16: tile bfloat16 support263263+ 0x7, 0, edx, 23, avx512_fp16 , AVX-512 FP16 instructions264264+ 0x7, 0, edx, 24, amx_tile , AMX-TILE: tile architecture support265265+ 0x7, 0, edx, 25, amx_int8 , AMX-INT8: tile 8-bit integer support266266+ 0x7, 0, edx, 26, spec_ctrl , Speculation Control (IBRS/IBPB: indirect branch restrictions)267267+ 0x7, 0, edx, 27, intel_stibp , Single thread indirect branch predictors268268+ 0x7, 0, edx, 28, flush_l1d , FLUSH L1D cache: IA32_FLUSH_CMD MSR269269+ 0x7, 0, edx, 29, arch_capabilities , Intel IA32_ARCH_CAPABILITIES MSR270270+ 0x7, 0, edx, 30, core_capabilities , IA32_CORE_CAPABILITIES MSR271271+ 0x7, 0, edx, 31, spec_ctrl_ssbd , Speculative store bypass disable272272+ 0x7, 1, eax, 4, avx_vnni , AVX-VNNI instructions273273+ 0x7, 1, eax, 5, avx512_bf16 , AVX-512 bfloat16 instructions274274+ 0x7, 1, eax, 6, lass , Linear address space separation275275+ 0x7, 1, eax, 7, cmpccxadd , CMPccXADD instructions276276+ 0x7, 1, eax, 8, arch_perfmon_ext , ArchPerfmonExt: leaf 0x23 is supported277277+ 0x7, 1, eax, 10, fzrm , Fast zero-length REP MOVSB278278+ 0x7, 1, eax, 11, fsrs , Fast short REP STOSB279279+ 0x7, 1, eax, 12, fsrc , Fast Short REP CMPSB/SCASB280280+ 0x7, 1, eax, 17, fred , FRED: Flexible return and event delivery transitions281281+ 0x7, 1, eax, 18, lkgs , LKGS: Load 'kernel' (userspace) GS282282+ 0x7, 1, eax, 19, wrmsrns , WRMSRNS instruction (WRMSR-non-serializing)283283+ 0x7, 1, eax, 20, nmi_src , NMI-source reporting with FRED event data284284+ 0x7, 1, eax, 21, amx_fp16 , AMX-FP16: FP16 tile operations285285+ 0x7, 1, eax, 22, hreset , History reset support286286+ 0x7, 1, eax, 23, avx_ifma , Integer fused multiply add287287+ 0x7, 1, eax, 26, lam , Linear address masking288288+ 0x7, 1, eax, 27, rd_wr_msrlist , RDMSRLIST/WRMSRLIST instructions289289+ 0x7, 1, ebx, 0, intel_ppin , Protected processor inventory number (PPIN{,_CTL} MSRs)290290+ 0x7, 1, edx, 4, avx_vnni_int8 , AVX-VNNI-INT8 instructions291291+ 0x7, 1, edx, 5, avx_ne_convert , AVX-NE-CONVERT instructions292292+ 0x7, 1, edx, 8, amx_complex , AMX-COMPLEX instructions (starting from Granite Rapids)293293+ 0x7, 1, edx, 14, prefetchit_0_1 , PREFETCHIT0/1 instructions294294+ 0x7, 1, edx, 18, cet_sss , CET supervisor shadow stacks safe to use295295+ 0x7, 2, edx, 0, intel_psfd , Intel predictive store forward disable296296+ 0x7, 2, edx, 1, ipred_ctrl , MSR bits IA32_SPEC_CTRL.IPRED_DIS_{U,S}297297+ 0x7, 2, edx, 2, rrsba_ctrl , MSR bits IA32_SPEC_CTRL.RRSBA_DIS_{U,S}298298+ 0x7, 2, edx, 3, ddp_ctrl , MSR bit IA32_SPEC_CTRL.DDPD_U299299+ 0x7, 2, edx, 4, bhi_ctrl , MSR bit IA32_SPEC_CTRL.BHI_DIS_S300300+ 0x7, 2, edx, 5, mcdt_no , MCDT mitigation not needed301301+ 0x7, 2, edx, 6, uclock_disable , UC-lock disable is supported301302302303# Leaf 9H303304# Intel DCA (Direct Cache Access) enumeration304305305305- 9, 0, eax, 0, dca_enabled_in_bios , DCA is enabled in BIOS306306+ 0x9, 0, eax, 0, dca_enabled_in_bios , DCA is enabled in BIOS306307307308# Leaf AH308309# Intel PMU (Performance Monitoring Unit) enumeration···311310 0xa, 0, eax, 7:0, pmu_version , Performance monitoring unit version ID312311 0xa, 0, eax, 15:8, pmu_n_gcounters , Number of general PMU counters per logical CPU313312 0xa, 0, eax, 23:16, pmu_gcounters_nbits , Bitwidth of PMU general counters314314- 0xa, 0, eax, 31:24, pmu_cpuid_ebx_bits , Length of cpuid leaf 0xa EBX bit vector313313+ 0xa, 0, eax, 31:24, pmu_cpuid_ebx_bits , Length of leaf 0xa EBX bit vector315314 0xa, 0, ebx, 0, no_core_cycle_evt , Core cycle event not available316315 0xa, 0, ebx, 1, no_insn_retired_evt , Instruction retired event not available317316 0xa, 0, ebx, 2, no_refcycle_evt , Reference cycles event not available···340339 0xd, 0, eax, 0, xcr0_x87 , XCR0.X87 (bit 0) supported341340 0xd, 0, eax, 1, xcr0_sse , XCR0.SEE (bit 1) supported342341 0xd, 0, eax, 2, xcr0_avx , XCR0.AVX (bit 2) supported343343- 0xd, 0, eax, 3, xcr0_mpx_bndregs , XCR0.BNDREGS (bit 3) supported (MPX BND0-BND3 regs)344344- 0xd, 0, eax, 4, xcr0_mpx_bndcsr , XCR0.BNDCSR (bit 4) supported (MPX BNDCFGU/BNDSTATUS regs)345345- 0xd, 0, eax, 5, xcr0_avx512_opmask , XCR0.OPMASK (bit 5) supported (AVX-512 k0-k7 regs)346346- 0xd, 0, eax, 6, xcr0_avx512_zmm_hi256 , XCR0.ZMM_Hi256 (bit 6) supported (AVX-512 ZMM0->ZMM7/15 regs)347347- 0xd, 0, eax, 7, xcr0_avx512_hi16_zmm , XCR0.HI16_ZMM (bit 7) supported (AVX-512 ZMM16->ZMM31 regs)348348- 0xd, 0, eax, 9, xcr0_pkru , XCR0.PKRU (bit 9) supported (XSAVE PKRU reg)349349- 0xd, 0, eax, 11, xcr0_cet_u , AMD XCR0.CET_U (bit 11) supported (CET supervisor state)350350- 0xd, 0, eax, 12, xcr0_cet_s , AMD XCR0.CET_S (bit 12) support (CET user state)342342+ 0xd, 0, eax, 3, xcr0_mpx_bndregs , XCR0.BNDREGS (bit 3) supported (MPX BND0-BND3 registers)343343+ 0xd, 0, eax, 4, xcr0_mpx_bndcsr , XCR0.BNDCSR (bit 4) supported (MPX BNDCFGU/BNDSTATUS registers)344344+ 0xd, 0, eax, 5, xcr0_avx512_opmask , XCR0.OPMASK (bit 5) supported (AVX-512 k0-k7 registers)345345+ 0xd, 0, eax, 6, xcr0_avx512_zmm_hi256 , XCR0.ZMM_Hi256 (bit 6) supported (AVX-512 ZMM0->ZMM7/15 registers)346346+ 0xd, 0, eax, 7, xcr0_avx512_hi16_zmm , XCR0.HI16_ZMM (bit 7) supported (AVX-512 ZMM16->ZMM31 registers)347347+ 0xd, 0, eax, 9, xcr0_pkru , XCR0.PKRU (bit 9) supported (XSAVE PKRU registers)348348+ 0xd, 0, eax, 11, xcr0_cet_u , XCR0.CET_U (bit 11) supported (CET user state)349349+ 0xd, 0, eax, 12, xcr0_cet_s , XCR0.CET_S (bit 12) supported (CET supervisor state)351350 0xd, 0, eax, 17, xcr0_tileconfig , XCR0.TILECONFIG (bit 17) supported (AMX can manage TILECONFIG)352351 0xd, 0, eax, 18, xcr0_tiledata , XCR0.TILEDATA (bit 18) supported (AMX can manage TILEDATA)353353- 0xd, 0, ebx, 31:0, xsave_sz_xcr0_enabled , XSAVE/XRSTR area byte size, for XCR0 enabled features354354- 0xd, 0, ecx, 31:0, xsave_sz_max , XSAVE/XRSTR area max byte size, all CPU features352352+ 0xd, 0, ebx, 31:0, xsave_sz_xcr0_enabled , XSAVE/XRSTOR area byte size, for XCR0 enabled features353353+ 0xd, 0, ecx, 31:0, xsave_sz_max , XSAVE/XRSTOR area max byte size, all CPU features355354 0xd, 0, edx, 30, xcr0_lwp , AMD XCR0.LWP (bit 62) supported (Light-weight Profiling)356355 0xd, 1, eax, 0, xsaveopt , XSAVEOPT instruction357356 0xd, 1, eax, 1, xsavec , XSAVEC instruction···370369 0xd, 63:2, eax, 31:0, xsave_sz , Size of save area for subleaf-N feature, in bytes371370 0xd, 63:2, ebx, 31:0, xsave_offset , Offset of save area for subleaf-N feature, in bytes372371 0xd, 63:2, ecx, 0, is_xss_bit , Subleaf N describes an XSS bit, otherwise XCR0 bit373373- 0xd, 63:2, ecx, 1, compacted_xsave_64byte_aligned, When compacted, subleaf-N feature xsave area is 64-byte aligned372372+ 0xd, 63:2, ecx, 1, compacted_xsave_64byte_aligned, When compacted, subleaf-N feature XSAVE area is 64-byte aligned374373375374# Leaf FH376375# Intel RDT / AMD PQoS resource monitoring···427426 0x12, 1, ecx, 0, xfrm_x87 , Enclave XFRM.X87 (bit 0) supported428427 0x12, 1, ecx, 1, xfrm_sse , Enclave XFRM.SEE (bit 1) supported429428 0x12, 1, ecx, 2, xfrm_avx , Enclave XFRM.AVX (bit 2) supported430430- 0x12, 1, ecx, 3, xfrm_mpx_bndregs , Enclave XFRM.BNDREGS (bit 3) supported (MPX BND0-BND3 regs)431431- 0x12, 1, ecx, 4, xfrm_mpx_bndcsr , Enclave XFRM.BNDCSR (bit 4) supported (MPX BNDCFGU/BNDSTATUS regs)432432- 0x12, 1, ecx, 5, xfrm_avx512_opmask , Enclave XFRM.OPMASK (bit 5) supported (AVX-512 k0-k7 regs)433433- 0x12, 1, ecx, 6, xfrm_avx512_zmm_hi256 , Enclave XFRM.ZMM_Hi256 (bit 6) supported (AVX-512 ZMM0->ZMM7/15 regs)434434- 0x12, 1, ecx, 7, xfrm_avx512_hi16_zmm , Enclave XFRM.HI16_ZMM (bit 7) supported (AVX-512 ZMM16->ZMM31 regs)435435- 0x12, 1, ecx, 9, xfrm_pkru , Enclave XFRM.PKRU (bit 9) supported (XSAVE PKRU reg)429429+ 0x12, 1, ecx, 3, xfrm_mpx_bndregs , Enclave XFRM.BNDREGS (bit 3) supported (MPX BND0-BND3 registers)430430+ 0x12, 1, ecx, 4, xfrm_mpx_bndcsr , Enclave XFRM.BNDCSR (bit 4) supported (MPX BNDCFGU/BNDSTATUS registers)431431+ 0x12, 1, ecx, 5, xfrm_avx512_opmask , Enclave XFRM.OPMASK (bit 5) supported (AVX-512 k0-k7 registers)432432+ 0x12, 1, ecx, 6, xfrm_avx512_zmm_hi256 , Enclave XFRM.ZMM_Hi256 (bit 6) supported (AVX-512 ZMM0->ZMM7/15 registers)433433+ 0x12, 1, ecx, 7, xfrm_avx512_hi16_zmm , Enclave XFRM.HI16_ZMM (bit 7) supported (AVX-512 ZMM16->ZMM31 registers)434434+ 0x12, 1, ecx, 9, xfrm_pkru , Enclave XFRM.PKRU (bit 9) supported (XSAVE PKRU registers)436435 0x12, 1, ecx, 17, xfrm_tileconfig , Enclave XFRM.TILECONFIG (bit 17) supported (AMX can manage TILECONFIG)437436 0x12, 1, ecx, 18, xfrm_tiledata , Enclave XFRM.TILEDATA (bit 18) supported (AMX can manage TILEDATA)438437 0x12, 31:2, eax, 3:0, subleaf_type , Subleaf type (dictates output layout)439439- 0x12, 31:2, eax, 31:12, epc_sec_base_addr_0 , EPC section base addr, bits[12:31]440440- 0x12, 31:2, ebx, 19:0, epc_sec_base_addr_1 , EPC section base addr, bits[32:51]438438+ 0x12, 31:2, eax, 31:12, epc_sec_base_addr_0 , EPC section base address, bits[12:31]439439+ 0x12, 31:2, ebx, 19:0, epc_sec_base_addr_1 , EPC section base address, bits[32:51]441440 0x12, 31:2, ecx, 3:0, epc_sec_type , EPC section type / property encoding442441 0x12, 31:2, ecx, 31:12, epc_sec_size_0 , EPC section size, bits[12:31]443442 0x12, 31:2, edx, 19:0, epc_sec_size_1 , EPC section size, bits[32:51]···445444# Leaf 14H446445# Intel Processor Trace enumeration447446448448- 0x14, 0, eax, 31:0, pt_max_subleaf , Max cpuid 0x14 subleaf447447+ 0x14, 0, eax, 31:0, pt_max_subleaf , Maximum leaf 0x14 subleaf449448 0x14, 0, ebx, 0, cr3_filtering , IA32_RTIT_CR3_MATCH is accessible450449 0x14, 0, ebx, 1, psb_cyc , Configurable PSB and cycle-accurate mode451450 0x14, 0, ebx, 2, ip_filtering , IP/TraceStop filtering; Warm-reset PT MSRs preservation···473472 0x15, 0, ecx, 31:0, cpu_crystal_hz , Core crystal clock nominal frequency, in Hz474473475474# Leaf 16H476476-# Intel processor fequency enumeration475475+# Intel processor frequency enumeration477476478477 0x16, 0, eax, 15:0, cpu_base_mhz , Processor base frequency, in MHz479478 0x16, 0, ebx, 15:0, cpu_max_mhz , Processor max frequency, in MHz···482481# Leaf 17H483482# Intel SoC vendor attributes enumeration484483485485- 0x17, 0, eax, 31:0, soc_max_subleaf , Max cpuid leaf 0x17 subleaf484484+ 0x17, 0, eax, 31:0, soc_max_subleaf , Maximum leaf 0x17 subleaf486485 0x17, 0, ebx, 15:0, soc_vendor_id , SoC vendor ID487487- 0x17, 0, ebx, 16, is_vendor_scheme , Assigned by industry enumaeratoion scheme (not Intel)486486+ 0x17, 0, ebx, 16, is_vendor_scheme , Assigned by industry enumeration scheme (not Intel)488487 0x17, 0, ecx, 31:0, soc_proj_id , SoC project ID, assigned by vendor489488 0x17, 0, edx, 31:0, soc_stepping_id , Soc project stepping ID, assigned by vendor490489 0x17, 3:1, eax, 31:0, vendor_brand_a , Vendor Brand ID string, bytes subleaf_nr * (0 -> 3)···495494# Leaf 18H496495# Intel determenestic address translation (TLB) parameters497496498498- 0x18, 31:0, eax, 31:0, tlb_max_subleaf , Max cpuid 0x18 subleaf497497+ 0x18, 31:0, eax, 31:0, tlb_max_subleaf , Maximum leaf 0x18 subleaf499498 0x18, 31:0, ebx, 0, tlb_4k_page , TLB 4KB-page entries supported500499 0x18, 31:0, ebx, 1, tlb_2m_page , TLB 2MB-page entries supported501500 0x18, 31:0, ebx, 2, tlb_4m_page , TLB 4MB-page entries supported502501 0x18, 31:0, ebx, 3, tlb_1g_page , TLB 1GB-page entries supported503503- 0x18, 31:0, ebx, 10:8, hard_partitioning , (Hard/Soft) partitioning between logical CPUs sharing this struct502502+ 0x18, 31:0, ebx, 10:8, hard_partitioning , (Hard/Soft) partitioning between logical CPUs sharing this structure504503 0x18, 31:0, ebx, 31:16, n_way_associative , Ways of associativity505504 0x18, 31:0, ecx, 31:0, n_sets , Number of sets506505 0x18, 31:0, edx, 4:0, tlb_type , Translation cache type (TLB type)507506 0x18, 31:0, edx, 7:5, tlb_cache_level , Translation cache level (1-based)508507 0x18, 31:0, edx, 8, is_fully_associative , Fully-associative structure509509- 0x18, 31:0, edx, 25:14, tlb_max_addressible_ids, Max num of addressible IDs for logical CPUs sharing this TLB - 1508508+ 0x18, 31:0, edx, 25:14, tlb_max_addressible_ids, Max number of addressable IDs for logical CPUs sharing this TLB - 1510509511510# Leaf 19H512511# Intel Key Locker enumeration···569568# Intel AMX, TMUL (Tile-matrix MULtiply) accelerator unit enumeration570569571570 0x1e, 0, ebx, 7:0, tmul_maxk , TMUL unit maximum height, K (rows or columns)572572- 0x1e, 0, ebx, 23:8, tmul_maxn , TMUL unit maxiumum SIMD dimension, N (column bytes)571571+ 0x1e, 0, ebx, 23:8, tmul_maxn , TMUL unit maximum SIMD dimension, N (column bytes)573572574573# Leaf 1FH575574# Intel extended topology enumeration v2···6246230x40000000, 0, edx, 31:0, hypervisor_id_2 , Hypervisor ID string bytes 8 - 11625624626625# Leaf 80000000H627627-# Maximum extended leaf number + CPU vendor string (AMD)626626+# Maximum extended leaf number + AMD/Transmeta CPU vendor string628627629629-0x80000000, 0, eax, 31:0, max_ext_leaf , Maximum extended cpuid leaf supported628628+0x80000000, 0, eax, 31:0, max_ext_leaf , Maximum extended CPUID leaf supported6306290x80000000, 0, ebx, 31:0, cpu_vendorid_0 , Vendor ID string bytes 0 - 36316300x80000000, 0, ecx, 31:0, cpu_vendorid_2 , Vendor ID string bytes 8 - 116326310x80000000, 0, edx, 31:0, cpu_vendorid_1 , Vendor ID string bytes 4 - 7···6376360x80000001, 0, eax, 3:0, e_stepping_id , Stepping ID6386370x80000001, 0, eax, 7:4, e_base_model , Base processor model6396380x80000001, 0, eax, 11:8, e_base_family , Base processor family639639+0x80000001, 0, eax, 13:12, e_base_type , Base processor type (Transmeta)6406400x80000001, 0, eax, 19:16, e_ext_model , Extended processor model6416410x80000001, 0, eax, 27:20, e_ext_family , Extended processor family6426420x80000001, 0, ebx, 15:0, brand_id , Brand ID···6616590x80000001, 0, ecx, 17, tce , Translation cache extension6626600x80000001, 0, ecx, 19, nodeid_msr , NodeId MSR (0xc001100c)6636610x80000001, 0, ecx, 21, tbm , Trailing bit manipulations664664-0x80000001, 0, ecx, 22, topoext , Topology Extensions (cpuid leaf 0x8000001d)662662+0x80000001, 0, ecx, 22, topoext , Topology Extensions (leaf 0x8000001d)6656630x80000001, 0, ecx, 23, perfctr_core , Core performance counter extensions6666640x80000001, 0, ecx, 24, perfctr_nb , NB/DF performance counter extensions6676650x80000001, 0, ecx, 26, bpext , Data access breakpoint extension···6896870x80000001, 0, edx, 19, mp , Out-of-spec AMD Multiprocessing bit6906880x80000001, 0, edx, 20, nx , No-execute page protection6916890x80000001, 0, edx, 22, mmxext , AMD MMX extensions690690+0x80000001, 0, edx, 23, e_mmx , MMX instructions (Transmeta)6926910x80000001, 0, edx, 24, e_fxsr , FXSAVE and FXRSTOR instructions6936920x80000001, 0, edx, 25, fxsr_opt , FXSAVE and FXRSTOR optimizations6946930x80000001, 0, edx, 26, pdpe1gb , 1-GB large page support···7237200x80000004, 0, edx, 31:0, cpu_brandid_11 , CPU brand ID string, bytes 44 - 47724721725722# Leaf 80000005H726726-# AMD L1 cache and L1 TLB enumeration723723+# AMD/Transmeta L1 cache and L1 TLB enumeration727724728728-0x80000005, 0, eax, 7:0, l1_itlb_2m_4m_nentries , L1 ITLB #entires, 2M and 4M pages725725+0x80000005, 0, eax, 7:0, l1_itlb_2m_4m_nentries , L1 ITLB #entries, 2M and 4M pages7297260x80000005, 0, eax, 15:8, l1_itlb_2m_4m_assoc , L1 ITLB associativity, 2M and 4M pages730730-0x80000005, 0, eax, 23:16, l1_dtlb_2m_4m_nentries , L1 DTLB #entires, 2M and 4M pages727727+0x80000005, 0, eax, 23:16, l1_dtlb_2m_4m_nentries , L1 DTLB #entries, 2M and 4M pages7317280x80000005, 0, eax, 31:24, l1_dtlb_2m_4m_assoc , L1 DTLB associativity, 2M and 4M pages7327290x80000005, 0, ebx, 7:0, l1_itlb_4k_nentries , L1 ITLB #entries, 4K pages7337300x80000005, 0, ebx, 15:8, l1_itlb_4k_assoc , L1 ITLB associativity, 4K pages···766763# CPU power management (mostly AMD) and AMD RAS enumeration7677647687650x80000007, 0, ebx, 0, overflow_recov , MCA overflow conditions not fatal769769-0x80000007, 0, ebx, 1, succor , Software containment of UnCORRectable errors766766+0x80000007, 0, ebx, 1, succor , Software containment of uncorrectable errors7707670x80000007, 0, ebx, 2, hw_assert , Hardware assert MSRs7717680x80000007, 0, ebx, 3, smca , Scalable MCA (MCAX MSRs)7727690x80000007, 0, ecx, 31:0, cpu_pwr_sample_ratio , CPU power sample time ratio773773-0x80000007, 0, edx, 0, digital_temp , Digital temprature sensor770770+0x80000007, 0, edx, 0, digital_temp , Digital temperature sensor7747710x80000007, 0, edx, 1, powernow_freq_id , PowerNOW! frequency scaling7757720x80000007, 0, edx, 2, powernow_volt_id , PowerNOW! voltage scaling7767730x80000007, 0, edx, 3, thermal_trip , THERMTRIP (Thermal Trip)···8138100x80000008, 0, ebx, 23, amd_ppin , Protected Processor Inventory Number8148110x80000008, 0, ebx, 24, amd_ssbd , Speculative Store Bypass Disable8158120x80000008, 0, ebx, 25, virt_ssbd , virtualized SSBD (Speculative Store Bypass Disable)816816-0x80000008, 0, ebx, 26, amd_ssb_no , SSBD not needed (fixed in HW)813813+0x80000008, 0, ebx, 26, amd_ssb_no , SSBD is not needed (fixed in hardware)8178140x80000008, 0, ebx, 27, cppc , Collaborative Processor Performance Control8188150x80000008, 0, ebx, 28, amd_psfd , Predictive Store Forward Disable8198160x80000008, 0, ebx, 29, btc_no , CPU not affected by Branch Type Confusion···8418380x8000000a, 0, edx, 10, pausefilter , Pause intercept filter8428390x8000000a, 0, edx, 12, pfthreshold , Pause filter threshold8438400x8000000a, 0, edx, 13, avic , Advanced virtual interrupt controller844844-0x8000000a, 0, edx, 15, v_vmsave_vmload , Virtual VMSAVE/VMLOAD (nested virt)841841+0x8000000a, 0, edx, 15, v_vmsave_vmload , Virtual VMSAVE/VMLOAD (nested virtualization)8458420x8000000a, 0, edx, 16, vgif , Virtualize the Global Interrupt Flag8468430x8000000a, 0, edx, 17, gmet , Guest mode execution trap8478440x8000000a, 0, edx, 18, x2avic , Virtual x2APIC···8538500x8000000a, 0, edx, 25, vnmi , NMI virtualization8548510x8000000a, 0, edx, 26, ibs_virt , IBS Virtualization8558520x8000000a, 0, edx, 27, ext_lvt_off_chg , Extended LVT offset fault change856856-0x8000000a, 0, edx, 28, svme_addr_chk , Guest SVME addr check853853+0x8000000a, 0, edx, 28, svme_addr_chk , Guest SVME address check857854858855# Leaf 80000019H859856# AMD TLB 1G-pages enumeration···894891# AMD LWP (Lightweight Profiling)8958928968930x8000001c, 0, eax, 0, os_lwp_avail , LWP is available to application programs (supported by OS)897897-0x8000001c, 0, eax, 1, os_lpwval , LWPVAL instruction (EventId=1) is supported by OS898898-0x8000001c, 0, eax, 2, os_lwp_ire , Instructions Retired Event (EventId=2) is supported by OS899899-0x8000001c, 0, eax, 3, os_lwp_bre , Branch Retired Event (EventId=3) is supported by OS900900-0x8000001c, 0, eax, 4, os_lwp_dme , DCache Miss Event (EventId=4) is supported by OS901901-0x8000001c, 0, eax, 5, os_lwp_cnh , CPU Clocks Not Halted event (EventId=5) is supported by OS902902-0x8000001c, 0, eax, 6, os_lwp_rnh , CPU Reference clocks Not Halted event (EventId=6) is supported by OS894894+0x8000001c, 0, eax, 1, os_lpwval , LWPVAL instruction is supported by OS895895+0x8000001c, 0, eax, 2, os_lwp_ire , Instructions Retired Event is supported by OS896896+0x8000001c, 0, eax, 3, os_lwp_bre , Branch Retired Event is supported by OS897897+0x8000001c, 0, eax, 4, os_lwp_dme , Dcache Miss Event is supported by OS898898+0x8000001c, 0, eax, 5, os_lwp_cnh , CPU Clocks Not Halted event is supported by OS899899+0x8000001c, 0, eax, 6, os_lwp_rnh , CPU Reference clocks Not Halted event is supported by OS9039000x8000001c, 0, eax, 29, os_lwp_cont , LWP sampling in continuous mode is supported by OS9049010x8000001c, 0, eax, 30, os_lwp_ptsc , Performance Time Stamp Counter in event records is supported by OS9059020x8000001c, 0, eax, 31, os_lwp_int , Interrupt on threshold overflow is supported by OS9069030x8000001c, 0, ebx, 7:0, lwp_lwpcb_sz , LWP Control Block size, in quadwords9079040x8000001c, 0, ebx, 15:8, lwp_event_sz , LWP event record size, in bytes908908-0x8000001c, 0, ebx, 23:16, lwp_max_events , LWP max supported EventId value (EventID 255 not included)905905+0x8000001c, 0, ebx, 23:16, lwp_max_events , LWP max supported EventID value (EventID 255 not included)9099060x8000001c, 0, ebx, 31:24, lwp_event_offset , LWP events area offset in the LWP Control Block910910-0x8000001c, 0, ecx, 4:0, lwp_latency_max , Num of bits in cache latency counters (10 to 31)907907+0x8000001c, 0, ecx, 4:0, lwp_latency_max , Number of bits in cache latency counters (10 to 31)9119080x8000001c, 0, ecx, 5, lwp_data_adddr , Cache miss events report the data address of the reference9129090x8000001c, 0, ecx, 8:6, lwp_latency_rnd , Amount by which cache latency is rounded9139100x8000001c, 0, ecx, 15:9, lwp_version , LWP implementation version···9169130x8000001c, 0, ecx, 29, lwp_ip_filtering , IP filtering (IPI, IPF, BaseIP, and LimitIP @ LWPCP) supported9179140x8000001c, 0, ecx, 30, lwp_cache_levels , Cache-related events can be filtered by cache level9189150x8000001c, 0, ecx, 31, lwp_cache_latency , Cache-related events can be filtered by latency919919-0x8000001c, 0, edx, 0, hw_lwp_avail , LWP is available in Hardware920920-0x8000001c, 0, edx, 1, hw_lpwval , LWPVAL instruction (EventId=1) is available in HW921921-0x8000001c, 0, edx, 2, hw_lwp_ire , Instructions Retired Event (EventId=2) is available in HW922922-0x8000001c, 0, edx, 3, hw_lwp_bre , Branch Retired Event (EventId=3) is available in HW923923-0x8000001c, 0, edx, 4, hw_lwp_dme , DCache Miss Event (EventId=4) is available in HW924924-0x8000001c, 0, edx, 5, hw_lwp_cnh , CPU Clocks Not Halted event (EventId=5) is available in HW925925-0x8000001c, 0, edx, 6, hw_lwp_rnh , CPU Reference clocks Not Halted event (EventId=6) is available in HW926926-0x8000001c, 0, edx, 29, hw_lwp_cont , LWP sampling in continuous mode is available in HW927927-0x8000001c, 0, edx, 30, hw_lwp_ptsc , Performance Time Stamp Counter in event records is available in HW928928-0x8000001c, 0, edx, 31, hw_lwp_int , Interrupt on threshold overflow is available in HW916916+0x8000001c, 0, edx, 0, hw_lwp_avail , LWP is available in hardware917917+0x8000001c, 0, edx, 1, hw_lpwval , LWPVAL instruction is available in hardware918918+0x8000001c, 0, edx, 2, hw_lwp_ire , Instructions Retired Event is available in hardware919919+0x8000001c, 0, edx, 3, hw_lwp_bre , Branch Retired Event is available in hardware920920+0x8000001c, 0, edx, 4, hw_lwp_dme , Dcache Miss Event is available in hardware921921+0x8000001c, 0, edx, 5, hw_lwp_cnh , Clocks Not Halted event is available in hardware922922+0x8000001c, 0, edx, 6, hw_lwp_rnh , Reference clocks Not Halted event is available in hardware923923+0x8000001c, 0, edx, 29, hw_lwp_cont , LWP sampling in continuous mode is available in hardware924924+0x8000001c, 0, edx, 30, hw_lwp_ptsc , Performance Time Stamp Counter in event records is available in hardware925925+0x8000001c, 0, edx, 31, hw_lwp_int , Interrupt on threshold overflow is available in hardware929926930927# Leaf 8000001DH931928# AMD deterministic cache parameters···9619580x8000001f, 0, eax, 4, sev_nested_paging , SEV secure nested paging supported9629590x8000001f, 0, eax, 5, vm_permission_levels , VMPL supported9639600x8000001f, 0, eax, 6, rpmquery , RPMQUERY instruction supported964964-0x8000001f, 0, eax, 7, vmpl_sss , VMPL supervisor shadwo stack supported961961+0x8000001f, 0, eax, 7, vmpl_sss , VMPL supervisor shadow stack supported9659620x8000001f, 0, eax, 8, secure_tsc , Secure TSC supported9669630x8000001f, 0, eax, 9, v_tsc_aux , Hardware virtualizes TSC_AUX967967-0x8000001f, 0, eax, 10, sme_coherent , HW enforces cache coherency across encryption domains964964+0x8000001f, 0, eax, 10, sme_coherent , Cache coherency is enforced across encryption domains9689650x8000001f, 0, eax, 11, req_64bit_hypervisor , SEV guest mandates 64-bit hypervisor9699660x8000001f, 0, eax, 12, restricted_injection , Restricted Injection supported9709670x8000001f, 0, eax, 13, alternate_injection , Alternate Injection supported···9769730x8000001f, 0, eax, 19, virt_ibs , IBS state virtualization is supported for SEV-ES guests9779740x8000001f, 0, eax, 24, vmsa_reg_protection , VMSA register protection is supported9789750x8000001f, 0, eax, 25, smt_protection , SMT protection is supported979979-0x8000001f, 0, eax, 28, svsm_page_msr , SVSM communication page MSR (0xc001f000h) is supported976976+0x8000001f, 0, eax, 28, svsm_page_msr , SVSM communication page MSR (0xc001f000) is supported9809770x8000001f, 0, eax, 29, nested_virt_snp_msr , VIRT_RMPUPDATE/VIRT_PSMASH MSRs are supported9819780x8000001f, 0, ebx, 5:0, pte_cbit_pos , PTE bit number used to enable memory encryption9829790x8000001f, 0, ebx, 11:6, phys_addr_reduction_nbits, Reduction of phys address space when encryption is enabled, in bits9839800x8000001f, 0, ebx, 15:12, vmpl_count , Number of VM permission levels (VMPL) supported9849810x8000001f, 0, ecx, 31:0, enc_guests_max , Max supported number of simultaneous encrypted guests985985-0x8000001f, 0, edx, 31:0, min_sev_asid_no_sev_es , Mininum ASID for SEV-enabled SEV-ES-disabled guest982982+0x8000001f, 0, edx, 31:0, min_sev_asid_no_sev_es , Minimum ASID for SEV-enabled SEV-ES-disabled guest986983987984# Leaf 80000020H988985# AMD Platform QoS extended feature IDs···9919880x80000020, 0, ebx, 2, smba , Slow Memory Bandwidth Allocation support9929890x80000020, 0, ebx, 3, bmec , Bandwidth Monitoring Event Configuration support9939900x80000020, 0, ebx, 4, l3rr , L3 Range Reservation support991991+0x80000020, 0, ebx, 5, abmc , Assignable Bandwidth Monitoring Counters992992+0x80000020, 0, ebx, 6, sdciae , Smart Data Cache Injection (SDCI) Allocation Enforcement9949930x80000020, 1, eax, 31:0, mba_limit_len , MBA enforcement limit size9959940x80000020, 1, edx, 31:0, mba_cos_max , MBA max Class of Service number (zero-based)9969950x80000020, 2, eax, 31:0, smba_limit_len , SMBA enforcement limit size···101210070x80000021, 0, eax, 0, no_nested_data_bp , No nested data breakpoints101310080x80000021, 0, eax, 1, fsgs_non_serializing , WRMSR to {FS,GS,KERNEL_GS}_BASE is non-serializing101410090x80000021, 0, eax, 2, lfence_rdtsc , LFENCE always serializing / synchronizes RDTSC10151015-0x80000021, 0, eax, 3, smm_page_cfg_lock , SMM paging configuration lock is supported10101010+0x80000021, 0, eax, 3, smm_page_cfg_lock , SMM paging configuration lock101610110x80000021, 0, eax, 6, null_sel_clr_base , Null selector clears base10171017-0x80000021, 0, eax, 7, upper_addr_ignore , EFER MSR Upper Address Ignore Enable bit supported10181018-0x80000021, 0, eax, 8, autoibrs , EFER MSR Automatic IBRS enable bit supported10191019-0x80000021, 0, eax, 9, no_smm_ctl_msr , SMM_CTL MSR (0xc0010116) is not present10201020-0x80000021, 0, eax, 10, fsrs_supported , Fast Short Rep Stosb (FSRS) is supported10211021-0x80000021, 0, eax, 11, fsrc_supported , Fast Short Repe Cmpsb (FSRC) is supported10221022-0x80000021, 0, eax, 13, prefetch_ctl_msr , Prefetch control MSR is supported10121012+0x80000021, 0, eax, 7, upper_addr_ignore , EFER MSR Upper Address Ignore10131013+0x80000021, 0, eax, 8, autoibrs , EFER MSR Automatic IBRS10141014+0x80000021, 0, eax, 9, no_smm_ctl_msr , SMM_CTL MSR (0xc0010116) is not available10151015+0x80000021, 0, eax, 10, fsrs , Fast Short Rep STOSB10161016+0x80000021, 0, eax, 11, fsrc , Fast Short Rep CMPSB10171017+0x80000021, 0, eax, 13, prefetch_ctl_msr , Prefetch control MSR is available10181018+0x80000021, 0, eax, 16, opcode_reclaim , Reserves opcode space102310190x80000021, 0, eax, 17, user_cpuid_disable , #GP when executing CPUID at CPL > 0 is supported10241024-0x80000021, 0, eax, 18, epsf_supported , Enhanced Predictive Store Forwarding (EPSF) is supported10251025-0x80000021, 0, ebx, 11:0, microcode_patch_size , Size of microcode patch, in 16-byte units10201020+0x80000021, 0, eax, 18, epsf , Enhanced Predictive Store Forwarding10211021+0x80000021, 0, eax, 22, wl_feedback , Workload-based heuristic feedback to OS10221022+0x80000021, 0, eax, 24, eraps , Enhanced Return Address Predictor Security10231023+0x80000021, 0, eax, 27, sbpb , Selective Branch Predictor Barrier10241024+0x80000021, 0, eax, 28, ibpb_brtype , Branch predictions flushed from CPU branch predictor10251025+0x80000021, 0, eax, 29, srso_no , CPU is not subject to the SRSO vulnerability10261026+0x80000021, 0, eax, 30, srso_uk_no , CPU is not vulnerable to SRSO at user-kernel boundary10271027+0x80000021, 0, eax, 31, srso_msr_fix , Software may use MSR BP_CFG[BpSpecReduce] to mitigate SRSO10281028+0x80000021, 0, ebx, 15:0, microcode_patch_size , Size of microcode patch, in 16-byte units10291029+0x80000021, 0, ebx, 23:16, rap_size , Return Address Predictor size1026103010271031# Leaf 80000022H10281032# AMD Performance Monitoring v2 enumeration···103910250x80000022, 0, eax, 0, perfmon_v2 , Performance monitoring v2 supported104010260x80000022, 0, eax, 1, lbr_v2 , Last Branch Record v2 extensions (LBR Stack)104110270x80000022, 0, eax, 2, lbr_pmc_freeze , Freezing core performance counters / LBR Stack supported10421042-0x80000022, 0, ebx, 3:0, n_pmc_core , Number of core perfomance counters10281028+0x80000022, 0, ebx, 3:0, n_pmc_core , Number of core performance counters104310290x80000022, 0, ebx, 9:4, lbr_v2_stack_size , Number of available LBR stack entries104410300x80000022, 0, ebx, 15:10, n_pmc_northbridge , Number of available northbridge (data fabric) performance counters104510310x80000022, 0, ebx, 21:16, n_pmc_umc , Number of available UMC performance counters···10491035# AMD Secure Multi-key Encryption enumeration10501036105110370x80000023, 0, eax, 0, mem_hmk_mode , MEM-HMK encryption mode is supported10521052-0x80000023, 0, ebx, 15:0, mem_hmk_avail_keys , MEM-HMK mode: total num of available encryption keys10381038+0x80000023, 0, ebx, 15:0, mem_hmk_avail_keys , MEM-HMK mode: total number of available encryption keys1053103910541040# Leaf 80000026H10551041# AMD extended topology enumeration v2···106510510x80000026, 3:0, ecx, 7:0, domain_level , This domain level (subleaf ID)106610520x80000026, 3:0, ecx, 15:8, domain_type , This domain type106710530x80000026, 3:0, edx, 31:0, x2apic_id , x2APIC ID of current logical CPU10541054+10551055+# Leaf 80860000H10561056+# Maximum Transmeta leaf number + CPU vendor ID string10571057+10581058+0x80860000, 0, eax, 31:0, max_tra_leaf , Maximum supported Transmeta leaf number10591059+0x80860000, 0, ebx, 31:0, cpu_vendorid_0 , Transmeta Vendor ID string bytes 0 - 310601060+0x80860000, 0, ecx, 31:0, cpu_vendorid_2 , Transmeta Vendor ID string bytes 8 - 1110611061+0x80860000, 0, edx, 31:0, cpu_vendorid_1 , Transmeta Vendor ID string bytes 4 - 710621062+10631063+# Leaf 80860001H10641064+# Transmeta extended CPU information10651065+10661066+0x80860001, 0, eax, 3:0, stepping , Stepping ID10671067+0x80860001, 0, eax, 7:4, base_model , Base CPU model ID10681068+0x80860001, 0, eax, 11:8, base_family_id , Base CPU family ID10691069+0x80860001, 0, eax, 13:12, cpu_type , CPU type10701070+0x80860001, 0, ebx, 7:0, cpu_rev_mask_minor , CPU revision ID, mask minor10711071+0x80860001, 0, ebx, 15:8, cpu_rev_mask_major , CPU revision ID, mask major10721072+0x80860001, 0, ebx, 23:16, cpu_rev_minor , CPU revision ID, minor10731073+0x80860001, 0, ebx, 31:24, cpu_rev_major , CPU revision ID, major10741074+0x80860001, 0, ecx, 31:0, cpu_base_mhz , CPU nominal frequency, in MHz10751075+0x80860001, 0, edx, 0, recovery , Recovery CMS is active (after bad flush)10761076+0x80860001, 0, edx, 1, longrun , LongRun power management capabilities10771077+0x80860001, 0, edx, 3, lrti , LongRun Table Interface10781078+10791079+# Leaf 80860002H10801080+# Transmeta Code Morphing Software (CMS) enumeration10811081+10821082+0x80860002, 0, eax, 31:0, cpu_rev_id , CPU revision ID10831083+0x80860002, 0, ebx, 7:0, cms_rev_mask_2 , CMS revision ID, mask component 210841084+0x80860002, 0, ebx, 15:8, cms_rev_mask_1 , CMS revision ID, mask component 110851085+0x80860002, 0, ebx, 23:16, cms_rev_minor , CMS revision ID, minor10861086+0x80860002, 0, ebx, 31:24, cms_rev_major , CMS revision ID, major10871087+0x80860002, 0, ecx, 31:0, cms_rev_mask_3 , CMS revision ID, mask component 310881088+10891089+# Leaf 80860003H10901090+# Transmeta CPU information string, bytes 0 - 1510911091+10921092+0x80860003, 0, eax, 31:0, cpu_info_0 , CPU info string bytes 0 - 310931093+0x80860003, 0, ebx, 31:0, cpu_info_1 , CPU info string bytes 4 - 710941094+0x80860003, 0, ecx, 31:0, cpu_info_2 , CPU info string bytes 8 - 1110951095+0x80860003, 0, edx, 31:0, cpu_info_3 , CPU info string bytes 12 - 1510961096+10971097+# Leaf 80860004H10981098+# Transmeta CPU information string, bytes 16 - 3110991099+11001100+0x80860004, 0, eax, 31:0, cpu_info_4 , CPU info string bytes 16 - 1911011101+0x80860004, 0, ebx, 31:0, cpu_info_5 , CPU info string bytes 20 - 2311021102+0x80860004, 0, ecx, 31:0, cpu_info_6 , CPU info string bytes 24 - 2711031103+0x80860004, 0, edx, 31:0, cpu_info_7 , CPU info string bytes 28 - 3111041104+11051105+# Leaf 80860005H11061106+# Transmeta CPU information string, bytes 32 - 4711071107+11081108+0x80860005, 0, eax, 31:0, cpu_info_8 , CPU info string bytes 32 - 3511091109+0x80860005, 0, ebx, 31:0, cpu_info_9 , CPU info string bytes 36 - 3911101110+0x80860005, 0, ecx, 31:0, cpu_info_10 , CPU info string bytes 40 - 4311111111+0x80860005, 0, edx, 31:0, cpu_info_11 , CPU info string bytes 44 - 4711121112+11131113+# Leaf 80860006H11141114+# Transmeta CPU information string, bytes 48 - 6311151115+11161116+0x80860006, 0, eax, 31:0, cpu_info_12 , CPU info string bytes 48 - 5111171117+0x80860006, 0, ebx, 31:0, cpu_info_13 , CPU info string bytes 52 - 5511181118+0x80860006, 0, ecx, 31:0, cpu_info_14 , CPU info string bytes 56 - 5911191119+0x80860006, 0, edx, 31:0, cpu_info_15 , CPU info string bytes 60 - 6311201120+11211121+# Leaf 80860007H11221122+# Transmeta live CPU information11231123+11241124+0x80860007, 0, eax, 31:0, cpu_cur_mhz , Current CPU frequency, in MHz11251125+0x80860007, 0, ebx, 31:0, cpu_cur_voltage , Current CPU voltage, in millivolts11261126+0x80860007, 0, ecx, 31:0, cpu_cur_perf_pctg , Current CPU performance percentage, 0 - 10011271127+0x80860007, 0, edx, 31:0, cpu_cur_gate_delay , Current CPU gate delay, in femtoseconds11281128+11291129+# Leaf C0000000H11301130+# Maximum Centaur/Zhaoxin leaf number11311131+11321132+0xc0000000, 0, eax, 31:0, max_cntr_leaf , Maximum Centaur/Zhaoxin leaf number11331133+11341134+# Leaf C0000001H11351135+# Centaur/Zhaoxin extended CPU features11361136+11371137+0xc0000001, 0, edx, 0, ccs_sm2 , CCS SM2 instructions11381138+0xc0000001, 0, edx, 1, ccs_sm2_en , CCS SM2 enabled11391139+0xc0000001, 0, edx, 2, xstore , Random Number Generator11401140+0xc0000001, 0, edx, 3, xstore_en , RNG enabled11411141+0xc0000001, 0, edx, 4, ccs_sm3_sm4 , CCS SM3 and SM4 instructions11421142+0xc0000001, 0, edx, 5, ccs_sm3_sm4_en , CCS SM3/SM4 enabled11431143+0xc0000001, 0, edx, 6, ace , Advanced Cryptography Engine11441144+0xc0000001, 0, edx, 7, ace_en , ACE enabled11451145+0xc0000001, 0, edx, 8, ace2 , Advanced Cryptography Engine v211461146+0xc0000001, 0, edx, 9, ace2_en , ACE v2 enabled11471147+0xc0000001, 0, edx, 10, phe , PadLock Hash Engine11481148+0xc0000001, 0, edx, 11, phe_en , PHE enabled11491149+0xc0000001, 0, edx, 12, pmm , PadLock Montgomery Multiplier11501150+0xc0000001, 0, edx, 13, pmm_en , PMM enabled11511151+0xc0000001, 0, edx, 16, parallax , Parallax auto adjust processor voltage11521152+0xc0000001, 0, edx, 17, parallax_en , Parallax enabled11531153+0xc0000001, 0, edx, 20, tm3 , Thermal Monitor v311541154+0xc0000001, 0, edx, 21, tm3_en , TM v3 enabled11551155+0xc0000001, 0, edx, 25, phe2 , PadLock Hash Engine v2 (SHA384/SHA512)11561156+0xc0000001, 0, edx, 26, phe2_en , PHE v2 enabled11571157+0xc0000001, 0, edx, 27, rsa , RSA instructions (XMODEXP/MONTMUL2)11581158+0xc0000001, 0, edx, 28, rsa_en , RSA instructions enabled
+180-195
tools/arch/x86/kcpuid/kcpuid.c
···11// SPDX-License-Identifier: GPL-2.022#define _GNU_SOURCE3344-#include <stdio.h>44+#include <cpuid.h>55+#include <err.h>66+#include <getopt.h>57#include <stdbool.h>88+#include <stdio.h>69#include <stdlib.h>710#include <string.h>88-#include <getopt.h>9111012#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))1113#define min(a, b) (((a) < (b)) ? (a) : (b))1414+#define __noreturn __attribute__((__noreturn__))12151316typedef unsigned int u32;1417typedef unsigned long long u64;···5249struct subleaf {5350 u32 index;5451 u32 sub;5555- u32 eax, ebx, ecx, edx;5252+ u32 output[NR_REGS];5653 struct reg_desc info[NR_REGS];5754};5855···6663 int nr;6764};68656666+enum range_index {6767+ RANGE_STD = 0, /* Standard */6868+ RANGE_EXT = 0x80000000, /* Extended */6969+ RANGE_TSM = 0x80860000, /* Transmeta */7070+ RANGE_CTR = 0xc0000000, /* Centaur/Zhaoxin */7171+};7272+7373+#define CPUID_INDEX_MASK 0xffff00007474+#define CPUID_FUNCTION_MASK (~CPUID_INDEX_MASK)7575+6976struct cpuid_range {7077 /* array of main leafs */7178 struct cpuid_func *funcs;7279 /* number of valid leafs */7380 int nr;7474- bool is_ext;8181+ enum range_index index;7582};76837777-/*7878- * basic: basic functions range: [0... ]7979- * ext: extended functions range: [0x80000000... ]8080- */8181-struct cpuid_range *leafs_basic, *leafs_ext;8484+static struct cpuid_range ranges[] = {8585+ { .index = RANGE_STD, },8686+ { .index = RANGE_EXT, },8787+ { .index = RANGE_TSM, },8888+ { .index = RANGE_CTR, },8989+};82908383-static bool is_amd;9191+static char *range_to_str(struct cpuid_range *range)9292+{9393+ switch (range->index) {9494+ case RANGE_STD: return "Standard";9595+ case RANGE_EXT: return "Extended";9696+ case RANGE_TSM: return "Transmeta";9797+ case RANGE_CTR: return "Centaur";9898+ default: return NULL;9999+ }100100+}101101+102102+#define __for_each_cpuid_range(range, __condition) \103103+ for (unsigned int i = 0; \104104+ i < ARRAY_SIZE(ranges) && ((range) = &ranges[i]) && (__condition); \105105+ i++)106106+107107+#define for_each_valid_cpuid_range(range) __for_each_cpuid_range(range, (range)->nr != 0)108108+#define for_each_cpuid_range(range) __for_each_cpuid_range(range, true)109109+110110+struct cpuid_range *index_to_cpuid_range(u32 index)111111+{112112+ u32 func_idx = index & CPUID_FUNCTION_MASK;113113+ u32 range_idx = index & CPUID_INDEX_MASK;114114+ struct cpuid_range *range;115115+116116+ for_each_valid_cpuid_range(range) {117117+ if (range->index == range_idx && (u32)range->nr > func_idx)118118+ return range;119119+ }120120+121121+ return NULL;122122+}123123+84124static bool show_details;85125static bool show_raw;86126static bool show_flags_only = true;···13185static u32 user_sub = 0xFFFFFFFF;13286static int flines;13387134134-static inline void cpuid(u32 *eax, u32 *ebx, u32 *ecx, u32 *edx)135135-{136136- /* ecx is often an input as well as an output. */137137- asm volatile("cpuid"138138- : "=a" (*eax),139139- "=b" (*ebx),140140- "=c" (*ecx),141141- "=d" (*edx)142142- : "0" (*eax), "2" (*ecx));143143-}8888+/*8989+ * Force using <cpuid.h> __cpuid_count() instead of __cpuid(). The9090+ * latter leaves ECX uninitialized, which can break CPUID queries.9191+ */9292+9393+#define cpuid(leaf, a, b, c, d) \9494+ __cpuid_count(leaf, 0, a, b, c, d)9595+9696+#define cpuid_count(leaf, subleaf, a, b, c, d) \9797+ __cpuid_count(leaf, subleaf, a, b, c, d)1449814599static inline bool has_subleafs(u32 f)146100{···163117 if (leaf->sub == 0)164118 printf("0x%08x: subleafs:\n", leaf->index);165119166166- printf(" %2d: EAX=0x%08x, EBX=0x%08x, ECX=0x%08x, EDX=0x%08x\n",167167- leaf->sub, leaf->eax, leaf->ebx, leaf->ecx, leaf->edx);120120+ printf(" %2d: EAX=0x%08x, EBX=0x%08x, ECX=0x%08x, EDX=0x%08x\n", leaf->sub,121121+ leaf->output[0], leaf->output[1], leaf->output[2], leaf->output[3]);168122 } else {169169- printf("0x%08x: EAX=0x%08x, EBX=0x%08x, ECX=0x%08x, EDX=0x%08x\n",170170- leaf->index, leaf->eax, leaf->ebx, leaf->ecx, leaf->edx);123123+ printf("0x%08x: EAX=0x%08x, EBX=0x%08x, ECX=0x%08x, EDX=0x%08x\n", leaf->index,124124+ leaf->output[0], leaf->output[1], leaf->output[2], leaf->output[3]);171125 }172126}173127···186140 * Cut off vendor-prefix from CPUID function as we're using it as an187141 * index into ->funcs.188142 */189189- func = &range->funcs[f & 0xffff];143143+ func = &range->funcs[f & CPUID_FUNCTION_MASK];190144191145 if (!func->leafs) {192146 func->leafs = malloc(sizeof(struct subleaf));193147 if (!func->leafs)194194- perror("malloc func leaf");148148+ err(EXIT_FAILURE, NULL);195149196150 func->nr = 1;197151 } else {198152 s = func->nr;199153 func->leafs = realloc(func->leafs, (s + 1) * sizeof(*leaf));200154 if (!func->leafs)201201- perror("realloc f->leafs");155155+ err(EXIT_FAILURE, NULL);202156203157 func->nr++;204158 }···207161208162 leaf->index = f;209163 leaf->sub = subleaf;210210- leaf->eax = a;211211- leaf->ebx = b;212212- leaf->ecx = c;213213- leaf->edx = d;164164+ leaf->output[R_EAX] = a;165165+ leaf->output[R_EBX] = b;166166+ leaf->output[R_ECX] = c;167167+ leaf->output[R_EDX] = d;214168215169 return false;216170}217171218172static void raw_dump_range(struct cpuid_range *range)219173{220220- u32 f;221221- int i;222222-223223- printf("%s Leafs :\n", range->is_ext ? "Extended" : "Basic");174174+ printf("%s Leafs :\n", range_to_str(range));224175 printf("================\n");225176226226- for (f = 0; (int)f < range->nr; f++) {177177+ for (u32 f = 0; (int)f < range->nr; f++) {227178 struct cpuid_func *func = &range->funcs[f];228228- u32 index = f;229229-230230- if (range->is_ext)231231- index += 0x80000000;232179233180 /* Skip leaf without valid items */234181 if (!func->nr)235182 continue;236183237184 /* First item is the main leaf, followed by all subleafs */238238- for (i = 0; i < func->nr; i++)185185+ for (int i = 0; i < func->nr; i++)239186 leaf_print_raw(&func->leafs[i]);240187 }241188}242189243190#define MAX_SUBLEAF_NUM 64244244-struct cpuid_range *setup_cpuid_range(u32 input_eax)191191+#define MAX_RANGE_INDEX_OFFSET 0xff192192+void setup_cpuid_range(struct cpuid_range *range)245193{246246- u32 max_func, idx_func, subleaf, max_subleaf;247247- u32 eax, ebx, ecx, edx, f = input_eax;248248- struct cpuid_range *range;249249- bool allzero;194194+ u32 max_func, range_funcs_sz;195195+ u32 eax, ebx, ecx, edx;250196251251- eax = input_eax;252252- ebx = ecx = edx = 0;197197+ cpuid(range->index, max_func, ebx, ecx, edx);253198254254- cpuid(&eax, &ebx, &ecx, &edx);255255- max_func = eax;256256- idx_func = (max_func & 0xffff) + 1;199199+ /*200200+ * If the CPUID range's maximum function value is garbage, then it201201+ * is not recognized by this CPU. Set the range's number of valid202202+ * leaves to zero so that for_each_valid_cpu_range() can ignore it.203203+ */204204+ if (max_func < range->index || max_func > (range->index + MAX_RANGE_INDEX_OFFSET)) {205205+ range->nr = 0;206206+ return;207207+ }257208258258- range = malloc(sizeof(struct cpuid_range));259259- if (!range)260260- perror("malloc range");209209+ range->nr = (max_func & CPUID_FUNCTION_MASK) + 1;210210+ range_funcs_sz = range->nr * sizeof(struct cpuid_func);261211262262- if (input_eax & 0x80000000)263263- range->is_ext = true;264264- else265265- range->is_ext = false;266266-267267- range->funcs = malloc(sizeof(struct cpuid_func) * idx_func);212212+ range->funcs = malloc(range_funcs_sz);268213 if (!range->funcs)269269- perror("malloc range->funcs");214214+ err(EXIT_FAILURE, NULL);270215271271- range->nr = idx_func;272272- memset(range->funcs, 0, sizeof(struct cpuid_func) * idx_func);216216+ memset(range->funcs, 0, range_funcs_sz);273217274274- for (; f <= max_func; f++) {275275- eax = f;276276- subleaf = ecx = 0;218218+ for (u32 f = range->index; f <= max_func; f++) {219219+ u32 max_subleaf = MAX_SUBLEAF_NUM;220220+ bool allzero;277221278278- cpuid(&eax, &ebx, &ecx, &edx);279279- allzero = cpuid_store(range, f, subleaf, eax, ebx, ecx, edx);222222+ cpuid(f, eax, ebx, ecx, edx);223223+224224+ allzero = cpuid_store(range, f, 0, eax, ebx, ecx, edx);280225 if (allzero)281226 continue;282227283228 if (!has_subleafs(f))284229 continue;285285-286286- max_subleaf = MAX_SUBLEAF_NUM;287230288231 /*289232 * Some can provide the exact number of subleafs,···291256 if (f == 0x80000026)292257 max_subleaf = 5;293258294294- for (subleaf = 1; subleaf < max_subleaf; subleaf++) {295295- eax = f;296296- ecx = subleaf;259259+ for (u32 subleaf = 1; subleaf < max_subleaf; subleaf++) {260260+ cpuid_count(f, subleaf, eax, ebx, ecx, edx);297261298298- cpuid(&eax, &ebx, &ecx, &edx);299299- allzero = cpuid_store(range, f, subleaf,300300- eax, ebx, ecx, edx);262262+ allzero = cpuid_store(range, f, subleaf, eax, ebx, ecx, edx);301263 if (allzero)302264 continue;303265 }304266305267 }306306-307307- return range;308268}309269310270/*···310280 * 0, 0, EAX, 31:0, max_basic_leafs, Max input value for supported subleafs311281 * 1, 0, ECX, 0, sse3, Streaming SIMD Extensions 3(SSE3)312282 */313313-static int parse_line(char *line)283283+static void parse_line(char *line)314284{315285 char *str;316316- int i;317286 struct cpuid_range *range;318287 struct cpuid_func *func;319288 struct subleaf *leaf;320289 u32 index;321321- u32 sub;322290 char buffer[512];323291 char *buf;324292 /*···338310339311 /* Skip comments and NULL line */340312 if (line[0] == '#' || line[0] == '\n')341341- return 0;313313+ return;342314343315 strncpy(buffer, line, 511);344316 buffer[511] = 0;345317 str = buffer;346346- for (i = 0; i < 5; i++) {318318+ for (int i = 0; i < 5; i++) {347319 tokens[i] = strtok(str, ",");348320 if (!tokens[i])349321 goto err_exit;···356328 /* index/main-leaf */357329 index = strtoull(tokens[0], NULL, 0);358330359359- if (index & 0x80000000)360360- range = leafs_ext;361361- else362362- range = leafs_basic;331331+ /*332332+ * Skip line parsing if the index is not covered by known-valid333333+ * CPUID ranges on this CPU.334334+ */335335+ range = index_to_cpuid_range(index);336336+ if (!range)337337+ return;363338364364- index &= 0x7FFFFFFF;365365- /* Skip line parsing for non-existing indexes */366366- if ((int)index >= range->nr)367367- return -1;368368-339339+ /* Skip line parsing if the index CPUID output is all zero */340340+ index &= CPUID_FUNCTION_MASK;369341 func = &range->funcs[index];370370-371371- /* Return if the index has no valid item on this platform */372342 if (!func->nr)373373- return 0;343343+ return;374344375345 /* subleaf */376346 buf = tokens[1];···381355 subleaf_start = strtoul(start, NULL, 0);382356 subleaf_end = min(subleaf_end, (u32)(func->nr - 1));383357 if (subleaf_start > subleaf_end)384384- return 0;358358+ return;385359 } else {386360 subleaf_start = subleaf_end;387361 if (subleaf_start > (u32)(func->nr - 1))388388- return 0;362362+ return;389363 }390364391365 /* register */···408382 bit_end = strtoul(end, NULL, 0);409383 bit_start = (start) ? strtoul(start, NULL, 0) : bit_end;410384411411- for (sub = subleaf_start; sub <= subleaf_end; sub++) {385385+ for (u32 sub = subleaf_start; sub <= subleaf_end; sub++) {412386 leaf = &func->leafs[sub];413387 reg = &leaf->info[reg_index];414388 bdesc = ®->descs[reg->nr++];···418392 strcpy(bdesc->simp, strtok(tokens[4], " \t"));419393 strcpy(bdesc->detail, tokens[5]);420394 }421421- return 0;395395+ return;422396423397err_exit:424424- printf("Warning: wrong line format:\n");425425- printf("\tline[%d]: %s\n", flines, line);426426- return -1;398398+ warnx("Wrong line format:\n"399399+ "\tline[%d]: %s", flines, line);427400}428401429402/* Parse csv file, and construct the array of all leafs and subleafs */···443418 file = fopen("./cpuid.csv", "r");444419 }445420446446- if (!file) {447447- printf("Fail to open '%s'\n", filename);448448- return;449449- }421421+ if (!file)422422+ err(EXIT_FAILURE, "%s", filename);450423451424 while (1) {452425 ret = getline(&line, &len, file);···459436 fclose(file);460437}461438462462-463463-/* Decode every eax/ebx/ecx/edx */464464-static void decode_bits(u32 value, struct reg_desc *rdesc, enum cpuid_reg reg)439439+static void show_reg(const struct reg_desc *rdesc, u32 value)465440{466466- struct bits_desc *bdesc;467467- int start, end, i;441441+ const struct bits_desc *bdesc;442442+ int start, end;468443 u32 mask;469444470470- if (!rdesc->nr) {471471- if (show_details)472472- printf("\t %s: 0x%08x\n", reg_names[reg], value);473473- return;474474- }475475-476476- for (i = 0; i < rdesc->nr; i++) {445445+ for (int i = 0; i < rdesc->nr; i++) {477446 bdesc = &rdesc->descs[i];478447479448 start = bdesc->start;···495480 }496481}497482483483+static void show_reg_header(bool has_entries, u32 leaf, u32 subleaf, const char *reg_name)484484+{485485+ if (show_details && has_entries)486486+ printf("CPUID_0x%x_%s[0x%x]:\n", leaf, reg_name, subleaf);487487+}488488+498489static void show_leaf(struct subleaf *leaf)499490{500500- if (!leaf)501501- return;502502-503503- if (show_raw) {491491+ if (show_raw)504492 leaf_print_raw(leaf);505505- } else {506506- if (show_details)507507- printf("CPUID_0x%x_ECX[0x%x]:\n",508508- leaf->index, leaf->sub);509509- }510493511511- decode_bits(leaf->eax, &leaf->info[R_EAX], R_EAX);512512- decode_bits(leaf->ebx, &leaf->info[R_EBX], R_EBX);513513- decode_bits(leaf->ecx, &leaf->info[R_ECX], R_ECX);514514- decode_bits(leaf->edx, &leaf->info[R_EDX], R_EDX);494494+ for (int i = R_EAX; i < NR_REGS; i++) {495495+ show_reg_header((leaf->info[i].nr > 0), leaf->index, leaf->sub, reg_names[i]);496496+ show_reg(&leaf->info[i], leaf->output[i]);497497+ }515498516499 if (!show_raw && show_details)517500 printf("\n");···517504518505static void show_func(struct cpuid_func *func)519506{520520- int i;521521-522522- if (!func)523523- return;524524-525525- for (i = 0; i < func->nr; i++)507507+ for (int i = 0; i < func->nr; i++)526508 show_leaf(&func->leafs[i]);527509}528510529511static void show_range(struct cpuid_range *range)530512{531531- int i;532532-533533- for (i = 0; i < range->nr; i++)513513+ for (int i = 0; i < range->nr; i++)534514 show_func(&range->funcs[i]);535515}536516537517static inline struct cpuid_func *index_to_func(u32 index)538518{519519+ u32 func_idx = index & CPUID_FUNCTION_MASK;539520 struct cpuid_range *range;540540- u32 func_idx;541521542542- range = (index & 0x80000000) ? leafs_ext : leafs_basic;543543- func_idx = index & 0xffff;544544-545545- if ((func_idx + 1) > (u32)range->nr) {546546- printf("ERR: invalid input index (0x%x)\n", index);522522+ range = index_to_cpuid_range(index);523523+ if (!range)547524 return NULL;548548- }525525+549526 return &range->funcs[func_idx];550527}551528552529static void show_info(void)553530{531531+ struct cpuid_range *range;554532 struct cpuid_func *func;555533556534 if (show_raw) {557535 /* Show all of the raw output of 'cpuid' instr */558558- raw_dump_range(leafs_basic);559559- raw_dump_range(leafs_ext);536536+ for_each_valid_cpuid_range(range)537537+ raw_dump_range(range);560538 return;561539 }562540···555551 /* Only show specific leaf/subleaf info */556552 func = index_to_func(user_index);557553 if (!func)558558- return;554554+ errx(EXIT_FAILURE, "Invalid input leaf (0x%x)", user_index);559555560556 /* Dump the raw data also */561557 show_raw = true;562558563559 if (user_sub != 0xFFFFFFFF) {564564- if (user_sub + 1 <= (u32)func->nr) {565565- show_leaf(&func->leafs[user_sub]);566566- return;560560+ if (user_sub + 1 > (u32)func->nr) {561561+ errx(EXIT_FAILURE, "Leaf 0x%x has no valid subleaf = 0x%x",562562+ user_index, user_sub);567563 }568564569569- printf("ERR: invalid input subleaf (0x%x)\n", user_sub);565565+ show_leaf(&func->leafs[user_sub]);566566+ return;570567 }571568572569 show_func(func);···575570 }576571577572 printf("CPU features:\n=============\n\n");578578- show_range(leafs_basic);579579- show_range(leafs_ext);573573+ for_each_valid_cpuid_range(range)574574+ show_range(range);580575}581576582582-static void setup_platform_cpuid(void)577577+static void __noreturn usage(int exit_code)583578{584584- u32 eax, ebx, ecx, edx;585585-586586- /* Check vendor */587587- eax = ebx = ecx = edx = 0;588588- cpuid(&eax, &ebx, &ecx, &edx);589589-590590- /* "htuA" */591591- if (ebx == 0x68747541)592592- is_amd = true;593593-594594- /* Setup leafs for the basic and extended range */595595- leafs_basic = setup_cpuid_range(0x0);596596- leafs_ext = setup_cpuid_range(0x80000000);597597-}598598-599599-static void usage(void)600600-{601601- printf("kcpuid [-abdfhr] [-l leaf] [-s subleaf]\n"602602- "\t-a|--all Show both bit flags and complex bit fields info\n"603603- "\t-b|--bitflags Show boolean flags only\n"604604- "\t-d|--detail Show details of the flag/fields (default)\n"605605- "\t-f|--flags Specify the cpuid csv file\n"606606- "\t-h|--help Show usage info\n"607607- "\t-l|--leaf=index Specify the leaf you want to check\n"608608- "\t-r|--raw Show raw cpuid data\n"609609- "\t-s|--subleaf=sub Specify the subleaf you want to check\n"579579+ errx(exit_code, "kcpuid [-abdfhr] [-l leaf] [-s subleaf]\n"580580+ "\t-a|--all Show both bit flags and complex bit fields info\n"581581+ "\t-b|--bitflags Show boolean flags only\n"582582+ "\t-d|--detail Show details of the flag/fields (default)\n"583583+ "\t-f|--flags Specify the CPUID CSV file\n"584584+ "\t-h|--help Show usage info\n"585585+ "\t-l|--leaf=index Specify the leaf you want to check\n"586586+ "\t-r|--raw Show raw CPUID data\n"587587+ "\t-s|--subleaf=sub Specify the subleaf you want to check"610588 );611589}612590···605617 { NULL, 0, NULL, 0 }606618};607619608608-static int parse_options(int argc, char *argv[])620620+static void parse_options(int argc, char *argv[])609621{610622 int c;611623···625637 user_csv = optarg;626638 break;627639 case 'h':628628- usage();629629- exit(1);630630- break;640640+ usage(EXIT_SUCCESS);631641 case 'l':632642 /* main leaf */633643 user_index = strtoul(optarg, NULL, 0);···638652 user_sub = strtoul(optarg, NULL, 0);639653 break;640654 default:641641- printf("%s: Invalid option '%c'\n", argv[0], optopt);642642- return -1;643643- }644644-645645- return 0;655655+ usage(EXIT_FAILURE);656656+ }646657}647658648659/*···652669 */653670int main(int argc, char *argv[])654671{655655- if (parse_options(argc, argv))656656- return -1;672672+ struct cpuid_range *range;673673+674674+ parse_options(argc, argv);657675658676 /* Setup the cpuid leafs of current platform */659659- setup_platform_cpuid();677677+ for_each_cpuid_range(range)678678+ setup_cpuid_range(range);660679661680 /* Read and parse the 'cpuid.csv' */662681 parse_text();
+2-1
tools/arch/x86/lib/memset_64.S
···3344#include <linux/export.h>55#include <linux/linkage.h>66+#include <linux/cfi_types.h>67#include <asm/cpufeatures.h>78#include <asm/alternative.h>89···2928 * only for the return value that is the same as the source input,3029 * which the compiler could/should do much better anyway.3130 */3232-SYM_FUNC_START(__memset)3131+SYM_TYPED_FUNC_START(__memset)3332 ALTERNATIVE "jmp memset_orig", "", X86_FEATURE_FSRS34333534 movq %rdi,%r9
+45
tools/include/linux/cfi_types.h
···11+/* SPDX-License-Identifier: GPL-2.0 */22+/*33+ * Clang Control Flow Integrity (CFI) type definitions.44+ */55+#ifndef _LINUX_CFI_TYPES_H66+#define _LINUX_CFI_TYPES_H77+88+#ifdef __ASSEMBLY__99+#include <linux/linkage.h>1010+1111+#ifdef CONFIG_CFI_CLANG1212+/*1313+ * Use the __kcfi_typeid_<function> type identifier symbol to1414+ * annotate indirectly called assembly functions. The compiler emits1515+ * these symbols for all address-taken function declarations in C1616+ * code.1717+ */1818+#ifndef __CFI_TYPE1919+#define __CFI_TYPE(name) \2020+ .4byte __kcfi_typeid_##name2121+#endif2222+2323+#define SYM_TYPED_ENTRY(name, linkage, align...) \2424+ linkage(name) ASM_NL \2525+ align ASM_NL \2626+ __CFI_TYPE(name) ASM_NL \2727+ name:2828+2929+#define SYM_TYPED_START(name, linkage, align...) \3030+ SYM_TYPED_ENTRY(name, linkage, align)3131+3232+#else /* CONFIG_CFI_CLANG */3333+3434+#define SYM_TYPED_START(name, linkage, align...) \3535+ SYM_START(name, linkage, align)3636+3737+#endif /* CONFIG_CFI_CLANG */3838+3939+#ifndef SYM_TYPED_FUNC_START4040+#define SYM_TYPED_FUNC_START(name) \4141+ SYM_TYPED_START(name, SYM_L_GLOBAL, SYM_A_ALIGN)4242+#endif4343+4444+#endif /* __ASSEMBLY__ */4545+#endif /* _LINUX_CFI_TYPES_H */
···849849__SYSCALL(__NR_listxattrat, sys_listxattrat)850850#define __NR_removexattrat 466851851__SYSCALL(__NR_removexattrat, sys_removexattrat)852852+#define __NR_open_tree_attr 467853853+__SYSCALL(__NR_open_tree_attr, sys_open_tree_attr)852854853855#undef __NR_syscalls854854-#define __NR_syscalls 467856856+#define __NR_syscalls 468855857856858/*857859 * 32 bit systems traditionally used different
···385385 *386386 * @sample_max_stack: Max number of frame pointers in a callchain,387387 * should be < /proc/sys/kernel/perf_event_max_stack388388+ * Max number of entries of branch stack389389+ * should be < hardware limit388390 */389391struct perf_event_attr {390392
+75-24
tools/include/uapi/linux/stat.h
···9898 */9999struct statx {100100 /* 0x00 */101101- __u32 stx_mask; /* What results were written [uncond] */102102- __u32 stx_blksize; /* Preferred general I/O size [uncond] */103103- __u64 stx_attributes; /* Flags conveying information about the file [uncond] */101101+ /* What results were written [uncond] */102102+ __u32 stx_mask;103103+104104+ /* Preferred general I/O size [uncond] */105105+ __u32 stx_blksize;106106+107107+ /* Flags conveying information about the file [uncond] */108108+ __u64 stx_attributes;109109+104110 /* 0x10 */105105- __u32 stx_nlink; /* Number of hard links */106106- __u32 stx_uid; /* User ID of owner */107107- __u32 stx_gid; /* Group ID of owner */108108- __u16 stx_mode; /* File mode */111111+ /* Number of hard links */112112+ __u32 stx_nlink;113113+114114+ /* User ID of owner */115115+ __u32 stx_uid;116116+117117+ /* Group ID of owner */118118+ __u32 stx_gid;119119+120120+ /* File mode */121121+ __u16 stx_mode;109122 __u16 __spare0[1];123123+110124 /* 0x20 */111111- __u64 stx_ino; /* Inode number */112112- __u64 stx_size; /* File size */113113- __u64 stx_blocks; /* Number of 512-byte blocks allocated */114114- __u64 stx_attributes_mask; /* Mask to show what's supported in stx_attributes */125125+ /* Inode number */126126+ __u64 stx_ino;127127+128128+ /* File size */129129+ __u64 stx_size;130130+131131+ /* Number of 512-byte blocks allocated */132132+ __u64 stx_blocks;133133+134134+ /* Mask to show what's supported in stx_attributes */135135+ __u64 stx_attributes_mask;136136+115137 /* 0x40 */116116- struct statx_timestamp stx_atime; /* Last access time */117117- struct statx_timestamp stx_btime; /* File creation time */118118- struct statx_timestamp stx_ctime; /* Last attribute change time */119119- struct statx_timestamp stx_mtime; /* Last data modification time */138138+ /* Last access time */139139+ struct statx_timestamp stx_atime;140140+141141+ /* File creation time */142142+ struct statx_timestamp stx_btime;143143+144144+ /* Last attribute change time */145145+ struct statx_timestamp stx_ctime;146146+147147+ /* Last data modification time */148148+ struct statx_timestamp stx_mtime;149149+120150 /* 0x80 */121121- __u32 stx_rdev_major; /* Device ID of special file [if bdev/cdev] */151151+ /* Device ID of special file [if bdev/cdev] */152152+ __u32 stx_rdev_major;122153 __u32 stx_rdev_minor;123123- __u32 stx_dev_major; /* ID of device containing file [uncond] */154154+155155+ /* ID of device containing file [uncond] */156156+ __u32 stx_dev_major;124157 __u32 stx_dev_minor;158158+125159 /* 0x90 */126160 __u64 stx_mnt_id;127127- __u32 stx_dio_mem_align; /* Memory buffer alignment for direct I/O */128128- __u32 stx_dio_offset_align; /* File offset alignment for direct I/O */161161+162162+ /* Memory buffer alignment for direct I/O */163163+ __u32 stx_dio_mem_align;164164+165165+ /* File offset alignment for direct I/O */166166+ __u32 stx_dio_offset_align;167167+129168 /* 0xa0 */130130- __u64 stx_subvol; /* Subvolume identifier */131131- __u32 stx_atomic_write_unit_min; /* Min atomic write unit in bytes */132132- __u32 stx_atomic_write_unit_max; /* Max atomic write unit in bytes */169169+ /* Subvolume identifier */170170+ __u64 stx_subvol;171171+172172+ /* Min atomic write unit in bytes */173173+ __u32 stx_atomic_write_unit_min;174174+175175+ /* Max atomic write unit in bytes */176176+ __u32 stx_atomic_write_unit_max;177177+133178 /* 0xb0 */134134- __u32 stx_atomic_write_segments_max; /* Max atomic write segment count */135135- __u32 __spare1[1];179179+ /* Max atomic write segment count */180180+ __u32 stx_atomic_write_segments_max;181181+182182+ /* File offset alignment for direct I/O reads */183183+ __u32 stx_dio_read_offset_align;184184+136185 /* 0xb8 */137186 __u64 __spare3[9]; /* Spare space for future expansion */187187+138188 /* 0x100 */139189};140190···214164#define STATX_MNT_ID_UNIQUE 0x00004000U /* Want/got extended stx_mount_id */215165#define STATX_SUBVOL 0x00008000U /* Want/got stx_subvol */216166#define STATX_WRITE_ATOMIC 0x00010000U /* Want/got atomic_write_* fields */167167+#define STATX_DIO_READ_ALIGN 0x00020000U /* Want/got dio read alignment info */217168218169#define STATX__RESERVED 0x80000000U /* Reserved for future struct statx expansion */219170
+1
tools/perf/arch/arm/entry/syscalls/syscall.tbl
···481481464 common getxattrat sys_getxattrat482482465 common listxattrat sys_listxattrat483483466 common removexattrat sys_removexattrat484484+467 common open_tree_attr sys_open_tree_attr
···557557464 common getxattrat sys_getxattrat558558465 common listxattrat sys_listxattrat559559466 common removexattrat sys_removexattrat560560+467 common open_tree_attr sys_open_tree_attr
+1
tools/perf/arch/s390/entry/syscalls/syscall.tbl
···469469464 common getxattrat sys_getxattrat sys_getxattrat470470465 common listxattrat sys_listxattrat sys_listxattrat471471466 common removexattrat sys_removexattrat sys_removexattrat472472+467 common open_tree_attr sys_open_tree_attr sys_open_tree_attr
+1
tools/perf/arch/sh/entry/syscalls/syscall.tbl
···470470464 common getxattrat sys_getxattrat471471465 common listxattrat sys_listxattrat472472466 common removexattrat sys_removexattrat473473+467 common open_tree_attr sys_open_tree_attr
+1
tools/perf/arch/sparc/entry/syscalls/syscall.tbl
···512512464 common getxattrat sys_getxattrat513513465 common listxattrat sys_listxattrat514514466 common removexattrat sys_removexattrat515515+467 common open_tree_attr sys_open_tree_attr
···390390464 common getxattrat sys_getxattrat391391465 common listxattrat sys_listxattrat392392466 common removexattrat sys_removexattrat393393+467 common open_tree_attr sys_open_tree_attr393394394395#395396# Due to a historical design error, certain syscalls are numbered differently
+1
tools/perf/arch/xtensa/entry/syscalls/syscall.tbl
···437437464 common getxattrat sys_getxattrat438438465 common listxattrat sys_listxattrat439439466 common removexattrat sys_removexattrat440440+467 common open_tree_attr sys_open_tree_attr
···392392393393extern int move_addr_to_kernel(void __user *uaddr, int ulen, struct sockaddr_storage *kaddr);394394extern int put_cmsg(struct msghdr*, int level, int type, int len, void *data);395395+extern int put_cmsg_notrunc(struct msghdr *msg, int level, int type, int len,396396+ void *data);395397396398struct timespec64;397399struct __kernel_timespec;
···155155#define AT_HANDLE_MNT_ID_UNIQUE 0x001 /* Return the u64 unique mount ID. */156156#define AT_HANDLE_CONNECTABLE 0x002 /* Request a connectable file handle */157157158158+/* Flags for execveat2(2). */159159+#define AT_EXECVE_CHECK 0x10000 /* Only perform a check if execution160160+ would be allowed. */161161+158162#endif /* _UAPI_LINUX_FCNTL_H */
+16-5
tools/perf/trace/beauty/include/uapi/linux/fs.h
···4040#define BLOCK_SIZE_BITS 104141#define BLOCK_SIZE (1<<BLOCK_SIZE_BITS)42424343+/* flags for integrity meta */4444+#define IO_INTEGRITY_CHK_GUARD (1U << 0) /* enforce guard check */4545+#define IO_INTEGRITY_CHK_REFTAG (1U << 1) /* enforce ref check */4646+#define IO_INTEGRITY_CHK_APPTAG (1U << 2) /* enforce app check */4747+4848+#define IO_INTEGRITY_VALID_FLAGS (IO_INTEGRITY_CHK_GUARD | \4949+ IO_INTEGRITY_CHK_REFTAG | \5050+ IO_INTEGRITY_CHK_APPTAG)5151+4352#define SEEK_SET 0 /* seek relative to beginning of file */4453#define SEEK_CUR 1 /* seek relative to current file position */4554#define SEEK_END 2 /* seek relative to end of file */···212203#define BLKROTATIONAL _IO(0x12,126)213204#define BLKZEROOUT _IO(0x12,127)214205#define BLKGETDISKSEQ _IOR(0x12,128,__u64)215215-/*216216- * A jump here: 130-136 are reserved for zoned block devices217217- * (see uapi/linux/blkzoned.h)218218- */206206+/* 130-136 are used by zoned block device ioctls (uapi/linux/blkzoned.h) */207207+/* 137-141 are used by blk-crypto ioctls (uapi/linux/blk-crypto.h) */219208220209#define BMAP_IOCTL 1 /* obsolete - kept for compatibility */221210#define FIBMAP _IO(0x00,1) /* bmap access */···339332/* Atomic Write */340333#define RWF_ATOMIC ((__force __kernel_rwf_t)0x00000040)341334335335+/* buffered IO that drops the cache after reading or writing data */336336+#define RWF_DONTCACHE ((__force __kernel_rwf_t)0x00000080)337337+342338/* mask of flags supported by the kernel */343339#define RWF_SUPPORTED (RWF_HIPRI | RWF_DSYNC | RWF_SYNC | RWF_NOWAIT |\344344- RWF_APPEND | RWF_NOAPPEND | RWF_ATOMIC)340340+ RWF_APPEND | RWF_NOAPPEND | RWF_ATOMIC |\341341+ RWF_DONTCACHE)345342346343#define PROCFS_IOCTL_MAGIC 'f'347344
···353353 */354354#define PR_LOCK_SHADOW_STACK_STATUS 76355355356356+/*357357+ * Controls the mode of timer_create() for CRIU restore operations.358358+ * Enabling this allows CRIU to restore timers with explicit IDs.359359+ *360360+ * Don't use for normal operations as the result might be undefined.361361+ */362362+#define PR_TIMER_CREATE_RESTORE_IDS 77363363+# define PR_TIMER_CREATE_RESTORE_IDS_OFF 0364364+# define PR_TIMER_CREATE_RESTORE_IDS_ON 1365365+# define PR_TIMER_CREATE_RESTORE_IDS_GET 2366366+356367#endif /* _LINUX_PRCTL_H */
+75-24
tools/perf/trace/beauty/include/uapi/linux/stat.h
···9898 */9999struct statx {100100 /* 0x00 */101101- __u32 stx_mask; /* What results were written [uncond] */102102- __u32 stx_blksize; /* Preferred general I/O size [uncond] */103103- __u64 stx_attributes; /* Flags conveying information about the file [uncond] */101101+ /* What results were written [uncond] */102102+ __u32 stx_mask;103103+104104+ /* Preferred general I/O size [uncond] */105105+ __u32 stx_blksize;106106+107107+ /* Flags conveying information about the file [uncond] */108108+ __u64 stx_attributes;109109+104110 /* 0x10 */105105- __u32 stx_nlink; /* Number of hard links */106106- __u32 stx_uid; /* User ID of owner */107107- __u32 stx_gid; /* Group ID of owner */108108- __u16 stx_mode; /* File mode */111111+ /* Number of hard links */112112+ __u32 stx_nlink;113113+114114+ /* User ID of owner */115115+ __u32 stx_uid;116116+117117+ /* Group ID of owner */118118+ __u32 stx_gid;119119+120120+ /* File mode */121121+ __u16 stx_mode;109122 __u16 __spare0[1];123123+110124 /* 0x20 */111111- __u64 stx_ino; /* Inode number */112112- __u64 stx_size; /* File size */113113- __u64 stx_blocks; /* Number of 512-byte blocks allocated */114114- __u64 stx_attributes_mask; /* Mask to show what's supported in stx_attributes */125125+ /* Inode number */126126+ __u64 stx_ino;127127+128128+ /* File size */129129+ __u64 stx_size;130130+131131+ /* Number of 512-byte blocks allocated */132132+ __u64 stx_blocks;133133+134134+ /* Mask to show what's supported in stx_attributes */135135+ __u64 stx_attributes_mask;136136+115137 /* 0x40 */116116- struct statx_timestamp stx_atime; /* Last access time */117117- struct statx_timestamp stx_btime; /* File creation time */118118- struct statx_timestamp stx_ctime; /* Last attribute change time */119119- struct statx_timestamp stx_mtime; /* Last data modification time */138138+ /* Last access time */139139+ struct statx_timestamp stx_atime;140140+141141+ /* File creation time */142142+ struct statx_timestamp stx_btime;143143+144144+ /* Last attribute change time */145145+ struct statx_timestamp stx_ctime;146146+147147+ /* Last data modification time */148148+ struct statx_timestamp stx_mtime;149149+120150 /* 0x80 */121121- __u32 stx_rdev_major; /* Device ID of special file [if bdev/cdev] */151151+ /* Device ID of special file [if bdev/cdev] */152152+ __u32 stx_rdev_major;122153 __u32 stx_rdev_minor;123123- __u32 stx_dev_major; /* ID of device containing file [uncond] */154154+155155+ /* ID of device containing file [uncond] */156156+ __u32 stx_dev_major;124157 __u32 stx_dev_minor;158158+125159 /* 0x90 */126160 __u64 stx_mnt_id;127127- __u32 stx_dio_mem_align; /* Memory buffer alignment for direct I/O */128128- __u32 stx_dio_offset_align; /* File offset alignment for direct I/O */161161+162162+ /* Memory buffer alignment for direct I/O */163163+ __u32 stx_dio_mem_align;164164+165165+ /* File offset alignment for direct I/O */166166+ __u32 stx_dio_offset_align;167167+129168 /* 0xa0 */130130- __u64 stx_subvol; /* Subvolume identifier */131131- __u32 stx_atomic_write_unit_min; /* Min atomic write unit in bytes */132132- __u32 stx_atomic_write_unit_max; /* Max atomic write unit in bytes */169169+ /* Subvolume identifier */170170+ __u64 stx_subvol;171171+172172+ /* Min atomic write unit in bytes */173173+ __u32 stx_atomic_write_unit_min;174174+175175+ /* Max atomic write unit in bytes */176176+ __u32 stx_atomic_write_unit_max;177177+133178 /* 0xb0 */134134- __u32 stx_atomic_write_segments_max; /* Max atomic write segment count */135135- __u32 __spare1[1];179179+ /* Max atomic write segment count */180180+ __u32 stx_atomic_write_segments_max;181181+182182+ /* File offset alignment for direct I/O reads */183183+ __u32 stx_dio_read_offset_align;184184+136185 /* 0xb8 */137186 __u64 __spare3[9]; /* Spare space for future expansion */187187+138188 /* 0x100 */139189};140190···214164#define STATX_MNT_ID_UNIQUE 0x00004000U /* Want/got extended stx_mount_id */215165#define STATX_SUBVOL 0x00008000U /* Want/got stx_subvol */216166#define STATX_WRITE_ATOMIC 0x00010000U /* Want/got atomic_write_* fields */167167+#define STATX_DIO_READ_ALIGN 0x00020000U /* Want/got dio read alignment info */217168218169#define STATX__RESERVED 0x80000000U /* Reserved for future struct statx expansion */219170
···25662566 return false;25672567}2568256825692569-static bool evsel__handle_error_quirks(struct evsel *evsel, int error)25702570-{25712571- /*25722572- * AMD core PMU tries to forward events with precise_ip to IBS PMU25732573- * implicitly. But IBS PMU has more restrictions so it can fail with25742574- * supported event attributes. Let's forward it back to the core PMU25752575- * by clearing precise_ip only if it's from precise_max (:P).25762576- */25772577- if ((error == -EINVAL || error == -ENOENT) && x86__is_amd_cpu() &&25782578- evsel->core.attr.precise_ip && evsel->precise_max) {25792579- evsel->core.attr.precise_ip = 0;25802580- pr_debug2_peo("removing precise_ip on AMD\n");25812581- display_attr(&evsel->core.attr);25822582- return true;25832583- }25842584-25852585- return false;25862586-}25872587-25882569static int evsel__open_cpu(struct evsel *evsel, struct perf_cpu_map *cpus,25892570 struct perf_thread_map *threads,25902571 int start_cpu_map_idx, int end_cpu_map_idx)···27092728 goto fallback_missing_features;2710272927112730 if (evsel__precise_ip_fallback(evsel))27122712- goto retry_open;27132713-27142714- if (evsel__handle_error_quirks(evsel, err))27152731 goto retry_open;2716273227172733out_close:
+1-1
tools/perf/util/unwind-libunwind-local.c
···371371 * has to be pointed by symsrc_filename372372 */373373 if (ofs == 0) {374374- if (dso__data_get_fd(dso, machine, &fd) {374374+ if (dso__data_get_fd(dso, machine, &fd)) {375375 ofs = elf_section_offset(fd, ".debug_frame");376376 dso__data_put_fd(dso);377377 }
+1
tools/scripts/syscall.tbl
···407407464 common getxattrat sys_getxattrat408408465 common listxattrat sys_listxattrat409409466 common removexattrat sys_removexattrat410410+467 common open_tree_attr sys_open_tree_attr