From: Cyril Bur <cyrilbur@gmail.com>
To: linuxppc-dev@lists.ozlabs.org, mpe@ellerman.id.au
Cc: mikey@neuling.org, anton@samba.org, wei.guo.simon@gmail.com
Subject: [PATCH 1/2] powerpc: tm: Add TM Unavailable Exception
Date: Wed, 14 Sep 2016 18:02:15 +1000 [thread overview]
Message-ID: <20160914080216.13833-2-cyrilbur@gmail.com> (raw)
In-Reply-To: <20160914080216.13833-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 0eba74b..cd40130 100644
--- a/arch/powerpc/kernel/traps.c
+++ b/arch/powerpc/kernel/traps.c
@@ -1372,6 +1372,13 @@ void vsx_unavailable_exception(struct pt_regs *regs)
}
#ifdef CONFIG_PPC64
+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);
+}
+
void facility_unavailable_exception(struct pt_regs *regs)
{
static char *facility_strings[] = {
@@ -1451,6 +1458,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];
@@ -1463,6 +1487,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.3
next prev parent reply other threads:[~2016-09-14 8:03 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-14 8:02 [PATCH 0/2] Enable MSR_TM lazily Cyril Bur
2016-09-14 8:02 ` Cyril Bur [this message]
2016-10-05 2:36 ` [1/2] powerpc: tm: Add TM Unavailable Exception Michael Ellerman
2016-09-14 8:02 ` [PATCH 2/2] powerpc: tm: Enable transactional memory (TM) lazily for userspace Cyril Bur
2016-09-19 4:47 ` Simon Guo
2016-09-19 5:26 ` Cyril Bur
2016-09-14 11:28 ` [PATCH 0/2] Enable MSR_TM lazily Nicholas Piggin
2016-09-14 11:46 ` Michael Neuling
2016-09-14 12:12 ` Nicholas Piggin
2016-09-14 12:17 ` Michael Neuling
2016-09-14 14:10 ` Carlos Eduardo Seo
2016-09-15 3:59 ` Nicholas Piggin
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=20160914080216.13833-2-cyrilbur@gmail.com \
--to=cyrilbur@gmail.com \
--cc=anton@samba.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mikey@neuling.org \
--cc=mpe@ellerman.id.au \
--cc=wei.guo.simon@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.