Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp1151115imw; Wed, 13 Jul 2022 14:45:30 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vLSOEyzYdZXFtdwS0Zsbog9mbzXjEPXVj3BWGfXpWaTDtYHN4qY+URHdGOajx/8O9rsXNB X-Received: by 2002:a05:6402:695:b0:435:65f3:38c2 with SMTP id f21-20020a056402069500b0043565f338c2mr7924405edy.347.1657748730550; Wed, 13 Jul 2022 14:45:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657748730; cv=none; d=google.com; s=arc-20160816; b=Bxrp42tPCNVNj7vf+rKGN2jz+0kCR22H2yXpLZcl3lZFlyl28qTjN/tsM3lSiLzreX yXRKfouQTUfnt9q3RQ+vhpVYtgfyCiDo+iPMDMb09a6CmGICEqoxqivWEjf/LlVkP9MC cAxLfNZ9TVbaT5s1xbQfha2gKr53OPz3cvJyQNDO2Kc9FDW9JNg0Kx+81nc1gs+U4V2N 94xR5GoWZLuG8dH+V9LuGjHuVQ1g74bEPbR8PCbT2uC/gHl8AU0R7tmUim92tiHImcNR c5OH5tXRYX+VQJkFlTngkKk4mtRv/Ct8aR5FBseGPG0o8GAF06+97/HBHUZJwtSpWrHG 5afg== 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=Ab8VngLcS5AVbTn6kXzNL+hZgFWAGWQBQWn++ASqXeo=; b=sISHlLLkf49j4Aup4OUF2luFNUnU8MSx/IlsGRR1ROtMiG7hjJP0LlNaB1k368IOnv o1EcXiUxw9nM0jfXznwIwDSH1+7ZNMi6ZvXTCKyU8NuxCM+tl0vTEJuX/9zHUAW36PzY StyYqfRRpF8u1JlQJZIZyXj3M6tXffrcQ+j9C5OX5fZfpnAiyENwwJ/WhPH0wJxHjgTI xPjMkVaZO0KPjPRZ9eAaEndSAxi4Bl7tMCdXhLplb35U0mlk9brVeVz6qWyVVGJjUjQl jj4fBtXcpt37Kiqqtyvi3jgrJveIhOYLBkcbDkXPC9Ot/PHZn++Hr/Yc/gW5b4xH6285 ezwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fRZXDUwW; 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 nc11-20020a1709071c0b00b0072eda63453esi768979ejc.668.2022.07.13.14.44.59; Wed, 13 Jul 2022 14:45:30 -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=fRZXDUwW; 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 S237555AbiGMVUQ (ORCPT + 99 others); Wed, 13 Jul 2022 17:20:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237472AbiGMVTn (ORCPT ); Wed, 13 Jul 2022 17:19:43 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D1CFFE4; Wed, 13 Jul 2022 14:19:11 -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 4AE47B82024; Wed, 13 Jul 2022 21:19:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 58CC4C385A9; Wed, 13 Jul 2022 21:19:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1657747149; bh=yCkYhWen7pBPp8Qaie4klyI5Sstkqz5vyoR6lpX4PQU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fRZXDUwWacRJ6oAJbSb/Wme8EE+/C8WAU2tZC01Iysxcr2AlJ2T+RLIyMX1qe1Ia5 JzujN22M7FDZMrzH/Z+vxdGoj06RlBPR8XpLQ8EM21U4/lVkj3FQyUnQoLZqBG1Fir 56ga9bVmsZFvBrcJ+I5bpb8Tf7QHI0knLscuftqY5rBfeM9uWUEHSaf5ZMT74c3h+d Ml8XL0acnYLpJpJ28a3XwPUyuxNGsfYrCgVLMeqZc0tOcoXqU/CGeBoCf32d4aoDm3 IAzA7/TW8SRoLDxHTxa2mHjEikfAUbk1OIEG54rQH3kp3/dMNm0JJLfh/Pi+PUW2nm Fa9ebtLePQpbA== 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 V5 16/16] rv/reactor: Add the panic reactor Date: Wed, 13 Jul 2022 23:17:32 +0200 Message-Id: <5b3233ed8c7bd06895cc177da8a4299d764d6f9a.1657745645.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: 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 f1d92d431130..ce2a90a89f55 100644 --- a/kernel/trace/rv/Kconfig +++ b/kernel/trace/rv/Kconfig @@ -71,3 +71,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..c9b9ed99495b --- /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); +} + +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