From patchwork Thu Dec 22 02:15:11 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 9484023 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3DB19601D5 for ; Thu, 22 Dec 2016 02:17:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2DB91200DF for ; Thu, 22 Dec 2016 02:17:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2283326D08; Thu, 22 Dec 2016 02:17:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C5CC9200DF for ; Thu, 22 Dec 2016 02:17:44 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cJsul-0001Y8-2J; Thu, 22 Dec 2016 02:15:27 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cJsuj-0001WB-3S for xen-devel@lists.xenproject.org; Thu, 22 Dec 2016 02:15:25 +0000 Received: from [85.158.139.211] by server-2.bemta-5.messagelabs.com id 95/AB-27429-C373B585; Thu, 22 Dec 2016 02:15:24 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrNLMWRWlGSWpSXmKPExsVybKJsh661eXS EwZXfehbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8acifsZC9olKl6efM3WwHhGqIuRi0NIYCqj xMt199ghnINMEu+mzwFyODnYBAwl/j7ZxAZiiwhISGxqWMEEYjMLWEvce/MDrEZYwEFi0qlvY DaLgKrEylOLwWxeATeJnY+XMoLYEgJyEiePTWYFsTkF3CV2zpsNViMk0M4o0b6rGqImQ2Jezx xWCNtLYtGNS1C2msTVc5uYJzDyLWBkWMWoUZxaVJZapGtkoJdUlJmeUZKbmJmja2hgqpebWly cmJ6ak5hUrJecn7uJERgo9QwMjDsYG2f7HWKU5GBSEuU9pR0dIcSXlJ9SmZFYnBFfVJqTWnyI UYaDQ0mC95UpUE6wKDU9tSItMwcYsjBpCQ4eJRHeoyBp3uKCxNzizHSI1ClGRSlx3kUgCQGQR EZpHlwbLE4uMcpKCfMyMjAwCPEUpBblZpagyr9iFOdgVBLmVQSZwpOZVwI3/RXQYiagxQu7w0 EWlyQipKQaGCNmeNosKDtw7JvzwTN+8vmTDNYXGBRbd8an1fOrLAnVLWVT8d7BMd1xYknU8bD 63adXt3Rwn9A9LLs1eK7odvWXs6/t/mgpLRDslVCs5vBzQ3R8atefpvs2aps8OC7FPDo69/Tq f64rn/OetJU/cecV74HpOvu8a3eeD7xbEaHGrfZ1M0+esRJLcUaioRZzUXEiAL+hWO6OAgAA X-Env-Sender: sstabellini@kernel.org X-Msg-Ref: server-9.tower-206.messagelabs.com!1482372920!76817378!1 X-Originating-IP: [198.145.29.136] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.1.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 37222 invoked from network); 22 Dec 2016 02:15:21 -0000 Received: from mail.kernel.org (HELO mail.kernel.org) (198.145.29.136) by server-9.tower-206.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 22 Dec 2016 02:15:21 -0000 Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0C3472013D; Thu, 22 Dec 2016 02:15:18 +0000 (UTC) Received: from sstabellini-ThinkPad-X260.hsd1.ca.comcast.net (96-82-76-110-static.hfc.comcastbusiness.net [96.82.76.110]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id F327920373; Thu, 22 Dec 2016 02:15:16 +0000 (UTC) From: Stefano Stabellini To: julien.grall@arm.com Date: Wed, 21 Dec 2016 18:15:11 -0800 Message-Id: <1482372913-18366-2-git-send-email-sstabellini@kernel.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1482372913-18366-1-git-send-email-sstabellini@kernel.org> References: <1482372913-18366-1-git-send-email-sstabellini@kernel.org> X-Virus-Scanned: ClamAV using ClamSMTP Cc: xen-devel@lists.xenproject.org, sstabellini@kernel.org Subject: [Xen-devel] [PATCH v2 2/4] arm: store vcpu id in struct irq_pending X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP We currently store the LR register number for every irq in irq_pending, but we don't store the vcpu id. Thus, we know in which LR they are, but we don't know the LR of which cpu. Fix this gap by adding a vcpu field in struct pending_irq. Use the bytes that are currently used for padding within the struct to avoid increasing the size of the struct. Signed-off-by: Stefano Stabellini --- xen/arch/arm/gic.c | 7 ++++++- xen/arch/arm/vgic.c | 2 ++ xen/include/asm-arm/vgic.h | 2 ++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c index a5348f2..3189693 100644 --- a/xen/arch/arm/gic.c +++ b/xen/arch/arm/gic.c @@ -379,6 +379,7 @@ static inline void gic_set_lr(int lr, struct pending_irq *p, set_bit(GIC_IRQ_GUEST_VISIBLE, &p->status); clear_bit(GIC_IRQ_GUEST_QUEUED, &p->status); p->lr = lr; + p->vcpu = current->vcpu_id; } static inline void gic_add_to_lr_pending(struct vcpu *v, struct pending_irq *n) @@ -501,14 +502,17 @@ static void gic_update_one_lr(struct vcpu *v, int i) if ( test_bit(GIC_IRQ_GUEST_ENABLED, &p->status) && test_bit(GIC_IRQ_GUEST_QUEUED, &p->status) && !test_bit(GIC_IRQ_GUEST_MIGRATING, &p->status) ) + { + p->vcpu = GIC_INVALID_VCPU; gic_raise_guest_irq(v, irq, p->priority); - else { + } else { list_del_init(&p->inflight); if ( test_and_clear_bit(GIC_IRQ_GUEST_MIGRATING, &p->status) ) { struct vcpu *v_target = vgic_get_target_vcpu(v, irq); irq_set_affinity(p->desc, cpumask_of(v_target->processor)); } + p->vcpu = GIC_INVALID_VCPU; } } } @@ -574,6 +578,7 @@ static void gic_restore_pending_irqs(struct vcpu *v) found: lr = p_r->lr; p_r->lr = GIC_INVALID_LR; + p_r->vcpu = GIC_INVALID_VCPU; set_bit(GIC_IRQ_GUEST_QUEUED, &p_r->status); clear_bit(GIC_IRQ_GUEST_VISIBLE, &p_r->status); gic_add_to_lr_pending(v, p_r); diff --git a/xen/arch/arm/vgic.c b/xen/arch/arm/vgic.c index 364d5f0..f2e3eda 100644 --- a/xen/arch/arm/vgic.c +++ b/xen/arch/arm/vgic.c @@ -66,6 +66,8 @@ static void vgic_init_pending_irq(struct pending_irq *p, unsigned int virq) INIT_LIST_HEAD(&p->inflight); INIT_LIST_HEAD(&p->lr_queue); p->irq = virq; + p->lr = GIC_INVALID_LR; + p->vcpu = GIC_INVALID_VCPU; } static void vgic_rank_init(struct vgic_irq_rank *rank, uint8_t index, diff --git a/xen/include/asm-arm/vgic.h b/xen/include/asm-arm/vgic.h index 467333c..fde5b32 100644 --- a/xen/include/asm-arm/vgic.h +++ b/xen/include/asm-arm/vgic.h @@ -72,6 +72,8 @@ struct pending_irq #define GIC_INVALID_LR (uint8_t)~0 uint8_t lr; uint8_t priority; +#define GIC_INVALID_VCPU (uint8_t)~0 + uint8_t vcpu; /* inflight is used to append instances of pending_irq to * vgic.inflight_irqs */ struct list_head inflight;