public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/mm/64: Fix reboot interaction with CR4.PCIDE
@ 2017-10-09  4:53 Andy Lutomirski
  2017-10-09 11:36 ` [tip:x86/urgent] " tip-bot for Andy Lutomirski
  0 siblings, 1 reply; 3+ messages in thread
From: Andy Lutomirski @ 2017-10-09  4:53 UTC (permalink / raw)
  To: x86; +Cc: linux-kernel, Borislav Petkov, Steven Rostedt, Andy Lutomirski

Trying to reboot via real mode fails with PCID on: long mode cannot
be exited while CR4.PCIDE is set.  (No, I have no idea why, but the
SDM and actual CPUs are in agreement here.)  The result is a GPF and
a hang instead of a reboot.

I didn't catch this in testing because neither my computer nor my VM
reboots this way.  I can trigger it with reboot=bios, though.

Fixes: 660da7c9228f ("x86/mm: Enable CR4.PCIDE on supported systems")
Reported-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Tested-by: Steven Rostedt (VMware) <rostedt@godomis.org>
Signed-off-by: Andy Lutomirski <luto@kernel.org>
---
 arch/x86/kernel/reboot.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
index 54180fa6f66f..add33f600531 100644
--- a/arch/x86/kernel/reboot.c
+++ b/arch/x86/kernel/reboot.c
@@ -105,6 +105,10 @@ void __noreturn machine_real_restart(unsigned int type)
 	load_cr3(initial_page_table);
 #else
 	write_cr3(real_mode_header->trampoline_pgd);
+
+	/* Exiting long mode will fail if CR4.PCIDE is set. */
+	if (static_cpu_has(X86_FEATURE_PCID))
+		cr4_clear_bits(X86_CR4_PCIDE);
 #endif
 
 	/* Jump to the identity-mapped low memory code */
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [tip:x86/urgent] x86/mm/64: Fix reboot interaction with CR4.PCIDE
  2017-10-09  4:53 [PATCH] x86/mm/64: Fix reboot interaction with CR4.PCIDE Andy Lutomirski
@ 2017-10-09 11:36 ` tip-bot for Andy Lutomirski
  2017-10-09 12:42   ` Steven Rostedt
  0 siblings, 1 reply; 3+ messages in thread
From: tip-bot for Andy Lutomirski @ 2017-10-09 11:36 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: bp, tglx, linux-kernel, mingo, hpa, rostedt, luto

Commit-ID:  924c6b900cfdf376b07bccfd80e62b21914f8a5a
Gitweb:     https://git.kernel.org/tip/924c6b900cfdf376b07bccfd80e62b21914f8a5a
Author:     Andy Lutomirski <luto@kernel.org>
AuthorDate: Sun, 8 Oct 2017 21:53:05 -0700
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Mon, 9 Oct 2017 13:31:04 +0200

x86/mm/64: Fix reboot interaction with CR4.PCIDE

Trying to reboot via real mode fails with PCID on: long mode cannot
be exited while CR4.PCIDE is set.  (No, I have no idea why, but the
SDM and actual CPUs are in agreement here.)  The result is a GPF and
a hang instead of a reboot.

I didn't catch this in testing because neither my computer nor my VM
reboots this way.  I can trigger it with reboot=bios, though.

Fixes: 660da7c9228f ("x86/mm: Enable CR4.PCIDE on supported systems")
Reported-and-tested-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Andy Lutomirski <luto@kernel.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Borislav Petkov <bp@alien8.de>
Link: https://lkml.kernel.org/r/f1e7d965998018450a7a70c2823873686a8b21c0.1507524746.git.luto@kernel.org

---
 arch/x86/kernel/reboot.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
index 54180fa..add33f6 100644
--- a/arch/x86/kernel/reboot.c
+++ b/arch/x86/kernel/reboot.c
@@ -105,6 +105,10 @@ void __noreturn machine_real_restart(unsigned int type)
 	load_cr3(initial_page_table);
 #else
 	write_cr3(real_mode_header->trampoline_pgd);
+
+	/* Exiting long mode will fail if CR4.PCIDE is set. */
+	if (static_cpu_has(X86_FEATURE_PCID))
+		cr4_clear_bits(X86_CR4_PCIDE);
 #endif
 
 	/* Jump to the identity-mapped low memory code */

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [tip:x86/urgent] x86/mm/64: Fix reboot interaction with CR4.PCIDE
  2017-10-09 11:36 ` [tip:x86/urgent] " tip-bot for Andy Lutomirski
@ 2017-10-09 12:42   ` Steven Rostedt
  0 siblings, 0 replies; 3+ messages in thread
From: Steven Rostedt @ 2017-10-09 12:42 UTC (permalink / raw)
  To: tip-bot for Andy Lutomirski
  Cc: luto, rostedt, hpa, linux-kernel, mingo, tglx, bp,
	linux-tip-commits

On Mon, 9 Oct 2017 04:36:01 -0700
tip-bot for Andy Lutomirski <tipbot@zytor.com> wrote:

> Commit-ID:  924c6b900cfdf376b07bccfd80e62b21914f8a5a
> Gitweb:     https://git.kernel.org/tip/924c6b900cfdf376b07bccfd80e62b21914f8a5a
> Author:     Andy Lutomirski <luto@kernel.org>
> AuthorDate: Sun, 8 Oct 2017 21:53:05 -0700
> Committer:  Thomas Gleixner <tglx@linutronix.de>
> CommitDate: Mon, 9 Oct 2017 13:31:04 +0200
> 
> x86/mm/64: Fix reboot interaction with CR4.PCIDE
> 
> Trying to reboot via real mode fails with PCID on: long mode cannot
> be exited while CR4.PCIDE is set.  (No, I have no idea why, but the
> SDM and actual CPUs are in agreement here.)  The result is a GPF and
> a hang instead of a reboot.
> 
> I didn't catch this in testing because neither my computer nor my VM
> reboots this way.  I can trigger it with reboot=bios, though.
> 
> Fixes: 660da7c9228f ("x86/mm: Enable CR4.PCIDE on supported systems")

> Reported-and-tested-by: Steven Rostedt (VMware) <rostedt@goodmis.org>

Didn't someone somewhere say not to combine tags? Have them always be
separate. I noticed they were separate when Andy submitted it, but I'm
assuming that Thomas combined it.

-- Steve


> Signed-off-by: Andy Lutomirski <luto@kernel.org>
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: Borislav Petkov <bp@alien8.de>
> Link: https://lkml.kernel.org/r/f1e7d965998018450a7a70c2823873686a8b21c0.1507524746.git.luto@kernel.org
> 
> ---
>  arch/x86/kernel/reboot.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
> index 54180fa..add33f6 100644
> --- a/arch/x86/kernel/reboot.c
> +++ b/arch/x86/kernel/reboot.c
> @@ -105,6 +105,10 @@ void __noreturn machine_real_restart(unsigned int type)
>  	load_cr3(initial_page_table);
>  #else
>  	write_cr3(real_mode_header->trampoline_pgd);
> +
> +	/* Exiting long mode will fail if CR4.PCIDE is set. */
> +	if (static_cpu_has(X86_FEATURE_PCID))
> +		cr4_clear_bits(X86_CR4_PCIDE);
>  #endif
>  
>  	/* Jump to the identity-mapped low memory code */

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-10-09 12:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-09  4:53 [PATCH] x86/mm/64: Fix reboot interaction with CR4.PCIDE Andy Lutomirski
2017-10-09 11:36 ` [tip:x86/urgent] " tip-bot for Andy Lutomirski
2017-10-09 12:42   ` Steven Rostedt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox