[PATCH v5 4/5] HV: Use NMI to replace INIT signal for lapic-pt VMs S5


Kaige Fu
 

We have implemented a new notification method using NMI.
So replace the INIT notification method with the NMI one.
Then we can remove INIT notification related code later.

Signed-off-by: Kaige Fu <kaige.fu@...>
---
hypervisor/arch/x86/guest/vmcs.c | 7 ++++---
hypervisor/common/schedule.c | 4 ++--
hypervisor/include/common/schedule.h | 1 +
3 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/hypervisor/arch/x86/guest/vmcs.c b/hypervisor/arch/x86/guest/vmcs.c
index 7dd2d806..a125e2de 100644
--- a/hypervisor/arch/x86/guest/vmcs.c
+++ b/hypervisor/arch/x86/guest/vmcs.c
@@ -606,10 +606,11 @@ void switch_apicv_mode_x2apic(struct acrn_vcpu *vcpu)
update_msr_bitmap_x2apic_passthru(vcpu);

/*
- * After passthroughing lapic to guest, we should use INIT signal to
- * notify vcpu thread instead of IPI
+ * After passthroughing lapic to guest, we should use NMI signal to
+ * notify vcpu thread instead of IPI. Because the IPI will be delivered
+ * the guest directly without vmexit.
*/
- vcpu->thread_obj.notify_mode = SCHED_NOTIFY_INIT;
+ vcpu->thread_obj.notify_mode = SCHED_NOTIFY_NMI;
} else {
value32 = exec_vmread32(VMX_PROC_VM_EXEC_CONTROLS2);
value32 &= ~VMX_PROCBASED_CTLS2_VAPIC;
diff --git a/hypervisor/common/schedule.c b/hypervisor/common/schedule.c
index da6c785b..73a6eda0 100644
--- a/hypervisor/common/schedule.c
+++ b/hypervisor/common/schedule.c
@@ -202,8 +202,8 @@ void sleep_thread(struct thread_object *obj)
scheduler->sleep(obj);
}
if (is_running(obj)) {
- if (obj->notify_mode == SCHED_NOTIFY_INIT) {
- make_reschedule_request(pcpu_id, DEL_MODE_INIT);
+ if (obj->notify_mode == SCHED_NOTIFY_NMI) {
+ make_reschedule_request(pcpu_id, DEL_MODE_NMI);
} else {
make_reschedule_request(pcpu_id, DEL_MODE_IPI);
}
diff --git a/hypervisor/include/common/schedule.h b/hypervisor/include/common/schedule.h
index 164e3441..809be686 100644
--- a/hypervisor/include/common/schedule.h
+++ b/hypervisor/include/common/schedule.h
@@ -26,6 +26,7 @@ enum thread_object_state {

enum sched_notify_mode {
SCHED_NOTIFY_INIT,
+ SCHED_NOTIFY_NMI,
SCHED_NOTIFY_IPI
};

--
2.20.0

Join acrn-dev@lists.projectacrn.org to automatically receive all group messages.