Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
7d04aec
hwmon: (fam15h_power) Use topology_core_id()
KAGA-KOKO Aug 14, 2023
e28484f
x86/cpu: Move cpu_core_id into topology info
KAGA-KOKO Aug 14, 2023
234b9f4
x86/cpu: Move cu_id into topology info
KAGA-KOKO Aug 14, 2023
426bae9
x86/cpu: Remove pointless evaluation of x86_coreid_bits
KAGA-KOKO Aug 14, 2023
5a7a9f0
x86/cpu: Move logical package and die IDs into topology info
KAGA-KOKO Aug 14, 2023
67b9a75
x86/cpu: Move cpu_l[l2]c_id into topology info
KAGA-KOKO Aug 14, 2023
349c3e9
x86/apic: Use BAD_APICID consistently
KAGA-KOKO Aug 14, 2023
9e98b59
x86/apic: Use u32 for APIC IDs in global data
KAGA-KOKO Aug 14, 2023
44ba40b
x86/apic: Use u32 for check_apicid_used()
KAGA-KOKO Aug 14, 2023
e29b3e1
x86/apic: Use u32 for cpu_present_to_apicid()
KAGA-KOKO Aug 14, 2023
4eca1b0
x86/apic: Use u32 for phys_pkg_id()
KAGA-KOKO Aug 14, 2023
655645a
x86/apic: Use u32 for [gs]et_apic_id()
KAGA-KOKO Aug 14, 2023
c139358
x86/apic, x86/hyperv: Use u32 in hv_snp_boot_ap() too
Oct 13, 2023
537ea55
x86/apic: Use u32 for wakeup_secondary_cpu[_64]()
KAGA-KOKO Aug 14, 2023
eaa55af
x86/cpu/topology: Cure the abuse of cpuinfo for persisting logical ids
KAGA-KOKO Aug 14, 2023
d67fe5c
x86/cpu: Provide debug interface
KAGA-KOKO Aug 14, 2023
fc47edb
x86/cpu: Provide cpuid_read() et al.
KAGA-KOKO Feb 14, 2024
ff8cd17
x86/cpuid: Include <linux/build_bug.h> in <asm/cpuid.h>
Mar 4, 2025
db3b630
x86/cpu: Provide cpu_init/parse_topology()
KAGA-KOKO Feb 13, 2024
a686ce2
x86/cpu: Add legacy topology parser
KAGA-KOKO Feb 13, 2024
18c15cc
x86/cpu: Use common topology code for Centaur and Zhaoxin
KAGA-KOKO Feb 13, 2024
d077676
x86/cpu: Move __max_die_per_package to common.c
KAGA-KOKO Feb 13, 2024
a37ed92
x86/cpu: Provide a sane leaf 0xb/0x1f parser
KAGA-KOKO Feb 13, 2024
8721dcd
x86/cpu: Use common topology code for Intel
KAGA-KOKO Feb 13, 2024
2fa0401
x86/topology/intel: Unlock CPUID before evaluating anything
KAGA-KOKO May 30, 2024
9ec594b
x86/cpu: Provide an AMD/HYGON specific topology parser
KAGA-KOKO Feb 13, 2024
e449ffa
x86/cpu/amd: Make the CPUID 0x80000008 parser correct
KAGA-KOKO Apr 10, 2024
2544fd5
x86/cpu/amd: Make the NODEID_MSR union actually work
KAGA-KOKO Apr 10, 2024
23d28d2
x86/cpu/amd: Move TOPOEXT enablement into the topology parser
KAGA-KOKO Apr 11, 2024
5302eb5
x86/topology/amd: Ensure that LLC ID is initialized
KAGA-KOKO May 8, 2024
fa1a39d
x86/topology/amd: Evaluate SMT in CPUID leaf 0x8000001e only on famil…
KAGA-KOKO May 28, 2024
cbba3cc
x86/smpboot: Teach it about topo.amd_node_id
KAGA-KOKO Feb 13, 2024
6133835
x86/cpu: Use common topology code for AMD
KAGA-KOKO Feb 13, 2024
70f7572
x86/cpu: Use common topology code for HYGON
KAGA-KOKO Feb 13, 2024
ac8dd1c
x86/mm/numa: Use core domain size on AMD
KAGA-KOKO Feb 13, 2024
3fce5d9
x86/cpu: Make topology_amd_node_id() use the actual node info
KAGA-KOKO Feb 13, 2024
bed7892
x86/cpu: Remove topology.c
KAGA-KOKO Feb 13, 2024
782bea5
x86/cpu: Remove x86_coreid_bits
KAGA-KOKO Feb 13, 2024
c61ea32
x86/apic: Remove unused phys_pkg_id() callback
KAGA-KOKO Feb 13, 2024
2f6c02f
x86/xen/smp_pv: Remove cpudata fiddling
KAGA-KOKO Feb 13, 2024
348260f
x86/apic/uv: Remove the private leaf 0xb parser
KAGA-KOKO Feb 13, 2024
3342d78
x86/cpu: Add extenended topology function for Centaur and Zhaoxin
quanxianwang Dec 3, 2025
a03f5f6
x86/cpu/topology: Make the APIC mismatch warnings complete
KAGA-KOKO Feb 13, 2024
7f8ce6e
x86/xen: return a sane initial apic id when running as PV guest
jgross1 Apr 5, 2024
462ea72
x86/platform/ce4100: Dont override x86_init.mpparse.setup_ioapic_ids
KAGA-KOKO Feb 13, 2024
dd39317
x86/ioapic: Replace some more set bit nonsense
KAGA-KOKO Feb 13, 2024
1e1996b
x86/apic: Get rid of get_physical_broadcast()
KAGA-KOKO Feb 13, 2024
14b52bc
x86/ioapic: Make io_apic_get_unique_id() simpler
KAGA-KOKO Feb 13, 2024
48e410d
x86/ioapic: Simplify setup_ioapic_ids_from_mpc_nocheck()
KAGA-KOKO Feb 13, 2024
eb8e385
x86/apic: Remove check_apicid_used() and ioapic_phys_id_map()
KAGA-KOKO Feb 13, 2024
e5efc67
x86/mpparse: Rename default_find_smp_config()
KAGA-KOKO Feb 13, 2024
2343223
x86/mpparse: Provide separate early/late callbacks
KAGA-KOKO Feb 13, 2024
6b7f9ca
x86/mpparse: Prepare for callback separation
KAGA-KOKO Feb 13, 2024
bf8ce9a
x86/dtb: Rename x86_dtb_init()
KAGA-KOKO Feb 13, 2024
fd09983
x86/platform/ce4100: Prepare for separate mpparse callbacks
KAGA-KOKO Feb 13, 2024
6bdde66
x86/platform/intel-mid: Prepare for separate mpparse callbacks
KAGA-KOKO Feb 13, 2024
665c588
x86/jailhouse: Prepare for separate mpparse callbacks
KAGA-KOKO Feb 13, 2024
3d3c143
x86/xen/smp_pv: Prepare for separate mpparse callbacks
KAGA-KOKO Feb 13, 2024
d64c153
x86/hyperv/vtl: Prepare for separate mpparse callbacks
KAGA-KOKO Feb 13, 2024
6147a40
x86/mpparse: Switch to new init callbacks
KAGA-KOKO Feb 13, 2024
8c8e729
x86/mm/numa: Move early mptable evaluation into common code
KAGA-KOKO Feb 13, 2024
7ac0c21
x86/mpparse: Remove the physid_t bitmap wrapper
KAGA-KOKO Feb 13, 2024
0f31fd2
x86/apic: Remove the pointless writeback of boot_cpu_physical_apicid
KAGA-KOKO Feb 13, 2024
bc98ece
x86/apic: Remove yet another dubious callback
KAGA-KOKO Feb 13, 2024
a4108d5
x86/apic: Use a proper define for invalid ACPI CPU ID
KAGA-KOKO Feb 13, 2024
aca4129
x86/hyperv/vtl: Correct x86_init.mpparse.parse_smp_cfg assignment
Apr 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions Documentation/arch/x86/topology.rst
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Package-related topology information in the kernel:
Modern systems use this value for the socket. There may be multiple
packages within a socket. This value may differ from topo.die_id.

