[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v5 05/10] exec: Relax range check in ram_block_discard_range()
From: |
David Hildenbrand |
Subject: |
[PATCH v5 05/10] exec: Relax range check in ram_block_discard_range() |
Date: |
Thu, 29 Apr 2021 13:27:03 +0200 |
We want to make use of ram_block_discard_range() in the RAM block resize
callback when growing a RAM block, *before* used_length is changed.
Let's relax the check. As RAM blocks always mmap the whole max_length area,
we cannot corrupt unrelated data.
Reviewed-by: Peter Xu <peterx@redhat.com>
Signed-off-by: David Hildenbrand <david@redhat.com>
---
softmmu/physmem.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/softmmu/physmem.c b/softmmu/physmem.c
index 4834003d47..4e587de150 100644
--- a/softmmu/physmem.c
+++ b/softmmu/physmem.c
@@ -3503,7 +3503,7 @@ int ram_block_discard_range(RAMBlock *rb, uint64_t start,
size_t length)
goto err;
}
- if ((start + length) <= rb->used_length) {
+ if ((start + length) <= rb->max_length) {
bool need_madvise, need_fallocate;
if (!QEMU_IS_ALIGNED(length, rb->page_size)) {
error_report("ram_block_discard_range: Unaligned length: %zx",
@@ -3570,7 +3570,7 @@ int ram_block_discard_range(RAMBlock *rb, uint64_t start,
size_t length)
} else {
error_report("ram_block_discard_range: Overrun block '%s' (%" PRIu64
"/%zx/" RAM_ADDR_FMT")",
- rb->idstr, start, length, rb->used_length);
+ rb->idstr, start, length, rb->max_length);
}
err:
--
2.30.2
- [PATCH v5 00/10] numa/exec/migration: Fix resizing RAM blocks while migrating, David Hildenbrand, 2021/04/29
- [PATCH v5 01/10] util: vfio-helpers: Factor out and fix processing of existing ram blocks, David Hildenbrand, 2021/04/29
- [PATCH v5 02/10] numa: Teach ram block notifiers about resizeable ram blocks, David Hildenbrand, 2021/04/29
- [PATCH v5 03/10] numa: Make all callbacks of ram block notifiers optional, David Hildenbrand, 2021/04/29
- [PATCH v5 04/10] migration/ram: Handle RAM block resizes during precopy, David Hildenbrand, 2021/04/29
- [PATCH v5 05/10] exec: Relax range check in ram_block_discard_range(),
David Hildenbrand <=
- [PATCH v5 06/10] migration/ram: Discard RAM when growing RAM blocks after ram_postcopy_incoming_init(), David Hildenbrand, 2021/04/29
- [PATCH v5 07/10] migration/ram: Simplify host page handling in ram_load_postcopy(), David Hildenbrand, 2021/04/29
- [PATCH v5 08/10] migration/ram: Handle RAM block resizes during postcopy, David Hildenbrand, 2021/04/29
- [PATCH v5 09/10] migration/multifd: Print used_length of memory block, David Hildenbrand, 2021/04/29
- [PATCH v5 10/10] migration/ram: Use offset_in_ramblock() in range checks, David Hildenbrand, 2021/04/29