From: Chao Liu <chao.liu.zevorn@gmail.com>
To: Jay Chang <jay.chang@sifive.com>
Cc: qemu-devel@nongnu.org, qemu-riscv@nongnu.org,
Palmer Dabbelt <palmer@dabbelt.com>,
Alistair Francis <alistair.francis@wdc.com>,
Weiwei Li <liwei1518@gmail.com>,
Daniel Henrique Barboza <daniel.barboza@oss.qualcomm.com>,
Liu Zhiwei <zhiwei_liu@linux.alibaba.com>,
Frank Chang <frank.chang@sifive.com>
Subject: Re: [PATCH 1/2] hw/riscv/riscv-iommu-hpm: Fix irq_overflow_left residual value bug
Date: Wed, 4 Mar 2026 21:20:22 +0800 [thread overview]
Message-ID: <aagxUh_cFPSKvUtZ@ZEVORN-PC.localdomain> (raw)
In-Reply-To: <20260304040959.47267-2-jay.chang@sifive.com>
On Wed, Mar 04, 2026 at 12:09:58PM +0800, Jay Chang wrote:
> Reset irq_overflow_left to 0 before setting up a new timer. Without
> this fix, a stale irq_overflow_left value from a previous timer setup
> could cause incorrect timer behavior.
>
> Signed-off-by: Jay Chang <jay.chang@sifive.com>
> Reviewed-by: Frank Chang <frank.chang@sifive.com>
> ---
> hw/riscv/riscv-iommu-hpm.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/hw/riscv/riscv-iommu-hpm.c b/hw/riscv/riscv-iommu-hpm.c
> index c5034bff79..e8d284ac8b 100644
> --- a/hw/riscv/riscv-iommu-hpm.c
> +++ b/hw/riscv/riscv-iommu-hpm.c
> @@ -228,6 +228,7 @@ static void hpm_setup_timer(RISCVIOMMUState *s, uint64_t value)
> }
>
> overflow_at = (uint64_t)qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + overflow_ns;
> + s->irq_overflow_left = 0;
>
Looks good. Without this reset, if a previous call set
irq_overflow_left (overflow_at > INT64_MAX) and the current
call does NOT overflow, the stale value persists and the
two-phase timer fires incorrectly.
Reviewed-by: Chao Liu <chao.liu.zevorn@gmail.com>
Best regards,
Chao Liu
> if (overflow_at > INT64_MAX) {
> s->irq_overflow_left = overflow_at - INT64_MAX;
> --
> 2.48.1
>
next prev parent reply other threads:[~2026-03-04 13:21 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-04 4:09 [PATCH 0/2] hw/riscv/riscv-iommu: Bug fixes and IPSR.PMIP support Jay Chang
2026-03-04 4:09 ` [PATCH 1/2] hw/riscv/riscv-iommu-hpm: Fix irq_overflow_left residual value bug Jay Chang
2026-03-04 13:20 ` Chao Liu [this message]
2026-03-04 4:09 ` [PATCH 2/2] hw/riscv/riscv-iommu: Add IPSR.PMIP RW1C support Jay Chang
2026-03-04 10:13 ` Nutty.Liu
2026-03-04 13:29 ` Chao Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aagxUh_cFPSKvUtZ@ZEVORN-PC.localdomain \
--to=chao.liu.zevorn@gmail.com \
--cc=alistair.francis@wdc.com \
--cc=daniel.barboza@oss.qualcomm.com \
--cc=frank.chang@sifive.com \
--cc=jay.chang@sifive.com \
--cc=liwei1518@gmail.com \
--cc=palmer@dabbelt.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-riscv@nongnu.org \
--cc=zhiwei_liu@linux.alibaba.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.