From patchwork Thu Dec 22 18:24:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 9485471 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 8F5D8600BA for ; Thu, 22 Dec 2016 18:26:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 72CC02843F for ; Thu, 22 Dec 2016 18:26:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 67A662844B; Thu, 22 Dec 2016 18:26:23 +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 1BA832843F for ; Thu, 22 Dec 2016 18:26:23 +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 1cK828-0005JO-AO; Thu, 22 Dec 2016 18:24:04 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cK827-0005HD-Fl for xen-devel@lists.xenproject.org; Thu, 22 Dec 2016 18:24:03 +0000 Received: from [193.109.254.147] by server-3.bemta-6.messagelabs.com id 07/01-09053-24A1C585; Thu, 22 Dec 2016 18:24:02 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrPLMWRWlGSWpSXmKPExsVysyfVTddJKib CYFu3uMX3LZOZHBg9Dn+4whLAGMWamZeUX5HAmtG43bGgXaDieONPlgbG9TxdjFwcQgKbGSWm vf/HDuEsZ5TYfGI2YxcjJwebgK7EjpuvmUFsEYFQiacLvgPZHBzMAl4SX957g5jCAikS/9uyQ SpYBFQlWs/cYgKxeQWsJX4u+wNmSwjISTScvw82hVPARuLV10lgcSGgmoMTdzBPYORewMiwil G9OLWoLLVI11wvqSgzPaMkNzEzR9fQwEwvN7W4ODE9NScxqVgvOT93EyPQswxAsINx5mX/Q4y SHExKorw5vDERQnxJ+SmVGYnFGfFFpTmpxYcYZTg4lCR4y8WBcoJFqempFWmZOcAQg0lLcPAo ifDOAUnzFhck5hZnpkOkTjHqcqw7teQpkxBLXn5eqpQ4bw1IkQBIUUZpHtwIWLhfYpSVEuZlB DpKiKcgtSg3swRV/hWjOAejkjBvBsgUnsy8ErhNr4COYAI6wrY5GuSIkkSElFQD475bJ7Q5f+ 4sXa52hn2rxrf6n/npYrcYz96dHJb2wNeW/+2VmIXtHN8SZrTyae58LLUsU+2PsKL2k2CvmCY hiTWr/l38sm1KT+bmFScnBjyZqypVocF5fOK9XWcOhmjemOKyoGKO9NGDd0J3p58NydN0mD1T 3SjS5n7oSuav9mmlj7qstGdefafEUpyRaKjFXFScCAAGAF3OcgIAAA== X-Env-Sender: andre.przywara@arm.com X-Msg-Ref: server-4.tower-27.messagelabs.com!1482431041!77984536!1 X-Originating-IP: [217.140.101.70] 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 59862 invoked from network); 22 Dec 2016 18:24:02 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-4.tower-27.messagelabs.com with SMTP; 22 Dec 2016 18:24:02 -0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A813C152D; Thu, 22 Dec 2016 10:24:01 -0800 (PST) Received: from e104803-lin.lan (unknown [10.1.207.46]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C76BE3F220; Thu, 22 Dec 2016 10:24:00 -0800 (PST) From: Andre Przywara To: Julien Grall , Stefano Stabellini Date: Thu, 22 Dec 2016 18:24:28 +0000 Message-Id: <20161222182446.18791-9-andre.przywara@arm.com> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20161222182446.18791-1-andre.przywara@arm.com> References: <20161222182446.18791-1-andre.przywara@arm.com> Cc: xen-devel@lists.xenproject.org, Vijay Kilari Subject: [Xen-devel] [RFC PATCH v2 08/26] ARM: GICv3 ITS: map device and LPIs to the ITS on physdev_op hypercall 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 To get MSIs from devices forwarded to a CPU, we need to name the device and its MSIs by mapping them to an ITS. Since this involves queueing commands to the ITS command queue, we can't really afford to do this during the guest's runtime, as this would open up a denial-of-service attack vector. So we require every device with MSI interrupts to be mapped explicitly by Dom0. For Dom0 itself we can just use the existing PCI physdev_op hypercalls, which the existing Linux kernel issues already. So upon receipt of this hypercall we map the device to the hardware ITS and prepare it to be later mapped by the virtual ITS by using the very same device ID (for Dom0 only). Also we ask for mapping 32 LPIs to cover 32 MSIs that the device may use. Signed-off-by: Andre Przywara --- xen/arch/arm/physdev.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/xen/arch/arm/physdev.c b/xen/arch/arm/physdev.c index 27bbbda..d9e6be3 100644 --- a/xen/arch/arm/physdev.c +++ b/xen/arch/arm/physdev.c @@ -9,11 +9,35 @@ #include #include #include +#include +#include #include int do_physdev_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg) { + struct physdev_manage_pci manage; + struct domain *dom0; + u32 devid; + int ret; + + switch (cmd) + { + case PHYSDEVOP_manage_pci_add: + case PHYSDEVOP_manage_pci_remove: + if ( copy_from_guest(&manage, arg, 1) != 0 ) + return -EFAULT; + + dom0 = hardware_domain; + devid = manage.bus << 8 | manage.devfn; + /* Allocate an ITS device table with space for 32 MSIs */ + ret = gicv3_its_map_device(dom0, devid, devid, 5, + cmd == PHYSDEVOP_manage_pci_add); + + put_domain(dom0); + return ret; + } + gdprintk(XENLOG_DEBUG, "PHYSDEVOP cmd=%d: not implemented\n", cmd); return -ENOSYS; }