Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp1256379iog; Thu, 16 Jun 2022 02:24:48 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vUpFZL+qQiRLy1npYX5aDyA++KOM5J3i0mtt7cQGN8r56O9MaJ6gCr2SjkDCqpNjqUhx04 X-Received: by 2002:a17:906:a245:b0:708:ce69:e38b with SMTP id bi5-20020a170906a24500b00708ce69e38bmr3624668ejb.100.1655371487932; Thu, 16 Jun 2022 02:24:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655371487; cv=none; d=google.com; s=arc-20160816; b=V9PJIhIBu8+3cHPdD9g8ReT/DRjJcXVWWxM/WZiVe0cqQEAFqUj0uOiYUZY0gTuU2n pQi37T+COKY+Tu+J7FnlAjt3w4T0Fy4uuIw5j+uTMdjs+zxXZaEDDSF+Lm3Vu0QwiACQ KVY3LzDQpTK8H6nhz49tsVevCC+CNGZ2TcQv4Ka5iPO+CPOY0TCVPmHsbS1P1TZLN+Q8 SqIm/virdnfny8XkV4GNTwE66WTl9nzT1wLTmc29RmtbbN0hLXrpRSOnqe3APoQaTSTE uOsVmAtUPFM3neAQeBQAsq3GSRjyZh/LovcZ5IteNBL+h/yPzYvR1rtGO09sp/dpjy9g gu/g== 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 :dkim-signature; bh=buVcwGgUQVeQNHNiNHFooVsmv7nXsKQbE3EHvvtqmNU=; b=Udh+cnH3xfFxrnNFg/5ggjoL2q9h5YmIt3pX0pSgii7UosjsNRUpo6Cbda45Liv7Ov i/Mu40Zd1yn5d6HqbUrAYwkXCOy73mZ7ZmlrFS4fy0VG0noK3UfHK6YRcvzJhf2zoFpp LCqvONwhl7aNTSMOG3kQ9nq8EyH9S1Y00WaQ6e8recF+7u0QdHBCfitp6Yy5/4UYc31E JQwfHu8p4lqRdt4e7Nvxu6uUVtQeRD8QCsHUly/MwKf48dDTWpuyu2IKPBs5yv7QnG/y Rd1lpw77l6p4Blzlb8t+ZiJNgscdXF5VRiYDXtgdeuc4YQRB8L6zqC5+UOZlEGXVmpDy sxww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=doipYHKQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m8-20020aa7c488000000b0043135d71925si1844538edq.467.2022.06.16.02.24.21; Thu, 16 Jun 2022 02:24:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=doipYHKQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359456AbiFPIrG (ORCPT + 99 others); Thu, 16 Jun 2022 04:47:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35516 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359806AbiFPIqV (ORCPT ); Thu, 16 Jun 2022 04:46:21 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE5B25DBDA; Thu, 16 Jun 2022 01:46:18 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 961E0B822AA; Thu, 16 Jun 2022 08:46:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E5140C341C6; Thu, 16 Jun 2022 08:46:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1655369176; bh=/xZOtWjGXYTz/J2Aiul1V0Ty93/KmzjcS55M0yhNTrk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=doipYHKQb4BVV959SwfH4xhLIiAmUC5P4OunW4L2kNxA9OtOLSCnkPlNZOgrlGMsi isfWf0Pnq+kQvZSDgukxH4KI/r4JZcDYxWmwl43YLk6lO7mGBuBEymZy2Wo+yly2c/ fqD9AnlWYXxGkOfVNpX7EgnsxN1l2gh1B85LDPSAENAoPVkjgciHotNZhnqsDEfciq PSz9lcfbd1j7zHhU+QyZw/8H5qhdNX2DdxB/6Qf3AFrD9X+F9/VWx+CEsPLan7FDqK aX3qP9BLjHe5yBIucBu3a/cNVEGXFtx8FpFzMTlQQCIK8SIBCu7n2e5XnDN3p8XTmt TpuXFnt10mvig== From: Daniel Bristot de Oliveira To: Steven Rostedt Cc: Daniel Bristot de Oliveira , Wim Van Sebroeck , Guenter Roeck , 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: [PATCH V4 13/20] rv/reactor: Add the panic reactor Date: Thu, 16 Jun 2022 10:44:55 +0200 Message-Id: <67e522ab57e64eee313af508a8c70f3cce33e525.1655368610.git.bristot@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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: Wim Van Sebroeck Cc: Guenter Roeck 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 be8e3dab0a52..91a17b13a080 100644 --- a/kernel/trace/rv/Kconfig +++ b/kernel/trace/rv/Kconfig @@ -60,4 +60,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 + bool "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 a13c750a35c1..963d14875b45 100644 --- a/kernel/trace/rv/Makefile +++ b/kernel/trace/rv/Makefile @@ -5,3 +5,4 @@ obj-$(CONFIG_RV_MON_WIP) += monitors/wip/wip.o obj-$(CONFIG_RV_MON_WWNR) += monitors/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..9d8d78a337a3 --- /dev/null +++ b/kernel/trace/rv/reactor_panic.c @@ -0,0 +1,44 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Panic RV reactor: + * Prints the exception msg to the kernel message log and panic(). + * + * Copyright (C) 2019-2022 Daniel Bristot de Oliveira + * + */ + +#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"); +MODULE_AUTHOR("Daniel Bristot de Oliveira"); +MODULE_DESCRIPTION("panic rv reactor: panic if an exception is found"); -- 2.35.1