Received: by 2002:a4a:311b:0:0:0:0:0 with SMTP id k27-v6csp4800816ooa; Tue, 14 Aug 2018 10:44:04 -0700 (PDT) X-Google-Smtp-Source: AA+uWPywd1gYzribcjZq1WYkCQC9fzWLnsmch/9AmsQMF37UGV35eoFlmJaE3kOFHOMOESaFcR4K X-Received: by 2002:a17:902:3225:: with SMTP id y34-v6mr6195009plb.206.1534268644263; Tue, 14 Aug 2018 10:44:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534268644; cv=none; d=google.com; s=arc-20160816; b=uJ8Qa+m5Eiq4zh+fsL7gu2p9p30WIt/jlbqoPUjzXrVAjRH4rf2LvsGprHzNCD7wL7 K2ijqLXH7L+vu3ltwxT8PqqbJ0Qy7E+klHiyUSbctBfkeHu1rK4lgfsI0Ppo/AKbvUBF 475GeGHDUY5kaAsTzq//PMWCnbwuyfZm1KjzgE8f/ROYa6/jAjslYIQMiBcHrCDoj4Lk WmCvOQLKjSvue25i+JnEdvzG98/Yp3tXo/KVuqsKvD+vucJgvDmLfJhsh47P7FYUJ0ME bICxtp89mMvl3tU24XWYQnw4KKLy6OzS0OY6r3hg1kYhYV+YkAls0rRBVcQq92m6dhVe eFTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=wBd/zX6OOYRHA/Vl5zqUecx5D67QjhH2DUTzRah8FtM=; b=x208SjpgcEZFrfHd8tBvgwc4yrrwS0FIryUEoLI4cUZ6hEMlY+kiwM5bgi9cjek5pH +K3G9ZW7uSu02yM93b4dUNTS26HFKUr0pn8NCnHJ6B05cXZIGj6QJ81X9yrgUkEAPl6r /h5uAITMiaoIoox0P2btA/QGXXApuYldgH71DiXxvAW0gWk2eFlDa9YvUlWlV9dKM4EA PDiYla28bYEqxvnTVs4KfXNTmciMktyShhnw9eO/ugX4mjIaUmJD6KjT/7e8X2612rRh /ayJEsF3GC2I5007DKEEel+YlK5vYdhBkjbjArLFR/gl7gWjUg5xE/REIYN9azYEV9Ug idwQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 128-v6si22852547pge.444.2018.08.14.10.43.49; Tue, 14 Aug 2018 10:44:04 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390379AbeHNUab (ORCPT + 99 others); Tue, 14 Aug 2018 16:30:31 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:59622 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388923AbeHNUaa (ORCPT ); Tue, 14 Aug 2018 16:30:30 -0400 Received: from localhost (unknown [194.244.16.108]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id E48F1CA5; Tue, 14 Aug 2018 17:42:18 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Borislav Petkov , Thomas Gleixner , David Woodhouse Subject: [PATCH 4.9 052/107] x86/CPU/AMD: Move TOPOEXT reenablement before reading smp_num_siblings Date: Tue, 14 Aug 2018 19:17:15 +0200 Message-Id: <20180814171524.347051225@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180814171520.883143803@linuxfoundation.org> References: <20180814171520.883143803@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Borislav Petkov commit 7ce2f0393ea2396142b7faf6ee9b1f3676d08a5f upstream The TOPOEXT reenablement is a workaround for broken BIOSen which didn't enable the CPUID bit. amd_get_topology_early(), however, relies on that bit being set so that it can read out the CPUID leaf and set smp_num_siblings properly. Move the reenablement up to early_init_amd(). While at it, simplify amd_get_topology_early(). [dwmw2: Backport to 4.9] Signed-off-by: Borislav Petkov Signed-off-by: Thomas Gleixner Signed-off-by: David Woodhouse Signed-off-by: Greg Kroah-Hartman --- arch/x86/kernel/cpu/amd.c | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) --- a/arch/x86/kernel/cpu/amd.c +++ b/arch/x86/kernel/cpu/amd.c @@ -300,12 +300,8 @@ static int nearby_node(int apicid) static void amd_get_topology_early(struct cpuinfo_x86 *c) { - if (boot_cpu_has(X86_FEATURE_TOPOEXT)) { - u32 eax, ebx, ecx, edx; - - cpuid(0x8000001e, &eax, &ebx, &ecx, &edx); - smp_num_siblings = ((ebx >> 8) & 0xff) + 1; - } + if (cpu_has(c, X86_FEATURE_TOPOEXT)) + smp_num_siblings = ((cpuid_ebx(0x8000001e) >> 8) & 0xff) + 1; } /* @@ -326,7 +322,6 @@ static void amd_get_topology(struct cpui cpuid(0x8000001e, &eax, &ebx, &ecx, &edx); node_id = ecx & 0xff; - smp_num_siblings = ((ebx >> 8) & 0xff) + 1; if (c->x86 == 0x15) c->cu_id = ebx & 0xff; @@ -578,6 +573,8 @@ static void bsp_init_amd(struct cpuinfo_ static void early_init_amd(struct cpuinfo_x86 *c) { + u64 value; + early_init_amd_mc(c); /* @@ -645,6 +642,21 @@ static void early_init_amd(struct cpuinf if (cpu_has_amd_erratum(c, amd_erratum_400)) set_cpu_bug(c, X86_BUG_AMD_E400); + + /* Re-enable TopologyExtensions if switched off by BIOS */ + if (c->x86 == 0x15 && + (c->x86_model >= 0x10 && c->x86_model <= 0x6f) && + !cpu_has(c, X86_FEATURE_TOPOEXT)) { + + if (msr_set_bit(0xc0011005, 54) > 0) { + rdmsrl(0xc0011005, value); + if (value & BIT_64(54)) { + set_cpu_cap(c, X86_FEATURE_TOPOEXT); + pr_info_once(FW_INFO "CPU: Re-enabling disabled Topology Extensions Support.\n"); + } + } + } + amd_get_topology_early(c); } @@ -737,19 +749,6 @@ static void init_amd_bd(struct cpuinfo_x { u64 value; - /* re-enable TopologyExtensions if switched off by BIOS */ - if ((c->x86_model >= 0x10) && (c->x86_model <= 0x6f) && - !cpu_has(c, X86_FEATURE_TOPOEXT)) { - - if (msr_set_bit(0xc0011005, 54) > 0) { - rdmsrl(0xc0011005, value); - if (value & BIT_64(54)) { - set_cpu_cap(c, X86_FEATURE_TOPOEXT); - pr_info_once(FW_INFO "CPU: Re-enabling disabled Topology Extensions Support.\n"); - } - } - } - /* * The way access filter has a performance penalty on some workloads. * Disable it on the affected CPUs.