Received: by 2002:ac0:e34a:0:0:0:0:0 with SMTP id g10csp502195imn; Wed, 27 Jul 2022 12:01:13 -0700 (PDT) X-Google-Smtp-Source: AGRyM1u1eGdlZub3rKE5Y329gTVEOgBIvn2/Ij9JYRZ6+b7ceZ6iPY7O0N79XLnUBvjQReOxKAaU X-Received: by 2002:a17:907:2cee:b0:72b:3b63:200 with SMTP id hz14-20020a1709072cee00b0072b3b630200mr18663237ejc.678.1658948473119; Wed, 27 Jul 2022 12:01:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658948473; cv=none; d=google.com; s=arc-20160816; b=Bo5Ho5akkBICM9OX7BvLQepYWMI02+Z7aG8UXXPlxIPPIhxKmN0mdzIU1/6HpGU7lO oaJCQT3oCB8+Fxh4e915EvE6WR6Wt8xzASExs6n+yNKUtDzt0h5xDp1T5OHYzvw/mZYO kyFrctidqmZNMq7D1/4OH383gLPU4uQQ2hY1kJxk+XOhOYuysdqcvTRVE5rhSO4uSWXW NYbBnY1NZI5lp0d126YTLWsE77hJTMAzhu15kHSt8Do8hAdDZSijeevUDyF1dnWT40bY oz+oh9PsEUiHN681FH6O3dUgK8TpIl7RTdEMjr9ac6PrrIvDqDQq8YNYoENxw7xxxcxf JctQ== 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=rQhiSj5/4V9/wzhNkMVMe/ijC6lH15U19cXIgIrqk9M=; b=s+TdyF6fdJNLH/U172P8N1QnK2/qjOS8oQmpzT/trlUiWZWPkKbuN64SuMkrDprc6X OQZ07WLi7hNoi69dKgNr2xefn1rYBL/GdGFT6Q4znCvSdzr94/XWD1pP+cNnLteD/Aac CJSWZwS6lfDfpuXEFHapmf/e0qKc87427HqF1FxvBQG9iPBQc62ayFnRITs4lGZ8uqFZ wEypZ3s2r+Y7lt/ogQCgOAswU705NRuNfFDD224ktLK8qVBkzmEWjY+CNLdyoxKyPV9A kWLFhe9uVf32AWmEdTz6vwy0LzWMxauZy8GMERMQK1LmLVlsqkow/CMkP4cttSXmFAh2 1dCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ZmIbSLOD; 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 ht13-20020a170907608d00b0072f6659c08dsi19658371ejc.848.2022.07.27.12.00.47; Wed, 27 Jul 2022 12:01:13 -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=ZmIbSLOD; 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 S243354AbiG0SMq (ORCPT + 99 others); Wed, 27 Jul 2022 14:12:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243318AbiG0SMU (ORCPT ); Wed, 27 Jul 2022 14:12:20 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 57FF9D43C5; Wed, 27 Jul 2022 10:13:39 -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 dfw.source.kernel.org (Postfix) with ESMTPS id C07706199F; Wed, 27 Jul 2022 17:13:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2B5ECC433D6; Wed, 27 Jul 2022 17:13:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1658942018; bh=b8X+BFzH2iCZK+xpE2p+40Q5LRHdNFPjgm8yK8trTBQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZmIbSLODQEtBwnpYyJR64MBHHBVgsAw2puDR4tKJzEhdOLtepoIZ/BqUeX6KrOLLg 8FpOzqilNuaHHdd1/EjRBmvkjt8dNnaZBiA5cxGNhWSakdCGM93jtRtgr1Kyrwzrf6 wwHTIgtg00/qodNh4nDKe7bP3qflf227BOer7yYohQ+VRu8CL0rdOVwkcu3XkoQRge EVBJ6Yc52b9ru4V2qMMN+47XZMG1x9fjhhmIlPJkpFht7gDFvty8eI+X06RNj0drLn TToFETbV7rToKvGNMuGctWRlrYt5xbD9v4LiMgXxckA3R17yRYgOIiciS0BRDvrcAl 9T2llwmaQrtQA== 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 , Tao Zhou , Randy Dunlap , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-devel@vger.kernel.org Subject: [PATCH V8 16/16] rv/reactor: Add the panic reactor Date: Wed, 27 Jul 2022 19:11:44 +0200 Message-Id: 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 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: Tao Zhou Cc: Randy Dunlap 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 | 43 +++++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+) create mode 100644 kernel/trace/rv/reactor_panic.c diff --git a/kernel/trace/rv/Kconfig b/kernel/trace/rv/Kconfig index e82d5015e6ab..831779607e84 100644 --- a/kernel/trace/rv/Kconfig +++ b/kernel/trace/rv/Kconfig @@ -68,3 +68,11 @@ config RV_REACT_PRINTK help Enables the printk reactor. The printk reactor emits a printk() message if an exception is found. + +config RV_REACT_PANIC + bool "Panic reactor" + depends on RV_REACTORS + default y + help + Enables the panic reactor. The panic reactor emits a printk() + message if an exception is found and panic()s the system. 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..b698d05dd069 --- /dev/null +++ b/kernel/trace/rv/reactor_panic.c @@ -0,0 +1,43 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2019-2022 Red Hat, Inc. Daniel Bristot de Oliveira + * + * Panic RV reactor: + * Prints the exception msg to the kernel message log and panic(). + */ + +#include +#include +#include +#include +#include +#include + +static void rv_panic_reaction(char *msg) +{ + panic(msg); +} + +static struct rv_reactor rv_panic = { + .name = "panic", + .description = "panic the system if an exception is found.", + .react = rv_panic_reaction +}; + +static int register_react_panic(void) +{ + rv_register_reactor(&rv_panic); + return 0; +} + +static 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