Received: by 2002:ac0:e34a:0:0:0:0:0 with SMTP id g10csp185339imn; Mon, 25 Jul 2022 13:26:05 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tF/T4v/A8VYFvOWGpex8T/Dp/J/GegyCVGV0RZnLsP0YbYGbjklAAChRlnspPNrwRmx1iq X-Received: by 2002:a05:6402:42d5:b0:43b:5cbc:eeba with SMTP id i21-20020a05640242d500b0043b5cbceebamr14911215edc.3.1658780765074; Mon, 25 Jul 2022 13:26:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658780765; cv=none; d=google.com; s=arc-20160816; b=pO+JDxK3HaPrC1jSCG4w53zw7THdGpqIfDzyrYA8+mmkHeTFOs4Aa1ndpofkDnQXUy QVy/ux+sC4hdahJNbzFkzZo/xA58sjas5WKg6Sv/Z0SXzPEuKF+c57GzCUrGUvNz7dwt dtq3UJeBBnigA/GE6P0oVEAkVWapgf48QRvkp4MRrrPXJ3QaLxX7seVyHd+t+ej4sFqT HnYftFkA18m2r6jsKHwVvKkP9+7RZ+WpZTC+AivXNTpaDVvNTzGI22ebHKgZf+tesI8V u1ubZlx14k1P50s8JZjEc6cL8cJNeWrLvdRxnGPRkDwL6P7aCOcmQyr84EwPsOmvv0A7 cR/w== 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=xzeuQ4txxMlEW4hUhxx0yJTnLHWK2MPkNma/gDyuH8joa1/cdT3zFcUgJdp52ANqHm MkC9yCcnuSPOyC8KaYMyd1a0TBCi8zvav2ZKdTQBqeW5DIHRMIJI12RqBTxSQTkP+uTt AdCwvzKicIxvs2hMRS7WpROfMmFXTDsb++t2nQq5EnhoDGfCDcBwubLbGr0ECwDfQMXY YjqGdl4lE3HIVpK2rTscAnu6HShwK9VbR9d4QQVAZu5BRehdnmlQfYu1so3RRzAe8wtK eAL6FQaMj6UhBNcSNijG53XrEZ9b+cJyzA9hdtffYxUsMpaPuaJkp3vnfC6HeuPf/bzt fhpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=AMgwab7L; 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 di12-20020a170906730c00b006f4d14bbbb3si15028351ejc.150.2022.07.25.13.25.40; Mon, 25 Jul 2022 13:26:05 -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=AMgwab7L; 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 S237125AbiGYUOt (ORCPT + 99 others); Mon, 25 Jul 2022 16:14:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237144AbiGYUOI (ORCPT ); Mon, 25 Jul 2022 16:14:08 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8B7522533; Mon, 25 Jul 2022 13:13:13 -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 2EC34B810F7; Mon, 25 Jul 2022 20:13:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 57129C36AE2; Mon, 25 Jul 2022 20:13:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1658779990; bh=b8X+BFzH2iCZK+xpE2p+40Q5LRHdNFPjgm8yK8trTBQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AMgwab7LYctG/3RHLwj4NLkVhPcNl8F//ulGEjpVplYrixmBJkG9TkvmRNsqLmdD7 qLN4L/xenYZ5fs4fss7sqROP6qBPJAdIX3jihGSBP6CcsESxQ4e4gBP9cHS/+vsaZZ r+vOcyeETQriLPkpmp5L642B1YMB4xKewS04czeYMKIXud1oQtANi06yVj5ygr4bvL B6Z4biKifOgHaiMj0NdmclZu66YeEEEovYz0uNbL+cndT3Tb0HWZPYa6Nj78S5ZjP0 WudNGdNsg3/ozSWleb/CrXPp7LlOV9R6wWuiTdRedRxIil5IBF/7FNSjpcQeLZwp05 hlggO3ns1zl4A== 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 V7 16/16] rv/reactor: Add the panic reactor Date: Mon, 25 Jul 2022 22:11:28 +0200 Message-Id: <8ea3fc5185e63c95d35ef7abd8c436e8a1730d8d.1658778484.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 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