- cpuinfo_x86.logical_proc_id:
- cpuinfo_x86.topo.logical_pkg_id:

The logical ID of the package. As we do not trust BIOSes to enumerate the
packages in a consistent way, we introduced the concept of logical package
Expand All @@ -79,9 +79,7 @@ Package-related topology information in the kernel:
The maximum possible number of packages in the system. Helpful for per
package facilities to preallocate per package information.

- cpu_llc_id:

A per-CPU variable containing:
- cpuinfo_x86.topo.llc_id:

- On Intel, the first APIC ID of the list of CPUs sharing the Last Level
Cache
Expand Down
2 changes: 1 addition & 1 deletion arch/x86/events/amd/uncore.c
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,7 @@ void amd_uncore_l3_ctx_scan(struct amd_uncore *uncore, unsigned int cpu)
info.split.aux_data = 0;
info.split.num_pmcs = NUM_COUNTERS_L2;
info.split.gid = 0;
info.split.cid = get_llc_id(cpu);
info.split.cid = per_cpu_llc_id(cpu);

if (boot_cpu_data.x86 >= 0x17)
info.split.num_pmcs = NUM_COUNTERS_L3;
Expand Down
2 changes: 1 addition & 1 deletion arch/x86/events/intel/uncore.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ int uncore_device_to_die(struct pci_dev *dev)
struct cpuinfo_x86 *c = &cpu_data(cpu);

