From: Paolo Bonzini <pbonzini@redhat.com>
To: Peter Crosthwaite <peter.crosthwaite@xilinx.com>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] exec: Respect as_tranlsate_internal length clamp
Date: Wed, 18 Mar 2015 12:11:44 +0100 [thread overview]
Message-ID: <55095D70.6000007@redhat.com> (raw)
In-Reply-To: <1426570554-15940-1-git-send-email-peter.crosthwaite@xilinx.com>
On 17/03/2015 06:35, Peter Crosthwaite wrote:
> address_space_translate_internal will clamp the *plen length argument
> based on the size of the memory region being queried. The iommu walker
> logic in addresss_space_translate was ignoring this by discarding the
> post fn call value of *plen. Fix by just always using *plen as the
> length argument throughout the fn, removing the len local variable.
>
> This fixes a bootloader bug when a single elf section spans multiple
> QEMU memory regions.
>
> Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
> ---
> exec.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/exec.c b/exec.c
> index e97071a..8b922db 100644
> --- a/exec.c
> +++ b/exec.c
> @@ -380,7 +380,6 @@ MemoryRegion *address_space_translate(AddressSpace *as, hwaddr addr,
> IOMMUTLBEntry iotlb;
> MemoryRegionSection *section;
> MemoryRegion *mr;
> - hwaddr len = *plen;
>
> rcu_read_lock();
> for (;;) {
> @@ -395,7 +394,7 @@ MemoryRegion *address_space_translate(AddressSpace *as, hwaddr addr,
> iotlb = mr->iommu_ops->translate(mr, addr, is_write);
> addr = ((iotlb.translated_addr & ~iotlb.addr_mask)
> | (addr & iotlb.addr_mask));
> - len = MIN(len, (addr | iotlb.addr_mask) - addr + 1);
> + *plen = MIN(*plen, (addr | iotlb.addr_mask) - addr + 1);
> if (!(iotlb.perm & (1 << is_write))) {
> mr = &io_mem_unassigned;
> break;
> @@ -406,10 +405,9 @@ MemoryRegion *address_space_translate(AddressSpace *as, hwaddr addr,
>
> if (xen_enabled() && memory_access_is_direct(mr, is_write)) {
> hwaddr page = ((addr & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE) - addr;
> - len = MIN(page, len);
> + *plen = MIN(page, *plen);
> }
>
> - *plen = len;
> *xlat = addr;
> rcu_read_unlock();
> return mr;
>
Applied, thanks.
Paolo
prev parent reply other threads:[~2015-03-18 11:11 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-17 5:35 [Qemu-devel] [PATCH] exec: Respect as_tranlsate_internal length clamp Peter Crosthwaite
2015-03-18 11:11 ` Paolo Bonzini [this message]
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=55095D70.6000007@redhat.com \
--to=pbonzini@redhat.com \
--cc=peter.crosthwaite@xilinx.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).