From 51644ab70ba125cb9545702d64890743d75b444b Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Thu, 11 Apr 2013 15:40:59 +0200 Subject: memory: add address_space_access_valid The old-style IOMMU lets you check whether an access is valid in a given DMAContext. There is no equivalent for AddressSpace in the memory API, implement it with a lookup of the dispatch tree. Reviewed-by: Richard Henderson Signed-off-by: Paolo Bonzini --- dma-helpers.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'dma-helpers.c') diff --git a/dma-helpers.c b/dma-helpers.c index 272632f367..2e298b6ebb 100644 --- a/dma-helpers.c +++ b/dma-helpers.c @@ -298,6 +298,11 @@ bool iommu_dma_memory_valid(DMAContext *dma, dma_addr_t addr, dma_addr_t len, plen = len; } + if (!address_space_access_valid(dma->as, paddr, len, + dir == DMA_DIRECTION_FROM_DEVICE)) { + return false; + } + len -= plen; addr += plen; } -- cgit v1.2.1