Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755081AbbFMGun (ORCPT ); Sat, 13 Jun 2015 02:50:43 -0400 Received: from 8bytes.org ([81.169.241.247]:51360 "EHLO theia.8bytes.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751569AbbFMGrl (ORCPT ); Sat, 13 Jun 2015 02:47:41 -0400 From: Joerg Roedel To: iommu@lists.linux-foundation.org Cc: David Woodhouse , zhen-hual@hp.com, bhe@redhat.com, ddutile@redhat.com, alex.williamson@redhat.com, dyoung@redhat.com, linux-kernel@vger.kernel.org, jroedel@8bytes.org, joro@8bytes.org, Joerg Roedel Subject: [PATCH 06/19] iommu/vt-d: Do not re-use domain-ids from the old kernel Date: Sat, 13 Jun 2015 08:47:14 +0200 Message-Id: <1434178047-17809-7-git-send-email-joro@8bytes.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1434178047-17809-1-git-send-email-joro@8bytes.org> References: <1434178047-17809-1-git-send-email-joro@8bytes.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1705 Lines: 55 From: Joerg Roedel 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. Signed-off-by: Joerg Roedel --- drivers/iommu/intel-iommu.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c index a755f94..1d56696 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, 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; @@ -2782,7 +2787,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; @@ -2837,6 +2842,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; } -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/