[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 23/24] hw/timer/npcm7xx_timer: Prevent timer from counting down pa
|
From: |
Peter Maydell |
|
Subject: |
[PULL 23/24] hw/timer/npcm7xx_timer: Prevent timer from counting down past zero |
|
Date: |
Thu, 19 Oct 2023 14:35:36 +0100 |
From: Chris Rauer <crauer@google.com>
The counter register is only 24-bits and counts down. If the timer is
running but the qtimer to reset it hasn't fired off yet, there is a chance
the regster read can return an invalid result.
Signed-off-by: Chris Rauer <crauer@google.com>
Message-id: 20230922181411.2697135-1-crauer@google.com
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
hw/timer/npcm7xx_timer.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/hw/timer/npcm7xx_timer.c b/hw/timer/npcm7xx_timer.c
index 32f5e021f85..a8bd93aeb2c 100644
--- a/hw/timer/npcm7xx_timer.c
+++ b/hw/timer/npcm7xx_timer.c
@@ -138,6 +138,9 @@ static int64_t npcm7xx_timer_count_to_ns(NPCM7xxTimer *t,
uint32_t count)
/* Convert a time interval in nanoseconds to a timer cycle count. */
static uint32_t npcm7xx_timer_ns_to_count(NPCM7xxTimer *t, int64_t ns)
{
+ if (ns < 0) {
+ return 0;
+ }
return clock_ns_to_ticks(t->ctrl->clock, ns) /
npcm7xx_tcsr_prescaler(t->tcsr);
}
--
2.34.1
- [PULL 01/24] hw/arm: Move raspberrypi-fw-defs.h to the include/hw/arm/ folder, (continued)
- [PULL 01/24] hw/arm: Move raspberrypi-fw-defs.h to the include/hw/arm/ folder, Peter Maydell, 2023/10/19
- [PULL 02/24] hw/arm/exynos4210: Get arm_boot_info declaration from 'hw/arm/boot.h', Peter Maydell, 2023/10/19
- [PULL 12/24] hw/arm/sbsa-ref: use bsa.h for PPI definitions, Peter Maydell, 2023/10/19
- [PULL 14/24] arm/kvm: convert to kvm_get_one_reg, Peter Maydell, 2023/10/19
- [PULL 11/24] include/hw/arm: move BSA definitions to bsa.h, Peter Maydell, 2023/10/19
- [PULL 07/24] elf2dmp: limit print length for sign_rsds, Peter Maydell, 2023/10/19
- [PULL 09/24] target/arm: Fix CNTPCT_EL0 trapping from EL0 when HCR_EL2.E2H is 0, Peter Maydell, 2023/10/19
- [PULL 10/24] {include/}hw/arm: refactor virt PPI logic, Peter Maydell, 2023/10/19
- [PULL 13/24] arm/kvm: convert to kvm_set_one_reg, Peter Maydell, 2023/10/19
- [PULL 21/24] target/arm/common-semi-target.h: Remove unnecessary boot.h include, Peter Maydell, 2023/10/19
- [PULL 23/24] hw/timer/npcm7xx_timer: Prevent timer from counting down past zero,
Peter Maydell <=
- [PULL 16/24] hw/arm/smmuv3: Update ID register bit field definitions, Peter Maydell, 2023/10/19
- [PULL 17/24] hw/arm/smmuv3: Sort ID register setting into field order, Peter Maydell, 2023/10/19
- [PULL 24/24] contrib/elf2dmp: Use g_malloc(), g_new() and g_free(), Peter Maydell, 2023/10/19
- [PULL 18/24] hw/arm/smmuv3: Advertise SMMUv3.1-XNX feature, Peter Maydell, 2023/10/19
- [PULL 19/24] target/arm: Implement FEAT_HPMN0, Peter Maydell, 2023/10/19
- [PULL 03/24] xlnx-bbram: hw/nvram: Remove deprecated device reset, Peter Maydell, 2023/10/19
- [PULL 04/24] xlnx-zynqmp-efuse: hw/nvram: Remove deprecated device reset, Peter Maydell, 2023/10/19
- [PULL 05/24] xlnx-versal-efuse: hw/nvram: Remove deprecated device reset, Peter Maydell, 2023/10/19
- [PULL 06/24] xlnx-bbram: hw/nvram: Use dot in device type name, Peter Maydell, 2023/10/19
- [PULL 08/24] elf2dmp: check array bounds in pdb_get_file_size, Peter Maydell, 2023/10/19