From patchwork Fri Nov 17 06:24:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chao Gao X-Patchwork-Id: 10062369 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 4BC4F6023A for ; Fri, 17 Nov 2017 06:28:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3E9272A539 for ; Fri, 17 Nov 2017 06:28:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 32F1D2A990; Fri, 17 Nov 2017 06:28:21 +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 CEB082A539 for ; Fri, 17 Nov 2017 06:28:20 +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 1eFa6c-0002YT-R5; Fri, 17 Nov 2017 06:26:26 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eFa6b-0002WC-Lm for xen-devel@lists.xenproject.org; Fri, 17 Nov 2017 06:26:25 +0000 Received: from [85.158.143.35] (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256 bits)) by server-2.bemta-6.messagelabs.com id 3B/18-05188-1118E0A5; Fri, 17 Nov 2017 06:26:25 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpkkeJIrShJLcpLzFFi42Jpa+sQ0RVo5Is y2LdN0uL7lslMDowehz9cYQlgjGLNzEvKr0hgzZj5di1jwUTFiimnrrE1MJ6W6GLk4hASmM4o 8fPaPbYuRk4OCQFeiSPLZrBC2L4SJ160soPYQgJVErM+L2EBsdkElCUufu0FqxcRkJT43XWaG WQQs8BBRokjW9vBEsICzhKHtm4HG8QioCqxdcE/JhCbV8BJ4uzsdVDLFCSmPHzPDGJzAtUv6v 3EArHMSaL15Q6mCYy8CxgZVjFqFKcWlaUW6RpZ6iUVZaZnlOQmZuboGhqY6eWmFhcnpqfmJCY V6yXn525iBAYEAxDsYDywKPAQoyQHk5IoL485X5QQX1J+SmVGYnFGfFFpTmrxIUYZDg4lCV6m BqCcYFFqempFWmYOMDRh0hIcPEoivAX1QGne4oLE3OLMdIjUKUZjjmczXzcwc0y72trELMSSl 5+XKiXO6wsySQCkNKM0D24QLGYuMcpKCfMyAp0mxFOQWpSbWYIq/4pRnINRSZhXD2QKT2ZeCd y+V0CnMAGdYnODG+SUkkSElFQDo1zW3Bn1PpWLGe/ZnBVTqM3/yROsNEW489N03cWCHy04i6p qLd+IOOwIFLDewLKdx1xKQ+Ju6Zm/q/e7Sd1T/6g3heP0yQ4f+QKr3A2S6+9W6yVaLPt3cJ5s kuMpJ9svbkW6Dc/S9661WHJabMbtM7fSZlszr5Qy/3r73w+tK0mnn+uybjRMUGIpzkg01GIuK k4EANx694qUAgAA X-Env-Sender: chao.gao@intel.com X-Msg-Ref: server-3.tower-21.messagelabs.com!1510899982!78918016!1 X-Originating-IP: [134.134.136.20] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTM0LjEzNC4xMzYuMjAgPT4gMzU1MzU4\n X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 7738 invoked from network); 17 Nov 2017 06:26:24 -0000 Received: from mga02.intel.com (HELO mga02.intel.com) (134.134.136.20) by server-3.tower-21.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 17 Nov 2017 06:26:24 -0000 Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Nov 2017 22:26:21 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,407,1505804400"; d="scan'208";a="2622217" Received: from skl-4s-chao.sh.intel.com ([10.239.48.9]) by fmsmga004.fm.intel.com with ESMTP; 16 Nov 2017 22:26:20 -0800 From: Chao Gao To: qemu-devel@nongnu.org Date: Fri, 17 Nov 2017 14:24:24 +0800 Message-Id: <1510899865-40323-3-git-send-email-chao.gao@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1510899865-40323-1-git-send-email-chao.gao@intel.com> References: <1510899865-40323-1-git-send-email-chao.gao@intel.com> Cc: Anthony Perard , xen-devel@lists.xenproject.org, Stefano Stabellini , Lan Tianyu , Chao Gao Subject: [Xen-devel] [PATCH v3 2/3] xen/pt: Pass the whole msi addr/data to Xen 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 Previously, some fields (reserved or unalterable) are filtered by Qemu. This fields are useless for the legacy interrupt format. However, these fields are may meaningful (for intel platform) for the interrupt of remapping format. It is better to pass the whole msi addr/data to Xen without any filtering. The main reason why we want this is QEMU doesn't have the knowledge to decide the interrupt format after we introduce vIOMMU inside Xen. Passing the whole msi message down and let arch-specific vIOMMU to decide the interrupt format. Signed-off-by: Chao Gao Signed-off-by: Lan Tianyu --- v3: - new --- hw/xen/xen_pt_msi.c | 47 ++++++++++++----------------------------------- 1 file changed, 12 insertions(+), 35 deletions(-) diff --git a/hw/xen/xen_pt_msi.c b/hw/xen/xen_pt_msi.c index 6d1e3bd..f7d6e76 100644 --- a/hw/xen/xen_pt_msi.c +++ b/hw/xen/xen_pt_msi.c @@ -47,25 +47,6 @@ static inline uint32_t msi_ext_dest_id(uint32_t addr_hi) return addr_hi & 0xffffff00; } -static uint32_t msi_gflags(uint32_t data, uint64_t addr) -{ - uint32_t result = 0; - int rh, dm, dest_id, deliv_mode, trig_mode; - - rh = (addr >> MSI_ADDR_REDIRECTION_SHIFT) & 0x1; - dm = (addr >> MSI_ADDR_DEST_MODE_SHIFT) & 0x1; - dest_id = msi_dest_id(addr); - deliv_mode = (data >> MSI_DATA_DELIVERY_MODE_SHIFT) & 0x7; - trig_mode = (data >> MSI_DATA_TRIGGER_SHIFT) & 0x1; - - result = dest_id | (rh << XEN_PT_GFLAGS_SHIFT_RH) - | (dm << XEN_PT_GFLAGS_SHIFT_DM) - | (deliv_mode << XEN_PT_GFLAGSSHIFT_DELIV_MODE) - | (trig_mode << XEN_PT_GFLAGSSHIFT_TRG_MODE); - - return result; -} - static inline uint64_t msi_addr64(XenPTMSI *msi) { return (uint64_t)msi->addr_hi << 32 | msi->addr_lo; @@ -160,23 +141,20 @@ static int msi_msix_update(XenPCIPassthroughState *s, bool masked) { PCIDevice *d = &s->dev; - uint8_t gvec = msi_vector(data); - uint32_t gflags = msi_gflags(data, addr); + uint32_t gflags = masked ? 0 : (1u << XEN_PT_GFLAGSSHIFT_UNMASKED); int rc = 0; uint64_t table_addr = 0; - XEN_PT_LOG(d, "Updating MSI%s with pirq %d gvec %#x gflags %#x" - " (entry: %#x)\n", - is_msix ? "-X" : "", pirq, gvec, gflags, msix_entry); + XEN_PT_LOG(d, "Updating MSI%s with pirq %d gvec %#x addr %"PRIx64 + " data %#x gflags %#x (entry: %#x)\n", + is_msix ? "-X" : "", pirq, addr, data, gflags, msix_entry); if (is_msix) { table_addr = s->msix->mmio_base_addr; } - gflags |= masked ? 0 : (1u << XEN_PT_GFLAGSSHIFT_UNMASKED); - - rc = xc_domain_update_msi_irq(xen_xc, xen_domid, gvec, - pirq, gflags, table_addr); + rc = xc_domain_update_msi_irq(xen_xc, xen_domid, pirq, addr, + data, gflags, table_addr); if (rc) { XEN_PT_ERR(d, "Updating of MSI%s failed. (err: %d)\n", @@ -199,8 +177,6 @@ static int msi_msix_disable(XenPCIPassthroughState *s, bool is_binded) { PCIDevice *d = &s->dev; - uint8_t gvec = msi_vector(data); - uint32_t gflags = msi_gflags(data, addr); int rc = 0; if (pirq == XEN_PT_UNASSIGNED_PIRQ) { @@ -208,12 +184,13 @@ static int msi_msix_disable(XenPCIPassthroughState *s, } if (is_binded) { - XEN_PT_LOG(d, "Unbind MSI%s with pirq %d, gvec %#x\n", - is_msix ? "-X" : "", pirq, gvec); - rc = xc_domain_unbind_msi_irq(xen_xc, xen_domid, gvec, pirq, gflags); + XEN_PT_LOG(d, "Unbind MSI%s with pirq %d, addr %"PRIx64", data %#x\n", + is_msix ? "-X" : "", pirq, addr, data); + rc = xc_domain_unbind_msi_irq(xen_xc, xen_domid, pirq, addr, data); if (rc) { - XEN_PT_ERR(d, "Unbinding of MSI%s failed. (err: %d, pirq: %d, gvec: %#x)\n", - is_msix ? "-X" : "", errno, pirq, gvec); + XEN_PT_ERR(d, "Unbinding of MSI%s failed. (err: %d, pirq: %d, " + "addr: %"PRIx64", data: %#x)\n", + is_msix ? "-X" : "", errno, pirq, addr, data); return rc; } }