From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 2/4] exec: small changes to flatview_do_translate
Date: Tue, 17 Apr 2018 16:08:00 +0200 [thread overview]
Message-ID: <20180417140802.16711-3-pbonzini@redhat.com> (raw)
In-Reply-To: <20180417140802.16711-1-pbonzini@redhat.com>
Prepare for extracting the IOMMU part to a separate function. Mostly
cosmetic; the only semantic change is that, if there is more than one
cascaded IOMMU and the second one fails to translate, *plen_out is now
adjusted according to the page mask of the first IOMMU.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
exec.c | 33 ++++++++++++++-------------------
1 file changed, 14 insertions(+), 19 deletions(-)
diff --git a/exec.c b/exec.c
index 02b1efebb7..1dea3e9c95 100644
--- a/exec.c
+++ b/exec.c
@@ -476,6 +476,7 @@ address_space_translate_internal(AddressSpaceDispatch *d, hwaddr addr, hwaddr *x
* would tell. It can be @NULL if we don't care about it.
* @is_write: whether the translation operation is for write
* @is_mmio: whether this can be MMIO, set true if it can
+ * @target_as: the address space targeted by the IOMMU
*
* This function is called from RCU critical section
*/
@@ -495,14 +496,14 @@ static MemoryRegionSection flatview_do_translate(FlatView *fv,
hwaddr page_mask = (hwaddr)(-1);
hwaddr plen = (hwaddr)(-1);
- if (plen_out) {
- plen = *plen_out;
+ if (!plen_out) {
+ plen_out = &plen;
}
for (;;) {
section = address_space_translate_internal(
- flatview_to_dispatch(fv), addr, &addr,
- &plen, is_mmio);
+ flatview_to_dispatch(fv), addr, xlat,
+ plen_out, is_mmio);
iommu_mr = memory_region_get_iommu(section->mr);
if (!iommu_mr) {
@@ -510,35 +511,29 @@ static MemoryRegionSection flatview_do_translate(FlatView *fv,
}
imrc = memory_region_get_iommu_class_nocheck(iommu_mr);
+ addr = *xlat;
iotlb = imrc->translate(iommu_mr, addr, is_write ?
IOMMU_WO : IOMMU_RO);
- addr = ((iotlb.translated_addr & ~iotlb.addr_mask)
- | (addr & iotlb.addr_mask));
- page_mask &= iotlb.addr_mask;
- plen = MIN(plen, (addr | iotlb.addr_mask) - addr + 1);
if (!(iotlb.perm & (1 << is_write))) {
goto translate_fail;
}
+ 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);
fv = address_space_to_flatview(iotlb.target_as);
*target_as = iotlb.target_as;
}
- *xlat = addr;
-
- if (page_mask == (hwaddr)(-1)) {
- /* Not behind an IOMMU, use default page size. */
- page_mask = ~TARGET_PAGE_MASK;
- }
-
if (page_mask_out) {
+ if (page_mask == (hwaddr)(-1)) {
+ /* Not behind an IOMMU, use default page size. */
+ page_mask = ~TARGET_PAGE_MASK;
+ }
*page_mask_out = page_mask;
}
- if (plen_out) {
- *plen_out = plen;
- }
-
return *section;
translate_fail:
--
2.17.0
next prev parent reply other threads:[~2018-04-17 14:08 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 ` Paolo Bonzini [this message]
2018-05-04 4:21 ` [Qemu-devel] [PATCH 2/4] exec: small changes to flatview_do_translate 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
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=20180417140802.16711-3-pbonzini@redhat.com \
--to=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).