aboutsummaryrefslogtreecommitdiffstats
path: root/xen/arch/x86/hvm/rtc.c
Commit message (Collapse)AuthorAgeFilesLines
* x86/HVM: RTC code must be in line with WAET flags passed by hvmloaderJan Beulich2013-05-211-4/+15
| | | | | | | | | | | | With hvmloader telling the guest that it may skip REG_C reads during the processing of RTC interrupts, the emulation code must not depend upon these reads to occur. Introduce two modes of operation for the emulation code, and short of a HVM parameter (too late to be introduced for 4.3) hard code the mode determination to always assume that Windows-conforming one for the time being. Signed-off-by: Jan Beulich <jbeulich@suse.com> Tested-by: Roger Pau Monné <roger.pau@citrix.com> (FreeBSD guest)
* x86/HVM: properly handle RTC periodic timer even when !RTC_PIEJan Beulich2013-05-211-1/+7
| | | | | | | | | Since in that case the processing it pt_intr_post() won't occur, we need to do some additional work in pt_update_irq(). Additionally we must not pay attention to the respective IRQ being masked. Signed-off-by: Jan Beulich <jbeulich@suse.com> Tested-by: Roger Pau Monné <roger.pau@citrix.com> (FreeBSD guest)
* x86/HVM: adjust IRQ (de-)assertionJan Beulich2013-05-211-13/+11
| | | | | | | | | De-assertion should only happen when RTC_IRQF gets cleared, i.e. upon REG_C reads. Assertion should be done only when the flag transitions from 0 to 1. Signed-off-by: Jan Beulich <jbeulich@suse.com> Tested-by: Roger Pau Monné <roger.pau@citrix.com> (FreeBSD guest)
* x86/HVM: fix processing of RTC REG_B writesJan Beulich2013-05-021-1/+3
| | | | | | | | | | | | | | | | | We must store the new values before calling rtc_update_irq(), and we need to call rtc_timer_update() when PIE transitions from 0 to 1 (as we may have previously turned off the periodic timer due to the guest not reading REG_C, and hence may have to re-enable it in order to start IRQs getting delivered to the guest). Note that the timer is being kept running if PIE transitions from 1 to 0, to match the behavior of keeping it running for a brief period of time if the guest doesn't clear PF in time (in order to avoid permanently destroying and re-creating the periodic timer). Signed-off-by: Jan Beulich <jbeulich@suse.com> Tested-by: Roger Pau Monné <roger.pau@citrix.com> (FreeBSD guest) Reviewed-by: Tim Deegan <tim@xen.org>
* x86/hvm: Centralize and simplify the RTC IRQ logic.Tim Deegan2013-03-291-20/+20
| | | | | | | | | | | | This keeps the behaviour of strobing the IRQ line every time any RTC interrupt source is raised. I rather suspect (based on the behaviour of the MC146818A RTC) that we ought to be suppressing all subsequent interrupts whenever RTC_IRQF is set, but this way avoids making guest-visible changes. Signed-off-by: Tim Deegan <tim@xen.org> Acked-by: Jan Beulich <jbeulich@suse.com> Acked-by: Keir Fraser <keir@xen.org>
* x86/hvm: Let the guest miss a few ticks before resetting the timer.Tim Deegan2013-03-291-6/+9
| | | | | | Signed-off-by: Tim Deegan <tim@xen.org> Acked-by: Jan Beulich <jbeulich@suse.com> Acked-by: Keir Fraser <keir@xen.org>
* x86/hvm: Avoid needlessly resetting the periodic timer.Tim Deegan2013-03-291-4/+14
| | | | | | Signed-off-by: Tim Deegan <tim@xen.org> Acked-by: Jan Beulich <jbeulich@suse.com> Acked-by: Keir Fraser <keir@xen.org>
* x86/hvm: Run the RTC periodic timer on a consistent time series.Tim Deegan2013-03-291-2/+4
| | | | | | | | | | When the RTC periodic timer gets restarted, align it to the VM's boot time, not to whatever time it is now. Otherwise every read of REG_C will restart the current period Signed-off-by: Tim Deegan <tim@xen.org> Acked-by: Keir Fraser <keir@xen.org> Acked-by: Jan Beulich <jbeulich@suse.com>
* x86/HVM: assorted RTC emulation adjustmentsJan Beulich2013-02-051-8/+18
| | | | | | | | | | | | | - only call check_update_timer() on REG_B writes when SET changes - only call alarm_timer_update() on REG_B writes when relevant bits change - instead properly handle AF and PF when the guest is not also setting AIE/PIE respectively (for UF this was already the case, only a comment was slightly inaccurate), including calling the respective update functions upon REG_C reads Signed-off-by: Jan Beulich <jbeulich@suse.com> Tested-by: Olaf Hering <olaf@aepfle.de>
* x86/HVM: generalize IRQ raising on RTC_REG_B writesJan Beulich2013-01-231-5/+10
| | | | | | | | Raise the RTC IRQ not only when UIE gets set while UF was already set, but generalize this to cover AIE and PIE as well. Signed-off-by: Jan Beulich <jbeulich@suse.com> Acked-by: Keir Fraser <keir@xen.org>
* x86/HVM: use cached original value in RTC_REG_B writing codeJan Beulich2013-01-231-3/+3
| | | | | Signed-off-by: Jan Beulich <jbeulich@suse.com> Acked-by: Keir Fraser <keir@xen.org>
* x86/HVM: fix RTC hour conversionsJan Beulich2013-01-231-8/+7
| | | | | | | | | Properly mask off bit 7 when retrieving the hour values in alarm_timer_update(), and properly use RTC_HOURS_ALARM's bit 7 when converting from 12- to 24-hour value. Signed-off-by: Jan Beulich <jbeulich@suse.com> Acked-by: Keir Fraser <keir@xen.org>
* x86/HVM: adjust rtc_timer_update()Jan Beulich2013-01-231-12/+17
| | | | | | | | | | Don't look at RTC_PIE in rtc_timer_update(), and hence don't call the function on REG_B writes at all. Also handle the two other possible clock bases. Signed-off-by: Jan Beulich <jbeulich@suse.com> Acked-by: Keir Fraser <keir@xen.org>
* x86/HVM: consolidate toggling of RTC IRQJan Beulich2013-01-231-14/+13
| | | | | | | | Note that in the RTC_UIE/RTC_UF case, this also fixes the lack of setting RTC_IRQF. Signed-off-by: Jan Beulich <jbeulich@suse.com> Acked-by: Keir Fraser <keir@xen.org>
* x86/HVM: use RTC_* names instead of literal numbersJan Beulich2013-01-231-3/+4
| | | | | Signed-off-by: Jan Beulich <jbeulich@suse.com> Acked-by: Keir Fraser <keir@xen.org>
* x86/hvm: fix RTC setting.Tim Deegan2013-01-181-3/+10
| | | | | | | | | | When the guest writes one field of the RTC time, we must bring all the other fields up to date for the current second before calculating the new RTC time. Signed-off-by: Tim Deegan <tim@xen.org> Tested-by: Phil Evans <Phil.Evans@m247.com> Committed-by: Jan Beulich <jbeulich@suse.com>
* Revert 25843:51090fe1ab97 (x86/HVM: assorted RTC emulation adjustments)Jan Beulich2012-09-121-61/+50
| | | | This was found to cause RHEL6 HVM guests to hang during shutdown.
* x86/HVM: assorted RTC emulation adjustmentsJan Beulich2012-09-111-50/+61
| | | | | | | | | | | | | | | | | | | | | | - don't look at RTC_PIE in rtc_timer_update(), and hence don't call the function on REG_B writes at all - only call alarm_timer_update() on REG_B writes when relevant bits change - only call check_update_timer() on REG_B writes when SET changes - instead properly handle AF and PF when the guest is not also setting AIE/PIE respectively (for UF this was already the case, only a comment was slightly inaccurate) - raise the RTC IRQ not only when UIE gets set while UF was already set, but generalize this to cover AIE and PIE as well - properly mask off bit 7 when retrieving the hour values in alarm_timer_update(), and properly use RTC_HOURS_ALARM's bit 7 when converting from 12- to 24-hour value - also handle the two other possible clock bases - use RTC_* names in a couple of places where literal numbers were used so far Signed-off-by: Jan Beulich <jbeulich@suse.com> Acked-by: Keir Fraser <keir@xen.org>
* x86/HVM: RTC periodic timer emulation adjustmentsJan Beulich2012-09-031-4/+7
| | | | | | | | | | | - don't call rtc_timer_update() on REG_A writes when the value didn't change (doing the call always was reported to cause wall clock time lagging with the JVM running on Windows) - don't call rtc_timer_update() on REG_B writes when RTC_PIE didn't change Signed-off-by: Jan Beulich <jbeulich@suse.com> Acked-by: Keir Fraser <keir@xen.org>
* RTC: Add alarm supportYang Zhang2012-03-071-2/+214
| | | | | | | | Use a timer to emulate update cycle. The timer runs only when AIE is set. Signed-off-by: Yang Zhang <yang.z.zhang@Intel.com> Committed-by: Keir Fraser <keir@xen.org>
* RTC: Add RTC update-ended interrupt supportYang Zhang2012-03-071-2/+102
| | | | | | | | Use a timer to emulate update cycle. When update cycle ended and UIE is set, raise an interrupt. The timer runs only when AF is cleared. Signed-off-by: Yang Zhang <yang.z.zhang@Intel.com> Committed-by: Keir Fraser <keir@xen.org>
* RTC: Add UIP(update in progress) check logicYang Zhang2012-03-071-0/+20
| | | | | | | | The UIP(update in progress) is set when RTC is in updating. And the update cycle begins 244us later after UIP is set. Signed-off-by: Yang Zhang <yang.z.zhang@Intel.com> Committed-by: Keir Fraser <keir@xen.org>
* RTC: fix 12-hour modeYang Zhang2012-03-071-4/+16
| | | | | | | Hours in 12-hour mode are in the 1-12 range, not 0-11. Signed-off-by: Yang Zhang <yang.z.zhang@Intel.com> Committed-by: Keir Fraser <keir@xen.org>
* RTC: use offset to caculate rtc clockYang Zhang2012-03-071-163/+17
| | | | | | | | There has no need to run two periodic timer to update RTC time. Use the offset instead. Signed-off-by: Yang Zhang <yang.z.zhang@Intel.com> Committed-by: Keir Fraser <keir@xen.org>
* hvm: correct RTC time offset update error due to tm->tm_yearAnnie Li2012-03-011-3/+5
| | | | | | | | | tm->tm_year in rtc.c is year number offsetting from 1900. So it is necessary to add the offset 1900 when calling mktime funtion in Xen. Otherwise, the calculation result of mktime is incorrect. Signed-off-by: Annie Li <annie.li@oracle.com> Committed-by: Keir Fraser <keir@xen.org>
* x86 hvm: Fix build error with some GCC versions.Keir Fraser2010-06-101-2/+2
| | | | Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
* Add a safety valve to the HVM RTC model for big time jumpsKeir Fraser2010-06-041-0/+13
| | | | | | | | | | | | | If xen's time leaps forward by a large amount, the RTC will try to model a tick for every second that it thinks has passed. This can livelock a CPU with a series of timer requests each of which fires immediately and requests the next one. This patch treats a delay of more than a day between ticks as a special case, abandoning the attempt to catch up. That should be good enough to avoid livelock but doesn't fix the underlying time problem. Signed-off-by: Tim Deegan <Tim.Deegan@citrix.com>
* hvm: correct time offset update in RTC write emulationKeir Fraser2010-03-091-2/+2
| | | | | | | | | mktime takes a month in 1..12 form while tm->tm_mon contains 0..11 so we need to add 1. Without this fix setting the month back or forward a month inside the guest would lead to the wrong number of days being added/subtracted. Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
* x86 hvm: Use 'x' as parameter name for macros converting betweenKeir Fraser2009-07-081-5/+5
| | | | | | | {vcpu,domain} and {vlapic,vpic,vrtc,hpet}. Completely avoids accidental aliasing. Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
* x86,hvm: Allow delivery of timer interrupts to VCPUs != 0Keir Fraser2009-07-071-1/+1
| | | | | | | This patch is needed for kexec/kdump since VCPU#0 is halted. Signed-off-by: Kouya Shimura <kouya@jp.fujitsu.com> Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
* Actually set a HVM domain's time offset when it sets the RTCKeir Fraser2009-03-181-0/+7
| | | | Signed-off-by: Tim Deegan <Tim.Deegan@citrix.com>
* Port HPET device model to vpt timer subsystemKeir Fraser2008-10-221-2/+2
| | | | | | | | | | | | | | | | | | | | | The current hpet implementation runs a one-shot xen timer for each hpet timer whenever the main counter is enabled regardless of whether or not the individual hpet timers are enabled. When the timer fires, if it is enabled the interrupt is routed to the guest. If the hpet timer is periodic, a new one-shot timer is set, for NOW()+period. There are a number of problems with this the most significant is guest time drift. Windows does not read the hardware clock to verify time, it depends on timer interrupts firing at the expected interval. The existing implementation queues a new one-shot timer each time it fires and does not allow for a difference between NOW() and the time the timer was expected to fire, causing drift. Also there is no allowance for lost ticks. This modification changes HPET to use the Virtual Platform Timer (VPT) and, for periodic timers, to use periodic timers. The VPT ensures an interrupt is delivered to the guest for each period that elapses, plus, its use of xen periodic timers ensures no drift. Signed-off-by: Peter Johnston <peter.johnston@citrix.com>
* x86 hvm: Fix RTC handling.Keir Fraser2008-07-021-26/+27
| | | | | | 1. Clean up initialisation/destruction. 2. Better handle per-domain time-offset changes. Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
* x86 hvm: Xen interface and implementation for virtual S3Keir Fraser2008-05-201-0/+6
| | | | | | | Signed-off-by: Tian Kevin <kevin.tian@intel.com> Signed-off-by: Yu Ke <ke.yu@intel.com> Signed-off-by: Ke Liping <liping.ke@intel.com> Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
* x86, hvm: I/O emulation handlers return X86EMUL_* return codes.Keir Fraser2008-04-151-4/+4
| | | | Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
* hvm: Improve in-Xen PIO emulation to better handle string PIOKeir Fraser2008-01-121-5/+6
| | | | | instructions. Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
* hvm: Reduce vpt.c dependencies on external timer details.Keir Fraser2007-12-121-8/+2
| | | | Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
* hvm: RTC emulation - RTC_UIE/RTC_SET fixKeir Fraser2007-11-161-2/+1
| | | | | | | | | | | | | | | | | This patch fixes a bug in the RTC code which appears to originate in having written the emuated device following an incorrect specification. VMware has (or had, at least, at the time we were still testing on both VMWare and Xen) the same issue. In the current code, when RTC_SET is set, RTC_UIE is cleared. This does not match the behavior of real hardware, where the case is simply that no update ended interrupts are sent as long as RTC_SET is set, but the UE ints will resume as soon as RTC_SET is cleared and the clock update is done. This little patch fixes this issue. In practicality, this means OS/2 can now set the time without having the clock stop. I don't know if any other guests have been affected by this issue. From: Trolle Selander <trolle.selander@gmail.com> Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
* hvm: Add locking to platform timers.Keir Fraser2007-06-151-6/+52
| | | | | Handy for correctness. Signed-off-by: Keir Fraser <keir@xensource.com>
* hvm: Simplify timer<->vcpu/domain conversion in RTC and PIT timerKeir Fraser2007-06-151-27/+35
| | | | | | models. These timers are always bound to vcpu0, where a specific vcpu matters. Signed-off-by: Keir Fraser <keir@xensource.com>
* hvm: Timer device model cleanups.kfraser@localhost.localdomain2007-06-141-37/+30
| | | | Signed-off-by: Keir Fraser <keir@xensource.com>
* [hvm] Keep track of time offset between domain time and dom0 time.Christian Limpach2007-04-031-0/+8
| | | | | | | | | | On each rtc time update from the hvm domain, we send an ioreq request to qemu which then updates the time offset xenstore entry. The time offset is preserved across reboot and can be set on domain creation by setting the rtc_timeoffset variable in a config file. From: Andrei Petrov <andrei.petrov@xensource.com> Signed-off-by: Christian Limpach <Christian.Limpach@xensource.com>
* [xen] Update the hvm rtc clock state if the domain's time offset is changed.Christian Limpach2007-03-081-2/+13
| | | | | | | The settimeoffset domctl had no effect on hvm domains since the offset was only read in rtc_init which is done when the domain is created. Signed-off-by: Christian Limpach <Christian.Limpach@xensource.com>
* [HVM] Save/restore: dynamically calculate the size of the save bufferTim Deegan2007-02-071-1/+1
| | | | Signed-off-by: Tim Deegan <Tim.Deegan@xensource.com>
* [HVM] Save/restore: save RTC state.Tim Deegan2007-01-311-77/+108
| | | | Signed-off-by: Tim Deegan <Tim.Deegan@xensource.com>
* [HVM] save restore: save restore dev in HVTim Deegan2007-01-181-1/+1
| | | | | | Signed-off-by: Zhai Edwin <edwin.zhai@intel.com> save/restore all dev state in HV such as PIT/PIC/APIC
* [HVM] Enable more than one platform timer (PIT/RTC/HPET)kfraser@localhost.localdomain2006-12-201-43/+29
| | | | | | | | | | | programmed as periodic timer and adds them to abstract layer, which keeps track of pending_intr_nr to avoid time interrupt lost and sync'ed timer with TSC. It also makes some cleanup to the time related code. Signed-off-by: Xiaowei Yang <xiaowei.yang@intel.com> Signed-off-by: Yunhong Jiang <yunhong.jiang@intel.com>
* [HVM] Fix bugs in RTC alarm code.kfraser@localhost.localdomain2006-11-271-3/+6
| | | | | | | - comparing bcd with binary data - comparing min with mon Signed-off-by: Xiaowei Yang <xiaowei.yang@intel.com>
* [HVM] Reworked interrupt distribution logic.kfraser@localhost.localdomain2006-11-211-131/+141
| | | | | | | | | | | | | TODO: 1. Fix IO-APIC ID to not conflict with LAPIC IDS. 2. Fix i8259 device model (seems to work already though!). 3. Add INTSRC overrides in MPBIOS and ACPI tables so that PCI legacy IRQ routing always ends up at an IO-APIC input with level trigger. Restricting link routing to {5,6,10,11} and setting overrides for all four of those would work. Signed-off-by: Keir Fraser <keir@xensource.com>
* [HVM] Decouple the RTC from the PIT periodic timerTim Deegan2006-11-161-26/+56
| | | | Signed-off-by: Tim Deegan <Tim.Deegan@xensource.com>