From: Andreas Herrmann <andreas.herrmann3@amd.com>
To: Ingo Molnar <mingo@elte.hu>, Thomas Gleixner <tglx@linutronix.de>
Cc: linux-kernel@vger.kernel.org,
Dmitry Adamushko <dmitry.adamushko@gmail.com>
Subject: [PATCH 6/10] x86: microcode_amd: replace inline asm by common rdmsr/wrmsr functions
Date: Tue, 16 Dec 2008 19:16:34 +0100 [thread overview]
Message-ID: <20081216181634.GM7013@alberich.amd.com> (raw)
In-Reply-To: <20081216180639.GG7013@alberich.amd.com>
Signed-off-by: Andreas Herrmann <andreas.herrmann3@amd.com>
---
arch/x86/include/asm/msr-index.h | 2 ++
arch/x86/kernel/microcode_amd.c | 23 +++++------------------
2 files changed, 7 insertions(+), 18 deletions(-)
diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-index.h
index e38859d..cb58643 100644
--- a/arch/x86/include/asm/msr-index.h
+++ b/arch/x86/include/asm/msr-index.h
@@ -85,7 +85,9 @@
/* AMD64 MSRs. Not complete. See the architecture manual for a more
complete list. */
+#define MSR_AMD64_PATCH_LEVEL 0x0000008b
#define MSR_AMD64_NB_CFG 0xc001001f
+#define MSR_AMD64_PATCH_LOADER 0xc0010020
#define MSR_AMD64_IBSFETCHCTL 0xc0011030
#define MSR_AMD64_IBSFETCHLINAD 0xc0011031
#define MSR_AMD64_IBSFETCHPHYSAD 0xc0011032
diff --git a/arch/x86/kernel/microcode_amd.c b/arch/x86/kernel/microcode_amd.c
index c7f225c..2856955 100644
--- a/arch/x86/kernel/microcode_amd.c
+++ b/arch/x86/kernel/microcode_amd.c
@@ -93,6 +93,7 @@ static struct equiv_cpu_entry *equiv_cpu_table;
static int collect_cpu_info_amd(int cpu, struct cpu_signature *csig)
{
struct cpuinfo_x86 *c = &cpu_data(cpu);
+ u32 dummy;
memset(csig, 0, sizeof(*csig));
@@ -102,9 +103,7 @@ static int collect_cpu_info_amd(int cpu, struct cpu_signature *csig)
return -1;
}
- asm volatile("movl %1, %%ecx; rdmsr"
- : "=a" (csig->rev)
- : "i" (0x0000008B) : "ecx");
+ rdmsr(MSR_AMD64_PATCH_LEVEL, csig->rev, dummy);
printk(KERN_INFO "microcode: collect_cpu_info_amd : patch_id=0x%x\n",
csig->rev);
@@ -181,12 +180,10 @@ static int get_matching_microcode(int cpu, void *mc, int rev)
static void apply_microcode_amd(int cpu)
{
unsigned long flags;
- unsigned int eax, edx;
- unsigned int rev;
+ u32 rev, dummy;
int cpu_num = raw_smp_processor_id();
struct ucode_cpu_info *uci = ucode_cpu_info + cpu_num;
struct microcode_amd *mc_amd = uci->mc;
- unsigned long addr;
/* We should bind the task to the CPU */
BUG_ON(cpu_num != cpu);
@@ -195,19 +192,9 @@ static void apply_microcode_amd(int cpu)
return;
spin_lock_irqsave(µcode_update_lock, flags);
-
- addr = (unsigned long)&mc_amd->hdr.data_code;
- edx = (unsigned int)(((unsigned long)upper_32_bits(addr)));
- eax = (unsigned int)(((unsigned long)lower_32_bits(addr)));
-
- asm volatile("movl %0, %%ecx; wrmsr" :
- : "i" (0xc0010020), "a" (eax), "d" (edx) : "ecx");
-
+ wrmsrl(MSR_AMD64_PATCH_LOADER, &mc_amd->hdr.data_code);
/* get patch id after patching */
- asm volatile("movl %1, %%ecx; rdmsr"
- : "=a" (rev)
- : "i" (0x0000008B) : "ecx");
-
+ rdmsr(MSR_AMD64_PATCH_LEVEL, rev, dummy);
spin_unlock_irqrestore(µcode_update_lock, flags);
/* check current patch id and patch's id for match */
--
1.6.0.4
next prev parent reply other threads:[~2008-12-16 18:17 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-16 18:06 [PATCH 0/10] x86: microcode_amd: fixes and cleanup Andreas Herrmann
2008-12-16 18:07 ` [PATCH 1/10] x86: microcode_amd: fix wrong handling of equivalent CPU id Andreas Herrmann
2008-12-16 18:08 ` [PATCH 2/10] x86: microcode_amd: fix typos and trailing whitespaces in log messages Andreas Herrmann
2008-12-16 18:11 ` [PATCH 3/10] x86: microcode_amd: fix checkpatch warnings/errors Andreas Herrmann
2008-12-16 18:13 ` [PATCH 4/10] x86: microcode_amd: fix compile warning Andreas Herrmann
2008-12-16 18:14 ` [PATCH 5/10] x86: microcode_amd: don't pass superfluous function pointer for get_ucode_data Andreas Herrmann
2008-12-16 18:16 ` Andreas Herrmann [this message]
2008-12-16 18:17 ` [PATCH 7/10] x86: microcode_amd: consolidate macro definitions Andreas Herrmann
2008-12-16 18:20 ` [PATCH 8/10] x86: microcode_amd: remove (wrong) chipset deivce ID checks Andreas Herrmann
2008-12-16 18:21 ` [PATCH 9/10] x86: microcode_amd: use 'packed' attribute for structs Andreas Herrmann
2008-12-16 18:22 ` [PATCH 10/10] x86: microcode_amd: modify log messages Andreas Herrmann
2008-12-16 23:22 ` [PATCH 0/10] x86: microcode_amd: fixes and cleanup Dmitry Adamushko
2008-12-16 23:24 ` Dmitry Adamushko
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=20081216181634.GM7013@alberich.amd.com \
--to=andreas.herrmann3@amd.com \
--cc=dmitry.adamushko@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--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 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®