From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
stable@vger.kernel.org, Will Deacon <will.deacon@arm.com>,
Russell King <rmk+kernel@armlinux.org.uk>,
Sasha Levin <sashal@kernel.org>
Subject: [PATCH 4.9 71/91] ARM: avoid Cortex-A9 livelock on tight dmb loops
Date: Thu, 4 Apr 2019 10:47:55 +0200 [thread overview]
Message-ID: <20190404084539.562049592@linuxfoundation.org> (raw)
In-Reply-To: <20190404084535.450029272@linuxfoundation.org>
4.9-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit 5388a5b82199facacd3d7ac0d05aca6e8f902fed ]
machine_crash_nonpanic_core() does this:
while (1)
cpu_relax();
because the kernel has crashed, and we have no known safe way to deal
with the CPU. So, we place the CPU into an infinite loop which we
expect it to never exit - at least not until the system as a whole is
reset by some method.
In the absence of erratum 754327, this code assembles to:
b .
In other words, an infinite loop. When erratum 754327 is enabled,
this becomes:
1: dmb
b 1b
It has been observed that on some systems (eg, OMAP4) where, if a
crash is triggered, the system tries to kexec into the panic kernel,
but fails after taking the secondary CPU down - placing it into one
of these loops. This causes the system to livelock, and the most
noticable effect is the system stops after issuing:
Loading crashdump kernel...
to the system console.
The tested as working solution I came up with was to add wfe() to
these infinite loops thusly:
while (1) {
cpu_relax();
wfe();
}
which, without 754327 builds to:
1: wfe
b 1b
or with 754327 is enabled:
1: dmb
wfe
b 1b
Adding "wfe" does two things depending on the environment we're running
under:
- where we're running on bare metal, and the processor implements
"wfe", it stops us spinning endlessly in a loop where we're never
going to do any useful work.
- if we're running in a VM, it allows the CPU to be given back to the
hypervisor and rescheduled for other purposes (maybe a different VM)
rather than wasting CPU cycles inside a crashed VM.
However, in light of erratum 794072, Will Deacon wanted to see 10 nops
as well - which is reasonable to cover the case where we have erratum
754327 enabled _and_ we have a processor that doesn't implement the
wfe hint.
So, we now end up with:
1: wfe
b 1b
when erratum 754327 is disabled, or:
1: dmb
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
wfe
b 1b
when erratum 754327 is enabled. We also get the dmb + 10 nop
sequence elsewhere in the kernel, in terminating loops.
This is reasonable - it means we get the workaround for erratum
794072 when erratum 754327 is enabled, but still relinquish the dead
processor - either by placing it in a lower power mode when wfe is
implemented as such or by returning it to the hypervisior, or in the
case where wfe is a no-op, we use the workaround specified in erratum
794072 to avoid the problem.
These as two entirely orthogonal problems - the 10 nops addresses
erratum 794072, and the wfe is an optimisation that makes the system
more efficient when crashed either in terms of power consumption or
by allowing the host/other VMs to make use of the CPU.
I don't see any reason not to use kexec() inside a VM - it has the
potential to provide automated recovery from a failure of the VMs
kernel with the opportunity for saving a crashdump of the failure.
A panic() with a reboot timeout won't do that, and reading the
libvirt documentation, setting on_reboot to "preserve" won't either
(the documentation states "The preserve action for an on_reboot event
is treated as a destroy".) Surely it has to be a good thing to
avoiding having CPUs spinning inside a VM that is doing no useful
work.
Acked-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
arch/arm/include/asm/barrier.h | 2 ++
arch/arm/include/asm/processor.h | 6 +++++-
arch/arm/kernel/machine_kexec.c | 5 ++++-
arch/arm/kernel/smp.c | 4 +++-
arch/arm/mach-omap2/prm_common.c | 4 +++-
5 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/arch/arm/include/asm/barrier.h b/arch/arm/include/asm/barrier.h
index 513e03d138ea..8331cb0d3461 100644
--- a/arch/arm/include/asm/barrier.h
+++ b/arch/arm/include/asm/barrier.h
@@ -10,6 +10,8 @@
#define sev() __asm__ __volatile__ ("sev" : : : "memory")
#define wfe() __asm__ __volatile__ ("wfe" : : : "memory")
#define wfi() __asm__ __volatile__ ("wfi" : : : "memory")
+#else
+#define wfe() do { } while (0)
#endif
#if __LINUX_ARM_ARCH__ >= 7
diff --git a/arch/arm/include/asm/processor.h b/arch/arm/include/asm/processor.h
index 8a1e8e995dae..08509183c7df 100644
--- a/arch/arm/include/asm/processor.h
+++ b/arch/arm/include/asm/processor.h
@@ -77,7 +77,11 @@ extern void release_thread(struct task_struct *);
unsigned long get_wchan(struct task_struct *p);
#if __LINUX_ARM_ARCH__ == 6 || defined(CONFIG_ARM_ERRATA_754327)
-#define cpu_relax() smp_mb()
+#define cpu_relax() \
+ do { \
+ smp_mb(); \
+ __asm__ __volatile__("nop; nop; nop; nop; nop; nop; nop; nop; nop; nop;"); \
+ } while (0)
#else
#define cpu_relax() barrier()
#endif
diff --git a/arch/arm/kernel/machine_kexec.c b/arch/arm/kernel/machine_kexec.c
index b18c1ea56bed..ef6b27fe1d2e 100644
--- a/arch/arm/kernel/machine_kexec.c
+++ b/arch/arm/kernel/machine_kexec.c
@@ -87,8 +87,11 @@ void machine_crash_nonpanic_core(void *unused)
set_cpu_online(smp_processor_id(), false);
atomic_dec(&waiting_for_crash_ipi);
- while (1)
+
+ while (1) {
cpu_relax();
+ wfe();
+ }
}
static void machine_kexec_mask_interrupts(void)
diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
index bc83ec7ed53f..7a5dc011c523 100644
--- a/arch/arm/kernel/smp.c
+++ b/arch/arm/kernel/smp.c
@@ -602,8 +602,10 @@ static void ipi_cpu_stop(unsigned int cpu)
local_fiq_disable();
local_irq_disable();
- while (1)
+ while (1) {
cpu_relax();
+ wfe();
+ }
}
static DEFINE_PER_CPU(struct completion *, cpu_completion);
diff --git a/arch/arm/mach-omap2/prm_common.c b/arch/arm/mach-omap2/prm_common.c
index f1ca9479491b..9e14604b9642 100644
--- a/arch/arm/mach-omap2/prm_common.c
+++ b/arch/arm/mach-omap2/prm_common.c
@@ -533,8 +533,10 @@ void omap_prm_reset_system(void)
prm_ll_data->reset_system();
- while (1)
+ while (1) {
cpu_relax();
+ wfe();
+ }
}
/**
--
2.19.1
next prev parent reply other threads:[~2019-04-04 9:53 UTC|newest]
Thread overview: 97+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-04 8:46 [PATCH 4.9 00/91] 4.9.168-stable review Greg Kroah-Hartman
2019-04-04 8:46 ` [PATCH 4.9 01/91] arm64: debug: Dont propagate UNKNOWN FAR into si_code for debug signals Greg Kroah-Hartman
2019-04-04 8:46 ` [PATCH 4.9 02/91] arm64: debug: Ensure debug handlers check triggering exception level Greg Kroah-Hartman
2019-04-04 8:46 ` [PATCH 4.9 03/91] ext4: cleanup bh release code in ext4_ind_remove_space() Greg Kroah-Hartman
2019-04-04 8:46 ` [PATCH 4.9 04/91] lib/int_sqrt: optimize initial value compute Greg Kroah-Hartman
2019-04-04 8:46 ` [PATCH 4.9 05/91] tty/serial: atmel: Add is_half_duplex helper Greg Kroah-Hartman
2019-04-04 8:46 ` [PATCH 4.9 06/91] tty/serial: atmel: RS485 HD w/DMA: enable RX after TX is stopped Greg Kroah-Hartman
2019-04-04 8:46 ` [PATCH 4.9 07/91] mm: mempolicy: make mbind() return -EIO when MPOL_MF_STRICT is specified Greg Kroah-Hartman
2019-04-04 8:46 ` [PATCH 4.9 08/91] i2c: core-smbus: prevent stack corruption on read I2C_BLOCK_DATA Greg Kroah-Hartman
2019-04-04 8:46 ` [PATCH 4.9 09/91] CIFS: fix POSIX lock leak and invalid ptr deref Greg Kroah-Hartman
2019-04-04 8:46 ` [PATCH 4.9 10/91] h8300: use cc-cross-prefix instead of hardcoding h8300-unknown-linux- Greg Kroah-Hartman
2019-04-04 8:46 ` [PATCH 4.9 11/91] tracing: kdb: Fix ftdump to not sleep Greg Kroah-Hartman
2019-04-04 8:46 ` [PATCH 4.9 12/91] gpio: gpio-omap: fix level interrupt idling Greg Kroah-Hartman
2019-04-04 8:46 ` [PATCH 4.9 13/91] include/linux/relay.h: fix percpu annotation in struct rchan Greg Kroah-Hartman
2019-04-04 8:46 ` [PATCH 4.9 14/91] sysctl: handle overflow for file-max Greg Kroah-Hartman
2019-04-04 8:46 ` [PATCH 4.9 15/91] enic: fix build warning without CONFIG_CPUMASK_OFFSTACK Greg Kroah-Hartman
2019-04-04 8:47 ` [PATCH 4.9 16/91] scsi: hisi_sas: Set PHY linkrate when disconnected Greg Kroah-Hartman
2019-04-04 8:47 ` [PATCH 4.9 17/91] mm/cma.c: cma_declare_contiguous: correct err handling Greg Kroah-Hartman
2019-04-04 8:47 ` [PATCH 4.9 18/91] mm/page_ext.c: fix an imbalance with kmemleak Greg Kroah-Hartman
2019-04-04 8:47 ` [PATCH 4.9 19/91] mm/vmalloc.c: fix kernel BUG at mm/vmalloc.c:512! Greg Kroah-Hartman
2019-04-04 8:47 ` [PATCH 4.9 20/91] mm/slab.c: kmemleak no scan alien caches Greg Kroah-Hartman
2019-04-04 8:47 ` [PATCH 4.9 21/91] ocfs2: fix a panic problem caused by o2cb_ctl Greg Kroah-Hartman
2019-04-04 8:47 ` [PATCH 4.9 22/91] f2fs: do not use mutex lock in atomic context Greg Kroah-Hartman
2019-04-04 8:47 ` [PATCH 4.9 23/91] fs/file.c: initialize init_files.resize_wait Greg Kroah-Hartman
2019-04-04 8:47 ` [PATCH 4.9 24/91] cifs: use correct format characters Greg Kroah-Hartman
2019-04-04 8:47 ` [PATCH 4.9 25/91] dm thin: add sanity checks to thin-pool and external snapshot creation Greg Kroah-Hartman
2019-04-04 8:47 ` [PATCH 4.9 26/91] cifs: Fix NULL pointer dereference of devname Greg Kroah-Hartman
2019-04-04 8:47 ` [PATCH 4.9 27/91] fs: Make splice() and tee() take into account O_NONBLOCK flag on pipes Greg Kroah-Hartman
2019-04-04 8:47 ` [PATCH 4.9 28/91] jbd2: fix invalid descriptor block checksum Greg Kroah-Hartman
2019-04-04 8:47 ` [PATCH 4.9 29/91] fs: fix guard_bio_eod to check for real EOD errors Greg Kroah-Hartman
2019-04-04 8:47 ` [PATCH 4.9 30/91] tools lib traceevent: Fix buffer overflow in arg_eval Greg Kroah-Hartman
2019-04-04 8:47 ` [PATCH 4.9 31/91] wil6210: check null pointer in _wil_cfg80211_merge_extra_ies Greg Kroah-Hartman
2019-04-04 8:47 ` [PATCH 4.9 32/91] crypto: crypto4xx - add missing of_node_put after of_device_is_available Greg Kroah-Hartman
2019-04-04 8:47 ` [PATCH 4.9 33/91] usb: chipidea: Grab the (legacy) USB PHY by phandle first Greg Kroah-Hartman
2019-04-04 8:47 ` [PATCH 4.9 34/91] scsi: core: replace GFP_ATOMIC with GFP_KERNEL in scsi_scan.c Greg Kroah-Hartman
2019-04-04 8:47 ` [PATCH 4.9 35/91] coresight: etm4x: Add support to enable ETMv4.2 Greg Kroah-Hartman
2019-04-04 8:47 ` [PATCH 4.9 36/91] ARM: 8840/1: use a raw_spinlock_t in unwind Greg Kroah-Hartman
2019-04-04 8:47 ` [PATCH 4.9 37/91] iommu/io-pgtable-arm-v7s: Only kmemleak_ignore L2 tables Greg Kroah-Hartman
2019-04-04 8:47 ` [PATCH 4.9 38/91] mmc: omap: fix the maximum timeout setting Greg Kroah-Hartman
2019-04-04 8:47 ` [PATCH 4.9 39/91] e1000e: Fix -Wformat-truncation warnings Greg Kroah-Hartman
2019-04-04 8:47 ` [PATCH 4.9 40/91] mlxsw: spectrum: Avoid " Greg Kroah-Hartman
2019-04-04 8:47 ` [PATCH 4.9 41/91] IB/mlx4: Increase the timeout for CM cache Greg Kroah-Hartman
2019-04-04 8:47 ` [PATCH 4.9 42/91] scsi: megaraid_sas: return error when create DMA pool failed Greg Kroah-Hartman
2019-04-04 8:47 ` [PATCH 4.9 43/91] perf test: Fix failure of evsel-tp-sched test on s390 Greg Kroah-Hartman
2019-04-04 8:47 ` [PATCH 4.9 44/91] SoC: imx-sgtl5000: add missing put_device() Greg Kroah-Hartman
2019-04-04 8:47 ` [PATCH 4.9 45/91] media: sh_veu: Correct return type for mem2mem buffer helpers Greg Kroah-Hartman
2019-04-04 8:47 ` [PATCH 4.9 46/91] media: s5p-jpeg: " Greg Kroah-Hartman
2019-04-04 8:47 ` [PATCH 4.9 47/91] media: s5p-g2d: " Greg Kroah-Hartman
2019-04-04 8:47 ` [PATCH 4.9 48/91] media: mx2_emmaprp: " Greg Kroah-Hartman
2019-04-04 8:47 ` [PATCH 4.9 49/91] vfs: fix preadv64v2 and pwritev64v2 compat syscalls with offset == -1 Greg Kroah-Hartman
2019-04-04 8:47 ` [PATCH 4.9 50/91] HID: intel-ish-hid: avoid binding wrong ishtp_cl_device Greg Kroah-Hartman
2019-04-04 8:47 ` [PATCH 4.9 51/91] leds: lp55xx: fix null deref on firmware load failure Greg Kroah-Hartman
2019-04-04 8:47 ` [PATCH 4.9 52/91] iwlwifi: pcie: fix emergency path Greg Kroah-Hartman
2019-04-04 8:47 ` [PATCH 4.9 53/91] ACPI / video: Refactor and fix dmi_is_desktop() Greg Kroah-Hartman
2019-04-04 8:47 ` [PATCH 4.9 54/91] kprobes: Prohibit probing on bsearch() Greg Kroah-Hartman
2019-04-04 8:47 ` [PATCH 4.9 55/91] ARM: 8833/1: Ensure that NEON code always compiles with Clang Greg Kroah-Hartman
2019-04-04 8:47 ` [PATCH 4.9 56/91] ALSA: PCM: check if ops are defined before suspending PCM Greg Kroah-Hartman
2019-04-04 8:47 ` [PATCH 4.9 57/91] usb: f_fs: Avoid crash due to out-of-scope stack ptr access Greg Kroah-Hartman
2019-04-04 8:47 ` [PATCH 4.9 58/91] bcache: fix input overflow to cache set sysfs file io_error_halflife Greg Kroah-Hartman
2019-04-04 8:47 ` [PATCH 4.9 59/91] bcache: fix input overflow to sequential_cutoff Greg Kroah-Hartman
2019-04-04 8:47 ` [PATCH 4.9 60/91] bcache: improve sysfs_strtoul_clamp() Greg Kroah-Hartman
2019-04-04 8:47 ` [PATCH 4.9 61/91] genirq: Avoid summation loops for /proc/stat Greg Kroah-Hartman
2019-04-04 8:47 ` [PATCH 4.9 62/91] iw_cxgb4: fix srqidx leak during connection abort Greg Kroah-Hartman
2019-04-04 8:47 ` [PATCH 4.9 63/91] fbdev: fbmem: fix memory access if logo is bigger than the screen Greg Kroah-Hartman
2019-04-04 8:47 ` [PATCH 4.9 64/91] cdrom: Fix race condition in cdrom_sysctl_register Greg Kroah-Hartman
2019-04-04 8:47 ` [PATCH 4.9 65/91] e1000e: fix cyclic resets at link up with active tx Greg Kroah-Hartman
2019-04-04 8:47 ` [PATCH 4.9 66/91] ASoC: fsl-asoc-card: fix object reference leaks in fsl_asoc_card_probe Greg Kroah-Hartman
2019-04-04 8:47 ` [PATCH 4.9 67/91] efi/memattr: Dont bail on zero VA if it equals the regions PA Greg Kroah-Hartman
2019-04-04 8:47 ` [PATCH 4.9 68/91] ARM: dts: lpc32xx: Remove leading 0x and 0s from bindings notation Greg Kroah-Hartman
2019-04-04 8:47 ` [PATCH 4.9 69/91] soc: qcom: gsbi: Fix error handling in gsbi_probe() Greg Kroah-Hartman
2019-04-04 8:47 ` [PATCH 4.9 70/91] mt7601u: bump supported EEPROM version Greg Kroah-Hartman
2019-04-04 8:47 ` Greg Kroah-Hartman [this message]
2019-04-04 8:47 ` [PATCH 4.9 72/91] tty: increase the default flip buffer limit to 2*640K Greg Kroah-Hartman
2019-04-04 8:47 ` [PATCH 4.9 73/91] powerpc/pseries: Perform full re-add of CPU for topology update post-migration Greg Kroah-Hartman
2019-04-04 8:47 ` [PATCH 4.9 74/91] media: mt9m111: set initial frame size other than 0x0 Greg Kroah-Hartman
2019-04-04 8:47 ` [PATCH 4.9 75/91] hwrng: virtio - Avoid repeated init of completion Greg Kroah-Hartman
2019-04-04 8:48 ` [PATCH 4.9 76/91] soc/tegra: fuse: Fix illegal free of IO base address Greg Kroah-Hartman
2019-04-04 8:48 ` [PATCH 4.9 77/91] HID: intel-ish: ipc: handle PIMR before ish_wakeup also clear PISR busy_clear bit Greg Kroah-Hartman
2019-04-04 8:48 ` [PATCH 4.9 78/91] hpet: Fix missing = character in the __setup() code of hpet_mmap_enable Greg Kroah-Hartman
2019-04-04 8:48 ` [PATCH 4.9 79/91] dmaengine: imx-dma: fix warning comparison of distinct pointer types Greg Kroah-Hartman
2019-04-04 8:48 ` [PATCH 4.9 80/91] dmaengine: qcom_hidma: assign channel cookie correctly Greg Kroah-Hartman
2019-04-04 8:48 ` [PATCH 4.9 81/91] netfilter: physdev: relax br_netfilter dependency Greg Kroah-Hartman
2019-04-04 8:48 ` [PATCH 4.9 82/91] media: s5p-jpeg: Check for fmt_ver_flag when doing fmt enumeration Greg Kroah-Hartman
2019-04-04 8:48 ` [PATCH 4.9 83/91] regulator: act8865: Fix act8600_sudcdc_voltage_ranges setting Greg Kroah-Hartman
2019-04-04 8:48 ` [PATCH 4.9 84/91] drm/nouveau: Stop using drm_crtc_force_disable Greg Kroah-Hartman
2019-04-04 8:48 ` [PATCH 4.9 85/91] x86/build: Specify elf_i386 linker emulation explicitly for i386 objects Greg Kroah-Hartman
2019-04-04 8:48 ` [PATCH 4.9 86/91] selinux: do not override context on context mounts Greg Kroah-Hartman
2019-04-04 8:48 ` [PATCH 4.9 87/91] wlcore: Fix memory leak in case wl12xx_fetch_firmware failure Greg Kroah-Hartman
2019-04-04 8:48 ` [PATCH 4.9 88/91] x86/build: Mark per-CPU symbols as absolute explicitly for LLD Greg Kroah-Hartman
2019-04-04 8:48 ` [PATCH 4.9 89/91] dmaengine: tegra: avoid overflow of byte tracking Greg Kroah-Hartman
2019-04-04 8:48 ` [PATCH 4.9 90/91] drm/dp/mst: Configure no_stop_bit correctly for remote i2c xfers Greg Kroah-Hartman
2019-04-04 8:48 ` [PATCH 4.9 91/91] ACPI / video: Extend chassis-type detection with a "Lunch Box" check Greg Kroah-Hartman
2019-04-04 16:44 ` [PATCH 4.9 00/91] 4.9.168-stable review kernelci.org bot
2019-04-05 3:14 ` Naresh Kamboju
2019-04-05 15:26 ` shuah
2019-04-05 15:36 ` Jon Hunter
2019-04-05 18:30 ` Guenter Roeck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190404084539.562049592@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rmk+kernel@armlinux.org.uk \
--cc=sashal@kernel.org \
--cc=stable@vger.kernel.org \
--cc=will.deacon@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).