linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Anton Blanchard <anton@samba.org>
To: benh@kernel.crashing.org, paulus@samba.org, mpe@ellerman.id.au
Cc: linuxppc-dev@lists.ozlabs.org, stable@vger.kernel.org
Subject: [PATCH] powerpc: do_notify_resume can be called with bad thread_info flags argument
Date: Thu, 30 Oct 2014 16:12:58 +1100	[thread overview]
Message-ID: <1414645978-21968-1-git-send-email-anton@samba.org> (raw)

Back in 7230c5644188 ("powerpc: Rework lazy-interrupt handling") we
added a call out to restore_interrupts() (written in c) before we
call do_notify_resume:

        bl      restore_interrupts
        addi    r3,r1,STACK_FRAME_OVERHEAD
        bl      do_notify_resume

Unfortunately do_notify_resume takes two arguments, the second one
being the thread_info flags:

void do_notify_resume(struct pt_regs *regs, unsigned long thread_info_flags)

We do populate r4 earlier, but restore_interrupts() is free to muck
it up all it wants. My guess is the gcc compiler gods shone down on
us and its register allocator never used r4. Sometimes, rarely, luck
is on our side.

Signed-off-by: Anton Blanchard <anton@samba.org>
Cc: stable@vger.kernel.org
---
 arch/powerpc/kernel/entry_64.S | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S
index 9caab69..add42d0 100644
--- a/arch/powerpc/kernel/entry_64.S
+++ b/arch/powerpc/kernel/entry_64.S
@@ -661,6 +661,13 @@ _GLOBAL(ret_from_except_lite)
 	bl	save_nvgprs
 	bl	restore_interrupts
 	addi	r3,r1,STACK_FRAME_OVERHEAD
+	/*
+	 * restore_interrupts() is written in c and could clobber all
+	 * volatile registers. We need to reload our thread_info flags
+	 * in r4 for do_notify_resume().
+	 */
+	CURRENT_THREAD_INFO(r9, r1)
+	ld	r4,TI_FLAGS(r9)
 	bl	do_notify_resume
 	b	ret_from_except
 
-- 
1.9.1

             reply	other threads:[~2014-10-30  5:13 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-30  5:12 Anton Blanchard [this message]
  -- strict thread matches above, loose matches on Subject: below --
2014-10-31  3:23 [PATCH] powerpc: do_notify_resume can be called with bad thread_info flags argument Anton Blanchard
2014-10-31  5:50 Anton Blanchard

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=1414645978-21968-1-git-send-email-anton@samba.org \
    --to=anton@samba.org \
    --cc=benh@kernel.crashing.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mpe@ellerman.id.au \
    --cc=paulus@samba.org \
    --cc=stable@vger.kernel.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).