Skip to content

Commit 7211274

Browse files
KAGA-KOKOIngo Molnar
authored andcommitted
x86/cpu/amd: Move TOPOEXT enablement into the topology parser
The topology rework missed that early_init_amd() tries to re-enable the Topology Extensions when the BIOS disabled them. The new parser is invoked before early_init_amd() so the re-enable attempt happens too late. Move it into the AMD specific topology parser code where it belongs. Fixes: f7fb3b2 ("x86/cpu: Provide an AMD/HYGON specific topology parser") Signed-off-by: Thomas Gleixner <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Link: https://lore.kernel.org/r/878r1j260l.ffs@tglx
1 parent c064b53 commit 7211274

File tree

2 files changed

+21
-15
lines changed

2 files changed

+21
-15
lines changed

arch/x86/kernel/cpu/amd.c

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,6 @@ static void early_detect_mem_encrypt(struct cpuinfo_x86 *c)
535535

536536
static void early_init_amd(struct cpuinfo_x86 *c)
537537
{
538-
u64 value;
539538
u32 dummy;
540539

541540
if (c->x86 >= 0xf)
@@ -603,20 +602,6 @@ static void early_init_amd(struct cpuinfo_x86 *c)
603602

604603
early_detect_mem_encrypt(c);
605604

606-
/* Re-enable TopologyExtensions if switched off by BIOS */
607-
if (c->x86 == 0x15 &&
608-
(c->x86_model >= 0x10 && c->x86_model <= 0x6f) &&
609-
!cpu_has(c, X86_FEATURE_TOPOEXT)) {
610-
611-
if (msr_set_bit(0xc0011005, 54) > 0) {
612-
rdmsrl(0xc0011005, value);
613-
if (value & BIT_64(54)) {
614-
set_cpu_cap(c, X86_FEATURE_TOPOEXT);
615-
pr_info_once(FW_INFO "CPU: Re-enabling disabled Topology Extensions Support.\n");
616-
}
617-
}
618-
}
619-
620605
if (!cpu_has(c, X86_FEATURE_HYPERVISOR) && !cpu_has(c, X86_FEATURE_IBPB_BRTYPE)) {
621606
if (c->x86 == 0x17 && boot_cpu_has(X86_FEATURE_AMD_IBPB))
622607
setup_force_cpu_cap(X86_FEATURE_IBPB_BRTYPE);

arch/x86/kernel/cpu/topology_amd.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,26 @@ static void legacy_set_llc(struct topo_scan *tscan)
147147
tscan->c->topo.llc_id = apicid >> tscan->dom_shifts[TOPO_CORE_DOMAIN];
148148
}
149149

150+
static void topoext_fixup(struct topo_scan *tscan)
151+
{
152+
struct cpuinfo_x86 *c = tscan->c;
153+
u64 msrval;
154+
155+
/* Try to re-enable TopologyExtensions if switched off by BIOS */
156+
if (cpu_has(c, X86_FEATURE_TOPOEXT) || c->x86_vendor != X86_VENDOR_AMD ||
157+
c->x86 != 0x15 || c->x86_model < 0x10 || c->x86_model > 0x6f)
158+
return;
159+
160+
if (msr_set_bit(0xc0011005, 54) <= 0)
161+
return;
162+
163+
rdmsrl(0xc0011005, msrval);
164+
if (msrval & BIT_64(54)) {
165+
set_cpu_cap(c, X86_FEATURE_TOPOEXT);
166+
pr_info_once(FW_INFO "CPU: Re-enabling disabled Topology Extensions Support.\n");
167+
}
168+
}
169+
150170
static void parse_topology_amd(struct topo_scan *tscan)
151171
{
152172
bool has_0xb = false;
@@ -176,6 +196,7 @@ static void parse_topology_amd(struct topo_scan *tscan)
176196
void cpu_parse_topology_amd(struct topo_scan *tscan)
177197
{
178198
tscan->amd_nodes_per_pkg = 1;
199+
topoext_fixup(tscan);
179200
parse_topology_amd(tscan);
180201

181202
if (tscan->amd_nodes_per_pkg > 1)

0 commit comments

Comments
 (0)