Skip to content

Commit

Permalink
hv: vm_event: send RTC change event in hv vRTC
Browse files Browse the repository at this point in the history
This patch adds support for HV vrtc vm_event.

RTC change event is sent upon each date/time reg write. Those events
will be handled in DM. DM will try to emit an RTC change event(to
Libvirt) based on its strategy. Only support post-launched VMs.

The DM event handler has already implemented the rtc chanage event.
Those events will be processed the same way as vrtc events from DM vrtc.

Tracked-On: projectacrn#8547
Signed-off-by: Wu Zhou <wu.zhou@intel.com>
Reviewed-by: Junjie Mao <junjie.mao@intel.com>
  • Loading branch information
izhouwu committed Jan 19, 2024
1 parent ac6505c commit 7c837eb
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions hypervisor/dm/vrtc.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <asm/tsc.h>
#include <vrtc.h>
#include <logmsg.h>
#include <vm_event.h>

#include "mc146818rtc.h"

Expand Down Expand Up @@ -549,6 +550,8 @@ static bool vrtc_write(struct acrn_vcpu *vcpu, uint16_t addr, size_t width,
struct acrn_vrtc *vrtc = &vcpu->vm->vrtc;
struct acrn_vrtc temp_vrtc;
uint8_t mask = 0xFFU;
struct vm_event rtc_chg_event;
struct rtc_change_event_data *edata = (struct rtc_change_event_data *)rtc_chg_event.event_data;

if ((width == 1U) && (addr == CMOS_ADDR_PORT)) {
vrtc->addr = (uint8_t)(value & 0x7FU);
Expand Down Expand Up @@ -595,6 +598,12 @@ static bool vrtc_write(struct acrn_vcpu *vcpu, uint16_t addr, size_t width,
vrtc->offset_rtctime += after - current;
vrtc->last_rtctime = VRTC_BROKEN_TIME;
spinlock_release(&vrtc_rebase_lock);
if (is_postlaunched_vm(vcpu->vm) && vrtc_is_time_register(vrtc->addr)) {
rtc_chg_event.type = VM_EVENT_RTC_CHG;
edata->delta_time = after - current;
edata->last_time = current;
send_vm_event(vcpu->vm, &rtc_chg_event);
}
break;
}
}
Expand Down

0 comments on commit 7c837eb

Please sign in to comment.