]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
iommu/vt-d: Do not re-use domain-ids from the old kernel
authorJoerg Roedel <jroedel@suse.de>
Fri, 12 Jun 2015 10:02:09 +0000 (12:02 +0200)
committerJoerg Roedel <jroedel@suse.de>
Tue, 16 Jun 2015 08:59:34 +0000 (10:59 +0200)
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>
drivers/iommu/intel-iommu.c

index 1eb743c700e9a5c256de79e83cbd6203a056fe09..431853386db807333f207edd083a501a483a6279 100644 (file)
@@ -273,6 +273,11 @@ static inline void context_set_domain_id(struct context_entry *context,
        context->hi |= (value & ((1 << 16) - 1)) << 8;
 }
 
+static inline int context_domain_id(struct context_entry *c)
+{
+       return((c->hi >> 8) & 0xffff);
+}
+
 static inline void context_clear_entry(struct context_entry *context)
 {
        context->lo = 0;
@@ -2802,7 +2807,7 @@ static int copy_context_table(struct intel_iommu *iommu,
                              int bus, bool ext)
 {
        struct context_entry *old_ce = NULL, *new_ce = NULL, ce;
-       int tbl_idx, pos = 0, idx, devfn, ret = 0;
+       int tbl_idx, pos = 0, idx, devfn, ret = 0, did;
        phys_addr_t old_ce_phys;
 
        tbl_idx = ext ? bus * 2 : bus;
@@ -2857,6 +2862,10 @@ static int copy_context_table(struct intel_iommu *iommu,
                if (!context_present(&ce))
                        continue;
 
+               did = context_domain_id(&ce);
+               if (did >= 0 && did < cap_ndoms(iommu->cap))
+                       set_bit(did, iommu->domain_ids);
+
                new_ce[idx] = ce;
        }