From: mikpe@csd.uu.se
To: Dave Jones <davej@codemonkey.org.uk>
Cc: torvalds@transmeta.com, linux-kernel@vger.kernel.org
Subject: [PATCH] restore sysenter MSRs at resume
Date: Wed, 7 May 2003 11:33:29 +0200 [thread overview]
Message-ID: <16056.53993.774345.897852@gargle.gargle.HOWL> (raw)
In-Reply-To: <20030506223534.GA3339@suse.de>
Dave Jones writes:
> On Tue, May 06, 2003 at 09:52:24PM +0200, mikpe@csd.uu.se wrote:
> > suspending the box (apm). At resume, I am immediately greeted with an
> > oops looking like:
> >
> > general protection fault: 0000 [#?]
> > CPU: 0
> > EIP: 0060:[<c0109079>] Not tainted
> > EFLAGS: 00010246
> > EIP is at systenter_past_esp+0x6e/0x71
>
> I wonder if your BIOS is trashing the sysenter MSRs on suspend.
> Maybe they need restoring ?
I've confirmed that that's exatly what's happening. EIP points to
the sysexit instruction in entry.S, and the sysenter MSRs are all zero.
The patch below hooks sysenter into the driver model and implements
a resume() method which restores the sysenter MSRs. On my '98 vintage
Latitude, this is necessary since those MSRs are cleared at resume.
Failure to restore them leads to oopses and eventual kernel hang.
(Of course, your user-space must also use sysenter. RH9 does.)
The patch has a debug printk() for problematic systems that require
the fix. If it says your machine didn't preserve the MSRs, please
post a note about this to LKML with your machine model, so we can
estimate the scope of the problem.
/Mikael
diff -ruN linux-2.5.69/arch/i386/kernel/sysenter.c linux-2.5.69.sysenter-pm/arch/i386/kernel/sysenter.c
--- linux-2.5.69/arch/i386/kernel/sysenter.c 2003-05-05 22:56:28.000000000 +0200
+++ linux-2.5.69.sysenter-pm/arch/i386/kernel/sysenter.c 2003-05-07 10:50:39.690468848 +0200
@@ -51,6 +51,53 @@
put_cpu();
}
+#ifdef CONFIG_PM
+#include <linux/device.h>
+
+static int sysenter_resume(struct device *dev, u32 state, u32 level)
+{
+ if (level != RESUME_POWER_ON)
+ return 0;
+ /* for collecting statistics, will go away */
+ {
+ unsigned int h, l0, l1, l2;
+ rdmsr(MSR_IA32_SYSENTER_CS, l0, h);
+ rdmsr(MSR_IA32_SYSENTER_ESP, l1, h);
+ rdmsr(MSR_IA32_SYSENTER_EIP, l2, h);
+ if (!l0 || !l1 || !l2)
+ printk("sysenter_resume: your BIOS didn't preserve the SYSENTER MSRs\n");
+ else
+ printk("sysenter_resume: congratulations, your BIOS seems Ok\n");
+ }
+ enable_sep_cpu(NULL);
+ return 0;
+}
+
+static struct device_driver sysenter_driver = {
+ .name = "sysenter",
+ .bus = &system_bus_type,
+ .resume = sysenter_resume,
+};
+
+static struct sys_device device_sysenter = {
+ .name = "sysenter",
+ .id = 0,
+ .dev = {
+ .name = "sysenter",
+ .driver = &sysenter_driver,
+ },
+};
+
+static int __init init_sysenter_devicefs(void)
+{
+ driver_register(&sysenter_driver);
+ return sys_device_register(&device_sysenter);
+}
+
+#else /* CONFIG_PM */
+static inline int init_sysenter_devicefs(void) { return 0; }
+#endif /* CONFIG_PM */
+
/*
* These symbols are defined by vsyscall.o to mark the bounds
* of the ELF DSO images included therein.
@@ -76,7 +123,7 @@
&vsyscall_sysenter_end - &vsyscall_sysenter_start);
on_each_cpu(enable_sep_cpu, NULL, 1, 1);
- return 0;
+ return init_sysenter_devicefs();
}
__initcall(sysenter_setup);
next prev parent reply other threads:[~2003-05-07 9:21 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-05-06 19:52 [BUG] 2.5.69 oops at sysenter_past_esp mikpe
2003-05-06 22:35 ` Dave Jones
2003-05-07 9:33 ` mikpe [this message]
2003-05-07 14:41 ` [PATCH] restore sysenter MSRs at resume Linus Torvalds
2003-05-07 17:23 ` mikpe
2003-05-07 17:39 ` Linus Torvalds
2003-05-08 21:47 ` Pavel Machek
2003-05-10 16:41 mikpe
2003-05-11 19:01 ` Linus Torvalds
2003-05-11 19:08 ` Pavel Machek
2003-05-11 19:28 ` Nigel Cunningham
2003-05-12 11:30 ` Pavel Machek
2003-05-12 19:33 ` Nigel Cunningham
2003-05-12 19:54 ` Pavel Machek
2003-05-11 21:04 ` Alan Cox
2003-05-12 0:07 ` Linus Torvalds
2003-05-12 11:13 ` Alan Cox
2003-05-12 20:15 ` Pavel Machek
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=16056.53993.774345.897852@gargle.gargle.HOWL \
--to=mikpe@csd.uu.se \
--cc=davej@codemonkey.org.uk \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@transmeta.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
all inboxes | Powered by JetHome®