From patchwork Fri Nov 17 06:22:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chao Gao X-Patchwork-Id: 10062313 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 551CB6023A for ; Fri, 17 Nov 2017 06:27:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 481402A539 for ; Fri, 17 Nov 2017 06:27:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3CCCE2A99E; Fri, 17 Nov 2017 06:27:14 +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 E342E2A539 for ; Fri, 17 Nov 2017 06:27:13 +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 1eFa5e-00015o-K1; Fri, 17 Nov 2017 06:25:26 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eFa5d-000147-GV for xen-devel@lists.xen.org; Fri, 17 Nov 2017 06:25:25 +0000 Received: from [85.158.139.211] by server-6.bemta-5.messagelabs.com id E5/F6-32721-4D08E0A5; Fri, 17 Nov 2017 06:25:24 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpkkeJIrShJLcpLzFFi42Jpa+uQ0L3SwBd l0LdIxGLJx8UsDoweR3f/ZgpgjGLNzEvKr0hgzTg2ez5jwQPBiln7H7A3MD7n62Lk4hASmM4o cevSO7YuRk4OCQFeiSPLZrBC2AESE48cYwSxhQSqJA5+WQVmswkoS1z82gtWLyIgLXHt82VGk EHMAs+ZJZas+wtWJCzgLfH+8T+wQSwCqhK3Hy5kArF5BZwl2q+9YYRYoCAx5eF7ZhCbEyi+/8 1BJohlThIH101jmsDIu4CRYRWjRnFqUVlqka6hqV5SUWZ6RkluYmaOrqGBqV5uanFxYnpqTmJ SsV5yfu4mRmBAMADBDsaG7Z6HGCU5mJREeXnM+aKE+JLyUyozEosz4otKc1KLDzHKcHAoSfAe qwfKCRalpqdWpGXmAEMTJi3BwaMkwpsIDE8h3uKCxNzizHSI1ClGY45nM183MHNMu9raxCzEk peflyolznsfZJIASGlGaR7cIFjMXGKUlRLmZQQ6TYinILUoN7MEVf4VozgHo5IwbyXIFJ7MvB K4fa+ATmECOsXmBjfIKSWJCCmpBsYU70vBIYmhqwWEPzvYlU46l3q/k3PWuf2LIrb/+MVyjVV y2i3pA2qGD7f9jrsnsXpvUKCLQZK7wsSVG0p1b0fbnvCdmrmee8GZw8ExL0ys9TXsZiUeW7nt lIsQx7Tlk2I/xqQtSY1e8OSGOcP+t4+4VsyZvEkukCvOoDJKrfnC3mJZs28cex4psRRnJBpqM RcVJwIA5MF2fJQCAAA= X-Env-Sender: chao.gao@intel.com X-Msg-Ref: server-11.tower-206.messagelabs.com!1510899922!87798367!1 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 51830 invoked from network); 17 Nov 2017 06:25:24 -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:24 -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:22 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.44,407,1505804400"; d="scan'208"; a="1245165205" Received: from skl-4s-chao.sh.intel.com ([10.239.48.9]) by fmsmga002.fm.intel.com with ESMTP; 16 Nov 2017 22:25:15 -0800 From: Chao Gao To: xen-devel@lists.xen.org Date: Fri, 17 Nov 2017 14:22:22 +0800 Message-Id: <1510899755-40237-16-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 , Ian Jackson , Tim Deegan , Jan Beulich , Andrew Cooper , Chao Gao , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [Xen-devel] [PATCH v4 15/28] 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 Software writes to QIE field of GCMD to enable or disable queued invalidations. This patch emulates QIE field 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 | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/xen/drivers/passthrough/vtd/iommu.h b/xen/drivers/passthrough/vtd/iommu.h index dc2df75..b71dab8 100644 --- a/xen/drivers/passthrough/vtd/iommu.h +++ b/xen/drivers/passthrough/vtd/iommu.h @@ -160,7 +160,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_SHIFT 26 +#define DMA_GSTS_QIES (((u64)1) << DMA_GSTS_QIES_SHIFT) #define DMA_GSTS_IRES_SHIFT 25 #define DMA_GSTS_IRES (((u64)1) << DMA_GSTS_IRES_SHIFT) #define DMA_GSTS_SIRTPS_SHIFT 24 diff --git a/xen/drivers/passthrough/vtd/vvtd.c b/xen/drivers/passthrough/vtd/vvtd.c index 83805d1..a2fa64a 100644 --- a/xen/drivers/passthrough/vtd/vvtd.c +++ b/xen/drivers/passthrough/vtd/vvtd.c @@ -539,6 +539,20 @@ static void write_gcmd_ire(struct vvtd *vvtd, uint32_t val) (vvtd, DMAR_GSTS_REG, DMA_GSTS_IRES_SHIFT); } +static void write_gcmd_qie(struct vvtd *vvtd, uint32_t val) +{ + bool set = val & DMA_GCMD_QIE; + + vvtd_info("%sable Queue Invalidation\n", set ? "En" : "Dis"); + + if ( set ) + vvtd_set_reg_quad(vvtd, DMAR_IQH_REG, 0); + + (set ? vvtd_set_bit : vvtd_clear_bit) + (vvtd, DMAR_GSTS_REG, DMA_GSTS_QIES_SHIFT); + +} + static void write_gcmd_sirtp(struct vvtd *vvtd, uint32_t val) { uint64_t irta = vvtd_get_reg_quad(vvtd, DMAR_IRTA_REG); @@ -598,6 +612,10 @@ static void vvtd_write_gcmd(struct vvtd *vvtd, uint32_t val) write_gcmd_sirtp(vvtd, val); if ( changed & DMA_GCMD_IRE ) write_gcmd_ire(vvtd, val); + if ( changed & DMA_GCMD_QIE ) + write_gcmd_qie(vvtd, val); + if ( changed & ~(DMA_GCMD_SIRTP | DMA_GCMD_IRE | DMA_GCMD_QIE) ) + vvtd_info("Only SIRTP, IRE, QIE in GCMD are handled"); } static int vvtd_in_range(struct vcpu *v, unsigned long addr)