From patchwork Fri Nov 17 06:22:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chao Gao X-Patchwork-Id: 10062347 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 4DC436023A for ; Fri, 17 Nov 2017 06:27:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 407EB2A539 for ; Fri, 17 Nov 2017 06:27:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 355F42A990; Fri, 17 Nov 2017 06:27:34 +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 933A32A539 for ; Fri, 17 Nov 2017 06:27:33 +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 1eFa5t-0001Qt-2i; Fri, 17 Nov 2017 06:25:41 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eFa5r-0001Oy-SB for xen-devel@lists.xen.org; Fri, 17 Nov 2017 06:25:39 +0000 Received: from [85.158.139.211] by server-3.bemta-5.messagelabs.com id D9/2D-02027-3E08E0A5; Fri, 17 Nov 2017 06:25:39 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrHLMWRWlGSWpSXmKPExsXS1tYhofuogS/ KYMYxRYslHxezODB6HN39mymAMYo1My8pvyKBNWPdxlNMBYc8KxoP7GNqYNxv1sXIxSEkMJ1R YsLGqYxdjJwcEgK8EkeWzWCFsAMkPn+6zdbFyAFUVCXR9UsCJMwmoCxx8WsvG4gtIiAtce3zZ UaQOcwCU1kkLj+5xw5SLywQJnH3dBRIDYuAqkRf20kWkDCvgLPE/W/uENMVJKY8fM8MYnMChf e/OcgEYgsJOEkcXDeNaQIj7wJGhlWMGsWpRWWpRbqGpnpJRZnpGSW5iZk5uoYGpnq5qcXFiem pOYlJxXrJ+bmbGIGhwAAEOxgbtnseYpTkYFIS5eUx54sS4kvKT6nMSCzOiC8qzUktPsQow8Gh JMF7rB4oJ1iUmp5akZaZAwxKmLQEB4+SCG8iMDCFeIsLEnOLM9MhUqcYjTmezXzdwMwx7WprE 7MQS15+XqqUOO99kEkCIKUZpXlwg2DRcolRVkqYlxHoNCGegtSi3MwSVPlXjOIcjErCvJUgU3 gy80rg9r0COoUJ6BSbG9wgp5QkIqSkGhh5tNdFbrqtarZuo+7xxWGiDG/ZlfMFzxwpFbWfnZx +a3LBu/S+6XsP7dQ0t115b3nB8UwL1cpJkRvefFtk5OL6fn22G4vBWvbMvgZxBt+d8goWLhFL o/+EOsss2iJ2pNPhXNqP/Y9ma6zRmKhXPu+Q9okrx7Njas69TrbizTrblDddOfa5EosSS3FGo qEWc1FxIgB2kAt0kQIAAA== X-Env-Sender: chao.gao@intel.com X-Msg-Ref: server-11.tower-206.messagelabs.com!1510899922!87798367!6 X-Originating-IP: [134.134.136.24] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTM0LjEzNC4xMzYuMjQgPT4gMzkwOTcx\n X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 53117 invoked from network); 17 Nov 2017 06:25:37 -0000 Received: from mga09.intel.com (HELO mga09.intel.com) (134.134.136.24) by server-11.tower-206.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 17 Nov 2017 06:25:37 -0000 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Nov 2017 22:25:37 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.44,407,1505804400"; d="scan'208"; a="1245165317" Received: from skl-4s-chao.sh.intel.com ([10.239.48.9]) by fmsmga002.fm.intel.com with ESMTP; 16 Nov 2017 22:25:35 -0800 From: Chao Gao To: xen-devel@lists.xen.org Date: Fri, 17 Nov 2017 14:22:27 +0800 Message-Id: <1510899755-40237-21-git-send-email-chao.gao@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1510899755-40237-1-git-send-email-chao.gao@intel.com> References: <1510899755-40237-1-git-send-email-chao.gao@intel.com> Cc: Lan Tianyu , Kevin Tian , Stefano Stabellini , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Tim Deegan , Jan Beulich , Chao Gao , Ian Jackson , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [Xen-devel] [PATCH v4 20/28] xen/pt: when binding guest msi, accept the whole msi message 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 ... rather than a filtered one. Previously, some fields (reserved or unalterable) are filtered by QEMU. These fields are useless for the legacy interrupt format (i.e. non remappable format). However, these fields are meaningful to remappable format. Accepting the whole msi message will significantly reduce the efforts to support binding remappable format msi. Signed-off-by: Chao Gao Signed-off-by: Lan Tianyu --- v4: - new --- tools/libxc/include/xenctrl.h | 7 ++++--- tools/libxc/xc_domain.c | 14 ++++++++------ xen/arch/x86/hvm/vmsi.c | 12 ++++++------ xen/drivers/passthrough/io.c | 36 +++++++++++++++++------------------- xen/include/asm-x86/hvm/irq.h | 5 +++-- xen/include/public/domctl.h | 8 ++------ 6 files changed, 40 insertions(+), 42 deletions(-) diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h index 666db0b..8ade90c 100644 --- a/tools/libxc/include/xenctrl.h +++ b/tools/libxc/include/xenctrl.h @@ -1756,16 +1756,17 @@ int xc_domain_ioport_mapping(xc_interface *xch, int xc_domain_update_msi_irq( xc_interface *xch, uint32_t domid, - uint32_t gvec, uint32_t pirq, + uint64_t addr, + uint32_t data, uint32_t gflags, uint64_t gtable); int xc_domain_unbind_msi_irq(xc_interface *xch, uint32_t domid, - uint32_t gvec, uint32_t pirq, - uint32_t gflags); + uint64_t addr, + uint32_t data); int xc_domain_bind_pt_irq(xc_interface *xch, uint32_t domid, diff --git a/tools/libxc/xc_domain.c b/tools/libxc/xc_domain.c index 3ccd27f..f7baf11 100644 --- a/tools/libxc/xc_domain.c +++ b/tools/libxc/xc_domain.c @@ -1735,8 +1735,9 @@ int xc_deassign_dt_device( int xc_domain_update_msi_irq( xc_interface *xch, uint32_t domid, - uint32_t gvec, uint32_t pirq, + uint64_t addr, + uint32_t data, uint32_t gflags, uint64_t gtable) { @@ -1750,7 +1751,8 @@ int xc_domain_update_msi_irq( bind = &(domctl.u.bind_pt_irq); bind->irq_type = PT_IRQ_TYPE_MSI; bind->machine_irq = pirq; - bind->u.msi.gvec = gvec; + bind->u.msi.addr = addr; + bind->u.msi.data = data; bind->u.msi.gflags = gflags; bind->u.msi.gtable = gtable; @@ -1761,9 +1763,9 @@ int xc_domain_update_msi_irq( int xc_domain_unbind_msi_irq( xc_interface *xch, uint32_t domid, - uint32_t gvec, uint32_t pirq, - uint32_t gflags) + uint64_t addr, + uint32_t data) { int rc; struct xen_domctl_bind_pt_irq *bind; @@ -1775,8 +1777,8 @@ int xc_domain_unbind_msi_irq( bind = &(domctl.u.bind_pt_irq); bind->irq_type = PT_IRQ_TYPE_MSI; bind->machine_irq = pirq; - bind->u.msi.gvec = gvec; - bind->u.msi.gflags = gflags; + bind->u.msi.addr = addr; + bind->u.msi.data = data; rc = do_domctl(xch, &domctl); return rc; diff --git a/xen/arch/x86/hvm/vmsi.c b/xen/arch/x86/hvm/vmsi.c index 7126de7..5edb0e7 100644 --- a/xen/arch/x86/hvm/vmsi.c +++ b/xen/arch/x86/hvm/vmsi.c @@ -101,12 +101,12 @@ int vmsi_deliver( void vmsi_deliver_pirq(struct domain *d, const struct hvm_pirq_dpci *pirq_dpci) { - uint32_t flags = pirq_dpci->gmsi.gflags; - int vector = pirq_dpci->gmsi.gvec; - uint8_t dest = (uint8_t)flags; - bool dest_mode = flags & XEN_DOMCTL_VMSI_X86_DM_MASK; - uint8_t delivery_mode = MASK_EXTR(flags, XEN_DOMCTL_VMSI_X86_DELIV_MASK); - bool trig_mode = flags & XEN_DOMCTL_VMSI_X86_TRIG_MASK; + uint8_t vector = pirq_dpci->gmsi.data & MSI_DATA_VECTOR_MASK; + uint8_t dest = MASK_EXTR(pirq_dpci->gmsi.addr, MSI_ADDR_DEST_ID_MASK); + bool dest_mode = pirq_dpci->gmsi.addr & MSI_ADDR_DESTMODE_MASK; + uint8_t delivery_mode = MASK_EXTR(pirq_dpci->gmsi.data, + MSI_DATA_DELIVERY_MODE_MASK); + bool trig_mode = pirq_dpci->gmsi.data & MSI_DATA_TRIGGER_MASK; HVM_DBG_LOG(DBG_LEVEL_IOAPIC, "msi: dest=%x dest_mode=%x delivery_mode=%x " diff --git a/xen/drivers/passthrough/io.c b/xen/drivers/passthrough/io.c index 8f16e6c..d8c66bf 100644 --- a/xen/drivers/passthrough/io.c +++ b/xen/drivers/passthrough/io.c @@ -339,19 +339,17 @@ int pt_irq_create_bind( { case PT_IRQ_TYPE_MSI: { - uint8_t dest, delivery_mode; + uint8_t dest, delivery_mode, gvec; bool dest_mode; int dest_vcpu_id; const struct vcpu *vcpu; - uint32_t gflags = pt_irq_bind->u.msi.gflags & - ~XEN_DOMCTL_VMSI_X86_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 = gflags; + pirq_dpci->gmsi.data = pt_irq_bind->u.msi.data; + pirq_dpci->gmsi.addr = pt_irq_bind->u.msi.addr; /* * 'pt_irq_create_bind' can be called after 'pt_irq_destroy_bind'. * The 'pirq_cleanup_check' which would free the structure is only @@ -383,8 +381,8 @@ int pt_irq_create_bind( } if ( unlikely(rc) ) { - pirq_dpci->gmsi.gflags = 0; - pirq_dpci->gmsi.gvec = 0; + pirq_dpci->gmsi.addr = 0; + pirq_dpci->gmsi.data = 0; pirq_dpci->dom = NULL; pirq_dpci->flags = 0; pirq_cleanup_check(info, d); @@ -403,22 +401,23 @@ 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 != gflags ) + if ( pirq_dpci->gmsi.data != pt_irq_bind->u.msi.data || + pirq_dpci->gmsi.addr != pt_irq_bind->u.msi.addr ) { /* 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 = gflags; + pirq_dpci->gmsi.data = pt_irq_bind->u.msi.data; + pirq_dpci->gmsi.addr = pt_irq_bind->u.msi.addr; } } /* Calculate dest_vcpu_id for MSI-type pirq migration. */ - dest = MASK_EXTR(pirq_dpci->gmsi.gflags, - XEN_DOMCTL_VMSI_X86_DEST_ID_MASK); - dest_mode = pirq_dpci->gmsi.gflags & XEN_DOMCTL_VMSI_X86_DM_MASK; - delivery_mode = MASK_EXTR(pirq_dpci->gmsi.gflags, - XEN_DOMCTL_VMSI_X86_DELIV_MASK); + dest = MASK_EXTR(pirq_dpci->gmsi.addr, MSI_ADDR_DEST_ID_MASK); + dest_mode = pirq_dpci->gmsi.addr & MSI_ADDR_DESTMODE_MASK; + delivery_mode = MASK_EXTR(pirq_dpci->gmsi.data, + MSI_DATA_DELIVERY_MODE_MASK); + gvec = pirq_dpci->gmsi.data & MSI_DATA_VECTOR_MASK; + pirq_dpci->gmsi.gvec = gvec; dest_vcpu_id = hvm_girq_dest_2_vcpu_id(d, dest, dest_mode); pirq_dpci->gmsi.dest_vcpu_id = dest_vcpu_id; @@ -837,9 +836,8 @@ static int _hvm_dpci_msi_eoi(struct domain *d, if ( (pirq_dpci->flags & HVM_IRQ_DPCI_MACH_MSI) && (pirq_dpci->gmsi.gvec == vector) ) { - unsigned int dest = MASK_EXTR(pirq_dpci->gmsi.gflags, - XEN_DOMCTL_VMSI_X86_DEST_ID_MASK); - bool dest_mode = pirq_dpci->gmsi.gflags & XEN_DOMCTL_VMSI_X86_DM_MASK; + uint32_t dest = MASK_EXTR(pirq_dpci->gmsi.addr, MSI_ADDR_DEST_ID_MASK); + bool dest_mode = pirq_dpci->gmsi.addr & MSI_ADDR_DESTMODE_MASK; if ( vlapic_match_dest(vcpu_vlapic(current), NULL, 0, dest, dest_mode) ) diff --git a/xen/include/asm-x86/hvm/irq.h b/xen/include/asm-x86/hvm/irq.h index 3b6b4bd..3a8832c 100644 --- a/xen/include/asm-x86/hvm/irq.h +++ b/xen/include/asm-x86/hvm/irq.h @@ -132,9 +132,10 @@ struct dev_intx_gsi_link { #define HVM_IRQ_DPCI_TRANSLATE (1u << _HVM_IRQ_DPCI_TRANSLATE_SHIFT) struct hvm_gmsi_info { - uint32_t gvec; - uint32_t gflags; + uint32_t data; int dest_vcpu_id; /* -1 :multi-dest, non-negative: dest_vcpu_id */ + uint64_t addr; + uint8_t gvec; bool posted; /* directly deliver to guest via VT-d PI? */ }; diff --git a/xen/include/public/domctl.h b/xen/include/public/domctl.h index 9f6f0aa..2717c68 100644 --- a/xen/include/public/domctl.h +++ b/xen/include/public/domctl.h @@ -536,15 +536,11 @@ struct xen_domctl_bind_pt_irq { uint8_t intx; } pci; struct { - uint8_t gvec; uint32_t gflags; -#define XEN_DOMCTL_VMSI_X86_DEST_ID_MASK 0x0000ff -#define XEN_DOMCTL_VMSI_X86_RH_MASK 0x000100 -#define XEN_DOMCTL_VMSI_X86_DM_MASK 0x000200 -#define XEN_DOMCTL_VMSI_X86_DELIV_MASK 0x007000 -#define XEN_DOMCTL_VMSI_X86_TRIG_MASK 0x008000 #define XEN_DOMCTL_VMSI_X86_UNMASKED 0x010000 + uint32_t data; + uint64_t addr; uint64_aligned_t gtable; } msi; struct {