[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-trivial] [PATCH] hw/timer/armv7m_systick: Fix default system_
From: |
Philippe Mathieu-Daudé |
Subject: |
Re: [Qemu-trivial] [PATCH] hw/timer/armv7m_systick: Fix default system_clock_scale. Resolves SIGFPE divide by zero. |
Date: |
Thu, 2 Nov 2017 00:31:57 -0300 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 |
Hi Domen,
Please have a look at the Contribute/SubmitAPatch guidelines for QEMU,
in particular about CC'ing the maintainers so your patch won't get lost:
https://wiki.qemu.org/Contribute/SubmitAPatch#CC_the_relevant_maintainer
$ ./scripts/get_maintainer.pl -f hw/timer/armv7m_systick.c
Peter Maydell <address@hidden> (maintainer:ARM cores)
address@hidden (open list:ARM cores)
^ Cc'ing them how.
On 11/01/2017 05:59 PM, Domen Puncer Kugler wrote:
> Fix default system_clock_scale. Resolves SIGFPE divide by zero.
>
> Netduino platform code does not provide a way to set
> system_clock_scale, so it remains 0.
> This causes a divide by zero, when emulated code asks systick for
> current timer value:
> (s->tick - (t + 1)) / systick_scale(s)) + 1;
> Patch fixes this by providing a default value.
See the thread around this reply:
http://lists.nongnu.org/archive/html/qemu-devel/2017-06/msg06678.html
>
> Also replaces a magic number an with already defined constant:
> #define SYSTICK_SCALE 1000ULL
>
>
> Signed-off-by: Domen Puncer Kugler <address@hidden>
> ---
>
> diff --git a/hw/timer/armv7m_systick.c b/hw/timer/armv7m_systick.c
> index df8d2804b3..651f8030a8 100644
> --- a/hw/timer/armv7m_systick.c
> +++ b/hw/timer/armv7m_systick.c
> @@ -25,15 +25,15 @@
> #define SYSTICK_CLKSOURCE (1 << 2)
> #define SYSTICK_COUNTFLAG (1 << 16)
>
> -int system_clock_scale;
> +uint64_t system_clock_scale = SYSTICK_SCALE;
>
> /* Conversion factor from qemu timer to SysTick frequencies. */
> -static inline int64_t systick_scale(SysTickState *s)
> +static inline uint64_t systick_scale(SysTickState *s)
> {
> if (s->control & SYSTICK_CLKSOURCE) {
> return system_clock_scale;
> } else {
> - return 1000;
> + return SYSTICK_SCALE;
> }
> }
>
Regards,
Phil.