if (c->initialized && cpu_to_node(cpu) == node)
return c->logical_die_id;
return c->topo.logical_die_id;
}

return -1;
Expand Down
6 changes: 3 additions & 3 deletions arch/x86/hyperv/hv_vtl.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ void __init hv_vtl_init_platform(void)
x86_init.resources.probe_roms = x86_init_noop;

/* Avoid searching for BIOS MP tables */
x86_init.mpparse.find_smp_config = x86_init_noop;
x86_init.mpparse.get_smp_config = x86_init_uint_noop;
x86_init.mpparse.find_mptable = x86_init_noop;
x86_init.mpparse.early_parse_smp_cfg = x86_init_noop;

x86_platform.get_wallclock = get_rtc_noop;
x86_platform.set_wallclock = set_rtc_noop;
Expand Down Expand Up @@ -207,7 +207,7 @@ static int hv_vtl_apicid_to_vp_id(u32 apic_id)
return ret;
}

static int hv_vtl_wakeup_secondary_cpu(int apicid, unsigned long start_eip)
static int hv_vtl_wakeup_secondary_cpu(u32 apicid, unsigned long start_eip)
{
int vp_id, cpu;

Expand Down
2 changes: 1 addition & 1 deletion arch/x86/hyperv/ivm.c
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ static void snp_cleanup_vmsa(struct sev_es_save_area *vmsa)
free_page((unsigned long)vmsa);
}

