From: Richard Weinberger <richard@nod.at>
To: jonas@southpole.se
Cc: linux@openrisc.net, linux-kernel@vger.kernel.org,
Richard Weinberger <richard@nod.at>
Subject: [PATCH] OpenRISC: Handle r0 with care
Date: Mon, 5 Mar 2012 22:07:07 +0100 [thread overview]
Message-ID: <1330981627-16121-1-git-send-email-richard@nod.at> (raw)
Depending on the OpenRISC implementation a rough task may able
to change r0 and corrupt other taks.
Handle this case by setting r0 to zero on each entry point.
Also ensure that r0 is really zero before jumping into _start.
Signed-off-by: Richard Weinberger <richard@nod.at>
diff --git a/arch/openrisc/kernel/entry.S b/arch/openrisc/kernel/entry.S
index d5f9c35..7c9c4f6 100644
--- a/arch/openrisc/kernel/entry.S
+++ b/arch/openrisc/kernel/entry.S
@@ -130,6 +130,7 @@ handler: ;\
#define UNHANDLED_EXCEPTION(handler,vector) \
.global handler ;\
handler: ;\
+ l.andi r0,r0,0 ;\
/* r1, EPCR, ESR already saved */ ;\
l.sw PT_GPR2(r1),r2 ;\
l.sw PT_GPR3(r1),r3 ;\
@@ -185,8 +186,8 @@ handler: ;\
/* ---[ 0x100: RESET exception ]----------------------------------------- */
EXCEPTION_ENTRY(_tng_kernel_start)
+ l.andi r0,r0,0
l.jal _start
- l.andi r0,r0,0
/* ---[ 0x200: BUS exception ]------------------------------------------- */
@@ -976,6 +977,7 @@ ENTRY(_kernel_thread_helper)
.align 0x400
ENTRY(_switch)
+ l.andi r0,r0,0
/* We don't store SR as _switch only gets called in a context where
* the SR will be the same going in and coming out... */
diff --git a/arch/openrisc/kernel/head.S b/arch/openrisc/kernel/head.S
index c75018d..c439324 100644
--- a/arch/openrisc/kernel/head.S
+++ b/arch/openrisc/kernel/head.S
@@ -152,6 +152,7 @@
*/
#define EXCEPTION_HANDLE(handler) \
+ l.andi r0,r0,0 ;\
EXCEPTION_T_STORE_GPR30 ;\
l.mfspr r30,r0,SPR_ESR_BASE ;\
l.andi r30,r30,SPR_SR_SM ;\
--
1.7.6
next reply other threads:[~2012-03-05 21:06 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-05 21:07 Richard Weinberger [this message]
2012-03-06 5:52 ` [ORLinux] " Stefan Kristiansson
2012-03-06 6:09 ` Jonas Bonn
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=1330981627-16121-1-git-send-email-richard@nod.at \
--to=richard@nod.at \
--cc=jonas@southpole.se \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@openrisc.net \
/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
all inboxes | Powered by JetHome®