From patchwork Mon Mar 18 09:06:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paul Durrant X-Patchwork-Id: 10856999 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8927A139A for ; Mon, 18 Mar 2019 09:09:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 710B5292A6 for ; Mon, 18 Mar 2019 09:09:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6549C29235; Mon, 18 Mar 2019 09:09:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id EE481292A6 for ; Mon, 18 Mar 2019 09:08:58 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1h5oEi-0000Sw-05; Mon, 18 Mar 2019 09:07:12 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1h5oEh-0000Sq-C2 for xen-devel@lists.xenproject.org; Mon, 18 Mar 2019 09:07:11 +0000 X-Inumbo-ID: 35c4f344-495d-11e9-bc90-bc764e045a96 Received: from SMTP03.CITRIX.COM (unknown [162.221.156.55]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 35c4f344-495d-11e9-bc90-bc764e045a96; Mon, 18 Mar 2019 09:07:09 +0000 (UTC) X-IronPort-AV: E=Sophos;i="5.58,493,1544486400"; d="scan'208";a="80840007" From: Paul Durrant To: Date: Mon, 18 Mar 2019 09:06:59 +0000 Message-ID: <20190318090700.1538-2-paul.durrant@citrix.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190318090700.1538-1-paul.durrant@citrix.com> References: <20190318090700.1538-1-paul.durrant@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 1/2] viridian: remove synic poll blocking X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Paul Durrant , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP This was added to try to ensure a consistent intack from repeated calls to hvm_vcpu_has_pending_irq(). However there are other ways in which a new IRR bit could be set between such calls. Hence the poll blocking does not actually serve any useful purpose, so it may as well be removed to simplify the code. Signed-off-by: Paul Durrant --- Cc: Jan Beulich Cc: Andrew Cooper Cc: Wei Liu Cc: "Roger Pau Monné" --- xen/arch/x86/hvm/viridian/synic.c | 14 +------------- xen/arch/x86/hvm/vlapic.c | 13 ++++--------- xen/include/asm-x86/hvm/viridian.h | 3 +-- 3 files changed, 6 insertions(+), 24 deletions(-) diff --git a/xen/arch/x86/hvm/viridian/synic.c b/xen/arch/x86/hvm/viridian/synic.c index 0fca5d36e6..2791021bcc 100644 --- a/xen/arch/x86/hvm/viridian/synic.c +++ b/xen/arch/x86/hvm/viridian/synic.c @@ -346,21 +346,9 @@ void viridian_synic_domain_deinit(const struct domain *d) { } -void viridian_synic_poll_once(struct vcpu *v) +void viridian_synic_poll(struct vcpu *v) { - struct viridian_vcpu *vv = v->arch.hvm.viridian; - - if ( vv->polled ) - return; - viridian_time_poll_timers(v); - - vv->polled = true; -} - -void viridian_synic_poll_unblock(const struct vcpu *v) -{ - v->arch.hvm.viridian->polled = false; } bool viridian_synic_deliver_timer_msg(struct vcpu *v, unsigned int sintx, diff --git a/xen/arch/x86/hvm/vlapic.c b/xen/arch/x86/hvm/vlapic.c index aab365f80d..24e8e63c4f 100644 --- a/xen/arch/x86/hvm/vlapic.c +++ b/xen/arch/x86/hvm/vlapic.c @@ -1311,15 +1311,15 @@ int vlapic_has_pending_irq(struct vcpu *v) * a synthetic interrupt may be asserted during the poll. */ if ( has_viridian_synic(v->domain) ) - viridian_synic_poll_once(v); + viridian_synic_poll(v); irr = vlapic_find_highest_irr(vlapic); if ( irr == -1 ) - goto out; + return -1; if ( hvm_funcs.virtual_intr_delivery_enabled && !nestedhvm_vcpu_in_guestmode(v) ) - goto out; + return irr; /* * If APIC assist was set then an EOI may have been avoided. @@ -1340,13 +1340,9 @@ int vlapic_has_pending_irq(struct vcpu *v) (irr & 0xf0) <= (isr & 0xf0) ) { viridian_apic_assist_clear(v); - irr = -1; + return -1; } - out: - if ( irr == -1 ) - viridian_synic_poll_unblock(v); - return irr; } @@ -1381,7 +1377,6 @@ int vlapic_ack_pending_irq(struct vcpu *v, int vector, bool_t force_ack) vlapic_set_vector(vector, &vlapic->regs->data[APIC_ISR]); vlapic_clear_irr(vector, vlapic); - viridian_synic_poll_unblock(v); return 1; } diff --git a/xen/include/asm-x86/hvm/viridian.h b/xen/include/asm-x86/hvm/viridian.h index 5fe2039978..1bea756a26 100644 --- a/xen/include/asm-x86/hvm/viridian.h +++ b/xen/include/asm-x86/hvm/viridian.h @@ -143,8 +143,7 @@ void viridian_apic_assist_clear(const struct vcpu *v); bool viridian_synic_is_auto_eoi_sint(const struct vcpu *v, unsigned int vector); -void viridian_synic_poll_once(struct vcpu *v); -void viridian_synic_poll_unblock(const struct vcpu *v); +void viridian_synic_poll(struct vcpu *v); void viridian_synic_ack_sint(const struct vcpu *v, unsigned int vector); #endif /* __ASM_X86_HVM_VIRIDIAN_H__ */ From patchwork Mon Mar 18 09:07:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paul Durrant X-Patchwork-Id: 10856995 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 86E4B17E6 for ; Mon, 18 Mar 2019 09:08:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6422329235 for ; Mon, 18 Mar 2019 09:08:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5849C292F5; Mon, 18 Mar 2019 09:08:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A792529235 for ; Mon, 18 Mar 2019 09:08:58 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1h5oEl-0000TW-9g; Mon, 18 Mar 2019 09:07:15 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1h5oEk-0000T8-Ek for xen-devel@lists.xenproject.org; Mon, 18 Mar 2019 09:07:14 +0000 X-Inumbo-ID: 35c17d5e-495d-11e9-95a4-93aca05e027d Received: from SMTP03.CITRIX.COM (unknown [162.221.156.55]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 35c17d5e-495d-11e9-95a4-93aca05e027d; Mon, 18 Mar 2019 09:07:09 +0000 (UTC) X-IronPort-AV: E=Sophos;i="5.58,493,1544486400"; d="scan'208";a="80840006" From: Paul Durrant To: Date: Mon, 18 Mar 2019 09:07:00 +0000 Message-ID: <20190318090700.1538-3-paul.durrant@citrix.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190318090700.1538-1-paul.durrant@citrix.com> References: <20190318090700.1538-1-paul.durrant@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 2/2] viridian: fix mistakes in timer expiration and re-start X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Paul Durrant , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP This patch fixes a few issues: - The specification says that a one-shot timers should be marked as disabled at the point of expiry, so the enabled bit should be cleared by stimer_expire() rather than poll_stimer(). For simplicity, call stimer_expire() from start_stimer() for timers that expire immediately rather than open-coding the expiry. - The code omits updating the expiration value for one-shot timers and so the eventual message delivered via the synic will be incorrect. - Periodic timers should only be re-started if they are still enabled so, now that enabled will be already clear for one-shot timers, call start_stimer() from poll_stimer() only if the timer is still enabled. Signed-off-by: Paul Durrant --- Cc: Jan Beulich Cc: Andrew Cooper Cc: Wei Liu Cc: "Roger Pau Monné" --- xen/arch/x86/hvm/viridian/time.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/xen/arch/x86/hvm/viridian/time.c b/xen/arch/x86/hvm/viridian/time.c index 7a759e70b3..692f014fc4 100644 --- a/xen/arch/x86/hvm/viridian/time.c +++ b/xen/arch/x86/hvm/viridian/time.c @@ -187,7 +187,7 @@ static void stop_stimer(struct viridian_stimer *vs) static void stimer_expire(void *data) { - const struct viridian_stimer *vs = data; + struct viridian_stimer *vs = data; struct vcpu *v = vs->v; struct viridian_vcpu *vv = v->arch.hvm.viridian; unsigned int stimerx = vs - &vv->stimer[0]; @@ -197,6 +197,9 @@ static void stimer_expire(void *data) set_bit(stimerx, &vv->stimer_pending); vcpu_kick(v); + + if ( !vs->config.periodic ) + vs->config.enabled = 0; } static void start_stimer(struct viridian_stimer *vs) @@ -256,7 +259,8 @@ static void start_stimer(struct viridian_stimer *vs) expiration = vs->count; if ( expiration - now <= 0 ) { - set_bit(stimerx, &vv->stimer_pending); + vs->expiration = expiration; + stimer_expire(vs); return; } } @@ -285,10 +289,8 @@ static void poll_stimer(struct vcpu *v, unsigned int stimerx) clear_bit(stimerx, &vv->stimer_pending); - if ( vs->config.periodic ) + if ( vs->config.enabled ) start_stimer(vs); - else - vs->config.enabled = 0; } void viridian_time_poll_timers(struct vcpu *v)