From patchwork Mon Dec 5 14:36:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Tyshchenko X-Patchwork-Id: 9461051 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 68BC860236 for ; Mon, 5 Dec 2016 14:38:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 57A3023E64 for ; Mon, 5 Dec 2016 14:38:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4B57C25EA6; Mon, 5 Dec 2016 14:38:38 +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=-3.6 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID 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 D454423E64 for ; Mon, 5 Dec 2016 14:38:37 +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 1cDuNX-0008CF-8O; Mon, 05 Dec 2016 14:36:27 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cDuNV-0008C9-Rw for xen-devel@lists.xenproject.org; Mon, 05 Dec 2016 14:36:25 +0000 Received: from [193.109.254.147] by server-3.bemta-6.messagelabs.com id C2/80-08948-96B75485; Mon, 05 Dec 2016 14:36:25 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupkkeJIrShJLcpLzFFi42Lxqg1y0s2odo0 waOrVsPi+ZTKTA6PH4Q9XWAIYo1gz85LyKxJYMx71r2Yp+MBfsbGvi6WBsYm7i5GLQ0hgJqNE 35H3LCAOi8AlFolpE76ygTgSAu9YJBquvgLKcAI5MRITVuxhg7ArJS5Nv8AEYgsJKEm83rmZC WoUk8TL7p9gCTYBA4n9756wg9giQEX3Vk0GizMLGEpsu3wSbKiwQJDE+UXNjCA2i4CqxKUDh8 FsXgFniVP7u1ghlslJ3DzXyTyBkW8BI8MqRo3i1KKy1CJdQ1O9pKLM9IyS3MTMHF1DAzO93NT i4sT01JzEpGK95PzcTYzAYGEAgh2M35YFHGKU5GBSEuWdkuAaIcSXlJ9SmZFYnBFfVJqTWnyI UYaDQ0mCd3EVUE6wKDU9tSItMwcYtjBpCQ4eJRHeWpA0b3FBYm5xZjpE6hSjLseOzjVPmYRY8 vLzUqXEIWYIgBRllObBjYDF0CVGWSlhXkago4R4ClKLcjNLUOVfMYpzMCoJ8/qDTOHJzCuB2/ QK6AgmoCNOHHcGOaIkESEl1cDIuDZIsDDLKex19Yr4hm93vB4uUi4yv8PKEdYvt3r6Jh+VXBn 7+/mnp63UOjXhcPlqgdctyV+dZppEVtRU1ls/3aB9/dWdhwVuClM23hUr/yR/rKKk7fifPb2N p7N7DFzmHHiY8bsmcN/hHreTzw93SS6/JfejzdDT0vfW6XS+9QG6EbVssjxKLMUZiYZazEXFi QAJlWronAIAAA== X-Env-Sender: olekstysh@gmail.com X-Msg-Ref: server-15.tower-27.messagelabs.com!1480948584!22872431!1 X-Originating-IP: [74.125.82.66] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.0.16; banners=-,-,- X-VirusChecked: Checked Received: (qmail 439 invoked from network); 5 Dec 2016 14:36:24 -0000 Received: from mail-wm0-f66.google.com (HELO mail-wm0-f66.google.com) (74.125.82.66) by server-15.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 5 Dec 2016 14:36:24 -0000 Received: by mail-wm0-f66.google.com with SMTP id u144so16289853wmu.0 for ; Mon, 05 Dec 2016 06:36:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=bTsgoZBOWEfiVQjKbWDxuakiqHMHfdjSDgSPUVprP+4=; b=LEhtmgQfXZK1h+IpzBTzSdNfT1SmvcpUa06ZCQVyh/1O5PFaaHLxjdNGNUcI/v8sYP 3rEFRDjts31rwDVdon901cIouh2NqwlqOQFwhquD9lX7JN0Np/C9OuyXRoXv44abXqMt RwmUxRaKLk1pmttX0uVgDEHtcUcBNS6hIy5hA63D1/YbwdVY5j6KLfOWpF5zhtDgEMn/ x8WLoYdDKO07HEskOoWdhHcuKWnf4jcH3xYVW+nIv8iHvhtQ7+D3by0cg7TvVZRft9L3 EFrRult6CHrJ8NUDWdANN031EHRLM3k5GauTyxBVbZjfJEa2crAO7ibfB6mvXtaUNhXU Qj9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=bTsgoZBOWEfiVQjKbWDxuakiqHMHfdjSDgSPUVprP+4=; b=Mbkf4nVeE1tFbe2CC6DZpKz6WsHvOjr5yVLl592lHCxyVUtQpyOoefTI2SuctTR/bB dZ88FPJd6z23O+EyQ/NUcUjZ+eLn61GR324kmGYiRtv+BOWZYFyBF/xIU/UBZ11Hv4HP LaqWUbdWpkO3DdoSlMr3t6AWVNpmuoWXxZpw3oHqV8ql11uQN5Lwy4rvTvNoL1yszv4v IOn0zkYvtbJRVNMHlP7PgzkTKi1xzE4jo2ezkwjHcGp+GsQoKIzPuzIs4DD/rNQO6XOS ztc/eI72Wy1M7lBmhaMkGp+s6D5su1EC6/ANGPRfE8i4mQQlzq3MY/1bd4S5c71NmQYS KaNQ== X-Gm-Message-State: AKaTC03qaXaig5hkV50QITnDMKqjVX6R95F+hcfdbA8zA/CgoR1bY9ruvesUPBUjpuJugA== X-Received: by 10.28.153.10 with SMTP id b10mr9075219wme.103.1480948584238; Mon, 05 Dec 2016 06:36:24 -0800 (PST) Received: from otyshchenko.kyiv.epam.com (ll-52.209.223.85.sovam.net.ua. [85.223.209.52]) by smtp.gmail.com with ESMTPSA id w18sm440930wme.9.2016.12.05.06.36.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 05 Dec 2016 06:36:23 -0800 (PST) From: Oleksandr Tyshchenko To: xen-devel@lists.xenproject.org Date: Mon, 5 Dec 2016 16:36:13 +0200 Message-Id: <1480948573-22061-1-git-send-email-olekstysh@gmail.com> X-Mailer: git-send-email 2.7.4 Cc: julien.grall@arm.com, sstabellini@kernel.org Subject: [Xen-devel] [PATCH v2] arm/irq: Reorder check when the IRQ is already used by someone 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 From: Oleksandr Tyshchenko Call irq_get_domain for the IRQ we are interested in only after making sure that it is the guest IRQ to avoid ASSERT(test_bit(_IRQ_GUEST, &desc->status)) triggering. Signed-off-by: Oleksandr Tyshchenko Signed-off-by: Andrii Anisov Reviewed-by: Stefano Stabellini CC: Julien Grall --- xen/arch/arm/irq.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/xen/arch/arm/irq.c b/xen/arch/arm/irq.c index 06d4843..6d7e44e 100644 --- a/xen/arch/arm/irq.c +++ b/xen/arch/arm/irq.c @@ -477,26 +477,28 @@ int route_irq_to_guest(struct domain *d, unsigned int virq, */ if ( desc->action != NULL ) { - struct domain *ad = irq_get_domain(desc); - - if ( test_bit(_IRQ_GUEST, &desc->status) && d == ad ) + if ( test_bit(_IRQ_GUEST, &desc->status) ) { - if ( irq_get_guest_info(desc)->virq != virq ) + struct domain *ad = irq_get_domain(desc); + + if ( d != ad ) + { + printk(XENLOG_G_ERR "IRQ %u is already used by domain %u\n", + irq, ad->domain_id); + retval = -EBUSY; + } else if ( irq_get_guest_info(desc)->virq != virq ) { printk(XENLOG_G_ERR "d%u: IRQ %u is already assigned to vIRQ %u\n", d->domain_id, irq, irq_get_guest_info(desc)->virq); retval = -EBUSY; } - goto out; } - - if ( test_bit(_IRQ_GUEST, &desc->status) ) - printk(XENLOG_G_ERR "IRQ %u is already used by domain %u\n", - irq, ad->domain_id); else + { printk(XENLOG_G_ERR "IRQ %u is already used by Xen\n", irq); - retval = -EBUSY; + retval = -EBUSY; + } goto out; }