aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/pci/intel-iommu.c38
-rw-r--r--include/linux/dma_remapping.h38
2 files changed, 38 insertions, 38 deletions
diff --git a/drivers/pci/intel-iommu.c b/drivers/pci/intel-iommu.c
index 29bf2d8176e2..9d06f4bb6b5e 100644
--- a/drivers/pci/intel-iommu.c
+++ b/drivers/pci/intel-iommu.c
@@ -90,6 +90,44 @@ get_context_addr_from_root(struct root_entry *root)
90 NULL); 90 NULL);
91} 91}
92 92
93/*
94 * low 64 bits:
95 * 0: present
96 * 1: fault processing disable
97 * 2-3: translation type
98 * 12-63: address space root
99 * high 64 bits:
100 * 0-2: address width
101 * 3-6: aval
102 * 8-23: domain id
103 */
104struct context_entry {
105 u64 lo;
106 u64 hi;
107};
108#define context_present(c) ((c).lo & 1)
109#define context_fault_disable(c) (((c).lo >> 1) & 1)
110#define context_translation_type(c) (((c).lo >> 2) & 3)
111#define context_address_root(c) ((c).lo & VTD_PAGE_MASK)
112#define context_address_width(c) ((c).hi & 7)
113#define context_domain_id(c) (((c).hi >> 8) & ((1 << 16) - 1))
114
115#define context_set_present(c) do {(c).lo |= 1;} while (0)
116#define context_set_fault_enable(c) \
117 do {(c).lo &= (((u64)-1) << 2) | 1;} while (0)
118#define context_set_translation_type(c, val) \
119 do { \
120 (c).lo &= (((u64)-1) << 4) | 3; \
121 (c).lo |= ((val) & 3) << 2; \
122 } while (0)
123#define CONTEXT_TT_MULTI_LEVEL 0
124#define context_set_address_root(c, val) \
125 do {(c).lo |= (val) & VTD_PAGE_MASK; } while (0)
126#define context_set_address_width(c, val) do {(c).hi |= (val) & 7;} while (0)
127#define context_set_domain_id(c, val) \
128 do {(c).hi |= ((val) & ((1 << 16) - 1)) << 8;} while (0)
129#define context_clear_entry(c) do {(c).lo = 0; (c).hi = 0;} while (0)
130
93static void flush_unmaps_timeout(unsigned long data); 131static void flush_unmaps_timeout(unsigned long data);
94 132
95DEFINE_TIMER(unmap_timer, flush_unmaps_timeout, 0, 0); 133DEFINE_TIMER(unmap_timer, flush_unmaps_timeout, 0, 0);
diff --git a/include/linux/dma_remapping.h b/include/linux/dma_remapping.h
index d8521662a495..9a88f7d0262f 100644
--- a/include/linux/dma_remapping.h
+++ b/include/linux/dma_remapping.h
@@ -12,44 +12,6 @@
12struct root_entry; 12struct root_entry;
13 13
14/* 14/*
15 * low 64 bits:
16 * 0: present
17 * 1: fault processing disable
18 * 2-3: translation type
19 * 12-63: address space root
20 * high 64 bits:
21 * 0-2: address width
22 * 3-6: aval
23 * 8-23: domain id
24 */
25struct context_entry {
26 u64 lo;
27 u64 hi;
28};
29#define context_present(c) ((c).lo & 1)
30#define context_fault_disable(c) (((c).lo >> 1) & 1)
31#define context_translation_type(c) (((c).lo >> 2) & 3)
32#define context_address_root(c) ((c).lo & VTD_PAGE_MASK)
33#define context_address_width(c) ((c).hi & 7)
34#define context_domain_id(c) (((c).hi >> 8) & ((1 << 16) - 1))
35
36#define context_set_present(c) do {(c).lo |= 1;} while (0)
37#define context_set_fault_enable(c) \
38 do {(c).lo &= (((u64)-1) << 2) | 1;} while (0)
39#define context_set_translation_type(c, val) \
40 do { \
41 (c).lo &= (((u64)-1) << 4) | 3; \
42 (c).lo |= ((val) & 3) << 2; \
43 } while (0)
44#define CONTEXT_TT_MULTI_LEVEL 0
45#define context_set_address_root(c, val) \
46 do {(c).lo |= (val) & VTD_PAGE_MASK; } while (0)
47#define context_set_address_width(c, val) do {(c).hi |= (val) & 7;} while (0)
48#define context_set_domain_id(c, val) \
49 do {(c).hi |= ((val) & ((1 << 16) - 1)) << 8;} while (0)
50#define context_clear_entry(c) do {(c).lo = 0; (c).hi = 0;} while (0)
51
52/*
53 * 0: readable 15 * 0: readable
54 * 1: writable 16 * 1: writable
55 * 2-6: reserved 17 * 2-6: reserved