[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 08/60] memory-device: turn alignment assert into chec
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 08/60] memory-device: turn alignment assert into check |
Date: |
Thu, 28 Jun 2018 22:04:18 +0200 |
From: David Hildenbrand <address@hidden>
The start of the address space indicates which maximum alignment is
supported by our machine (e.g. ppc, x86 1GB). This is helpful to
catch fragmenting guest physical memory in strange fashions.
Right now we can crash QEMU by e.g. (there might be easier examples)
qemu-system-x86_64 -m 256M,maxmem=20G,slots=2 \
-object memory-backend-file,id=mem0,size=8192M,mem-path=/dev/zero,align=8192M \
-device pc-dimm,id=dimm1,memdev=mem0
Signed-off-by: David Hildenbrand <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Michael S. Tsirkin <address@hidden>
Reviewed-by: Igor Mammedov <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
hw/mem/memory-device.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/hw/mem/memory-device.c b/hw/mem/memory-device.c
index 3e04f39..6de4f70 100644
--- a/hw/mem/memory-device.c
+++ b/hw/mem/memory-device.c
@@ -116,9 +116,15 @@ uint64_t memory_device_get_free_addr(MachineState *ms,
const uint64_t *hint,
address_space_start = ms->device_memory->base;
address_space_end = address_space_start +
memory_region_size(&ms->device_memory->mr);
- g_assert(QEMU_ALIGN_UP(address_space_start, align) == address_space_start);
g_assert(address_space_end >= address_space_start);
+ /* address_space_start indicates the maximum alignment we expect */
+ if (QEMU_ALIGN_UP(address_space_start, align) != address_space_start) {
+ error_setg(errp, "the alignment (0%" PRIx64 ") is not supported",
+ align);
+ return 0;
+ }
+
memory_device_check_addable(ms, size, errp);
if (*errp) {
return 0;
--
1.8.3.1
- [Qemu-devel] [PULL 00/60] Misc patches for soft freeze, Paolo Bonzini, 2018/06/28
- [Qemu-devel] [PULL 03/60] chardev: don't splatter terminal settings on exit if not previously set, Paolo Bonzini, 2018/06/28
- [Qemu-devel] [PULL 01/60] exec: Fix MAP_RAM for cached access, Paolo Bonzini, 2018/06/28
- [Qemu-devel] [PULL 02/60] move public invalidate APIs out of translate-all.{c, h}, clean up, Paolo Bonzini, 2018/06/28
- [Qemu-devel] [PULL 06/60] target/i386: Fix BLSR and BLSI, Paolo Bonzini, 2018/06/28
- [Qemu-devel] [PULL 07/60] whpx: commit missing file, Paolo Bonzini, 2018/06/28
- [Qemu-devel] [PULL 04/60] main-loop: document IOCanReadHandler, Paolo Bonzini, 2018/06/28
- [Qemu-devel] [PULL 05/60] hw/char/serial: Only retry if qemu_chr_fe_write returns 0, Paolo Bonzini, 2018/06/28
- [Qemu-devel] [PULL 08/60] memory-device: turn alignment assert into check,
Paolo Bonzini <=
- [Qemu-devel] [PULL 09/60] exec: check that alignment is a power of two, Paolo Bonzini, 2018/06/28
- [Qemu-devel] [PULL 13/60] QemuMutex: support --enable-debug-mutex, Paolo Bonzini, 2018/06/28
- [Qemu-devel] [PULL 12/60] qemu-thread: introduce qemu-thread-common.h, Paolo Bonzini, 2018/06/28
- [Qemu-devel] [PULL 10/60] kvm: Delete the slot if and only if the KVM_MEM_READONLY flag is changed, Paolo Bonzini, 2018/06/28
- [Qemu-devel] [PULL 11/60] tests/atomic_add-bench: add -m option to use mutexes, Paolo Bonzini, 2018/06/28
- [Qemu-devel] [PULL 17/60] pc-dimm: remove leftover "struct pc_dimms_capacity", Paolo Bonzini, 2018/06/28
- [Qemu-devel] [PULL 15/60] Replace '-enable-kvm' with '-accel kvm' in docs and help texts, Paolo Bonzini, 2018/06/28
- [Qemu-devel] [PULL 18/60] pc: rename pc_dimm_(plug|unplug|...)* into pc_memory_(plug|unplug|...)*, Paolo Bonzini, 2018/06/28
- [Qemu-devel] [PULL 21/60] pc: factor out pc specific dimm checks into pc_memory_pre_plug(), Paolo Bonzini, 2018/06/28
- [Qemu-devel] [PULL 14/60] configure: enable debug-mutex if debug enabled, Paolo Bonzini, 2018/06/28