2023-08-14 10:18:47 +02:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
|
|
|
|
#include <linux/debugfs.h>
|
|
|
|
|
|
|
|
#include <asm/apic.h>
|
|
|
|
#include <asm/processor.h>
|
|
|
|
|
2024-02-13 22:04:01 +01:00
|
|
|
#include "cpu.h"
|
|
|
|
|
2023-08-14 10:18:47 +02:00
|
|
|
static int cpu_debug_show(struct seq_file *m, void *p)
|
|
|
|
{
|
|
|
|
unsigned long cpu = (unsigned long)m->private;
|
|
|
|
struct cpuinfo_x86 *c = per_cpu_ptr(&cpu_info, cpu);
|
|
|
|
|
|
|
|
seq_printf(m, "online: %d\n", cpu_online(cpu));
|
|
|
|
if (!c->initialized)
|
|
|
|
return 0;
|
|
|
|
|
2024-12-11 22:57:24 -08:00
|
|
|
seq_printf(m, "initial_apicid: 0x%x\n", c->topo.initial_apicid);
|
|
|
|
seq_printf(m, "apicid: 0x%x\n", c->topo.apicid);
|
2023-08-14 10:18:47 +02:00
|
|
|
seq_printf(m, "pkg_id: %u\n", c->topo.pkg_id);
|
|
|
|
seq_printf(m, "die_id: %u\n", c->topo.die_id);
|
|
|
|
seq_printf(m, "cu_id: %u\n", c->topo.cu_id);
|
|
|
|
seq_printf(m, "core_id: %u\n", c->topo.core_id);
|
x86/cpu: Add CPU type to struct cpuinfo_topology
Sometimes it is required to take actions based on if a CPU is a performance or
efficiency core. As an example, intel_pstate driver uses the Intel core-type
to determine CPU scaling. Also, some CPU vulnerabilities only affect
a specific CPU type, like RFDS only affects Intel Atom. Hybrid systems that
have variants P+E, P-only(Core) and E-only(Atom), it is not straightforward to
identify which variant is affected by a type specific vulnerability.
Such processors do have CPUID field that can uniquely identify them. Like,
P+E, P-only and E-only enumerates CPUID.1A.CORE_TYPE identification, while P+E
additionally enumerates CPUID.7.HYBRID. Based on this information, it is
possible for boot CPU to identify if a system has mixed CPU types.
Add a new field hw_cpu_type to struct cpuinfo_topology that stores the
hardware specific CPU type. This saves the overhead of IPIs to get the CPU
type of a different CPU. CPU type is populated early in the boot process,
before vulnerabilities are enumerated.
Signed-off-by: Pawan Gupta <pawan.kumar.gupta@linux.intel.com>
Co-developed-by: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Acked-by: Dave Hansen <dave.hansen@linux.intel.com>
Link: https://lore.kernel.org/r/20241025171459.1093-5-mario.limonciello@amd.com
2024-10-25 12:14:58 -05:00
|
|
|
seq_printf(m, "cpu_type: %s\n", get_topology_cpu_type_name(c));
|
2023-08-14 10:18:47 +02:00
|
|
|
seq_printf(m, "logical_pkg_id: %u\n", c->topo.logical_pkg_id);
|
|
|
|
seq_printf(m, "logical_die_id: %u\n", c->topo.logical_die_id);
|
2024-11-15 06:07:58 +00:00
|
|
|
seq_printf(m, "logical_core_id: %u\n", c->topo.logical_core_id);
|
2023-08-14 10:18:47 +02:00
|
|
|
seq_printf(m, "llc_id: %u\n", c->topo.llc_id);
|
|
|
|
seq_printf(m, "l2c_id: %u\n", c->topo.l2c_id);
|
2024-02-13 22:04:11 +01:00
|
|
|
seq_printf(m, "amd_node_id: %u\n", c->topo.amd_node_id);
|
|
|
|
seq_printf(m, "amd_nodes_per_pkg: %u\n", topology_amd_nodes_per_pkg());
|
2024-02-13 22:06:16 +01:00
|
|
|
seq_printf(m, "num_threads: %u\n", __num_threads_per_package);
|
|
|
|
seq_printf(m, "num_cores: %u\n", __num_cores_per_package);
|
2024-02-13 22:06:03 +01:00
|
|
|
seq_printf(m, "max_dies_per_pkg: %u\n", __max_dies_per_package);
|
2024-02-13 22:06:12 +01:00
|
|
|
seq_printf(m, "max_threads_per_core:%u\n", __max_threads_per_core);
|
2023-08-14 10:18:47 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int cpu_debug_open(struct inode *inode, struct file *file)
|
|
|
|
{
|
|
|
|
return single_open(file, cpu_debug_show, inode->i_private);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct file_operations dfs_cpu_ops = {
|
|
|
|
.open = cpu_debug_open,
|
|
|
|
.read = seq_read,
|
|
|
|
.llseek = seq_lseek,
|
|
|
|
.release = single_release,
|
|
|
|
};
|
|
|
|
|
2024-02-13 22:04:01 +01:00
|
|
|
static int dom_debug_show(struct seq_file *m, void *p)
|
|
|
|
{
|
|
|
|
static const char *domain_names[TOPO_MAX_DOMAIN] = {
|
|
|
|
[TOPO_SMT_DOMAIN] = "Thread",
|
|
|
|
[TOPO_CORE_DOMAIN] = "Core",
|
|
|
|
[TOPO_MODULE_DOMAIN] = "Module",
|
|
|
|
[TOPO_TILE_DOMAIN] = "Tile",
|
|
|
|
[TOPO_DIE_DOMAIN] = "Die",
|
|
|
|
[TOPO_DIEGRP_DOMAIN] = "DieGrp",
|
|
|
|
[TOPO_PKG_DOMAIN] = "Package",
|
|
|
|
};
|
|
|
|
unsigned int dom, nthreads = 1;
|
|
|
|
|
|
|
|
for (dom = 0; dom < TOPO_MAX_DOMAIN; dom++) {
|
|
|
|
nthreads *= x86_topo_system.dom_size[dom];
|
|
|
|
seq_printf(m, "domain: %-10s shift: %u dom_size: %5u max_threads: %5u\n",
|
|
|
|
domain_names[dom], x86_topo_system.dom_shifts[dom],
|
|
|
|
x86_topo_system.dom_size[dom], nthreads);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int dom_debug_open(struct inode *inode, struct file *file)
|
|
|
|
{
|
|
|
|
return single_open(file, dom_debug_show, inode->i_private);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct file_operations dfs_dom_ops = {
|
|
|
|
.open = dom_debug_open,
|
|
|
|
.read = seq_read,
|
|
|
|
.llseek = seq_lseek,
|
|
|
|
.release = single_release,
|
|
|
|
};
|
|
|
|
|
2023-08-14 10:18:47 +02:00
|
|
|
static __init int cpu_init_debugfs(void)
|
|
|
|
{
|
|
|
|
struct dentry *dir, *base = debugfs_create_dir("topo", arch_debugfs_dir);
|
|
|
|
unsigned long id;
|
|
|
|
char name[24];
|
|
|
|
|
2024-02-13 22:04:01 +01:00
|
|
|
debugfs_create_file("domains", 0444, base, NULL, &dfs_dom_ops);
|
|
|
|
|
2023-08-14 10:18:47 +02:00
|
|
|
dir = debugfs_create_dir("cpus", base);
|
|
|
|
for_each_possible_cpu(id) {
|
|
|
|
sprintf(name, "%lu", id);
|
|
|
|
debugfs_create_file(name, 0444, dir, (void *)id, &dfs_cpu_ops);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
late_initcall(cpu_init_debugfs);
|