From nobody Thu Mar 28 17:44:56 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1602838458; cv=none; d=zohomail.com; s=zohoarc; b=IfZTUQhFte6DbU5gPF5LhIRZmbyXKvV/L/R+0Ous7oiqWd3Q+9gaL6SJoag/HexZyDzmOk8S3XByoTlah5W1S998pTjiUX4jSTILyKusNsLLPimoiQJmhodHLhxGFkvQhWrqNunbm0yZ+AFn01SAhqRKNb4kUmbcipfJ1ZR3de8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602838458; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=zyQ6eY76TMGPa8WVIau7vgU5vO2lNHpIxzzWhjQGo/o=; b=ACLnGeg1TNf+pKdkIZY1NZ/31EsUTWyspA9tdAsojxCq3iaVJMuY5mfUnuoUpsHYoiQnXk0kAbemXVW5mXRfzdKawtcUibA8wcvzP/Rb/uL9IF7cYEw9oEHl4bHC0Y6oMHCfbldfiS8kzsWiMV+bQIiMoUvSRw0d+tXse+6tLVc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1602838458134997.2431326580174; Fri, 16 Oct 2020 01:54:18 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.7831.20635 (Exim 4.92) (envelope-from ) id 1kTLUu-0002GS-Kh; Fri, 16 Oct 2020 08:54:00 +0000 Received: by outflank-mailman (output) from mailman id 7831.20635; Fri, 16 Oct 2020 08:54:00 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kTLUu-0002GL-Gi; Fri, 16 Oct 2020 08:54:00 +0000 Received: by outflank-mailman (input) for mailman id 7831; Fri, 16 Oct 2020 08:53:59 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kTLUt-0002Cr-6S for xen-devel@lists.xenproject.org; Fri, 16 Oct 2020 08:53:59 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 0514ee4d-f27f-4eec-91c8-876f51d5a0c1; Fri, 16 Oct 2020 08:53:53 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 92038ADE8; Fri, 16 Oct 2020 08:53:52 +0000 (UTC) Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kTLUt-0002Cr-6S for xen-devel@lists.xenproject.org; Fri, 16 Oct 2020 08:53:59 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 0514ee4d-f27f-4eec-91c8-876f51d5a0c1; Fri, 16 Oct 2020 08:53:53 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 92038ADE8; Fri, 16 Oct 2020 08:53:52 +0000 (UTC) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 0514ee4d-f27f-4eec-91c8-876f51d5a0c1 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1602838432; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zyQ6eY76TMGPa8WVIau7vgU5vO2lNHpIxzzWhjQGo/o=; b=BZLrBXjW2NcVN4gnBUmmQWXJtGnOha8usIRFFMsQ2VKj+cEPtjvMRMe+WLRCvluBZBmLsv Mii/naLC/ClGU3oocMpFgwxQ7VGuXUPGEGb2b5Fvpx+5gFEimK2aYGzlnT9/rxIA/zVZIY MIeL9jIWDa6bq+svRUamZlH99qnEcUM= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu Subject: [PATCH v3 1/3] xen/x86: add nmi continuation framework Date: Fri, 16 Oct 2020 10:53:48 +0200 Message-Id: <20201016085350.10233-2-jgross@suse.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201016085350.10233-1-jgross@suse.com> References: <20201016085350.10233-1-jgross@suse.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) Actions in NMI context are rather limited as e.g. locking is rather fragile. Add a generic framework to continue processing in normal interrupt context after leaving NMI processing. This is done by a high priority interrupt vector triggered via a self IPI from NMI context, which will then call the continuation function specified during NMI handling. Signed-off-by: Juergen Gross --- V2: - add prototype for continuation function (Roger Pau Monn=C3=A9) - switch from softirq to explicit self-IPI (Jan Beulich) --- xen/arch/x86/apic.c | 13 +++++++--- xen/arch/x86/traps.c | 52 +++++++++++++++++++++++++++++++++++++++ xen/include/asm-x86/nmi.h | 13 +++++++++- 3 files changed, 74 insertions(+), 4 deletions(-) diff --git a/xen/arch/x86/apic.c b/xen/arch/x86/apic.c index 60627fd6e6..7497ddb5da 100644 --- a/xen/arch/x86/apic.c +++ b/xen/arch/x86/apic.c @@ -40,6 +40,7 @@ #include #include #include +#include #include =20 static bool __read_mostly tdt_enabled; @@ -1376,16 +1377,22 @@ void spurious_interrupt(struct cpu_user_regs *regs) { /* * Check if this is a vectored interrupt (most likely, as this is prob= ably - * a request to dump local CPU state). Vectored interrupts are ACKed; - * spurious interrupts are not. + * a request to dump local CPU state or to continue NMI handling). + * Vectored interrupts are ACKed; spurious interrupts are not. */ if (apic_isr_read(SPURIOUS_APIC_VECTOR)) { + bool is_spurious; + ack_APIC_irq(); + is_spurious =3D !nmi_check_continuation(); if (this_cpu(state_dump_pending)) { this_cpu(state_dump_pending) =3D false; dump_execstate(regs); - return; + is_spurious =3D false; } + + if ( !is_spurious ) + return; } =20 /* see sw-dev-man vol 3, chapter 7.4.13.5 */ diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c index bc5b8f8ea3..6f4db9d549 100644 --- a/xen/arch/x86/traps.c +++ b/xen/arch/x86/traps.c @@ -79,6 +79,7 @@ #include #include #include +#include #include #include =20 @@ -1799,6 +1800,57 @@ void unset_nmi_callback(void) nmi_callback =3D dummy_nmi_callback; } =20 +static DEFINE_PER_CPU(nmi_contfunc_t *, nmi_cont_func); +static DEFINE_PER_CPU(void *, nmi_cont_arg); +static DEFINE_PER_CPU(bool, nmi_cont_busy); + +bool nmi_check_continuation(void) +{ + unsigned int cpu =3D smp_processor_id(); + nmi_contfunc_t *func =3D per_cpu(nmi_cont_func, cpu); + void *arg =3D per_cpu(nmi_cont_arg, cpu); + + if ( per_cpu(nmi_cont_busy, cpu) ) + { + per_cpu(nmi_cont_busy, cpu) =3D false; + printk("Trying to set NMI continuation while still one active!\n"); + } + + /* Reads must be done before following write (local cpu ordering only)= . */ + barrier(); + + per_cpu(nmi_cont_func, cpu) =3D NULL; + + if ( func ) + func(arg); + + return func; +} + +int set_nmi_continuation(nmi_contfunc_t *func, void *arg) +{ + unsigned int cpu =3D smp_processor_id(); + + if ( per_cpu(nmi_cont_func, cpu) ) + { + per_cpu(nmi_cont_busy, cpu) =3D true; + return -EBUSY; + } + + per_cpu(nmi_cont_func, cpu) =3D func; + per_cpu(nmi_cont_arg, cpu) =3D arg; + + /* + * Issue a self-IPI. Handling is done in spurious_interrupt(). + * NMI could have happened in IPI sequence, so wait for ICR being idle + * again before leaving NMI handler. + */ + send_IPI_self(SPURIOUS_APIC_VECTOR); + apic_wait_icr_idle(); + + return 0; +} + void do_device_not_available(struct cpu_user_regs *regs) { #ifdef CONFIG_PV diff --git a/xen/include/asm-x86/nmi.h b/xen/include/asm-x86/nmi.h index a288f02a50..68db75b1ed 100644 --- a/xen/include/asm-x86/nmi.h +++ b/xen/include/asm-x86/nmi.h @@ -33,5 +33,16 @@ nmi_callback_t *set_nmi_callback(nmi_callback_t *callbac= k); void unset_nmi_callback(void); =20 DECLARE_PER_CPU(unsigned int, nmi_count); -=20 + +typedef void nmi_contfunc_t(void *arg); + +/** + * set_nmi_continuation + * + * Schedule a function to be started in interrupt context after NMI handli= ng. + */ +int set_nmi_continuation(nmi_contfunc_t *func, void *arg); + +/* Check for NMI continuation pending. */ +bool nmi_check_continuation(void); #endif /* ASM_NMI_H */ --=20 2.26.2 From nobody Thu Mar 28 17:44:56 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1602838458; cv=none; d=zohomail.com; s=zohoarc; b=FWOwuLInCw30WBNJX10+hPbZAAkE8lNuSLdqPf9saPfFAm3NMS7sVCEB/IgxlyhEsH2tgnjEa7aCJNdiKt281zWV/ViPHoHcajhjrE/7Yj4fyve0vNJKszsSWLRK4r8UY7FZsGdrAlTHclrAz2kMedQRXyTKgCt0wsRmAOpNnYI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602838458; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=rSOB8WNkMaU2hnrfpEjv6May2yW7ubKae50ylsNLlyI=; b=XEswF4XdOB+hBAN9HWWbLUeJOG4vFIswabqmb4TW0naZL2yFsh9PwCqAgMx43n8Tq74nsPDgGYq0xbo90j9HumUGVBqeVcuxDG2Yu5gkZguYqrY4jbxOVi2mwOMLJ+xmyqrZYn/8j4VIiSi57ZnBkVMfWUJQ0HdrZuwEM2EJSOw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1602838458261818.0301070006545; Fri, 16 Oct 2020 01:54:18 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.7829.20611 (Exim 4.92) (envelope-from ) id 1kTLUq-0002D8-2I; Fri, 16 Oct 2020 08:53:56 +0000 Received: by outflank-mailman (output) from mailman id 7829.20611; Fri, 16 Oct 2020 08:53:56 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kTLUp-0002D1-VC; Fri, 16 Oct 2020 08:53:55 +0000 Received: by outflank-mailman (input) for mailman id 7829; Fri, 16 Oct 2020 08:53:54 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kTLUo-0002Cr-Ah for xen-devel@lists.xenproject.org; Fri, 16 Oct 2020 08:53:54 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 4e64d87c-f3c5-472e-95bc-a569bfb942e0; Fri, 16 Oct 2020 08:53:53 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id B9C6BADFF; Fri, 16 Oct 2020 08:53:52 +0000 (UTC) Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kTLUo-0002Cr-Ah for xen-devel@lists.xenproject.org; Fri, 16 Oct 2020 08:53:54 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 4e64d87c-f3c5-472e-95bc-a569bfb942e0; Fri, 16 Oct 2020 08:53:53 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id B9C6BADFF; Fri, 16 Oct 2020 08:53:52 +0000 (UTC) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 4e64d87c-f3c5-472e-95bc-a569bfb942e0 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1602838432; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rSOB8WNkMaU2hnrfpEjv6May2yW7ubKae50ylsNLlyI=; b=JBkDJimAwG7YFhn7Tfy6L5waIaU2GINdyg3NuIpE1IGeZdYSB/vspy5e8BIWspmAs5R9KK zSmdkBkjXR5AKSqzZaSbrb4d20Xubf/XAsphoA/kBoflGHf2bdVSmHWlgJZBKJ7u2jhkII pMgSMsgPFhNapbRGP7k4epMyk3u/hmg= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu Subject: [PATCH v3 2/3] xen/oprofile: use set_nmi_continuation() for sending virq to guest Date: Fri, 16 Oct 2020 10:53:49 +0200 Message-Id: <20201016085350.10233-3-jgross@suse.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201016085350.10233-1-jgross@suse.com> References: <20201016085350.10233-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) Content-Type: text/plain; charset="utf-8" Instead of calling send_guest_vcpu_virq() from NMI context use the NMI continuation framework for that purpose. This avoids taking locks in NMI mode. Signed-off-by: Juergen Gross --- xen/arch/x86/oprofile/nmi_int.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/oprofile/nmi_int.c b/xen/arch/x86/oprofile/nmi_in= t.c index 0f103d80a6..825f0aeef0 100644 --- a/xen/arch/x86/oprofile/nmi_int.c +++ b/xen/arch/x86/oprofile/nmi_int.c @@ -83,6 +83,13 @@ void passive_domain_destroy(struct vcpu *v) model->free_msr(v); } =20 +static void nmi_oprofile_send_virq(void *arg) +{ + struct vcpu *v =3D arg; + + send_guest_vcpu_virq(v, VIRQ_XENOPROF); +} + static int nmi_callback(const struct cpu_user_regs *regs, int cpu) { int xen_mode, ovf; @@ -90,7 +97,7 @@ static int nmi_callback(const struct cpu_user_regs *regs,= int cpu) ovf =3D model->check_ctrs(cpu, &cpu_msrs[cpu], regs); xen_mode =3D ring_0(regs); if ( ovf && is_active(current->domain) && !xen_mode ) - send_guest_vcpu_virq(current, VIRQ_XENOPROF); + set_nmi_continuation(nmi_oprofile_send_virq, current); =20 if ( ovf =3D=3D 2 ) current->arch.nmi_pending =3D true; --=20 2.26.2 From nobody Thu Mar 28 17:44:56 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1602838467; cv=none; d=zohomail.com; s=zohoarc; b=XFpbBgmSMF/piDHm1e3S5+wcaD1e3ADpO50QOXme1XpK1mp5l8BYNsy0LxK2y5a+pdBIE/sU7zfJ4iEOQqrJWdPUUNTNYmxSsysvqN6vlzMAWxS+zI+bQGk0+pd5vf5pxUeTcE6kKFG+stqiBtpRgmAhlEJ0nsW/cLkdkHRJU0s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602838467; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=t+pus/iAw/KMl2PmZi703thdM1sjdiTbovsr4cajzfc=; b=LaWzcCu2Hzw37O4U0anS06htYOiTTxzMaVfG5dxUnCsYBr3iA4bQ/qs+3E5+WMUulsuzjBVC7KKPCQKZ0ss7bE+EaL8zyTgiIvY7x2Dop/tdzhqyPjhgU8pq7kaHb1PevEnFk0sLu7qovE8iNddJORFNMUROsuIbPJzUyqGSdSs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1602838467369788.9695522489682; Fri, 16 Oct 2020 01:54:27 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.7832.20647 (Exim 4.92) (envelope-from ) id 1kTLV0-0002LE-2Q; Fri, 16 Oct 2020 08:54:06 +0000 Received: by outflank-mailman (output) from mailman id 7832.20647; Fri, 16 Oct 2020 08:54:06 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kTLUz-0002L7-V8; Fri, 16 Oct 2020 08:54:05 +0000 Received: by outflank-mailman (input) for mailman id 7832; Fri, 16 Oct 2020 08:54:04 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kTLUy-0002Cr-6n for xen-devel@lists.xenproject.org; Fri, 16 Oct 2020 08:54:04 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id fdcc0cbe-beb2-429a-a324-e4a52de30dda; Fri, 16 Oct 2020 08:53:53 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id DF079AE3A; Fri, 16 Oct 2020 08:53:52 +0000 (UTC) Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kTLUy-0002Cr-6n for xen-devel@lists.xenproject.org; Fri, 16 Oct 2020 08:54:04 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id fdcc0cbe-beb2-429a-a324-e4a52de30dda; Fri, 16 Oct 2020 08:53:53 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id DF079AE3A; Fri, 16 Oct 2020 08:53:52 +0000 (UTC) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: fdcc0cbe-beb2-429a-a324-e4a52de30dda X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1602838433; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=t+pus/iAw/KMl2PmZi703thdM1sjdiTbovsr4cajzfc=; b=VSxgyH+2PWjo2xPWP/qIbyRFuRCFo3Of0OnO9Qgy5pLDBvtfGPVQsJjkJ5mkNT0qF2Hx/8 SqhNvCbgfpz1XlZ/XxUiD3+wS+QDiMHJYxkZeAbL3ggnTvcgOmj61u9OzHi6712OMHL8QF UpZHlN4tMzBL7E9nNaVGpU9fS8DgcE4= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu Subject: [PATCH v3 3/3] xen/x86: issue pci_serr error message via NMI continuation Date: Fri, 16 Oct 2020 10:53:50 +0200 Message-Id: <20201016085350.10233-4-jgross@suse.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201016085350.10233-1-jgross@suse.com> References: <20201016085350.10233-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) Content-Type: text/plain; charset="utf-8" Instead of using a softirq pci_serr_error() can use NMI continuation for issuing an error message. Signed-off-by: Juergen Gross --- xen/arch/x86/traps.c | 9 +++------ xen/include/asm-x86/softirq.h | 5 ++--- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c index 6f4db9d549..7a68ac40be 100644 --- a/xen/arch/x86/traps.c +++ b/xen/arch/x86/traps.c @@ -1659,7 +1659,7 @@ void do_general_protection(struct cpu_user_regs *regs) panic("GENERAL PROTECTION FAULT\n[error_code=3D%04x]\n", regs->error_c= ode); } =20 -static void pci_serr_softirq(void) +static void pci_serr_nmicont(void *arg) { printk("\n\nNMI - PCI system error (SERR)\n"); outb(inb(0x61) & 0x0b, 0x61); /* re-enable the PCI SERR error line. */ @@ -1687,9 +1687,8 @@ static void pci_serr_error(const struct cpu_user_regs= *regs) nmi_hwdom_report(_XEN_NMIREASON_pci_serr); /* fallthrough */ case 'i': /* 'ignore' */ - /* Would like to print a diagnostic here but can't call printk() - from NMI context -- raise a softirq instead. */ - raise_softirq(PCI_SERR_SOFTIRQ); + /* Issue error message in NMI continuation. */ + set_nmi_continuation(pci_serr_nmicont, NULL); break; default: /* 'fatal' */ console_force_unlock(); @@ -2183,8 +2182,6 @@ void __init trap_init(void) percpu_traps_init(); =20 cpu_init(); - - open_softirq(PCI_SERR_SOFTIRQ, pci_serr_softirq); } =20 void activate_debugregs(const struct vcpu *curr) diff --git a/xen/include/asm-x86/softirq.h b/xen/include/asm-x86/softirq.h index 0b7a77f11f..415ee866c7 100644 --- a/xen/include/asm-x86/softirq.h +++ b/xen/include/asm-x86/softirq.h @@ -6,9 +6,8 @@ #define VCPU_KICK_SOFTIRQ (NR_COMMON_SOFTIRQS + 2) =20 #define MACHINE_CHECK_SOFTIRQ (NR_COMMON_SOFTIRQS + 3) -#define PCI_SERR_SOFTIRQ (NR_COMMON_SOFTIRQS + 4) -#define HVM_DPCI_SOFTIRQ (NR_COMMON_SOFTIRQS + 5) -#define NR_ARCH_SOFTIRQS 6 +#define HVM_DPCI_SOFTIRQ (NR_COMMON_SOFTIRQS + 4) +#define NR_ARCH_SOFTIRQS 5 =20 bool arch_skip_send_event_check(unsigned int cpu); =20 --=20 2.26.2