From: Luis Chamberlain <mcgrof@kernel.org> Date: 2020-05-09 04:36:05
Device driver firmware can crash, and sometimes, this can leave your
system in a state which makes the device or subsystem completely
useless. 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 this series provides a helper which
lets drivers annotate this and shows how to use this on networking
drivers.
My methodology for finding when firmware crashes is to git grep for
"crash" and then doing some study of the code to see if this indeed
a place where the firmware crashes. In some places this is quite
obvious.
I'm starting off with networking first, if this gets merged later on I
can focus on the other drivers, but I already have some work done on
other subsytems.
Review, flames, etc are greatly appreciated.
This work, only on networking drivers, can be found on my git tree as well:
https://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux-next.git/log/?h=20200509-taint-firmware-net
Luis Chamberlain (15):
taint: add module firmware crash taint support
ethernet/839: use new module_firmware_crashed()
bnx2x: use new module_firmware_crashed()
bnxt: use new module_firmware_crashed()
bna: use new module_firmware_crashed()
liquidio: use new module_firmware_crashed()
cxgb4: use new module_firmware_crashed()
ehea: use new module_firmware_crashed()
qed: use new module_firmware_crashed()
soc: qcom: ipa: use new module_firmware_crashed()
wimax/i2400m: use new module_firmware_crashed()
ath10k: use new module_firmware_crashed()
ath6kl: use new module_firmware_crashed()
brcm80211: use new module_firmware_crashed()
mwl8k: use new module_firmware_crashed()
drivers/net/ethernet/8390/axnet_cs.c | 4 +++-
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 1 +
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 1 +
drivers/net/ethernet/brocade/bna/bfa_ioc.c | 1 +
drivers/net/ethernet/cavium/liquidio/lio_main.c | 1 +
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 1 +
drivers/net/ethernet/ibm/ehea/ehea_main.c | 2 ++
drivers/net/ethernet/qlogic/qed/qed_debug.c | 3 +++
drivers/net/ipa/ipa_modem.c | 1 +
drivers/net/wimax/i2400m/rx.c | 1 +
drivers/net/wireless/ath/ath10k/pci.c | 2 ++
drivers/net/wireless/ath/ath10k/sdio.c | 2 ++
drivers/net/wireless/ath/ath10k/snoc.c | 1 +
drivers/net/wireless/ath/ath6kl/hif.c | 1 +
.../net/wireless/broadcom/brcm80211/brcmfmac/core.c | 1 +
drivers/net/wireless/marvell/mwl8k.c | 1 +
include/linux/kernel.h | 3 ++-
include/linux/module.h | 13 +++++++++++++
include/trace/events/module.h | 3 ++-
kernel/module.c | 5 +++--
kernel/panic.c | 1 +
21 files changed, 44 insertions(+), 5 deletions(-)
--
2.25.1
From: Luis Chamberlain <mcgrof@kernel.org> Date: 2020-05-09 04:36:08
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 S. Tsirkin" <mst@redhat.com>
Cc: Shannon Nelson <redacted>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
drivers/net/ethernet/8390/axnet_cs.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
@@ -1358,9 +1358,11 @@ static void ei_receive(struct net_device *dev)*/if((netif_msg_rx_err(ei_local))&&this_frame!=ei_local->current_page&&-(this_frame!=0x0||rxing_page!=0xFF))+(this_frame!=0x0||rxing_page!=0xFF)){+module_firmware_crashed();netdev_err(dev,"mismatched read page pointers %2x vs %2x\n",this_frame,ei_local->current_page);+}if(this_frame==rxing_page)/* Read all the frames? */break;/* Done for now */
From: Luis Chamberlain <mcgrof@kernel.org> Date: 2020-05-09 04:36:08
Device driver firmware can crash, and sometimes, this can leave your
system in a state which makes the device or subsystem completely
useless. 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 module_firmware_crashed() uses LOCKDEP_STILL_OK as this
fact should in no way shape or form affect lockdep. This taint is device
driver specific.
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
include/linux/kernel.h | 3 ++-
include/linux/module.h | 13 +++++++++++++
include/trace/events/module.h | 3 ++-
kernel/module.c | 5 +++--
kernel/panic.c | 1 +
5 files changed, 21 insertions(+), 4 deletions(-)
From: Luis Chamberlain <mcgrof@kernel.org> Date: 2020-05-09 04:36:10
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 <michael.chan@broadcom.com>
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 1 +
1 file changed, 1 insertion(+)
From: Luis Chamberlain <mcgrof@kernel.org> Date: 2020-05-09 04:36:11
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: Ariel Elior <redacted>
Cc: Sudarsana Kalluru <skalluru@marvell.com>
CC: GR-everest-linux-l2@marvell.com
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 1 +
1 file changed, 1 insertion(+)
From: Luis Chamberlain <mcgrof@kernel.org> Date: 2020-05-09 04:36:14
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: Derek Chickles <redacted>
Cc: Satanand Burla <sburla@marvell.com>
Cc: Felix Manlunas <redacted>
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
drivers/net/ethernet/cavium/liquidio/lio_main.c | 1 +
1 file changed, 1 insertion(+)
From: Luis Chamberlain <mcgrof@kernel.org> Date: 2020-05-09 04:36:23
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: Ariel Elior <redacted>
Cc: GR-everest-linux-l2@marvell.com
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
drivers/net/ethernet/qlogic/qed/qed_debug.c | 3 +++
1 file changed, 3 insertions(+)
From: Luis Chamberlain <mcgrof@kernel.org> Date: 2020-05-09 04:36:25
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: linux-wireless@vger.kernel.org
Cc: Lennert Buytenhek <redacted>
Cc: Kalle Valo <redacted>
Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org>
Cc: Johannes Berg <redacted>
Cc: Ganapathi Bhat <redacted>
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
drivers/net/wireless/marvell/mwl8k.c | 1 +
1 file changed, 1 insertion(+)
From: Luis Chamberlain <mcgrof@kernel.org> Date: 2020-05-09 04:36:29
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: linux-wireless@vger.kernel.org
Cc: brcm80211-dev-list.pdl@broadcom.com
Cc: brcm80211-dev-list@cypress.com
Cc: Arend van Spriel <arend.vanspriel@broadcom.com>
Cc: Franky Lin <redacted>
Cc: Hante Meuleman <redacted>
Cc: Chi-Hsien Lin <redacted>
Cc: Wright Feng <redacted>
Cc: Kalle Valo <redacted>
Cc: "Rafał Miłecki" <rafal@milecki.pl>
Cc: Pieter-Paul Giesberts <redacted>
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c | 1 +
1 file changed, 1 insertion(+)
From: Luis Chamberlain <mcgrof@kernel.org> Date: 2020-05-09 04:36:37
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: Douglas Miller <redacted>
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
drivers/net/ethernet/ibm/ehea/ehea_main.c | 2 ++
1 file changed, 2 insertions(+)
From: Luis Chamberlain <mcgrof@kernel.org> Date: 2020-05-09 04:36:39
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: linux-wimax@intel.com
Cc: Inaky Perez-Gonzalez <redacted>
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
drivers/net/wimax/i2400m/rx.c | 1 +
1 file changed, 1 insertion(+)
From: Luis Chamberlain <mcgrof@kernel.org> Date: 2020-05-09 04:36:45
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: linux-wireless@vger.kernel.org
Cc: ath10k@lists.infradead.org
Cc: Kalle Valo <redacted>
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
drivers/net/wireless/ath/ath6kl/hif.c | 1 +
1 file changed, 1 insertion(+)
From: Luis Chamberlain <mcgrof@kernel.org> Date: 2020-05-09 04:36:53
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: Alex Elder <elder@kernel.org>
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
drivers/net/ipa/ipa_modem.c | 1 +
1 file changed, 1 insertion(+)
From: Luis Chamberlain <mcgrof@kernel.org> Date: 2020-05-09 04:37:00
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: Vishal Kulkarni <redacted>
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 1 +
1 file changed, 1 insertion(+)
From: Luis Chamberlain <mcgrof@kernel.org> Date: 2020-05-09 04:37:05
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: Rasesh Mody <rmody@marvell.com>
Cc: Sudarsana Kalluru <skalluru@marvell.com>
Cc: GR-Linux-NIC-Dev@marvell.com
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
drivers/net/ethernet/brocade/bna/bfa_ioc.c | 1 +
1 file changed, 1 insertion(+)
From: Luis Chamberlain <mcgrof@kernel.org> Date: 2020-05-09 04:45:46
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: linux-wireless@vger.kernel.org
Cc: ath10k@lists.infradead.org
Cc: Kalle Valo <redacted>
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
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(+)
From: Igor Russkikh <hidden> Date: 2020-05-09 06:34:35
quoted hunk
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: Ariel Elior <redacted>
Cc: GR-everest-linux-l2@marvell.com
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
drivers/net/ethernet/qlogic/qed/qed_debug.c | 3 +++
1 file changed, 3 insertions(+)
Hi Luis,
qed_dbg_all_data is being used to gather debug dump from device. Failures
inside it may happen due to various reasons, but they normally do not indicate
FW failure.
So I think its not a good place to insert this call.
Its hard to find exact good place to insert it in qed.
One more thing is that AFAIU taint flag gets permanent on kernel, but for
example our device can recover itself from some FW crashes, thus it'd be
transparent for user.
Whats the logical purpose of module_firmware_crashed? Does it mean fatal
unrecoverable error on device?
Thanks,
Igor
From: Rafael Aquini <hidden> Date: 2020-05-09 15:19:01
On Sat, May 09, 2020 at 04:35:38AM +0000, Luis Chamberlain wrote:
quoted hunk
Device driver firmware can crash, and sometimes, this can leave your
system in a state which makes the device or subsystem completely
useless. 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 module_firmware_crashed() uses LOCKDEP_STILL_OK as this
fact should in no way shape or form affect lockdep. This taint is device
driver specific.
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
include/linux/kernel.h | 3 ++-
include/linux/module.h | 13 +++++++++++++
include/trace/events/module.h | 3 ++-
kernel/module.c | 5 +++--
kernel/panic.c | 1 +
5 files changed, 21 insertions(+), 4 deletions(-)
@@ -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,7 @@ 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`` Device drivers might annotate the kernel with this taint, in cases+ their firmware might have crashed leaving the driver in a crippled and+ potentially useless state.
quoted hunk
struct taint_flag {
char c_true; /* character printed when tainted */
From: Luis Chamberlain <mcgrof@kernel.org> Date: 2020-05-09 16:42:33
On Sat, May 09, 2020 at 09:32:51AM +0300, Igor Russkikh wrote:
quoted
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: Ariel Elior <redacted>
Cc: GR-everest-linux-l2@marvell.com
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
drivers/net/ethernet/qlogic/qed/qed_debug.c | 3 +++
1 file changed, 3 insertions(+)
Hi Luis,
qed_dbg_all_data is being used to gather debug dump from device. Failures
inside it may happen due to various reasons, but they normally do not indicate
FW failure.
So I think its not a good place to insert this call.
Its hard to find exact good place to insert it in qed.
Is there a way to check if what happened was indeed a fw crash?
One more thing is that AFAIU taint flag gets permanent on kernel, but for
example our device can recover itself from some FW crashes, thus it'd be
transparent for user.
Similar things are *supposed* to recoverable with other device, however
this can also sometimes lead to a situation where devices are not usable
anymore, and require a full driver unload / load.
Whats the logical purpose of module_firmware_crashed? Does it mean fatal
unrecoverable error on device?
Its just to annotate on the module and kernel that this has happened.
I take it you may agree that, firmware crashing *often* is not good design,
and these issues should be reported to / fixed by vendors. In cases
where driver bugs are reported it is good to see if a firmware crash has
happened before, so that during analysis this is ruled out.
Luis
@@ -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,7 @@ 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`` Device drivers might annotate the kernel with this taint, in cases+ their firmware might have crashed leaving the driver in a crippled and+ potentially useless state.
Sure, I'll modify it a bit to add the use case to help with support
issues, ie, to help rule out firmware issues.
I'm starting to think that to make this even more usesul later we may
want to add a uevent to add_taint() so that userspace can decide to look
into this, ignore it, or report something to the user, say on their
desktop.
Luis
From: Jakub Kicinski <kuba@kernel.org> Date: 2020-05-09 18:35:51
On Sat, 9 May 2020 04:35:37 +0000 Luis Chamberlain wrote:
Device driver firmware can crash, and sometimes, this can leave your
system in a state which makes the device or subsystem completely
useless. 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 this series provides a helper which
lets drivers annotate this and shows how to use this on networking
drivers.
My methodology for finding when firmware crashes is to git grep for
"crash" and then doing some study of the code to see if this indeed
a place where the firmware crashes. In some places this is quite
obvious.
I'm starting off with networking first, if this gets merged later on I
can focus on the other drivers, but I already have some work done on
other subsytems.
Review, flames, etc are greatly appreciated.
Tainting itself may be useful, but that's just the first step. I'd much
rather see folks start using the devlink health infrastructure. Devlink
is netlink based, but it's _not_ networking specific (many of its
optional features obviously are, but don't let that mislead you).
With devlink health we get (a) a standard notification on the failure;
(b) information/state dump in a (somewhat) structured form, which can be
collected & shared with vendors; (c) automatic remediation (usually
device reset of some scope).
Now regarding the tainting - as I said it may be useful, but don't we
have to define what constitutes a "firmware crash"? There are many
failure modes, some perfectly recoverable (e.g. processing queue hang),
some mere bugs (e.g. device fails to initialize some functions). All of
them may impact the functioning of the system. How do we choose those
that taint?
From: Shannon Nelson <hidden> Date: 2020-05-10 01:01:57
On 5/8/20 9:35 PM, Luis Chamberlain wrote:
Device driver firmware can crash, and sometimes, this can leave your
system in a state which makes the device or subsystem completely
useless. 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 this series provides a helper which
lets drivers annotate this and shows how to use this on networking
drivers.
If the driver is able to detect that the device firmware has come back
alive, through user intervention or whatever, should there be a way to
"untaint" the kernel? Or would you expect it to remain tainted?
sln
From: Andrew Lunn <andrew@lunn.ch> Date: 2020-05-10 02:01:47
On Sat, May 09, 2020 at 06:01:51PM -0700, Shannon Nelson wrote:
On 5/8/20 9:35 PM, Luis Chamberlain wrote:
quoted
Device driver firmware can crash, and sometimes, this can leave your
system in a state which makes the device or subsystem completely
useless. 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 this series provides a helper which
lets drivers annotate this and shows how to use this on networking
drivers.
If the driver is able to detect that the device firmware has come back
alive, through user intervention or whatever, should there be a way to
"untaint" the kernel? Or would you expect it to remain tainted?
Hi Shannon
In general, you don't want to be able to untained. Say a non-GPL
licenced module is loaded, which taints the kernel. It might then try
to untaint the kernel to hide its.
As for firmware, how much damage can the firmware do as it crashed? If
it is a DMA master, it could of splattered stuff through
memory. Restarting the firmware is not going to reverse the damage it
has done.
Andrew
From: Shannon Nelson <hidden> Date: 2020-05-10 02:20:02
On 5/9/20 6:58 PM, Andrew Lunn wrote:
On Sat, May 09, 2020 at 06:01:51PM -0700, Shannon Nelson wrote:
quoted
On 5/8/20 9:35 PM, Luis Chamberlain wrote:
quoted
Device driver firmware can crash, and sometimes, this can leave your
system in a state which makes the device or subsystem completely
useless. 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 this series provides a helper which
lets drivers annotate this and shows how to use this on networking
drivers.
If the driver is able to detect that the device firmware has come back
alive, through user intervention or whatever, should there be a way to
"untaint" the kernel? Or would you expect it to remain tainted?
Hi Shannon
In general, you don't want to be able to untained. Say a non-GPL
licenced module is loaded, which taints the kernel. It might then try
to untaint the kernel to hide its.
Yeah, obviously we don't want this to be abuseable. I was just
wondering about reversing this particular status if the broken device
could get itself fixed.
As for firmware, how much damage can the firmware do as it crashed? If
it is a DMA master, it could of splattered stuff through
memory. Restarting the firmware is not going to reverse the damage it
has done.
True, and tho' the driver might get the thing restarted, it wouldn't
necessarily know what kind of damage had ensued.
Carry on,
sln
@@ -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,7 @@ 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`` Device drivers might annotate the kernel with this taint, in cases+ their firmware might have crashed leaving the driver in a crippled and+ potentially useless state.
Sure, I'll modify it a bit to add the use case to help with support
issues, ie, to help rule out firmware issues.
Please also update tools/debugging/kernel-chktaint.
I'm starting to think that to make this even more usesul later we may
want to add a uevent to add_taint() so that userspace can decide to look
into this, ignore it, or report something to the user, say on their
desktop.
From: Luis Chamberlain <mcgrof@kernel.org> Date: 2020-05-11 14:11:20
On Sat, May 09, 2020 at 11:35:46AM -0700, Jakub Kicinski wrote:
On Sat, 9 May 2020 04:35:37 +0000 Luis Chamberlain wrote:
quoted
Device driver firmware can crash, and sometimes, this can leave your
system in a state which makes the device or subsystem completely
useless. 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 this series provides a helper which
lets drivers annotate this and shows how to use this on networking
drivers.
My methodology for finding when firmware crashes is to git grep for
"crash" and then doing some study of the code to see if this indeed
a place where the firmware crashes. In some places this is quite
obvious.
I'm starting off with networking first, if this gets merged later on I
can focus on the other drivers, but I already have some work done on
other subsytems.
Review, flames, etc are greatly appreciated.
Tainting itself may be useful, but that's just the first step. I'd much
rather see folks start using the devlink health infrastructure. Devlink
is netlink based, but it's _not_ networking specific (many of its
optional features obviously are, but don't let that mislead you).
With devlink health we get (a) a standard notification on the failure;
(b) information/state dump in a (somewhat) structured form, which can be
collected & shared with vendors; (c) automatic remediation (usually
device reset of some scope).
It indeed sounds very useful!
Now regarding the tainting - as I said it may be useful, but don't we
have to define what constitutes a "firmware crash"?
Yes indeed, I missed clarifying this in the documentation. I'll do so
in my next respin.
There are many
failure modes, some perfectly recoverable (e.g. processing queue hang),
some mere bugs (e.g. device fails to initialize some functions). All of
them may impact the functioning of the system. How do we choose those
that taint?
Its up to the maintainers of the device driver, what I was aiming for
were those firmware crashes which indeed *can* have an impact on user
experience, and can *even* potentially require a driver removal / addition
to to get things back in order again.
Luis
From: Luis Chamberlain <mcgrof@kernel.org> Date: 2020-05-11 14:13:31
On Sat, May 09, 2020 at 07:15:23PM -0700, Shannon Nelson wrote:
On 5/9/20 6:58 PM, Andrew Lunn wrote:
quoted
On Sat, May 09, 2020 at 06:01:51PM -0700, Shannon Nelson wrote:
As for firmware, how much damage can the firmware do as it crashed? If
it is a DMA master, it could of splattered stuff through
memory. Restarting the firmware is not going to reverse the damage it
has done.
True, and tho' the driver might get the thing restarted, it wouldn't
necessarily know what kind of damage had ensued.
Indeed, it is those uknowns which we currently assume is just fine, but
in reality can be damaging. Today we just move on with life, but such
information is useful for analysis.
Luis
From: Steven Rostedt <rostedt@goodmis.org> Date: 2020-05-11 19:21:46
On Sat, 9 May 2020 18:01:51 -0700
Shannon Nelson [off-list ref] wrote:
If the driver is able to detect that the device firmware has come back
alive, through user intervention or whatever, should there be a way to
"untaint" the kernel? Or would you expect it to remain tainted?
The only way to untaint a kernel is a reboot. A taint just means "something
happened to this kernel since it was booted". It's used as a hint, and
that's all.
I agree with the other comments in this thread. Use devlink health or
whatever tool to look further into causes. But from what I see here, this
code is "good enough" for a taint.
-- Steve
From: Igor Russkikh <hidden> Date: 2020-05-12 16:24:43
quoted
So I think its not a good place to insert this call.
Its hard to find exact good place to insert it in qed.
Is there a way to check if what happened was indeed a fw crash?
Our driver has two firmwares (slowpath and fastpath).
For slowpath firmware the way to understand it crashed is to observe command
response timeout. This is in qed_mcp.c, around "The MFW failed to respond to
command" traceout.
For fastpath this is tricky, think you may leave the above place as the only
place to invoke module_firmware_crashed()
quoted
One more thing is that AFAIU taint flag gets permanent on kernel, but
for
quoted
example our device can recover itself from some FW crashes, thus it'd be
transparent for user.
Similar things are *supposed* to recoverable with other device, however
this can also sometimes lead to a situation where devices are not usable
anymore, and require a full driver unload / load.
quoted
Whats the logical purpose of module_firmware_crashed? Does it mean fatal
unrecoverable error on device?
Its just to annotate on the module and kernel that this has happened.
I take it you may agree that, firmware crashing *often* is not good
design,
and these issues should be reported to / fixed by vendors. In cases
where driver bugs are reported it is good to see if a firmware crash has
happened before, so that during analysis this is ruled out.
Probably, but still I see some misalignment here, in sense that taint is about
the kernel state, not about a hardware state indication.
devlink health could really be a much better candidate for such things.
Regards
Igor
From: Luis Chamberlain <mcgrof@kernel.org> Date: 2020-05-12 17:34:36
On Tue, May 12, 2020 at 07:23:28PM +0300, Igor Russkikh wrote:
quoted
quoted
So I think its not a good place to insert this call.
Its hard to find exact good place to insert it in qed.
Is there a way to check if what happened was indeed a fw crash?
Our driver has two firmwares (slowpath and fastpath).
For slowpath firmware the way to understand it crashed is to observe command
response timeout. This is in qed_mcp.c, around "The MFW failed to respond to
command" traceout.
Ok thanks.
For fastpath this is tricky, think you may leave the above place as the only
place to invoke module_firmware_crashed()
@@ -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);+module_firmware_crashed();qed_mcp_print_cpu_info(p_hwfn,p_ptt);spin_lock_bh(&p_hwfn->mcp_info->cmd_lock);
quoted
quoted
One more thing is that AFAIU taint flag gets permanent on kernel, but
for
quoted
example our device can recover itself from some FW crashes, thus it'd be
transparent for user.
Similar things are *supposed* to recoverable with other device, however
this can also sometimes lead to a situation where devices are not usable
anymore, and require a full driver unload / load.
quoted
Whats the logical purpose of module_firmware_crashed? Does it mean fatal
unrecoverable error on device?
Its just to annotate on the module and kernel that this has happened.
I take it you may agree that, firmware crashing *often* is not good
design,
and these issues should be reported to / fixed by vendors. In cases
where driver bugs are reported it is good to see if a firmware crash has
happened before, so that during analysis this is ruled out.
Probably, but still I see some misalignment here, in sense that taint is about
the kernel state, not about a hardware state indication.
The kernel carries the driver though, and the driver / subsystem can
often times act strange when this happens.
devlink health could really be a much better candidate for such things.
That sounds fantastic, please Cc me on patches! However I still believe
we should register this event in the kernel for support purposes.
Luis