From patchwork Thu Jul 3 16:53:11 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 33059 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f71.google.com (mail-oa0-f71.google.com [209.85.219.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 0941620560 for ; Thu, 3 Jul 2014 16:56:25 +0000 (UTC) Received: by mail-oa0-f71.google.com with SMTP id n16sf2143376oag.2 for ; Thu, 03 Jul 2014 09:56:24 -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=6G48WpwjbfKNRRgKV+lYtjnVSqbPNjy+3VWstE1cT+k=; b=Rg4ojrb0Mrz7rnAq1n3Ki7ubnmUVUFkRNq/to8WCaM2XMLLTVs/5hbw4Xe+in/2r4p 3Z4lHYDmXM73bkI2/ukcT12OT3N1YoZwl/kmBFd4m1XlAwTtUvg1C4YXA3J293+7jcRb BRK6bdEgX0zRAqOPcKc//HOdhqQi75OWDNGYXsCJWXPREiwwZWj3j5l5FkanSAizHg1d G39ktHhmDEXukJNYqhe1ObkHX7ry7Ky4rE/01AXWWBKGufAat8MZ1hp7e+0KuuVI/jez CULR1MMy7pN6cT3qzwSzEF5Gn54NasKhXDyMTJMlkGGGlIkc/SBZu9DPZE4riW4CzAFX qFCA== X-Gm-Message-State: ALoCoQk/QOR9/3xebRapnl3+y0duwkQz1Z1DUJrGWWfy8gWnPRGIhX8t9NG5iurpwt9+SNBshWGY X-Received: by 10.42.39.140 with SMTP id h12mr5300638ice.9.1404406584595; Thu, 03 Jul 2014 09:56:24 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.101.23 with SMTP id t23ls598531qge.32.gmail; Thu, 03 Jul 2014 09:56:24 -0700 (PDT) X-Received: by 10.58.235.130 with SMTP id um2mr4935216vec.18.1404406584509; Thu, 03 Jul 2014 09:56:24 -0700 (PDT) Received: from mail-vc0-f178.google.com (mail-vc0-f178.google.com [209.85.220.178]) by mx.google.com with ESMTPS id sp1si14445102vec.83.2014.07.03.09.56.24 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 03 Jul 2014 09:56:24 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.178 as permitted sender) client-ip=209.85.220.178; Received: by mail-vc0-f178.google.com with SMTP id ij19so514354vcb.9 for ; Thu, 03 Jul 2014 09:56:24 -0700 (PDT) X-Received: by 10.220.166.9 with SMTP id k9mr4942935vcy.20.1404406584423; Thu, 03 Jul 2014 09:56:24 -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 tc5csp392543vcb; Thu, 3 Jul 2014 09:56:24 -0700 (PDT) X-Received: by 10.50.36.106 with SMTP id p10mr57924474igj.9.1404406583626; Thu, 03 Jul 2014 09:56:23 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id d18si43916844ics.56.2014.07.03.09.56.23 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 03 Jul 2014 09:56:23 -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 1X2kGr-0004bK-T2; Thu, 03 Jul 2014 16:54:05 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1X2kGq-0004ag-NO for xen-devel@lists.xensource.com; Thu, 03 Jul 2014 16:54:04 +0000 Received: from [85.158.139.211:61574] by server-10.bemta-5.messagelabs.com id C3/A3-10247-BAA85B35; Thu, 03 Jul 2014 16:54:03 +0000 X-Env-Sender: Stefano.Stabellini@citrix.com X-Msg-Ref: server-6.tower-206.messagelabs.com!1404406440!13526197!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.11.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 26851 invoked from network); 3 Jul 2014 16:54:03 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-6.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 3 Jul 2014 16:54:03 -0000 X-IronPort-AV: E=Sophos;i="5.01,595,1400025600"; d="scan'208";a="149633507" Received: from accessns.citrite.net (HELO FTLPEX01CL02.citrite.net) ([10.9.154.239]) by FTLPIPO01.CITRIX.COM with ESMTP; 03 Jul 2014 16:54:00 +0000 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; Thu, 3 Jul 2014 12:53:59 -0400 Received: from kaball.uk.xensource.com ([10.80.2.59]) by ukmail1.uk.xensource.com with esmtp (Exim 4.69) (envelope-from ) id 1X2kGg-00014w-AB; Thu, 03 Jul 2014 17:53:54 +0100 From: Stefano Stabellini To: Date: Thu, 3 Jul 2014 17:53:11 +0100 Message-ID: <1404406394-18231-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 v7 4/6] 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.178 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 b5269d4..be97261 100644 --- a/xen/arch/arm/gic.c +++ b/xen/arch/arm/gic.c @@ -138,7 +138,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 8827a77..b4493a3 100644 --- a/xen/arch/arm/vgic.c +++ b/xen/arch/arm/vgic.c @@ -873,6 +873,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 92f1e86..bb02a6c 100644 --- a/xen/include/asm-arm/vgic.h +++ b/xen/include/asm-arm/vgic.h @@ -86,6 +86,7 @@ extern int domain_vgic_init(struct domain *d); extern void domain_vgic_free(struct domain *d); extern int vcpu_vgic_init(struct vcpu *v); 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 int vcpu_vgic_free(struct vcpu *v);