From: "Dr. David Alan Gilbert (git)" <dgilbert@redhat.com>
To: qemu-devel@nongnu.org, pbonzini@redhat.com, mst@redhat.com
Cc: peter.maydell@linaro.org
Subject: [Qemu-devel] [PATCH 2/2] vhost: Fix memory region section comparison
Date: Tue, 13 Aug 2019 11:29:36 +0100 [thread overview]
Message-ID: <20190813102936.32195-3-dgilbert@redhat.com> (raw)
In-Reply-To: <20190813102936.32195-1-dgilbert@redhat.com>
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Using memcmp to compare structures wasn't safe,
as I found out on ARM when I was getting false miscompares.
Use the helper function for comparing the MRSs.
Fixes: ade6d081fc33948e56e6
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
---
hw/virtio/vhost.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index bc899fc60e..2ef4bc720f 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -451,8 +451,13 @@ static void vhost_commit(MemoryListener *listener)
changed = true;
} else {
/* Same size, lets check the contents */
- changed = n_old_sections && memcmp(dev->mem_sections, old_sections,
- n_old_sections * sizeof(old_sections[0])) != 0;
+ for (int i = 0; i < n_old_sections; i++) {
+ if (!MemoryRegionSection_eq(&old_sections[i],
+ &dev->mem_sections[i])) {
+ changed = true;
+ break;
+ }
+ }
}
trace_vhost_commit(dev->started, changed);
--
2.21.0
next prev parent reply other threads:[~2019-08-13 10:30 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-13 10:29 [Qemu-devel] [PATCH 0/2] Fix MemoryRegionSection alignment and comparison Dr. David Alan Gilbert (git)
2019-08-13 10:29 ` [Qemu-devel] [PATCH 1/2] memory: Align and add helper for comparing MemoryRegionSections Dr. David Alan Gilbert (git)
2019-08-13 12:58 ` Philippe Mathieu-Daudé
2019-08-14 17:25 ` Dr. David Alan Gilbert
2019-08-14 17:35 ` Philippe Mathieu-Daudé
2019-08-14 17:44 ` Dr. David Alan Gilbert
2019-08-13 10:29 ` Dr. David Alan Gilbert (git) [this message]
2019-08-13 12:06 ` [Qemu-devel] [PATCH 0/2] Fix MemoryRegionSection alignment and comparison Paolo Bonzini
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=20190813102936.32195-3-dgilbert@redhat.com \
--to=dgilbert@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--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).