Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp1860643rwb; Fri, 19 Aug 2022 10:35:26 -0700 (PDT) X-Google-Smtp-Source: AA6agR4u8uihj0JF4p7mz4fWNEDP74X15VDUlXrN1KdEGRmcKZL4gmDCDqp3zcEoJge43L5u62zQ X-Received: by 2002:a17:90a:5d8a:b0:1f7:3c7a:9cc7 with SMTP id t10-20020a17090a5d8a00b001f73c7a9cc7mr9607798pji.207.1660930526635; Fri, 19 Aug 2022 10:35:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660930526; cv=none; d=google.com; s=arc-20160816; b=hNRNjF0IyrRvxCcDP0AuggWFEy6nauOi52LA5Wme60faskhQdfA5s7tQh9wmjzZTsE +pgHAb8xNE6mDM96b1vVS2Kz+F6IXeJEPO9fcR59QaBuOouXxi6bJ1lfZsZd9oP4I9SN EbQi3SSdeMKJxmpZKNQlvg3jrosAQ0d+NwgbOJYqMjJr4jqc/5wtslZpCeANweAXwubE gTZ/zR7KA22zM15rs5KMzRC8pJukLpaRrzrKuVqFw8ddGtyu2uPAtx3u63Z8679FPb8h tgFHvK4+IQ0P4YoXMi73HMQ5ySiBbNX68nfswpZKzos5E/du39qY2AQSWrvXU2msdsJq Uadg== 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=UKeKG6BFwOLBOYERXKqD9IOpnml9fXQ2+ilbCyVSDbQ=; b=HTut7+hL+3sJj6y2ZDuj/DPfNHIOa10LsdBuEcfIOh2tsqbi2wXTsO7Nhs6ZdnOJO1 qj6z2ZCRAvgpKd/iWYS/XesJ0d7+jO5AXr1kdM2tOtWXlVJk+ArUygTZJ5CtKdzuXt0j jZvFn0tUbZuz9w0PzWbDERpDqRi7n4LglVy46KCxbTCMbKZxKc+8IZMw7boR59GWRsKO L0p8KqV3e3WKfIVBpubqFswTcyIpEf/4cri7qwom+osYprplK0k+ZSI0KXeszqIq7vWd 6uV69KJqhdVrE2RliueIuQWhPy1zAfqkA6clnfWhxpBjf8pelX8OB/b6mYZ10dYiq9/I WoKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=10NN1a2u; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a19-20020a62d413000000b00528c39ccb81si4425232pfh.277.2022.08.19.10.35.15; Fri, 19 Aug 2022 10:35:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=10NN1a2u; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S1353956AbiHSQrj (ORCPT + 99 others); Fri, 19 Aug 2022 12:47:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353966AbiHSQpd (ORCPT ); Fri, 19 Aug 2022 12:45:33 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6043512A1D3; Fri, 19 Aug 2022 09:11:40 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id E6964B82822; Fri, 19 Aug 2022 16:11:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3ABE5C433D7; Fri, 19 Aug 2022 16:11:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660925472; bh=m12qmVYfHBX0x5j74m/PMuBKWQQgC3NVEWHrfsdh0Kk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=10NN1a2uGUES14nB2Rk2kKvB1pQTkZXRX/zq9bt1KEW1fxz5F4NoGw/dS6/Vlk1by JdIL4qCDUS92fW0NIPIyBXwN1Pdss0HOQSrYzoSjk+TYb8zGXB/hnLLbGA3Ggeskp+ XBox7zJs/veQLjnr++FmMoqGHmMqEhpXT1SWrd8k= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sean Christopherson , Paolo Bonzini , Sasha Levin Subject: [PATCH 5.10 500/545] KVM: VMX: Drop explicit nested check from vmx_set_cr4() Date: Fri, 19 Aug 2022 17:44:30 +0200 Message-Id: <20220819153851.866986742@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220819153829.135562864@linuxfoundation.org> References: <20220819153829.135562864@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sean Christopherson [ Upstream commit a447e38a7fadb2e554c3942dda183e55cccd5df0 ] Drop vmx_set_cr4()'s explicit check on the 'nested' module param now that common x86 handles the check by incorporating VMXE into the CR4 reserved bits, via kvm_cpu_caps. X86_FEATURE_VMX is set in kvm_cpu_caps (by vmx_set_cpu_caps()), if and only if 'nested' is true. No functional change intended. Signed-off-by: Sean Christopherson Message-Id: <20201007014417.29276-3-sean.j.christopherson@intel.com> Signed-off-by: Paolo Bonzini Signed-off-by: Sasha Levin --- arch/x86/kvm/vmx/vmx.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index 1b75847d8a49..154ec5d8cdf5 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -3211,18 +3211,13 @@ int vmx_set_cr4(struct kvm_vcpu *vcpu, unsigned long cr4) } } - if (cr4 & X86_CR4_VMXE) { - /* - * To use VMXON (and later other VMX instructions), a guest - * must first be able to turn on cr4.VMXE (see handle_vmon()). - * So basically the check on whether to allow nested VMX - * is here. We operate under the default treatment of SMM, - * so VMX cannot be enabled under SMM. Note, guest CPUID is - * intentionally ignored, it's handled by cr4_guest_rsvd_bits. - */ - if (!nested || is_smm(vcpu)) - return 1; - } + /* + * We operate under the default treatment of SMM, so VMX cannot be + * enabled under SMM. Note, whether or not VMXE is allowed at all is + * handled by kvm_valid_cr4(). + */ + if ((cr4 & X86_CR4_VMXE) && is_smm(vcpu)) + return 1; if (vmx->nested.vmxon && !nested_cr4_valid(vcpu, cr4)) return 1; -- 2.35.1