diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2025-05-26 14:49:13 +0200 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2025-06-06 14:32:54 +0200 |
commit | 14b5a799339d2d21826eac5ab1e98d00b1f1f89f (patch) | |
tree | fdc3c254f7f404912db13ccd6f2ccf5da80c4e8f | |
parent | 6e85cfe44c0e0311d6395526a064eb5af761a879 (diff) | |
download | qemu-14b5a799339d2d21826eac5ab1e98d00b1f1f89f.zip qemu-14b5a799339d2d21826eac5ab1e98d00b1f1f89f.tar.gz qemu-14b5a799339d2d21826eac5ab1e98d00b1f1f89f.tar.bz2 |
hpet: return errors from realize if properties are incorrect
Do not silently adjust num_timers, and fail if intcap is 0.
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r-- | hw/timer/hpet.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/hw/timer/hpet.c b/hw/timer/hpet.c index 9db027c..cb48cc1 100644 --- a/hw/timer/hpet.c +++ b/hw/timer/hpet.c @@ -691,8 +691,14 @@ static void hpet_realize(DeviceState *dev, Error **errp) int i; HPETTimer *timer; + if (s->num_timers < HPET_MIN_TIMERS || s->num_timers > HPET_MAX_TIMERS) { + error_setg(errp, "hpet.num_timers must be between %d and %d", + HPET_MIN_TIMERS, HPET_MAX_TIMERS); + return; + } if (!s->intcap) { - warn_report("Hpet's intcap not initialized"); + error_setg(errp, "hpet.hpet-intcap not initialized"); + return; } if (hpet_fw_cfg.count == UINT8_MAX) { /* first instance */ @@ -700,7 +706,7 @@ static void hpet_realize(DeviceState *dev, Error **errp) } if (hpet_fw_cfg.count == 8) { - error_setg(errp, "Only 8 instances of HPET is allowed"); + error_setg(errp, "Only 8 instances of HPET are allowed"); return; } @@ -710,11 +716,6 @@ static void hpet_realize(DeviceState *dev, Error **errp) sysbus_init_irq(sbd, &s->irqs[i]); } - if (s->num_timers < HPET_MIN_TIMERS) { - s->num_timers = HPET_MIN_TIMERS; - } else if (s->num_timers > HPET_MAX_TIMERS) { - s->num_timers = HPET_MAX_TIMERS; - } for (i = 0; i < HPET_MAX_TIMERS; i++) { timer = &s->timer[i]; timer->qemu_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, hpet_timer, timer); |