From patchwork Thu Jun 29 05:50:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "lan,Tianyu" X-Patchwork-Id: 9816525 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 03D97603F2 for ; Thu, 29 Jun 2017 11:59:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B8F2A285FF for ; Thu, 29 Jun 2017 11:59:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AE04C28623; Thu, 29 Jun 2017 11:59:57 +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=-2.2 required=2.0 tests=BAYES_00, DATE_IN_PAST_06_12, RCVD_IN_DNSWL_MED,RCVD_IN_SORBS_SPAM 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 59231285FF for ; Thu, 29 Jun 2017 11:59:57 +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 1dQY5c-0006ei-87; Thu, 29 Jun 2017 11:58:28 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dQY5a-0006ce-U4 for xen-devel@lists.xen.org; Thu, 29 Jun 2017 11:58:27 +0000 Received: from [85.158.137.68] by server-17.bemta-3.messagelabs.com id 9F/60-01859-26BE4595; Thu, 29 Jun 2017 11:58:26 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrHLMWRWlGSWpSXmKPExsVywNykWDfxdUi kwaNz2hZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8bdub8ZCxaKVOy82c/ewHhRoIuRi0NIYBqj xOE5u5i7GDk5JAR4JY4sm8EKYftLbG2+zQZiCwm0M0rsmeUIYrMJqEucWDyREcQWEZCWuPb5M pjNLLCPUeLNc1UQW1jAQ2Jx/zsWEJtFQFWie+dSJhCbV8BV4u2Fk2wQ8xUkpjx8D7aXEyjecH ML1C4XiU89O5knMPIuYGRYxahRnFpUllqka2ikl1SUmZ5RkpuYmaNraGCsl5taXJyYnpqTmFS sl5yfu4kRGA4MQLCD8VW38yFGSQ4mJVFew+chkUJ8SfkplRmJxRnxRaU5qcWHGGU4OJQkeE+/ BMoJFqWmp1akZeYAAxMmLcHBoyTC2wfSyltckJhbnJkOkTrFqCglzsv1CighAJLIKM2Da4NFw yVGWSlhXkagQ4R4ClKLcjNLUOVfMYpzMCoJ8z4F2c6TmVcCN/0V0GImoMXCM8AWlyQipKQaGG 0rfBQmmr+/M/Hv20uzdWZw5bovXG0r7+P9rHvuywT7DYqud1e991x54kt4cWqQgdjGy61aO4J 5Wl7vDuJ5E1nhcGBP9mnubxYuYSIPXUvtV5Tu7tTas61K+fbTXVPO3P77YPpjh0db+8K4n0bc 6vlxkqd65tKUxXmT7HhPFT6bYr7nw0PrmbxKLMUZiYZazEXFiQC92UXhgQIAAA== X-Env-Sender: tianyu.lan@intel.com X-Msg-Ref: server-6.tower-31.messagelabs.com!1498737503!64604194!1 X-Originating-IP: [192.55.52.115] X-SpamReason: No, hits=0.8 required=7.0 tests=DATE_IN_PAST_06_12 X-StarScan-Received: X-StarScan-Version: 9.4.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 25319 invoked from network); 29 Jun 2017 11:58:25 -0000 Received: from mga14.intel.com (HELO mga14.intel.com) (192.55.52.115) by server-6.tower-31.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 29 Jun 2017 11:58:25 -0000 Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Jun 2017 04:58:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.40,280,1496127600"; d="scan'208";a="102716485" Received: from sky-ws.sh.intel.com (HELO localhost) ([10.239.48.74]) by orsmga004.jf.intel.com with ESMTP; 29 Jun 2017 04:58:21 -0700 From: Lan Tianyu To: xen-devel@lists.xen.org Date: Thu, 29 Jun 2017 01:50:49 -0400 Message-Id: <1498715457-16565-18-git-send-email-tianyu.lan@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1498715457-16565-1-git-send-email-tianyu.lan@intel.com> References: <1498715457-16565-1-git-send-email-tianyu.lan@intel.com> Cc: Lan Tianyu , kevin.tian@intel.com, wei.liu2@citrix.com, andrew.cooper3@citrix.com, ian.jackson@eu.citrix.com, jbeulich@suse.com, Chao Gao Subject: [Xen-devel] [PATCH 17/25] X86/vvtd: Enable Queued Invalidation through GCMD 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 From: Chao Gao Software writes to QIE fields of GCMD to enable or disable queued invalidations. This patch emulates QIE fields of GCMD. Signed-off-by: Chao Gao Signed-off-by: Lan Tianyu --- xen/drivers/passthrough/vtd/iommu.h | 3 ++- xen/drivers/passthrough/vtd/vvtd.c | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/xen/drivers/passthrough/vtd/iommu.h b/xen/drivers/passthrough/vtd/iommu.h index 70e64cf..82bf6bc 100644 --- a/xen/drivers/passthrough/vtd/iommu.h +++ b/xen/drivers/passthrough/vtd/iommu.h @@ -190,7 +190,8 @@ #define DMA_GSTS_FLS (((u64)1) << 29) #define DMA_GSTS_AFLS (((u64)1) << 28) #define DMA_GSTS_WBFS (((u64)1) << 27) -#define DMA_GSTS_QIES (((u64)1) <<26) +#define DMA_GSTS_QIES_BIT 26 +#define DMA_GSTS_QIES (((u64)1) << DMA_GSTS_QIES_BIT) #define DMA_GSTS_IRES (((u64)1) <<25) #define DMA_GSTS_SIRTPS_BIT 24 #define DMA_GSTS_SIRTPS (((u64)1) << DMA_GSTS_SIRTPS_BIT) diff --git a/xen/drivers/passthrough/vtd/vvtd.c b/xen/drivers/passthrough/vtd/vvtd.c index c6d7014..0954aa2 100644 --- a/xen/drivers/passthrough/vtd/vvtd.c +++ b/xen/drivers/passthrough/vtd/vvtd.c @@ -102,6 +102,11 @@ static inline void __vvtd_set_bit(struct vvtd *vvtd, uint32_t reg, int nr) return __set_bit(nr, (uint32_t *)&vvtd->regs->data[reg]); } +static inline void __vvtd_clear_bit(struct vvtd *vvtd, uint32_t reg, int nr) +{ + return __clear_bit(nr, (uint32_t *)&vvtd->regs->data[reg]); +} + static inline void vvtd_set_reg(struct vvtd *vtd, uint32_t reg, uint32_t value) { @@ -262,6 +267,21 @@ static int vvtd_record_fault(struct vvtd *vvtd, return 0; } +static int vvtd_handle_gcmd_qie(struct vvtd *vvtd, uint32_t val) +{ + VVTD_DEBUG(VVTD_DBG_RW, "%sable Queue Invalidation.", + (val & DMA_GCMD_QIE) ? "En" : "Dis"); + + if ( val & DMA_GCMD_QIE ) + __vvtd_set_bit(vvtd, DMAR_GSTS_REG, DMA_GSTS_QIES_BIT); + else + { + vvtd_set_reg_quad(vvtd, DMAR_IQH_REG, 0ULL); + __vvtd_clear_bit(vvtd, DMAR_GSTS_REG, DMA_GSTS_QIES_BIT); + } + return X86EMUL_OKAY; +} + static int vvtd_handle_gcmd_sirtp(struct vvtd *vvtd, uint32_t val) { uint64_t irta; @@ -296,6 +316,8 @@ static int vvtd_write_gcmd(struct vvtd *vvtd, uint32_t val) if ( changed & DMA_GCMD_SIRTP ) vvtd_handle_gcmd_sirtp(vvtd, val); + if ( changed & DMA_GCMD_QIE ) + vvtd_handle_gcmd_qie(vvtd, val); return X86EMUL_OKAY; }