From: Peter Xu <peterx@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: qemu-devel@nongnu.org
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 [thread overview]
Message-ID: <20180504042231.GC28447@xz-mi> (raw)
In-Reply-To: <20180417140802.16711-4-pbonzini@redhat.com>
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 <peterx@redhat.com>
--
Peter Xu
next prev parent reply other threads:[~2018-05-04 4:22 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-17 14:07 [Qemu-devel] [PATCH 0/4] exec: reintroduce MemoryRegion caching Paolo Bonzini
2018-04-17 14:07 ` [Qemu-devel] [PATCH 1/4] exec: move memory access declarations to a common header, inline *_phys functions Paolo Bonzini
2018-04-17 14:08 ` [Qemu-devel] [PATCH 2/4] exec: small changes to flatview_do_translate Paolo Bonzini
2018-05-04 4:21 ` Peter Xu
2018-04-17 14:08 ` [Qemu-devel] [PATCH 3/4] exec: extract address_space_translate_iommu, fix page_mask corner case Paolo Bonzini
2018-05-04 4:22 ` Peter Xu [this message]
2018-05-04 7:33 ` Paolo Bonzini
2018-04-17 14:08 ` [Qemu-devel] [PATCH 4/4] exec: reintroduce MemoryRegion caching Paolo Bonzini
2018-05-16 10:41 ` [Qemu-devel] [PATCH 0/4] " Auger Eric
2018-05-16 10:42 ` Paolo Bonzini
2018-05-16 13:38 ` Auger Eric
2018-05-16 13:49 ` Auger Eric
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180504042231.GC28447@xz-mi \
--to=peterx@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).