Received: by 2002:ab2:7988:0:b0:1f4:b336:87c4 with SMTP id g8csp107036lqj; Thu, 11 Apr 2024 11:07:47 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVnOF0WzTFLspzd2Uo5UX9GuAUF+JzlIzMvJsP6aJVaKwcz6dJXKkO9++0nRcrymvSk8+Vqj56zxabMWrU9ZJVQUVuYtkF6dV1gePPLNg== X-Google-Smtp-Source: AGHT+IFAPApGZQL54vc8frodB9etIEcM0/mzJaY/hJ3yW1yQpkWb9nOQus3F8Lotwlpw9njaK1vX X-Received: by 2002:a05:6a21:7887:b0:1a9:8836:ae37 with SMTP id bf7-20020a056a21788700b001a98836ae37mr796601pzc.12.1712858866838; Thu, 11 Apr 2024 11:07:46 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712858866; cv=pass; d=google.com; s=arc-20160816; b=aojU9bWh57ZAXDpbblk2/JvRDLRuptUckjZY+Cs//vlKLpG3bBHAWd6BozUw8PbgAQ Rz2YtLW4ZyLDMlGvzS21zPrQ5XmHQAecqXa8K6XJiBwS/wdD6bHgoLDIa1yPXEhdd1bI RfwfIEub6mq7NiJ08pNko3FSOnfhzYlS8YVYsrnTTzCaMWxvX67rOqaK7eUeyN6JHLiy 6Yc+umG7U5WbLEPZRzV3op98LPn1aZIzCjHE2YOfJGh6ZKGYe0VeXi7u47wDf5C4hD/R aKI4YR1JSFE0VCBLQy/7ufQY75b1XtonQlm7i5FaFB2Wf0K8aeorarbS8M7wR6iVkZY4 TXQw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :message-id:date:subject:cc:to:dkim-signature:dkim-signature:from; bh=TsFOOJcOHJ7plsoN3ZMIm7IsVte2hrryLXZRjUEr1RQ=; fh=dREHapjDl49VbOQ+lOLLWHBoHh/hzPv4sVAua04CbzQ=; b=rttoRj7ShD+tyZby4FSmFeHnRvu1IJv1oPvagjSGkg53YHs1rHbBwFNW1jnnD5dagw CTlGz0eRAHaqG/ZtNyTmQC8w9a8y7Lee3ypnp/qN9u+nxlNuSF0LqfHnglpFAFzhPAR0 8VgGLJJMPUHjHvYQiHy9LimoJypkPdP9oEO5ldetIKUmXPrpuGpeQf8wqthsoWyhgXQB faIp+NxqOGoJXx/Jrx+ZyqmozzXrBARiVPWbfMJeoNwS5eFh2Dh+AaTwgrGAY48nnTWC QQlFqaXckG1kFxwPtHICe+OKqdMsJuuVkZYHrsaOLvwRwv5kcBmqiz/vwlWWkpKcUvSl qhDA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=k7UpgUEn; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-141360-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-141360-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id dw15-20020a056a00368f00b006ead793ff20si1765014pfb.167.2024.04.11.11.07.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 11:07:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-141360-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=k7UpgUEn; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-141360-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-141360-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 68006287154 for ; Thu, 11 Apr 2024 18:06:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C8EA1502BB; Thu, 11 Apr 2024 16:55:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="k7UpgUEn"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="aPpPeN85" Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9C53B4C629 for ; Thu, 11 Apr 2024 16:55:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712854542; cv=none; b=uBx8jIF5HW1FFAAVRY/i7hL/7X0KdUZmORyLeW/G8EPxEk9jkGF/CQZku9aTFAhQbMFq0vbJsgnSZtEs1xqRd1VS83rWE7ApmnMh3E2/id7k5bSxcvg/XORFykwGLMD87Ps0/6PL1h3+AB4Hx0LzyLTaK2RcpFHJ/kAivB0/5xU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712854542; c=relaxed/simple; bh=aryO/c1uQgmEOTObfNrdfHzECktcnoGdCFewhnZiGzM=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=QsUak2C/QLvHR2A+iLs37LjEwt4ypS3xHkEijIbv5wMyOEumIk/6x0C++4MvdVgx0QkPvXafb0LWXt2AKUAEkqOEzwCUlbhLVFcXtMgklCvQyvclkOMdYJtNh30gDPMMfOPQH6O2+4E6df9TmxEraAU//NXAzmMksCsdp0E5Z00= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=k7UpgUEn; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=aPpPeN85; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1712854539; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type; bh=TsFOOJcOHJ7plsoN3ZMIm7IsVte2hrryLXZRjUEr1RQ=; b=k7UpgUEn0wKgyPCHTVl9AdGUS1mZ8RZtbsXU+Oo9fjYrectt91xIn2uJTXMrUnGCLqiQzS G3rr2kGJQT1g0UHhhTwfrP5NMo6YYIj6htcACHGP+/gVx0hqudsBG7DpxSaBKnXefxjSc9 +ElnAW3k4ku9u29lTzC6PnvHnRktxJIvyuia+zA7knFKP1/BWyuCIoCEvNODVr+y3ziS9f Nvctid1B8O6rWMFcTr++i1RenI25EY/4Jy5XKeuiKbOE7zCotX4CFz+QQ3cFUE0ybSJVUc OoL35pTqFb5TG5aXXOW0yGMi12WCapT8HmBvKY4aigIA3kMfLFD02hyyoEQryQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1712854539; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type; bh=TsFOOJcOHJ7plsoN3ZMIm7IsVte2hrryLXZRjUEr1RQ=; b=aPpPeN85qog8fqmo/cs6Sk8O76+uFImdLyx0TCkKcZCavesdNjxOd9Fhc7+4N/5Rj+RE09 afEAKxCax8iZHSCA== To: LKML Cc: x86@kernel.org Subject: [PATCH] x86/cpu/amd: Move TOPOEXT enablement into the topology parser Date: Thu, 11 Apr 2024 18:55:38 +0200 Message-ID: <878r1j260l.ffs@tglx> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain 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: f7fb3b2dd92c ("x86/cpu: Provide an AMD/HYGON specific topology parser") Signed-off-by: Thomas Gleixner --- arch/x86/kernel/cpu/amd.c | 15 --------------- arch/x86/kernel/cpu/topology_amd.c | 21 +++++++++++++++++++++ 2 files changed, 21 insertions(+), 15 deletions(-) --- a/arch/x86/kernel/cpu/amd.c +++ b/arch/x86/kernel/cpu/amd.c @@ -535,7 +535,6 @@ static void early_detect_mem_encrypt(str static void early_init_amd(struct cpuinfo_x86 *c) { - u64 value; u32 dummy; if (c->x86 >= 0xf) @@ -603,20 +602,6 @@ 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"); - } - } - } - if (!cpu_has(c, X86_FEATURE_HYPERVISOR) && !cpu_has(c, X86_FEATURE_IBPB_BRTYPE)) { if (c->x86 == 0x17 && boot_cpu_has(X86_FEATURE_AMD_IBPB)) setup_force_cpu_cap(X86_FEATURE_IBPB_BRTYPE); --- a/arch/x86/kernel/cpu/topology_amd.c +++ b/arch/x86/kernel/cpu/topology_amd.c @@ -147,6 +147,26 @@ static void legacy_set_llc(struct topo_s tscan->c->topo.llc_id = apicid >> tscan->dom_shifts[TOPO_CORE_DOMAIN]; } +static void topoext_fixup(struct topo_scan *tscan) +{ + struct cpuinfo_x86 *c = tscan->c; + u64 msrval; + + /* Try to re-enable TopologyExtensions if switched off by BIOS */ + if (cpu_has(c, X86_FEATURE_TOPOEXT) || c->x86_vendor != X86_VENDOR_AMD || + c->x86 != 0x15 || c->x86_model < 0x10 || c->x86_model > 0x6f) + return; + + if (msr_set_bit(0xc0011005, 54) <= 0) + return; + + rdmsrl(0xc0011005, msrval); + if (msrval & BIT_64(54)) { + set_cpu_cap(c, X86_FEATURE_TOPOEXT); + pr_info_once(FW_INFO "CPU: Re-enabling disabled Topology Extensions Support.\n"); + } +} + static void parse_topology_amd(struct topo_scan *tscan) { bool has_0xb = false; @@ -176,6 +196,7 @@ static void parse_topology_amd(struct to void cpu_parse_topology_amd(struct topo_scan *tscan) { tscan->amd_nodes_per_pkg = 1; + topoext_fixup(tscan); parse_topology_amd(tscan); if (tscan->amd_nodes_per_pkg > 1)