From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>,
Paolo Bonzini <pbonzini@redhat.com>, Peter Xu <peterx@redhat.com>,
David Hildenbrand <david@redhat.com>
Cc: qemu-devel@nongnu.org, Richard Henderson <richard.henderson@linaro.org>
Subject: Re: [PATCH, v2] physmem: avoid bounce buffer too small
Date: Wed, 28 Feb 2024 16:06:41 +0100 [thread overview]
Message-ID: <fb6ef90d-4a3e-4bdd-8516-8b15c1f2329f@linaro.org> (raw)
In-Reply-To: <20240228125939.56925-1-heinrich.schuchardt@canonical.com>
Hi Heinrich,
On 28/2/24 13:59, Heinrich Schuchardt wrote:
> virtqueue_map_desc() is called with values of sz exceeding that may exceed
> TARGET_PAGE_SIZE. sz = 0x2800 has been observed.
>
> We only support a single bounce buffer. We have to avoid
> virtqueue_map_desc() calling address_space_map() multiple times. Otherwise
> we see an error
>
> qemu: virtio: bogus descriptor or out of resources
>
> Increase the minimum size of the bounce buffer to 0x10000 which matches
> the largest value of TARGET_PAGE_SIZE for all architectures.
>
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
> ---
> v2:
> remove unrelated change
> ---
> system/physmem.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/system/physmem.c b/system/physmem.c
> index e3ebc19eef..3c82da1c86 100644
> --- a/system/physmem.c
> +++ b/system/physmem.c
> @@ -3151,8 +3151,12 @@ void *address_space_map(AddressSpace *as,
> *plen = 0;
> return NULL;
> }
> - /* Avoid unbounded allocations */
> - l = MIN(l, TARGET_PAGE_SIZE);
> + /*
> + * There is only one bounce buffer. The largest occuring value of
> + * parameter sz of virtqueue_map_desc() must fit into the bounce
> + * buffer.
> + */
> + l = MIN(l, 0x10000);
Please define this magic value. Maybe ANY_TARGET_PAGE_SIZE or
TARGETS_BIGGEST_PAGE_SIZE?
Then along:
QEMU_BUILD_BUG_ON(TARGET_PAGE_SIZE <= TARGETS_BIGGEST_PAGE_SIZE);
> bounce.buffer = qemu_memalign(TARGET_PAGE_SIZE, l);
> bounce.addr = addr;
> bounce.len = l;
next prev parent reply other threads:[~2024-02-28 15:08 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-28 12:59 [PATCH, v2] physmem: avoid bounce buffer too small Heinrich Schuchardt
2024-02-28 15:06 ` Philippe Mathieu-Daudé [this message]
2024-02-28 18:27 ` Heinrich Schuchardt
2024-02-28 18:39 ` Peter Maydell
2024-02-28 19:07 ` Heinrich Schuchardt
2024-02-29 1:11 ` Peter Xu
2024-02-29 10:22 ` Heinrich Schuchardt
2024-02-29 10:36 ` Mattias Nissler
2024-02-29 10:46 ` Jonathan Cameron via
2024-02-29 9:38 ` Peter Maydell
2024-02-29 10:59 ` Jonathan Cameron via
2024-02-29 11:11 ` Peter Maydell
2024-02-29 11:17 ` Heinrich Schuchardt
2024-02-29 12:34 ` Peter Maydell
2024-02-29 12:52 ` Mattias Nissler
2024-02-29 13:19 ` Peter Maydell
2024-02-29 14:17 ` Heinrich Schuchardt
2024-02-29 14:52 ` Peter Maydell
2024-02-29 11:18 ` Mattias Nissler
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=fb6ef90d-4a3e-4bdd-8516-8b15c1f2329f@linaro.org \
--to=philmd@linaro.org \
--cc=david@redhat.com \
--cc=heinrich.schuchardt@canonical.com \
--cc=pbonzini@redhat.com \
--cc=peterx@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.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).