int hv_snp_boot_ap(int cpu, unsigned long start_ip)
int hv_snp_boot_ap(u32 cpu, unsigned long start_ip)
{
struct sev_es_save_area *vmsa = (struct sev_es_save_area *)
__get_free_page(GFP_KERNEL | __GFP_ZERO);
Expand Down
43 changes: 14 additions & 29 deletions arch/x86/include/asm/apic.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ extern void x86_32_probe_apic(void);
static inline void x86_32_probe_apic(void) { }
#endif

extern u32 cpuid_to_apicid[];

#define CPU_ACPIID_INVALID U32_MAX

#ifdef CONFIG_X86_LOCAL_APIC

extern int apic_verbosity;
Expand All @@ -55,8 +59,6 @@ extern int local_apic_timer_c2_ok;
extern bool apic_is_disabled;
extern unsigned int lapic_timer_period;

extern int cpuid_to_apicid[];

extern enum apic_intr_mode_id apic_intr_mode;
enum apic_intr_mode_id {
APIC_PIC,
Expand Down Expand Up @@ -292,21 +294,16 @@ struct apic {
/* Probe, setup and smpboot functions */
int (*probe)(void);
int (*acpi_madt_oem_check)(char *oem_id, char *oem_table_id);
bool (*apic_id_registered)(void);

bool (*check_apicid_used)(physid_mask_t *map, int apicid);
void (*init_apic_ldr)(void);
void (*ioapic_phys_id_map)(physid_mask_t *phys_map, physid_mask_t *retmap);
int (*cpu_present_to_apicid)(int mps_cpu);
int (*phys_pkg_id)(int cpuid_apic, int index_msb);
u32 (*cpu_present_to_apicid)(int mps_cpu);

u32 (*get_apic_id)(unsigned long x);
u32 (*set_apic_id)(unsigned int id);
u32 (*get_apic_id)(u32 id);

/* wakeup_secondary_cpu */
int (*wakeup_secondary_cpu)(int apicid, unsigned long start_eip);
int (*wakeup_secondary_cpu)(u32 apicid, unsigned long start_eip);
/* wakeup secondary CPU using 64-bit wakeup point */
int (*wakeup_secondary_cpu_64)(int apicid, unsigned long start_eip);
int (*wakeup_secondary_cpu_64)(u32 apicid, unsigned long start_eip);

char *name;
};
Expand All @@ -324,8 +321,8 @@ struct apic_override {
void (*send_IPI_self)(int vector);
u64 (*icr_read)(void);
void (*icr_write)(u32 low, u32 high);
int (*wakeup_secondary_cpu)(int apicid, unsigned long start_eip);
int (*wakeup_secondary_cpu_64)(int apicid, unsigned long start_eip);
int (*wakeup_secondary_cpu)(u32 apicid, unsigned long start_eip);
int (*wakeup_secondary_cpu_64)(u32 apicid, unsigned long start_eip);
};

/*
Expand Down Expand Up @@ -495,16 +492,6 @@ static inline bool lapic_vector_set_in_irr(unsigned int vector)
return !!(irr & (1U << (vector % 32)));
}

static inline unsigned default_get_apic_id(unsigned long x)
{
unsigned int ver = GET_APIC_VERSION(apic_read(APIC_LVR));

if (APIC_XAPIC(ver) || boot_cpu_has(X86_FEATURE_EXTD_APICID))
return (x >> 24) & 0xFF;
else
return (x >> 24) & 0x0F;
}

/*
* Warm reset vector position:
*/
Expand All @@ -519,9 +506,9 @@ extern void generic_bigsmp_probe(void);

extern struct apic apic_noop;

static inline unsigned int read_apic_id(void)
static inline u32 read_apic_id(void)
{
unsigned int reg = apic_read(APIC_ID);
u32 reg = apic_read(APIC_ID);

return apic->get_apic_id(reg);
}
Expand All @@ -540,15 +527,13 @@ extern int default_apic_id_valid(u32 apicid);
extern u32 apic_default_calc_apicid(unsigned int cpu);
extern u32 apic_flat_calc_apicid(unsigned int cpu);

extern bool default_check_apicid_used(physid_mask_t *map, int apicid);
extern void default_ioapic_phys_id_map(physid_mask_t *phys_map, physid_mask_t *retmap);
extern int default_cpu_present_to_apicid(int mps_cpu);
extern u32 default_cpu_present_to_apicid(int mps_cpu);

void apic_send_nmi_to_offline_cpu(unsigned int cpu);

#else /* CONFIG_X86_LOCAL_APIC */

static inline unsigned int read_apic_id(void) { return 0; }
static inline u32 read_apic_id(void) { return 0; }

#endif /* !CONFIG_X86_LOCAL_APIC */

Expand Down
3 changes: 0 additions & 3 deletions arch/x86/include/asm/cacheinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ extern unsigned int memory_caching_control;
#define CACHE_MTRR 0x01
#define CACHE_PAT 0x02

void cacheinfo_amd_init_llc_id(struct cpuinfo_x86 *c, int cpu);
void cacheinfo_hygon_init_llc_id(struct cpuinfo_x86 *c, int cpu);

void cache_disable(void);
void cache_enable(void);
void set_cache_aps_delayed_init(bool val);
Expand Down
37 changes: 37 additions & 0 deletions arch/x86/include/asm/cpuid.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#ifndef _ASM_X86_CPUID_H
#define _ASM_X86_CPUID_H

#include <linux/build_bug.h>
#include <asm/string.h>

struct cpuid_regs {
Expand Down Expand Up @@ -127,6 +128,42 @@ static inline unsigned int cpuid_edx(unsigned int op)
return edx;
}

static inline void __cpuid_read(unsigned int leaf, unsigned int subleaf, u32 *regs)
{
regs[CPUID_EAX] = leaf;
regs[CPUID_ECX] = subleaf;
__cpuid(regs + CPUID_EAX, regs + CPUID_EBX, regs + CPUID_ECX, regs + CPUID_EDX);
}

#define cpuid_subleaf(leaf, subleaf, regs) { \
static_assert(sizeof(*(regs)) == 16); \
__cpuid_read(leaf, subleaf, (u32 *)(regs)); \
}

#define cpuid_leaf(leaf, regs) { \
static_assert(sizeof(*(regs)) == 16); \
__cpuid_read(leaf, 0, (u32 *)(regs)); \
}

