Received: by 10.192.165.148 with SMTP id m20csp722762imm; Wed, 2 May 2018 07:49:18 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqBYwZ4snm83JFaMeCACxxhR9YBStq0CrEu8UTxJQBh7pFO2usNgvkYZuEkDgGwF9Ef0hE2 X-Received: by 2002:a63:ae49:: with SMTP id e9-v6mr16006916pgp.38.1525272558577; Wed, 02 May 2018 07:49:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525272558; cv=none; d=google.com; s=arc-20160816; b=o1gJpjmMySdoF7j2L4Xt6JUydeVDbnGUE/94iLe2KSnYcHQW+Qj/1Ku3Rc0VhdPl7R p9Wf5fSMIKWreF0UGI8O/I1BrOaPzn3hKSjW7Gt7mIgKQs8plGlz8GGLHvdzc1sR67l6 8A3IdAaeiI1jNdaVhzJrIBJBp6dILYo51rw7Y0WkdV5Hu2lZx1O0e00/mkAhF+q/lHsp ezhRkv54xKF5b1pr5O9TVa67DvyoUEzvJcO4XmxV9uOB/5enwCtaLJPPph62R1aq8kPU pC5P+IPVq0oaOdJwI9zj0k8iC64FMyllMBeKfDXa/BrqtzoFipNTd9REV8QW1FgFfipr We7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date:arc-authentication-results; bh=IEAZM1hIYnSqzNO7Whq+4NhtPwNR4V/niQRshfYl1pM=; b=Ag0OqIytC7jCKE7QCaBHiXpaZQfMdBoYF9qcQflcQOSa8Ki2fhegBLosi7eKYhaeFy QUVBV75WDj3OR5dFDFtwgTZ4gII7QiR/JK+AW5OqMe8fDI+DgLgbPPgRNBgzRhqDm/dP UcAJXZkCOIxSMu4hzrUsGwiGa5ERINYc7JnDBhD/42eSQpXE1P84uHGxNL4MR4HS3VPC kSdeIDDzVNWp0zmHlzSmutX5IdQ0O4fUlVP5QIImp+CWRV0LMVf7GoXI+ZllldLNQT96 UErz35nX8dFulsps7O0ywxPHDySryJBL0mj8x6coimRda+fdX6DViUhKyVomc0pSadgK wqcw== 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 v7-v6si11868142plp.31.2018.05.02.07.49.04; Wed, 02 May 2018 07:49:18 -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 S1751527AbeEBOsy (ORCPT + 99 others); Wed, 2 May 2018 10:48:54 -0400 Received: from terminus.zytor.com ([198.137.202.136]:56235 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751011AbeEBOsv (ORCPT ); Wed, 2 May 2018 10:48:51 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTP id w42Emjx3200658; Wed, 2 May 2018 07:48:45 -0700 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w42Emj5k200655; Wed, 2 May 2018 07:48:45 -0700 Date: Wed, 2 May 2018 07:48:45 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Thomas Gleixner Message-ID: Cc: linux-kernel@vger.kernel.org, tglx@linutronix.de, tim.c.chen@linux.intel.com, jrg.otte@gmail.com, mingo@kernel.org, hpa@zytor.com, torvalds@linux-foundation.org Reply-To: mingo@kernel.org, tim.c.chen@linux.intel.com, jrg.otte@gmail.com, tglx@linutronix.de, linux-kernel@vger.kernel.org, torvalds@linux-foundation.org, hpa@zytor.com In-Reply-To: References: To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/urgent] x86/cpu: Restore CPUID_8000_0008_EBX reload Git-Commit-ID: c65732e4f72124ca5a3a0dd3bee0d3cee39c7170 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00 autolearn=ham autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: c65732e4f72124ca5a3a0dd3bee0d3cee39c7170 Gitweb: https://git.kernel.org/tip/c65732e4f72124ca5a3a0dd3bee0d3cee39c7170 Author: Thomas Gleixner AuthorDate: Mon, 30 Apr 2018 21:47:46 +0200 Committer: Thomas Gleixner CommitDate: Wed, 2 May 2018 16:44:38 +0200 x86/cpu: Restore CPUID_8000_0008_EBX reload The recent commt which addresses the x86_phys_bits corruption with encrypted memory on CPUID reload after a microcode update lost the reload of CPUID_8000_0008_EBX as well. As a consequence IBRS and IBRS_FW are not longer detected Restore the behaviour by bringing the reload of CPUID_8000_0008_EBX back. This restore has a twist due to the convoluted way the cpuid analysis works: CPUID_8000_0008_EBX is used by AMD to enumerate IBRB, IBRS, STIBP. On Intel EBX is not used. But the speculation control code sets the AMD bits when running on Intel depending on the Intel specific speculation control bits. This was done to use the same bits for alternatives. The change which moved the 8000_0008 evaluation out of get_cpu_cap() broke this nasty scheme due to ordering. So that on Intel the store to CPUID_8000_0008_EBX clears the IBRB, IBRS, STIBP bits which had been set before by software. So the actual CPUID_8000_0008_EBX needs to go back to the place where it was and the phys/virt address space calculation cannot touch it. In hindsight this should have used completely synthetic bits for IBRB, IBRS, STIBP instead of reusing the AMD bits, but that's for 4.18. /me needs to find time to cleanup that steaming pile of ... Fixes: d94a155c59c9 ("x86/cpu: Prevent cpuinfo_x86::x86_phys_bits adjustment corruption") Reported-by: Jörg Otte Reported-by: Tim Chen Signed-off-by: Thomas Gleixner Tested-by: Jörg Otte Cc: Linus Torvalds Cc: kirill.shutemov@linux.intel.com Cc: Borislav Petkov x86_power = edx; } + if (c->extended_cpuid_level >= 0x80000008) { + cpuid(0x80000008, &eax, &ebx, &ecx, &edx); + c->x86_capability[CPUID_8000_0008_EBX] = ebx; + } + if (c->extended_cpuid_level >= 0x8000000a) c->x86_capability[CPUID_8000_000A_EDX] = cpuid_edx(0x8000000a); @@ -871,7 +876,6 @@ static void get_cpu_address_sizes(struct cpuinfo_x86 *c) c->x86_virt_bits = (eax >> 8) & 0xff; c->x86_phys_bits = eax & 0xff; - c->x86_capability[CPUID_8000_0008_EBX] = ebx; } #ifdef CONFIG_X86_32 else if (cpu_has(c, X86_FEATURE_PAE) || cpu_has(c, X86_FEATURE_PSE36))