blob: 21b3e7d33d6809ee1f888ac8aef38203fe27a1c4 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Suresh Siddhae61d98d2008-07-10 11:16:35 -07002#ifndef _DMA_REMAPPING_H
3#define _DMA_REMAPPING_H
4
5/*
Fenghua Yu5b6985c2008-10-16 18:02:32 -07006 * VT-d hardware uses 4KiB page size regardless of host page size.
Suresh Siddhae61d98d2008-07-10 11:16:35 -07007 */
Fenghua Yu5b6985c2008-10-16 18:02:32 -07008#define VTD_PAGE_SHIFT (12)
9#define VTD_PAGE_SIZE (1UL << VTD_PAGE_SHIFT)
10#define VTD_PAGE_MASK (((u64)-1) << VTD_PAGE_SHIFT)
11#define VTD_PAGE_ALIGN(addr) (((addr) + VTD_PAGE_SIZE - 1) & VTD_PAGE_MASK)
Suresh Siddhae61d98d2008-07-10 11:16:35 -070012
Youquan Song6dd9a7c2011-05-25 19:13:49 +010013#define VTD_STRIDE_SHIFT (9)
14#define VTD_STRIDE_MASK (((u64)-1) << VTD_STRIDE_SHIFT)
15
Suresh Siddhae61d98d2008-07-10 11:16:35 -070016#define DMA_PTE_READ (1)
17#define DMA_PTE_WRITE (2)
Youquan Song6dd9a7c2011-05-25 19:13:49 +010018#define DMA_PTE_LARGE_PAGE (1 << 7)
Sheng Yang9cf06692009-03-18 15:33:07 +080019#define DMA_PTE_SNP (1 << 11)
Suresh Siddhae61d98d2008-07-10 11:16:35 -070020
Fenghua Yu4ed0d3e2009-04-24 17:30:20 -070021#define CONTEXT_TT_MULTI_LEVEL 0
Yu Zhao93a23a72009-05-18 13:51:37 +080022#define CONTEXT_TT_DEV_IOTLB 1
Fenghua Yu4ed0d3e2009-04-24 17:30:20 -070023#define CONTEXT_TT_PASS_THROUGH 2
David Woodhouse2f26e0a2015-09-09 11:40:47 +010024/* Extended context entry types */
25#define CONTEXT_TT_PT_PASID 4
26#define CONTEXT_TT_PT_PASID_DEV_IOTLB 5
27#define CONTEXT_TT_MASK (7ULL << 2)
28
David Woodhouse907fea32015-10-13 14:11:13 +010029#define CONTEXT_DINVE (1ULL << 8)
David Woodhouse2f26e0a2015-09-09 11:40:47 +010030#define CONTEXT_PRS (1ULL << 9)
31#define CONTEXT_PASIDE (1ULL << 11)
Fenghua Yu4ed0d3e2009-04-24 17:30:20 -070032
Suresh Siddhae61d98d2008-07-10 11:16:35 -070033struct intel_iommu;
Mark McLoughlin99126f72008-11-20 15:49:47 +000034struct dmar_domain;
35struct root_entry;
Suresh Siddhae61d98d2008-07-10 11:16:35 -070036
Ingo Molnarc66b9902009-01-04 10:55:02 +010037
Suresh Siddhad3f13812011-08-23 17:05:25 -070038#ifdef CONFIG_INTEL_IOMMU
Weidong Han1b573682008-12-08 15:34:06 +080039extern int iommu_calculate_agaw(struct intel_iommu *iommu);
Fenghua Yu4ed0d3e2009-04-24 17:30:20 -070040extern int iommu_calculate_max_sagaw(struct intel_iommu *iommu);
Suresh Siddhaf5d1b972011-08-23 17:05:22 -070041extern int dmar_disabled;
Eugeni Dodonov8bc1f852011-11-23 16:42:14 -020042extern int intel_iommu_enabled;
Shaohua Libfd20f12017-04-26 09:18:35 -070043extern int intel_iommu_tboot_noforce;
Ingo Molnarc66b9902009-01-04 10:55:02 +010044#else
45static inline int iommu_calculate_agaw(struct intel_iommu *iommu)
46{
47 return 0;
48}
Fenghua Yu4ed0d3e2009-04-24 17:30:20 -070049static inline int iommu_calculate_max_sagaw(struct intel_iommu *iommu)
50{
51 return 0;
52}
Suresh Siddhaf5d1b972011-08-23 17:05:22 -070053#define dmar_disabled (1)
Eugeni Dodonov8bc1f852011-11-23 16:42:14 -020054#define intel_iommu_enabled (0)
Ingo Molnarc66b9902009-01-04 10:55:02 +010055#endif
Suresh Siddhae61d98d2008-07-10 11:16:35 -070056
Suresh Siddha2ae21012008-07-10 11:16:43 -070057
Suresh Siddhae61d98d2008-07-10 11:16:35 -070058#endif