]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
powerpc/tm: Unset MSR[TS] if not recheckpointing
authorBreno Leitao <leitao@debian.org>
Mon, 26 Nov 2018 20:12:00 +0000 (18:12 -0200)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Wed, 14 Aug 2019 09:18:49 +0000 (11:18 +0200)
commitbc668177e77e80f26d340ea12230e51d41a08a94
tree51a946381faf4a55e64e0c46952c1988b6931d3e
parentc0d81320929851fcedb16ced4d7a1de0cbfd118e
powerpc/tm: Unset MSR[TS] if not recheckpointing

BugLink: https://bugs.launchpad.net/bugs/1837257
commit 6f5b9f018f4c7686fd944d920209d1382d320e4e upstream.

There is a TM Bad Thing bug that can be caused when you return from a
signal context in a suspended transaction but with ucontext MSR[TS] unset.

This forces regs->msr[TS] to be set at syscall entrance (since the CPU
state is transactional). It also calls treclaim() to flush the transaction
state, which is done based on the live (mfmsr) MSR state.

Since user context MSR[TS] is not set, then restore_tm_sigcontexts() is not
called, thus, not executing recheckpoint, keeping the CPU state as not
transactional. When calling rfid, SRR1 will have MSR[TS] set, but the CPU
state is non transactional, causing the TM Bad Thing with the following
stack:

[   33.862316] Bad kernel stack pointer 3fffd9dce3e0 at c00000000000c47c
cpu 0x8: Vector: 700 (Program Check) at [c00000003ff7fd40]
    pc: c00000000000c47c: fast_exception_return+0xac/0xb4
    lr: 00003fff865f442c
    sp: 3fffd9dce3e0
   msr: 8000000102a03031
  current = 0xc00000041f68b700
  paca    = 0xc00000000fb84800   softe: 0        irq_happened: 0x01
    pid   = 1721, comm = tm-signal-sigre
Linux version 4.9.0-3-powerpc64le (debian-kernel@lists.debian.org) (gcc version 6.3.0 20170516 (Debian 6.3.0-18) ) #1 SMP Debian 4.9.30-2+deb9u2 (2017-06-26)
WARNING: exception is not recoverable, can't continue

The same problem happens on 32-bits signal handler, and the fix is very
similar, if tm_recheckpoint() is not executed, then regs->msr[TS] should be
zeroed.

This patch also fixes a sparse warning related to lack of indentation when
CONFIG_PPC_TRANSACTIONAL_MEM is set.

Fixes: 2b0a576d15e0e ("powerpc: Add new transactional memory state to the signal context")
CC: Stable <stable@vger.kernel.org> # 3.10+
Signed-off-by: Breno Leitao <leitao@debian.org>
Tested-by: Michal Suchánek <msuchanek@suse.de>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
arch/powerpc/kernel/signal_32.c
arch/powerpc/kernel/signal_64.c