Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp673038ybh; Tue, 10 Mar 2020 06:15:06 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtVQu9QUI5NY6DowO7R8WR1GJQG2jPJE0KoR6csf277eNpMVOo4vxPK3i4/cPp1cROVkr7c X-Received: by 2002:aca:849:: with SMTP id 70mr1120179oii.30.1583846106253; Tue, 10 Mar 2020 06:15:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583846106; cv=none; d=google.com; s=arc-20160816; b=JWlgsEKxkES0e5H0WklR3u4LaXoQelXQ+2M+rEJEuobnnF61jnUFmYRW+TdOEI36xi 7LLljyaWvpreJVRp+hbKeDXVR8JsRVdWTkDoBrIJUPqggRoOSy/0zFFnl43tkB/krYJZ mvTuefmWn9imMn8EmB4t9t6RcqZNsK8DCz4N1667t3MpJlugA3db3XK6UG6oMj6JD9mw YxrxayCcgEEQpleyHfXtZKtWvIXFiBJybKPgR7Oh2wuieXjTHBaTVumlPaIsoqkSZuwP vTA2u2JODtAFrbDrMPIslXfaJ3zDfyDzk72J57K9TX+C7A++7b9cMS59v5ejsxTcoblR SstQ== 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=WD/5GMkFpR1vLcbvxv8PoiOlfRvU4+2pIR7HOImLLy8=; b=nZ6AizFDaJa3Fr3ILydXPW/+zPUUBhwBWbeSMJHktO3F7vLqE02iuxR0MV7G13VgcZ xx4gN0naG1Q+93LBZiUUmAS9ZdDLG6dfsZfkXdjqTLGyi0SqB6mcHUnIrhDcn7ZzLyxK V6JQPOC1IMZwHgBCuFRTNPTwY++bxFPt1GxFpr2F/pi9jK3AOnplLT1xgPUAIzlJQKQh w/8sFsX//BDBDU0ixMjkn1gYZljQmbr3gMdDUbuzag4+INISPdGQ0Q+0Cir16r7cwlu1 y0B8w0SOJOYAkosRFJ0aTIsRR5Xw4If8JBAP8dFS/Z82MVWweyk/x5nCcrA845jlxGbx YCAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jGj3Ca+u; 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 h3si5722514oie.105.2020.03.10.06.14.54; Tue, 10 Mar 2020 06:15:06 -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=jGj3Ca+u; 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 S1731716AbgCJNNb (ORCPT + 99 others); Tue, 10 Mar 2020 09:13:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:36254 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731313AbgCJNN2 (ORCPT ); Tue, 10 Mar 2020 09:13:28 -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 07B3D208E4; Tue, 10 Mar 2020 13:13:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1583846007; bh=FqekamkOTbT+AsvmMCl5YEGkr5FD3eEvXeQTkaC9658=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jGj3Ca+uRlYRU3TbyUb7WJyn+8UpJ9zdQxO7DI9/k8c4yeU3IDIjSKCSN+Z3vMR67 cWB8JDu++rWseNU0nf0m9e6OhBbtMlzgoR1Gplp1QK2wESRqlEZURgk2BT84n8a/2v rOTgC9nG5sY8Hl4GdbDviP5/cYIuJ1lV1hpPmEsM= 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 4.19 52/86] x86/pkeys: Manually set X86_FEATURE_OSPKE to preserve existing changes Date: Tue, 10 Mar 2020 13:45:16 +0100 Message-Id: <20200310124533.602563646@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200310124530.808338541@linuxfoundation.org> References: <20200310124530.808338541@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 @@ -387,7 +387,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