From patchwork Mon Aug 14 14:28:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 9899061 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 953A1603B5 for ; Mon, 14 Aug 2017 14:31:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 84AAC2866C for ; Mon, 14 Aug 2017 14:31:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7768C28670; Mon, 14 Aug 2017 14:31:03 +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 704CD28634 for ; Mon, 14 Aug 2017 14:31:02 +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 1dhGN8-0004li-9E; Mon, 14 Aug 2017 14:29:38 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dhGN7-0004jM-2f for xen-devel@lists.xenproject.org; Mon, 14 Aug 2017 14:29:37 +0000 Received: from [85.158.139.211] by server-3.bemta-5.messagelabs.com id B7/A6-02033-0D3B1995; Mon, 14 Aug 2017 14:29:36 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrMIsWRWlGSWpSXmKPExsXitHSDve75zRM jDZadNbb4vmUykwOjx+EPV1gCGKNYM/OS8isSWDMm3nrBVvBNpOL3y62MDYxT+LsYOTkkBPwl Di3byQJiswnoSFycu5Oti5GDQ0RAReL2XoMuRi4OZoENjBLnfuxlB6kRFgiX6D7xkhmkhkVAV eLnihCQMK+ApcTGU1eYIEbqSbyd+IIRxOYUsJL4cvk6WKsQUM3R/uuMEPWCEidnPgFbyyygKd G6/Tc7hC0v0bx1NjNEvaJE/7wHbBMY+WYhaZmFpGUWkpYFjMyrGNWLU4vKUot0DfWSijLTM0p yEzNzdA0NTPVyU4uLE9NTcxKTivWS83M3MQIDrZ6BgXEHY1Ov8yFGSQ4mJVHeBJ/eSCG+pPyU yozE4oz4otKc1OJDjBocHAKb166+wCjFkpefl6okwRu2aWKkkGBRanpqRVpmDjAWYEolOHiUR Hj9QNK8xQWJucWZ6RCpU4y6HK8m/P/GJAQ2Q0qc9wdIkQBIUUZpHtwIWFxeYpSVEuZlZGBgEO IpSC3KzSxBlX/FKM7BqCTMawAyhSczrwRu0yugI5iAjugD+YW3uCQRISXVwBh/NuvLuVturkH ORqVFl+PNFs3vc559KaasoOXw14pFtpsiFlxSnBvDdFtoNndftPAra5N5j9OKgk7+yTA7H7vU ZJ3OWevPet+fZ+WlTdo44S6TCsOOiEzvet6ay/FuHfZfPh43XseYzWT4M8i2OF0rsIf18juP7 uLup51f3lkeOfizOd0sUomlOCPRUIu5qDgRAHatztrGAgAA X-Env-Sender: prvs=3925c166a=roger.pau@citrix.com X-Msg-Ref: server-12.tower-206.messagelabs.com!1502720974!70921400!1 X-Originating-IP: [66.165.176.63] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni42MyA9PiAzMDYwNDg=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 53202 invoked from network); 14 Aug 2017 14:29:35 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-12.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 14 Aug 2017 14:29:35 -0000 X-IronPort-AV: E=Sophos;i="5.41,373,1498521600"; d="scan'208";a="443694411" From: Roger Pau Monne To: Date: Mon, 14 Aug 2017 15:28:43 +0100 Message-ID: <20170814142850.39133-5-roger.pau@citrix.com> X-Mailer: git-send-email 2.11.0 (Apple Git-81) In-Reply-To: <20170814142850.39133-1-roger.pau@citrix.com> References: <20170814142850.39133-1-roger.pau@citrix.com> MIME-Version: 1.0 Cc: Andrew Cooper , boris.ostrovsky@oracle.com, Roger Pau Monne , Jan Beulich Subject: [Xen-devel] [PATCH v5 04/11] x86/physdev: enable PHYSDEVOP_pci_mmcfg_reserved for PVH Dom0 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: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP So that MMCFG regions not present in the MCFG ACPI table can be added at run time by the hardware domain. Signed-off-by: Roger Pau Monné --- Cc: Jan Beulich Cc: Andrew Cooper --- Changes since v4: - Change the hardware_domain check in hvm_physdev_op to a vpci check. - Only register the MMCFG area, but don't scan it. Changes since v3: - New in this version. --- xen/arch/x86/hvm/hypercall.c | 4 ++++ xen/arch/x86/hvm/io.c | 7 +++---- xen/arch/x86/physdev.c | 9 +++++++++ 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/xen/arch/x86/hvm/hypercall.c b/xen/arch/x86/hvm/hypercall.c index e7238ce293..369abfd262 100644 --- a/xen/arch/x86/hvm/hypercall.c +++ b/xen/arch/x86/hvm/hypercall.c @@ -89,6 +89,10 @@ static long hvm_physdev_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg) if ( !has_pirq(curr->domain) ) return -ENOSYS; break; + case PHYSDEVOP_pci_mmcfg_reserved: + if ( !has_vpci(curr->domain) ) + return -ENOSYS; + break; } if ( !curr->hcall_compat ) diff --git a/xen/arch/x86/hvm/io.c b/xen/arch/x86/hvm/io.c index 2845dc5b48..93c3b21a47 100644 --- a/xen/arch/x86/hvm/io.c +++ b/xen/arch/x86/hvm/io.c @@ -524,10 +524,9 @@ static const struct hvm_mmio_ops vpci_mmcfg_ops = { .write = vpci_mmcfg_write, }; -int __hwdom_init register_vpci_mmcfg_handler(struct domain *d, paddr_t addr, - unsigned int start_bus, - unsigned int end_bus, - unsigned int seg) +int register_vpci_mmcfg_handler(struct domain *d, paddr_t addr, + unsigned int start_bus, unsigned int end_bus, + unsigned int seg) { struct hvm_mmcfg *mmcfg; diff --git a/xen/arch/x86/physdev.c b/xen/arch/x86/physdev.c index 0eb409758f..10e0a1ad79 100644 --- a/xen/arch/x86/physdev.c +++ b/xen/arch/x86/physdev.c @@ -559,6 +559,15 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg) ret = pci_mmcfg_reserved(info.address, info.segment, info.start_bus, info.end_bus, info.flags); + if ( ret || !is_hvm_domain(currd) ) + break; + + /* + * For HVM (PVH) domains try to add the newly found MMCFG to the + * domain. + */ + ret = register_vpci_mmcfg_handler(currd, info.address, info.start_bus, + info.end_bus, info.segment); break; }