Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 7 Aug 2020 00:33:28 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org
Subject:   svn commit: r363999 - in stable/12/sys/x86: include x86
Message-ID:  <202008070033.0770XShW054768@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Fri Aug  7 00:33:28 2020
New Revision: 363999
URL: https://svnweb.freebsd.org/changeset/base/363999

Log:
  MFC r363495: Introduce ipi_self_from_nmi().
  
  It allows safe IPI sending to current CPU from NMI context.
  
  Unlike other ipi_*() functions this waits for delivery to leave LAPIC in
  a state safe for interrupted code.

Modified:
  stable/12/sys/x86/include/x86_smp.h
  stable/12/sys/x86/x86/mp_x86.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/x86/include/x86_smp.h
==============================================================================
--- stable/12/sys/x86/include/x86_smp.h	Fri Aug  7 00:26:16 2020	(r363998)
+++ stable/12/sys/x86/include/x86_smp.h	Fri Aug  7 00:33:28 2020	(r363999)
@@ -101,6 +101,7 @@ void 	ipi_bitmap_handler(struct trapframe frame);
 void	ipi_cpu(int cpu, u_int ipi);
 int	ipi_nmi_handler(void);
 void	ipi_selected(cpuset_t cpus, u_int ipi);
+void	ipi_self_from_nmi(u_int vector);
 void	set_interrupt_apic_ids(void);
 void	smp_cache_flush(smp_invl_cb_t curcpu_cb);
 void	smp_masked_invlpg(cpuset_t mask, vm_offset_t addr, struct pmap *pmap,

Modified: stable/12/sys/x86/x86/mp_x86.c
==============================================================================
--- stable/12/sys/x86/x86/mp_x86.c	Fri Aug  7 00:26:16 2020	(r363998)
+++ stable/12/sys/x86/x86/mp_x86.c	Fri Aug  7 00:33:28 2020	(r363999)
@@ -1350,6 +1350,21 @@ ipi_all_but_self(u_int ipi)
 	lapic_ipi_vectored(ipi, APIC_IPI_DEST_OTHERS);
 }
 
+void
+ipi_self_from_nmi(u_int vector)
+{
+
+	lapic_ipi_vectored(vector, APIC_IPI_DEST_SELF);
+
+	/* Wait for IPI to finish. */
+	if (!lapic_ipi_wait(50000)) {
+		if (KERNEL_PANICKED())
+			return;
+		else
+			panic("APIC: IPI is stuck");
+	}
+}
+
 int
 ipi_nmi_handler(void)
 {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202008070033.0770XShW054768>