Skip to content

Commit

Permalink
iommu/vt-d: Don't copy translation tables if RTT bit needs to be changed
Browse files Browse the repository at this point in the history
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.

Tested-by: ZhenHua Li <zhen-hual@hp.com>
Tested-by: Baoquan He <bhe@redhat.com>
Signed-off-by: Joerg Roedel <jroedel@suse.de>
  • Loading branch information
Joerg Roedel committed Jun 16, 2015
1 parent a87f491 commit c3361f2
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion drivers/iommu/intel-iommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -2934,10 +2934,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)
Expand Down

0 comments on commit c3361f2

Please sign in to comment.