From patchwork Tue Sep 27 15:57:22 2016 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: 9352203 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 82AE96077B for ; Tue, 27 Sep 2016 16:00:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 746A92927A for ; Tue, 27 Sep 2016 16:00:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 693392928F; Tue, 27 Sep 2016 16:00:59 +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 0C35B2927A for ; Tue, 27 Sep 2016 16:00:59 +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 1boumQ-0000A1-Ry; Tue, 27 Sep 2016 15:58:50 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1boumP-000064-8C for xen-devel@lists.xenproject.org; Tue, 27 Sep 2016 15:58:49 +0000 Received: from [85.158.139.211] by server-10.bemta-5.messagelabs.com id 4F/7B-16745-8379AE75; Tue, 27 Sep 2016 15:58:48 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrJIsWRWlGSWpSXmKPExsXitHRDpK7Z9Ff hBve22lh83zKZyYHR4/CHKywBjFGsmXlJ+RUJrBmv595iLjgoUfHkz3HWBsbfQl2MnBwSAv4S nVduMIPYbAI6Ehfn7mTrYuTgEBFQkbi916CLkYuDWeAGo8SntXcZQWqEBZIlXi3uArNZBFQlV jYuYQGxeQVcJWbPbmeEmKkr8fDcb1YQmxMo3tu2gAnEFhJwkbg78yMrRL2gxMmZT8B6mQU0JV q3/2aHsOUlmrfOZoaoV5Ton/eADWImt8Tt01OZJzDyz0LSPgtJ+ywk7QsYmVcxahSnFpWlFuk aWuglFWWmZ5TkJmbm6BoamOrlphYXJ6an5iQmFesl5+duYgQGIQMQ7GBs2u55iFGSg0lJlFej /VW4EF9SfkplRmJxRnxRaU5q8SFGGQ4OJQnekmlAOcGi1PTUirTMHGA8wKQlOHiURHh5QNK8x QWJucWZ6RCpU4yKUuK8DVOBEgIgiYzSPLg2WAxeYpSVEuZlBDpEiKcgtSg3swRV/hWjOAejkj CvAsh4nsy8Erjpr4AWMwEtXnriBcjikkSElFQDoyD31Mwdbq5xInamMpzVywtcfLcK2u5ee/z OhslJkdrFs03vKrkGKWfsmR6wV/XGq1df9UUy+X1PPZIN/JTh7XpoQceflZVvZrItuBUYO3Or X+PZ6qCc6C+r9d6tL1ptHdVb6xDcYTvrjcTbd9eaeTuXZ2jvVy0+JnPnpJV6Qn9BjPoM0c4kJ ZbijERDLeai4kQAgbDfXrwCAAA= X-Env-Sender: prvs=071b8e69e=roger.pau@citrix.com X-Msg-Ref: server-15.tower-206.messagelabs.com!1474991925!48021928!1 X-Originating-IP: [66.165.176.89] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni44OSA9PiAyMDMwMDc=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 8.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 40814 invoked from network); 27 Sep 2016 15:58:46 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-15.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 27 Sep 2016 15:58:46 -0000 X-IronPort-AV: E=Sophos;i="5.30,405,1470700800"; d="scan'208";a="380934588" From: Roger Pau Monne To: Date: Tue, 27 Sep 2016 17:57:22 +0200 Message-ID: <1474991845-27962-28-git-send-email-roger.pau@citrix.com> X-Mailer: git-send-email 2.7.4 (Apple Git-66) In-Reply-To: <1474991845-27962-1-git-send-email-roger.pau@citrix.com> References: <1474991845-27962-1-git-send-email-roger.pau@citrix.com> MIME-Version: 1.0 X-DLP: MIA2 Cc: Andrew Cooper , Paul Durrant , Jan Beulich , boris.ostrovsky@oracle.com, Roger Pau Monne Subject: [Xen-devel] [PATCH v2 27/30] x86/msixtbl: disable MSI-X intercepts for domains without an ioreq server 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 The current msixtbl intercepts only partially trap MSI-X accesses, but are not complete, there's missing logic in order to setup PIRQs and bind them to domains. Disable them for domains without at least an ioreq server (PVH). Signed-off-by: Roger Pau Monné --- Cc: Paul Durrant Cc: Jan Beulich Cc: Andrew Cooper --- NB: this is a preparatory patch for introducing a complete MSI-X emulation layer into Xen. Long term the current msixtbl code should be replaced with the complete MSI-X emulation introduced in later patches. --- xen/arch/x86/hvm/ioreq.c | 11 +++++++++++ xen/drivers/passthrough/io.c | 4 +++- xen/include/asm-x86/hvm/ioreq.h | 1 + 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/hvm/ioreq.c b/xen/arch/x86/hvm/ioreq.c index d2245e2..b09fa96 100644 --- a/xen/arch/x86/hvm/ioreq.c +++ b/xen/arch/x86/hvm/ioreq.c @@ -772,6 +772,17 @@ int hvm_destroy_ioreq_server(struct domain *d, ioservid_t id) return rc; } +int hvm_has_ioreq_server(struct domain *d) +{ + int empty; + + spin_lock_recursive(&d->arch.hvm_domain.ioreq_server.lock); + empty = list_empty(&d->arch.hvm_domain.ioreq_server.list); + spin_unlock_recursive(&d->arch.hvm_domain.ioreq_server.lock); + + return !empty; +} + int hvm_get_ioreq_server_info(struct domain *d, ioservid_t id, unsigned long *ioreq_pfn, unsigned long *bufioreq_pfn, diff --git a/xen/drivers/passthrough/io.c b/xen/drivers/passthrough/io.c index edd8dbd..1e5e365 100644 --- a/xen/drivers/passthrough/io.c +++ b/xen/drivers/passthrough/io.c @@ -24,6 +24,7 @@ #include #include #include +#include #include static DEFINE_PER_CPU(struct list_head, dpci_list); @@ -384,7 +385,8 @@ int pt_irq_create_bind( pirq_dpci->dom = d; /* bind after hvm_irq_dpci is setup to avoid race with irq handler*/ rc = pirq_guest_bind(d->vcpu[0], info, 0); - if ( rc == 0 && pt_irq_bind->u.msi.gtable ) + if ( rc == 0 && pt_irq_bind->u.msi.gtable && + hvm_has_ioreq_server(d) ) { rc = msixtbl_pt_register(d, info, pt_irq_bind->u.msi.gtable); if ( unlikely(rc) ) diff --git a/xen/include/asm-x86/hvm/ioreq.h b/xen/include/asm-x86/hvm/ioreq.h index fbf2c74..6456cd2 100644 --- a/xen/include/asm-x86/hvm/ioreq.h +++ b/xen/include/asm-x86/hvm/ioreq.h @@ -31,6 +31,7 @@ int hvm_get_ioreq_server_info(struct domain *d, ioservid_t id, unsigned long *ioreq_pfn, unsigned long *bufioreq_pfn, evtchn_port_t *bufioreq_port); +int hvm_has_ioreq_server(struct domain *d); int hvm_map_io_range_to_ioreq_server(struct domain *d, ioservid_t id, uint32_t type, uint64_t start, uint64_t end);