[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: |
Paolo Bonzini |
Subject: |
Re: [Qemu-devel] [PATCH 3/4] exec: extract address_space_translate_iommu, fix page_mask corner case |
Date: |
Fri, 4 May 2018 03:33:53 -0400 (EDT) |
----- Original Message -----
> From: "Peter Xu" <address@hidden>
> To: "Paolo Bonzini" <address@hidden>
> Cc: address@hidden
> Sent: Friday, May 4, 2018 6:22:31 AM
> Subject: Re: [Qemu-devel] [PATCH 3/4] exec: extract
> address_space_translate_iommu, fix page_mask corner case
>
> 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?)
Good point, I'll fix that.
Paolo
>
> Reviewed-by: Peter Xu <address@hidden>
>
> --
> Peter Xu
>