From patchwork Wed Aug 13 16:29:38 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 35377 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pd0-f197.google.com (mail-pd0-f197.google.com [209.85.192.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id F3E0020DCC for ; Wed, 13 Aug 2014 16:32:52 +0000 (UTC) Received: by mail-pd0-f197.google.com with SMTP id y10sf75751627pdj.8 for ; Wed, 13 Aug 2014 09:32:52 -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=72wKfPBkpelv2pUjcd2v83OhCWezoCQiKHN9YFqdibA=; b=Z1b1U1EMpSvDBNDkP74VHmv94q/Wg1dPAHwoS1YVYPtFVt3a7/SE1siNIgSCRHoSVj vJMJfXLpaR19MX+RZ3Da0US4FbH2+bcngwl3jin4zS97wXAVZ35blO8hFP6KBGaeHEYF XSnh20qtaP2vQJvPAYPTkQfVmrgL2lyJXentRTdKFbJ5liIyBXxTvEHMK+7Y5kzeCztA qwDZxR9KrkeRZ2k276YE/gi3raPF7GS2180OIrykfL/A1WQSSNtqUN44PsijWelwgpUn PTilUjbV1PhpwnPboeCv7c4qFRmup2YBOn6Qq9INbOSTmx9XID17e+dpF6Lp24idQYUG a3zQ== X-Gm-Message-State: ALoCoQn5qITlT+OF0gDZr9FpbY3PSZf7Cp0kzAQddBUZgrgB2msHSQbFa0/0ZnbpXxQAYW/U1DB8 X-Received: by 10.66.124.199 with SMTP id mk7mr2818811pab.15.1407947572341; Wed, 13 Aug 2014 09:32:52 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.38.80 with SMTP id s74ls599866qgs.64.gmail; Wed, 13 Aug 2014 09:32:52 -0700 (PDT) X-Received: by 10.220.105.201 with SMTP id u9mr4770567vco.11.1407947572120; Wed, 13 Aug 2014 09:32:52 -0700 (PDT) Received: from mail-vc0-f177.google.com (mail-vc0-f177.google.com [209.85.220.177]) by mx.google.com with ESMTPS id wc6si1413294vdb.42.2014.08.13.09.32.52 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 13 Aug 2014 09:32:52 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.177 as permitted sender) client-ip=209.85.220.177; Received: by mail-vc0-f177.google.com with SMTP id hy4so15123628vcb.22 for ; Wed, 13 Aug 2014 09:32:52 -0700 (PDT) X-Received: by 10.52.129.165 with SMTP id nx5mr3954200vdb.25.1407947572024; Wed, 13 Aug 2014 09:32:52 -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 tc5csp344311vcb; Wed, 13 Aug 2014 09:32:51 -0700 (PDT) X-Received: by 10.42.216.148 with SMTP id hi20mr7489914icb.12.1407947569474; Wed, 13 Aug 2014 09:32:49 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id d9si4923380igo.13.2014.08.13.09.32.49 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 13 Aug 2014 09:32:49 -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 1XHbSE-0003Q3-8X; Wed, 13 Aug 2014 16:31:14 +0000 Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XHbSD-0003PZ-2m for xen-devel@lists.xensource.com; Wed, 13 Aug 2014 16:31:13 +0000 Received: from [85.158.143.35:19389] by server-1.bemta-4.messagelabs.com id 25/B3-05872-0D29BE35; Wed, 13 Aug 2014 16:31:12 +0000 X-Env-Sender: Stefano.Stabellini@citrix.com X-Msg-Ref: server-7.tower-21.messagelabs.com!1407947470!12876867!2 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 20704 invoked from network); 13 Aug 2014 16:31:11 -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:11 -0000 X-IronPort-AV: E=Sophos;i="5.01,857,1400025600"; d="scan'208";a="161414768" 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-0Q; Wed, 13 Aug 2014 17:31:04 +0100 From: Stefano Stabellini To: Date: Wed, 13 Aug 2014 17:29:38 +0100 Message-ID: <1407947384-24279-4-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 04/10] xen/arm: support irq delivery to vcpu > 0 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.177 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: Use vgic_get_target_vcpu to retrieve the target vcpu from do_IRQ. Remove in-code comments about missing implementation of SGI delivery to vcpus other than 0. Signed-off-by: Stefano Stabellini Acked-by: Julien Grall Acked-by: Ian Campbell --- Changes in v7: - improve in-code comment; - use gic_number_lines in assert. Changes in v6: - add in-code comments; - assert that the guest irq is an SPI. Changes in v4: - the mask in gic_route_irq_to_guest is a physical cpu mask, treat it as such; - export vgic_get_target_vcpu in a previous patch. --- xen/arch/arm/gic.c | 3 ++- xen/arch/arm/irq.c | 5 +++-- xen/arch/arm/vgic.c | 11 +++++++++++ xen/include/asm-arm/vgic.h | 1 + 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c index 3e75fc5..f5c7c91 100644 --- a/xen/arch/arm/gic.c +++ b/xen/arch/arm/gic.c @@ -137,7 +137,8 @@ void gic_route_irq_to_guest(struct domain *d, struct irq_desc *desc, gic_set_irq_properties(desc, cpumask_of(smp_processor_id()), GIC_PRI_IRQ); - /* TODO: do not assume delivery to vcpu0 */ + /* Use vcpu0 to retrieve the pending_irq struct. Given that we only + * route SPIs to guests, it doesn't make any difference. */ p = irq_to_pending(d->vcpu[0], desc->irq); p->desc = desc; } diff --git a/xen/arch/arm/irq.c b/xen/arch/arm/irq.c index 3a8acbf..49ca467 100644 --- a/xen/arch/arm/irq.c +++ b/xen/arch/arm/irq.c @@ -198,8 +198,9 @@ void do_IRQ(struct cpu_user_regs *regs, unsigned int irq, int is_fiq) desc->status |= IRQ_INPROGRESS; desc->arch.eoi_cpu = smp_processor_id(); - /* XXX: inject irq into all guest vcpus */ - vgic_vcpu_inject_irq(d->vcpu[0], irq); + /* the irq cannot be a PPI, we only support delivery of SPIs to + * guests */ + vgic_vcpu_inject_spi(d, irq); goto out_no_end; } diff --git a/xen/arch/arm/vgic.c b/xen/arch/arm/vgic.c index e0dcaf6..ed7108e 100644 --- a/xen/arch/arm/vgic.c +++ b/xen/arch/arm/vgic.c @@ -401,6 +401,17 @@ out: smp_send_event_check_mask(cpumask_of(v->processor)); } +void vgic_vcpu_inject_spi(struct domain *d, unsigned int irq) +{ + struct vcpu *v; + + /* the IRQ needs to be an SPI */ + ASSERT(irq >= 32 && irq <= gic_number_lines()); + + v = vgic_get_target_vcpu(d->vcpu[0], irq); + vgic_vcpu_inject_irq(v, irq); +} + /* * Local variables: * mode: C diff --git a/xen/include/asm-arm/vgic.h b/xen/include/asm-arm/vgic.h index 434a625..9b1db04 100644 --- a/xen/include/asm-arm/vgic.h +++ b/xen/include/asm-arm/vgic.h @@ -161,6 +161,7 @@ extern void domain_vgic_free(struct domain *d); extern int vcpu_vgic_init(struct vcpu *v); extern struct vcpu *vgic_get_target_vcpu(struct vcpu *v, unsigned int irq); extern void vgic_vcpu_inject_irq(struct vcpu *v, unsigned int irq); +extern void vgic_vcpu_inject_spi(struct domain *d, unsigned int irq); extern void vgic_clear_pending_irqs(struct vcpu *v); extern struct pending_irq *irq_to_pending(struct vcpu *v, unsigned int irq); extern struct vgic_irq_rank *vgic_rank_offset(struct vcpu *v, int b, int n, int s);