From 2777f230757636d191d7b822b056bb8a74d8e58b Mon Sep 17 00:00:00 2001 From: Kaige Fu Date: Thu, 5 Dec 2019 16:27:37 +0000 Subject: [PATCH] HV: Add helper function send_single_nmi This patch adds a helper function send_single_nmi. The fisrt caller will soon come with the following patch. Tracked-On: #3886 Acked-by: Eddie Dong Signed-off-by: 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 200833cc0..732036ecd 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 5e490b8c4..9b59c21d4 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 */