From: Chao Gao <chao.gao@intel.com>
To: xen-devel@lists.xen.org
Cc: "Lan Tianyu" <tianyu.lan@intel.com>,
"Kevin Tian" <kevin.tian@intel.com>,
"Stefano Stabellini" <sstabellini@kernel.org>,
"Wei Liu" <wei.liu2@citrix.com>,
"Konrad Rzeszutek Wilk" <konrad.wilk@oracle.com>,
"George Dunlap" <george.dunlap@eu.citrix.com>,
"Ian Jackson" <ian.jackson@eu.citrix.com>,
"Tim Deegan" <tim@xen.org>, "Jan Beulich" <jbeulich@suse.com>,
"Andrew Cooper" <andrew.cooper3@citrix.com>,
"Chao Gao" <chao.gao@intel.com>,
"Roger Pau Monné" <roger.pau@citrix.com>
Subject: [PATCH v4 06/28] vtd: clean-up and preparation for vvtd
Date: Fri, 17 Nov 2017 14:22:13 +0800 [thread overview]
Message-ID: <1510899755-40237-7-git-send-email-chao.gao@intel.com> (raw)
In-Reply-To: <1510899755-40237-1-git-send-email-chao.gao@intel.com>
This patch contains following changes:
- align register definitions
- use MASK_EXTR to define some macros about extended capabilies
rather than open-coding the masks
- define fields of FECTL and FESTS as uint32_t rather than u64 since
FECTL and FESTS are 32 bit registers.
No functional changes.
Signed-off-by: Chao Gao <chao.gao@intel.com>
Signed-off-by: Lan Tianyu <tianyu.lan@intel.com>
---
v4:
- Only fix the alignment and defer introducing new definition to when
they are needed
(Suggested-by Roger Pau Monné)
- remove parts of open-coded masks
v3:
- new
---
xen/drivers/passthrough/vtd/iommu.h | 86 +++++++++++++++++++++----------------
1 file changed, 48 insertions(+), 38 deletions(-)
diff --git a/xen/drivers/passthrough/vtd/iommu.h b/xen/drivers/passthrough/vtd/iommu.h
index 72c1a2e..db80b31 100644
--- a/xen/drivers/passthrough/vtd/iommu.h
+++ b/xen/drivers/passthrough/vtd/iommu.h
@@ -26,28 +26,28 @@
* Intel IOMMU register specification per version 1.0 public spec.
*/
-#define DMAR_VER_REG 0x0 /* Arch version supported by this IOMMU */
-#define DMAR_CAP_REG 0x8 /* Hardware supported capabilities */
-#define DMAR_ECAP_REG 0x10 /* Extended capabilities supported */
-#define DMAR_GCMD_REG 0x18 /* Global command register */
-#define DMAR_GSTS_REG 0x1c /* Global status register */
-#define DMAR_RTADDR_REG 0x20 /* Root entry table */
-#define DMAR_CCMD_REG 0x28 /* Context command reg */
-#define DMAR_FSTS_REG 0x34 /* Fault Status register */
-#define DMAR_FECTL_REG 0x38 /* Fault control register */
-#define DMAR_FEDATA_REG 0x3c /* Fault event interrupt data register */
-#define DMAR_FEADDR_REG 0x40 /* Fault event interrupt addr register */
-#define DMAR_FEUADDR_REG 0x44 /* Upper address register */
-#define DMAR_AFLOG_REG 0x58 /* Advanced Fault control */
-#define DMAR_PMEN_REG 0x64 /* Enable Protected Memory Region */
-#define DMAR_PLMBASE_REG 0x68 /* PMRR Low addr */
-#define DMAR_PLMLIMIT_REG 0x6c /* PMRR low limit */
-#define DMAR_PHMBASE_REG 0x70 /* pmrr high base addr */
-#define DMAR_PHMLIMIT_REG 0x78 /* pmrr high limit */
-#define DMAR_IQH_REG 0x80 /* invalidation queue head */
-#define DMAR_IQT_REG 0x88 /* invalidation queue tail */
-#define DMAR_IQA_REG 0x90 /* invalidation queue addr */
-#define DMAR_IRTA_REG 0xB8 /* intr remap */
+#define DMAR_VER_REG 0x0 /* Arch version supported by this IOMMU */
+#define DMAR_CAP_REG 0x8 /* Hardware supported capabilities */
+#define DMAR_ECAP_REG 0x10 /* Extended capabilities supported */
+#define DMAR_GCMD_REG 0x18 /* Global command register */
+#define DMAR_GSTS_REG 0x1c /* Global status register */
+#define DMAR_RTADDR_REG 0x20 /* Root entry table */
+#define DMAR_CCMD_REG 0x28 /* Context command reg */
+#define DMAR_FSTS_REG 0x34 /* Fault Status register */
+#define DMAR_FECTL_REG 0x38 /* Fault control register */
+#define DMAR_FEDATA_REG 0x3c /* Fault event interrupt data register */
+#define DMAR_FEADDR_REG 0x40 /* Fault event interrupt addr register */
+#define DMAR_FEUADDR_REG 0x44 /* Upper address register */
+#define DMAR_AFLOG_REG 0x58 /* Advanced Fault control */
+#define DMAR_PMEN_REG 0x64 /* Enable Protected Memory Region */
+#define DMAR_PLMBASE_REG 0x68 /* PMRR Low addr */
+#define DMAR_PLMLIMIT_REG 0x6c /* PMRR low limit */
+#define DMAR_PHMBASE_REG 0x70 /* pmrr high base addr */
+#define DMAR_PHMLIMIT_REG 0x78 /* pmrr high limit */
+#define DMAR_IQH_REG 0x80 /* invalidation queue head */
+#define DMAR_IQT_REG 0x88 /* invalidation queue tail */
+#define DMAR_IQA_REG 0x90 /* invalidation queue addr */
+#define DMAR_IRTA_REG 0xb8 /* intr remap */
#define OFFSET_STRIDE (9)
#define dmar_readl(dmar, reg) readl((dmar) + (reg))
@@ -93,16 +93,26 @@
* Extended Capability Register
*/
+#define DMA_ECAP_SNP_CTL ((uint64_t)1 << 7)
+#define DMA_ECAP_PASS_THRU ((uint64_t)1 << 6)
+#define DMA_ECAP_CACHE_HINTS ((uint64_t)1 << 5)
+#define DMA_ECAP_EIM ((uint64_t)1 << 4)
+#define DMA_ECAP_INTR_REMAP ((uint64_t)1 << 3)
+#define DMA_ECAP_DEV_IOTLB ((uint64_t)1 << 2)
+#define DMA_ECAP_QUEUED_INVAL ((uint64_t)1 << 1)
+#define DMA_ECAP_COHERENT ((uint64_t)1 << 0)
+
+#define ecap_snp_ctl(e) MASK_EXTR(e, DMA_ECAP_SNP_CTL)
+#define ecap_pass_thru(e) MASK_EXTR(e, DMA_ECAP_PASS_THRU)
+#define ecap_cache_hints(e) MASK_EXTR(e, DMA_ECAP_CACHE_HINTS)
+#define ecap_eim(e) MASK_EXTR(e, DMA_ECAP_EIM)
+#define ecap_intr_remap(e) MASK_EXTR(e, DMA_ECAP_INTR_REMAP)
+#define ecap_dev_iotlb(e) MASK_EXTR(e, DMA_ECAP_DEV_IOTLB)
+#define ecap_queued_inval(e) MASK_EXTR(e, DMA_ECAP_QUEUED_INVAL)
+#define ecap_coherent(e) MASK_EXTR(e, DMA_ECAP_COHERENT)
+
#define ecap_niotlb_iunits(e) ((((e) >> 24) & 0xff) + 1)
#define ecap_iotlb_offset(e) ((((e) >> 8) & 0x3ff) * 16)
-#define ecap_coherent(e) ((e >> 0) & 0x1)
-#define ecap_queued_inval(e) ((e >> 1) & 0x1)
-#define ecap_dev_iotlb(e) ((e >> 2) & 0x1)
-#define ecap_intr_remap(e) ((e >> 3) & 0x1)
-#define ecap_eim(e) ((e >> 4) & 0x1)
-#define ecap_cache_hints(e) ((e >> 5) & 0x1)
-#define ecap_pass_thru(e) ((e >> 6) & 0x1)
-#define ecap_snp_ctl(e) ((e >> 7) & 0x1)
/* IOTLB_REG */
#define DMA_TLB_FLUSH_GRANU_OFFSET 60
@@ -164,16 +174,16 @@
#define DMA_CCMD_CAIG_MASK(x) (((u64)x) & ((u64) 0x3 << 59))
/* FECTL_REG */
-#define DMA_FECTL_IM (((u64)1) << 31)
+#define DMA_FECTL_IM ((uint32_t)1 << 31)
/* FSTS_REG */
-#define DMA_FSTS_PFO ((u64)1 << 0)
-#define DMA_FSTS_PPF ((u64)1 << 1)
-#define DMA_FSTS_AFO ((u64)1 << 2)
-#define DMA_FSTS_APF ((u64)1 << 3)
-#define DMA_FSTS_IQE ((u64)1 << 4)
-#define DMA_FSTS_ICE ((u64)1 << 5)
-#define DMA_FSTS_ITE ((u64)1 << 6)
+#define DMA_FSTS_PFO ((uint32_t)1 << 0)
+#define DMA_FSTS_PPF ((uint32_t)1 << 1)
+#define DMA_FSTS_AFO ((uint32_t)1 << 2)
+#define DMA_FSTS_APF ((uint32_t)1 << 3)
+#define DMA_FSTS_IQE ((uint32_t)1 << 4)
+#define DMA_FSTS_ICE ((uint32_t)1 << 5)
+#define DMA_FSTS_ITE ((uint32_t)1 << 6)
#define DMA_FSTS_FAULTS DMA_FSTS_PFO | DMA_FSTS_PPF | DMA_FSTS_AFO | DMA_FSTS_APF | DMA_FSTS_IQE | DMA_FSTS_ICE | DMA_FSTS_ITE
#define dma_fsts_fault_record_index(s) (((s) >> 8) & 0xff)
--
1.8.3.1
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2017-11-17 6:22 UTC|newest]
Thread overview: 83+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-17 6:22 [PATCH v4 00/28] add vIOMMU support with irq remapping function of virtual VT-d Chao Gao
2017-11-17 6:22 ` [PATCH v4 01/28] Xen/doc: Add Xen virtual IOMMU doc Chao Gao
2018-02-09 12:54 ` Roger Pau Monné
2018-02-09 15:53 ` Chao Gao
2017-11-17 6:22 ` [PATCH v4 02/28] VIOMMU: Add vIOMMU framework and vIOMMU domctl Chao Gao
2018-02-09 14:33 ` Roger Pau Monné
2018-02-09 16:13 ` Chao Gao
2017-11-17 6:22 ` [PATCH v4 03/28] VIOMMU: Add irq request callback to deal with irq remapping Chao Gao
2018-02-09 15:02 ` Roger Pau Monné
2018-02-09 16:21 ` Chao Gao
2017-11-17 6:22 ` [PATCH v4 04/28] VIOMMU: Add get irq info callback to convert irq remapping request Chao Gao
2018-02-09 15:06 ` Roger Pau Monné
2018-02-09 16:34 ` Chao Gao
2017-11-17 6:22 ` [PATCH v4 05/28] VIOMMU: Introduce callback of checking irq remapping mode Chao Gao
2018-02-09 15:11 ` Roger Pau Monné
2018-02-09 16:47 ` Chao Gao
2018-02-12 10:21 ` Roger Pau Monné
2017-11-17 6:22 ` Chao Gao [this message]
2018-02-09 15:17 ` [PATCH v4 06/28] vtd: clean-up and preparation for vvtd Roger Pau Monné
2018-02-09 16:51 ` Chao Gao
2017-11-17 6:22 ` [PATCH v4 07/28] x86/hvm: Introduce a emulated VTD for HVM Chao Gao
2018-02-09 16:27 ` Roger Pau Monné
2018-02-09 17:12 ` Chao Gao
2018-02-12 10:35 ` Roger Pau Monné
2017-11-17 6:22 ` [PATCH v4 08/28] x86/vvtd: Add MMIO handler for VVTD Chao Gao
2018-02-09 16:39 ` Roger Pau Monné
2018-02-09 17:21 ` Chao Gao
2018-02-09 17:51 ` Roger Pau Monné
2018-02-22 6:20 ` Chao Gao
2018-02-23 17:07 ` Roger Pau Monné
2018-02-23 17:37 ` Wei Liu
2017-11-17 6:22 ` [PATCH v4 09/28] x86/vvtd: Set Interrupt Remapping Table Pointer through GCMD Chao Gao
2018-02-09 16:59 ` Roger Pau Monné
2018-02-11 4:34 ` Chao Gao
2018-02-11 5:09 ` Chao Gao
2018-02-12 11:25 ` Roger Pau Monné
2017-11-17 6:22 ` [PATCH v4 10/28] x86/vvtd: Enable Interrupt Remapping " Chao Gao
2018-02-09 17:15 ` Roger Pau Monné
2018-02-11 5:05 ` Chao Gao
2018-02-12 11:30 ` Roger Pau Monné
2018-02-22 6:25 ` Chao Gao
2017-11-17 6:22 ` [PATCH v4 11/28] x86/vvtd: Process interrupt remapping request Chao Gao
2018-02-09 17:44 ` Roger Pau Monné
2018-02-11 5:31 ` Chao Gao
2018-02-23 17:04 ` Roger Pau Monné
2017-11-17 6:22 ` [PATCH v4 12/28] x86/vvtd: decode interrupt attribute from IRTE Chao Gao
2018-02-12 11:55 ` Roger Pau Monné
2018-02-22 6:33 ` Chao Gao
2017-11-17 6:22 ` [PATCH v4 13/28] x86/vvtd: add a helper function to decide the interrupt format Chao Gao
2018-02-12 12:14 ` Roger Pau Monné
2017-11-17 6:22 ` [PATCH v4 14/28] x86/vvtd: Handle interrupt translation faults Chao Gao
2018-02-12 12:55 ` Roger Pau Monné
2018-02-22 8:23 ` Chao Gao
2017-11-17 6:22 ` [PATCH v4 15/28] x86/vvtd: Enable Queued Invalidation through GCMD Chao Gao
2018-02-12 14:04 ` Roger Pau Monné
2018-02-22 10:33 ` Chao Gao
2017-11-17 6:22 ` [PATCH v4 16/28] x86/vvtd: Add queued invalidation (QI) support Chao Gao
2018-02-12 14:36 ` Roger Pau Monné
2018-02-23 4:38 ` Chao Gao
2017-11-17 6:22 ` [PATCH v4 17/28] x86/vvtd: save and restore emulated VT-d Chao Gao
2018-02-12 14:49 ` Roger Pau Monné
2018-02-23 5:22 ` Chao Gao
2018-02-23 17:19 ` Roger Pau Monné
2017-11-17 6:22 ` [PATCH v4 18/28] x86/vioapic: Hook interrupt delivery of vIOAPIC Chao Gao
2018-02-12 14:54 ` Roger Pau Monné
2018-02-24 1:51 ` Chao Gao
2018-02-24 3:17 ` Tian, Kevin
2017-11-17 6:22 ` [PATCH v4 19/28] x86/vioapic: extend vioapic_get_vector() to support remapping format RTE Chao Gao
2018-02-12 15:01 ` Roger Pau Monné
2017-11-17 6:22 ` [PATCH v4 20/28] xen/pt: when binding guest msi, accept the whole msi message Chao Gao
2018-02-12 15:16 ` Roger Pau Monné
2018-02-24 2:20 ` Chao Gao
2017-11-17 6:22 ` [PATCH v4 21/28] vvtd: update hvm_gmsi_info when binding guest msi with pirq or Chao Gao
2018-02-12 15:38 ` Roger Pau Monné
2018-02-24 5:05 ` Chao Gao
2017-11-17 6:22 ` [PATCH v4 22/28] x86/vmsi: Hook delivering remapping format msi to guest and handling eoi Chao Gao
2017-11-17 6:22 ` [PATCH v4 23/28] tools/libacpi: Add DMA remapping reporting (DMAR) ACPI table structures Chao Gao
2017-11-17 6:22 ` [PATCH v4 24/28] tools/libacpi: Add new fields in acpi_config for DMAR table Chao Gao
2017-11-17 6:22 ` [PATCH v4 25/28] tools/libxl: Add an user configurable parameter to control vIOMMU attributes Chao Gao
2017-11-17 6:22 ` [PATCH v4 26/28] tools/libxl: build DMAR table for a guest with one virtual VTD Chao Gao
2017-11-17 6:22 ` [PATCH v4 27/28] tools/libxl: create vIOMMU during domain construction Chao Gao
2017-11-17 6:22 ` [PATCH v4 28/28] tools/libxc: Add viommu operations in libxc Chao Gao
2018-10-04 15:51 ` [PATCH v4 00/28] add vIOMMU support with irq remapping function of virtual VT-d Jan Beulich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1510899755-40237-7-git-send-email-chao.gao@intel.com \
--to=chao.gao@intel.com \
--cc=andrew.cooper3@citrix.com \
--cc=george.dunlap@eu.citrix.com \
--cc=ian.jackson@eu.citrix.com \
--cc=jbeulich@suse.com \
--cc=kevin.tian@intel.com \
--cc=konrad.wilk@oracle.com \
--cc=roger.pau@citrix.com \
--cc=sstabellini@kernel.org \
--cc=tianyu.lan@intel.com \
--cc=tim@xen.org \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).