|
|
b1a050a |
From 6be8f5e2626e102433e569d9cece2120baf0c879 Mon Sep 17 00:00:00 2001
|
|
|
b1a050a |
From: Prasad J Pandit <pjp@fedoraproject.org>
|
|
|
b1a050a |
Date: Mon, 24 Oct 2016 16:26:54 +0100
|
|
|
b1a050a |
Subject: [PATCH] timer: a9gtimer: remove loop to auto-increment comparator
|
|
|
b1a050a |
|
|
|
b1a050a |
ARM A9MP processor has a peripheral timer with an auto-increment
|
|
|
b1a050a |
register, which holds an increment step value. A user could set
|
|
|
b1a050a |
this value to zero. When auto-increment control bit is enabled,
|
|
|
b1a050a |
it leads to an infinite loop in 'a9_gtimer_update' while
|
|
|
b1a050a |
updating comparator value. Remove this loop incrementing the
|
|
|
b1a050a |
comparator value.
|
|
|
b1a050a |
|
|
|
b1a050a |
Reported-by: Li Qiang <liqiang6-s@360.cn>
|
|
|
b1a050a |
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
|
|
|
b1a050a |
Message-id: 1476733226-11635-1-git-send-email-ppandit@redhat.com
|
|
|
b1a050a |
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
|
|
|
b1a050a |
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
|
|
|
b1a050a |
---
|
|
|
b1a050a |
hw/timer/a9gtimer.c | 14 +++++++-------
|
|
|
b1a050a |
1 files changed, 7 insertions(+), 7 deletions(-)
|
|
|
b1a050a |
|
|
|
b1a050a |
diff --git a/hw/timer/a9gtimer.c b/hw/timer/a9gtimer.c
|
|
|
b1a050a |
index 772f85f..ce1dc63 100644
|
|
|
b1a050a |
--- a/hw/timer/a9gtimer.c
|
|
|
b1a050a |
+++ b/hw/timer/a9gtimer.c
|
|
|
b1a050a |
@@ -82,15 +82,15 @@ static void a9_gtimer_update(A9GTimerState *s, bool sync)
|
|
|
b1a050a |
if ((s->control & R_CONTROL_TIMER_ENABLE) &&
|
|
|
b1a050a |
(gtb->control & R_CONTROL_COMP_ENABLE)) {
|
|
|
b1a050a |
/* R2p0+, where the compare function is >= */
|
|
|
b1a050a |
- while (gtb->compare < update.new) {
|
|
|
b1a050a |
+ if (gtb->compare < update.new) {
|
|
|
b1a050a |
DB_PRINT("Compare event happened for CPU %d\n", i);
|
|
|
b1a050a |
gtb->status = 1;
|
|
|
b1a050a |
- if (gtb->control & R_CONTROL_AUTO_INCREMENT) {
|
|
|
b1a050a |
- DB_PRINT("Auto incrementing timer compare by %" PRId32 "\n",
|
|
|
b1a050a |
- gtb->inc);
|
|
|
b1a050a |
- gtb->compare += gtb->inc;
|
|
|
b1a050a |
- } else {
|
|
|
b1a050a |
- break;
|
|
|
b1a050a |
+ if (gtb->control & R_CONTROL_AUTO_INCREMENT && gtb->inc) {
|
|
|
b1a050a |
+ uint64_t inc =
|
|
|
b1a050a |
+ QEMU_ALIGN_UP(update.new - gtb->compare, gtb->inc);
|
|
|
b1a050a |
+ DB_PRINT("Auto incrementing timer compare by %"
|
|
|
b1a050a |
+ PRId64 "\n", inc);
|
|
|
b1a050a |
+ gtb->compare += inc;
|
|
|
b1a050a |
}
|
|
|
b1a050a |
}
|
|
|
b1a050a |
cdiff = (int64_t)gtb->compare - (int64_t)update.new + 1;
|
|
|
b1a050a |
--
|
|
|
b1a050a |
1.7.0.4
|
|
|
b1a050a |
|