[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Stable-8.2.9 33/45] s390x/s390-virtio-ccw: don't crash on weird RAM siz
From: |
Michael Tokarev |
Subject: |
[Stable-8.2.9 33/45] s390x/s390-virtio-ccw: don't crash on weird RAM sizes |
Date: |
Mon, 27 Jan 2025 23:26:14 +0300 |
KVM is not happy when starting a VM with weird RAM sizes:
# qemu-system-s390x --enable-kvm --nographic -m 1234K
qemu-system-s390x: kvm_set_user_memory_region: KVM_SET_USER_MEMORY_REGION
failed, slot=0, start=0x0, size=0x244000: Invalid argument
kvm_set_phys_mem: error registering slot: Invalid argument
Aborted (core dumped)
Let's handle that in a better way by rejecting such weird RAM sizes
right from the start:
# qemu-system-s390x --enable-kvm --nographic -m 1234K
qemu-system-s390x: ram size must be multiples of 1 MiB
Message-ID: <20241219144115.2820241-2-david@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Eric Farman <farman@linux.ibm.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Acked-by: Janosch Frank <frankja@linux.ibm.com>
Signed-off-by: David Hildenbrand <david@redhat.com>
(cherry picked from commit 14e568ab4836347481af2e334009c385f456a734)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
index 2d6b86624f..d31686e105 100644
--- a/hw/s390x/s390-virtio-ccw.c
+++ b/hw/s390x/s390-virtio-ccw.c
@@ -184,6 +184,17 @@ static void s390_memory_init(MemoryRegion *ram)
{
MemoryRegion *sysmem = get_system_memory();
+ if (!QEMU_IS_ALIGNED(memory_region_size(ram), 1 * MiB)) {
+ /*
+ * SCLP cannot possibly expose smaller granularity right now and KVM
+ * cannot handle smaller granularity. As we don't support NUMA, the
+ * region size directly corresponds to machine->ram_size, and the
region
+ * is a single RAM memory region.
+ */
+ error_report("ram size must be multiples of 1 MiB");
+ exit(EXIT_FAILURE);
+ }
+
/* allocate RAM for core */
memory_region_add_subregion(sysmem, 0, ram);
--
2.39.5
- [Stable-8.2.9 19/45] target/riscv: Avoid bad shift in riscv_cpu_do_interrupt(), (continued)
- [Stable-8.2.9 19/45] target/riscv: Avoid bad shift in riscv_cpu_do_interrupt(), Michael Tokarev, 2025/01/28
- [Stable-8.2.9 22/45] .gitlab-ci.d/cirrus: Drop support for macOS 13 (Ventura), Michael Tokarev, 2025/01/28
- [Stable-8.2.9 25/45] fuzz: specify audiodev for usb-audio, Michael Tokarev, 2025/01/28
- [Stable-8.2.9 24/45] tcg/riscv: Fix StoreStore barrier generation, Michael Tokarev, 2025/01/28
- [Stable-8.2.9 26/45] x86/loader: only patch linux kernels, Michael Tokarev, 2025/01/28
- [Stable-8.2.9 27/45] edk2: get version + date from git submodule, Michael Tokarev, 2025/01/28
- [Stable-8.2.9 28/45] edk2: commit version info, Michael Tokarev, 2025/01/28
- [Stable-8.2.9 30/45] hw/intc/arm_gicv3_its: Zero initialize local DTEntry etc structs, Michael Tokarev, 2025/01/28
- [Stable-8.2.9 29/45] roms: re-add edk2-basetools target, Michael Tokarev, 2025/01/28
- [Stable-8.2.9 31/45] meson.build: Disallow libnfs v6 to fix the broken macOS build, Michael Tokarev, 2025/01/28
- [Stable-8.2.9 33/45] s390x/s390-virtio-ccw: don't crash on weird RAM sizes,
Michael Tokarev <=
- [Stable-8.2.9 32/45] vhost-user: fix shared object return values, Michael Tokarev, 2025/01/28
- [Stable-8.2.9 35/45] docs: Correct release of TCG trace-events removal, Michael Tokarev, 2025/01/28
- [Stable-8.2.9 34/45] target/loongarch: Use actual operand size with vbsrl check, Michael Tokarev, 2025/01/28
- [Stable-8.2.9 37/45] tests/qtest/boot-serial-test: Correct HPPA machine name, Michael Tokarev, 2025/01/28
- [Stable-8.2.9 36/45] target/i386/cpu: Fix notes for CPU models, Michael Tokarev, 2025/01/28
- [Stable-8.2.9 41/45] pci/msix: Fix msix pba read vector poll end calculation, Michael Tokarev, 2025/01/28
- [Stable-8.2.9 38/45] backends/cryptodev-vhost-user: Fix local_error leaks, Michael Tokarev, 2025/01/28
- [Stable-8.2.9 42/45] tests: acpi: whitelist expected blobs, Michael Tokarev, 2025/01/28
- [Stable-8.2.9 39/45] hw/usb/hcd-xhci-pci: Use modulo to select MSI vector as per spec, Michael Tokarev, 2025/01/28
- [Stable-8.2.9 45/45] hw/cxl: Fix msix_notify: Assertion `vector < dev->msix_entries_nr`, Michael Tokarev, 2025/01/28