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, maxime.coquelin@redhat.com, marcandre.lureau@redhat.com Subject: [Qemu-devel] [PATCH v2 3/3] vhost: Fix memory region section comparison Date: Wed, 14 Aug 2019 18:55:35 +0100 [thread overview] Message-ID: <20190814175535.2023-4-dgilbert@redhat.com> (raw) In-Reply-To: <20190814175535.2023-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 falce 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
WARNING: multiple messages have this Message-ID (diff)
From: "Michael S. Tsirkin" <mst@redhat.com> To: qemu-devel@nongnu.org Cc: Peter Maydell <peter.maydell@linaro.org>, "Dr. David Alan Gilbert" <dgilbert@redhat.com>, qemu-stable@nongnu.org Subject: [PULL 3/3] vhost: Fix memory region section comparison Date: Wed, 25 Sep 2019 10:30:20 -0400 [thread overview] Message-ID: <20190814175535.2023-4-dgilbert@redhat.com> (raw) Message-ID: <20190925143020.B9J6AcO-Qejkfhp4cS9ej138GeEC4B4NAzupWCgLtC0@z> (raw) In-Reply-To: <20190925142910.26529-1-mst@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 falce miscompares. Use the helper function for comparing the MRSs. Fixes: ade6d081fc33948e56e6 ("vhost: Regenerate region list from changed sections list") Cc: qemu-stable@nongnu.org Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Message-Id: <20190814175535.2023-4-dgilbert@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@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 34accdf615..2386b511f3 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); -- MST
next prev parent reply other threads:[~2019-08-14 17:59 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-08-14 17:55 [Qemu-devel] [PATCH v2 0/3] Fix MemoryRegionSection alignment and comparison Dr. David Alan Gilbert (git) 2019-08-14 17:55 ` [Qemu-devel] [PATCH v2 1/3] memory: Align MemoryRegionSections fields Dr. David Alan Gilbert (git) 2019-09-25 14:30 ` [PULL " Michael S. Tsirkin 2019-08-14 17:55 ` [Qemu-devel] [PATCH v2 2/3] memory: Provide an equality function for MemoryRegionSections Dr. David Alan Gilbert (git) 2019-09-25 14:30 ` [PULL " Michael S. Tsirkin 2019-08-14 17:55 ` Dr. David Alan Gilbert (git) [this message] 2019-09-25 14:30 ` [PULL 3/3] vhost: Fix memory region section comparison Michael S. Tsirkin 2019-08-15 2:16 ` [Qemu-devel] [PATCH v2 0/3] Fix MemoryRegionSection alignment and comparison no-reply 2019-09-25 14:30 [PULL 0/3] vhost: fixes Michael S. Tsirkin 2019-09-27 10:10 ` Peter Maydell
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=20190814175535.2023-4-dgilbert@redhat.com \ --to=dgilbert@redhat.com \ --cc=marcandre.lureau@redhat.com \ --cc=maxime.coquelin@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: linkBe 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).