From patchwork Thu Aug 24 09:47:52 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: 9919685 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 EEA9260349 for ; Thu, 24 Aug 2017 09:50:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E3DCA28A59 for ; Thu, 24 Aug 2017 09:50:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D8CD828BD2; Thu, 24 Aug 2017 09:50:24 +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 8103828A59 for ; Thu, 24 Aug 2017 09:50:24 +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 1dkokE-0007Sd-Fu; Thu, 24 Aug 2017 09:48:10 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dkokC-0007SG-DJ for xen-devel@lists.xenproject.org; Thu, 24 Aug 2017 09:48:08 +0000 Received: from [193.109.254.147] by server-3.bemta-6.messagelabs.com id AA/CB-03044-7D0AE995; Thu, 24 Aug 2017 09:48:07 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprNIsWRWlGSWpSXmKPExsXitHRDpO71BfM iDTZMY7P4vmUykwOjx+EPV1gCGKNYM/OS8isSWDNOHjrIXLBWuqK9M7qB8adwFyMnh4SAv8TD 3g9sIDabgI7Exbk7wWwRAVOJtnsLGbsYOTiYBcolZtyIBwkLC/hI7J6yhRXEZhFQlfj87hMTi M0rYCkx50wvO8RIPYm3E18wgticAlYSdy++ABspBFRzZAVMvaDEyZlPWEBsZgFNidbtv9khbH mJ5q2zmSHqFSX65z1gm8DINwtJyywkLbOQtCxgZF7FqFGcWlSWWqRrZKyXVJSZnlGSm5iZo2t oYKaXm1pcnJiempOYVKyXnJ+7iREYaAxAsIPxz/zAQ4ySHExKorxPpOdFCvEl5adUZiQWZ8QX leakFh9ilOHgUJLgXTsfKCdYlJqeWpGWmQMMeZi0BAePkgjvcpA0b3FBYm5xZjpE6hSjopQ4b zlIQgAkkVGaB9cGi7NLjLJSwryMQIcI8RSkFuVmlqDKv2IU52BUEuatBJnCk5lXAjf9FdBiJq DFk07MAVlckoiQkmpglM6/HrMqNjtn/7ktXz9+f8z2qtOjl8mwuXtliVTD0fW5kaesZh509ir 1mPn1XeDxcn375fv0dwW/DHvX635bxmjBOa+suv5/8eoFRjtS5qk86vkye5bZGkHdEm3pIK6E eQc+nX8ffOXZDr43IjPvvfnkZMPG8HH5CuPLj48LtpYc2ljj9fj8bSWW4oxEQy3mouJEAKMqj JOuAgAA X-Env-Sender: prvs=402c228e5=roger.pau@citrix.com X-Msg-Ref: server-2.tower-27.messagelabs.com!1503568084!53674861!2 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: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 55538 invoked from network); 24 Aug 2017 09:48:06 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-2.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 24 Aug 2017 09:48:06 -0000 X-IronPort-AV: E=Sophos;i="5.41,420,1498521600"; d="scan'208";a="436696546" From: Roger Pau Monne To: , Date: Thu, 24 Aug 2017 10:47:52 +0100 Message-ID: <20170824094753.77795-2-roger.pau@citrix.com> X-Mailer: git-send-email 2.11.0 (Apple Git-81) In-Reply-To: <20170824094753.77795-1-roger.pau@citrix.com> References: <20170824094753.77795-1-roger.pau@citrix.com> MIME-Version: 1.0 Cc: Andrew Cooper , Jan Beulich , Roger Pau Monne Subject: [Xen-devel] [PATCH XEN] x86/pt: add a MSI unmask flag to XEN_DOMCTL_bind_pt_irq 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 flag is part of the gflags, and should be used to request the unmask of a MSI interrupt once it's bound. This is required for the device model in order to be capable of binding MSIX interrupts that have the entry mask bit already unset at bind time. Without this fix the interrupts would be left masked. Signed-off-by: Roger Pau Monné Reported by: Andreas Kinzler --- Cc: Jan Beulich Cc: Andrew Cooper --- xen/drivers/passthrough/io.c | 23 ++++++++++++++++++++--- xen/include/asm-x86/hvm/irq.h | 1 + 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/xen/drivers/passthrough/io.c b/xen/drivers/passthrough/io.c index 19a21bf85a..f68b31809f 100644 --- a/xen/drivers/passthrough/io.c +++ b/xen/drivers/passthrough/io.c @@ -342,13 +342,14 @@ int pt_irq_create_bind( uint8_t dest, dest_mode, delivery_mode; int dest_vcpu_id; const struct vcpu *vcpu; + uint32_t gflags = pt_irq_bind->u.msi.gflags & ~VMSI_UNMASKED; if ( !(pirq_dpci->flags & HVM_IRQ_DPCI_MAPPED) ) { pirq_dpci->flags = HVM_IRQ_DPCI_MAPPED | HVM_IRQ_DPCI_MACH_MSI | HVM_IRQ_DPCI_GUEST_MSI; pirq_dpci->gmsi.gvec = pt_irq_bind->u.msi.gvec; - pirq_dpci->gmsi.gflags = pt_irq_bind->u.msi.gflags; + pirq_dpci->gmsi.gflags = gflags; /* * 'pt_irq_create_bind' can be called after 'pt_irq_destroy_bind'. * The 'pirq_cleanup_check' which would free the structure is only @@ -401,13 +402,13 @@ int pt_irq_create_bind( /* If pirq is already mapped as vmsi, update guest data/addr. */ if ( pirq_dpci->gmsi.gvec != pt_irq_bind->u.msi.gvec || - pirq_dpci->gmsi.gflags != pt_irq_bind->u.msi.gflags ) + pirq_dpci->gmsi.gflags != gflags ) { /* Directly clear pending EOIs before enabling new MSI info. */ pirq_guest_eoi(info); pirq_dpci->gmsi.gvec = pt_irq_bind->u.msi.gvec; - pirq_dpci->gmsi.gflags = pt_irq_bind->u.msi.gflags; + pirq_dpci->gmsi.gflags = gflags; } } /* Calculate dest_vcpu_id for MSI-type pirq migration. */ @@ -438,6 +439,22 @@ int pt_irq_create_bind( pi_update_irte(vcpu ? &vcpu->arch.hvm_vmx.pi_desc : NULL, info, pirq_dpci->gmsi.gvec); + if ( pt_irq_bind->u.msi.gflags & VMSI_UNMASKED ) + { + struct irq_desc *desc = irq_to_desc(info->arch.irq); + unsigned long flags; + + if ( !desc ) + { + pt_irq_destroy_bind(d, pt_irq_bind); + return -EINVAL; + } + + spin_lock_irqsave(&desc->lock, flags); + guest_mask_msi_irq(desc, false); + spin_unlock_irqrestore(&desc->lock, flags); + } + break; } diff --git a/xen/include/asm-x86/hvm/irq.h b/xen/include/asm-x86/hvm/irq.h index 106dc19613..9546c24879 100644 --- a/xen/include/asm-x86/hvm/irq.h +++ b/xen/include/asm-x86/hvm/irq.h @@ -136,6 +136,7 @@ struct dev_intx_gsi_link { #define VMSI_DM_MASK 0x200 #define VMSI_DELIV_MASK 0x7000 #define VMSI_TRIG_MODE 0x8000 +#define VMSI_UNMASKED 0x10000 #define GFLAGS_SHIFT_RH 8 #define GFLAGS_SHIFT_DELIV_MODE 12