[LTC Test] Ubuntu 18.04: tm_sigreturn failed on P8 compat mode 16.04.04 guest
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
The Ubuntu-power-systems project |
Fix Released
|
Medium
|
Canonical Kernel Team | ||
linux (Ubuntu) |
Fix Released
|
Medium
|
Unassigned | ||
Xenial |
Fix Released
|
Medium
|
Unassigned |
Bug Description
== SRU Justification ==
IBM is seeing tm_sigreturn test failures on P8 and P9 hosts. The bad thing
exception is being raised when executing the following line:
c00000000004fcfc: b0 04 03 e8 ld r0,1200(r3)
-> c00000000004fd00: a6 23 02 7c mtspr 130,r0
Which is basically restoring TEXASR in the thread.
ISA says "These registers can be written only when in Non-transactional
state" and the MSR is set to be transactional (suspended):
MSR: 8000000300201033 [ME][RI]
That explains why they are getting the "bad thing exception". A mtspr is
being called with a transaction suspended.
This test failure is fixed by upstream commit 78a3e8889b4b.
Upstream commit 78a3e8889b4b is in mainline as of 4.8-rc5.
== Fix ==
78a3e8889b4b ("powerpc: signals: Discard transaction state from signal frames")
== Regression Potential ==
Low. Specific to powerpc.
== Test Case ==
A test kernel was built with this patch and tested by the original bug reporter.
The bug reporter states the test kernel resolved the bug.
This test fails in the same way on a P8 host, so it is nothing to do with P9.
There have been many TM bugs fixed upstream since 4.4. I would suggest starting with commit 044215d145a7 ("powerpc/tm: Fix illegal TM state in signal handler", 2017-08-22) and see if that helps.
The bad thing exception is being raised when executing the following line:
-> c00000000004fd00: a6 23 02 7c mtspr 130,r0
Which is basically restoring TEXASR in the thread.
ISA says "These registers can be written only when in Non-transactional state" and the MSR is set to be transactional (suspended):
MSR: 8000000300201033 [ME][RI]
That explains why we are getting the "bad thing exception". A mtspr is being called with a transaction suspended.
I think we need the following commit to have this fixed:
commit 78a3e8889b4b6b9
Author: Cyril Bur <email address hidden>
Date: Tue Aug 23 10:46:17 2016 +1000
powerpc: signals: Discard transaction state from signal frames
Userspace can begin and suspend a transaction within the signal
handler which means they might enter sys_rt_sigreturn() with the
processor in suspended state.
sys_
been in a transaction before signal delivery). To do this it must
restore TM SPRS. To achieve this, any transaction initiated within the
signal frame must be discarded in order to be able to restore TM SPRs
as TM SPRs can only be manipulated non-transaction
>From the PowerPC ISA:
TM Bad Thing Exception [Category: Transactional Memory]
An attempt is made to execute a mtspr targeting a TM register in
other than Non-transactional state.
Not doing so results in a TM Bad Thing:
[12045.221359] Kernel BUG at c000000000050a40 [verbose debug info unavailable]
[12045.221470] Unexpected TM Bad Thing exception at c000000000050a40 (msr 0x201033)
[12045.221540] Oops: Unrecoverable exception, sig: 6 [#1]
[12045.221586] SMP NR_CPUS=2048 NUMA PowerNV
[12045.221634] Modules linked in: xt_CHECKSUM iptable_mangle ipt_MASQUERADE
nf_
xt_conntrack nf_conntrack ipt_REJECT nf_reject_ipv4 xt_tcpudp bridge stp llc ebtable_filter
ebtables ip6table_filter ip6_tables iptable_filter ip_tables x_tables kvm_hv kvm
uio_
scsi_
[12045.222167] CPU: 68 PID: 6178 Comm: sigreturnpanic Not tainted 4.7.0 #34
[12045.222224] task: c0000000fce38600 ti: c0000000fceb4000 task.ti: c0000000fceb4000
[12045.222293] NIP: c000000000050a40 LR: c0000000000163bc CTR: 0000000000000000
[12045.222361] REGS: c0000000fceb7ac0 TRAP: 0700 Not tainted (4.7.0)
[12045.222418] MSR: 9000000300201033 <SF,HV,
[12045.222625] CFAR: c0000000000163b8 SOFTE: 0 PACATMSCRATCH: 900000014280f033
GPR00: 01100000b8000001 c0000000fceb7d40 c00000000139c100 c0000000fce390d0
GPR04: 900000034280f033 0000000000000000 0000000000000000 0000000000000000
GPR08: 0000000000000000 b000000000001033 0000000000000001 0000000000000000
GPR12: 0000000000000000 c000000002926400 0000000000000000 0000000000000000
GPR16: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
GPR20: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
GPR24: 0000000000000000 00003ffff98cadd0 00003ffff98cb470 0000000000000000
GPR28: 900000034280f033 c0000000fceb7ea0 0000000000000001 c0000000fce390d0
[12045.223535] NIP [c000000000050a40] tm_restore_
[12045.223584] LR [c0000000000163bc] tm_recheckpoint
[12045.223630] Call Trace:
[12045.223655] [c0000000fceb7d80] [c000000000026e74] sys_rt_
[12045.223738] [c0000000fceb7e30] [c0000000000092e0] system_
[12045.223806] Instruction dump:
[12045.223841] 7c800164 4e800020 7c0022a6 f80304a8 7c0222a6 f80304b0 7c0122a6 f80304b8
[12045.223955] 4e800020 e80304a8 7c0023a6 e80304b0 <7c0223a6> e80304b8 7c0123a6 4e800020
[12045.224074] ---[ end trace cb8002ee240bae76 ]---
It isn't clear exactly if there is really a use case for userspace
returning with a suspended transaction, however, doing so doesn't (on
its own) constitute a bad frame. As such, this patch simply discards
the transactional state of the context calling the sigreturn and
continues.
Reported-by: Laurent Dufour <email address hidden>
Signed-off-by: Cyril Bur <email address hidden>
Tested-by: Laurent Dufour <email address hidden>
Reviewed-by: Laurent Dufour <email address hidden>
Acked-by: Simon Guo <email address hidden>
Signed-off-by: Benjamin Herrenschmidt <email address hidden>
diff --git a/Documentation
index ba0a2a4..e32fdbb 100644
--- a/Documentation
+++ b/Documentation
@@ -167,6 +167,8 @@ signal will be rolled back anyway.
For signals taken in non-TM or suspended mode, we use the
normal/
+Any transaction initiated inside a sighandler and suspended on return
+from the sighandler to the kernel will get reclaimed and discarded.
Failure cause codes used by kernel
======
diff --git a/arch/
index b6aa378..a7daf74 100644
--- a/arch/
+++ b/arch/
@@ -1226,7 +1226,21 @@ long sys_rt_
(regs->gpr[1] + __SIGNAL_FRAMESIZE + 16);
if (!access_
goto bad;
+
#ifdef CONFIG_
+ /*
+ * If there is a transactional state then throw it away.
+ * The purpose of a sigreturn is to destroy all traces of the
+ * signal frame, this includes any transactional state created
+ * within in. We only check for suspended as we can never be
+ * active in the kernel, we are active, there is nothing better to
+ * do than go ahead and Bad Thing later.
+ * The cause is not important as there will never be a
+ * recheckpoint so it's not user visible.
+ */
+ if (MSR_TM_
+ tm_reclaim_
+
if (__get_user(tmp, &rt_sf-
goto bad;
uc_transact = (struct ucontext __user *)(uintptr_t)tmp;
diff --git a/arch/
index 7e49984..70409bb 100644
--- a/arch/
+++ b/arch/
@@ -676,7 +676,21 @@ int sys_rt_
if (__copy_
goto badframe;
set_current_
+
#ifdef CONFIG_
+ /*
+ * If there is a transactional state then throw it away.
+ * The purpose of a sigreturn is to destroy all traces of the
+ * signal frame, this includes any transactional state created
+ * within in. We only check for suspended as we can never be
+ * active in the kernel, we are active, there is nothing better to
+ * do than go ahead and Bad Thing later.
+ * The cause is not important as there will never be a
+ * recheckpoint so it's not user visible.
+ */
+ if (MSR_TM_
+ tm_reclaim_
+
if (__get_user(msr, &uc->uc_
goto badframe;
if (MSR_TM_
== Breno Leitao <email address hidden> ==
That is exactly the commit id that solves the problem.
I was able to cherry pick 78a3e8889b4b6b9
1604 ? sudo dmesg -c > /dev/null
1604 ? ./tm-sigreturn
test: tm_sigreturn
tags: git_version:
success: tm_sigreturn
1604 ? dmesg
1604 ?
tags: | added: triage-g |
Changed in ubuntu-power-systems: | |
status: | New → Triaged |
importance: | Undecided → Medium |
assignee: | nobody → Canonical Kernel Team (canonical-kernel-team) |
Changed in linux (Ubuntu): | |
importance: | Undecided → Medium |
status: | New → Triaged |
Changed in ubuntu-power-systems: | |
status: | Triaged → In Progress |
description: | updated |
Changed in linux (Ubuntu Xenial): | |
status: | In Progress → Fix Committed |
Changed in ubuntu-power-systems: | |
status: | In Progress → Fix Committed |
tags: |
added: verification-done-xenial removed: verification-needed-xenial |
Changed in ubuntu-power-systems: | |
status: | Fix Committed → Fix Released |
Changed in linux (Ubuntu): | |
status: | In Progress → Fix Released |
tags: | added: cscc |
Default Comment by Bridge