Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp789447pxb; Tue, 5 Apr 2022 23:24:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwWMEFoujTtGYcZrV6r2Q9t2Q4//uGTBk5LJO8nlT+wCVA2+hwAOXHXhVlEPZecwaQODmIu X-Received: by 2002:a63:7888:0:b0:398:91:7b5e with SMTP id t130-20020a637888000000b0039800917b5emr5979205pgc.212.1649226284723; Tue, 05 Apr 2022 23:24:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649226284; cv=none; d=google.com; s=arc-20160816; b=B6VwZdEuXEFYMq/b5+jUlcPShptYdOINUiw3UG9Uw5Ix0/Rix3U6EoFNKnGEF4rbWM Mba0MInRiY+/2NUHBMvSI1HkswHiQE8FidQBR2KQU8+Hf63jTBZA6Dntzi2Wf6WGMj5X 2bO/fthLLQBvAR17exZzPpt2qvuM+SBrTiPu10Xw8so+VH65RcaUKAtkcSLlNQWRTFru 7sh6FZD6lN9kzNob6+BY/NpPafFafUUUE+lfOkZHcWwy8jqC7psuToWMVp5zHDzVFU5t OCPgyKGL6O/W+Bvb1Ah0tlF4hzIrSimByWExgKeUOWRDvEn/Sfxm9BzTdbfybYlBEbmm xJZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=iGOKDprACpATycXmJsJYt0TllS34C5LvZmKh+gyonAQ=; b=EIIv8CcSknK3RY0CuiAEY4iWEDFCgU17an8iOq45jDZnqHIcSQtfnIGxBOyUAwz+Wg 0ICk0oZZdBqlxD/QYQky2KE76WyVPvlGCSFbeapW8Dsx49sqKWx0fnxPyxL07plrfNBT p9wHStT3I4KDwNE+WA8oVwg6Igl/NCluhuNNmwDSgieo+IaYDJNbi02nwLL49+HPYDMq mibiLqAax781boCLn0PoFzcnhOrmq7lrXjWMIGigjNDwXP/Q+NDl5mKfz4LxoDKmI+Ge 3dIXUT2gVcOLAMqkxavwyNfVDeOvYvBQaJdlWqMM6qjs+M0bq+kvtDAfLIcTKOWd+GwO g9qw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=KNRGDcoI; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id z3-20020aa78883000000b004fa3a8e0097si16866067pfe.334.2022.04.05.23.24.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Apr 2022 23:24:44 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=KNRGDcoI; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CAD5C470092; Tue, 5 Apr 2022 23:23:42 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383103AbiDEU3o (ORCPT + 99 others); Tue, 5 Apr 2022 16:29:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1457224AbiDEQC5 (ORCPT ); Tue, 5 Apr 2022 12:02:57 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0C4082BCD for ; Tue, 5 Apr 2022 08:33:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1649172836; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iGOKDprACpATycXmJsJYt0TllS34C5LvZmKh+gyonAQ=; b=KNRGDcoIJYi0FhWh3t4fufY2bBzPXVj39HwY5PCXVBARvBsaJrnQuYDTQ/G+VXEEme4QbV FugiiNjzKEmcloI9egT9Wyc278dwwIH+nusp6w8u0bpTeh2R6mSTdj0jZXVm5KpHri4MG6 DYeT5exSveoXrfrgT1t4iP+raWJxLMM= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-112-7V-XLK6eOv6CE4gvfAzzWQ-1; Tue, 05 Apr 2022 11:33:55 -0400 X-MC-Unique: 7V-XLK6eOv6CE4gvfAzzWQ-1 Received: by mail-wm1-f70.google.com with SMTP id a16-20020a05600c349000b0038e6392a346so1399750wmq.4 for ; Tue, 05 Apr 2022 08:33:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=iGOKDprACpATycXmJsJYt0TllS34C5LvZmKh+gyonAQ=; b=2xIcGUZpmI1M22c490Y6LtKb0DoKk0Hk03P3c/4FyIcLPw7ysX8rfgzrTJ0PpenuJq Oa82qRGyTtccsUnXt6puoPFhN4wxBgp5+XHL/YZzvJOh5jR8BszaznKBtDJy2sJW5gBI ssstCb/YmYmvX5EFk7NR1Rbcjq62gOISx1G5n+hiKZ2a1O38pEBB65eTQFXlD5fcCxPj wggFQR5Czxn4CNBnC3+G09THKIfVXaYA0AU8ICg+AI8iLsY/YTbyhwRE0tl6yrrv//+B 6Aglqbnc//ipUR+KsD5ajRzFUHV6YkpZh+jmxG++BPdN8pZNI5Saii1ORlF5hVpdi+Tg t2Bg== X-Gm-Message-State: AOAM5321CVky8nVt7ecITnaOsnMC5K2e2EvSVvpoKsy4pBSzg5iEnYDc I9Ctp3NUsDP0ixZG/pAdsxo+HODJudv0+XrZgbV21bVZ7uvclBEPCmqX4ueu/FlWp4VUuS0KMRd j/yF/2SxlUs0Y9pq2D6ASz/Tt X-Received: by 2002:adf:9062:0:b0:206:b5e:e934 with SMTP id h89-20020adf9062000000b002060b5ee934mr3260392wrh.434.1649172833799; Tue, 05 Apr 2022 08:33:53 -0700 (PDT) X-Received: by 2002:adf:9062:0:b0:206:b5e:e934 with SMTP id h89-20020adf9062000000b002060b5ee934mr3260366wrh.434.1649172833544; Tue, 05 Apr 2022 08:33:53 -0700 (PDT) Received: from [10.32.181.87] (nat-pool-mxp-t.redhat.com. [149.6.153.186]) by smtp.googlemail.com with ESMTPSA id e12-20020a5d6d0c000000b001a65e479d20sm14953605wrq.83.2022.04.05.08.33.52 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 05 Apr 2022 08:33:52 -0700 (PDT) Message-ID: Date: Tue, 5 Apr 2022 17:33:51 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: [RFC PATCH v5 076/104] KVM: x86: Add option to force LAPIC expiration wait Content-Language: en-US To: isaku.yamahata@intel.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: isaku.yamahata@gmail.com, Jim Mattson , erdemaktas@google.com, Connor Kuehl , Sean Christopherson References: <52b0451a4ffba54455acf710b443715ac16effd4.1646422845.git.isaku.yamahata@intel.com> From: Paolo Bonzini In-Reply-To: <52b0451a4ffba54455acf710b443715ac16effd4.1646422845.git.isaku.yamahata@intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE 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 3/4/22 20:49, isaku.yamahata@intel.com wrote: > From: Sean Christopherson > > Add an option to skip the IRR check-in kvm_wait_lapic_expire(). This > will be used by TDX to wait if there is an outstanding notification for > a TD, i.e. a virtual interrupt is being triggered via posted interrupt > processing. KVM TDX doesn't emulate PI processing, i.e. there will > never be a bit set in IRR/ISR, so the default behavior for APICv of > querying the IRR doesn't work as intended. Would be better to explain "doesn't work as intended" more verbosely. Otherwise, Reviewed-by: Paolo Bonzini Paolo > Signed-off-by: Sean Christopherson > Signed-off-by: Isaku Yamahata > --- > arch/x86/kvm/lapic.c | 4 ++-- > arch/x86/kvm/lapic.h | 2 +- > arch/x86/kvm/svm/svm.c | 2 +- > arch/x86/kvm/vmx/vmx.c | 2 +- > 4 files changed, 5 insertions(+), 5 deletions(-) > > diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c > index 9322e6340a74..d49f029ef0e3 100644 > --- a/arch/x86/kvm/lapic.c > +++ b/arch/x86/kvm/lapic.c > @@ -1620,12 +1620,12 @@ static void __kvm_wait_lapic_expire(struct kvm_vcpu *vcpu) > __wait_lapic_expire(vcpu, tsc_deadline - guest_tsc); > } > > -void kvm_wait_lapic_expire(struct kvm_vcpu *vcpu) > +void kvm_wait_lapic_expire(struct kvm_vcpu *vcpu, bool force_wait) > { > if (lapic_in_kernel(vcpu) && > vcpu->arch.apic->lapic_timer.expired_tscdeadline && > vcpu->arch.apic->lapic_timer.timer_advance_ns && > - lapic_timer_int_injected(vcpu)) > + (force_wait || lapic_timer_int_injected(vcpu))) > __kvm_wait_lapic_expire(vcpu); > } > EXPORT_SYMBOL_GPL(kvm_wait_lapic_expire); > diff --git a/arch/x86/kvm/lapic.h b/arch/x86/kvm/lapic.h > index 2b44e533fc8d..2a0119ef9e96 100644 > --- a/arch/x86/kvm/lapic.h > +++ b/arch/x86/kvm/lapic.h > @@ -233,7 +233,7 @@ static inline int kvm_lapic_latched_init(struct kvm_vcpu *vcpu) > > bool kvm_apic_pending_eoi(struct kvm_vcpu *vcpu, int vector); > > -void kvm_wait_lapic_expire(struct kvm_vcpu *vcpu); > +void kvm_wait_lapic_expire(struct kvm_vcpu *vcpu, bool force_wait); > > void kvm_bitmap_or_dest_vcpus(struct kvm *kvm, struct kvm_lapic_irq *irq, > unsigned long *vcpu_bitmap); > diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c > index c7eec23e9ebe..a46415845f48 100644 > --- a/arch/x86/kvm/svm/svm.c > +++ b/arch/x86/kvm/svm/svm.c > @@ -3766,7 +3766,7 @@ static __no_kcsan fastpath_t svm_vcpu_run(struct kvm_vcpu *vcpu) > clgi(); > kvm_load_guest_xsave_state(vcpu); > > - kvm_wait_lapic_expire(vcpu); > + kvm_wait_lapic_expire(vcpu, false); > > /* > * If this vCPU has touched SPEC_CTRL, restore the guest's value if > diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c > index 00f88aa25047..9b7bd52d19a9 100644 > --- a/arch/x86/kvm/vmx/vmx.c > +++ b/arch/x86/kvm/vmx/vmx.c > @@ -6838,7 +6838,7 @@ fastpath_t vmx_vcpu_run(struct kvm_vcpu *vcpu) > if (enable_preemption_timer) > vmx_update_hv_timer(vcpu); > > - kvm_wait_lapic_expire(vcpu); > + kvm_wait_lapic_expire(vcpu, false); > > /* > * If this vCPU has touched SPEC_CTRL, restore the guest's value if