powerpc: do_notify_resume can be called with bad thread_info flags argument
authorAnton Blanchard <anton@samba.org>
Fri, 31 Oct 2014 05:50:57 +0000 (16:50 +1100)
committerZefan Li <lizefan@huawei.com>
Mon, 2 Feb 2015 09:05:10 +0000 (17:05 +0800)
commitb1873077c564ef1103f593d85f0792b16ea89367
treed3b7c3e396c5befce73925190da3f77f633ac2fa
parentd6be20a0690320e1bd3970bafd8bc86b57fdf65b
powerpc: do_notify_resume can be called with bad thread_info flags argument

commit 808be31426af57af22268ef0fcb42617beb3d15b upstream.

Back in 7230c5644188 ("powerpc: Rework lazy-interrupt handling") we
added a call out to restore_interrupts() (written in c) before calling
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 (the second argument) 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.

LLVM on the other hand did trample r4.

Signed-off-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
[lizf: Backported to 3.4: adjust context]
Signed-off-by: Zefan Li <lizefan@huawei.com>
arch/powerpc/kernel/entry_64.S