From patchwork Wed Aug 13 16:29:41 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 35374 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f70.google.com (mail-pa0-f70.google.com [209.85.220.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 60AF520DCC for ; Wed, 13 Aug 2014 16:32:48 +0000 (UTC) Received: by mail-pa0-f70.google.com with SMTP id lf10sf82530291pab.9 for ; Wed, 13 Aug 2014 09:32:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:mime-version:cc:subject:precedence:list-id :list-unsubscribe:list-post:list-help:list-subscribe:sender :errors-to:x-original-sender:x-original-authentication-results :mailing-list:list-archive:content-type:content-transfer-encoding; bh=AglKisO6qq9EW+PeoySW49qpmVfDZK9Umw6aLNT8iQY=; b=PfDI6cFyLAk23jIlDR7I8DjKITv/PrechgVS5a4ZZx9x7kIfKZZaxeHUSdTGqSnBcB LsTfX9xYFf1MeMZ9d+cC3mP7UXD1ROJsE4DldxMyhflva9JFJ3ey8AGB99mX2M0NNlzt xZEPwkedZzVO1Y7S4DamJv/07Xy9yqtNR7pDlYc3oY6344A56R0ihtQGibN020JjliS5 08bFIJ3NYATbBiMq7RkRG53Fs2lb0GVags5nl7cYCVCL1ZUX95hz/JsZN1Nfb8rf0aOw gN3P2JXNOAZTJBjboW/16WT47sGs7fFpLuMPyzPYhh1fHVgWHyo5GThZvEKyYdSFZpD8 2slg== X-Gm-Message-State: ALoCoQlbSQFQtJzs/45a3kTNs4hHfutjFXZvELBvIVTMzbwwbaUI7W7e0XoGAALyI44PrpJGBKPr X-Received: by 10.66.122.101 with SMTP id lr5mr2832869pab.19.1407947567703; Wed, 13 Aug 2014 09:32:47 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.95.21 with SMTP id h21ls655847qge.52.gmail; Wed, 13 Aug 2014 09:32:47 -0700 (PDT) X-Received: by 10.220.202.9 with SMTP id fc9mr4868855vcb.40.1407947567571; Wed, 13 Aug 2014 09:32:47 -0700 (PDT) Received: from mail-vc0-f171.google.com (mail-vc0-f171.google.com [209.85.220.171]) by mx.google.com with ESMTPS id m8si1407297vcj.67.2014.08.13.09.32.47 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 13 Aug 2014 09:32:47 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.171 as permitted sender) client-ip=209.85.220.171; Received: by mail-vc0-f171.google.com with SMTP id hq11so15343410vcb.16 for ; Wed, 13 Aug 2014 09:32:47 -0700 (PDT) X-Received: by 10.221.47.9 with SMTP id uq9mr2090852vcb.48.1407947567488; Wed, 13 Aug 2014 09:32:47 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp344297vcb; Wed, 13 Aug 2014 09:32:46 -0700 (PDT) X-Received: by 10.42.226.69 with SMTP id iv5mr7892772icb.43.1407947566286; Wed, 13 Aug 2014 09:32:46 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id j11si31843561igf.27.2014.08.13.09.32.45 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 13 Aug 2014 09:32:46 -0700 (PDT) Received-SPF: none (google.com: xen-devel-bounces@lists.xen.org does not designate permitted sender hosts) client-ip=50.57.142.19; Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XHbSF-0003Qd-Lg; Wed, 13 Aug 2014 16:31:15 +0000 Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XHbSD-0003Pj-Om for xen-devel@lists.xensource.com; Wed, 13 Aug 2014 16:31:13 +0000 Received: from [85.158.143.35:19444] by server-2.bemta-4.messagelabs.com id 1F/34-04525-1D29BE35; Wed, 13 Aug 2014 16:31:13 +0000 X-Env-Sender: Stefano.Stabellini@citrix.com X-Msg-Ref: server-7.tower-21.messagelabs.com!1407947470!12876867!3 X-Originating-IP: [66.165.176.89] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni44OSA9PiAyMDMwMDc=\n X-StarScan-Received: X-StarScan-Version: 6.12.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 20776 invoked from network); 13 Aug 2014 16:31:12 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-7.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 13 Aug 2014 16:31:12 -0000 X-IronPort-AV: E=Sophos;i="5.01,857,1400025600"; d="scan'208";a="161414769" Received: from ukmail1.uk.xensource.com (10.80.16.128) by smtprelay.citrix.com (10.13.107.79) with Microsoft SMTP Server id 14.3.181.6; Wed, 13 Aug 2014 12:31:09 -0400 Received: from kaball.uk.xensource.com ([10.80.2.59]) by ukmail1.uk.xensource.com with esmtp (Exim 4.69) (envelope-from ) id 1XHbS4-00059X-37; Wed, 13 Aug 2014 17:31:04 +0100 From: Stefano Stabellini To: Date: Wed, 13 Aug 2014 17:29:41 +0100 Message-ID: <1407947384-24279-7-git-send-email-stefano.stabellini@eu.citrix.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: MIME-Version: 1.0 X-DLP: MIA1 Cc: julien.grall@citrix.com, Ian.Campbell@citrix.com, Stefano Stabellini Subject: [Xen-devel] [PATCH v12 07/10] xen: remove workaround to inject evtchn_irq on irq enable X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Post: , List-Help: , List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: stefano.stabellini@eu.citrix.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.171 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Archive: evtchn_upcall_pending is already set by common code at vcpu creation, therefore on ARM we also need to call vgic_vcpu_inject_irq for it. Currently we do that from vgic_enable_irqs as a workaround. Do this properly by introducing an appropriate arch specific hook: arch_evtchn_inject. arch_evtchn_inject is called by map_vcpu_info to inject the evtchn irq into the guest. On ARM is implemented by calling vgic_vcpu_inject_irq. On x86 guests typically don't call VCPUOP_register_vcpu_info on vcpu0, therefore avoiding the issue. However theoretically they could call VCPUOP_register_vcpu_info on vcpu0 and in that case Xen would need to inject the event channel notification into the guest if the guest is HVM. So implement arch_evtchn_inject on x86 by calling hvm_assert_evtchn_irq. Signed-off-by: Stefano Stabellini Acked-by: Jan Beulich Acked-by: Julien Grall --- Changes in v10: - provide an implementation for x86. Changes in v9: - use an arch hook. Changes in v2: - coding style fix; - add comment; - return an error if arch_set_info_guest is called without VGCF_online. --- xen/arch/arm/vgic.c | 23 +++++++++-------------- xen/arch/x86/hvm/irq.c | 6 ++++++ xen/common/domain.c | 1 + xen/include/xen/event.h | 3 +++ 4 files changed, 19 insertions(+), 14 deletions(-) diff --git a/xen/arch/arm/vgic.c b/xen/arch/arm/vgic.c index 2319d71..3cf5e7b 100644 --- a/xen/arch/arm/vgic.c +++ b/xen/arch/arm/vgic.c @@ -264,20 +264,10 @@ void vgic_enable_irqs(struct vcpu *v, uint32_t r, int n) v_target = d->arch.vgic.handler->get_target_vcpu(v, irq); p = irq_to_pending(v_target, irq); set_bit(GIC_IRQ_GUEST_ENABLED, &p->status); - /* We need to force the first injection of evtchn_irq because - * evtchn_upcall_pending is already set by common code on vcpu - * creation. */ - if ( irq == v_target->domain->arch.evtchn_irq && - vcpu_info(current, evtchn_upcall_pending) && - list_empty(&p->inflight) ) - vgic_vcpu_inject_irq(v_target, irq); - else { - unsigned long flags; - spin_lock_irqsave(&v_target->arch.vgic.lock, flags); - if ( !list_empty(&p->inflight) && !test_bit(GIC_IRQ_GUEST_VISIBLE, &p->status) ) - gic_raise_guest_irq(v_target, irq, p->priority); - spin_unlock_irqrestore(&v_target->arch.vgic.lock, flags); - } + spin_lock_irqsave(&v_target->arch.vgic.lock, flags); + if ( !list_empty(&p->inflight) && !test_bit(GIC_IRQ_GUEST_VISIBLE, &p->status) ) + gic_raise_guest_irq(v_target, irq, p->priority); + spin_unlock_irqrestore(&v_target->arch.vgic.lock, flags); if ( p->desc != NULL ) { irq_set_affinity(p->desc, cpumask_of(v_target->processor)); @@ -433,6 +423,11 @@ void vgic_vcpu_inject_spi(struct domain *d, unsigned int irq) vgic_vcpu_inject_irq(v, irq); } +void arch_evtchn_inject(struct vcpu *v) +{ + vgic_vcpu_inject_irq(v, v->domain->arch.evtchn_irq); +} + /* * Local variables: * mode: C diff --git a/xen/arch/x86/hvm/irq.c b/xen/arch/x86/hvm/irq.c index 3b29678..35f4f94 100644 --- a/xen/arch/x86/hvm/irq.c +++ b/xen/arch/x86/hvm/irq.c @@ -468,6 +468,12 @@ int hvm_local_events_need_delivery(struct vcpu *v) return !hvm_interrupt_blocked(v, intack); } +void arch_evtchn_inject(struct vcpu *v) +{ + if ( has_hvm_container_vcpu(v) ) + hvm_assert_evtchn_irq(v); +} + static void irq_dump(struct domain *d) { struct hvm_irq *hvm_irq = &d->arch.hvm_domain.irq; diff --git a/xen/common/domain.c b/xen/common/domain.c index 5d86e6c..8fbdc94 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -1101,6 +1101,7 @@ int map_vcpu_info(struct vcpu *v, unsigned long gfn, unsigned offset) vcpu_info(v, evtchn_upcall_pending) = 1; for ( i = 0; i < BITS_PER_EVTCHN_WORD(d); i++ ) set_bit(i, &vcpu_info(v, evtchn_pending_sel)); + arch_evtchn_inject(v); return 0; } diff --git a/xen/include/xen/event.h b/xen/include/xen/event.h index 06c0654..88526f8 100644 --- a/xen/include/xen/event.h +++ b/xen/include/xen/event.h @@ -69,6 +69,9 @@ int guest_enabled_event(struct vcpu *v, uint32_t virq); /* Notify remote end of a Xen-attached event channel.*/ void notify_via_xen_event_channel(struct domain *ld, int lport); +/* Inject an event channel notification into the guest */ +void arch_evtchn_inject(struct vcpu *v); + /* * Internal event channel object storage. *