All of lore.kernel.org
 help / color / mirror / Atom feed
From: "tip-bot for H. Peter Anvin" <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, hpa@zytor.com, mingo@kernel.org,
	onny@project-insanity.org, tglx@linutronix.de,
	hpa@linux.intel.com, rjw@sisk.pl,
	christian.suenkenberg@student.kit.edu
Subject: [tip:x86/urgent] x86, suspend: Handle CPUs which fail to #GP on RDMSR
Date: Fri, 12 Jul 2013 20:21:48 -0700	[thread overview]
Message-ID: <tip-3a783f6e39cc6c89da8846312f29ca47affaa470@git.kernel.org> (raw)
In-Reply-To: <51DDC972.3010005@student.kit.edu>

Commit-ID:  3a783f6e39cc6c89da8846312f29ca47affaa470
Gitweb:     http://git.kernel.org/tip/3a783f6e39cc6c89da8846312f29ca47affaa470
Author:     H. Peter Anvin <hpa@linux.intel.com>
AuthorDate: Fri, 12 Jul 2013 16:48:12 -0700
Committer:  H. Peter Anvin <hpa@linux.intel.com>
CommitDate: Fri, 12 Jul 2013 16:48:12 -0700

x86, suspend: Handle CPUs which fail to #GP on RDMSR

There are CPUs which have errata causing RDMSR of a nonexistent MSR to
not fault.  We would then try to WRMSR to restore the value of that
MSR, causing a crash.  Specifically, some Pentium M variants would
have this problem trying to save and restore the non-existent EFER,
causing a crash on resume.

Work around this by making sure we can write back the result at
suspend time.

Huge thanks to Christian Sünkenberg for finding the offending erratum
that finally deciphered the mystery.

Reported-and-tested-by: Johan Heinrich <onny@project-insanity.org>
Debugged-by: Christian Sünkenberg <christian.suenkenberg@student.kit.edu>
Acked-by: Rafael J. Wysocki <rjw@sisk.pl>
Link: http://lkml.kernel.org/r/51DDC972.3010005@student.kit.edu
Cc: <stable@vger.kernel.org> # v3.7+
---
 arch/x86/kernel/acpi/sleep.c | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c
index 2a34aaf..3312010 100644
--- a/arch/x86/kernel/acpi/sleep.c
+++ b/arch/x86/kernel/acpi/sleep.c
@@ -48,9 +48,20 @@ int x86_acpi_suspend_lowlevel(void)
 #ifndef CONFIG_64BIT
 	native_store_gdt((struct desc_ptr *)&header->pmode_gdt);
 
+	/*
+	 * We have to check that we can write back the value, and not
+	 * just read it.  At least on 90 nm Pentium M (Family 6, Model
+	 * 13), reading an invalid MSR is not guaranteed to trap, see
+	 * Erratum X4 in "Intel Pentium M Processor on 90 nm Process
+	 * with 2-MB L2 Cache and Intel® Processor A100 and A110 on 90
+	 * nm process with 512-KB L2 Cache Specification Update".
+	 */
 	if (!rdmsr_safe(MSR_EFER,
 			&header->pmode_efer_low,
-			&header->pmode_efer_high))
+			&header->pmode_efer_high) &&
+	    !wrmsr_safe(MSR_EFER,
+			header->pmode_efer_low,
+			header->pmode_efer_high))
 		header->pmode_behavior |= (1 << WAKEUP_BEHAVIOR_RESTORE_EFER);
 #endif /* !CONFIG_64BIT */
 
@@ -61,7 +72,10 @@ int x86_acpi_suspend_lowlevel(void)
 	}
 	if (!rdmsr_safe(MSR_IA32_MISC_ENABLE,
 			&header->pmode_misc_en_low,
-			&header->pmode_misc_en_high))
+			&header->pmode_misc_en_high) &&
+	    !wrmsr_safe(MSR_IA32_MISC_ENABLE,
+			header->pmode_misc_en_low,
+			header->pmode_misc_en_high))
 		header->pmode_behavior |=
 			(1 << WAKEUP_BEHAVIOR_RESTORE_MISC_ENABLE);
 	header->realmode_flags = acpi_realmode_flags;

  parent reply	other threads:[~2013-07-13  3:22 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-18 15:54 [Bisected] 3.7-rc1 can't resume Jonas Heinrich
2013-02-18 16:21 ` H. Peter Anvin
2013-02-23 13:18   ` Jonas Heinrich
2013-02-23 21:54     ` H. Peter Anvin
     [not found]       ` <20130320143257.GA473@onny>
2013-05-01 17:01         ` [Bisected] 3.7-rc1 can't resume (still present in 3.9) Jonas Heinrich
2013-05-01 17:33           ` H. Peter Anvin
2013-05-01 18:51             ` Jonas Heinrich
2013-05-01 18:55               ` H. Peter Anvin
2013-05-02  0:45                 ` Rafael J. Wysocki
2013-05-02 20:32                   ` Jonas Heinrich
2013-05-02 23:29                     ` Rafael J. Wysocki
2013-05-03 11:07                       ` Jonas Heinrich
2013-05-03 11:37                         ` Rafael J. Wysocki
2013-05-28 21:36                           ` Rafael J. Wysocki
2013-05-03 12:15                         ` Jarkko Sakkinen
2013-07-08  9:50                           ` Jonas Heinrich
2013-07-08 13:05                             ` Rafael J. Wysocki
2013-07-15 21:11                               ` H. Peter Anvin
2013-07-10 20:52             ` Christian Sünkenberg
2013-07-10 23:57               ` H. Peter Anvin
2013-07-12 23:36                 ` Christian Sünkenberg
2013-07-12 23:45                   ` H. Peter Anvin
2013-07-13  3:21               ` tip-bot for H. Peter Anvin [this message]
2013-07-15 20:58               ` [tip:x86/urgent] x86, suspend: Handle CPUs which fail to #GP on RDMSR tip-bot for H. Peter Anvin

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=tip-3a783f6e39cc6c89da8846312f29ca47affaa470@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=christian.suenkenberg@student.kit.edu \
    --cc=hpa@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=onny@project-insanity.org \
    --cc=rjw@sisk.pl \
    --cc=tglx@linutronix.de \
    /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.