From patchwork Tue Jun 3 16:07:07 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 31328 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f72.google.com (mail-yh0-f72.google.com [209.85.213.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 61DD5203AC for ; Tue, 3 Jun 2014 16:09:40 +0000 (UTC) Received: by mail-yh0-f72.google.com with SMTP id f73sf32924926yha.11 for ; Tue, 03 Jun 2014 09:09:40 -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=cCGkUc6NDwKNnFPtMPgcLKEdXGgpXGQLwGAJH9GV0B4=; b=Jx1o+VZcxujHRrloRMN49bkZjojJZSMA+IQUzP3/yL1CEStjzMnCuCb+nbZM9kqFE/ D18RozRn9yO2Bx33CQ1Ij63r1d6KU2bPsrk3soRJnIHgub1FtoBwozwFqdkrCjXK+2Oa vy4BNaLqcfYcwiIVasXDmHUn7jylv8b8xw7+2AMpYwZoK5z23UsiLu7PP9RDKSTP6KN5 Lz3RgCdzqyveDm8G3VAdCZzf49PJV63pwSkcmjUSXCePzKO/cflBpCQzMiOb4ZIkx7Uy PbB52gnwVSM1kPW+fRGNmTcbm1+FLrWfN8708Qo8xXjg+xkBIuucpy7MC9SQlizBLO2Q qtkg== X-Gm-Message-State: ALoCoQnnAjJWDvDbWyUSs7E1kr9tnzrtZmqVq6sfYs3YZNfJcf5q4EnXE5DRQRrvmjgQL7Q2sH/z X-Received: by 10.58.247.202 with SMTP id yg10mr18029499vec.1.1401811779777; Tue, 03 Jun 2014 09:09:39 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.31.195 with SMTP id f61ls2569633qgf.59.gmail; Tue, 03 Jun 2014 09:09:39 -0700 (PDT) X-Received: by 10.58.99.36 with SMTP id en4mr2057535veb.62.1401811779676; Tue, 03 Jun 2014 09:09:39 -0700 (PDT) Received: from mail-vc0-f180.google.com (mail-vc0-f180.google.com [209.85.220.180]) by mx.google.com with ESMTPS id xr4si4083996veb.87.2014.06.03.09.09.39 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 03 Jun 2014 09:09:39 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.180 as permitted sender) client-ip=209.85.220.180; Received: by mail-vc0-f180.google.com with SMTP id hq11so5004439vcb.25 for ; Tue, 03 Jun 2014 09:09:39 -0700 (PDT) X-Received: by 10.221.7.71 with SMTP id on7mr38117647vcb.18.1401811779575; Tue, 03 Jun 2014 09:09:39 -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.220.221.72 with SMTP id ib8csp7981vcb; Tue, 3 Jun 2014 09:09:39 -0700 (PDT) X-Received: by 10.220.18.134 with SMTP id w6mr37775454vca.5.1401811779052; Tue, 03 Jun 2014 09:09:39 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id h18si10260559vdg.75.2014.06.03.09.09.38 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 03 Jun 2014 09:09:39 -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 1WrrFK-0000Dd-18; Tue, 03 Jun 2014 16:07:30 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WrrFI-0000DL-Dz for xen-devel@lists.xensource.com; Tue, 03 Jun 2014 16:07:28 +0000 Received: from [193.109.254.147:32847] by server-9.bemta-14.messagelabs.com id C6/40-03644-FB2FD835; Tue, 03 Jun 2014 16:07:27 +0000 X-Env-Sender: Stefano.Stabellini@citrix.com X-Msg-Ref: server-15.tower-27.messagelabs.com!1401811645!8893761!2 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 6726 invoked from network); 3 Jun 2014 16:07:27 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-15.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 3 Jun 2014 16:07:27 -0000 X-IronPort-AV: E=Sophos;i="4.98,966,1392163200"; d="scan'208";a="138679354" Received: from accessns.citrite.net (HELO FTLPEX01CL02.citrite.net) ([10.9.154.239]) by FTLPIPO02.CITRIX.COM with ESMTP; 03 Jun 2014 16:07:25 +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; Tue, 3 Jun 2014 12:07:24 -0400 Received: from kaball.uk.xensource.com ([10.80.2.59]) by ukmail1.uk.xensource.com with esmtp (Exim 4.69) (envelope-from ) id 1WrrF9-0003um-5a; Tue, 03 Jun 2014 17:07:19 +0100 From: Stefano Stabellini To: Date: Tue, 3 Jun 2014 17:07:07 +0100 Message-ID: <1401811627-4389-2-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 v2 2/2] xen/arm: observe itarget setting in vgic_enable_irqs and vgic_disable_irqs 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.180 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: vgic_enable_irqs should enable irq delivery to the vcpu specified by GICD_ITARGETSR, rather than the vcpu that wrote to GICD_ISENABLER. Similarly vgic_disable_irqs should use the target vcpu specified by itarget to disable irqs. Correctly initialize itargets for SPIs. Signed-off-by: Stefano Stabellini Acked-by: Julien Grall --- Changes in v2: - refactor the common code in get_target_vcpu; - unify PPI and SPI paths; - correctly initialize itargets for SPI; - use byte_read. --- xen/arch/arm/vgic.c | 43 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 8 deletions(-) diff --git a/xen/arch/arm/vgic.c b/xen/arch/arm/vgic.c index 1304b5e..55ed27d 100644 --- a/xen/arch/arm/vgic.c +++ b/xen/arch/arm/vgic.c @@ -106,7 +106,15 @@ int domain_vgic_init(struct domain *d) INIT_LIST_HEAD(&d->arch.vgic.pending_irqs[i].lr_queue); } for (i=0; iarch.vgic.shared_irqs[i].lock); + /* Only delivery to CPU0 */ + for ( j = 0 ; j < 8 ; j++ ) + d->arch.vgic.shared_irqs[i].itargets[j] = + (1<<0) | (1<<8) | (1<<16) | (1<<24); + } return 0; } @@ -369,6 +377,21 @@ read_as_zero: return 1; } +static struct vcpu *get_target_vcpu(struct vcpu *v, unsigned int irq) +{ + int target; + struct vgic_irq_rank *rank; + struct vcpu *v_target; + + rank = vgic_irq_rank(v, 1, irq/32); + vgic_lock_rank(v, rank); + target = byte_read(rank->itargets[(irq%32)/4], 0, irq % 4); + target = find_next_bit((const unsigned long *) &target, 8, 0); + v_target = v->domain->vcpu[target]; + vgic_unlock_rank(v, rank); + return v_target; +} + static void vgic_disable_irqs(struct vcpu *v, uint32_t r, int n) { const unsigned long mask = r; @@ -376,12 +399,14 @@ static void vgic_disable_irqs(struct vcpu *v, uint32_t r, int n) unsigned int irq; unsigned long flags; int i = 0; + struct vcpu *v_target; while ( (i = find_next_bit(&mask, 32, i)) < 32 ) { irq = i + (32 * n); - p = irq_to_pending(v, irq); + v_target = get_target_vcpu(v, irq); + p = irq_to_pending(v_target, irq); clear_bit(GIC_IRQ_GUEST_ENABLED, &p->status); - gic_remove_from_queues(v, irq); + gic_remove_from_queues(v_target, irq); if ( p->desc != NULL ) { spin_lock_irqsave(&p->desc->lock, flags); @@ -399,24 +424,26 @@ static void vgic_enable_irqs(struct vcpu *v, uint32_t r, int n) unsigned int irq; unsigned long flags; int i = 0; + struct vcpu *v_target; while ( (i = find_next_bit(&mask, 32, i)) < 32 ) { irq = i + (32 * n); - p = irq_to_pending(v, irq); + v_target = 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->domain->arch.evtchn_irq && + if ( irq == v_target->domain->arch.evtchn_irq && vcpu_info(current, evtchn_upcall_pending) && list_empty(&p->inflight) ) - vgic_vcpu_inject_irq(v, irq); + vgic_vcpu_inject_irq(v_target, irq); else { unsigned long flags; - spin_lock_irqsave(&v->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, irq, p->priority); - spin_unlock_irqrestore(&v->arch.vgic.lock, flags); + gic_raise_guest_irq(v_target, irq, p->priority); + spin_unlock_irqrestore(&v_target->arch.vgic.lock, flags); } if ( p->desc != NULL ) {