From: Michael Ellerman <mpe@ellerman.id.au>
To: Gavin Shan <gwshan@linux.vnet.ibm.com>
Cc: linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH] powerpc/kernel: Avoid memory corruption at early stage
Date: Thu, 22 Jan 2015 17:21:22 +1100 [thread overview]
Message-ID: <1421907682.4598.6.camel@ellerman.id.au> (raw)
In-Reply-To: <1420695651-574-1-git-send-email-gwshan@linux.vnet.ibm.com>
On Thu, 2015-01-08 at 16:40 +1100, Gavin Shan wrote:
> When calling to early_setup(), we picks "boot_paca" up for the
> master CPU and initialize that with initialise_paca(). At the
> point, SLB shadow buffer isn't populated yet. Updating the SLB
> shadow buffer should corrupt what we had in physical address 0
> where the trap instruction is usually stored.
Ouch.
Introduced in 6f4441ef7009 ("powerpc: Dynamically allocate slb_shadow from
memblock") - December 2013.
So it seems it doesn't cause us any harm in general.
Did you actually hit a bug with it?
> diff --git a/arch/powerpc/kernel/paca.c b/arch/powerpc/kernel/paca.c
> index d6e195e..048a6ee 100644
> --- a/arch/powerpc/kernel/paca.c
> +++ b/arch/powerpc/kernel/paca.c
> @@ -115,6 +115,9 @@ static struct slb_shadow * __init init_slb_shadow(int cpu)
> {
> struct slb_shadow *s = &slb_shadow[cpu];
>
> + if (!slb_shadow)
> + return NULL;
> +
> s->persistent = cpu_to_be32(SLB_NUM_BOLTED);
> s->buffer_length = cpu_to_be32(sizeof(*s));
Yeah I guess that's an OK fix.
We must have a valid SLB shadow before we ever call _switch(), which is much
later. The only way we could hit this case for the real paca is if
allocate_slb_shadows() failed to allocate, but it would have panicked if it
did.
cheers
next prev parent reply other threads:[~2015-01-22 6:21 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-08 5:40 [PATCH] powerpc/kernel: Avoid memory corruption at early stage Gavin Shan
2015-01-22 6:21 ` Michael Ellerman [this message]
2015-01-22 6:40 ` Gavin Shan
2015-01-23 0:47 ` Michael Ellerman
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=1421907682.4598.6.camel@ellerman.id.au \
--to=mpe@ellerman.id.au \
--cc=gwshan@linux.vnet.ibm.com \
--cc=linuxppc-dev@lists.ozlabs.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 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.