Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp6017248pxb; Mon, 14 Feb 2022 13:13:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJy/SIoTYKqRS+86a5IZlbEnNtUOIk0NZgbyWp3tTMfcKaehXFCMpC8Z2aoLWDRyjvOOWvPI X-Received: by 2002:a17:90a:1951:b0:1b9:b02e:69a8 with SMTP id 17-20020a17090a195100b001b9b02e69a8mr581765pjh.127.1644873225279; Mon, 14 Feb 2022 13:13:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644873225; cv=none; d=google.com; s=arc-20160816; b=g5RxrSgPYtNPZzf6OeVmAp6QAATMgNbemfId1n4DfiQdKiV53KT4EfeBW4SVxXz2rV NwsPWOHCn+AwT7erhTCHugmenBT2i/F6Sx/jROuuszMw7KceYS5mcSOD6G2qGfkSg00F tcqVEH2Ox3jxQWpIet0ygHC0Ve0PAgLg6fp/tgBZFPNQ3LrGaKfPduLrrGe8gCfmrKS/ fYkj0Y4Ug4IFfaUWpCWiUbVqnWbWpVSJZXG4+tter0QvQGCPINECOZ1G5jCjkHmxdekk xiCO4kjHmPxEo2zxZmTDHiLuzvV+9El3wdAmqg1VTxPsERdhsF+jdpIrQ5Rh7yotL2Bi soig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=UM4Ob6tJmmezzazetH4lKjHE5fWXszj+PlvI1ZraU9g=; b=r1Goi1klBiTAQTbu5fRWDXT/LBRjvzapkk55zZSRFQa9EHuml8/hhrkut3wBBSL5L5 n8wkCGyCqBfbdN6aH7fGLxLDpLapDqj4Mb8UxKmzMH073qHKIkc7AzwxUmvjQ7U94DuQ 262dPMDo2RZC3pMOYvLOI6XIYo6ildWIiPYbQTNUTJCxPlFkVZtMIfIGEGIOYhOEpjLg U4AdqgrWhxNJjtoJmlG3dbjqa+RdV+qKLaWWHKGDIf/onYn+xoZI68q6zMkRv3dEweUT MhIpKG6WgczTsepJu2B2AgEYjSfMSyMFu5483IgQBDJ4WZQnFqgXVSQQFr2Ab/1AxhwH 6rsA== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id i9si14401886plg.446.2022.02.14.13.13.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Feb 2022 13:13:45 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 330F819CCE8; Mon, 14 Feb 2022 12:33:27 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241428AbiBNLW4 convert rfc822-to-8bit (ORCPT + 99 others); Mon, 14 Feb 2022 06:22:56 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:52246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244212AbiBNLWX (ORCPT ); Mon, 14 Feb 2022 06:22:23 -0500 Received: from us-smtp-delivery-44.mimecast.com (us-smtp-delivery-44.mimecast.com [207.211.30.44]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9B9B43818D for ; Mon, 14 Feb 2022 02:58:10 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-663-0G0PgSf2Me27bKhlbURrpw-1; Mon, 14 Feb 2022 05:47:31 -0500 X-MC-Unique: 0G0PgSf2Me27bKhlbURrpw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2728018B613A; Mon, 14 Feb 2022 10:47:29 +0000 (UTC) Received: from x1.com (unknown [10.22.16.130]) by smtp.corp.redhat.com (Postfix) with ESMTP id E781F26DFB; Mon, 14 Feb 2022 10:47:24 +0000 (UTC) From: Daniel Bristot de Oliveira To: Steven Rostedt Cc: Daniel Bristot de Oliveira , Jonathan Corbet , Ingo Molnar , Thomas Gleixner , Peter Zijlstra , Will Deacon , Catalin Marinas , Marco Elver , Dmitry Vyukov , "Paul E. McKenney" , Shuah Khan , Gabriele Paoloni , Juri Lelli , Clark Williams , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-devel@vger.kernel.org Subject: [RFC V2 13/21] rv/reactor: Add the panic reactor Date: Mon, 14 Feb 2022 11:45:04 +0100 Message-Id: <170ee4f4601b34a8ad25fa9a4f3626368c51e211.1644830251.git.bristot@kernel.org> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=bristot@kernel.org X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: kernel.org Content-Transfer-Encoding: 8BIT Content-Type: text/plain; charset=WINDOWS-1252 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Sample reactor that panics the system when an exception is found. This is useful both to capture a vmcore, or to fail-safe a critical system. Cc: Jonathan Corbet Cc: Steven Rostedt Cc: Ingo Molnar Cc: Thomas Gleixner Cc: Peter Zijlstra Cc: Will Deacon Cc: Catalin Marinas Cc: Marco Elver Cc: Dmitry Vyukov Cc: "Paul E. McKenney" Cc: Shuah Khan Cc: Gabriele Paoloni Cc: Juri Lelli Cc: Clark Williams Cc: linux-doc@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: linux-trace-devel@vger.kernel.org Signed-off-by: Daniel Bristot de Oliveira --- kernel/trace/rv/Kconfig | 8 ++++++ kernel/trace/rv/Makefile | 1 + kernel/trace/rv/reactor_panic.c | 44 +++++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+) create mode 100644 kernel/trace/rv/reactor_panic.c diff --git a/kernel/trace/rv/Kconfig b/kernel/trace/rv/Kconfig index 490f1417def9..7940898a0504 100644 --- a/kernel/trace/rv/Kconfig +++ b/kernel/trace/rv/Kconfig @@ -45,4 +45,12 @@ config RV_REACT_PRINTK Enables the printk reactor. The printk reactor emmits a printk() message if an exception is found. +config RV_REACT_PANIC + tristate "Panic reactor" + depends on RV_REACTORS + default y if RV_REACTORS + help + Enables the panic reactor. The panic reactor emmits a printk() + message if an exception is found and panic()s the system. + endif # RV diff --git a/kernel/trace/rv/Makefile b/kernel/trace/rv/Makefile index d86ceb103ef2..1f5747f065ce 100644 --- a/kernel/trace/rv/Makefile +++ b/kernel/trace/rv/Makefile @@ -5,3 +5,4 @@ obj-$(CONFIG_RV_MON_WIP) += monitor_wip/wip.o obj-$(CONFIG_RV_MON_WWNR) += monitor_wwnr/wwnr.o obj-$(CONFIG_RV_REACTORS) += rv_reactors.o obj-$(CONFIG_RV_REACT_PRINTK) += reactor_printk.o +obj-$(CONFIG_RV_REACT_PANIC) += reactor_panic.o diff --git a/kernel/trace/rv/reactor_panic.c b/kernel/trace/rv/reactor_panic.c new file mode 100644 index 000000000000..538cd3846a4e --- /dev/null +++ b/kernel/trace/rv/reactor_panic.c @@ -0,0 +1,44 @@ +/* + * Panic RV reactor: + * Prints the exception msg to the kernel message log and panic(). + * + * Copyright (C) 2019-2022 Daniel Bristot de Oliveira + * + * SPDX-License-Identifier: GPL-2.0 + */ + +#include +#include +#include +#include +#include +#include + +static void rv_panic_reaction(char *msg) +{ + panic(msg); +} + +struct rv_reactor rv_panic = { + .name = "panic", + .description = "panic the system if an exception is found.", + .react = rv_panic_reaction +}; + +int register_react_panic(void) +{ + rv_register_reactor(&rv_panic); + return 0; +} + +void unregister_react_panic(void) +{ + rv_unregister_reactor(&rv_panic); +} + +module_init(register_react_panic); +module_exit(unregister_react_panic); + +MODULE_LICENSE("GPL v2"); +MODULE_AUTHOR("Daniel Bristot de Oliveira"); +MODULE_DESCRIPTION("panic rv reactor: panic if an exception is found"); -- 2.33.1