From nobody Tue Apr 16 14:47:52 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=1604915451; cv=none; d=zohomail.com; s=zohoarc; b=ZKFzfpXt62K1yuCqar04SWzYSS6+G4aPpLcdyWQSiS5mj4khuZzYKVmCH0kRWvJxZtMNTmQ/jCEnHwX7FjcV/rgTeb6kf1EHfofI6STPjtXTfOXS6kuv0MAP+R8OJrzfOSddODcohU052UbNSvM3WCXq8M3tLOLTZnUDc9YMQYg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604915451; 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=1OcADNeqtn5le1IW034CfnSXJe+7ZXbQ3qogiKRAU7Y=; b=Czph7imdSPJROdpjcR3hHYH/+2mvrIABxPwAg13t0gC0snnMdTUQshmDa6IROOW8/6ZcWaPvX9tJfBPDC2HMx32RWgg/HAs9LKmg7wa/i2/bw2GwxUGWCTb91tR1TpIRXEdlmiXvytMl3Zl60bJGIk40QUn3vQSn6IvMM1H/08s= 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 1604915451749386.5269769711849; Mon, 9 Nov 2020 01:50:51 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.22269.48547 (Exim 4.92) (envelope-from ) id 1kc3om-00037W-S0; Mon, 09 Nov 2020 09:50:32 +0000 Received: by outflank-mailman (output) from mailman id 22269.48547; Mon, 09 Nov 2020 09:50:32 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kc3om-00037L-P0; Mon, 09 Nov 2020 09:50:32 +0000 Received: by outflank-mailman (input) for mailman id 22269; Mon, 09 Nov 2020 09:50:31 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kc3ok-00032y-UC for xen-devel@lists.xenproject.org; Mon, 09 Nov 2020 09:50:30 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 73627980-4f17-4a32-8c9f-f9554f50e3a6; Mon, 09 Nov 2020 09:50:24 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id AAA75AC23; Mon, 9 Nov 2020 09:50:23 +0000 (UTC) Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kc3ok-00032y-UC for xen-devel@lists.xenproject.org; Mon, 09 Nov 2020 09:50:30 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 73627980-4f17-4a32-8c9f-f9554f50e3a6; Mon, 09 Nov 2020 09:50:24 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id AAA75AC23; Mon, 9 Nov 2020 09:50:23 +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: 73627980-4f17-4a32-8c9f-f9554f50e3a6 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=1604915423; 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=1OcADNeqtn5le1IW034CfnSXJe+7ZXbQ3qogiKRAU7Y=; b=U584MBYlyKA0OmO+EmQRpJWo3L6D/lC8U9IOmHtAp+DfmcF7sHcckrOBXW5j73Dj/CNL8H JxejBerXqH53Nfby8wCmFQa0d5wqFUjEdmM24QOY1UWJ4OipRn0ZbZGdMqiZFJu6tXsVWV MF2SZMlAuDBx0XMRyEWC8P3zomCk7Aw= 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 v4 1/3] xen/x86: add nmi continuation framework Date: Mon, 9 Nov 2020 10:50:19 +0100 Message-Id: <20201109095021.9897-2-jgross@suse.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201109095021.9897-1-jgross@suse.com> References: <20201109095021.9897-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 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 Reviewed-by: Jan Beulich --- V4: - make the framework less generic V2: - add prototype for continuation function (Roger Pau Monn=C3=A9) - switch from softirq to explicit self-IPI (Jan Beulich) Signed-off-by: Juergen Gross --- xen/arch/x86/apic.c | 13 ++++++++++--- xen/arch/x86/traps.c | 19 +++++++++++++++++++ xen/include/asm-x86/nmi.h | 11 ++++++++++- 3 files changed, 39 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..5005ac6e6e 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,24 @@ void unset_nmi_callback(void) nmi_callback =3D dummy_nmi_callback; } =20 +bool nmi_check_continuation(void) +{ + bool ret =3D false; + + return ret; +} + +void trigger_nmi_continuation(void) +{ + /* + * 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(); +} + 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..9a5da14162 100644 --- a/xen/include/asm-x86/nmi.h +++ b/xen/include/asm-x86/nmi.h @@ -33,5 +33,14 @@ 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 + +/** + * trigger_nmi_continuation + * + * Schedule continuation to be started in interrupt context after NMI hand= ling. + */ +void trigger_nmi_continuation(void); + +/* Check for NMI continuation pending. */ +bool nmi_check_continuation(void); #endif /* ASM_NMI_H */ --=20 2.26.2 From nobody Tue Apr 16 14:47:52 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=1604915452; cv=none; d=zohomail.com; s=zohoarc; b=mg8WOMeaYeuCUhUWSUcRJgIFiq6NXNzN3GnBdtCTAcIRzjQmUkXAPd0RfNGNIzFtGgeo3QN9ivI3mMHoGVfBp/scmuRieANkQ5R3YWglOIeyT7MSi4Msvjk3vnKWBoycZXYZG3hjJ+Pbi15X2meDZgXSNjoyscwtWpYHDVdGLjg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604915452; 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=+Ehg+Oe06If61OaHeelhui6nZFa39xSlzfoRaxz8w3I=; b=ROYdDjnRpc0aROmnh5xi/lzjxpSJoB5NYmJtobx+IrfzB1opgRiUKkNmVrXSBFs8EkZqbJPaVuof7XwFtQ9mILDjEbKhzkH424j+vHpty7h0TAdDuMZ1R0j6VH/e2qtXZhmDxbDcwg/9qWw5Yw8lZUwEKSGNnywOfSXukkNwuWA= 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 1604915452816812.9458885555741; Mon, 9 Nov 2020 01:50:52 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.22270.48559 (Exim 4.92) (envelope-from ) id 1kc3or-0003Ba-4y; Mon, 09 Nov 2020 09:50:37 +0000 Received: by outflank-mailman (output) from mailman id 22270.48559; Mon, 09 Nov 2020 09:50:37 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kc3or-0003BR-1M; Mon, 09 Nov 2020 09:50:37 +0000 Received: by outflank-mailman (input) for mailman id 22270; Mon, 09 Nov 2020 09:50:36 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kc3op-00032y-UN for xen-devel@lists.xenproject.org; Mon, 09 Nov 2020 09:50:35 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 10bdc7d8-87d4-43e9-a1d6-2b01eb3537ff; Mon, 09 Nov 2020 09:50:24 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id BEB7BAC55; Mon, 9 Nov 2020 09:50:23 +0000 (UTC) Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kc3op-00032y-UN for xen-devel@lists.xenproject.org; Mon, 09 Nov 2020 09:50:35 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 10bdc7d8-87d4-43e9-a1d6-2b01eb3537ff; Mon, 09 Nov 2020 09:50:24 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id BEB7BAC55; Mon, 9 Nov 2020 09:50:23 +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: 10bdc7d8-87d4-43e9-a1d6-2b01eb3537ff 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=1604915423; 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=+Ehg+Oe06If61OaHeelhui6nZFa39xSlzfoRaxz8w3I=; b=fh9NlGNOOPqmb4A14oeD+pOVfS5y4p5QA6KODCl8vN86moulHHvmfxjKs0FNyuK40MakFd Wu6iKHP0Px1fltYULEvPx4jChyZcRVeTL7ldidbPNL3KNJMIsIHaeUKgSF2wwaOGdHNKOB r7R0lf+8qiwOfbkNg5MO46JbLuCMWn8= 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 v4 2/3] xen/oprofile: use NMI continuation for sending virq to guest Date: Mon, 9 Nov 2020 10:50:20 +0100 Message-Id: <20201109095021.9897-3-jgross@suse.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201109095021.9897-1-jgross@suse.com> References: <20201109095021.9897-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 --- V4: - rework to less generic approach --- xen/arch/x86/oprofile/nmi_int.c | 20 ++++++++++++++++++-- xen/arch/x86/traps.c | 4 ++++ xen/include/asm-x86/xenoprof.h | 7 +++++++ 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/oprofile/nmi_int.c b/xen/arch/x86/oprofile/nmi_in= t.c index 0f103d80a6..5f17cba0b2 100644 --- a/xen/arch/x86/oprofile/nmi_int.c +++ b/xen/arch/x86/oprofile/nmi_int.c @@ -38,6 +38,8 @@ static unsigned long saved_lvtpc[NR_CPUS]; =20 static char *cpu_type; =20 +static DEFINE_PER_CPU(struct vcpu *, nmi_cont_vcpu); + static int passive_domain_msr_op_checks(unsigned int msr, int *typep, int = *indexp) { struct vpmu_struct *vpmu =3D vcpu_vpmu(current); @@ -83,14 +85,28 @@ void passive_domain_destroy(struct vcpu *v) model->free_msr(v); } =20 +bool nmi_oprofile_send_virq(void) +{ + struct vcpu *v =3D this_cpu(nmi_cont_vcpu); + + if ( v ) + send_guest_vcpu_virq(v, VIRQ_XENOPROF); + + this_cpu(nmi_cont_vcpu) =3D NULL; + + return v; +} + static int nmi_callback(const struct cpu_user_regs *regs, int cpu) { int xen_mode, ovf; =20 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); + if ( ovf && is_active(current->domain) && !xen_mode ) { + this_cpu(nmi_cont_vcpu) =3D current; + trigger_nmi_continuation(); + } =20 if ( ovf =3D=3D 2 ) current->arch.nmi_pending =3D true; diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c index 5005ac6e6e..7cb7d7e09c 100644 --- a/xen/arch/x86/traps.c +++ b/xen/arch/x86/traps.c @@ -65,6 +65,7 @@ #include #include #include +#include #include #include #include @@ -1804,6 +1805,9 @@ bool nmi_check_continuation(void) { bool ret =3D false; =20 + if ( nmi_oprofile_send_virq() ) + ret =3D true; + return ret; } =20 diff --git a/xen/include/asm-x86/xenoprof.h b/xen/include/asm-x86/xenoprof.h index 1026ba2e1f..cf6af8c5df 100644 --- a/xen/include/asm-x86/xenoprof.h +++ b/xen/include/asm-x86/xenoprof.h @@ -69,6 +69,8 @@ int passive_domain_do_rdmsr(unsigned int msr, uint64_t *m= sr_content); int passive_domain_do_wrmsr(unsigned int msr, uint64_t msr_content); void passive_domain_destroy(struct vcpu *v); =20 +bool nmi_oprofile_send_virq(void); + #else =20 static inline int passive_domain_do_rdmsr(unsigned int msr, @@ -85,6 +87,11 @@ static inline int passive_domain_do_wrmsr(unsigned int m= sr, =20 static inline void passive_domain_destroy(struct vcpu *v) {} =20 +static inline bool nmi_oprofile_send_virq(void) +{ + return false; +} + #endif /* CONFIG_XENOPROF */ =20 #endif /* __ASM_X86_XENOPROF_H__ */ --=20 2.26.2 From nobody Tue Apr 16 14:47:52 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=1604915451; cv=none; d=zohomail.com; s=zohoarc; b=nTdS2Y9G0lGpzgPsObD0apC5Rt5/zCKRuaLLGwTLC3fIwXBnPSak4c6b48lado+pClvupy3YxO2dfFHjS1oIBfGv1GaVMBZg5p1cIC884UECng2bwa5QA5dZZxq6zkZA14vMAqpEEW2hDZUuiVk/HdqTWE2zenGW1wEldcyZKdc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604915451; 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=GLBR9EmjHCFkPapKcP0kRX3wmjiDirIrvyn/L7SIsBk=; b=EykvNlSnwjSAIyisV5otvFNduqVYRrl97q+uHyNVkj/nXf2TGSwvcyZ/mXMT9LwKlMSY4c8bGUrzxWcBWYKIGQMAe4Z2rdJq+ZDOb8MOkwMf1KlgJSLCXZkQ98XMMLWdNbtI20K7eHOXiQa06MTVULOP1YyEWSYzmRwtXfFsMKA= 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 1604915451798708.8758120552093; Mon, 9 Nov 2020 01:50:51 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.22268.48535 (Exim 4.92) (envelope-from ) id 1kc3oh-000342-KF; Mon, 09 Nov 2020 09:50:27 +0000 Received: by outflank-mailman (output) from mailman id 22268.48535; Mon, 09 Nov 2020 09:50:27 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kc3oh-00033v-Gt; Mon, 09 Nov 2020 09:50:27 +0000 Received: by outflank-mailman (input) for mailman id 22268; Mon, 09 Nov 2020 09:50:26 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kc3of-00032y-Ve for xen-devel@lists.xenproject.org; Mon, 09 Nov 2020 09:50:26 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id abd59ebd-efb6-4d95-a147-c7bb5d752dbe; Mon, 09 Nov 2020 09:50:24 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id E0472AC65; Mon, 9 Nov 2020 09:50:23 +0000 (UTC) Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kc3of-00032y-Ve for xen-devel@lists.xenproject.org; Mon, 09 Nov 2020 09:50:26 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id abd59ebd-efb6-4d95-a147-c7bb5d752dbe; Mon, 09 Nov 2020 09:50:24 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id E0472AC65; Mon, 9 Nov 2020 09:50:23 +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: abd59ebd-efb6-4d95-a147-c7bb5d752dbe 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=1604915424; 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=GLBR9EmjHCFkPapKcP0kRX3wmjiDirIrvyn/L7SIsBk=; b=ZMdQFefCGQLexNWbgcUpKI//N649BSfQt+iiuKYf3V80m/cdf+zyipd2CdYWR5MhtGzZJ8 TObwY6Pcy9GRx6gO/Ha7bhJA/+fHa35BErQ/FoBRcq8AIVelWvsclOFaUwxLYcPoYonyY+ 1li17/vxGJ+D5DTiosZo/BOzOaGW+cw= 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 v4 3/3] xen/x86: issue pci_serr error message via NMI continuation Date: Mon, 9 Nov 2020 10:50:21 +0100 Message-Id: <20201109095021.9897-4-jgross@suse.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201109095021.9897-1-jgross@suse.com> References: <20201109095021.9897-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 Reviewed-by: Jan Beulich --- V4: - rework to less generic approach --- xen/arch/x86/traps.c | 21 +++++++++++++++------ xen/include/asm-x86/softirq.h | 5 ++--- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c index 7cb7d7e09c..6aeccef32d 100644 --- a/xen/arch/x86/traps.c +++ b/xen/arch/x86/traps.c @@ -1660,10 +1660,18 @@ void do_general_protection(struct cpu_user_regs *re= gs) panic("GENERAL PROTECTION FAULT\n[error_code=3D%04x]\n", regs->error_c= ode); } =20 -static void pci_serr_softirq(void) +static bool pci_serr_cont; + +static bool pci_serr_nmicont(void) { + if ( !pci_serr_cont ) + return false; + + pci_serr_cont =3D false; printk("\n\nNMI - PCI system error (SERR)\n"); outb(inb(0x61) & 0x0b, 0x61); /* re-enable the PCI SERR error line. */ + + return true; } =20 static void nmi_hwdom_report(unsigned int reason_idx) @@ -1688,9 +1696,9 @@ 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. */ + pci_serr_cont =3D true; + trigger_nmi_continuation(); break; default: /* 'fatal' */ console_force_unlock(); @@ -1808,6 +1816,9 @@ bool nmi_check_continuation(void) if ( nmi_oprofile_send_virq() ) ret =3D true; =20 + if ( pci_serr_nmicont() ) + ret =3D true; + return ret; } =20 @@ -2154,8 +2165,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