From: Jan Kiszka <jan.kis...@siemens.com> Make sure we are not silently rounding down or even wrapping around, causing inconsistencies with the provided image.
Signed-off-by: Jan Kiszka <jan.kis...@siemens.com> --- hw/sd/sd.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 16aee210b4..834392b0a8 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -2818,6 +2818,16 @@ static void sd_realize(DeviceState *dev, Error **errp) } blk_set_dev_ops(sd->blk, &sd_block_ops, sd); } + if (sd->boot_part_size % (128 * KiB) || + sd->boot_part_size > 255 * 128 * KiB) { + char *size_str = size_to_str(sd->boot_part_size); + + error_setg(errp, "Invalid boot partition size: %s", size_str); + g_free(size_str); + error_append_hint(errp, + "The boot partition size must be multiples of 128K" + "and not larger than 32640K.\n"); + } } static void emmc_realize(DeviceState *dev, Error **errp) -- 2.43.0