]> git.proxmox.com Git - mirror_qemu.git/commitdiff
migration: check length directly to make sure the range is aligned
authorWei Yang <richardw.yang@linux.intel.com>
Fri, 12 Jul 2019 03:27:04 +0000 (11:27 +0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Wed, 18 Dec 2019 01:34:10 +0000 (02:34 +0100)
Since the start addr is already checked, to make sure the range is
aligned, checking the length is enough.

Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Message-Id: <20190712032704.7826-1-richardw.yang@linux.intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
exec.c

diff --git a/exec.c b/exec.c
index a34c34818404a4bea5ad618d0b666425d1b6abb2..dfe2096d4a767e11f81332236601b783c5f63951 100644 (file)
--- a/exec.c
+++ b/exec.c
@@ -3901,10 +3901,9 @@ int ram_block_discard_range(RAMBlock *rb, uint64_t start, size_t length)
 
     if ((start + length) <= rb->used_length) {
         bool need_madvise, need_fallocate;
-        uint8_t *host_endaddr = host_startaddr + length;
-        if ((uintptr_t)host_endaddr & (rb->page_size - 1)) {
-            error_report("ram_block_discard_range: Unaligned end address: %p",
-                         host_endaddr);
+        if (length & (rb->page_size - 1)) {
+            error_report("ram_block_discard_range: Unaligned length: %zx",
+                         length);
             goto err;
         }