Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp545109pxb; Thu, 2 Sep 2021 09:39:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzaRDOBzuK+GntAUntA1MTGtC9I3Qyh36OVgByVZBFeSSy2MunuTeTqPSf8tUs/X2Un1Erv X-Received: by 2002:a17:906:2a8e:: with SMTP id l14mr4688702eje.321.1630600798139; Thu, 02 Sep 2021 09:39:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630600798; cv=none; d=google.com; s=arc-20160816; b=goIJym3T/L8P2agOTU+0HYzb1a2wBgQ8d0LTt8nLkDujmUNQrvKypSeYmHW0nWYdXp ZIwrTbJgm9Nee+kxXpa4ig042uRKCfXgRLinO5dFbFxKBd2HtsZH22iIyFBb7JDmc5Pm l/KGqLhD4PQEaJbZWZr0w9GtJe3VfLGIXZa9yVwtQ6yVHpdCEoyIyCdkokadrGHuCOkF X4zhmcRJzpRW3PyExyUxHo2nnpIuNNRJIJNXDIkVsS55YFGz+3dm2xRlx//So11HXTPw TSDpGT66jlfAbfL37ghBLGhab2PKohHlQ0Wn1+9vaW4yaDPrR/yaAvRLzrWudvuJeVnv pGMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=WoqzlkSq/fGvPkW8YSM9+7jUzqSLn8LthZIO2IYZaaI=; b=EOUc4D6F+AMtDC0kJ3gFaAm5gKLB53azMwcbt8v1HX8xKK8Sq8ixh7CaAX6cKL2gHE Immid8GCr4WLWwBJbkHHBhkEntC5zXxJsPXNuYXFctUv6UITHdlO7GMl6/OfsXDDk4f4 4m4yxVoZId69J9JXxmLr6XV5bw0GWabmx4fcILM+Rc1uwIBiQ2b7Eb2ySlYTolWLZaCo PMiMsrP7E5mrsAJdVMwEFFdCb4OlPXPvEcoGOpwmYtD2aT7ONR4T+dyEGfl7j93kY6kZ WLE+OZrRTcBbV/OXXWYGwIH3nBJkCWCzyVOoT8pf/mBXfzRLQf0a9tnk5SLEPVrD6gan LgEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=EEt3jt+S; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m3si2506952edq.359.2021.09.02.09.39.08; Thu, 02 Sep 2021 09:39:58 -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; dkim=pass header.i=@google.com header.s=20161025 header.b=EEt3jt+S; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346359AbhIBQhg (ORCPT + 99 others); Thu, 2 Sep 2021 12:37:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231400AbhIBQhf (ORCPT ); Thu, 2 Sep 2021 12:37:35 -0400 Received: from mail-pg1-x530.google.com (mail-pg1-x530.google.com [IPv6:2607:f8b0:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 113BAC061757 for ; Thu, 2 Sep 2021 09:36:37 -0700 (PDT) Received: by mail-pg1-x530.google.com with SMTP id w8so2549572pgf.5 for ; Thu, 02 Sep 2021 09:36:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=WoqzlkSq/fGvPkW8YSM9+7jUzqSLn8LthZIO2IYZaaI=; b=EEt3jt+S/Vci4zOc2xXUi/q+4p+B26VNW1UEEVqkibBi6mK2FwOUk1MdFlVSEMLOrJ d/Y1GQP1SHYBP3qaD29j6I/xwZ4Qk6GCSKQojlmJgH3IxGgE3RmB94Mq3pKkaiDkshak M3wC0yRrjXekqCh34ATBmVCBiyibb4kkXb9l9mojlO6gZxz2/gW/J9VLrdiR8JNp22Mi mlBrnft4AALtSAiy7BVK00Yxgom9yCxS/J/MXfpPmtlBmp5RC42QjjAEjsYWmM5Hapea V070XUV1Hs3cEmbIeKHAHZY/z5MQcknVUpkcFz6y4FchLBtfjAGHkgRGrCo+n6SdxsTn Y3KA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=WoqzlkSq/fGvPkW8YSM9+7jUzqSLn8LthZIO2IYZaaI=; b=jlou8g2hjWRLO+x9Dd6fiKAOwQLXUrpGUsOlAjNA/4m+FPvNO/IMxn/aiEjhlQuR7Q 1rjOYVelDfLpmD9F1bladWfD8lQznfuoAblWy8LL4xqfRI4zEBTpLDsGMijlbK8rMKxO yk7Cn7r1OwEoZRRpxwhB2vHTRp1IV7FDYFy3LCAyMQX/z2joorwp0ruhlBSD0FuaVAgZ CEKn8GbF70M92yZwwU0QFMlcLEJuJb/3E2g2gML1NP5/nyUQ0UodsGM1ylAWTPsTbO9O nOhxMC5UI7PToZ5VornxkmG4dedP09Hnr2T64k1bNJ4ofg1AlHMnLfshENjP4JUR/iQy Xn4g== X-Gm-Message-State: AOAM530A3hcuU0rzBI/sXaWH1i1G7cPhK6gFwZeaseHRD2fIjqyoS90D CifBUxp/pqbRsONCc51EXYtjeA== X-Received: by 2002:a63:dc03:: with SMTP id s3mr4136239pgg.88.1630600596415; Thu, 02 Sep 2021 09:36:36 -0700 (PDT) Received: from google.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id p9sm3646853pgn.36.2021.09.02.09.36.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Sep 2021 09:36:35 -0700 (PDT) Date: Thu, 2 Sep 2021 16:36:32 +0000 From: Sean Christopherson To: Xiaoyao Li Cc: Tao Xu , pbonzini@redhat.com, vkuznets@redhat.com, wanpengli@tencent.com, jmattson@google.com, joro@8bytes.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, hpa@zytor.com, x86@kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] KVM: VMX: Enable Notify VM exit Message-ID: References: <20210525051204.1480610-1-tao3.xu@intel.com> <080602dc-f998-ec13-ddf9-42902aa477de@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 02, 2021, Sean Christopherson wrote: > On Tue, Aug 03, 2021, Xiaoyao Li wrote: > > On 8/2/2021 11:46 PM, Sean Christopherson wrote: > > > > > > @@ -5642,6 +5653,31 @@ static int handle_bus_lock_vmexit(struct kvm_vcpu *vcpu) > > > > > > return 0; > > > > > > } > > > > > > +static int handle_notify(struct kvm_vcpu *vcpu) > > > > > > +{ > > > > > > + unsigned long exit_qual = vmx_get_exit_qual(vcpu); > > > > > > + > > > > > > + if (!(exit_qual & NOTIFY_VM_CONTEXT_INVALID)) { > > > > > > > > > > What does CONTEXT_INVALID mean? The ISE doesn't provide any information whatsoever. > > > > > > > > It means whether the VM context is corrupted and not valid in the VMCS. > > > > > > Well that's a bit terrifying. Under what conditions can the VM context become > > > corrupted? E.g. if the context can be corrupted by an inopportune NOTIFY exit, > > > then KVM needs to be ultra conservative as a false positive could be fatal to a > > > guest. > > > > > > > Short answer is no case will set the VM_CONTEXT_INVALID bit. > > But something must set it, otherwise it wouldn't exist. The condition(s) under > which it can be set matters because it affects how KVM should respond. E.g. if > the guest can trigger VM_CONTEXT_INVALID at will, then we should probably treat > it as a shutdown and reset the VMCS. Oh, and "shutdown" would be relative to the VMCS, i.e. if L2 triggers a NOTIFY exit with VM_CONTEXT_INVALID then KVM shouldn't kill the entire VM. The least awful option would probably be to synthesize a shutdown VM-Exit to L1. That won't communicate to L1 that vmcs12 state is stale/bogus, but I don't see any way to handle that via an existing VM-Exit reason :-/ > But if VM_CONTEXT_INVALID can occur if and only if there's a hardware/ucode > issue, then we can do: > > if (KVM_BUG_ON(exit_qual & NOTIFY_VM_CONTEXT_INVALID, vcpu->kvm)) > return -EIO; > > Either way, to enable this by default we need some form of documentation that > describes what conditions lead to VM_CONTEXT_INVALID.