From patchwork Thu Jul 24 17:33:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 34236 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 91AE220C7F for ; Thu, 24 Jul 2014 17:36:00 +0000 (UTC) Received: by mail-pd0-f197.google.com with SMTP id y10sf19184426pdj.4 for ; Thu, 24 Jul 2014 10:35:59 -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=AZclJbPb/aZSr+lkYmUEFbkHeuxjI5fwaFedfLn8D44=; b=I3MLOQ/mTy81fjQOkaDoCLsh7Dw7wnxm30YVlrHQayXfyzgRxyvjEWcaoxBbWiMY16 HT5trNo1qUa4+nKgpK8FQp5jo6rBVENih08u9MfH7+4vbAhCS0Hec4yl0Q87ePV3QECL MPYHOBlpU+OuRLcupEkw2zXAP9JRlD2M2iGmrgR1eqtMAAgFU3XV9Ln+QDEK2cvS6y2p Zbk3wPkrjFmO+BeSregYwSuiOJ0OQSGr+H90j5XtRfXgYyKg3tyLZ6Nc7I892drOcSec TZcO7hOlWzCNqnR7+/MZXj0HAu+KZi7Il81Kb9LcdJJdzfhNfdWQ5x/GHgz/fG7Chb2/ HgHA== X-Gm-Message-State: ALoCoQm1mrYFuoSkszYlT6kglkL69U7hOYSXHYMPiD8+97WFcQvHwAmKgMIAUTZBxDaXOJ0GEwSe X-Received: by 10.70.48.38 with SMTP id i6mr5041200pdn.5.1406223359695; Thu, 24 Jul 2014 10:35:59 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.23.19 with SMTP id 19ls236424qgo.59.gmail; Thu, 24 Jul 2014 10:35:59 -0700 (PDT) X-Received: by 10.220.200.71 with SMTP id ev7mr14749614vcb.24.1406223359459; Thu, 24 Jul 2014 10:35:59 -0700 (PDT) Received: from mail-vc0-f179.google.com (mail-vc0-f179.google.com [209.85.220.179]) by mx.google.com with ESMTPS id yk8si5822001vdc.22.2014.07.24.10.35.59 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 24 Jul 2014 10:35:59 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.179 as permitted sender) client-ip=209.85.220.179; Received: by mail-vc0-f179.google.com with SMTP id hq11so5616817vcb.10 for ; Thu, 24 Jul 2014 10:35:59 -0700 (PDT) X-Received: by 10.221.26.10 with SMTP id rk10mr14828712vcb.0.1406223359092; Thu, 24 Jul 2014 10:35:59 -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 tc5csp383633vcb; Thu, 24 Jul 2014 10:35:58 -0700 (PDT) X-Received: by 10.50.67.51 with SMTP id k19mr13442656igt.39.1406223357757; Thu, 24 Jul 2014 10:35:57 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id b8si21057551igx.57.2014.07.24.10.35.57 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 24 Jul 2014 10:35:57 -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 1XAMup-0002UA-7O; Thu, 24 Jul 2014 17:34:51 +0000 Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XAMun-0002St-Au for xen-devel@lists.xensource.com; Thu, 24 Jul 2014 17:34:49 +0000 Received: from [85.158.143.35:49533] by server-1.bemta-4.messagelabs.com id 19/87-05872-8B341D35; Thu, 24 Jul 2014 17:34:48 +0000 X-Env-Sender: Stefano.Stabellini@citrix.com X-Msg-Ref: server-5.tower-21.messagelabs.com!1406223286!19957100!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.11.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 25708 invoked from network); 24 Jul 2014 17:34:48 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-5.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 24 Jul 2014 17:34:48 -0000 X-IronPort-AV: E=Sophos;i="5.01,725,1400025600"; d="scan'208";a="155886522" Received: from accessns.citrite.net (HELO FTLPEX01CL01.citrite.net) ([10.9.154.239]) by FTLPIPO02.CITRIX.COM with ESMTP; 24 Jul 2014 17:34:18 +0000 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; Thu, 24 Jul 2014 13:34:17 -0400 Received: from kaball.uk.xensource.com ([10.80.2.59]) by ukmail1.uk.xensource.com with esmtp (Exim 4.69) (envelope-from ) id 1XAMuC-00067o-Cg; Thu, 24 Jul 2014 18:34:12 +0100 From: Stefano Stabellini To: Date: Thu, 24 Jul 2014 18:33:06 +0100 Message-ID: <1406223192-26267-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: MIA2 Cc: julien.grall@citrix.com, Ian.Campbell@citrix.com, Stefano Stabellini Subject: [Xen-devel] [PATCH v9 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.179 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 5f45cd2..02e5985 100644 --- a/xen/arch/arm/vgic.c +++ b/xen/arch/arm/vgic.c @@ -400,6 +400,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);