[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 07/13] hw/core/machine: diagnose wrapping of maxmem
From: |
Philippe Mathieu-Daudé |
Subject: |
[PULL 07/13] hw/core/machine: diagnose wrapping of maxmem |
Date: |
Tue, 3 Dec 2024 12:31:34 +0100 |
From: Daniel P. Berrangé <berrange@redhat.com>
The 'maxmem' parameter parsed on the command line is held in uint64_t
and then assigned to the MachineState field that is 'ram_addr_t'. This
assignment will wrap on 32-bit hosts, silently changing the user's
config request if it were over-sized.
Improve the existing diagnositics for validating 'size', and add the
same diagnostics for 'maxmem'
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Tested-by: Ani Sinha <anisinha@redhat.com>
Reviewed-by: Ani Sinha <anisinha@redhat.com>
Message-ID: <20241127114057.255995-1-berrange@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/core/machine.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/hw/core/machine.c b/hw/core/machine.c
index a35c4a8faec..f29fe959647 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -598,11 +598,19 @@ static void machine_set_mem(Object *obj, Visitor *v,
const char *name,
mem->size = mc->fixup_ram_size(mem->size);
}
if ((ram_addr_t)mem->size != mem->size) {
- error_setg(errp, "ram size too large");
+ error_setg(errp, "ram size %llu exceeds permitted maximum %llu",
+ (unsigned long long)mem->size,
+ (unsigned long long)RAM_ADDR_MAX);
goto out_free;
}
if (mem->has_max_size) {
+ if ((ram_addr_t)mem->max_size != mem->max_size) {
+ error_setg(errp, "ram size %llu exceeds permitted maximum %llu",
+ (unsigned long long)mem->max_size,
+ (unsigned long long)RAM_ADDR_MAX);
+ goto out_free;
+ }
if (mem->max_size < mem->size) {
error_setg(errp, "invalid value of maxmem: "
"maximum memory size (0x%" PRIx64 ") must be at least "
--
2.45.2
- [PULL 00/13] Misc fixes for 2024-12-03, Philippe Mathieu-Daudé, 2024/12/03
- [PULL 01/13] hw/openrisc: Fixed undercounting of TTCR in continuous mode, Philippe Mathieu-Daudé, 2024/12/03
- [PULL 02/13] hw/openrisc/openrisc_sim: keep serial@90000000 as default, Philippe Mathieu-Daudé, 2024/12/03
- [PULL 03/13] ui/cocoa: Temporarily ignore annoying deprecated declaration warnings, Philippe Mathieu-Daudé, 2024/12/03
- [PULL 04/13] MAINTAINERS: add myself as the maintainer for LoongArch VirtMachine, Philippe Mathieu-Daudé, 2024/12/03
- [PULL 05/13] meson: Add missing SDL dependency to system/main.c, Philippe Mathieu-Daudé, 2024/12/03
- [PULL 06/13] MAINTAINERS: update email addr for Brian Cain, Philippe Mathieu-Daudé, 2024/12/03
- [PULL 07/13] hw/core/machine: diagnose wrapping of maxmem,
Philippe Mathieu-Daudé <=
- [PULL 08/13] target/riscv: Avoid bad shift in riscv_cpu_do_interrupt(), Philippe Mathieu-Daudé, 2024/12/03
- [PULL 09/13] hw/display/vga: Do not reset 'big_endian_fb' in vga_common_reset(), Philippe Mathieu-Daudé, 2024/12/03
- [PULL 10/13] hw/virtio: fix crash in processing balloon stats, Philippe Mathieu-Daudé, 2024/12/03
- [PULL 11/13] tests/qtest: drop 'fuzz-' prefix from virtio-balloon test, Philippe Mathieu-Daudé, 2024/12/03
- [PULL 12/13] tests/qtest: add test for querying balloon guest stats, Philippe Mathieu-Daudé, 2024/12/03
- [PULL 13/13] system: Select HVF by default when no other accelerator is available, Philippe Mathieu-Daudé, 2024/12/03
- Re: [PULL 00/13] Misc fixes for 2024-12-03, Peter Maydell, 2024/12/03