summary refs log tree commit diff stats
path: root/hw/arm/virt.c
diff options
context:
space:
mode:
authorDmitry Osipenko <digetx@gmail.com>2016-06-06 16:59:30 +0100
committerPeter Maydell <peter.maydell@linaro.org>2016-06-06 16:59:30 +0100
commite91171e30235ae99ab8060988aa3c9536692bba8 (patch)
tree1195474d5a8dd172bcb37f505f4c0a2518b53936 /hw/arm/virt.c
parent2a0ee672c9f0a13fd0535d831366670561b4586e (diff)
downloadfocaccia-qemu-e91171e30235ae99ab8060988aa3c9536692bba8.tar.gz
focaccia-qemu-e91171e30235ae99ab8060988aa3c9536692bba8.zip
hw/ptimer: Fix issues caused by the adjusted timer limit value
Multiple issues here related to the timer with a adjusted .limit value:

1) ptimer_get_count() returns incorrect counter value for the disabled
timer after loading the counter with a small value, because adjusted limit
value is used instead of the original.

For instance:
    1) ptimer_stop(t)
    2) ptimer_set_period(t, 1)
    3) ptimer_set_limit(t, 0, 1)
    4) ptimer_get_count(t) <-- would return 10000 instead of 0

2) ptimer_get_count() might return incorrect value for the timer running
with a adjusted limit value.

For instance:
    1) ptimer_stop(t)
    2) ptimer_set_period(t, 1)
    3) ptimer_set_limit(t, 10, 1)
    4) ptimer_run(t)
    5) ptimer_get_count(t) <-- might return value > 10

3) Neither ptimer_set_period() nor ptimer_set_freq() are adjusting the
limit value, so it is still possible to make timer timeout value
arbitrary small.

For instance:
    1) ptimer_set_period(t, 10000)
    2) ptimer_set_limit(t, 1, 0)
    3) ptimer_set_period(t, 1) <-- bypass limit correction

Fix all of the above issues by adjusting timer period instead of the limit.
Perform the adjustment for periodic timer only. Use the delta value instead
of the limit to make decision whether adjustment is required, as limit could
be altered while timer is running, resulting in incorrect value returned by
ptimer_get_count.

Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Reviewed-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>
Message-id: cd141f74f5737480ec586b9c7d18cce1d69884e2.1464367869.git.digetx@gmail.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'hw/arm/virt.c')
0 files changed, 0 insertions, 0 deletions