On Tue, Apr 17, 2018 at 04:08:01PM +0200, Paolo Bonzini wrote:

[...]

> +static MemoryRegionSection address_space_translate_iommu(IOMMUMemoryRegion 
> *iommu_mr,
> +                                                         hwaddr *xlat,
> +                                                         hwaddr *plen_out,
> +                                                         hwaddr 
> *page_mask_out,
> +                                                         bool is_write,
> +                                                         bool is_mmio,
> +                                                         AddressSpace 
> **target_as)
> +{
> +    MemoryRegionSection *section;
> +    hwaddr page_mask = (hwaddr)-1;
> +
> +    do {
> +        hwaddr addr = *xlat;
> +        IOMMUMemoryRegionClass *imrc = 
> memory_region_get_iommu_class_nocheck(iommu_mr);
> +        IOMMUTLBEntry iotlb = imrc->translate(iommu_mr, addr, is_write ?
> +                                              IOMMU_WO : IOMMU_RO);
> +
> +        if (!(iotlb.perm & (1 << is_write))) {
> +            goto unassigned;
> +        }
> +
> +        addr = ((iotlb.translated_addr & ~iotlb.addr_mask)
> +                | (addr & iotlb.addr_mask));
> +        page_mask &= iotlb.addr_mask;
> +        *plen_out = MIN(*plen_out, (addr | iotlb.addr_mask) - addr + 1);
> +        *target_as = iotlb.target_as;
> +
> +        section = address_space_translate_internal(
> +                address_space_to_dispatch(iotlb.target_as), addr, xlat,
> +                plen_out, is_mmio);
> +        if (!section) {
> +            goto unassigned;

(we won't reach here, will we?)

Reviewed-by: Peter Xu <pet...@redhat.com>

-- 
Peter Xu

Reply via email to