Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp241841pxf; Wed, 10 Mar 2021 05:28:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJzee+sF2h5pPUj5SKeGSI5y82xcJaxIXKXyllHKGkO5fzcEDGUNSGckjlHjS6S5bhffWfVh X-Received: by 2002:a17:906:a2d3:: with SMTP id by19mr3616483ejb.98.1615382920106; Wed, 10 Mar 2021 05:28:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615382920; cv=none; d=google.com; s=arc-20160816; b=hiq2AvMs1salTIQcFm7HX1+ZobIZXYqQLq4Vr55MO8oGRXtENMZctpABLCtpQCo7At lwED7OGjiQ96lMrmuEgf9QC4Omtw+XvGXza/6hGSu4JK0KJ8z8tEEKPdpa3gCwfCBOTs j0tix2++9817JpGQLwgyj3s/8yiSASeLxWv8OLmPT4AoHzkJBKtd5U35E1jDP2wRSrgL RS4NwnItL37qQ0V+q0J2Echyr2d7T1w4ZjWKkknzsZ96+MQ4teju+kX6Cr2xAdQC9ysj tR+4PmLCN4Jsl9eI4b+ZBjBw9EHroxuQjHyn+6XYI2xlBsFoevacBTXVeV6rVvVKH9No IyzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=c36MzebCT8i/SDG0sj+JpytIzTAqJryvvQ+0NZSW1VI=; b=zFdClf9C5I0ZUVy61q3IOuz9KQDCFLA3rSjg1QoM8TBFBm8syJhULh3l0ZY6TuNfKz 8QJC+laT4w5WaEdpuppb1s755TGCdns0oGRgHHSJ/i0rbZkbWP+IiEtH5PQ8Oj/yWC4+ gBunnoE6v+p1D5GeBh+ssRMaRCG15S8NZgBZklMRyrEa9zlaHW+vZySfvmhel+pm3VOF NsDYYcN1+h4TepDiWc7LyhXwdpljmGv3Z03VUW/NRcwXNexj58q2S8J82q9FB1s1/LPF mYD63nqRD1tDg37XKtis9r1AjNBzT4Q96E2NdcgqeIhbSNL7WmbTCyWxqFKKrV/ufOmv 9NKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=GajVXrZn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v10si9105453eds.85.2021.03.10.05.28.15; Wed, 10 Mar 2021 05:28:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=GajVXrZn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233905AbhCJN13 (ORCPT + 99 others); Wed, 10 Mar 2021 08:27:29 -0500 Received: from mail.kernel.org ([198.145.29.99]:46524 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232787AbhCJNZA (ORCPT ); Wed, 10 Mar 2021 08:25:00 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2A4A464FDC; Wed, 10 Mar 2021 13:24:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615382700; bh=XQQ9uTjCOGkWb5LHQKTQFVtOqVSsw6/cFLW0mJpYp4M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GajVXrZnIOfGoGM5pgzVIOgzbmBcjIgUthBnIKAwKOLkOxjifY62bzHL+vd2eFHGp 6fqCFDUTnvwuomYv1e0XEBHVLtsrBwjxWeRSoqmSyaBnXormCMR7PZCObHAHRjK5uH tn1qNaVvmOJGsgnJW7N1DMowz4QGrs1EOLxm4B08= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vitaly Kuznetsov , Paolo Bonzini , Sasha Levin Subject: [PATCH 5.10 30/49] KVM: x86: Supplement __cr4_reserved_bits() with X86_FEATURE_PCID check Date: Wed, 10 Mar 2021 14:23:41 +0100 Message-Id: <20210310132322.895507927@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210310132321.948258062@linuxfoundation.org> References: <20210310132321.948258062@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Greg Kroah-Hartman From: Vitaly Kuznetsov [ Upstream commit 4683d758f48e6ae87d3d3493ffa00aceb955ee16 ] Commit 7a873e455567 ("KVM: selftests: Verify supported CR4 bits can be set before KVM_SET_CPUID2") reveals that KVM allows to set X86_CR4_PCIDE even when PCID support is missing: ==== Test Assertion Failure ==== x86_64/set_sregs_test.c:41: rc pid=6956 tid=6956 - Invalid argument 1 0x000000000040177d: test_cr4_feature_bit at set_sregs_test.c:41 2 0x00000000004014fc: main at set_sregs_test.c:119 3 0x00007f2d9346d041: ?? ??:0 4 0x000000000040164d: _start at ??:? KVM allowed unsupported CR4 bit (0x20000) Add X86_FEATURE_PCID feature check to __cr4_reserved_bits() to make kvm_is_valid_cr4() fail. Signed-off-by: Vitaly Kuznetsov Message-Id: <20210201142843.108190-1-vkuznets@redhat.com> Signed-off-by: Paolo Bonzini Signed-off-by: Sasha Levin --- arch/x86/kvm/x86.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/x86/kvm/x86.h b/arch/x86/kvm/x86.h index e7ca622a468f..2249a7d7ca27 100644 --- a/arch/x86/kvm/x86.h +++ b/arch/x86/kvm/x86.h @@ -404,6 +404,8 @@ bool kvm_msr_allowed(struct kvm_vcpu *vcpu, u32 index, u32 type); __reserved_bits |= X86_CR4_UMIP; \ if (!__cpu_has(__c, X86_FEATURE_VMX)) \ __reserved_bits |= X86_CR4_VMXE; \ + if (!__cpu_has(__c, X86_FEATURE_PCID)) \ + __reserved_bits |= X86_CR4_PCIDE; \ __reserved_bits; \ }) -- 2.30.1