Received: by 2002:a19:651b:0:0:0:0:0 with SMTP id z27csp473645lfb; Mon, 2 May 2022 10:31:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyAVo4YAw5uDKOeD+MMNIQaKe84T+Sh23B5qBGQUDdMOoBXF/TJMhRjd9mSS593Bz4gN9bn X-Received: by 2002:a65:490d:0:b0:39e:58cb:b1eb with SMTP id p13-20020a65490d000000b0039e58cbb1ebmr10881953pgs.390.1651512689748; Mon, 02 May 2022 10:31:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651512689; cv=none; d=google.com; s=arc-20160816; b=a9+ryQi1a1mPfcdwcOTHnsSoNe32zHFakwltk6hrUDQNbs4LwPfO91UcIQ8Yf6qBMA WCD4ZD8Cb+z30h+Qw9eJWCNEqCW784VSfIMYzd1TJrlqmf0BCx9+lXP491q6XeG/reWA goHOIVd8laON4B5z2vyqFEjTkiJMSx/0dPSQ1yql345iZVeIsgMI6k+g/ns0MoXOqCQS G+vMO63xbRvSlvSttzcjPzDveDPychwEal4/B3hkrpJstD5ftF25DLpowSo3HuB8rzIv OEo1/toiWmPZ4RxEcOgfKdn0dU5Vj0Ywy2fUUfQZyYO3xLfLLvipIoAQiiaYlC5nUuTl /BVQ== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=RkN7JUMz0DAtONAVPRmRHnP64HBiaCnPPuSBpGqI0Eo=; b=Is4usFN5EHwcy8IVuHwRyMhmsX2HSuShFjy4C2RSMBxAauDiINIKBjocdxf7nlRbpI cLpLczj9Vg0FNE00xQrOGOmY8CsFWNUtWV4agWQ8gpEp8q2lPNurXbYt50rd3JB7xV8I dNWAMOqexQhusQ7btFydrB4nfEZV28ZNOIoanK0Zr0kJfbnt5GsyiYkZ55odBzfWegK4 Dl7xAxX1BeM7HaJX1/JVSCYClyeXj6ut3Ot6lOAMzRYo2byKb+0G9fUpgDxOyKNQmCv0 ZhTd/KorIHEGuhjS27bx1zuqsrIMyUBHxMFZJa+aik4as6simXVOQ1YnyrBaQPiUsiWq RDHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=APvmC5k2; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g15-20020a056a0023cf00b0050d3c71a70bsi16764766pfc.375.2022.05.02.10.30.35; Mon, 02 May 2022 10:31:29 -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=@google.com header.s=20210112 header.b=APvmC5k2; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379396AbiD2RGm (ORCPT + 99 others); Fri, 29 Apr 2022 13:06:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379389AbiD2RGk (ORCPT ); Fri, 29 Apr 2022 13:06:40 -0400 Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5A44B0A7D for ; Fri, 29 Apr 2022 10:03:21 -0700 (PDT) Received: by mail-pj1-x102d.google.com with SMTP id cq17-20020a17090af99100b001dc0386cd8fso2430267pjb.5 for ; Fri, 29 Apr 2022 10:03:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=RkN7JUMz0DAtONAVPRmRHnP64HBiaCnPPuSBpGqI0Eo=; b=APvmC5k2WUKy0VF/8OFRKt3sJeb7n0edWipqz/MuxQSpQdH6U840xRClQNgeSB0/HP CorEabT7uAif+i25odVZeixSMo+CrYTYX0OCnVriOtMIrhAOjQNKxMuoqgWXTAZgMl2P nSOmNzDXu54i8slffbv/+iAa3TqxxKOgSzJCyGmNjc48RJVfqclQY74gl/+qZEQWQaRL G5fGahViQBcY78yDKgrE3WecQcf8RitMoYp1YinysH+SnU/xWu61GQYEH15+arqh/kUj FWhXZjI9jmGQM1gJbsagSphVpJWn67RBBedRQD6AunGL/AormBN2S16j4yeB+1GMnWCZ r4tQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=RkN7JUMz0DAtONAVPRmRHnP64HBiaCnPPuSBpGqI0Eo=; b=Sh8tEA9QOFU+5dfK95qJvFaWpSS4n5zIowEK79k6Y9Di254j2lYJD6tC5AuXzLEuvd eUWhu7CvQ3bMArFhlKXPypqUnSXPWVuUg2xG0cwnVfxflgF/K/XOQNqGakHP5kX7GXJX eesRKi1VHpSapiilyf8upA6trsMGZPKswdJtfGVd+Ch1JfyuAbXuE5F/6SHO+eLzGLdC dVSj8b9w+fnHyIDWUbuTNnC4yXJvqxwBrefpbeXwLNZUo89gzo7B006s3te4fPCZOXPY 9ICqCIMsfP2OpNRmqHLzUJldZK2k6GBqVi8U4NE7Ix9HY4/eyBtMcBS4J0GC1NU06416 iaCg== X-Gm-Message-State: AOAM531bCYrO24YQ9KiRHYI8W3wIV/gOZW8jMFJRCziEbK+Ze4ggg+d1 WU99Wix65ThDsUsxxgOvDHyKMA== X-Received: by 2002:a17:90a:ab81:b0:1ca:8a76:cdda with SMTP id n1-20020a17090aab8100b001ca8a76cddamr5005883pjq.26.1651251801115; Fri, 29 Apr 2022 10:03:21 -0700 (PDT) Received: from google.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id l5-20020a63ea45000000b003c1b2bea056sm2061378pgk.84.2022.04.29.10.03.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Apr 2022 10:03:20 -0700 (PDT) Date: Fri, 29 Apr 2022 17:03:17 +0000 From: Sean Christopherson To: Paolo Bonzini Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, mlevitsk@redhat.com, stable@vger.kernel.org Subject: Re: [PATCH 1/3] KVM: x86: make vendor code check for all nested events Message-ID: References: <20220427173758.517087-1-pbonzini@redhat.com> <20220427173758.517087-2-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20220427173758.517087-2-pbonzini@redhat.com> X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable 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 On Wed, Apr 27, 2022, Paolo Bonzini wrote: > Right now, the VMX preemption timer is special cased via the > hv_timer_pending, but the purpose of the callback can be easily > extended to observing any event that can occur only in non-root > mode. Interrupts, NMIs etc. are already handled properly by > the *_interrupt_allowed callbacks, so what is missing is only > MTF. Check it in the newly-renamed callback, so that > kvm_vcpu_running's call to kvm_check_nested_events > becomes redundant. > > Cc: stable@vger.kernel.org > Reported-by: Maxim Levitsky > Signed-off-by: Paolo Bonzini > --- > arch/x86/include/asm/kvm_host.h | 2 +- > arch/x86/kvm/vmx/nested.c | 7 ++++++- > arch/x86/kvm/x86.c | 8 ++++---- > 3 files changed, 11 insertions(+), 6 deletions(-) > > diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h > index 4ff36610af6a..e2e4f60159e9 100644 > --- a/arch/x86/include/asm/kvm_host.h > +++ b/arch/x86/include/asm/kvm_host.h > @@ -1504,7 +1504,7 @@ struct kvm_x86_ops { > struct kvm_x86_nested_ops { > void (*leave_nested)(struct kvm_vcpu *vcpu); > int (*check_events)(struct kvm_vcpu *vcpu); > - bool (*hv_timer_pending)(struct kvm_vcpu *vcpu); > + bool (*has_events)(struct kvm_vcpu *vcpu); > void (*triple_fault)(struct kvm_vcpu *vcpu); > int (*get_state)(struct kvm_vcpu *vcpu, > struct kvm_nested_state __user *user_kvm_nested_state, > diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c > index 856c87563883..54672025c3a1 100644 > --- a/arch/x86/kvm/vmx/nested.c > +++ b/arch/x86/kvm/vmx/nested.c > @@ -3857,6 +3857,11 @@ static bool nested_vmx_preemption_timer_pending(struct kvm_vcpu *vcpu) > to_vmx(vcpu)->nested.preemption_timer_expired; > } > > +static bool vmx_has_nested_events(struct kvm_vcpu *vcpu) > +{ > + return nested_vmx_preemption_timer_pending(vcpu) || vmx->nested.mtf_pending; This doesn't even compile... arch/x86/kvm/vmx/nested.c: In function ‘vmx_has_nested_events’: arch/x86/kvm/vmx/nested.c:3862:61: error: ‘vmx’ undeclared (first use in this function) 3862 | return nested_vmx_preemption_timer_pending(vcpu) || vmx->nested.mtf_pending; | ^~~ arch/x86/kvm/vmx/nested.c:3862:61: note: each undeclared identifier is reported only once for each function it appears in CC [M] arch/x86/kvm/svm/svm_onhyperv.o arch/x86/kvm/vmx/nested.c:3863:1: error: control reaches end of non-void function [-Werror=return-type] 3863 | } | ^ cc1: all warnings being treated as errors LD [M] arch/x86/kvm/kvm.o