linux/arch/powerpc/kernel
Michael Ellerman 8e25a62e8d powerpc/idle: Don't corrupt back chain when going idle
commit 496c5fe25c377ddb7815c4ce8ecfb676f051e9b6 upstream.

In isa206_idle_insn_mayloss() we store various registers into the stack
red zone, which is allowed.

However inside the IDLE_STATE_ENTER_SEQ_NORET macro we save r2 again,
to 0(r1), which corrupts the stack back chain.

We used to do the same in isa206_idle_insn_mayloss() itself, but we
fixed that in 73287caa9210 ("powerpc64/idle: Fix SP offsets when saving
GPRs"), however we missed that the macro also corrupts the back chain.

Corrupting the back chain is bad for debuggability but doesn't
necessarily cause a bug.

However we recently changed the stack handling in some KVM code, and it
now relies on the stack back chain being valid when it returns. The
corruption causes that code to return with r1 pointing somewhere in
kernel data, at some point LR is restored from the stack and we branch
to NULL or somewhere else invalid.

Only affects Power8 hosts running KVM guests, with dynamic_mt_modes
enabled (which it is by default).

The fixes tag below points to the commit that changed the KVM stack
handling, exposing this bug. The actual corruption of the back chain has
always existed since 948cf67c47 ("powerpc: Add NAP mode support on
Power7 in HV mode").

Fixes: 9b4416c5095c ("KVM: PPC: Book3S HV: Fix stack handling in idle_kvm_start_guest()")
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20211020094826.3222052-1-mpe@ellerman.id.au
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-10-27 09:54:28 +02:00
..
syscalls powerpc: Wire up clone3 syscall 2019-07-29 09:34:27 +10:00
trace powerpc/ftrace: Enable HAVE_FUNCTION_GRAPH_RET_ADDR_PTR 2019-09-18 12:24:55 +10:00
vdso32 powerpc: Fix vDSO clock_getres() 2019-12-17 19:56:47 +01:00
vdso64 powerpc: Fix vDSO clock_getres() 2019-12-17 19:56:47 +01:00
.gitignore powerpc: improve prom_init_check rule 2019-09-14 00:04:41 +10:00
align.c powerpc/spe: Mark expected switch fall-throughs 2019-07-31 00:19:34 +10:00
asm-offsets.c powerpc/64: Fix stack trace not displaying final frame 2021-03-17 17:03:43 +01:00
audit.c
btext.c
cacheinfo.c powerpc updates for 5.3 2019-07-13 16:08:36 -07:00
cacheinfo.h powerpc/cacheinfo: add cacheinfo_teardown, cacheinfo_rebuild 2019-06-15 16:52:06 +10:00
compat_audit.c
cpu_setup_6xx.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
cpu_setup_44x.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
cpu_setup_fsl_booke.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
cpu_setup_pa6t.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 333 2019-06-05 17:37:06 +02:00
cpu_setup_power.S powerpc/64s: Don't init FSCR_DSCR in __init_FSCR() 2020-09-03 11:26:39 +02:00
cpu_setup_ppc970.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
cputable.c powerpc: fix hardware PMU exception bug on PowerVM compatibility mode systems 2020-03-12 13:00:31 +01:00
crash_dump.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 230 2019-06-19 17:09:06 +02:00
crash.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 230 2019-06-19 17:09:06 +02:00
dawr.c powerpc: Fix compile issue with force DAWR 2019-07-03 15:19:35 +10:00
dbell.c KVM: PPC: Book3S HV: use smp_mb() when setting/clearing host_ipi flag 2019-09-24 12:46:26 +10:00
dma-iommu.c powerpc/dma: Fix dma_map_ops::get_required_mask 2020-09-23 12:40:46 +02:00
dma-mask.c dma-mapping, powerpc: simplify the arch dma_set_mask override 2019-02-18 22:41:03 +11:00
dma-swiotlb.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
dt_cpu_ftrs.c powerpc/64s: Don't let DT CPU features set FSCR_DSCR 2020-06-22 09:31:23 +02:00
early_32.c powerpc/32: use memset() instead of memset_io() to zero BSS 2019-05-03 01:20:26 +10:00
eeh_cache.c powerpc/eeh_cache: Fix a possible debugfs deadlock 2020-11-18 19:20:18 +01:00
eeh_dev.c powerpc/eeh: Add bdfn field to eeh_dev 2019-08-22 23:12:46 +10:00
eeh_driver.c powerpc/eeh: Fix deadlock handling dead PHB 2020-02-28 17:22:17 +01:00
eeh_event.c powerpc/eeh: Fix build with STACKTRACE=n 2019-09-14 00:01:14 +10:00
eeh_pe.c powerpc/eeh: Clean up EEH PEs after recovery finishes 2019-09-05 14:22:37 +10:00
eeh_sysfs.c powerpc/eeh: Add include_passed to eeh_pe_state_clear() 2019-02-05 11:55:43 +11:00
eeh.c powerpc/eeh: Fix EEH handling for hugepages in ioremap space. 2021-05-11 14:04:15 +02:00
entry_32.S powerpc/32s: Add missing call to kuep_lock on syscall entry 2021-03-04 10:26:49 +01:00
entry_64.S powerpc/book3s64: Fix link stack flush on context switch 2019-11-29 10:10:31 +01:00
epapr_hcalls.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
epapr_paravirt.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 266 2019-06-05 17:30:28 +02:00
exceptions-64e.S powerpc/64: optimise LOAD_REG_IMMEDIATE_SYM() 2019-08-27 13:03:36 +10:00
exceptions-64s.S powerpc/64s: flush L1D after user accesses 2020-11-22 10:14:10 +01:00
fadump.c powerpc/fadump: Mark fadump_calculate_reserve_size as __init 2021-05-14 09:44:26 +02:00
firmware.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
fpu.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
fsl_booke_entry_mapping.S
head_8xx.S powerpc/8xx: Fix software emulation interrupt 2021-03-04 10:26:33 +01:00
head_32.h powerpc/32: replace LOAD_MSR_KERNEL() by LOAD_REG_IMMEDIATE() 2019-08-27 13:03:36 +10:00
head_32.S powerpc/603: Fix protection of user pages mapped with PROT_NONE 2021-03-17 17:03:33 +01:00
head_40x.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
head_44x.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
head_64.S powerpc/64: Fix an EMIT_BUG_ENTRY in head_64.S 2020-12-30 11:51:17 +01:00
head_booke.h powerpc/32: fix build failure on book3e with KVM 2019-06-16 00:03:38 +10:00
head_fsl_booke.S powerpc/kasan: Fix boot failure with RELOCATABLE && FSL_BOOKE 2020-01-26 10:00:59 +01:00
hw_breakpoint.c powerpc/watchpoint: Disable watchpoint hit by larx/stcx instructions 2019-09-12 09:27:00 +10:00
idle_6xx.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
idle_book3e.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
idle_book3s.S powerpc/idle: Don't corrupt back chain when going idle 2021-10-27 09:54:28 +02:00
idle_e500.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
idle_power4.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
idle.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
ima_kexec.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
io-workarounds.c powerpc/mm: rework io-workaround invocation. 2019-08-27 13:03:34 +10:00
io.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
iomap.c
iommu.c powerpc/iommu: Annotate nested lock for lockdep 2021-05-19 10:08:24 +02:00
irq.c powerpc/irq: fix stack overflow verification 2019-12-31 16:46:29 +01:00
isa-bridge.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
jump_label.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
kexec_elf_64.c kexec: add KEXEC_ELF 2019-09-06 23:58:43 +02:00
kgdb.c powerpc: Activate CONFIG_THREAD_INFO_IN_TASK 2019-02-23 22:31:40 +11:00
kprobes-ftrace.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 156 2019-05-30 11:26:35 -07:00
kprobes.c powerpc/kprobes: Fix kprobe Oops happens in booke 2021-08-18 08:57:01 +02:00
kvm_emul.S powerpc/kvm: Add ifdefs around template code 2019-09-14 00:04:40 +10:00
kvm.c powerpc/kvm: Explicitly mark kvm guest code as __init 2019-09-14 00:04:40 +10:00
l2cr_6xx.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 61 2019-05-24 17:36:45 +02:00
legacy_serial.c
machine_kexec_32.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 230 2019-06-19 17:09:06 +02:00
machine_kexec_64.c powerpc/pseries/svm: Unshare all pages before kexecing a new kernel 2019-08-30 09:55:40 +10:00
machine_kexec_file_64.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 285 2019-06-05 17:36:37 +02:00
machine_kexec.c powerpc/crashkernel: Take "mem=" option into account 2020-06-24 17:50:18 +02:00
Makefile powerpc: Avoid broken GCC __attribute__((optimize)) 2020-12-30 11:51:09 +01:00
mce_power.c powerpc/mm/mce: Keep irqs disabled during lockless page table walk 2019-09-19 21:24:59 +10:00
mce.c powerpc/64s/pseries: machine check convert to use common event code 2019-08-30 10:32:35 +10:00
misc_32.S powerpc: Convert flush_icache_range & friends to C 2020-03-12 13:00:25 +01:00
misc_64.S powerpc: Convert flush_icache_range & friends to C 2020-03-12 13:00:25 +01:00
misc.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
module_32.c powerpc updates for 5.3 2019-07-13 16:08:36 -07:00
module_64.c powerpc updates for 5.3 2019-07-13 16:08:36 -07:00
module.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 156 2019-05-30 11:26:35 -07:00
module.lds
msi.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
note.S powerpc: Add PowerPC Capabilities ELF note 2019-08-30 09:40:15 +10:00
nvram_64.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
of_platform.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
optprobes_head.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
optprobes.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
paca.c powerpc: Avoid broken GCC __attribute__((optimize)) 2020-12-30 11:51:09 +01:00
pci_32.c powerpc/64: Adjust order in pcibios_init() 2019-08-22 23:11:48 +10:00
pci_64.c powerpc/64: Adjust order in pcibios_init() 2019-08-22 23:11:48 +10:00
pci_dn.c powerpc/sriov: Remove VF eeh_dev state when disabling SR-IOV 2020-02-24 08:36:56 +01:00
pci_of_scan.c powerpc/of/pci: Rewrite pci_parse_of_flags 2019-08-29 20:24:05 +10:00
pci-common.c powerpc/pci: Add ppc_md.discover_phbs() 2021-03-17 17:03:42 +01:00
pci-hotplug.c powerpc/eeh: Fix race when freeing PDNs 2019-09-05 14:22:37 +10:00
pmc.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
ppc32.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
ppc_save_regs.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
proc_powerpc.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 156 2019-05-30 11:26:35 -07:00
process.c powerpc/64: Fix stack trace not displaying final frame 2021-03-17 17:03:43 +01:00
prom_init_check.sh powerpc/prom_init: Undo relocation before entering secure mode 2019-10-29 15:12:17 +11:00
prom_init.c powerpc/prom: Fix "ibm,arch-vec-5-platform-support" scan 2021-03-04 10:26:46 +01:00
prom_parse.c
prom.c powerpc/prom: Mark identical_pvr_fixup as __init 2021-05-14 09:44:26 +02:00
ptrace32.c
ptrace.c ptrace: move clearing of TIF_SYSCALL_EMU flag to core 2019-06-05 17:51:17 +01:00
reloc_32.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
reloc_64.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
rtas_flash.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
rtas_pci.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 156 2019-05-30 11:26:35 -07:00
rtas-proc.c
rtas-rtc.c
rtas.c powerpc/rtas: Fix typo of ibm,open-errinjct in RTAS filter 2020-12-30 11:51:38 +01:00
rtasd.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
security.c powerpc/security: Fix debugfs data leak on 32-bit 2020-01-26 10:00:59 +01:00
setup_32.c powerpc/32: drop CPU_FTR_UNIFIED_ID_CACHE 2019-08-28 23:19:33 +10:00
setup_64.c powerpc: Avoid broken GCC __attribute__((optimize)) 2020-12-30 11:51:09 +01:00
setup-common.c powerpc/64: Set up a kernel stack for secondaries before cpu_restore() 2020-12-30 11:51:04 +01:00
setup.h powerpc: Avoid broken GCC __attribute__((optimize)) 2020-12-30 11:51:09 +01:00
signal_32.c powerpc/tm: Fix clearing MSR[TS] in current when reclaiming on signal delivery 2020-02-28 17:22:17 +01:00
signal_64.c powerpc/64/tm: Don't let userspace set regs->trap via sigreturn 2020-04-17 10:50:22 +02:00
signal.c powerpc/tm: Fix clearing MSR[TS] in current when reclaiming on signal delivery 2020-02-28 17:22:17 +01:00
signal.h
smp-tbsync.c
smp.c powerpc: Offline CPU in stop_this_cpu() 2021-07-14 16:53:47 +02:00
stacktrace.c powerpc/stacktrace: Include linux/delay.h 2021-09-22 12:26:23 +02:00
suspend.c PM: hibernate: powerpc: Expose pfn_is_nosave() prototype 2019-06-14 10:48:56 +02:00
swsusp_32.S powerpc/32s: fix suspend/resume when IBATs 4-7 are used 2019-06-19 20:05:07 +10:00
swsusp_64.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 505 2019-06-19 17:11:22 +02:00
swsusp_asm64.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 505 2019-06-19 17:11:22 +02:00
swsusp_booke.S
swsusp.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
sys_ppc32.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
syscalls.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
sysfs.c powerpc: Warn about use of smt_snooze_delay 2020-11-05 11:43:31 +01:00
systbl_chk.sh treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
systbl.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
tau_6xx.c powerpc/tau: Disable TAU between measurements 2020-10-29 09:57:49 +01:00
time.c Revert "powerpc/64: irq_work avoid interrupt when called with hardware irqs enabled" 2020-04-29 16:33:01 +02:00
tm.S powerpc/tm: update comment about interrupt re-entrancy 2019-07-02 21:39:49 +10:00
traps.c powerpc: improve handling of unrecoverable system reset 2021-03-17 17:03:42 +01:00
ucall.S powerpc/kernel: Add ucall_norets() ultravisor call handler 2019-08-30 09:40:15 +10:00
udbg_16550.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
udbg.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
uprobes.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 156 2019-05-30 11:26:35 -07:00
vdso.c powerpc/vdso: Fix vdso cpu truncation 2020-08-19 08:16:12 +02:00
vecemu.c
vector.S powerpc/64: Don't trace code that runs with the soft irq mask unreconciled 2019-05-03 01:58:11 +10:00
vmlinux.lds.S vmlinux.lds.h: Create section for protection against instrumentation 2021-02-17 10:35:16 +01:00
watchdog.c powerpc/watchdog: Use hrtimers for per-CPU heartbeat 2019-04-30 11:31:02 +10:00