From patchwork Mon Jan 30 18:31:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 9545885 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 64A1260415 for ; Mon, 30 Jan 2017 18:33:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5BFD127F7F for ; Mon, 30 Jan 2017 18:33:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 50B8C28173; Mon, 30 Jan 2017 18:33:11 +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 0A62527F7F for ; Mon, 30 Jan 2017 18:33:11 +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 1cYGj4-0007kC-0U; Mon, 30 Jan 2017 18:30:50 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cYGj3-0007iO-4L for xen-devel@lists.xenproject.org; Mon, 30 Jan 2017 18:30:49 +0000 Received: from [85.158.143.35] by server-7.bemta-6.messagelabs.com id 04/55-29440-8568F885; Mon, 30 Jan 2017 18:30:48 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrGLMWRWlGSWpSXmKPExsVysyfVTTe8rT/ C4PRyG4vvWyYzOTB6HP5whSWAMYo1My8pvyKBNaN7w1fmggP8FZ1n77M1MLbydDFycQgJbGaU +DVvJyuEs5xR4snWyyxdjJwcbAK6EjtuvmYGsUUEQiXm/HwEZHNwMAt4SXx57w0SFhaIlXjxZ z4riM0ioCrxcN5NdhCbV8BG4uGU32C2hICcRMP5+2BjOIHiszf/ZgKxhQSsJf71LGecwMi9gJ FhFaNGcWpRWWqRrrGBXlJRZnpGSW5iZo6uoYGZXm5qcXFiempOYlKxXnJ+7iZGoH8ZgGAH49+ 1gYcYJTmYlER5+z72RQjxJeWnVGYkFmfEF5XmpBYfYpTh4FCS4O1q7Y8QEixKTU+tSMvMAQYa TFqCg0dJhDcVJM1bXJCYW5yZDpE6xagoJc6bB5IQAElklObBtcGC+xKjrJQwLyPQIUI8BalFu ZklqPKvGMU5GJWEef1ApvBk5pXATX8FtJgJaLH7qz6QxSWJCCmpBsbpW//7W5Wbe05dyqyy1O vrWU3+Ay2s51LWdkWU+rd2KxbG3glLPJkcaJdmck523ualk1LY/x7+LMl3RF6q+fUWpeuPJyx p0s+79tDn9L5Tr/aVlzT6H7S7u+DMzbbvRicZv2ZkrLua3f+O6/dk+/4Pdxd35HLw3kuZLnT1 5DyTm9NtUs44u5YrsRRnJBpqMRcVJwIArAsoWGkCAAA= X-Env-Sender: andre.przywara@arm.com X-Msg-Ref: server-4.tower-21.messagelabs.com!1485801047!49064959!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 53676 invoked from network); 30 Jan 2017 18:30:47 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-4.tower-21.messagelabs.com with SMTP; 30 Jan 2017 18:30:47 -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 499A51595; Mon, 30 Jan 2017 10:30:47 -0800 (PST) Received: from e104803-lin.lan (unknown [10.1.207.46]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6A0063F24D; Mon, 30 Jan 2017 10:30:46 -0800 (PST) From: Andre Przywara To: Stefano Stabellini , Julien Grall Date: Mon, 30 Jan 2017 18:31:34 +0000 Message-Id: <20170130183153.28566-10-andre.przywara@arm.com> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170130183153.28566-1-andre.przywara@arm.com> References: <20170130183153.28566-1-andre.przywara@arm.com> Cc: xen-devel@lists.xenproject.org, Vijay Kilari Subject: [Xen-devel] [PATCH 09/28] 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 | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/xen/arch/arm/physdev.c b/xen/arch/arm/physdev.c index 27bbbda..6e02de4 100644 --- a/xen/arch/arm/physdev.c +++ b/xen/arch/arm/physdev.c @@ -9,11 +9,32 @@ #include #include #include +#include +#include #include int do_physdev_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg) { + struct physdev_manage_pci manage; + 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; + + devid = manage.bus << 8 | manage.devfn; + /* Allocate an ITS device table with space for 32 MSIs */ + ret = gicv3_its_map_guest_device(hardware_domain, devid, devid, 5, + cmd == PHYSDEVOP_manage_pci_add); + + return ret; + } + gdprintk(XENLOG_DEBUG, "PHYSDEVOP cmd=%d: not implemented\n", cmd); return -ENOSYS; }