|
From: | Paolo Bonzini |
Subject: | Re: [PATCH] hw/timer: fix int underflow |
Date: | Tue, 14 Jan 2025 11:40:06 +0100 |
User-agent: | Mozilla Thunderbird |
On 1/14/25 11:14, Peter Maydell wrote:
I would say that the patch is more or less obvious in the sense that the intent of the code is to model a counter (which counts up by 1 and cannot miss a step) with a timer within a process that could be preempted. You probably will not find an answer in the datasheet, other than by analyzing the signal diagrams, because this scenario simply cannot exist with a hardware counter.So, to my opinion, explicit cast to "long long" is necessary here to get the expected behavior.I wasn't saying the existing code was necessarily correct, or that your proposed change was necessarily wrong. I was saying your patch didn't come with any analysis of what the actual hardware behaviour is, which is how you would determine whether the fix you propose is the correct one, or if it should be some other change instead. (Some of my response was trying to provide some of that analysis.)
However, the patch has another problem, which is that it can cause a stack overflow at imx_gpt_compute_next_timeout(s, event).
Paolo
[Prev in Thread] | Current Thread | [Next in Thread] |