Il 15/06/2012 17:38, [email protected] 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
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html