linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Wolfgang Denk <wd@denx.de>
To: linuxppc-dev@lists.ozlabs.org
Cc: Scott Wood <scottwood@freescale.com>, Wolfgang Denk <wd@denx.de>
Subject: [PATCH] [RFC] Emulate "lwsync" to run standard user land on e500 cores
Date: Fri, 18 Oct 2013 09:38:00 +0200	[thread overview]
Message-ID: <1382081880-6666-1-git-send-email-wd@denx.de> (raw)

Default Debian PowerPC doesn't work on e500 because the code contains
"lwsync" instructions, which are unsupported on this core.  As a
result, applications using this will crash with an "unhandled signal 4"
"Illegal instruction" error.

As a work around we add code to emulate this insn.  This is expensive
performance-wise, but allows to run standard user land code.

Signed-off-by: Wolfgang Denk <wd@denx.de>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Scott Wood <scottwood@freescale.com>
---
I am aware that the clean solution to the problem is to build user
space with compiler options that match the target architecture.
However, sometimes this is just too much effort.

Also, of course the performance of such an emulation sucks. But the
the occurrence of such instructions is so rare that no significant
slowdown can be oserved.

I'm not sure if this should / could go into mainline.  I'm posting it
primarily so it can be found should anybody else need this.
- wd

 arch/powerpc/kernel/traps.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
index f783c93..f330374 100644
--- a/arch/powerpc/kernel/traps.c
+++ b/arch/powerpc/kernel/traps.c
@@ -986,6 +986,13 @@ static int emulate_instruction(struct pt_regs *regs)
 		return 0;
 	}
 
+	/* Emulating the lwsync insn as a sync insn */
+	if (instword == PPC_INST_LWSYNC) {
+		PPC_WARN_EMULATED(lwsync, regs);
+		asm volatile("sync" : : : "memory");
+		return 0;
+	}
+
 	/* Emulate the mcrxr insn.  */
 	if ((instword & PPC_INST_MCRXR_MASK) == PPC_INST_MCRXR) {
 		int shift = (instword >> 21) & 0x1c;
-- 
1.8.3.1

             reply	other threads:[~2013-10-18  7:38 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-18  7:38 Wolfgang Denk [this message]
2013-10-18 16:38 ` [PATCH] [RFC] Emulate "lwsync" to run standard user land on e500 cores Scott Wood
2013-10-18 18:50   ` Wolfgang Denk
2013-10-23  5:07 ` Kumar Gala
2013-10-23 10:15   ` Scott Wood
2013-10-24  4:06     ` Kumar Gala
2013-10-24  9:45       ` Benjamin Herrenschmidt
2013-10-24  9:55         ` Kumar Gala
2013-10-24 21:05           ` James Yang
2013-10-25  4:12             ` Kumar Gala
2013-10-25  4:49               ` Yang James-RA8135
2013-10-25  9:58                 ` David Laight
2013-10-25 13:02                   ` Benjamin Herrenschmidt
2013-10-26  7:26                     ` Kumar Gala
2013-10-25 15:13                   ` James Yang
2013-10-25 10:36           ` Scott Wood
2013-10-25 15:25             ` James Yang
2013-10-28 17:52               ` Scott Wood
2013-10-27 10:29             ` Wolfgang Denk
2013-10-27 10:25           ` Wolfgang Denk
2013-10-24 10:18       ` David Laight

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=1382081880-6666-1-git-send-email-wd@denx.de \
    --to=wd@denx.de \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=scottwood@freescale.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 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).