Received: by 2002:a4a:311b:0:0:0:0:0 with SMTP id k27-v6csp4781449ooa; Tue, 14 Aug 2018 10:27:38 -0700 (PDT) X-Google-Smtp-Source: AA+uWPwqXKJltokImvDtiNa1gjD/5qobCg8RGhzLoib7552Un1+HwX2hboU3vEgv4QnvEDJTj4BO X-Received: by 2002:a62:f50b:: with SMTP id n11-v6mr24215482pfh.120.1534267658672; Tue, 14 Aug 2018 10:27:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534267658; cv=none; d=google.com; s=arc-20160816; b=huSF/nsYG2q/PCcJQLodqxlO6uyXN/yT6jATe9FOrbsJmGFrppmSnDLYWy2WypuZZw qCkPVMMUMdbhjpuhPiELRAA3yIhzRVj/k/DkdDNf4CNcWjSjf8bsL+2SMpnpGbHVevwS ky7J0RDMRD8K0DU4E4/CkAI3W6kDZx7CNrEwKam/3Cgo7UmmDiFZrDur3pnDwgx+5hiz L4MC1BTLkPrLrnV+DDSDQsiluMCX9/bKJWDgC7sXiwxSl+snRY2kybHo+CEqp87GApgP sm2zdgHwVQ6W1TmWhiZ7SEWSHjRbSuASzsLUGsn+Vlc9mGKKRA2V6OMdfsNwZc5rRYlj zr5A== 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=PcJOP2SRVmCtmZmkHWOn9Sv8X01iufWvvz933cqBYwI=; b=HrHnO+JRVKZOGKIq/ZPqp5Hp+0Jnb6pRRsZyLFLZF8y+RQxpPy3PNx2JPNiUwsdBnt VL6WJce85QZmmKg2qvZDAFHWMgO7AD0yucEz3VuufVZfUQu39ZigziES+bKM9Y0jipi0 Pm4kne8qJoYdcCADF7fljdoXOE37vteTFp3Wp2xWEK9Ruz2DCyWQMwd5B+GxBJXI3jzv YN7+H+2ISqVBy2eSX5ZSAH/0NB2vjfa/e0wKYm+G1NRZImIIxPkHRMupnzHUV/UVv6GR 16bVzlEQzGpOrU8bdEp3Lx02rR63VJf2X4MtFhZ7vk8oOrH80lAEruKlbQ2ZG+Q1djgD wxkg== 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 x19-v6si19902800pgk.80.2018.08.14.10.27.23; Tue, 14 Aug 2018 10:27:38 -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 S2388169AbeHNUN0 (ORCPT + 99 others); Tue, 14 Aug 2018 16:13:26 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:51624 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733240AbeHNUNZ (ORCPT ); Tue, 14 Aug 2018 16:13:25 -0400 Received: from localhost (unknown [194.244.16.108]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 1B12FD1D; Tue, 14 Aug 2018 17:25: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 Subject: [PATCH 4.18 30/79] x86/CPU/AMD: Move TOPOEXT reenablement before reading smp_num_siblings Date: Tue, 14 Aug 2018 19:16:49 +0200 Message-Id: <20180814171337.950694081@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180814171336.799314117@linuxfoundation.org> References: <20180814171336.799314117@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.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Borislav Petkov 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(). Signed-off-by: Borislav Petkov Signed-off-by: Thomas Gleixner Signed-off-by: Greg Kroah-Hartman --- arch/x86/kernel/cpu/amd.c | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) --- a/arch/x86/kernel/cpu/amd.c +++ b/arch/x86/kernel/cpu/amd.c @@ -318,12 +318,8 @@ static void legacy_fixup_core_id(struct 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; } /* @@ -345,7 +341,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; @@ -624,6 +619,7 @@ clear_sev: static void early_init_amd(struct cpuinfo_x86 *c) { + u64 value; u32 dummy; early_init_amd_mc(c); @@ -695,6 +691,20 @@ static void early_init_amd(struct cpuinf early_detect_mem_encrypt(c); + /* 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); } @@ -787,19 +797,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.