Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3847633ybb; Mon, 23 Mar 2020 08:46:36 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuF9O5otKLhhbBSNlaUrjQf++K6bkhq5V3Ifmpx8R0KwCvtnlw/boK+v8bK+gIq9UDtAJ44 X-Received: by 2002:aca:61d4:: with SMTP id v203mr17966514oib.72.1584978396589; Mon, 23 Mar 2020 08:46:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584978396; cv=none; d=google.com; s=arc-20160816; b=VyNXCYuJ7pxjFng89HX0GCahSk0lYhnfHiVxEVbnPuH+mYuFGJhXGSyS+hfsMKqVeI tIF09F7FMRDB2gmqQ3ntpK6C2PJhdm2IMDckXFNRmxqi5aB9DwJDMaDk7GaXCr+hnktp rN5Ap7cL9x1exjL+r1Ym+J4lqIyuGSV5mSv9U/BWdzTFUcJl9RVRLPjy73O5glw95s9X 6b7tACiRB8bNWF6se6t5C1qne8sd3AxtbtiodTmrHMbar6vUEVp0usMsQZkrEsN1JRzD TlS7c9RcUSVLSosT2JP8kQU2/rUK1qgBsm7O4LXTLStSYUSVJ60q0Ii+y7VyxOOoEFy6 3Blg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:ironport-sdr:ironport-sdr; bh=z65X92DNd1llK2SgD2KtMm8qgbpfzDh3dZb086ZZDHg=; b=Q0+LM6dUnQcNuRb2JK9VSMGAmL2jIYw4hehYHdMoY5FBJrc9JqSzD9oEijfSdS8utp 6DZ1pqJEriKH+kPK8RW6zsK+tRdUxJIzORLGK8zE05IkxYlw7A5PC7IAhlvLOfnWT5gu iUgmykxkEQJMtSiNiHln4ZzjIWLSQ/A0RSfWTUv2hXCWwdy9TVv+89CNALAZNdszTZ14 9cOXnnEj6sWPRDcCfgOo/8Jm90qNEdleqz4s8/GNg6RlrBiDa0rrxQZICnte/aC8DbPi Rg7k/+mjAIWdz4P9ZTb4Ti3mtvy0x2FM3Zbx4zq6tmcJwGjg4kGiZF4lYhLlIler5Rcq LC0g== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x8si8465846otb.140.2020.03.23.08.46.22; Mon, 23 Mar 2020 08:46:36 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727356AbgCWPp5 (ORCPT + 99 others); Mon, 23 Mar 2020 11:45:57 -0400 Received: from mga14.intel.com ([192.55.52.115]:15279 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726049AbgCWPp5 (ORCPT ); Mon, 23 Mar 2020 11:45:57 -0400 IronPort-SDR: u7ZN4ARRIn8F7MchxD9fwYKEgcQj6DabdvWSO1U6JYjlwOcnIxl8icbOdiAyv+Io21fq8Cp805 sq4bymdjfXaw== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Mar 2020 08:45:56 -0700 IronPort-SDR: bu1ik5F+bnR7ftr76+AYqs6SQU+gaMwj5hoyqpsiWSdHEg6qDPt3p7v6V7BJ2jXFoZan5rr/QE RFjx0wMxztJQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,296,1580803200"; d="scan'208";a="249669076" Received: from sjchrist-coffee.jf.intel.com (HELO linux.intel.com) ([10.54.74.202]) by orsmga006.jf.intel.com with ESMTP; 23 Mar 2020 08:45:55 -0700 Date: Mon, 23 Mar 2020 08:45:55 -0700 From: Sean Christopherson To: Vitaly Kuznetsov Cc: Paolo Bonzini , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Ben Gardon , Junaid Shahid , Liran Alon , Boris Ostrovsky , John Haxby , Miaohe Lin , Tom Lendacky Subject: Re: [PATCH v3 02/37] KVM: nVMX: Validate the EPTP when emulating INVEPT(EXTENT_CONTEXT) Message-ID: <20200323154555.GH28711@linux.intel.com> References: <20200320212833.3507-1-sean.j.christopherson@intel.com> <20200320212833.3507-3-sean.j.christopherson@intel.com> <871rpj9lay.fsf@vitty.brq.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <871rpj9lay.fsf@vitty.brq.redhat.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 23, 2020 at 03:51:17PM +0100, Vitaly Kuznetsov wrote: > Sean Christopherson writes: > > > Signal VM-Fail for the single-context variant of INVEPT if the specified > > EPTP is invalid. Per the INEVPT pseudocode in Intel's SDM, it's subject > > to the standard EPT checks: > > > > If VM entry with the "enable EPT" VM execution control set to 1 would > > fail due to the EPTP value then VMfail(Invalid operand to INVEPT/INVVPID); > > > > Fixes: bfd0a56b90005 ("nEPT: Nested INVEPT") > > Signed-off-by: Sean Christopherson > > --- > > arch/x86/kvm/vmx/nested.c | 6 +++++- > > 1 file changed, 5 insertions(+), 1 deletion(-) > > > > diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c > > index 8578513907d7..f3774cef4fd4 100644 > > --- a/arch/x86/kvm/vmx/nested.c > > +++ b/arch/x86/kvm/vmx/nested.c > > @@ -5156,8 +5156,12 @@ static int handle_invept(struct kvm_vcpu *vcpu) > > } > > > > switch (type) { > > - case VMX_EPT_EXTENT_GLOBAL: > > case VMX_EPT_EXTENT_CONTEXT: > > + if (!nested_vmx_check_eptp(vcpu, operand.eptp)) > > + return nested_vmx_failValid(vcpu, > > + VMXERR_INVALID_OPERAND_TO_INVEPT_INVVPID); > > I was going to ask "and we don't seem to check that current nested VMPTR > is valid, how can we know that nested_vmx_failValid() is the right > VMfail() to use" but then I checked our nested_vmx_failValid() and there > is a fallback there: > > if (vmx->nested.current_vmptr == -1ull && !vmx->nested.hv_evmcs) > return nested_vmx_failInvalid(vcpu); > > so this is a non-issue. My question, however, transforms into "would it > make sense to introduce nested_vmx_fail() implementing the logic from > SDM: > > VMfail(ErrorNumber): > IF VMCS pointer is valid > THEN VMfailValid(ErrorNumber); > ELSE VMfailInvalid; > FI; > Hmm, I wouldn't be opposed to such a wrapper. It would pair with nested_vmx_succeed(). > > > + fallthrough; > > + case VMX_EPT_EXTENT_GLOBAL: > > /* > > * TODO: Sync the necessary shadow EPT roots here, rather than > > * at the next emulated VM-entry. > > Reviewed-by: Vitaly Kuznetsov > > -- > Vitaly >