From: Cyril Bur <cyrilbur@gmail.com>
To: linuxppc-dev@ozlabs.org
Cc: anton@samba.org, mikey@neuling.org
Subject: [RFC 2/3] powerpc: tm: Add TM Unavailable Exception
Date: Wed, 29 Jun 2016 16:34:35 +1000 [thread overview]
Message-ID: <20160629063436.10003-3-cyrilbur@gmail.com> (raw)
In-Reply-To: <20160629063436.10003-1-cyrilbur@gmail.com>
If the kernel disables transactional memory (TM) and userspace still
tries TM related actions (TM instructions or TM SPR accesses) TM aware
hardware will cause the kernel to take a facility unavailable
exception.
Add checks for the exception being caused by illegal TM access in
userspace.
Signed-off-by: Cyril Bur <cyrilbur@gmail.com>
---
arch/powerpc/kernel/traps.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
index 3e4c84d..29260ee 100644
--- a/arch/powerpc/kernel/traps.c
+++ b/arch/powerpc/kernel/traps.c
@@ -1364,6 +1364,13 @@ void vsx_unavailable_exception(struct pt_regs *regs)
die("Unrecoverable VSX Unavailable Exception", regs, SIGABRT);
}
+static void tm_unavailable(struct pt_regs *regs)
+{
+ pr_emerg("Unrecoverable TM Unavailable Exception "
+ "%lx at %lx\n", regs->trap, regs->nip);
+ die("Unrecoverable TM Unavailable Exception", regs, SIGABRT);
+}
+
#ifdef CONFIG_PPC64
void facility_unavailable_exception(struct pt_regs *regs)
{
@@ -1434,6 +1441,23 @@ void facility_unavailable_exception(struct pt_regs *regs)
return;
}
+ /*
+ * TM Unavailable
+ *
+ * If
+ * - firmware bits say don't do TM or
+ * - CONFIG_PPC_TRANSACTIONAL_MEM was not set and
+ * - hardware is actually TM aware
+ * Then userspace can spam the console (even with the use of
+ * _ratelimited), just send the SIGILL.
+ */
+ if (status == FSCR_TM_LG) {
+ if (!cpu_has_feature(CPU_FTR_TM))
+ goto out;
+ tm_unavailable(regs);
+ return;
+ }
+
if ((status < ARRAY_SIZE(facility_strings)) &&
facility_strings[status])
facility = facility_strings[status];
@@ -1446,6 +1470,7 @@ void facility_unavailable_exception(struct pt_regs *regs)
"%sFacility '%s' unavailable, exception at 0x%lx, MSR=%lx\n",
hv ? "Hypervisor " : "", facility, regs->nip, regs->msr);
+out:
if (user_mode(regs)) {
_exception(SIGILL, regs, ILL_ILLOPC, regs->nip);
return;
--
2.9.0
next prev parent reply other threads:[~2016-06-29 6:40 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-29 6:34 [RFC 0/3] Enable MSR_TM lazily Cyril Bur
2016-06-29 6:34 ` [RFC 1/3] selftests/powerpc: Add test to check TM ucontext creation Cyril Bur
2016-06-29 6:34 ` Cyril Bur [this message]
2016-06-29 6:34 ` [RFC 3/3] powerpc: tm: Enable transactional memory (TM) lazily for userspace Cyril Bur
2016-06-30 9:46 ` Laurent Dufour
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=20160629063436.10003-3-cyrilbur@gmail.com \
--to=cyrilbur@gmail.com \
--cc=anton@samba.org \
--cc=linuxppc-dev@ozlabs.org \
--cc=mikey@neuling.org \
/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).