From patchwork Sun May 25 18:06:32 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 30894 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qc0-f198.google.com (mail-qc0-f198.google.com [209.85.216.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 81967203AC for ; Sun, 25 May 2014 18:08:35 +0000 (UTC) Received: by mail-qc0-f198.google.com with SMTP id m20sf25261336qcx.5 for ; Sun, 25 May 2014 11:08:35 -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=/PyYp4/V1RdRjuA/OnQuz+EnHcwj7QOuFwT6UKYuo9I=; b=IRYzsO/+liNyG6SHlW2GPVNxBxPifxXTGiQ/+BME/ErrgmxJgv0inXfbTx/qgdwVBK T7qTC+TciPjgxvyv8LX0XRJ0di0aSnENyEwy8vHU+9KcBcOTmSqNE7c3+ZcB056HNnax lun2jjehIYp4q+U7lf1dtH+//1HTqMdOtL7ZAvRoGf9mcAO7uRLCbbRVL6Av0SfsRuJV RY9PWTAtJxWhNjAnhK7XBgIK4OZKMqja7P75G1qCcfYZhYG5gUrPo1fSSDvTrXurWb4H J6SMn28q9B3/2xUtGNwPIALBiKO9A6DsE3wpHLzQR83C2PhgDVTkt+kuOkmYGeYHiYYV UOAQ== X-Gm-Message-State: ALoCoQkzG8OyAXMmK/64tLZ2t+sR7Gp9MSn59wh4HX+GzAMZ1RBuxhRD9a6pGhaHOTuJAnzrAQpC X-Received: by 10.236.136.231 with SMTP id w67mr6877822yhi.37.1401041315359; Sun, 25 May 2014 11:08:35 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.17.19 with SMTP id 19ls1055158qgc.69.gmail; Sun, 25 May 2014 11:08:35 -0700 (PDT) X-Received: by 10.52.143.6 with SMTP id sa6mr13745882vdb.22.1401041315270; Sun, 25 May 2014 11:08:35 -0700 (PDT) Received: from mail-ve0-f178.google.com (mail-ve0-f178.google.com [209.85.128.178]) by mx.google.com with ESMTPS id ua6si5083124vcb.14.2014.05.25.11.08.35 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 25 May 2014 11:08:35 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.178 as permitted sender) client-ip=209.85.128.178; Received: by mail-ve0-f178.google.com with SMTP id sa20so8481286veb.9 for ; Sun, 25 May 2014 11:08:35 -0700 (PDT) X-Received: by 10.221.44.73 with SMTP id uf9mr16551062vcb.9.1401041315197; Sun, 25 May 2014 11:08:35 -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 ib8csp51939vcb; Sun, 25 May 2014 11:08:34 -0700 (PDT) X-Received: by 10.224.43.148 with SMTP id w20mr26240527qae.26.1401041314760; Sun, 25 May 2014 11:08:34 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id l66si10571564qgf.78.2014.05.25.11.08.34 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Sun, 25 May 2014 11:08:34 -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 1Wocoo-0001Y1-Ry; Sun, 25 May 2014 18:06:46 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Wocon-0001Xb-C2 for xen-devel@lists.xensource.com; Sun, 25 May 2014 18:06:45 +0000 Received: from [85.158.139.211:12380] by server-16.bemta-5.messagelabs.com id 40/5A-19700-43132835; Sun, 25 May 2014 18:06:44 +0000 X-Env-Sender: Stefano.Stabellini@citrix.com X-Msg-Ref: server-6.tower-206.messagelabs.com!1401041201!6250755!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.11.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 6716 invoked from network); 25 May 2014 18:06:43 -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; 25 May 2014 18:06:43 -0000 X-IronPort-AV: E=Sophos;i="4.98,907,1392163200"; d="scan'208";a="135542930" Received: from accessns.citrite.net (HELO FTLPEX01CL02.citrite.net) ([10.9.154.239]) by FTLPIPO01.CITRIX.COM with ESMTP; 25 May 2014 18:06:41 +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; Sun, 25 May 2014 14:06:41 -0400 Received: from kaball.uk.xensource.com ([10.80.2.59]) by ukmail1.uk.xensource.com with esmtp (Exim 4.69) (envelope-from ) id 1Wocod-00045L-OD; Sun, 25 May 2014 19:06:35 +0100 From: Stefano Stabellini To: Date: Sun, 25 May 2014 19:06:32 +0100 Message-ID: <1401041192-20424-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: MIA1 Cc: julien.grall@citrix.com, Ian.Campbell@citrix.com, Stefano Stabellini Subject: [Xen-devel] [PATCH 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.128.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: 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. Signed-off-by: Stefano Stabellini --- xen/arch/arm/vgic.c | 42 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 34 insertions(+), 8 deletions(-) diff --git a/xen/arch/arm/vgic.c b/xen/arch/arm/vgic.c index e4f38a0..0f0ba1d 100644 --- a/xen/arch/arm/vgic.c +++ b/xen/arch/arm/vgic.c @@ -376,12 +376,25 @@ static void vgic_disable_irqs(struct vcpu *v, uint32_t r, int n) unsigned int irq; unsigned long flags; int i = 0; + int target; + struct vcpu *v_target; + struct vgic_irq_rank *rank; while ( (i = find_next_bit(&mask, 32, i)) < 32 ) { irq = i + (32 * n); - p = irq_to_pending(v, irq); + rank = vgic_irq_rank(v, 1, irq/32); + vgic_lock_rank(v, rank); + if ( irq >= 32 ) + { + target = rank->itargets[(irq%32)/4] >> (8*(irq % 4)); + target &= 0xff; + v_target = v->domain->vcpu[target]; + } else + v_target = v; + vgic_unlock_rank(v, rank); + 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,21 +412,34 @@ static void vgic_enable_irqs(struct vcpu *v, uint32_t r, int n) unsigned int irq; unsigned long flags; int i = 0; + int target; + struct vcpu *v_target; + struct vgic_irq_rank *rank; while ( (i = find_next_bit(&mask, 32, i)) < 32 ) { irq = i + (32 * n); - p = irq_to_pending(v, irq); + rank = vgic_irq_rank(v, 1, irq/32); + vgic_lock_rank(v, rank); + if ( irq >= 32 ) + { + target = rank->itargets[(irq%32)/4] >> (8*(irq % 4)); + target &= 0xff; + v_target = v->domain->vcpu[target]; + } else + v_target = v; + vgic_unlock_rank(v, rank); + p = irq_to_pending(v_target, irq); set_bit(GIC_IRQ_GUEST_ENABLED, &p->status); - 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 ) {