LKML Archive on lore.kernel.org
 help / color / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Andy Lutomirski <luto@amacapital.net>,
	Thomas Gleixner <tglx@linutronix.de>,
	"Peter Zijlstra (Intel)" <peterz@infradead.org>,
	Ingo Molnar <mingo@kernel.org>
Subject: [PATCH] x86: Init per-cpu shadow copy of CR4 for i386 too
Date: Fri, 27 Feb 2015 14:50:19 -0500
Message-ID: <20150227145019.2bdd4354@gandalf.local.home> (raw)
In-Reply-To: <CA+55aFw__pp_ivEsX3o_7OUhLV6ROvVq_vdsxNHv2DgvTCYVqg@mail.gmail.com>

On Fri, 27 Feb 2015 10:59:52 -0800
Linus Torvalds <torvalds@linux-foundation.org> wrote:
 
> Presumably there is some initialization missing - I suspect that the
> cached value of cr4 is from the *previous* time the CPU was up, and we
> don't correctly initialize the cached copy at early CPU bringup.

Found it. The problem is that there's two cpu_init()s in common.c. Andy
only added the cr4 init to one of them.


x86: Init per-cpu shadow copy of CR4 for i386 too

The commit 1e02ce4cccdc "x86: Store a per-cpu shadow copy of CR4" added
a shadow CR4 such that reads and writes that do not modify the CR4
execute much faster than always reading the register itself.
The change modified cpu_init() in common.c, so that the shadow CR4 gets
initialized before anything uses it. Unfortunately, there's two
cpu_init()s in common.c. There's one for x86_64 and one for i386. The
commit only added the shadow init to x86_64. The i386 needs the init
too.

Link: http://lkml.kernel.org/r/20150227125208.71c36402@gandalf.local.home
Fixes: 1e02ce4cccdc "x86: Store a per-cpu shadow copy of CR4"
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index b5c8ff5e9dfc..2346c95c6ab1 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -1396,6 +1396,12 @@ void cpu_init(void)
 
 	wait_for_master_cpu(cpu);
 
+	/*
+	 * Initialize the CR4 shadow before doing anything that could
+	 * try to read it.
+	 */
+	cr4_init_shadow();
+
 	show_ucode_info_early();
 
 	printk(KERN_INFO "Initializing CPU#%d\n", cpu);

  reply index

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-27 17:52 [REGRESSION][4.0-rc1] My i386 fails to do CPU hotplug Steven Rostedt
2015-02-27 18:59 ` Linus Torvalds
2015-02-27 19:50   ` Steven Rostedt [this message]
2015-02-27 19:54     ` [PATCH] x86: Init per-cpu shadow copy of CR4 for i386 too Andy Lutomirski
2015-02-27 19:59       ` Steven Rostedt
2015-02-28  7:07     ` [tip:x86/urgent] x86: Init per-cpu shadow copy of CR4 on 32-bit CPUs too tip-bot for Steven Rostedt
2015-02-27 19:53   ` [PATCH] x86_32: Initialize the cr4 shadow on cpu init Andy Lutomirski
2015-02-27 20:19     ` Steven Rostedt
2015-02-27 20:21       ` Andy Lutomirski

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=20150227145019.2bdd4354@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.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

LKML Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/lkml/0 lkml/git/0.git
	git clone --mirror https://lore.kernel.org/lkml/1 lkml/git/1.git
	git clone --mirror https://lore.kernel.org/lkml/2 lkml/git/2.git
	git clone --mirror https://lore.kernel.org/lkml/3 lkml/git/3.git
	git clone --mirror https://lore.kernel.org/lkml/4 lkml/git/4.git
	git clone --mirror https://lore.kernel.org/lkml/5 lkml/git/5.git
	git clone --mirror https://lore.kernel.org/lkml/6 lkml/git/6.git
	git clone --mirror https://lore.kernel.org/lkml/7 lkml/git/7.git
	git clone --mirror https://lore.kernel.org/lkml/8 lkml/git/8.git
	git clone --mirror https://lore.kernel.org/lkml/9 lkml/git/9.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 lkml lkml/ https://lore.kernel.org/lkml \
		linux-kernel@vger.kernel.org
	public-inbox-index lkml

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-kernel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git