From patchwork Fri Aug 8 17:13:50 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 35159 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oi0-f72.google.com (mail-oi0-f72.google.com [209.85.218.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 489172118A for ; Fri, 8 Aug 2014 17:17:05 +0000 (UTC) Received: by mail-oi0-f72.google.com with SMTP id a141sf20898822oig.11 for ; Fri, 08 Aug 2014 10:17:04 -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=vE0w8imviGAUwE0N+XA2oIV7D/nMmOtFkh4opRHpB9U=; b=HTqzmNKYKEPHimsPJIIwGutINyVo9nqmx2+79vsCwOfwIhYrx2GD2E6uEkpV6BB8dV iKyoYZ4OK+BGl8HGF8GSO5SJkOXsho1E1LC9ociueserXZox15XMLtJjPcweSkJVSpXz ony6KT37X+vrKfybxr1ec6Gv70rTMk79MnmysBkgbAj6xd/r+lQmMiG2jDgE2T1vVbkV 7HdkijrhrEv1Au64/IlnQAyB2D5LHUD3MdJ5uDtewksepXue8+2Q6mnD3g8a+fLRuGj5 +CvyDjnad252uJG+1EjeAkrHFW7Eou/6TCuJlH0sa7kOc3t27RtPUVgluax0lsZE7jxP FXFg== X-Gm-Message-State: ALoCoQmT0TTbg/FSiwTGdpQsV4Y9W2APW9HVabIQzfhEziVT6e9HxIWfwKRDPzFQ1zkz+3lQvsIc X-Received: by 10.182.129.37 with SMTP id nt5mr13138579obb.8.1407518224939; Fri, 08 Aug 2014 10:17:04 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.93.34 with SMTP id c31ls613504qge.92.gmail; Fri, 08 Aug 2014 10:17:04 -0700 (PDT) X-Received: by 10.220.184.70 with SMTP id cj6mr1170799vcb.5.1407518224795; Fri, 08 Aug 2014 10:17:04 -0700 (PDT) Received: from mail-vc0-f170.google.com (mail-vc0-f170.google.com [209.85.220.170]) by mx.google.com with ESMTPS id z17si3100637vct.60.2014.08.08.10.17.04 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 08 Aug 2014 10:17:04 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.170 as permitted sender) client-ip=209.85.220.170; Received: by mail-vc0-f170.google.com with SMTP id lf12so8814332vcb.1 for ; Fri, 08 Aug 2014 10:17:04 -0700 (PDT) X-Received: by 10.52.244.138 with SMTP id xg10mr7655545vdc.40.1407518224724; Fri, 08 Aug 2014 10:17:04 -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 tc5csp140492vcb; Fri, 8 Aug 2014 10:17:04 -0700 (PDT) X-Received: by 10.43.118.7 with SMTP id fo7mr13793401icc.3.1407518223511; Fri, 08 Aug 2014 10:17:03 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id jn1si4836151igb.11.2014.08.08.10.17.02 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 08 Aug 2014 10:17:03 -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 1XFnlh-00018C-Ta; Fri, 08 Aug 2014 17:15:53 +0000 Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XFnlf-00013y-A8 for xen-devel@lists.xensource.com; Fri, 08 Aug 2014 17:15:51 +0000 Received: from [85.158.143.35:40914] by server-3.bemta-4.messagelabs.com id F0/16-06192-6C505E35; Fri, 08 Aug 2014 17:15:50 +0000 X-Env-Sender: Stefano.Stabellini@citrix.com X-Msg-Ref: server-15.tower-21.messagelabs.com!1407518147!11934574!1 X-Originating-IP: [66.165.176.63] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni42MyA9PiAzMDYwNDg=\n X-StarScan-Received: X-StarScan-Version: 6.12.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 6477 invoked from network); 8 Aug 2014 17:15:48 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-15.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 8 Aug 2014 17:15:48 -0000 X-IronPort-AV: E=Sophos;i="5.01,826,1400025600"; d="scan'208";a="160746980" Received: from ukmail1.uk.xensource.com (10.80.16.128) by smtprelay.citrix.com (10.13.107.78) with Microsoft SMTP Server id 14.3.181.6; Fri, 8 Aug 2014 13:15:13 -0400 Received: from kaball.uk.xensource.com ([10.80.2.59]) by ukmail1.uk.xensource.com with esmtp (Exim 4.69) (envelope-from ) id 1XFnky-0001op-H6; Fri, 08 Aug 2014 18:15:08 +0100 From: Stefano Stabellini To: Date: Fri, 8 Aug 2014 18:13:50 +0100 Message-ID: <1407518033-10694-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 v11 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.170 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 731d84d..ce4457e 100644 --- a/xen/arch/arm/vgic.c +++ b/xen/arch/arm/vgic.c @@ -263,20 +263,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)); @@ -432,6 +422,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 cd64aea..05d0049 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -1058,6 +1058,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. *