Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp62145pxu; Tue, 6 Oct 2020 18:55:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxXk79Oac4njIycDY2R6UTGxTczH8lRqnRT9RHQ2b4dZolQP2LlJuobd6DVk9EIL1ffGEZn X-Received: by 2002:a17:906:2f85:: with SMTP id w5mr948942eji.1.1602035738422; Tue, 06 Oct 2020 18:55:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602035738; cv=none; d=google.com; s=arc-20160816; b=Dyb7cypR3MpNiBx8TDhvdMX6Y8vO0FMewwbD/xaZ66AdNOJfySe9Ul7QW+MeN0pPYY GD6zIMOen79UjneBYYSeGJAR94KZC2tlbgbtsrC735SLWXRLoU9EvEHI30n8WLaHGIkh 2A5exqI6Eh7eHXZoprb8RCJrTBg5ubwQAtWj19IiQfunFPIKw7FFGe5oS4FVfucOaK78 ZC+O8oR58Sl/X78WOrKrBiVH23OQ0x70YlXGx8bi0ZbKxJG4m6njFo7cvhXpCnMqgW76 +rYIW00Wkldb7bslwPmlMHeGmSUoiV04B3sfGQsH61tON548opKVsirIF+4PMTA6GF0Q kUHg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :ironport-sdr:ironport-sdr; bh=zPPvQIZrNCZpT6NDAv/+lvVHKBXwDE8NZOCQn9dSj10=; b=lZEXOiD8j4sIjm4VgESW5hADWRGL0/DhNTFBY0i984HR4zgg+xPl0hEGzJKemrKj3g 7zUTZbK9IAxVTLHBAb/j1jz/DBJWDgMQ3UL6+tGBKBljad5ebq/wH1eswoKCUvMBo5a9 2Z0ouNBMNCvFeL6pIWVkvJS4fEeC/Khc7WrPExZMeqJZp8ijvh6YTQPNxeYP9sKUknzJ ylXwyt28G0fnVjQUPFSChBWnLFdwiMX50dTpwFX2viStzPPqwrDyvpmaSNP5LQLjKgZX 0lWCddM+fzOryOCe6H3GieumHr48/3ds1TwWXIqtUDLFH76ck7Rcjy1ydzKnHtw2O+8R /3aQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ci27si410685ejc.169.2020.10.06.18.55.14; Tue, 06 Oct 2020 18:55:38 -0700 (PDT) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727288AbgJGBoU (ORCPT + 99 others); Tue, 6 Oct 2020 21:44:20 -0400 Received: from mga09.intel.com ([134.134.136.24]:7786 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725996AbgJGBoT (ORCPT ); Tue, 6 Oct 2020 21:44:19 -0400 IronPort-SDR: augEx6RMjvDLytXLG/GDFNBA2sNW3r6SLo93/tBX1nLOydiaXJV+tKA/2/gVdghC8xT0a/DvAv a7CRZppb8RlQ== X-IronPort-AV: E=McAfee;i="6000,8403,9766"; a="164914598" X-IronPort-AV: E=Sophos;i="5.77,344,1596524400"; d="scan'208";a="164914598" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Oct 2020 18:44:18 -0700 IronPort-SDR: ClxIysU7kjze7rjcytzQqlWKI4Hrh8ofDwhey6mUxV/8Oq67RLswPUT3G7X60HFIQ+ziR+v/2o qzZ0O3o5fI0w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,344,1596524400"; d="scan'208";a="297410300" Received: from sjchrist-coffee.jf.intel.com ([10.54.74.160]) by fmsmga008.fm.intel.com with ESMTP; 06 Oct 2020 18:44:18 -0700 From: Sean Christopherson To: Paolo Bonzini Cc: Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Stas Sergeev Subject: [PATCH 2/6] KVM: VMX: Drop explicit 'nested' check from vmx_set_cr4() Date: Tue, 6 Oct 2020 18:44:13 -0700 Message-Id: <20201007014417.29276-3-sean.j.christopherson@intel.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201007014417.29276-1-sean.j.christopherson@intel.com> References: <20201007014417.29276-1-sean.j.christopherson@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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 99ea57ba2a84..dac93346aca9 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -3104,18 +3104,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.28.0