From: Peter Xu <peterx@redhat.com>
To: kvm@vger.kernel.org
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
"Juan Quintela" <quintela@redhat.com>,
"Radim Krčmář" <rkrcmar@redhat.com>,
peterx@redhat.com,
"Dr . David Alan Gilbert" <dgilbert@redhat.com>
Subject: [PATCH 2/2] kvm: Fix loop of clear dirty with off-by-one
Date: Wed, 8 May 2019 13:44:03 +0800 [thread overview]
Message-ID: <20190508054403.7277-3-peterx@redhat.com> (raw)
In-Reply-To: <20190508054403.7277-1-peterx@redhat.com>
Just imaging the case where num_pages < BITS_PER_LONG, then the loop
will be skipped while it shouldn't.
Signed-off-by: Peter Xu <peterx@redhat.com>
---
virt/kvm/kvm_main.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index ad39c57de82d..15601a19a87a 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -1264,8 +1264,8 @@ int kvm_clear_dirty_log_protect(struct kvm *kvm,
return -EFAULT;
spin_lock(&kvm->mmu_lock);
- for (offset = log->first_page,
- i = offset / BITS_PER_LONG, n = log->num_pages / BITS_PER_LONG; n--;
+ for (offset = log->first_page, i = offset / BITS_PER_LONG,
+ n = (log->num_pages / BITS_PER_LONG + 1); n--;
i++, offset += BITS_PER_LONG) {
unsigned long mask = *dirty_bitmap_buffer++;
atomic_long_t *p = (atomic_long_t *) &dirty_bitmap[i];
--
2.17.1
next prev parent reply other threads:[~2019-05-08 5:44 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-08 5:44 [PATCH 0/2] kvm: Some more trivial fixes for clear dirty log Peter Xu
2019-05-08 5:44 ` [PATCH 1/2] kvm: Fix the bitmap range to copy during clear dirty Peter Xu
2019-05-08 5:44 ` Peter Xu [this message]
2019-05-08 8:12 ` [PATCH 0/2] kvm: Some more trivial fixes for clear dirty log Paolo Bonzini
2019-05-08 8:36 ` Peter Xu
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=20190508054403.7277-3-peterx@redhat.com \
--to=peterx@redhat.com \
--cc=dgilbert@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=quintela@redhat.com \
--cc=rkrcmar@redhat.com \
/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