From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8AAB0C83027 for ; Thu, 2 Sep 2021 16:36:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 73F4D60F4B for ; Thu, 2 Sep 2021 16:36:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346380AbhIBQhg (ORCPT ); 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-Google-Smtp-Source: ABdhPJxxFMkDLmuTdTkfD6jluqnpwjbDQr6laF4lzbyjb+BdXXTCdkepFXCmGefjgCwNI6xghcnuqA== 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.