Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp1395716ybf; Thu, 27 Feb 2020 10:08:35 -0800 (PST) X-Google-Smtp-Source: APXvYqyz6V99Ni9KG1I7xKrfcOaUo1NoWEt8QenrV/uKpga0EDvcpBJH1v/yI6UmHrZbreCTYb9r X-Received: by 2002:a9d:7304:: with SMTP id e4mr110079otk.99.1582826915393; Thu, 27 Feb 2020 10:08:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582826915; cv=none; d=google.com; s=arc-20160816; b=qfqE7RaEifZG3Fut1INlTSCDJV1T97wherLN3QP/7KzMis5kmqbts0M6WBGhsYSFBA WGhff3i8fd+zyCcT98Vj3/o1ZtlMcWF+g+CHVJ1cOcC/9B5apnAPuvWwuC1GJHTtY4Qc yaAaephIpFqKJWtpVp7QIpD+CWcLpe+0HE+Eqd3tasY+zf+RNsZikf0yTK0uBgsQIi0/ 8k4zzvuBInqoT+jFav6eTeZOHRBf/ZDtuJ17WS0SRaP7mFNKj4ak8jUAOcpIuWlgupuT 44wvPpWdo5G5qvP21EHFQtk8/cfJIFyefA+dYOcv3Nfipdz3BYnUpT+y3L29wfQ9lCld rkKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :robot-unsubscribe:robot-id:message-id:mime-version:references :in-reply-to:cc:subject:to:reply-to:from:date; bh=XcibCx35qLoILyEat3zoMhXqIOIj8xafB7gTto0kX0c=; b=L5doEvb3BN7WptXLmdaOkuSWufcGDvaxzHUVju+0xTTHKya6+UztiI20blEenoqQJe GxqLqxBFFxWCa7h7MXfpHHUm8kS/WrROraQeaMA4MWf3IZk9ekAu2LVjhP0EuA4gr3aa u4ihxD1wuPu6PTGPlasiHsMLYtYbK3Xqro330Y7vy6xc595ZXWfkxeIh99ju58zoms/H bJXtTITS3qHfTM1a2wpR3VLUXWGAqfyxLJoZDx92MxJcd0Qicd8P2dUMxHXCzRmkpz7j GM9GyW4J8d45bYM9tUnNORJyCcYaDSZ8ldC8f5MSeY2jGgBLMiMlS90xWb+XBeNXQIYS GBRQ== 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 s143si272919oih.251.2020.02.27.10.08.23; Thu, 27 Feb 2020 10:08:35 -0800 (PST) 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 S1729805AbgB0SIC (ORCPT + 99 others); Thu, 27 Feb 2020 13:08:02 -0500 Received: from Galois.linutronix.de ([193.142.43.55]:35032 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729142AbgB0SIC (ORCPT ); Thu, 27 Feb 2020 13:08:02 -0500 Received: from [5.158.153.53] (helo=tip-bot2.lab.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1j7NZf-0002LJ-8H; Thu, 27 Feb 2020 19:07:51 +0100 Received: from [127.0.1.1] (localhost [IPv6:::1]) by tip-bot2.lab.linutronix.de (Postfix) with ESMTP id CBF161C2172; Thu, 27 Feb 2020 19:07:50 +0100 (CET) Date: Thu, 27 Feb 2020 18:07:50 -0000 From: "tip-bot2 for Sean Christopherson" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/urgent] x86/pkeys: Manually set X86_FEATURE_OSPKE to preserve existing changes Cc: Jacob Keller , Sean Christopherson , Borislav Petkov , Dave Hansen , stable@vger.kernel.org, x86 , LKML In-Reply-To: <20200226231615.13664-1-sean.j.christopherson@intel.com> References: <20200226231615.13664-1-sean.j.christopherson@intel.com> MIME-Version: 1.0 Message-ID: <158282687050.28353.6531125831614540420.tip-bot2@tip-bot2> X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the x86/urgent branch of tip: Commit-ID: 735a6dd02222d8d070c7bb748f25895239ca8c92 Gitweb: https://git.kernel.org/tip/735a6dd02222d8d070c7bb748f25895239ca8c92 Author: Sean Christopherson AuthorDate: Wed, 26 Feb 2020 15:16:15 -08:00 Committer: Borislav Petkov CommitterDate: Thu, 27 Feb 2020 19:02:45 +01:00 x86/pkeys: Manually set X86_FEATURE_OSPKE to preserve existing changes Explicitly set X86_FEATURE_OSPKE via set_cpu_cap() instead of calling get_cpu_cap() to pull the feature bit from CPUID after enabling CR4.PKE. Invoking get_cpu_cap() effectively wipes out any {set,clear}_cpu_cap() changes that were made between this_cpu->c_init() and setup_pku(), as all non-synthetic feature words are reinitialized from the CPU's CPUID values. Blasting away capability updates manifests most visibility when running on a VMX capable CPU, but with VMX disabled by BIOS. To indicate that VMX is disabled, init_ia32_feat_ctl() clears X86_FEATURE_VMX, using clear_cpu_cap() instead of setup_clear_cpu_cap() so that KVM can report which CPU is misconfigured (KVM needs to probe every CPU anyways). Restoring X86_FEATURE_VMX from CPUID causes KVM to think VMX is enabled, ultimately leading to an unexpected #GP when KVM attempts to do VMXON. Arguably, init_ia32_feat_ctl() should use setup_clear_cpu_cap() and let KVM figure out a different way to report the misconfigured CPU, but VMX is not the only feature bit that is affected, i.e. there is precedent that tweaking feature bits via {set,clear}_cpu_cap() after ->c_init() is expected to work. Most notably, x86_init_rdrand()'s clearing of X86_FEATURE_RDRAND when RDRAND malfunctions is also overwritten. Fixes: 0697694564c8 ("x86/mm/pkeys: Actually enable Memory Protection Keys in the CPU") Reported-by: Jacob Keller Signed-off-by: Sean Christopherson Signed-off-by: Borislav Petkov Acked-by: Dave Hansen Tested-by: Jacob Keller Cc: stable@vger.kernel.org Link: https://lkml.kernel.org/r/20200226231615.13664-1-sean.j.christopherson@intel.com --- arch/x86/kernel/cpu/common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index 52c9bfb..4cdb123 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -445,7 +445,7 @@ static __always_inline void setup_pku(struct cpuinfo_x86 *c) * cpuid bit to be set. We need to ensure that we * update that bit in this CPU's "cpu_info". */ - get_cpu_cap(c); + set_cpu_cap(c, X86_FEATURE_OSPKE); } #ifdef CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS