From owner-svn-src-head@freebsd.org Fri Jul 24 20:52:10 2020 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B92CB373AD5; Fri, 24 Jul 2020 20:52:10 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4BD1bZ4XD7z4Gwj; Fri, 24 Jul 2020 20:52:10 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7FEFD1043E; Fri, 24 Jul 2020 20:52:10 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 06OKqA44019926; Fri, 24 Jul 2020 20:52:10 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 06OKqAg2019924; Fri, 24 Jul 2020 20:52:10 GMT (envelope-from mav@FreeBSD.org) Message-Id: <202007242052.06OKqAg2019924@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 24 Jul 2020 20:52:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r363495 - in head/sys/x86: include x86 X-SVN-Group: head X-SVN-Commit-Author: mav X-SVN-Commit-Paths: in head/sys/x86: include x86 X-SVN-Commit-Revision: 363495 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Jul 2020 20:52:10 -0000 Author: mav Date: Fri Jul 24 20:52:09 2020 New Revision: 363495 URL: https://svnweb.freebsd.org/changeset/base/363495 Log: 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. MFC after: 2 weeks Sponsored by: iXsystems, Inc. Modified: head/sys/x86/include/x86_smp.h head/sys/x86/x86/mp_x86.c Modified: head/sys/x86/include/x86_smp.h ============================================================================== --- head/sys/x86/include/x86_smp.h Fri Jul 24 20:48:06 2020 (r363494) +++ head/sys/x86/include/x86_smp.h Fri Jul 24 20:52:09 2020 (r363495) @@ -97,6 +97,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: head/sys/x86/x86/mp_x86.c ============================================================================== --- head/sys/x86/x86/mp_x86.c Fri Jul 24 20:48:06 2020 (r363494) +++ head/sys/x86/x86/mp_x86.c Fri Jul 24 20:52:09 2020 (r363495) @@ -1398,6 +1398,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) {