From patchwork Tue May 26 14:58:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 11572921 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D129E159A for ; Wed, 27 May 2020 12:52:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B6F0A20873 for ; Wed, 27 May 2020 12:52:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590583976; bh=UlWxHR2+JjYrbrsIo9RFWetNsJ8HeI3W97glk4AJMH4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=aG53jY6y5saKt3bg3YLinoB239SVN0EkS8qSoChNnZyJUi+D0BZXuFRQqXOhpKT57 SWgUDxPE8ECPprwEt7cC50ZyRXYArsa9DbSKcbuyS9FXuR74gffGnRYIqc0WF1Ux+a SfpUdU6jhrfdMDbUa+RSUb+uMxnWt2hO8t/9HjU8= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730143AbgE0Mw4 (ORCPT ); Wed, 27 May 2020 08:52:56 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:45961 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730134AbgE0Mwz (ORCPT ); Wed, 27 May 2020 08:52:55 -0400 Received: by mail-pg1-f194.google.com with SMTP id f21so8720826pgg.12 for ; Wed, 27 May 2020 05:52:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:resent-from:resent-date:resent-message-id :resent-to:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3I2sdug0etgqRHUdoxPJvhoiBePAC70+vSrOonIbSmY=; b=l2OGABBpZhwoAk5HHpZvMnX/kabWz4iTi1F8qqEs0Sl5NoW7IdAMEWmHj/lhHSpa/X MeAzOm67lS9xurgRVYOx39Ggo5NVTetz3Hv6k9RV41gYp44wi+UpafQS9oijRgo/KQih 5Y/BnqZ6MkVqh5XRv1PfWW1UvnCkQ2FSMW3gQuL76zbVGq1C4QLB8Ljb6naVMieK29JG 2E8F26zyvqdjdcNaUN6Hge59zWBHhYJBAa65dNxfFPxHEW5HXPGPUiu9MAGdoKp4DLyG jffVziS18xEg26ChzPV8ggwaoV7iUu/ZV7Zu/v/D4oUjD+E/ktFh+d67Jw0ROjaEsEzg bWWA== X-Gm-Message-State: AOAM5338vdGkQ7x7zyJgfKqHvM99wDy5c4jgnFskKe6zTiAze51tt/Wd sCtd4jCNPco0zt+wRkfwTurfA6mrIuEoKQ== X-Google-Smtp-Source: ABdhPJxZ/eOTTa76Koqoz5fyLSajHtZC/oKHIcEiH/TbaZ4duI+ACwoQNyysG3NwcEuCRLRPO7WNbA== X-Received: by 2002:a63:a363:: with SMTP id v35mr3550639pgn.95.1590583974260; Wed, 27 May 2020 05:52:54 -0700 (PDT) Received: from 42.do-not-panic.com (42.do-not-panic.com. [157.230.128.187]) by smtp.gmail.com with ESMTPSA id 141sm2112781pfz.171.2020.05.27.05.52.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 May 2020 05:52:53 -0700 (PDT) Received: by 42.do-not-panic.com (Postfix, from userid 1000) id 6874F40605; Wed, 27 May 2020 12:52:52 +0000 (UTC) Received: from 42.do-not-panic.com (42.do-not-panic.com. [157.230.128.187]) by smtp.gmail.com with ESMTPSA id 1sm68426pje.26.2020.05.26.07.58.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 May 2020 07:58:19 -0700 (PDT) Received: by 42.do-not-panic.com (Postfix, from userid 1000) id 9DD6C40E7B; Tue, 26 May 2020 14:58:17 +0000 (UTC) From: Luis Chamberlain To: jeyu@kernel.org, davem@davemloft.net, kuba@kernel.org Cc: michael.chan@broadcom.com, dchickles@marvell.com, sburla@marvell.com, fmanlunas@marvell.com, aelior@marvell.com, GR-everest-linux-l2@marvell.com, kvalo@codeaurora.org, johannes@sipsolutions.net, akpm@linux-foundation.org, arnd@arndb.de, rostedt@goodmis.org, mingo@redhat.com, aquini@redhat.com, cai@lca.pw, dyoung@redhat.com, bhe@redhat.com, peterz@infradead.org, tglx@linutronix.de, gpiccoli@canonical.com, pmladek@suse.com, tiwai@suse.de, schlad@suse.de, andriy.shevchenko@linux.intel.com, derosier@gmail.com, keescook@chromium.org, daniel.vetter@ffwll.ch, will@kernel.org, mchehab+samsung@kernel.org, vkoul@kernel.org, mchehab+huawei@kernel.org, robh@kernel.org, mhiramat@kernel.org, sfr@canb.auug.org.au, linux@dominikbrodowski.net, glider@google.com, paulmck@kernel.org, elver@google.com, bauerman@linux.ibm.com, yamada.masahiro@socionext.com, samitolvanen@google.com, yzaikin@google.com, dvyukov@google.com, rdunlap@infradead.org, corbet@lwn.net, dianders@chromium.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Luis Chamberlain Subject: [PATCH v3 1/8] kernel.h: move taint and system state flags to uapi Date: Tue, 26 May 2020 14:58:08 +0000 Message-Id: <20200526145815.6415-2-mcgrof@kernel.org> X-Mailer: git-send-email 2.23.0.rc1 In-Reply-To: <20200526145815.6415-1-mcgrof@kernel.org> References: <20200526145815.6415-1-mcgrof@kernel.org> MIME-Version: 1.0 X-TUID: o7xEiSwAFgaO Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org The taint and system state flags will be used in a subsequent patch exposing these to userspace, so move them to uapi. We keep the TAINT_FLAGS_COUNT outside of uapi, as this value can change per release. Signed-off-by: Luis Chamberlain --- include/linux/kernel.h | 34 +--------------------------------- include/uapi/linux/kernel.h | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 33 deletions(-) diff --git a/include/linux/kernel.h b/include/linux/kernel.h index 82d91547d122..337634363d00 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h @@ -569,40 +569,8 @@ extern unsigned long get_taint(void); extern int root_mountflags; extern bool early_boot_irqs_disabled; +extern enum system_states system_state; -/* - * Values used for system_state. Ordering of the states must not be changed - * as code checks for <, <=, >, >= STATE. - */ -extern enum system_states { - SYSTEM_BOOTING, - SYSTEM_SCHEDULING, - SYSTEM_RUNNING, - SYSTEM_HALT, - SYSTEM_POWER_OFF, - SYSTEM_RESTART, - SYSTEM_SUSPEND, -} system_state; - -/* This cannot be an enum because some may be used in assembly source. */ -#define TAINT_PROPRIETARY_MODULE 0 -#define TAINT_FORCED_MODULE 1 -#define TAINT_CPU_OUT_OF_SPEC 2 -#define TAINT_FORCED_RMMOD 3 -#define TAINT_MACHINE_CHECK 4 -#define TAINT_BAD_PAGE 5 -#define TAINT_USER 6 -#define TAINT_DIE 7 -#define TAINT_OVERRIDDEN_ACPI_TABLE 8 -#define TAINT_WARN 9 -#define TAINT_CRAP 10 -#define TAINT_FIRMWARE_WORKAROUND 11 -#define TAINT_OOT_MODULE 12 -#define TAINT_UNSIGNED_MODULE 13 -#define TAINT_SOFTLOCKUP 14 -#define TAINT_LIVEPATCH 15 -#define TAINT_AUX 16 -#define TAINT_RANDSTRUCT 17 #define TAINT_FLAGS_COUNT 18 #define TAINT_FLAGS_MAX ((1UL << TAINT_FLAGS_COUNT) - 1) diff --git a/include/uapi/linux/kernel.h b/include/uapi/linux/kernel.h index 0ff8f7477847..4bbd4093eb64 100644 --- a/include/uapi/linux/kernel.h +++ b/include/uapi/linux/kernel.h @@ -12,4 +12,39 @@ #define __KERNEL_DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d)) +/* + * Values used for system_state. Ordering of the states must not be changed + * as code checks for <, <=, >, >= STATE. + */ +enum system_states { + SYSTEM_BOOTING, + SYSTEM_SCHEDULING, + SYSTEM_RUNNING, + SYSTEM_HALT, + SYSTEM_POWER_OFF, + SYSTEM_RESTART, + SYSTEM_SUSPEND, +}; + +/* This cannot be an enum because some may be used in assembly source. */ +#define TAINT_PROPRIETARY_MODULE 0 +#define TAINT_FORCED_MODULE 1 +#define TAINT_CPU_OUT_OF_SPEC 2 +#define TAINT_FORCED_RMMOD 3 +#define TAINT_MACHINE_CHECK 4 +#define TAINT_BAD_PAGE 5 +#define TAINT_USER 6 +#define TAINT_DIE 7 +#define TAINT_OVERRIDDEN_ACPI_TABLE 8 +#define TAINT_WARN 9 +#define TAINT_CRAP 10 +#define TAINT_FIRMWARE_WORKAROUND 11 +#define TAINT_OOT_MODULE 12 +#define TAINT_UNSIGNED_MODULE 13 +#define TAINT_SOFTLOCKUP 14 +#define TAINT_LIVEPATCH 15 +#define TAINT_AUX 16 +#define TAINT_RANDSTRUCT 17 +/* be sure to update TAINT_FLAGS_COUNT when extending this */ + #endif /* _UAPI_LINUX_KERNEL_H */ From patchwork Tue May 26 14:58:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 11572923 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0BB2A60D for ; Wed, 27 May 2020 12:53:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DD39E2053B for ; Wed, 27 May 2020 12:52:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590583979; bh=EwQQ7GnQ3ytbrZCKyeHLfbjuoGjA1c1A7GX/jNvBTWY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=j8zysTxhPsW/bc/MkdIt69uqe6Wd6dNner0mg9sCHPo9oFi10bEebM1hZSM4NawBV QkgRbP447L91/qmkkETuuvMC9Iqw7rBlse0Q3hsSt/isp26Ym50XHemZzy48P6sRyP DAsX34bNdvKTEp/8ifQH/i8W0aYiM2pbgACQ/eb4= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730151AbgE0Mw7 (ORCPT ); Wed, 27 May 2020 08:52:59 -0400 Received: from mail-pj1-f66.google.com ([209.85.216.66]:40882 "EHLO mail-pj1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729996AbgE0Mw6 (ORCPT ); Wed, 27 May 2020 08:52:58 -0400 Received: by mail-pj1-f66.google.com with SMTP id ci23so1477971pjb.5 for ; Wed, 27 May 2020 05:52:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:resent-from:resent-date:resent-message-id :resent-to:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7++pOXk6IJDsuFeObZU4Im4lkvw0LhpJw7+dPj+k3k8=; b=nSNYpjB+MN0ADX9Ro2ooXLBWug4UBfIUG3EoIFnTJK1rbGEY3skLdqF2e+hjw0NaG9 YoqIfldi1y7vNsrgd2LpbeDx+zEehnm/iHMQQHFkigaRfHOZESnVk3w3uC5+/S4ukZRU MKr5A2cbhrLf5JdDwmd+0/Jtp6xdzbuJdL7NNp3OksvLj2ahjh78bUCpU0u6/t33KHBR ljtTCrJWZLHznEDQX8lwHY+OsGzhmxsFsJY7cifogMikiF8ld50ETEG5uU1WtCSA41T7 ty6gjKtCW2pEyNdkZsvBF2Xh5LF0XtWwh6uISMv8etWU+PYGF0nocRgo4rw7i2JKkToB D26Q== X-Gm-Message-State: AOAM530zSII1JZb4DadaC8cnAmvrd9azK6xnAoq5uUiQsGg/vm2RbNCR dwRMXuzBeZO/J/PEayzBisuIKUHy2zzrzQ== X-Google-Smtp-Source: ABdhPJxC3cSgqSU853+uYBF6uCY7GOGTTrokryeRqt7skNrPLhOS9G3PaMoiLUy9UGQ5ME0FzeQXEw== X-Received: by 2002:a17:90a:e54d:: with SMTP id ei13mr5171797pjb.126.1590583976899; Wed, 27 May 2020 05:52:56 -0700 (PDT) Received: from 42.do-not-panic.com (42.do-not-panic.com. [157.230.128.187]) by smtp.gmail.com with ESMTPSA id u4sm3630744pjf.3.2020.05.27.05.52.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 May 2020 05:52:56 -0700 (PDT) Received: by 42.do-not-panic.com (Postfix, from userid 1000) id B8FEB40605; Wed, 27 May 2020 12:52:55 +0000 (UTC) Received: from 42.do-not-panic.com (42.do-not-panic.com. [157.230.128.187]) by smtp.gmail.com with ESMTPSA id u26sm15437401pfn.88.2020.05.26.07.58.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 May 2020 07:58:19 -0700 (PDT) Received: by 42.do-not-panic.com (Postfix, from userid 1000) id DF70F41C6A; Tue, 26 May 2020 14:58:17 +0000 (UTC) From: Luis Chamberlain To: jeyu@kernel.org, davem@davemloft.net, kuba@kernel.org Cc: michael.chan@broadcom.com, dchickles@marvell.com, sburla@marvell.com, fmanlunas@marvell.com, aelior@marvell.com, GR-everest-linux-l2@marvell.com, kvalo@codeaurora.org, johannes@sipsolutions.net, akpm@linux-foundation.org, arnd@arndb.de, rostedt@goodmis.org, mingo@redhat.com, aquini@redhat.com, cai@lca.pw, dyoung@redhat.com, bhe@redhat.com, peterz@infradead.org, tglx@linutronix.de, gpiccoli@canonical.com, pmladek@suse.com, tiwai@suse.de, schlad@suse.de, andriy.shevchenko@linux.intel.com, derosier@gmail.com, keescook@chromium.org, daniel.vetter@ffwll.ch, will@kernel.org, mchehab+samsung@kernel.org, vkoul@kernel.org, mchehab+huawei@kernel.org, robh@kernel.org, mhiramat@kernel.org, sfr@canb.auug.org.au, linux@dominikbrodowski.net, glider@google.com, paulmck@kernel.org, elver@google.com, bauerman@linux.ibm.com, yamada.masahiro@socionext.com, samitolvanen@google.com, yzaikin@google.com, dvyukov@google.com, rdunlap@infradead.org, corbet@lwn.net, dianders@chromium.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Luis Chamberlain Subject: [PATCH v3 2/8] panic: add uevent support Date: Tue, 26 May 2020 14:58:09 +0000 Message-Id: <20200526145815.6415-3-mcgrof@kernel.org> X-Mailer: git-send-email 2.23.0.rc1 In-Reply-To: <20200526145815.6415-1-mcgrof@kernel.org> References: <20200526145815.6415-1-mcgrof@kernel.org> MIME-Version: 1.0 X-TUID: jXgR+G3lcox7 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Add support to let panic events such as taints trigger uevents. If you don't have a journalctl -k -f window going and you're not actively monitoring what is going on in the kernel you may not realize that your kernel is hosed. Only those clueful that something may be off might inspect the kernel logs. Since not everyone is, add support to throw some bones to userspace that something might be fishy. Let userspace figure out how to inform users, and what to do. Signed-off-by: Luis Chamberlain --- MAINTAINERS | 8 + include/linux/panic_events.h | 26 +++ include/uapi/linux/panic_events.h | 17 ++ init/main.c | 1 + kernel/Makefile | 1 + kernel/module.c | 2 + kernel/panic.c | 7 +- kernel/panic_events.c | 289 ++++++++++++++++++++++++++++++ lib/Kconfig.debug | 13 ++ 9 files changed, 363 insertions(+), 1 deletion(-) create mode 100644 include/linux/panic_events.h create mode 100644 include/uapi/linux/panic_events.h create mode 100644 kernel/panic_events.c diff --git a/MAINTAINERS b/MAINTAINERS index 3a003f310574..5bb467c0b36f 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -12876,6 +12876,14 @@ L: platform-driver-x86@vger.kernel.org S: Maintained F: drivers/platform/x86/panasonic-laptop.c +PANIC EVENTS +M: Luis Chamberlain +L: linux-kernel@vger.kernel.org +S: Maintained +F: include/linux/panic_events.h +F: include/uapi/linux/panic_events.h +F: kernel/panic_events.c + PARALLAX PING IIO SENSOR DRIVER M: Andreas Klinger L: linux-iio@vger.kernel.org diff --git a/include/linux/panic_events.h b/include/linux/panic_events.h new file mode 100644 index 000000000000..8e7e331ecaaf --- /dev/null +++ b/include/linux/panic_events.h @@ -0,0 +1,26 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +#ifndef _LINUX_PANIC_EVENTS_H + +#include +#include + +#ifdef CONFIG_PANIC_EVENTS + +void panic_uevent(enum panic_uevent event); +void panic_uevent_taint(unsigned int flag, struct module *mod); + +#else +static inline void panic_events_init(void) +{ +} + +static inline panic_uevent(enum panic_uevent event) +{ +} + +static inline void panic_uevent_taint(unsigned int flag, struct module *mod) +{ +} +#endif + +#endif /* _LINUX_PANIC_EVENTS_H */ diff --git a/include/uapi/linux/panic_events.h b/include/uapi/linux/panic_events.h new file mode 100644 index 000000000000..4f409597be52 --- /dev/null +++ b/include/uapi/linux/panic_events.h @@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +#ifndef _UAPI_PANIC_EVENTS_H +#define _UAPI_PANIC_EVENTS_H + +/** + * enum panic_uevent - panic uevents + * + * @PANIC_LOCKDEP_DISABLED: lockdep has been disabled + * @PANIC_TAINT: lockdep has been disabled + */ +enum panic_uevent { + PANIC_LOCKDEP_DISABLED, + PANIC_TAINT, + __PANIC_MAX, /* non-ABI */ +}; + +#endif /* _UAPI_PANIC_EVENTS_H */ diff --git a/init/main.c b/init/main.c index 0ead83e86b5a..2bf33b5ec7b4 100644 --- a/init/main.c +++ b/init/main.c @@ -96,6 +96,7 @@ #include #include #include +#include #include #include diff --git a/kernel/Makefile b/kernel/Makefile index 0bd4ed7ca157..0c1794818579 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -12,6 +12,7 @@ obj-y = fork.o exec_domain.o panic.o \ notifier.o ksysfs.o cred.o reboot.o \ async.o range.o smpboot.o ucount.o +obj-$(CONFIG_PANIC_EVENTS) += panic_events.o obj-$(CONFIG_MODULES) += kmod.o obj-$(CONFIG_MULTIUSER) += groups.o diff --git a/kernel/module.c b/kernel/module.c index 128bfc3e7ada..9b85d58441a2 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -56,6 +56,7 @@ #include #include #include +#include #include #include "module-internal.h" @@ -330,6 +331,7 @@ static inline void add_taint_module(struct module *mod, unsigned flag, { add_taint(flag, lockdep_ok); set_bit(flag, &mod->taints); + panic_uevent_taint(flag, mod); } /* diff --git a/kernel/panic.c b/kernel/panic.c index e2157ca387c8..48e9e2efa5bb 100644 --- a/kernel/panic.c +++ b/kernel/panic.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -440,8 +441,10 @@ unsigned long get_taint(void) */ void add_taint(unsigned flag, enum lockdep_ok lockdep_ok) { - if (lockdep_ok == LOCKDEP_NOW_UNRELIABLE && __debug_locks_off()) + if (lockdep_ok == LOCKDEP_NOW_UNRELIABLE && __debug_locks_off()) { pr_warn("Disabling lock debugging due to kernel taint\n"); + panic_uevent(PANIC_LOCKDEP_DISABLED); + } set_bit(flag, &tainted_mask); @@ -449,6 +452,8 @@ void add_taint(unsigned flag, enum lockdep_ok lockdep_ok) panic_on_taint = 0; panic("panic_on_taint set ..."); } + + panic_uevent_taint(flag, NULL); } EXPORT_SYMBOL(add_taint); diff --git a/kernel/panic_events.c b/kernel/panic_events.c new file mode 100644 index 000000000000..5a53a1b1fd9a --- /dev/null +++ b/kernel/panic_events.c @@ -0,0 +1,289 @@ +// SPDX-License-Identifier: GPL-2.0+ + +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + +#include +#include +#include +#include +#include +#include + +/** + * DOC: Panic events + * + * Panic events are sent to userspace to inform userspace that something + * critical has happened to the kernel. These events can happen in any + * context, and so to send these events to userspace we preallocate memory + * needed during initialization as needed for operation. The events are + * queued and later dispatched. The uevents sent are best effort, if we are + * short of memory kobject_uevent_env() can fail. + */ + +/* The max amount of lines on a uevent we support */ +#define PANIC_UEVENT_MAX_LINES 8 + +/* We assume each possible CPU can trigger these events */ +#define PANIC_MAX_EVENTS_PER_CPU 4 + +/* The max number of concurrent uvents we support, otherwise we drop events */ +#define PANIC_NUM_CACHE_EVENTS (num_possible_cpus() * PANIC_MAX_EVENTS_PER_CPU) + +static LIST_HEAD(panic_free_list); +static spinlock_t free_lock; + +static LIST_HEAD(panic_pend_list); +static spinlock_t pend_lock; + +struct panic_event { + enum panic_uevent uevent; + char module_name[MODULE_NAME_LEN]; + enum system_states sys_state; + unsigned int flag; + struct list_head list; +}; + +static struct panic_event *panic_events; + +static struct kset *panic_kset; +static struct kobj_type empty_ktype; +static struct kobject *panic_events_kobj; +static struct kobject _panic_events_kobj; + +static void panic_process_events(struct work_struct *work); +static DECLARE_WORK(panic_events_work, panic_process_events); + +static char (*panic_envp)[PATH_MAX]; +/* Protects panic_envp */ +static DEFINE_MUTEX(panic_mutex); + +struct panic_event *get_free_panic_event(void) +{ + struct panic_event *event = NULL; + + spin_lock(&free_lock); + if (list_empty(&panic_free_list)) { + pr_warn_once("Not enough free panic pool events, we need to bump PANIC_NUM_CACHE_EVENTS, please report this\n"); + goto out; + } + event = list_first_entry(&panic_free_list, struct panic_event, list); + list_del_init(&event->list); + +out: + spin_unlock(&free_lock); + + return event; +} + +static void queue_panic_event(struct panic_event *event) +{ + spin_lock(&pend_lock); + list_add_tail(&event->list, &panic_pend_list); + spin_unlock(&pend_lock); +} + +struct panic_event *get_pend_panic_event(void) +{ + struct panic_event *event = NULL; + + spin_lock(&pend_lock); + if (list_empty(&panic_pend_list)) + goto out; + + event = list_first_entry(&panic_pend_list, struct panic_event, list); + list_del_init(&event->list); + +out: + spin_unlock(&pend_lock); + + return event; +} + +static void panic_send_event(struct panic_event *event) +{ + unsigned int idx = 0, i; + bool pending = false; + char *envp[PANIC_UEVENT_MAX_LINES]; + int r; + + mutex_lock(&panic_mutex); + memset(panic_envp, 0, PATH_MAX * PANIC_UEVENT_MAX_LINES); + snprintf(panic_envp[idx++], PATH_MAX, "SYSTEM_STATE=%d", + event->sys_state); + snprintf(panic_envp[idx++], PATH_MAX, "EVENT=%d", event->uevent); + + if (event->uevent == PANIC_LOCKDEP_DISABLED) + goto out_send; + + /* + * add_taint_module() will trigger two uevents, one for the kernel, + * and another for the module, if the module was not built-in. + */ + if (event->uevent == PANIC_TAINT) { + snprintf(panic_envp[idx++], PATH_MAX, "TAINT=%d", event->flag); + if (strcmp(event->module_name, "") != 0) + snprintf(panic_envp[idx++], PATH_MAX, "MODULE_NAME=%s", + event->module_name); + } + +out_send: + for (i = 0; i < idx; i++) + envp[i] = panic_envp[i]; + envp[idx] = NULL; + + r = kobject_uevent_env(panic_events_kobj, KOBJ_CHANGE, envp); + if (!r) + pr_debug("failed to sent uevent: %d\n", event->uevent); + mutex_unlock(&panic_mutex); + + memset(event, 0, sizeof(struct panic_event)); + + spin_lock(&free_lock); + list_add_tail(&event->list, &panic_free_list); + spin_unlock(&free_lock); + + spin_lock(&pend_lock); + if (!list_empty(&panic_pend_list)) + pending = true; + spin_unlock(&pend_lock); + + if (pending) + schedule_work(&panic_events_work); +} + +static void panic_process_events(struct work_struct *work) +{ + struct panic_event *event; + bool pending = false; + + event = get_pend_panic_event(); + if (!event) + goto out; + + panic_send_event(event); + +out: + spin_lock(&pend_lock); + if (!list_empty(&panic_pend_list)) + pending = true; + spin_unlock(&pend_lock); + + if (pending) + schedule_work(&panic_events_work); +} + +/* For simple panic uvents which only need an event type specified */ +void panic_uevent(enum panic_uevent uevent) +{ + struct panic_event *event; + + if (!panic_events_kobj) + return; + + event = get_free_panic_event(); + if (!event) + return; + + event->uevent = uevent; + event->sys_state = system_state; + + queue_panic_event(event); + schedule_work(&panic_events_work); +} + +void panic_uevent_taint(unsigned int flag, struct module *mod) +{ + struct panic_event *event; + + if (!panic_events_kobj) + return; + + event = get_free_panic_event(); + if (!event) + return; + + event->uevent = PANIC_TAINT; + event->sys_state = system_state; + event->flag = flag; + + if (mod) + strncpy(event->module_name, module_name(mod), MODULE_NAME_LEN); + + queue_panic_event(event); + schedule_work(&panic_events_work); +} + +static __init void panic_events_init(void) +{ + struct panic_event *event; + char *envp[2]; + unsigned int i; + size_t used; + int r; + + spin_lock_init(&free_lock); + spin_lock_init(&pend_lock); + + mutex_lock(&panic_mutex); + + panic_envp = kzalloc(PATH_MAX * PANIC_UEVENT_MAX_LINES, GFP_KERNEL); + if (!panic_envp) + goto out_unlock; + + panic_events = kzalloc(sizeof(struct panic_event) * + PANIC_NUM_CACHE_EVENTS, GFP_KERNEL); + if (!panic_events) + goto out_env; + + for (i = 0; i < PANIC_NUM_CACHE_EVENTS; i++) { + event = &panic_events[i]; + list_add_tail(&event->list, &panic_free_list); + } + + snprintf(panic_envp[0], PATH_MAX, "MAX_EVENT_SUPPORTED=%d", + __PANIC_MAX-1); + + envp[0] = panic_envp[0]; + envp[1] = NULL; + + panic_kset = kset_create_and_add("panic", NULL, kernel_kobj); + if (!panic_kset) + goto out_events; + + _panic_events_kobj.kset = panic_kset; + + r = kobject_init_and_add(&_panic_events_kobj, &empty_ktype, + NULL, "events"); + if (r) { + pr_warn("Could not add panic events kobject\n"); + goto out_kset; + } + + /* Without this set this infrastructure is ignored */ + panic_events_kobj = &_panic_events_kobj; + + /* Inform userspace which events we'll send uevents for */ + r = kobject_uevent_env(panic_events_kobj, KOBJ_ADD, envp); + if (r != 0) + pr_debug("failed to send first event\n"); + + mutex_unlock(&panic_mutex); + + used = (PATH_MAX * PANIC_UEVENT_MAX_LINES) + + (sizeof(struct panic_event) * PANIC_NUM_CACHE_EVENTS); + + pr_info("initialized using %zu preallocated bytes\n", used); + + return; + +out_kset: + kset_unregister(panic_kset); +out_events: + kfree(panic_events); +out_env: + kfree(panic_envp); +out_unlock: + mutex_unlock(&panic_mutex); +} + +core_initcall(panic_events_init); diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index cf77b3881a21..966e8eaad09e 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -835,6 +835,19 @@ config DEBUG_SHIRQ menu "Debug Oops, Lockups and Hangs" +config PANIC_EVENTS + bool "Enable uevents relating to panics or taints" + help + Say Y here to enable the kernel to send uevents relating to panics or + when taint events happen. This may be useful if you want to craft some + userspace component to analyze a taint, or inform the user of this + event. These events are useful later in boot, prior to device driver + initialization, so it won't capture events early in boot. The events + are also best effort, if the system is low on memory some uevents + not reach userspace. + + Say N if unsure. + config PANIC_ON_OOPS bool "Panic on Oops" help From patchwork Tue May 26 14:58:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 11572925 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AE50C60D for ; Wed, 27 May 2020 12:53:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8F74920873 for ; Wed, 27 May 2020 12:53:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590583983; bh=OcCdR7LKLgC914RG8kQDQ2gMex21XC0MywA8RY7F+cE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=DauSdnkHAVW6ZTX1P9EJqRCsbiNVlyinhmjCGgyUNo8FTry09wMB0D/TyVEEVcAFH SI+PVFdzRzSjjbNLvB2gfsaBX+y/RyOrQCPi9R8sM4gwdtA37CkUmWZYkQ6RdtNDHk f1xPaWyotR5WRVgQBAvCnkKDh6DcIoBYz9Ywhr+4= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730164AbgE0MxC (ORCPT ); Wed, 27 May 2020 08:53:02 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:36920 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729996AbgE0MxC (ORCPT ); Wed, 27 May 2020 08:53:02 -0400 Received: by mail-pl1-f193.google.com with SMTP id x10so10097558plr.4 for ; Wed, 27 May 2020 05:53:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:resent-from:resent-date:resent-message-id :resent-to:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=EvSxJvzu8CuJNVtnMN+6EPtAduMBjuHw07i/r14VRgA=; b=VCg84nfnHOACcBVJ0eG4sWzWS8mGf3NOWewdkSHkYTkFuwrwSZGzdHyCpZMzP4Qkvv Yn7T57t8JG5kSG7d9ZIE/5VzrXByDL7KbJQsIV0P8V7BDMaxtfXzP55Ylcr7VWJGDXka Kh0jl2koiTVkNFD5Gr5kj7qMGQcO3NFGw7NIBGs7Pv+F13Y4Jzsp4t40V4yHNK4FwF4/ ni74OA/hQMJyoRsn5IbQnwqmhpFvyDBKm7H/S1C8lyGKxlQuOgLEcXgTVY4VproA3Kkz 78GpIlBo0qTz6/0/gFAtH8a3utHODsiq4XF7wtWuy9/I+p1sPONem0lKUEKZw/wG1zA0 0/6g== X-Gm-Message-State: AOAM532WNe8zBfpyY9m+qq9D7hP0fYLAd4Zh6oUcb6BsqFwuyLIkkioI Qb5WaHt8iVXKNglF2pOw2Px3IwkCEG2UNg== X-Google-Smtp-Source: ABdhPJxcP6aKH7kWdCQ4g8c7Xy3Oi+7Sek/2PRaXp5l8qgRu4h/8GevSPSqSLNSuZEA4QcyWvzgHIg== X-Received: by 2002:a17:902:b68f:: with SMTP id c15mr5891442pls.303.1590583980067; Wed, 27 May 2020 05:53:00 -0700 (PDT) Received: from 42.do-not-panic.com (42.do-not-panic.com. [157.230.128.187]) by smtp.gmail.com with ESMTPSA id iq13sm2637923pjb.48.2020.05.27.05.52.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 May 2020 05:52:59 -0700 (PDT) Received: by 42.do-not-panic.com (Postfix, from userid 1000) id 1017F40605; Wed, 27 May 2020 12:52:59 +0000 (UTC) Received: from 42.do-not-panic.com (42.do-not-panic.com. [157.230.128.187]) by smtp.gmail.com with ESMTPSA id m18sm77891pjl.14.2020.05.26.07.58.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 May 2020 07:58:22 -0700 (PDT) Received: by 42.do-not-panic.com (Postfix, from userid 1000) id 2FDE941D00; Tue, 26 May 2020 14:58:18 +0000 (UTC) From: Luis Chamberlain To: jeyu@kernel.org, davem@davemloft.net, kuba@kernel.org Cc: michael.chan@broadcom.com, dchickles@marvell.com, sburla@marvell.com, fmanlunas@marvell.com, aelior@marvell.com, GR-everest-linux-l2@marvell.com, kvalo@codeaurora.org, johannes@sipsolutions.net, akpm@linux-foundation.org, arnd@arndb.de, rostedt@goodmis.org, mingo@redhat.com, aquini@redhat.com, cai@lca.pw, dyoung@redhat.com, bhe@redhat.com, peterz@infradead.org, tglx@linutronix.de, gpiccoli@canonical.com, pmladek@suse.com, tiwai@suse.de, schlad@suse.de, andriy.shevchenko@linux.intel.com, derosier@gmail.com, keescook@chromium.org, daniel.vetter@ffwll.ch, will@kernel.org, mchehab+samsung@kernel.org, vkoul@kernel.org, mchehab+huawei@kernel.org, robh@kernel.org, mhiramat@kernel.org, sfr@canb.auug.org.au, linux@dominikbrodowski.net, glider@google.com, paulmck@kernel.org, elver@google.com, bauerman@linux.ibm.com, yamada.masahiro@socionext.com, samitolvanen@google.com, yzaikin@google.com, dvyukov@google.com, rdunlap@infradead.org, corbet@lwn.net, dianders@chromium.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Luis Chamberlain Subject: [PATCH v3 3/8] taint: add firmware crash taint support Date: Tue, 26 May 2020 14:58:10 +0000 Message-Id: <20200526145815.6415-4-mcgrof@kernel.org> X-Mailer: git-send-email 2.23.0.rc1 In-Reply-To: <20200526145815.6415-1-mcgrof@kernel.org> References: <20200526145815.6415-1-mcgrof@kernel.org> MIME-Version: 1.0 X-TUID: hP3LOue9k35j Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Device drivers firmware can crash, and *sometimes*, this can leave your system in a state which makes the device or subsystem completely useless. In the worst of cases not even removing the module and adding it back again will correct your situation and you are left with no other option but to do a full system reboot. Some drivers have work arounds for these situations, and sometimes they can recover the device / functionality but not all device drivers have these arrangements and in the worst cases requiring a full reboot is completely hidden from the user experience, leaving them dumbfounded with what has happened. Detecting this by inspecting /proc/sys/kernel/tainted instead of scraping some magical words from the kernel log, which is driver specific, is much easier. So instead provide a helper which lets drivers annotate this. Once this happens, scrapers can easily look for modules taint flags for a firmware crash. This will taint both the kernel and respective calling module. The new helper taint_firmware_crashed() uses LOCKDEP_STILL_OK as this fact should in no way shape or form affect lockdep. This taint is device driver specific. While extending the declaration of add_taint_module(), just make the flag unsigned int clear. Signed-off-by: Luis Chamberlain --- Documentation/admin-guide/tainted-kernels.rst | 6 ++++++ include/linux/kernel.h | 2 +- include/linux/module.h | 13 +++++++++++++ include/trace/events/module.h | 3 ++- include/uapi/linux/kernel.h | 1 + kernel/module.c | 13 +++++++++---- kernel/panic.c | 1 + tools/debugging/kernel-chktaint | 7 +++++++ 8 files changed, 40 insertions(+), 6 deletions(-) diff --git a/Documentation/admin-guide/tainted-kernels.rst b/Documentation/admin-guide/tainted-kernels.rst index 71e9184a9079..92530f1d60ae 100644 --- a/Documentation/admin-guide/tainted-kernels.rst +++ b/Documentation/admin-guide/tainted-kernels.rst @@ -100,6 +100,7 @@ Bit Log Number Reason that got the kernel tainted 15 _/K 32768 kernel has been live patched 16 _/X 65536 auxiliary taint, defined for and used by distros 17 _/T 131072 kernel was built with the struct randomization plugin + 18 _/Q 262144 driver firmware crash annotation === === ====== ======================================================== Note: The character ``_`` is representing a blank in this table to make reading @@ -162,3 +163,8 @@ More detailed explanation for tainting produce extremely unusual kernel structure layouts (even performance pathological ones), which is important to know when debugging. Set at build time. + + 18) ``Q`` used by device drivers to annotate that the device driver's firmware + has crashed and the device's operation has been severely affected. The + device may be left in a crippled state, requiring full driver removal / + addition, system reboot, or it is unclear how long recovery will take. diff --git a/include/linux/kernel.h b/include/linux/kernel.h index 337634363d00..a1974907c320 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h @@ -571,7 +571,7 @@ extern int root_mountflags; extern bool early_boot_irqs_disabled; extern enum system_states system_state; -#define TAINT_FLAGS_COUNT 18 +#define TAINT_FLAGS_COUNT 19 #define TAINT_FLAGS_MAX ((1UL << TAINT_FLAGS_COUNT) - 1) struct taint_flag { diff --git a/include/linux/module.h b/include/linux/module.h index 2e6670860d27..b3e143d2993e 100644 --- a/include/linux/module.h +++ b/include/linux/module.h @@ -705,6 +705,14 @@ static inline bool is_livepatch_module(struct module *mod) bool is_module_sig_enforced(void); void set_module_sig_enforced(void); +void add_taint_module(struct module *mod, unsigned int flag, + enum lockdep_ok lockdep_ok); + +static inline void taint_firmware_crashed(void) +{ + add_taint_module(THIS_MODULE, TAINT_FIRMWARE_CRASH, LOCKDEP_STILL_OK); +} + #else /* !CONFIG_MODULES... */ static inline struct module *__module_address(unsigned long addr) @@ -852,6 +860,11 @@ void *dereference_module_function_descriptor(struct module *mod, void *ptr) return ptr; } +static inline void taint_firmware_crashed(void) +{ + add_taint(TAINT_FIRMWARE_CRASH, LOCKDEP_STILL_OK); +} + #endif /* CONFIG_MODULES */ #ifdef CONFIG_SYSFS diff --git a/include/trace/events/module.h b/include/trace/events/module.h index 097485c73c01..b749ea25affd 100644 --- a/include/trace/events/module.h +++ b/include/trace/events/module.h @@ -26,7 +26,8 @@ struct module; { (1UL << TAINT_OOT_MODULE), "O" }, \ { (1UL << TAINT_FORCED_MODULE), "F" }, \ { (1UL << TAINT_CRAP), "C" }, \ - { (1UL << TAINT_UNSIGNED_MODULE), "E" }) + { (1UL << TAINT_UNSIGNED_MODULE), "E" }, \ + { (1UL << TAINT_FIRMWARE_CRASH), "Q" }) TRACE_EVENT(module_load, diff --git a/include/uapi/linux/kernel.h b/include/uapi/linux/kernel.h index 4bbd4093eb64..1e364659afca 100644 --- a/include/uapi/linux/kernel.h +++ b/include/uapi/linux/kernel.h @@ -45,6 +45,7 @@ enum system_states { #define TAINT_LIVEPATCH 15 #define TAINT_AUX 16 #define TAINT_RANDSTRUCT 17 +#define TAINT_FIRMWARE_CRASH 18 /* be sure to update TAINT_FLAGS_COUNT when extending this */ #endif /* _UAPI_LINUX_KERNEL_H */ diff --git a/kernel/module.c b/kernel/module.c index 9b85d58441a2..538def226332 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -326,13 +326,18 @@ static inline int strong_try_module_get(struct module *mod) return -ENOENT; } -static inline void add_taint_module(struct module *mod, unsigned flag, - enum lockdep_ok lockdep_ok) +void add_taint_module(struct module *mod, unsigned int flag, + enum lockdep_ok lockdep_ok) { add_taint(flag, lockdep_ok); - set_bit(flag, &mod->taints); - panic_uevent_taint(flag, mod); + + /* Skip this if the module is built-in */ + if (mod) { + set_bit(flag, &mod->taints); + panic_uevent_taint(flag, mod); + } } +EXPORT_SYMBOL_GPL(add_taint_module); /* * A thread that wants to hold a reference to a module only while it diff --git a/kernel/panic.c b/kernel/panic.c index 48e9e2efa5bb..cb1c5619e983 100644 --- a/kernel/panic.c +++ b/kernel/panic.c @@ -387,6 +387,7 @@ const struct taint_flag taint_flags[TAINT_FLAGS_COUNT] = { [ TAINT_LIVEPATCH ] = { 'K', ' ', true }, [ TAINT_AUX ] = { 'X', ' ', true }, [ TAINT_RANDSTRUCT ] = { 'T', ' ', true }, + [ TAINT_FIRMWARE_CRASH ] = { 'Q', ' ', true }, }; /** diff --git a/tools/debugging/kernel-chktaint b/tools/debugging/kernel-chktaint index 2240cb56e6e5..c397c6aabea7 100755 --- a/tools/debugging/kernel-chktaint +++ b/tools/debugging/kernel-chktaint @@ -194,6 +194,13 @@ else addout "T" echo " * kernel was built with the struct randomization plugin (#17)" fi +T=`expr $T / 2` +if [ `expr $T % 2` -eq 0 ]; then + addout " " +else + addout "Q" + echo " * a device driver's firmware has crashed (#18)" +fi echo "For a more detailed explanation of the various taint flags see" echo " Documentation/admin-guide/tainted-kernels.rst in the the Linux kernel sources" From patchwork Tue May 26 14:58:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 11572929 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 49C8560D for ; Wed, 27 May 2020 12:53:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3333D20873 for ; Wed, 27 May 2020 12:53:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590583987; bh=dZeLXoUBQtKDHLLwUZOY5erPD//Mcj+l4J+EmoZeztE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=F0vLWCYabqE+ndsG+p+MIPbjlPzjfT2twkDyIikuHB8IhTB2NRzI5JAkDqHYFuxgJ mCORPiJNyqU0+43zTV7hinEYH3Gp0iRcjzdEVnRDucOqI58mMFK9eNqS3F/r5j3lL4 Lu7nXXaAaD20b1pwv7DTJXxOmzOHdNlArCnZCEdg= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730169AbgE0MxG (ORCPT ); Wed, 27 May 2020 08:53:06 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:41376 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729996AbgE0MxG (ORCPT ); Wed, 27 May 2020 08:53:06 -0400 Received: by mail-pl1-f194.google.com with SMTP id a13so10110813pls.8 for ; Wed, 27 May 2020 05:53:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:resent-from:resent-date:resent-message-id :resent-to:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=UXRYeaDc02XdMrQZXPWL4bjUJlIpwN0dvTWzE8/MMVk=; b=qFsP3D8KYLpRVjfhq/SwtGBvOBeTTWpoGbue3gA72kokywiUQybPBleMd0U1ziTpuG 89g94/CEQPorKTrl18FNXCZ3azwPVBRXGkg3iWyo9XHcmkuKj2I4OizGrc1RErU4jepp 6NA1z9QCz5k1q6GfLm7+K12swsfWVOLu4TwaRLhVKpJbZBkFK8OIrZnBYYd06AXFjpk9 RF8jJUwhEgXYWKqEVqT2ZCqMHUTExjVywkb0zak+Htjdys+17QJrdFrf9/KA3f/GG86U EKWPefWRNv2RUu6hncIWT/p+HEfEgSLcoptoJ6WBu2SkBtjLBXEW/FmSLH29T1qlVerq 68Ig== X-Gm-Message-State: AOAM532SJhm8aE0MuYzU+DfyHRez8U/Z/YQ4uKX1x6h6EH9k3cV3hA/l Sta9f72FPVdSnFEY8GFl9AxWXgmzM3H0hA== X-Google-Smtp-Source: ABdhPJwMCW7fFpZ/UvjWvAVI3jCGhdM8d8BhJ0CII0fE+lGgZP5tnoP6hQRj5nH/EWvNB+Mv4yLugQ== X-Received: by 2002:a17:90a:3326:: with SMTP id m35mr5101494pjb.10.1590583983544; Wed, 27 May 2020 05:53:03 -0700 (PDT) Received: from 42.do-not-panic.com (42.do-not-panic.com. [157.230.128.187]) by smtp.gmail.com with ESMTPSA id b23sm2041528pgs.33.2020.05.27.05.53.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 May 2020 05:53:03 -0700 (PDT) Received: by 42.do-not-panic.com (Postfix, from userid 1000) id 3A50140605; Wed, 27 May 2020 12:53:02 +0000 (UTC) Received: from 42.do-not-panic.com (42.do-not-panic.com. [157.230.128.187]) by smtp.gmail.com with ESMTPSA id x13sm15122851pfn.200.2020.05.26.07.58.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 May 2020 07:58:22 -0700 (PDT) Received: by 42.do-not-panic.com (Postfix, from userid 1000) id 6982C41D12; Tue, 26 May 2020 14:58:18 +0000 (UTC) From: Luis Chamberlain To: jeyu@kernel.org, davem@davemloft.net, kuba@kernel.org Cc: michael.chan@broadcom.com, dchickles@marvell.com, sburla@marvell.com, fmanlunas@marvell.com, aelior@marvell.com, GR-everest-linux-l2@marvell.com, kvalo@codeaurora.org, johannes@sipsolutions.net, akpm@linux-foundation.org, arnd@arndb.de, rostedt@goodmis.org, mingo@redhat.com, aquini@redhat.com, cai@lca.pw, dyoung@redhat.com, bhe@redhat.com, peterz@infradead.org, tglx@linutronix.de, gpiccoli@canonical.com, pmladek@suse.com, tiwai@suse.de, schlad@suse.de, andriy.shevchenko@linux.intel.com, derosier@gmail.com, keescook@chromium.org, daniel.vetter@ffwll.ch, will@kernel.org, mchehab+samsung@kernel.org, vkoul@kernel.org, mchehab+huawei@kernel.org, robh@kernel.org, mhiramat@kernel.org, sfr@canb.auug.org.au, linux@dominikbrodowski.net, glider@google.com, paulmck@kernel.org, elver@google.com, bauerman@linux.ibm.com, yamada.masahiro@socionext.com, samitolvanen@google.com, yzaikin@google.com, dvyukov@google.com, rdunlap@infradead.org, corbet@lwn.net, dianders@chromium.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Luis Chamberlain Subject: [PATCH v3 4/8] panic: make taint data type clearer Date: Tue, 26 May 2020 14:58:11 +0000 Message-Id: <20200526145815.6415-5-mcgrof@kernel.org> X-Mailer: git-send-email 2.23.0.rc1 In-Reply-To: <20200526145815.6415-1-mcgrof@kernel.org> References: <20200526145815.6415-1-mcgrof@kernel.org> MIME-Version: 1.0 X-TUID: ofW0vIudzYdt Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Let us be clearer about the the data type for the taint flag. Signed-off-by: Luis Chamberlain --- include/asm-generic/bug.h | 4 ++-- include/linux/kernel.h | 4 ++-- kernel/panic.c | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/asm-generic/bug.h b/include/asm-generic/bug.h index c94e33ae3e7b..87dbe57301f4 100644 --- a/include/asm-generic/bug.h +++ b/include/asm-generic/bug.h @@ -80,7 +80,7 @@ struct bug_entry { */ #ifndef __WARN_FLAGS extern __printf(4, 5) -void warn_slowpath_fmt(const char *file, const int line, unsigned taint, +void warn_slowpath_fmt(const char *file, const int line, unsigned int taint, const char *fmt, ...); #define __WARN() __WARN_printf(TAINT_WARN, NULL) #define __WARN_printf(taint, arg...) do { \ @@ -110,7 +110,7 @@ extern __printf(1, 2) void __warn_printk(const char *fmt, ...); struct warn_args; struct pt_regs; -void __warn(const char *file, int line, void *caller, unsigned taint, +void __warn(const char *file, int line, void *caller, unsigned int taint, struct pt_regs *regs, struct warn_args *args); #ifndef WARN_ON diff --git a/include/linux/kernel.h b/include/linux/kernel.h index a1974907c320..d154844eb9cd 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h @@ -563,8 +563,8 @@ enum lockdep_ok { LOCKDEP_STILL_OK, LOCKDEP_NOW_UNRELIABLE }; -extern void add_taint(unsigned flag, enum lockdep_ok); -extern int test_taint(unsigned flag); +extern void add_taint(unsigned int flag, enum lockdep_ok); +extern int test_taint(unsigned int flag); extern unsigned long get_taint(void); extern int root_mountflags; diff --git a/kernel/panic.c b/kernel/panic.c index cb1c5619e983..3cfe84318ecf 100644 --- a/kernel/panic.c +++ b/kernel/panic.c @@ -421,7 +421,7 @@ const char *print_tainted(void) return buf; } -int test_taint(unsigned flag) +int test_taint(unsigned int flag) { return test_bit(flag, &tainted_mask); } @@ -440,7 +440,7 @@ unsigned long get_taint(void) * If something bad has gone wrong, you'll want @lockdebug_ok = false, but for * some notewortht-but-not-corrupting cases, it can be set to true. */ -void add_taint(unsigned flag, enum lockdep_ok lockdep_ok) +void add_taint(unsigned int flag, enum lockdep_ok lockdep_ok) { if (lockdep_ok == LOCKDEP_NOW_UNRELIABLE && __debug_locks_off()) { pr_warn("Disabling lock debugging due to kernel taint\n"); @@ -579,7 +579,7 @@ struct warn_args { va_list args; }; -void __warn(const char *file, int line, void *caller, unsigned taint, +void __warn(const char *file, int line, void *caller, unsigned int taint, struct pt_regs *regs, struct warn_args *args) { disable_trace_on_warning(); @@ -622,7 +622,7 @@ void __warn(const char *file, int line, void *caller, unsigned taint, } #ifndef __WARN_FLAGS -void warn_slowpath_fmt(const char *file, int line, unsigned taint, +void warn_slowpath_fmt(const char *file, int line, unsigned int taint, const char *fmt, ...) { struct warn_args args; From patchwork Tue May 26 14:58:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 11570677 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 297811392 for ; Tue, 26 May 2020 14:58:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0CA8520723 for ; Tue, 26 May 2020 14:58:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590505134; bh=z4g8BXqkxKpN8OSDwsb3VvEAcHlgSEkYYBGnThWscbM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=BJwwGBTF5QGY/NfmW5Nj0cJwGJAn1b/OX7rMK8Kq/BxcO7vitK3ilvoMGPj3tUPdl 7r8XEhJaBFn3J4EJvXHOpD9Xyjv8dE1/xYsawxfDK+2CVo0RpvGlMK7sqfJc5LClg0 iaHvv7uygjq0M5dsqU1GS3CFOjQgim1GbZNLXlpM= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731443AbgEZO6m (ORCPT ); Tue, 26 May 2020 10:58:42 -0400 Received: from mail-pj1-f68.google.com ([209.85.216.68]:36647 "EHLO mail-pj1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731353AbgEZO63 (ORCPT ); Tue, 26 May 2020 10:58:29 -0400 Received: by mail-pj1-f68.google.com with SMTP id q24so1447500pjd.1; Tue, 26 May 2020 07:58:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=llTH2n++tTVLBhGsV5Icw97tnABVgUx2YdNChWoYrTA=; b=A2xhpnQUC2hi8e/mORVqh5I+pLYzNsbb5VK0d/u6QKGDxV4p668ZwF9PQ267n69q/b loX1NPHcqQSLki7AvTypHz52LfeP8aeYPb4M7KqfSlQ4uLF5CvD9cbeLWXuljTBbStnB CMZrCi6O76w1zos9qnMB5E8e26OIIEEBQkw1hh34qVdM8ul4O1o9yH5ScX7VWPQSzkv8 q6jIMJAFd7+84hX+Q3rhDQT5VpmyWYIAMo1NaP1X52kBnAx5jBL3GDLGz9vXyHCowk0w Q5m/wZYodoFwQHdOboJc9d7PPTsUCwtptxvkkKQ86vLbonMIySEoiOR/Saew1y8BKFqx OOPA== X-Gm-Message-State: AOAM532zKE1gClFWYH/JIS1XzmNWE+nSXhbvl18K9qAiOnKH+vd9ruJI xAi5XMDmjmllN9tQzmBaTPkt/+TojwuyRA== X-Google-Smtp-Source: ABdhPJyLz50Sjirnf6zkmVAF4v4gho1TNrewe05nIrzVVuTcQr6Kt75n4njhYwpQzdS375ICVt/pXA== X-Received: by 2002:a17:902:9043:: with SMTP id w3mr1387143plz.250.1590505107012; Tue, 26 May 2020 07:58:27 -0700 (PDT) Received: from 42.do-not-panic.com (42.do-not-panic.com. [157.230.128.187]) by smtp.gmail.com with ESMTPSA id s15sm40988pgv.5.2020.05.26.07.58.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 May 2020 07:58:25 -0700 (PDT) Received: by 42.do-not-panic.com (Postfix, from userid 1000) id 9028741DCA; Tue, 26 May 2020 14:58:18 +0000 (UTC) From: Luis Chamberlain To: jeyu@kernel.org, davem@davemloft.net, kuba@kernel.org Cc: michael.chan@broadcom.com, dchickles@marvell.com, sburla@marvell.com, fmanlunas@marvell.com, aelior@marvell.com, GR-everest-linux-l2@marvell.com, kvalo@codeaurora.org, johannes@sipsolutions.net, akpm@linux-foundation.org, arnd@arndb.de, rostedt@goodmis.org, mingo@redhat.com, aquini@redhat.com, cai@lca.pw, dyoung@redhat.com, bhe@redhat.com, peterz@infradead.org, tglx@linutronix.de, gpiccoli@canonical.com, pmladek@suse.com, tiwai@suse.de, schlad@suse.de, andriy.shevchenko@linux.intel.com, derosier@gmail.com, keescook@chromium.org, daniel.vetter@ffwll.ch, will@kernel.org, mchehab+samsung@kernel.org, vkoul@kernel.org, mchehab+huawei@kernel.org, robh@kernel.org, mhiramat@kernel.org, sfr@canb.auug.org.au, linux@dominikbrodowski.net, glider@google.com, paulmck@kernel.org, elver@google.com, bauerman@linux.ibm.com, yamada.masahiro@socionext.com, samitolvanen@google.com, yzaikin@google.com, dvyukov@google.com, rdunlap@infradead.org, corbet@lwn.net, dianders@chromium.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Luis Chamberlain , linux-wireless@vger.kernel.org, ath10k@lists.infradead.org Subject: [PATCH v3 5/8] ath10k: use new taint_firmware_crashed() Date: Tue, 26 May 2020 14:58:12 +0000 Message-Id: <20200526145815.6415-6-mcgrof@kernel.org> X-Mailer: git-send-email 2.23.0.rc1 In-Reply-To: <20200526145815.6415-1-mcgrof@kernel.org> References: <20200526145815.6415-1-mcgrof@kernel.org> MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org This makes use of the new taint_firmware_crashed() to help annotate when firmware for device drivers crash. When firmware crashes devices can sometimes become unresponsive, and recovery sometimes requires a driver unload / reload and in the worst cases a reboot. Using a taint flag allows us to annotate when this happens clearly. I have run into this situation with this driver with the latest firmware as of today, May 21, 2020 using v5.6.0, leaving me at a state at which my only option is to reboot. Driver removal and addition does not fix the situation. This is reported on kernel.org bugzilla korg#207851 [0]. But this isn't the first firmware crash reported, others have been filed before and none of these bugs have yet been addressed [1] [2] [3]. Including my own I see these firmware crash reports: * korg#207851 [0] * korg#197013 [1] * korg#201237 [2] * korg#195987 [3] [0] https://bugzilla.kernel.org/show_bug.cgi?id=207851 [1] https://bugzilla.kernel.org/show_bug.cgi?id=197013 [2] https://bugzilla.kernel.org/show_bug.cgi?id=201237 [3] https://bugzilla.kernel.org/show_bug.cgi?id=195987 Cc: linux-wireless@vger.kernel.org Cc: ath10k@lists.infradead.org Cc: Kalle Valo Acked-by: Rafael Aquini Signed-off-by: Luis Chamberlain --- drivers/net/wireless/ath/ath10k/pci.c | 2 ++ drivers/net/wireless/ath/ath10k/sdio.c | 2 ++ drivers/net/wireless/ath/ath10k/snoc.c | 1 + 3 files changed, 5 insertions(+) diff --git a/drivers/net/wireless/ath/ath10k/pci.c b/drivers/net/wireless/ath/ath10k/pci.c index 1d941d53fdc9..818c3acc2468 100644 --- a/drivers/net/wireless/ath/ath10k/pci.c +++ b/drivers/net/wireless/ath/ath10k/pci.c @@ -1767,6 +1767,7 @@ static void ath10k_pci_fw_dump_work(struct work_struct *work) scnprintf(guid, sizeof(guid), "n/a"); ath10k_err(ar, "firmware crashed! (guid %s)\n", guid); + taint_firmware_crashed(); ath10k_print_driver_info(ar); ath10k_pci_dump_registers(ar, crash_data); ath10k_ce_dump_registers(ar, crash_data); @@ -2837,6 +2838,7 @@ static int ath10k_pci_hif_power_up(struct ath10k *ar, if (ret) { if (ath10k_pci_has_fw_crashed(ar)) { ath10k_warn(ar, "firmware crashed during chip reset\n"); + taint_firmware_crashed(); ath10k_pci_fw_crashed_clear(ar); ath10k_pci_fw_crashed_dump(ar); } diff --git a/drivers/net/wireless/ath/ath10k/sdio.c b/drivers/net/wireless/ath/ath10k/sdio.c index e2aff2254a40..8b2fc0b89be4 100644 --- a/drivers/net/wireless/ath/ath10k/sdio.c +++ b/drivers/net/wireless/ath/ath10k/sdio.c @@ -794,6 +794,7 @@ static int ath10k_sdio_mbox_proc_dbg_intr(struct ath10k *ar) /* TODO: Add firmware crash handling */ ath10k_warn(ar, "firmware crashed\n"); + taint_firmware_crashed(); /* read counter to clear the interrupt, the debug error interrupt is * counter 0. @@ -915,6 +916,7 @@ static int ath10k_sdio_mbox_proc_cpu_intr(struct ath10k *ar) if (cpu_int_status & MBOX_CPU_STATUS_ENABLE_ASSERT_MASK) { ath10k_err(ar, "firmware crashed!\n"); queue_work(ar->workqueue, &ar->restart_work); + taint_firmware_crashed(); } return ret; } diff --git a/drivers/net/wireless/ath/ath10k/snoc.c b/drivers/net/wireless/ath/ath10k/snoc.c index 354d49b1cd45..071ee7607a4c 100644 --- a/drivers/net/wireless/ath/ath10k/snoc.c +++ b/drivers/net/wireless/ath/ath10k/snoc.c @@ -1451,6 +1451,7 @@ void ath10k_snoc_fw_crashed_dump(struct ath10k *ar) scnprintf(guid, sizeof(guid), "n/a"); ath10k_err(ar, "firmware crashed! (guid %s)\n", guid); + taint_firmware_crashed(); ath10k_print_driver_info(ar); ath10k_msa_dump_memory(ar, crash_data); mutex_unlock(&ar->dump_mutex); From patchwork Tue May 26 14:58:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 11572933 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1E3FC60D for ; Wed, 27 May 2020 12:53:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 078C320873 for ; Wed, 27 May 2020 12:53:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590583993; bh=w6cYeMI9QxlHC8AWjjavyai2TK5T6/96DBjhjcHIf74=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=adX4au5/xh3Z/VmVSbaHgGCtkzuQQ9yDyxJlkv7+ZXA9kjRtBOhpJb2PU9tvmpC5c mOeuoyfjzQvD2elWYxgOZU3Yk6+9Z3MZSm3KzJJ1Ko8qTJ13Fb8qkZpeoD/WBTiHeB tvPRbZ9xZ/uKfotbOI6NivY0fW3UUENqQZA738RE= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730175AbgE0MxL (ORCPT ); Wed, 27 May 2020 08:53:11 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:36011 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729996AbgE0MxK (ORCPT ); Wed, 27 May 2020 08:53:10 -0400 Received: by mail-pf1-f196.google.com with SMTP id e11so10826157pfn.3 for ; Wed, 27 May 2020 05:53:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:resent-from:resent-date:resent-message-id :resent-to:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zOBEOlJCwRVyUrO7obeZe7+iAPzekeZt6xLUEcXHiBo=; b=t7UHbFMU2DutgLcHwrnQ3/nF24FDJxRuCQ4NA6KunaP5Z6fl1WPbarZzm3dbgtXRpu N9eDE1rx7vJgOMymC7vf5nJ5Cy6MsfhUgVZGExL7mTaLFa8lFW5tDB+1aKPtKgP/K2wK H15zUU72tewomZLD4zckx+kCCwA3ShyAT8JT74aAnrvqtwtD+//1zmSdOuknJqp73Fnt fGrZFjt4RGBMceR4qYKRoDQGSciH/2048DTndpWSn68Rb+NCLn6FOPL1tRWdDPbpzuko XEKoCtihbqpclQlCJxKy9X4SiXP8sTmLKRM51s/ChrvLs0Ba7+CgEgkUADdzBx9PJWRN VrdQ== X-Gm-Message-State: AOAM531bj72EbxobJt7IN5oAO3mb6jdf4FyN3YL1gl5hA4oPLAEMKb/W tGObbsb5xtbO10ctn+s4ktok20ymiRpZvg== X-Google-Smtp-Source: ABdhPJw74r4jz1NFbP9PfWTp0TcW0IDRd+JjEhsryiAFRLW+nIVjUkb/9DSfOTscCG0tL92lKb4fww== X-Received: by 2002:a63:cc4f:: with SMTP id q15mr3771086pgi.439.1590583989750; Wed, 27 May 2020 05:53:09 -0700 (PDT) Received: from 42.do-not-panic.com (42.do-not-panic.com. [157.230.128.187]) by smtp.gmail.com with ESMTPSA id g1sm2069069pfo.142.2020.05.27.05.53.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 May 2020 05:53:09 -0700 (PDT) Received: by 42.do-not-panic.com (Postfix, from userid 1000) id 62E6C40605; Wed, 27 May 2020 12:53:08 +0000 (UTC) Received: from 42.do-not-panic.com (42.do-not-panic.com. [157.230.128.187]) by smtp.gmail.com with ESMTPSA id r69sm15995450pfc.209.2020.05.26.07.58.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 May 2020 07:58:25 -0700 (PDT) Received: by 42.do-not-panic.com (Postfix, from userid 1000) id B4A6F422E5; Tue, 26 May 2020 14:58:18 +0000 (UTC) From: Luis Chamberlain To: jeyu@kernel.org, davem@davemloft.net, kuba@kernel.org Cc: michael.chan@broadcom.com, dchickles@marvell.com, sburla@marvell.com, fmanlunas@marvell.com, aelior@marvell.com, GR-everest-linux-l2@marvell.com, kvalo@codeaurora.org, johannes@sipsolutions.net, akpm@linux-foundation.org, arnd@arndb.de, rostedt@goodmis.org, mingo@redhat.com, aquini@redhat.com, cai@lca.pw, dyoung@redhat.com, bhe@redhat.com, peterz@infradead.org, tglx@linutronix.de, gpiccoli@canonical.com, pmladek@suse.com, tiwai@suse.de, schlad@suse.de, andriy.shevchenko@linux.intel.com, derosier@gmail.com, keescook@chromium.org, daniel.vetter@ffwll.ch, will@kernel.org, mchehab+samsung@kernel.org, vkoul@kernel.org, mchehab+huawei@kernel.org, robh@kernel.org, mhiramat@kernel.org, sfr@canb.auug.org.au, linux@dominikbrodowski.net, glider@google.com, paulmck@kernel.org, elver@google.com, bauerman@linux.ibm.com, yamada.masahiro@socionext.com, samitolvanen@google.com, yzaikin@google.com, dvyukov@google.com, rdunlap@infradead.org, corbet@lwn.net, dianders@chromium.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Vasundhara Volam , Luis Chamberlain Subject: [PATCH v3 6/8] bnxt_en: use new taint_firmware_crashed() Date: Tue, 26 May 2020 14:58:13 +0000 Message-Id: <20200526145815.6415-7-mcgrof@kernel.org> X-Mailer: git-send-email 2.23.0.rc1 In-Reply-To: <20200526145815.6415-1-mcgrof@kernel.org> References: <20200526145815.6415-1-mcgrof@kernel.org> MIME-Version: 1.0 X-TUID: 6RHjWPRLSqR3 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Vasundhara Volam This makes use of the new module_firmware_crashed() to help annotate when firmware for device drivers crash. When firmware crashes devices can sometimes become unresponsive, and recovery sometimes requires a driver unload / reload and in the worst cases a reboot. Using a taint flag allows us to annotate when this happens clearly. Cc: Michael Chan Cc: Luis Chamberlain Acked-by: Rafael Aquini Signed-off-by: Vasundhara Volam Signed-off-by: Luis Chamberlain Reviewed-by: Michael Chan --- drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c index a812beb46325..776a7ae0ef7f 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c @@ -121,6 +121,7 @@ static int bnxt_fw_fatal_recover(struct devlink_health_reporter *reporter, if (!priv_ctx) return -EOPNOTSUPP; + taint_firmware_crashed(); bp->fw_health->fatal = true; event = fw_reporter_ctx->sp_event; if (event == BNXT_FW_RESET_NOTIFY_SP_EVENT) From patchwork Tue May 26 14:58:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 11572935 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E2D8D60D for ; Wed, 27 May 2020 12:53:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CAC9420873 for ; Wed, 27 May 2020 12:53:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590583998; bh=2UCJ2+0HMUg+V9H51K3IUfS7z9rwxVY2sHw2wIkMC/I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=05vCVB3YTTLH6sWyrKfMRqPnR/gC+30oroflSkz9w8YYH5AphNnzIm5aLoGoph5sk AFSXAnqpql35yHPu320kwxJixl+HEaJTxYK4UyZU6S16B1WhlcwYv6phLJO+NdzOYW mzbEl0J7lslGujUmvHYyJHxRuXLWdPc9CL305WXY= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730146AbgE0MxS (ORCPT ); Wed, 27 May 2020 08:53:18 -0400 Received: from mail-pj1-f67.google.com ([209.85.216.67]:35210 "EHLO mail-pj1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729996AbgE0MxR (ORCPT ); Wed, 27 May 2020 08:53:17 -0400 Received: by mail-pj1-f67.google.com with SMTP id 5so1492394pjd.0 for ; Wed, 27 May 2020 05:53:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:resent-from:resent-date:resent-message-id :resent-to:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lLNCK+WRq9ug4fTBP9sca/wv2hUwl+4zOX5ypfLbsKY=; b=ipuT9cBXcwk15LlCsWc6uFhqV3X6F8SYJ00yqhr2/8xQZT9EPw4y7MNd8hFgOGjeVM eLJaq1C+CyJejpogb2hSB3aTQKmxA5eVYQYarhENIMUQTPdlG79PvPqSq7HteUh2EXjR liwI2FTiezEnputrexTUNdZGc2OukgHay8X7FX+7uS5P7ys+ZXW2rog6G+PRe2VMg4TU Sr4Ppot0Bf9OkXXpqstNeITpmOOZyN5G2M0rPdvaTT9vjt2DKXzR/dSqFsfaGOVc59FT 931+8/3zqPLdxE5fBaHPNXWu3q/GiCRgOCzD6Xx132YdSovhFuGrLSPUbRwvQCsvPbWW 7Qpw== X-Gm-Message-State: AOAM530uvanuBBPk00ICNf2XdFaJpRym9qvreAamboA+GBfwVgWtjzLU N+fpXpE9Mfus4eRbWcOLzjLkQEWzzkWaBw== X-Google-Smtp-Source: ABdhPJw02sl0t/dA62cYxQC4t2rcjEd1E7uQMG1gOeGf1c8/8uma+SnNHzaBo4Nm2MNbvV0BBNa2VQ== X-Received: by 2002:a17:90a:bb8b:: with SMTP id v11mr5006195pjr.50.1590583996288; Wed, 27 May 2020 05:53:16 -0700 (PDT) Received: from 42.do-not-panic.com (42.do-not-panic.com. [157.230.128.187]) by smtp.gmail.com with ESMTPSA id dw13sm2531331pjb.40.2020.05.27.05.53.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 May 2020 05:53:16 -0700 (PDT) Received: by 42.do-not-panic.com (Postfix, from userid 1000) id 2FEAC40605; Wed, 27 May 2020 12:53:15 +0000 (UTC) Received: from 42.do-not-panic.com (42.do-not-panic.com. [157.230.128.187]) by smtp.gmail.com with ESMTPSA id y14sm15686666pfr.11.2020.05.26.07.58.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 May 2020 07:58:25 -0700 (PDT) Received: by 42.do-not-panic.com (Postfix, from userid 1000) id D804142309; Tue, 26 May 2020 14:58:18 +0000 (UTC) From: Luis Chamberlain To: jeyu@kernel.org, davem@davemloft.net, kuba@kernel.org Cc: michael.chan@broadcom.com, dchickles@marvell.com, sburla@marvell.com, fmanlunas@marvell.com, aelior@marvell.com, GR-everest-linux-l2@marvell.com, kvalo@codeaurora.org, johannes@sipsolutions.net, akpm@linux-foundation.org, arnd@arndb.de, rostedt@goodmis.org, mingo@redhat.com, aquini@redhat.com, cai@lca.pw, dyoung@redhat.com, bhe@redhat.com, peterz@infradead.org, tglx@linutronix.de, gpiccoli@canonical.com, pmladek@suse.com, tiwai@suse.de, schlad@suse.de, andriy.shevchenko@linux.intel.com, derosier@gmail.com, keescook@chromium.org, daniel.vetter@ffwll.ch, will@kernel.org, mchehab+samsung@kernel.org, vkoul@kernel.org, mchehab+huawei@kernel.org, robh@kernel.org, mhiramat@kernel.org, sfr@canb.auug.org.au, linux@dominikbrodowski.net, glider@google.com, paulmck@kernel.org, elver@google.com, bauerman@linux.ibm.com, yamada.masahiro@socionext.com, samitolvanen@google.com, yzaikin@google.com, dvyukov@google.com, rdunlap@infradead.org, corbet@lwn.net, dianders@chromium.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Luis Chamberlain Subject: [PATCH v3 7/8] liquidio: use new taint_firmware_crashed() Date: Tue, 26 May 2020 14:58:14 +0000 Message-Id: <20200526145815.6415-8-mcgrof@kernel.org> X-Mailer: git-send-email 2.23.0.rc1 In-Reply-To: <20200526145815.6415-1-mcgrof@kernel.org> References: <20200526145815.6415-1-mcgrof@kernel.org> MIME-Version: 1.0 X-TUID: qc+Is70wjb5b Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org This makes use of the new taint_firmware_crashed() to help annotate when firmware for device drivers crash. When firmware crashes devices can sometimes become unresponsive, and recovery sometimes requires a driver unload / reload and in the worst cases a reboot. Using a taint flag allows us to annotate when this happens clearly. Cc: Derek Chickles Cc: Satanand Burla Cc: Felix Manlunas Acked-by: Rafael Aquini Reviewed-by: Derek Chickles Signed-off-by: Luis Chamberlain --- drivers/net/ethernet/cavium/liquidio/lio_main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/ethernet/cavium/liquidio/lio_main.c b/drivers/net/ethernet/cavium/liquidio/lio_main.c index 66d31c018c7e..ee1796ea4818 100644 --- a/drivers/net/ethernet/cavium/liquidio/lio_main.c +++ b/drivers/net/ethernet/cavium/liquidio/lio_main.c @@ -801,6 +801,7 @@ static int liquidio_watchdog(void *param) continue; WRITE_ONCE(oct->cores_crashed, true); + taint_firmware_crashed(); other_oct = get_other_octeon_device(oct); if (other_oct) WRITE_ONCE(other_oct->cores_crashed, true); From patchwork Tue May 26 14:58:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 11572937 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 18BFA159A for ; Wed, 27 May 2020 12:53:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 01BBB20873 for ; Wed, 27 May 2020 12:53:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590584004; bh=rh/ZwuBqEQdTP5hmpFrECM/X5iKXZZT4RSLrxOAfj5g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=IPTKJrwsX+KQC5/Zxq1A87EM7+bOYCkLJkc6OP5Cha03sml0i0Thitwnv0PtOBJGU E8h0o5eVTC+zx0QxUQvkwPXwSAQUQfFz1Jc73gSGbuySIkGr0J6r4uXV6zH1VUxTk3 yDGp8Y1uVNHcgXYn7LHYvhEgEIh7zhOM2q2ciaEc= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730166AbgE0MxX (ORCPT ); Wed, 27 May 2020 08:53:23 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:41138 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729731AbgE0MxX (ORCPT ); Wed, 27 May 2020 08:53:23 -0400 Received: by mail-pf1-f195.google.com with SMTP id 23so11778279pfy.8 for ; Wed, 27 May 2020 05:53:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:resent-from:resent-date:resent-message-id :resent-to:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=L6RbYv5B1MYyKpilgE+iTClDmvIVUX2RuuOQOJ/aMVQ=; b=mnYO83srxb539PZ/8409bBJqD5VWKtAWlFJEC/Y/F5j6vATpB8kQzutiJEZCEn+p9F VOwpd48zfhuw6xLL76esu/cZyyKd2MmQSBpTu5hAQAlNVnuXD3KLmAC+hziblfsmqt+6 29G/LNnmd3LoDgLEvx6tIfS1k2xaMttqsbwTRoe/L9ZpjJMUPbBaBY7VhttE4N/woZ80 ITHNoaAzCZHKjD53ijrB0fbPoGuS3jUZaLKOfdw3cl36J8JP1Wv15u7ZUbyBmVlLdlO4 36G9JMcFTcuAcfVCFZGA1c1woUKw4nIh8S9cg15sZkw7wA3vUnZWsHnMP+iu+VTGdr4d Dadw== X-Gm-Message-State: AOAM531KDia0JVQqHOFRUHli3UVjkW1I/RXdLGmPoi60uhgyxBwqG3WE 2bfgBrt9ZvGhJ70798lG1ipGe01wmpYNmw== X-Google-Smtp-Source: ABdhPJzG/32mtruxm/l4NDI4+3wD/Nhstlo9iBFx63ZoqYd6Q0glKeMs85z9Xeel7PnPlJdGFnvI5g== X-Received: by 2002:aa7:9508:: with SMTP id b8mr3977687pfp.48.1590584002086; Wed, 27 May 2020 05:53:22 -0700 (PDT) Received: from 42.do-not-panic.com (42.do-not-panic.com. [157.230.128.187]) by smtp.gmail.com with ESMTPSA id k31sm2260089pje.19.2020.05.27.05.53.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 May 2020 05:53:21 -0700 (PDT) Received: by 42.do-not-panic.com (Postfix, from userid 1000) id 0852640605; Wed, 27 May 2020 12:53:21 +0000 (UTC) Received: from 42.do-not-panic.com (42.do-not-panic.com. [157.230.128.187]) by smtp.gmail.com with ESMTPSA id a6sm15582861pfa.111.2020.05.26.07.58.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 May 2020 07:58:25 -0700 (PDT) Received: by 42.do-not-panic.com (Postfix, from userid 1000) id 0547C4230A; Tue, 26 May 2020 14:58:19 +0000 (UTC) From: Luis Chamberlain To: jeyu@kernel.org, davem@davemloft.net, kuba@kernel.org Cc: michael.chan@broadcom.com, dchickles@marvell.com, sburla@marvell.com, fmanlunas@marvell.com, aelior@marvell.com, GR-everest-linux-l2@marvell.com, kvalo@codeaurora.org, johannes@sipsolutions.net, akpm@linux-foundation.org, arnd@arndb.de, rostedt@goodmis.org, mingo@redhat.com, aquini@redhat.com, cai@lca.pw, dyoung@redhat.com, bhe@redhat.com, peterz@infradead.org, tglx@linutronix.de, gpiccoli@canonical.com, pmladek@suse.com, tiwai@suse.de, schlad@suse.de, andriy.shevchenko@linux.intel.com, derosier@gmail.com, keescook@chromium.org, daniel.vetter@ffwll.ch, will@kernel.org, mchehab+samsung@kernel.org, vkoul@kernel.org, mchehab+huawei@kernel.org, robh@kernel.org, mhiramat@kernel.org, sfr@canb.auug.org.au, linux@dominikbrodowski.net, glider@google.com, paulmck@kernel.org, elver@google.com, bauerman@linux.ibm.com, yamada.masahiro@socionext.com, samitolvanen@google.com, yzaikin@google.com, dvyukov@google.com, rdunlap@infradead.org, corbet@lwn.net, dianders@chromium.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Luis Chamberlain , Igor Russkikh Subject: [PATCH v3 8/8] qed: use new taint_firmware_crashed() Date: Tue, 26 May 2020 14:58:15 +0000 Message-Id: <20200526145815.6415-9-mcgrof@kernel.org> X-Mailer: git-send-email 2.23.0.rc1 In-Reply-To: <20200526145815.6415-1-mcgrof@kernel.org> References: <20200526145815.6415-1-mcgrof@kernel.org> MIME-Version: 1.0 X-TUID: ft9zMR0oDEMI Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org This makes use of the new taint_firmware_crashed() to help annotate when firmware for device drivers crash. When firmware crashes devices can sometimes become unresponsive, and recovery sometimes requires a driver unload / reload and in the worst cases a reboot. Using a taint flag allows us to annotate when this happens clearly. Cc: Ariel Elior Cc: GR-everest-linux-l2@marvell.com Reviewed-by: Igor Russkikh Acked-by: Rafael Aquini Signed-off-by: Luis Chamberlain --- drivers/net/ethernet/qlogic/qed/qed_mcp.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/ethernet/qlogic/qed/qed_mcp.c b/drivers/net/ethernet/qlogic/qed/qed_mcp.c index 9624616806e7..dd4357b0b5d1 100644 --- a/drivers/net/ethernet/qlogic/qed/qed_mcp.c +++ b/drivers/net/ethernet/qlogic/qed/qed_mcp.c @@ -566,6 +566,7 @@ _qed_mcp_cmd_and_union(struct qed_hwfn *p_hwfn, DP_NOTICE(p_hwfn, "The MFW failed to respond to command 0x%08x [param 0x%08x].\n", p_mb_params->cmd, p_mb_params->param); + taint_firmware_crashed(); qed_mcp_print_cpu_info(p_hwfn, p_ptt); spin_lock_bh(&p_hwfn->mcp_info->cmd_lock);