From: Michael Ellerman <patch-notifications@ellerman.id.au>
To: Michael Ellerman <mpe@ellerman.id.au>, linuxppc-dev@ozlabs.org
Cc: npiggin@gmail.com, dja@axtens.net
Subject: Re: [PATCH v6 1/2] powerpc/64: Setup a paca before parsing device tree etc.
Date: Thu, 26 Mar 2020 23:06:57 +1100 (AEDT) [thread overview]
Message-ID: <48p3cy3fx0z9sSL@ozlabs.org> (raw)
In-Reply-To: <20200320032116.1024773-1-mpe@ellerman.id.au>
On Fri, 2020-03-20 at 03:21:15 UTC, Michael Ellerman wrote:
> From: Daniel Axtens <dja@axtens.net>
>
> Currently we set up the paca after parsing the device tree for CPU
> features. Prior to that, r13 contains random data, which means there
> is random data in r13 while we're running the generic dt parsing code.
>
> This random data varies depending on whether we boot through a vmlinux
> or a zImage: for the vmlinux case it's usually around zero, but for
> zImages we see random values like 912a72603d420015.
>
> This is poor practice, and can also lead to difficult-to-debug
> crashes. For example, when kcov is enabled, the kcov instrumentation
> attempts to read preempt_count out of the current task, which goes via
> the paca. This then crashes in the zImage case.
>
> Similarly stack protector can cause crashes if r13 is bogus, by
> reading from the stack canary in the paca.
>
> To resolve this:
>
> - move the paca setup to before the CPU feature parsing.
>
> - because we no longer have access to CPU feature flags in paca
> setup, change the HV feature test in the paca setup path to consider
> the actual value of the MSR rather than the CPU feature.
>
> Translations get switched on once we leave early_setup, so I think
> we'd already catch any other cases where the paca or task aren't set
> up.
>
> Boot tested on a P9 guest and host.
>
> Fixes: fb0b0a73b223 ("powerpc: Enable kcov")
> Fixes: 06ec27aea9fc ("powerpc/64: add stack protector support")
> Cc: stable@vger.kernel.org # v4.20+
> Reviewed-by: Andrew Donnellan <ajd@linux.ibm.com>
> Suggested-by: Michael Ellerman <mpe@ellerman.id.au>
> Signed-off-by: Daniel Axtens <dja@axtens.net>
> [mpe: Reword comments & change log a bit to mention stack protector]
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Series applied to powerpc next.
https://git.kernel.org/powerpc/c/d4a8e98621543d5798421eed177978bf2b3cdd11
cheers
prev parent reply other threads:[~2020-03-26 13:06 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-20 3:21 [PATCH v6 1/2] powerpc/64: Setup a paca before parsing device tree etc Michael Ellerman
2020-03-20 3:21 ` [PATCH v6 2/2] powerpc/64: Prevent stack protection in early boot Michael Ellerman
2020-03-26 12:06 ` Michael Ellerman [this message]
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=48p3cy3fx0z9sSL@ozlabs.org \
--to=patch-notifications@ellerman.id.au \
--cc=dja@axtens.net \
--cc=linuxppc-dev@ozlabs.org \
--cc=mpe@ellerman.id.au \
--cc=npiggin@gmail.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).