Skip to content

Commit a503fdc

Browse files
KaigeFuwenlingz
authored andcommitted
HV: Fix poweroff issue of hard RTVM
We should use INIT signal to notify the vcpu threads when powering off the hard RTVM. To achive this, we should set the vcpu->thread_obj.notify_mode as SCHED_NOTIFY_INIT. Patch (27163df hv: sched: add sleep/wake for thread object) tries to set the notify_mode according `is_lapic_pt_enabled(vcpu)` in function prepare_vcpu. But at this point, the is_lapic_pt_enabled(vcpu) will always return false. Consequently, it will set notify_mode as SCHED_NOTIFY_IPI. Then leads to the failure of powering off hard RTVM. This patch fixes it by: - Initialize the notify_mode as SCHED_NOTIFY_IPI in prepare_vcpu. - Set the notify_mode as SCHED_NOTIFY_INIT after passthroughing lapic to guest. Tracked-On: #3974 Signed-off-by: Kaige Fu <kaige.fu@intel.com>
1 parent 5ca26d3 commit a503fdc

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

hypervisor/arch/x86/guest/vcpu.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -758,8 +758,7 @@ int32_t prepare_vcpu(struct acrn_vm *vm, uint16_t pcpu_id)
758758
vcpu->thread_obj.sched_ctl = &per_cpu(sched_ctl, pcpu_id);
759759
vcpu->thread_obj.thread_entry = vcpu_thread;
760760
vcpu->thread_obj.pcpu_id = pcpu_id;
761-
vcpu->thread_obj.notify_mode = is_lapic_pt_enabled(vcpu) ?
762-
SCHED_NOTIFY_INIT : SCHED_NOTIFY_IPI;
761+
vcpu->thread_obj.notify_mode = SCHED_NOTIFY_IPI;
763762
vcpu->thread_obj.host_sp = build_stack_frame(vcpu);
764763
vcpu->thread_obj.switch_out = context_switch_out;
765764
vcpu->thread_obj.switch_in = context_switch_in;

hypervisor/arch/x86/guest/vmcs.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,12 @@ void switch_apicv_mode_x2apic(struct acrn_vcpu *vcpu)
599599
exec_vmwrite32(VMX_PROC_VM_EXEC_CONTROLS2, value32);
600600

601601
update_msr_bitmap_x2apic_passthru(vcpu);
602+
603+
/*
604+
* After passthroughing lapic to guest, we should use INIT signal to
605+
* notify vcpu thread instead of IPI
606+
*/
607+
vcpu->thread_obj.notify_mode = SCHED_NOTIFY_INIT;
602608
} else {
603609
value32 = exec_vmread32(VMX_PROC_VM_EXEC_CONTROLS2);
604610
value32 &= ~VMX_PROCBASED_CTLS2_VAPIC;

0 commit comments

Comments
 (0)