[PATCH v5 0/8] add vRTC write emulate

Zhao, Yuanyuan

Now ACRN would emulate vRTC for non-RT pre-launched VM, RTVM and
Service VM.
For vRTC read, ACRN would only return the the physical RTC register value;
for vRTC write, ACRN would ignore it.

New implement is:
1. Service OS read and write physical RTC.
2. The initial vRTC of each VM will is same with physical RTC, i.e. the RTC of service VM.
3. Guest VM can re-program its RTC (thu NTP etc.), but the update of guest RTC will be
emulated by Hypervisor through 'offset_rtctime'.
4. Service VM will update physical RTC. So, if the system shuts down, hypervisor can rely
on #2 for each VM to get right initial RTC (sync with real NTP), without saving the “offset_rtctime”.
5. A calibration of vrtc will trigger by timer every 3 hours to keep
6. When write the physical RTC, will reset the 'offset_rtctime' of each
guest VM.

1. [1/8] 'vrtc_set_basetime' change byte array to 'struct rtcdev' ptr.
2. [3/8] Remove space.
3. [4/8][5/8] Commit message.
4. [6/8] 'vrtc_read' switch case '0' to 'RTC_SEC'.
5. [7/8] 'calibrate_lock' --> 'vrtc_rebase_lock'.

1. Add a calibrate_lock.
2. Split reg_b and reg_c patch.
3. Other commits in v3.

1. Remove Servcie VM pass through, add read & write for it in HV.
2. Add periodical calibation of vrtc.
3. When set RTC time, reset offset of vrtc.


1. Change name of 'mc146818rtc.h'.
2. Add cover letter.
3. Use unsigned int in time transform.
4. Split patches in a new way.

Yuanyuan Zhao (8):
hv: add `rtcdev` emulate vrtc
hv: support vrtc BCD data mode
hv: support 12 hour mode
hv: add vRTC reg_b and reg_c support
hv: add Service VM write physical RTC register
hv: add time modification of vrtc
hv: vrtc calibrate function
hv: calibrate vrtc when modify physical time

hypervisor/dm/vrtc.c | 635 ++++++++++++++++++++-
hypervisor/include/arch/x86/asm/guest/vm.h | 3 +-
hypervisor/include/dm/mc146818rtc.h | 72 +++
hypervisor/include/dm/vrtc.h | 44 ++
4 files changed, 742 insertions(+), 12 deletions(-)
create mode 100644 hypervisor/include/dm/mc146818rtc.h
create mode 100644 hypervisor/include/dm/vrtc.h