From: "Alex Bennée" <alex.bennee@linaro.org>
To: Anthony PERARD <anthony.perard@vates.tech>
Cc: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>,
qemu-devel@nongnu.org, sstabellini@kernel.org, paul@xen.org,
edgar.iglesias@amd.com, xen-devel@lists.xenproject.org
Subject: Re: [PATCH v1 2/2] xen: mapcache: Fix unmapping of first entries in buckets
Date: Thu, 04 Jul 2024 17:44:52 +0100 [thread overview]
Message-ID: <87wmm1m7i3.fsf@draig.linaro.org> (raw)
In-Reply-To: <ZoawbAnukIBkYWCw@l14> (Anthony PERARD's message of "Thu, 04 Jul 2024 14:23:41 +0000")
Anthony PERARD <anthony.perard@vates.tech> writes:
> On Tue, Jul 02, 2024 at 12:44:21AM +0200, Edgar E. Iglesias wrote:
>> From: "Edgar E. Iglesias" <edgar.iglesias@amd.com>
>>
>> This fixes the clobbering of the entry->next pointer when
>> unmapping the first entry in a bucket of a mapcache.
>>
>> Fixes: 123acd816d ("xen: mapcache: Unmap first entries in buckets")
>> Reported-by: Anthony PERARD <anthony.perard@vates.tech>
>> Signed-off-by: Edgar E. Iglesias <edgar.iglesias@amd.com>
>> ---
>> hw/xen/xen-mapcache.c | 12 +++++++++++-
>> 1 file changed, 11 insertions(+), 1 deletion(-)
>>
>> diff --git a/hw/xen/xen-mapcache.c b/hw/xen/xen-mapcache.c
>> index 5f23b0adbe..18ba7b1d8f 100644
>> --- a/hw/xen/xen-mapcache.c
>> +++ b/hw/xen/xen-mapcache.c
>> @@ -597,7 +597,17 @@ static void xen_invalidate_map_cache_entry_unlocked(MapCache *mc,
>> pentry->next = entry->next;
>> g_free(entry);
>> } else {
>> - memset(entry, 0, sizeof *entry);
>> + /*
>> + * Invalidate mapping but keep entry->next pointing to the rest
>> + * of the list.
>> + *
>> + * Note that lock is already zero here, otherwise we don't unmap.
>> + */
>> + entry->paddr_index = 0;
>> + entry->vaddr_base = NULL;
>> + entry->valid_mapping = NULL;
>> + entry->flags = 0;
>> + entry->size = 0;
>
> This kind of feels like mc->entry should be an array of pointer rather
> than an array of MapCacheEntry but that seems to work well enough and
> not the first time entries are been cleared like that.
The use of a hand rolled list is a bit of a concern considering QEMU and
Glib both provide various abstractions used around the rest of the code
base. The original patch that introduces the mapcache doesn't tell me
much about access patterns for the cache, just that it is trying to
solve memory exhaustion issues with lots of dynamic small mappings.
Maybe a simpler structure is desirable?
We also have an interval tree implementation ("qemu/interval-tree.h") if
what we really want is a sorted tree of memory that can be iterated
locklessly.
--
Alex Bennée
Virtualisation Tech Lead @ Linaro
next prev parent reply other threads:[~2024-07-04 16:45 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-01 22:44 [PATCH v1 0/2] xen: mapcache: Fix unmapping of first the entry in a bucket Edgar E. Iglesias
2024-07-01 22:44 ` [PATCH v1 1/2] physmem: Bail out qemu_ram_block_from_host() for invalid ram addrs Edgar E. Iglesias
2024-07-04 10:26 ` Alex Bennée
2024-07-04 11:42 ` Edgar E. Iglesias
2024-07-04 12:33 ` Alex Bennée
2024-07-08 23:14 ` Stefano Stabellini
2024-07-01 22:44 ` [PATCH v1 2/2] xen: mapcache: Fix unmapping of first entries in buckets Edgar E. Iglesias
2024-07-04 14:23 ` Anthony PERARD
2024-07-04 16:44 ` Alex Bennée [this message]
2024-07-04 18:48 ` Edgar E. Iglesias via
2024-07-04 18:48 ` Edgar E. Iglesias
2024-07-06 6:27 ` Edgar E. Iglesias
2024-07-07 8:45 ` Alex Bennée
2024-07-08 23:16 ` Stefano Stabellini
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=87wmm1m7i3.fsf@draig.linaro.org \
--to=alex.bennee@linaro.org \
--cc=anthony.perard@vates.tech \
--cc=edgar.iglesias@amd.com \
--cc=edgar.iglesias@gmail.com \
--cc=paul@xen.org \
--cc=qemu-devel@nongnu.org \
--cc=sstabellini@kernel.org \
--cc=xen-devel@lists.xenproject.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.