[PATCH v4 3/8] HV: Add helper function send_single_nmi


Kaige Fu
 

This patch adds a helper function send_single_nmi. The fisrt caller
will soon come with the following patch.

Acked-by: Eddie Dong <eddie.dong@...>
Signed-off-by: Kaige Fu <kaige.fu@...>
---
hypervisor/arch/x86/lapic.c | 15 +++++++++++++++
hypervisor/include/arch/x86/lapic.h | 9 +++++++++
2 files changed, 24 insertions(+)

diff --git a/hypervisor/arch/x86/lapic.c b/hypervisor/arch/x86/lapic.c
index c06daaab..a54cb067 100644
--- a/hypervisor/arch/x86/lapic.c
+++ b/hypervisor/arch/x86/lapic.c
@@ -288,3 +288,18 @@ void send_single_init(uint16_t pcpu_id)

msr_write(MSR_IA32_EXT_APIC_ICR, icr.value);
}
+
+/**
+ * @pre pcpu_id < CONFIG_MAX_PCPU_NUM
+ *
+ * @return None
+ */
+void send_single_nmi(uint16_t pcpu_id)
+{
+ union apic_icr icr;
+
+ icr.value_32.hi_32 = per_cpu(lapic_id, pcpu_id);
+ icr.value_32.lo_32 = (INTR_LAPIC_ICR_PHYSICAL << 11U) | (INTR_LAPIC_ICR_NMI << 8U);
+
+ msr_write(MSR_IA32_EXT_APIC_ICR, icr.value);
+}
diff --git a/hypervisor/include/arch/x86/lapic.h b/hypervisor/include/arch/x86/lapic.h
index 5e490b8c..9b59c21d 100644
--- a/hypervisor/include/arch/x86/lapic.h
+++ b/hypervisor/include/arch/x86/lapic.h
@@ -183,4 +183,13 @@ void send_single_ipi(uint16_t pcpu_id, uint32_t vector);
*/
void send_single_init(uint16_t pcpu_id);

+/**
+ * @brief Send an NMI signal to a single pCPU
+ *
+ * @param[in] pcpu_id The id of destination physical cpu
+ *
+ * @return None
+ */
+void send_single_nmi(uint16_t pcpu_id);
+
#endif /* INTR_LAPIC_H */
--
2.20.0

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