From 4142c740cffe9e93580e7a48fdbcc3b80d370209 Mon Sep 17 00:00:00 2001 From: Jan Kiszka Date: Wed, 24 Feb 2016 10:19:54 +0100 Subject: [PATCH] x86: Filter out physical address that can't be handled by DMAR units Make sure that we do not try to program DMAR page tables with physical addresses beyond the supported range (39 or 48 bits, depending on the page table levels). Signed-off-by: Jan Kiszka --- hypervisor/arch/x86/vtd.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hypervisor/arch/x86/vtd.c b/hypervisor/arch/x86/vtd.c index 28faf51..6d36394 100644 --- a/hypervisor/arch/x86/vtd.c +++ b/hypervisor/arch/x86/vtd.c @@ -773,6 +773,9 @@ int iommu_map_memory_region(struct cell *cell, if (!(mem->flags & JAILHOUSE_MEM_DMA)) return 0; + if (mem->virt_start & BIT_MASK(63, 12 + 9 * dmar_pt_levels)) + return trace_error(-E2BIG); + if (mem->flags & JAILHOUSE_MEM_READ) flags |= VTD_PAGE_READ; if (mem->flags & JAILHOUSE_MEM_WRITE) -- 2.39.2