Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752717AbbFMGsf (ORCPT ); Sat, 13 Jun 2015 02:48:35 -0400 Received: from 8bytes.org ([81.169.241.247]:51446 "EHLO theia.8bytes.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751964AbbFMGr4 (ORCPT ); Sat, 13 Jun 2015 02:47:56 -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 10/19] iommu/vt-d: Don't copy translation tables if RTT bit needs to be changed Date: Sat, 13 Jun 2015 08:47:18 +0200 Message-Id: <1434178047-17809-11-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: 1422 Lines: 45 From: Joerg Roedel We can't change the RTT bit when translation is enabled, so don't copy translation tables when we would change the bit with our new root entry. Signed-off-by: Joerg Roedel --- drivers/iommu/intel-iommu.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c index 39bc3d6..e23d5b4 100644 --- a/drivers/iommu/intel-iommu.c +++ b/drivers/iommu/intel-iommu.c @@ -2914,10 +2914,20 @@ static int copy_translation_tables(struct intel_iommu *iommu) unsigned long flags; u64 rtaddr_reg; int bus, ret; - bool ext; + bool new_ext, ext; rtaddr_reg = dmar_readq(iommu->reg + DMAR_RTADDR_REG); ext = !!(rtaddr_reg & DMA_RTADDR_RTT); + new_ext = !!ecap_ecs(iommu->ecap); + + /* + * The RTT bit can only be changed when translation is disabled, + * but disabling translation means to open a window for data + * corruption. So bail out and don't copy anything if we would + * have to change the bit. + */ + if (new_ext != ext) + return -EINVAL; old_rt_phys = rtaddr_reg & VTD_PAGE_MASK; if (!old_rt_phys) -- 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/