Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp683230ybh; Tue, 10 Mar 2020 06:25:01 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvKFJoTjLpLvpW9CTBn2rLLzlrAQpZMYLx1D7PXL791kjx9dEn2iYT6Mol54lXlN+Gw/Bil X-Received: by 2002:a05:6830:1e46:: with SMTP id e6mr16315861otj.257.1583846700931; Tue, 10 Mar 2020 06:25:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583846700; cv=none; d=google.com; s=arc-20160816; b=TKwVHD1ZvDtj8M6SfS56nMlt31oH/8GlwueoX9o7Dwx76W1Co1eVDHoLdqpAzDZ/cn VzDDApCuQZbVrJd2bYlAN3TLkWSjljhRLgoXWz5G2j7d4FipnBjpcDLWMejAVGnNwVro I460/dLcakz0lpT/WwU4Y4FSDAoj4oNHlRxokafuPKyFxx8htg/BQC75hOdLf2/Mc3XO rsdVuIGKbT3IVo10OcvbZ8/uPH0vnKncrNIDO/XgPtaim9QTck3YzX0a1Nwa7vv6PtHE TzFi2Z4ai+u9gB6BZb1QmZoSTdzYgv2UGtxRlFNAd4bf7WTwQxPI5/M2ZdzxfBpYG0cH m6nA== 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:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=qqn+ZtHHR/5bUrXaI8H4ySCIm6mWjoqkh2J/8dDHjcM=; b=SBfWJVJ50zB3b4P0uLigYk+x2Dzaqb+WUFtVQfMUAwQZz4919Hk94C4yTJm0QxQxkx OE0hu/7jhnACtESDYM9JYTmpKt/gnASWsTVsd1loaM0NZJ0t8MPhN+76sbo9U50a2l5u jOs7YeJXUZ3bEPnMP+ogQzQo1275kJ9+Sc08hnMb6cm/pFDWubyINOJyLvBoR26vKnXU KcmYjhfm5IMnn8820jMwoTu5fzdwNQRgEhl8kt5GLT3g8oW41DCqVHOjuv2ZhqNs+8tp 7lcdXG2gzT47gwr0Llniy8ncWrxMxiTBzocF/M1KycAaZnUg9wAHo2Rr8DUvNJg+cIbE dpMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=k4lKnSUh; 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 a3si8043240otk.234.2020.03.10.06.24.49; Tue, 10 Mar 2020 06:25:00 -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; dkim=pass header.i=@kernel.org header.s=default header.b=k4lKnSUh; 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 S1729988AbgCJNA0 (ORCPT + 99 others); Tue, 10 Mar 2020 09:00:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:41160 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729979AbgCJNAY (ORCPT ); Tue, 10 Mar 2020 09:00:24 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E35B220674; Tue, 10 Mar 2020 13:00:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1583845223; bh=/mdxnAdIc908lANtJyPC1YYbCwLetm54mAVznZ+geG8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k4lKnSUh7WodyAR/GTtolxJssw/XM786N+nWL1+ztZOOnHCMyO9AsFMRKE5rAs/Hc XqtNn266eMYtZ3R87zOwhB/O6+jdkdBFp1P/p4pi2gIrLpRvdtQbHGvi4mdrPsvBue iGxPjaXNRb2dsBZssDgg4E0r2aQpyO8hko+R54hI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jacob Keller , Sean Christopherson , Borislav Petkov , Dave Hansen Subject: [PATCH 5.5 105/189] x86/pkeys: Manually set X86_FEATURE_OSPKE to preserve existing changes Date: Tue, 10 Mar 2020 13:39:02 +0100 Message-Id: <20200310123650.321435804@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200310123639.608886314@linuxfoundation.org> References: <20200310123639.608886314@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sean Christopherson commit 735a6dd02222d8d070c7bb748f25895239ca8c92 upstream. 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 Signed-off-by: Greg Kroah-Hartman --- arch/x86/kernel/cpu/common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -462,7 +462,7 @@ static __always_inline void setup_pku(st * 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