static inline void __cpuid_read_reg(unsigned int leaf, unsigned int subleaf,
enum cpuid_regs_idx regidx, u32 *reg)
{
u32 regs[4];

__cpuid_read(leaf, subleaf, regs);
*reg = regs[regidx];
}

#define cpuid_subleaf_reg(leaf, subleaf, regidx, reg) { \
static_assert(sizeof(*(reg)) == 4); \
__cpuid_read_reg(leaf, subleaf, regidx, (u32 *)(reg)); \
}

#define cpuid_leaf_reg(leaf, regidx, reg) { \
static_assert(sizeof(*(reg)) == 4); \
__cpuid_read_reg(leaf, 0, regidx, (u32 *)(reg)); \
}

static __always_inline bool cpuid_function_is_indexed(u32 function)
{
switch (function) {
Expand Down
1 change: 0 additions & 1 deletion arch/x86/include/asm/io_apic.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ extern void mask_ioapic_entries(void);
extern int restore_ioapic_entries(void);

extern void setup_ioapic_ids_from_mpc(void);
extern void setup_ioapic_ids_from_mpc_nocheck(void);

extern int mp_find_ioapic(u32 gsi);
extern int mp_find_ioapic_pin(int ioapic, u32 gsi);
Expand Down
66 changes: 15 additions & 51 deletions arch/x86/include/asm/mpspec.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#ifndef _ASM_X86_MPSPEC_H
#define _ASM_X86_MPSPEC_H

#include <linux/types.h>

#include <asm/mpspec_def.h>
#include <asm/x86_init.h>
Expand Down Expand Up @@ -37,7 +38,7 @@ extern int mp_bus_id_to_type[MAX_MP_BUSSES];

extern DECLARE_BITMAP(mp_bus_not_pci, MAX_MP_BUSSES);

extern unsigned int boot_cpu_physical_apicid;
extern u32 boot_cpu_physical_apicid;
extern u8 boot_cpu_apic_version;

#ifdef CONFIG_X86_LOCAL_APIC
Expand All @@ -46,70 +47,33 @@ extern int smp_found_config;
# define smp_found_config 0
#endif

static inline void get_smp_config(void)
{
x86_init.mpparse.get_smp_config(0);
}

static inline void early_get_smp_config(void)
{
x86_init.mpparse.get_smp_config(1);
}

static inline void find_smp_config(void)
{
x86_init.mpparse.find_smp_config();
}

#ifdef CONFIG_X86_MPPARSE
extern void e820__memblock_alloc_reserved_mpc_new(void);
extern int enable_update_mptable;
extern void default_find_smp_config(void);
extern void default_get_smp_config(unsigned int early);
extern void mpparse_find_mptable(void);
extern void mpparse_parse_early_smp_config(void);
extern void mpparse_parse_smp_config(void);
#else
static inline void e820__memblock_alloc_reserved_mpc_new(void) { }
#define enable_update_mptable 0
#define default_find_smp_config x86_init_noop
#define default_get_smp_config x86_init_uint_noop
#define enable_update_mptable 0
#define mpparse_find_mptable x86_init_noop
#define mpparse_parse_early_smp_config x86_init_noop
#define mpparse_parse_smp_config x86_init_noop
#endif

int generic_processor_info(int apicid);

#define PHYSID_ARRAY_SIZE BITS_TO_LONGS(MAX_LOCAL_APIC)
extern DECLARE_BITMAP(phys_cpu_present_map, MAX_LOCAL_APIC);

struct physid_mask {
unsigned long mask[PHYSID_ARRAY_SIZE];
};

typedef struct physid_mask physid_mask_t;

#define physid_set(physid, map) set_bit(physid, (map).mask)
#define physid_isset(physid, map) test_bit(physid, (map).mask)

#define physids_or(dst, src1, src2) \
bitmap_or((dst).mask, (src1).mask, (src2).mask, MAX_LOCAL_APIC)

#define physids_clear(map) \
bitmap_zero((map).mask, MAX_LOCAL_APIC)

#define physids_empty(map) \
bitmap_empty((map).mask, MAX_LOCAL_APIC)

static inline void physids_promote(unsigned long physids, physid_mask_t *map)
static inline void reset_phys_cpu_present_map(u32 apicid)
{
physids_clear(*map);
map->mask[0] = physids;
bitmap_zero(phys_cpu_present_map, MAX_LOCAL_APIC);
set_bit(apicid, phys_cpu_present_map);
}

static inline void physid_set_mask_of_physid(int physid, physid_mask_t *map)
static inline void copy_phys_cpu_present_map(unsigned long *dst)
{
physids_clear(*map);
physid_set(physid, *map);
bitmap_copy(dst, phys_cpu_present_map, MAX_LOCAL_APIC);
}

#define PHYSID_MASK_ALL { {[0 ... PHYSID_ARRAY_SIZE-1] = ~0UL} }
#define PHYSID_MASK_NONE { {[0 ... PHYSID_ARRAY_SIZE-1] = 0UL} }

extern physid_mask_t phys_cpu_present_map;

#endif /* _ASM_X86_MPSPEC_H */
4 changes: 2 additions & 2 deletions arch/x86/include/asm/mshyperv.h
Original file line number Diff line number Diff line change
Expand Up @@ -275,11 +275,11 @@ int hv_unmap_ioapic_interrupt(int ioapic_id, struct hv_interrupt_entry *entry);
#ifdef CONFIG_AMD_MEM_ENCRYPT
bool hv_ghcb_negotiate_protocol(void);
void __noreturn hv_ghcb_terminate(unsigned int set, unsigned int reason);
int hv_snp_boot_ap(int cpu, unsigned long start_ip);
int hv_snp_boot_ap(u32 cpu, unsigned long start_ip);
#else
static inline bool hv_ghcb_negotiate_protocol(void) { return false; }
static inline void hv_ghcb_terminate(unsigned int set, unsigned int reason) {}
static inline int hv_snp_boot_ap(int cpu, unsigned long start_ip) { return 0; }
static inline int hv_snp_boot_ap(u32 cpu, unsigned long start_ip) { return 0; }
#endif

#if defined(CONFIG_AMD_MEM_ENCRYPT) || defined(CONFIG_INTEL_TDX_GUEST)
Expand Down
Loading