From: "George Spelvin" <linux@horizon.com>
To: hpa@linux.intel.com
Cc: linux@horizon.com, linux-kernel@vger.kernel.org
Subject: Re: [GIT PULL] x86 fixes for 3.11-rc2
Date: 20 Jul 2013 08:25:04 -0400 [thread overview]
Message-ID: <20130720122504.25856.qmail@science.horizon.com> (raw)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2591 bytes --]
It's marginal with only two call sites, but would it be worth factoring
out the write-back function? Something like this (untested) patch.
It definitely makes the generated assembly cleaner.
(Signed-off-by: George Spelvin <linux@horizon.com> if you want it.)
diff --git a/arch/x86/include/asm/msr.h b/arch/x86/include/asm/msr.h
index cb75028..8802d97 100644
--- a/arch/x86/include/asm/msr.h
+++ b/arch/x86/include/asm/msr.h
@@ -171,6 +171,30 @@ static inline int wrmsr_safe(unsigned msr, unsigned low, unsigned high)
__err; \
})
+/*
+ * 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".
+ */
+#define rdmsr_verysafe(msr, low, high) \
+({ \
+ int __err; \
+ asm volatile("2: rdmsr\n" \
+ "3: wrmsr ; xor %[err],%[err]\n" \
+ "1:\n\t" \
+ ".section .fixup,\"ax\"\n\t" \
+ "4: mov %[fault],%[err] ; jmp 1b\n\t" \
+ ".previous\n\t" \
+ _ASM_EXTABLE(2b, 4b) \
+ _ASM_EXTABLE(3b, 4b) \
+ : [err] "=r" (__err), "=a" (*low), "=d" (*high) \
+ : "c" (msr), [fault] "i" (-EIO)); \
+ __err; \
+})
+
static inline int rdmsrl_safe(unsigned msr, unsigned long long *p)
{
int err;
diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c
index b44577b..7c3f40c 100644
--- a/arch/x86/kernel/acpi/sleep.c
+++ b/arch/x86/kernel/acpi/sleep.c
@@ -48,9 +48,9 @@ int acpi_suspend_lowlevel(void)
#ifndef CONFIG_64BIT
native_store_gdt((struct desc_ptr *)&header->pmode_gdt);
- if (!rdmsr_safe(MSR_EFER,
- &header->pmode_efer_low,
- &header->pmode_efer_high))
+ if (!rdmsr_verysafe(MSR_EFER,
+ &header->pmode_efer_low,
+ &header->pmode_efer_high))
header->pmode_behavior |= (1 << WAKEUP_BEHAVIOR_RESTORE_EFER);
#endif /* !CONFIG_64BIT */
@@ -59,9 +59,9 @@ int acpi_suspend_lowlevel(void)
header->pmode_cr4 = read_cr4();
header->pmode_behavior |= (1 << WAKEUP_BEHAVIOR_RESTORE_CR4);
}
- if (!rdmsr_safe(MSR_IA32_MISC_ENABLE,
- &header->pmode_misc_en_low,
- &header->pmode_misc_en_high))
+ if (!rdmsr_verysafe(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;
next reply other threads:[~2013-07-20 12:25 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-20 12:25 George Spelvin [this message]
2013-07-20 13:25 ` [GIT PULL] x86 fixes for 3.11-rc2 Borislav Petkov
2013-07-20 14:47 ` George Spelvin
2013-07-20 16:55 ` Borislav Petkov
2013-07-21 20:17 ` H. Peter Anvin
-- strict thread matches above, loose matches on Subject: below --
2013-07-18 22:41 H. Peter Anvin
2013-07-19 0:46 ` Linus Torvalds
2013-07-19 0:49 ` Myklebust, Trond
2013-07-19 0:50 ` H. Peter Anvin
2013-07-19 4:25 ` 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=20130720122504.25856.qmail@science.horizon.com \
--to=linux@horizon.com \
--cc=hpa@linux.intel.com \
--cc=linux-kernel@vger.kernel.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 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.