qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "J. Mayer" <l_indien@magic.fr>
To: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [Bug] Timer bugs in hw/m48t59.c?
Date: Mon, 24 Sep 2007 22:25:17 +0200	[thread overview]
Message-ID: <1190665518.30193.6.camel@rapid> (raw)
In-Reply-To: <46F7F2B6.2080105@mail.berlios.de>

[-- Attachment #1: Type: text/plain, Size: 955 bytes --]

On Mon, 2007-09-24 at 19:24 +0200, Stefan Weil wrote:
> Hello,

Hi,

> the bug mentioned in my previous mail is still open.
> Could someone please add the patch to CVS HEAD
> (or find another solution)?

Seems you're right, this code would lead to crashes. I think there are
other issues to address in the same code because alrm_timer and wd_timer
are always NULL if the RTC model is a m48t08.
Could you please take a look at this updated patch ?

Regards.

> 
> Thank you
> Stefan
> 
> Stefan Weil schrieb:
> > Hi,
> >
> > could SPARC or PPC users please check whether the timer code
> > in hw/m48t59.c is really correct?
> >
> > I expect a crash in qemu_mod_timer after wd_timer = NULL and
> > a call to qemu_mod_timer with this NULL value.
> >
> > The same applies to alrm_timer.
> >
> > I wrote a quick-and-dirty patch, but think that even more
> > old code could be removed.
> >
> > Stefan
> >
[...]

-- 
J. Mayer <l_indien@magic.fr>
Never organized

[-- Attachment #2: m48t59.c.diff --]
[-- Type: text/x-patch, Size: 1483 bytes --]

Index: hw/m48t59.c
===================================================================
RCS file: /sources/qemu/qemu/hw/m48t59.c,v
retrieving revision 1.14
diff -u -d -d -p -r1.14 m48t59.c
--- hw/m48t59.c	17 Sep 2007 08:09:47 -0000	1.14
+++ hw/m48t59.c	24 Sep 2007 20:24:01 -0000
@@ -161,10 +161,9 @@ static void set_alarm (m48t59_t *NVRAM, 
     NVRAM->alarm = mktime(tm);
     if (NVRAM->alrm_timer != NULL) {
         qemu_del_timer(NVRAM->alrm_timer);
-	NVRAM->alrm_timer = NULL;
+        if (NVRAM->alarm - time(NULL) > 0)
+            qemu_mod_timer(NVRAM->alrm_timer, NVRAM->alarm * 1000);
     }
-    if (NVRAM->alarm - time(NULL) > 0)
-	qemu_mod_timer(NVRAM->alrm_timer, NVRAM->alarm * 1000);
 }
 
 /* Watchdog management */
@@ -188,15 +187,14 @@ static void set_up_watchdog (m48t59_t *N
 {
     uint64_t interval; /* in 1/16 seconds */
 
+    NVRAM->buffer[0x1FF0] &= ~0x80;
     if (NVRAM->wd_timer != NULL) {
         qemu_del_timer(NVRAM->wd_timer);
-	NVRAM->wd_timer = NULL;
-    }
-    NVRAM->buffer[0x1FF0] &= ~0x80;
-    if (value != 0) {
-	interval = (1 << (2 * (value & 0x03))) * ((value >> 2) & 0x1F);
-	qemu_mod_timer(NVRAM->wd_timer, ((uint64_t)time(NULL) * 1000) +
-		       ((interval * 1000) >> 4));
+        if (value != 0) {
+            interval = (1 << (2 * (value & 0x03))) * ((value >> 2) & 0x1F);
+            qemu_mod_timer(NVRAM->wd_timer, ((uint64_t)time(NULL) * 1000) +
+                           ((interval * 1000) >> 4));
+        }
     }
 }
 

      reply	other threads:[~2007-09-24 20:25 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-22 20:42 [Qemu-devel] [Bug] Timer bugs in hw/m48t59.c? Stefan Weil
2007-03-23 20:20 ` Blue Swirl
2007-09-24 17:24 ` Stefan Weil
2007-09-24 20:25   ` J. Mayer [this message]

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=1190665518.30193.6.camel@rapid \
    --to=l_indien@magic.fr \
    --cc=qemu-devel@nongnu.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).