diff options
author | Joerg Roedel <jroedel@suse.de> | 2015-06-12 06:02:09 -0400 |
---|---|---|
committer | Joerg Roedel <jroedel@suse.de> | 2015-06-16 04:59:34 -0400 |
commit | dbcd861f252d727ac856a3da2cba8a480a36ab2e (patch) | |
tree | 888c1b9cb3f9a39acc61886c97186698f85853b9 /drivers/iommu/intel-iommu.c | |
parent | 091d42e43d21b6ca7ec39bf5f9e17bc0bd8d4312 (diff) |
iommu/vt-d: Do not re-use domain-ids from the old kernel
Mark all domain-ids we find as reserved, so that there could
be no collision between domains from the previous kernel and
our domains in the IOMMU TLB.
Tested-by: ZhenHua Li <zhen-hual@hp.com>
Tested-by: Baoquan He <bhe@redhat.com>
Signed-off-by: Joerg Roedel <jroedel@suse.de>
Diffstat (limited to 'drivers/iommu/intel-iommu.c')
-rw-r--r-- | drivers/iommu/intel-iommu.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c index 1eb743c700e9..431853386db8 100644 --- a/drivers/iommu/intel-iommu.c +++ b/drivers/iommu/intel-iommu.c | |||
@@ -273,6 +273,11 @@ static inline void context_set_domain_id(struct context_entry *context, | |||
273 | context->hi |= (value & ((1 << 16) - 1)) << 8; | 273 | context->hi |= (value & ((1 << 16) - 1)) << 8; |
274 | } | 274 | } |
275 | 275 | ||
276 | static inline int context_domain_id(struct context_entry *c) | ||
277 | { | ||
278 | return((c->hi >> 8) & 0xffff); | ||
279 | } | ||
280 | |||
276 | static inline void context_clear_entry(struct context_entry *context) | 281 | static inline void context_clear_entry(struct context_entry *context) |
277 | { | 282 | { |
278 | context->lo = 0; | 283 | context->lo = 0; |
@@ -2802,7 +2807,7 @@ static int copy_context_table(struct intel_iommu *iommu, | |||
2802 | int bus, bool ext) | 2807 | int bus, bool ext) |
2803 | { | 2808 | { |
2804 | struct context_entry *old_ce = NULL, *new_ce = NULL, ce; | 2809 | struct context_entry *old_ce = NULL, *new_ce = NULL, ce; |
2805 | int tbl_idx, pos = 0, idx, devfn, ret = 0; | 2810 | int tbl_idx, pos = 0, idx, devfn, ret = 0, did; |
2806 | phys_addr_t old_ce_phys; | 2811 | phys_addr_t old_ce_phys; |
2807 | 2812 | ||
2808 | tbl_idx = ext ? bus * 2 : bus; | 2813 | tbl_idx = ext ? bus * 2 : bus; |
@@ -2857,6 +2862,10 @@ static int copy_context_table(struct intel_iommu *iommu, | |||
2857 | if (!context_present(&ce)) | 2862 | if (!context_present(&ce)) |
2858 | continue; | 2863 | continue; |
2859 | 2864 | ||
2865 | did = context_domain_id(&ce); | ||
2866 | if (did >= 0 && did < cap_ndoms(iommu->cap)) | ||
2867 | set_bit(did, iommu->domain_ids); | ||
2868 | |||
2860 | new_ce[idx] = ce; | 2869 | new_ce[idx] = ce; |
2861 | } | 2870 | } |
2862 | 2871 | ||