[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 3/4] exec: extract address_space_translate_iommu
From: |
Peter Xu |
Subject: |
Re: [Qemu-devel] [PATCH 3/4] exec: extract address_space_translate_iommu, fix page_mask corner case |
Date: |
Fri, 4 May 2018 12:22:31 +0800 |
User-agent: |
Mutt/1.9.3 (2018-01-21) |
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 <address@hidden>
--
Peter Xu
- Re: [Qemu-devel] [PATCH 3/4] exec: extract address_space_translate_iommu, fix page_mask corner case,
Peter Xu <=