linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Michael Ellerman <mpe@ellerman.id.au>
To: linuxppc-dev@ozlabs.org
Subject: Re: [PATCH] powerpc: Check that all cpu features are in the possible map
Date: Tue, 04 Mar 2014 14:38:49 +1100	[thread overview]
Message-ID: <1393904329.11997.3.camel@concordia> (raw)
In-Reply-To: <1393901079-25319-1-git-send-email-mpe@ellerman.id.au>

On Tue, 2014-03-04 at 13:44 +1100, Michael Ellerman wrote:
> diff --git a/arch/powerpc/kernel/cputable.c b/arch/powerpc/kernel/cputable.c
> index 6c8dd5d..eb31713 100644
> --- a/arch/powerpc/kernel/cputable.c
> +++ b/arch/powerpc/kernel/cputable.c
> @@ -2255,6 +2255,15 @@ static struct cpu_spec * __init setup_cpu_spec(unsigned long offset,
>  	}
>  #endif /* CONFIG_PPC64 || CONFIG_BOOKE */
>  
> +	/*
> +	 * Check that all CPU features are in the possible mask. We don't want
> +	 * to WARN() because we're called very early, and doing so will kill
> +	 * the machine, so just printk() instead.
> +	 */
> +	if (t->cpu_features != (t->cpu_features & CPU_FTRS_POSSIBLE))
> +		printk("WARNING: cpu spec contains impossible features! 0x%lx\n",
> +			(t->cpu_features & ~CPU_FTRS_POSSIBLE));


Actually even this is not safe.

printk() takes the logbuf_lock, but we don't have a paca yet, so our LOCK_TOKEN
will be some random guff in low memory. And although that's OK, we're single
threaded, it's a bit fishy.

What's worse is printk() does local_irq_save(), which will _store_ to our paca
(soft_enabled), and so we risk flipping a value somewhere.

Interestingly lockdep appears to be OK, even though we haven't initialised it
yet. printk() helpfully turns lockdep off before doing any locking.

cheers

      reply	other threads:[~2014-03-04  3:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-04  2:44 [PATCH] powerpc: Check that all cpu features are in the possible map Michael Ellerman
2014-03-04  3:38 ` 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=1393904329.11997.3.camel@concordia \
    --to=mpe@ellerman.id.au \
    --cc=linuxppc-dev@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 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).