kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* UIP flag not cleared
       [not found] <2097433711.249908057.1339773258139.JavaMail.root@spooler3-g27.priv.proxad.net>
@ 2012-06-15 15:38 ` nicolas.ochem
  2012-07-03 13:28   ` Paolo Bonzini
  0 siblings, 1 reply; 2+ messages in thread
From: nicolas.ochem @ 2012-06-15 15:38 UTC (permalink / raw)
  To: kvm

Hi list, 


I am having troubles porting my os to qemu/kvm environment. It's about the RTC (real-time clock) 

There is a flag (UIP flag) which is supposed to show when RTC can be read or not. 

We wait 10ms for that flag to be cleared, but sometimes it's not enough with qemu/kvm. 

Is it necessary to check this flag at all ? or can I always read the RTC regardless of the status of the flag ? If the latter is true, why then is this flag not always clear ? 

I'm using the virtualization stack of centos 6.2 

Thanks in advance 

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: UIP flag not cleared
  2012-06-15 15:38 ` UIP flag not cleared nicolas.ochem
@ 2012-07-03 13:28   ` Paolo Bonzini
  0 siblings, 0 replies; 2+ messages in thread
From: Paolo Bonzini @ 2012-07-03 13:28 UTC (permalink / raw)
  To: nicolas.ochem; +Cc: kvm

Il 15/06/2012 17:38, nicolas.ochem@free.fr ha scritto:
> Hi list,
> 
> 
> I am having troubles porting my os to qemu/kvm environment. It's
> about the RTC (real-time clock)
> 
> There is a flag (UIP flag) which is supposed to show when RTC can be
> read or not.
> 
> We wait 10ms for that flag to be cleared, but sometimes it's not
> enough with qemu/kvm.

You need to wait more than 10ms then. :(  This will be fixed in QEMU
1.2, but you cannot rule out delays due to bad scheduling of the virtual
machine monitor (aka QEMU itself).

> Is it necessary to check this flag at all ? or can I always read the
> RTC regardless of the status of the flag ? If the latter is true, why
> then is this flag not always clear ?

Unlike real hardware, QEMU updates the time atomically; there are no
"invalid states" during the update of the RTC.  However, _reads_ of the
RTC are not atomic so you do need UIP.  UIP triggers 220 us *before* the
invalid state, so that if UIP=0 you have 220 us to read the RTC.  If
your reads take less than 220 us, they are guaranteed to be atomic.

If you need a workaround you can do the following (but it will break on
bare metal):

    old_UIP = UIP
    read RTC
    if old_UIP = 1 and UIP = 0
        read RTC again

i.e. accept the old read if both old_UIP and UIP are 1 (and of course if
old_UIP was 0).

Paolo

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-07-03 13:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <2097433711.249908057.1339773258139.JavaMail.root@spooler3-g27.priv.proxad.net>
2012-06-15 15:38 ` UIP flag not cleared nicolas.ochem
2012-07-03 13:28   ` Paolo Bonzini

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).