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: 215460 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 04858C433E4 for ; Wed, 27 May 2020 12:52:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D4FC22053B 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: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: 215459 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B300DC433E0 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 8E0E42053B 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: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: 215458 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 266F4C433E0 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 048922053B 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 --- 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: 215457 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E523BC433E0 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 C51BD2053B 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);