blob: 4e7b2f65fed6741148b8742ded9a98a81f6d1aa1 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Intel CPU Microcode Update Driver for Linux
3 *
Tigran Aivazian69688262006-12-13 00:35:14 -08004 * Copyright (C) 2000-2006 Tigran Aivazian <tigran@aivazian.fsnet.co.uk>
Shaohua Li9a3110b2006-09-27 01:50:51 -07005 * 2006 Shaohua Li <shaohua.li@intel.com>
Linus Torvalds1da177e2005-04-16 15:20:36 -07006 *
7 * This driver allows to upgrade microcode on Intel processors
Ben Castricumbc4e0f92008-06-10 13:15:12 +02008 * belonging to IA-32 family - PentiumPro, Pentium II,
Linus Torvalds1da177e2005-04-16 15:20:36 -07009 * Pentium III, Xeon, Pentium 4, etc.
10 *
Ben Castricumbc4e0f92008-06-10 13:15:12 +020011 * Reference: Section 8.11 of Volume 3a, IA-32 Intel? Architecture
12 * Software Developer's Manual
13 * Order Number 253668 or free download from:
14 *
15 * http://developer.intel.com/design/pentium4/manuals/253668.htm
Linus Torvalds1da177e2005-04-16 15:20:36 -070016 *
17 * For more information, go to http://www.urbanmyth.org/microcode
18 *
19 * This program is free software; you can redistribute it and/or
20 * modify it under the terms of the GNU General Public License
21 * as published by the Free Software Foundation; either version
22 * 2 of the License, or (at your option) any later version.
23 *
24 * 1.0 16 Feb 2000, Tigran Aivazian <tigran@sco.com>
25 * Initial release.
26 * 1.01 18 Feb 2000, Tigran Aivazian <tigran@sco.com>
27 * Added read() support + cleanups.
28 * 1.02 21 Feb 2000, Tigran Aivazian <tigran@sco.com>
29 * Added 'device trimming' support. open(O_WRONLY) zeroes
30 * and frees the saved copy of applied microcode.
31 * 1.03 29 Feb 2000, Tigran Aivazian <tigran@sco.com>
32 * Made to use devfs (/dev/cpu/microcode) + cleanups.
33 * 1.04 06 Jun 2000, Simon Trimmer <simon@veritas.com>
34 * Added misc device support (now uses both devfs and misc).
35 * Added MICROCODE_IOCFREE ioctl to clear memory.
36 * 1.05 09 Jun 2000, Simon Trimmer <simon@veritas.com>
37 * Messages for error cases (non Intel & no suitable microcode).
38 * 1.06 03 Aug 2000, Tigran Aivazian <tigran@veritas.com>
39 * Removed ->release(). Removed exclusive open and status bitmap.
40 * Added microcode_rwsem to serialize read()/write()/ioctl().
41 * Removed global kernel lock usage.
42 * 1.07 07 Sep 2000, Tigran Aivazian <tigran@veritas.com>
43 * Write 0 to 0x8B msr and then cpuid before reading revision,
44 * so that it works even if there were no update done by the
45 * BIOS. Otherwise, reading from 0x8B gives junk (which happened
46 * to be 0 on my machine which is why it worked even when I
47 * disabled update by the BIOS)
48 * Thanks to Eric W. Biederman <ebiederman@lnxi.com> for the fix.
49 * 1.08 11 Dec 2000, Richard Schaal <richard.schaal@intel.com> and
50 * Tigran Aivazian <tigran@veritas.com>
51 * Intel Pentium 4 processor support and bugfixes.
52 * 1.09 30 Oct 2001, Tigran Aivazian <tigran@veritas.com>
53 * Bugfix for HT (Hyper-Threading) enabled processors
54 * whereby processor resources are shared by all logical processors
55 * in a single CPU package.
56 * 1.10 28 Feb 2002 Asit K Mallick <asit.k.mallick@intel.com> and
57 * Tigran Aivazian <tigran@veritas.com>,
58 * Serialize updates as required on HT processors due to speculative
59 * nature of implementation.
60 * 1.11 22 Mar 2002 Tigran Aivazian <tigran@veritas.com>
61 * Fix the panic when writing zero-length microcode chunk.
Ben Castricumbc4e0f92008-06-10 13:15:12 +020062 * 1.12 29 Sep 2003 Nitin Kamble <nitin.a.kamble@intel.com>,
Linus Torvalds1da177e2005-04-16 15:20:36 -070063 * Jun Nakajima <jun.nakajima@intel.com>
64 * Support for the microcode updates in the new format.
65 * 1.13 10 Oct 2003 Tigran Aivazian <tigran@veritas.com>
66 * Removed ->read() method and obsoleted MICROCODE_IOCFREE ioctl
Ben Castricumbc4e0f92008-06-10 13:15:12 +020067 * because we no longer hold a copy of applied microcode
Linus Torvalds1da177e2005-04-16 15:20:36 -070068 * in kernel memory.
69 * 1.14 25 Jun 2004 Tigran Aivazian <tigran@veritas.com>
70 * Fix sigmatch() macro to handle old CPUs with pf == 0.
71 * Thanks to Stuart Swales for pointing out this bug.
72 */
73
74//#define DEBUG /* pr_debug */
Randy Dunlapa9415642006-01-11 12:17:48 -080075#include <linux/capability.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070076#include <linux/kernel.h>
77#include <linux/init.h>
78#include <linux/sched.h>
Arnd Bergmann77149362008-05-20 19:16:16 +020079#include <linux/smp_lock.h>
Dave Jones5cf6c542006-02-28 16:58:53 -080080#include <linux/cpumask.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070081#include <linux/module.h>
82#include <linux/slab.h>
83#include <linux/vmalloc.h>
84#include <linux/miscdevice.h>
85#include <linux/spinlock.h>
86#include <linux/mm.h>
Alexey Dobriyan4e950f62007-07-30 02:36:13 +040087#include <linux/fs.h>
Ingo Molnar14cc3e22006-03-26 01:37:14 -080088#include <linux/mutex.h>
Shaohua Lia30a6a22006-09-27 01:50:52 -070089#include <linux/cpu.h>
90#include <linux/firmware.h>
91#include <linux/platform_device.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070092
93#include <asm/msr.h>
94#include <asm/uaccess.h>
95#include <asm/processor.h>
Peter Oruba9a56a0f2008-07-28 18:44:13 +020096#include <asm/microcode.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070097
98MODULE_DESCRIPTION("Intel CPU (IA-32) Microcode Update Driver");
Tigran Aivazian69688262006-12-13 00:35:14 -080099MODULE_AUTHOR("Tigran Aivazian <tigran@aivazian.fsnet.co.uk>");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100MODULE_LICENSE("GPL");
101
Jan Beulichba528f22006-06-23 02:04:19 -0700102#define MICROCODE_VERSION "1.14a"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103
104#define DEFAULT_UCODE_DATASIZE (2000) /* 2000 bytes */
Peter Oruba8e610282008-07-28 18:44:14 +0200105#define MC_HEADER_SIZE (sizeof (struct microcode_header)) /* 48 bytes */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106#define DEFAULT_UCODE_TOTALSIZE (DEFAULT_UCODE_DATASIZE + MC_HEADER_SIZE) /* 2048 bytes */
107#define EXT_HEADER_SIZE (sizeof (struct extended_sigtable)) /* 20 bytes */
108#define EXT_SIGNATURE_SIZE (sizeof (struct extended_signature)) /* 12 bytes */
109#define DWSIZE (sizeof (u32))
110#define get_totalsize(mc) \
Peter Oruba8e610282008-07-28 18:44:14 +0200111 (((struct microcode *)mc)->hdr.totalsize ? \
112 ((struct microcode *)mc)->hdr.totalsize : DEFAULT_UCODE_TOTALSIZE)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113#define get_datasize(mc) \
Peter Oruba8e610282008-07-28 18:44:14 +0200114 (((struct microcode *)mc)->hdr.datasize ? \
115 ((struct microcode *)mc)->hdr.datasize : DEFAULT_UCODE_DATASIZE)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116
117#define sigmatch(s1, s2, p1, p2) \
118 (((s1) == (s2)) && (((p1) & (p2)) || (((p1) == 0) && ((p2) == 0))))
119
120#define exttable_size(et) ((et)->count * EXT_SIGNATURE_SIZE + EXT_HEADER_SIZE)
121
122/* serialize access to the physical write to MSR 0x79 */
123static DEFINE_SPINLOCK(microcode_update_lock);
124
125/* no concurrent ->write()s are allowed on /dev/cpu/microcode */
Ingo Molnar14cc3e22006-03-26 01:37:14 -0800126static DEFINE_MUTEX(microcode_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127
Peter Orubac3b71bc2008-07-28 18:44:15 +0200128static struct ucode_cpu_info ucode_cpu_info[NR_CPUS];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129
Shaohua Li9a3110b2006-09-27 01:50:51 -0700130static void collect_cpu_info(int cpu_num)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700131{
Mike Travis92cb7612007-10-19 20:35:04 +0200132 struct cpuinfo_x86 *c = &cpu_data(cpu_num);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700133 struct ucode_cpu_info *uci = ucode_cpu_info + cpu_num;
134 unsigned int val[2];
135
Shaohua Li9a3110b2006-09-27 01:50:51 -0700136 /* We should bind the task to the CPU */
137 BUG_ON(raw_smp_processor_id() != cpu_num);
138 uci->pf = uci->rev = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139 uci->mc = NULL;
Shaohua Li9a3110b2006-09-27 01:50:51 -0700140 uci->valid = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141
142 if (c->x86_vendor != X86_VENDOR_INTEL || c->x86 < 6 ||
143 cpu_has(c, X86_FEATURE_IA64)) {
Shaohua Li9a3110b2006-09-27 01:50:51 -0700144 printk(KERN_ERR "microcode: CPU%d not a capable Intel "
145 "processor\n", cpu_num);
146 uci->valid = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147 return;
Shaohua Li9a3110b2006-09-27 01:50:51 -0700148 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700149
Shaohua Li9a3110b2006-09-27 01:50:51 -0700150 uci->sig = cpuid_eax(0x00000001);
151
152 if ((c->x86_model >= 5) || (c->x86 > 6)) {
153 /* get processor flags from MSR 0x17 */
154 rdmsr(MSR_IA32_PLATFORM_ID, val[0], val[1]);
155 uci->pf = 1 << ((val[1] >> 18) & 7);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700156 }
157
158 wrmsr(MSR_IA32_UCODE_REV, 0, 0);
Zachary Amsden245067d2005-09-03 15:56:37 -0700159 /* see notes above for revision 1.07. Apparent chip bug */
Andi Kleen487472b2006-01-11 22:45:27 +0100160 sync_core();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700161 /* get the current revision from MSR 0x8B */
162 rdmsr(MSR_IA32_UCODE_REV, val[0], uci->rev);
163 pr_debug("microcode: collect_cpu_info : sig=0x%x, pf=0x%x, rev=0x%x\n",
164 uci->sig, uci->pf, uci->rev);
165}
166
Shaohua Li9a3110b2006-09-27 01:50:51 -0700167static inline int microcode_update_match(int cpu_num,
Peter Oruba8e610282008-07-28 18:44:14 +0200168 struct microcode_header *mc_header, int sig, int pf)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700169{
170 struct ucode_cpu_info *uci = ucode_cpu_info + cpu_num;
171
Shaohua Li9a3110b2006-09-27 01:50:51 -0700172 if (!sigmatch(sig, uci->sig, pf, uci->pf)
173 || mc_header->rev <= uci->rev)
174 return 0;
175 return 1;
176}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700177
Shaohua Li9a3110b2006-09-27 01:50:51 -0700178static int microcode_sanity_check(void *mc)
179{
Peter Oruba8e610282008-07-28 18:44:14 +0200180 struct microcode_header *mc_header = mc;
Shaohua Li9a3110b2006-09-27 01:50:51 -0700181 struct extended_sigtable *ext_header = NULL;
182 struct extended_signature *ext_sig;
183 unsigned long total_size, data_size, ext_table_size;
184 int sum, orig_sum, ext_sigcount = 0, i;
185
186 total_size = get_totalsize(mc_header);
187 data_size = get_datasize(mc_header);
Shaohua Libd8e39f2006-09-27 01:50:54 -0700188 if (data_size + MC_HEADER_SIZE > total_size) {
Shaohua Li9a3110b2006-09-27 01:50:51 -0700189 printk(KERN_ERR "microcode: error! "
190 "Bad data size in microcode data file\n");
191 return -EINVAL;
192 }
193
194 if (mc_header->ldrver != 1 || mc_header->hdrver != 1) {
195 printk(KERN_ERR "microcode: error! "
196 "Unknown microcode update format\n");
197 return -EINVAL;
198 }
199 ext_table_size = total_size - (MC_HEADER_SIZE + data_size);
200 if (ext_table_size) {
201 if ((ext_table_size < EXT_HEADER_SIZE)
202 || ((ext_table_size - EXT_HEADER_SIZE) % EXT_SIGNATURE_SIZE)) {
203 printk(KERN_ERR "microcode: error! "
204 "Small exttable size in microcode data file\n");
205 return -EINVAL;
Jan Beulichba528f22006-06-23 02:04:19 -0700206 }
Shaohua Li9a3110b2006-09-27 01:50:51 -0700207 ext_header = mc + MC_HEADER_SIZE + data_size;
208 if (ext_table_size != exttable_size(ext_header)) {
209 printk(KERN_ERR "microcode: error! "
210 "Bad exttable size in microcode data file\n");
211 return -EFAULT;
Jan Beulichba528f22006-06-23 02:04:19 -0700212 }
Shaohua Li9a3110b2006-09-27 01:50:51 -0700213 ext_sigcount = ext_header->count;
214 }
215
216 /* check extended table checksum */
217 if (ext_table_size) {
218 int ext_table_sum = 0;
Shaohua Li9a4b9ef2006-09-27 01:50:53 -0700219 int *ext_tablep = (int *)ext_header;
Shaohua Li9a3110b2006-09-27 01:50:51 -0700220
221 i = ext_table_size / DWSIZE;
222 while (i--)
223 ext_table_sum += ext_tablep[i];
224 if (ext_table_sum) {
225 printk(KERN_WARNING "microcode: aborting, "
226 "bad extended signature table checksum\n");
227 return -EINVAL;
Jan Beulichba528f22006-06-23 02:04:19 -0700228 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700229 }
Shaohua Li9a3110b2006-09-27 01:50:51 -0700230
231 /* calculate the checksum */
232 orig_sum = 0;
233 i = (MC_HEADER_SIZE + data_size) / DWSIZE;
234 while (i--)
235 orig_sum += ((int *)mc)[i];
236 if (orig_sum) {
237 printk(KERN_ERR "microcode: aborting, bad checksum\n");
238 return -EINVAL;
239 }
240 if (!ext_table_size)
241 return 0;
242 /* check extended signature checksum */
243 for (i = 0; i < ext_sigcount; i++) {
Jan Engelhardtade1af72008-01-30 13:33:23 +0100244 ext_sig = (void *)ext_header + EXT_HEADER_SIZE +
245 EXT_SIGNATURE_SIZE * i;
Shaohua Li9a3110b2006-09-27 01:50:51 -0700246 sum = orig_sum
247 - (mc_header->sig + mc_header->pf + mc_header->cksum)
248 + (ext_sig->sig + ext_sig->pf + ext_sig->cksum);
249 if (sum) {
250 printk(KERN_ERR "microcode: aborting, bad checksum\n");
251 return -EINVAL;
252 }
253 }
254 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700255}
256
Shaohua Li9a3110b2006-09-27 01:50:51 -0700257/*
258 * return 0 - no update found
259 * return 1 - found update
260 * return < 0 - error
261 */
262static int get_maching_microcode(void *mc, int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700263{
Shaohua Li9a3110b2006-09-27 01:50:51 -0700264 struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
Peter Oruba8e610282008-07-28 18:44:14 +0200265 struct microcode_header *mc_header = mc;
Shaohua Li9a3110b2006-09-27 01:50:51 -0700266 struct extended_sigtable *ext_header;
267 unsigned long total_size = get_totalsize(mc_header);
268 int ext_sigcount, i;
269 struct extended_signature *ext_sig;
270 void *new_mc;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700271
Shaohua Li9a3110b2006-09-27 01:50:51 -0700272 if (microcode_update_match(cpu, mc_header,
273 mc_header->sig, mc_header->pf))
274 goto find;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700275
Shaohua Li9a3110b2006-09-27 01:50:51 -0700276 if (total_size <= get_datasize(mc_header) + MC_HEADER_SIZE)
277 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700278
Jan Engelhardtade1af72008-01-30 13:33:23 +0100279 ext_header = mc + get_datasize(mc_header) + MC_HEADER_SIZE;
Shaohua Li9a3110b2006-09-27 01:50:51 -0700280 ext_sigcount = ext_header->count;
Jan Engelhardtade1af72008-01-30 13:33:23 +0100281 ext_sig = (void *)ext_header + EXT_HEADER_SIZE;
Shaohua Li9a3110b2006-09-27 01:50:51 -0700282 for (i = 0; i < ext_sigcount; i++) {
283 if (microcode_update_match(cpu, mc_header,
284 ext_sig->sig, ext_sig->pf))
285 goto find;
286 ext_sig++;
287 }
288 return 0;
289find:
Ben Castricumfe176de2008-03-27 20:52:35 +0100290 pr_debug("microcode: CPU%d found a matching microcode update with"
Shaohua Li9a3110b2006-09-27 01:50:51 -0700291 " version 0x%x (current=0x%x)\n", cpu, mc_header->rev,uci->rev);
292 new_mc = vmalloc(total_size);
293 if (!new_mc) {
294 printk(KERN_ERR "microcode: error! Can not allocate memory\n");
295 return -ENOMEM;
296 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700297
Shaohua Li9a3110b2006-09-27 01:50:51 -0700298 /* free previous update file */
299 vfree(uci->mc);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700300
Shaohua Li9a3110b2006-09-27 01:50:51 -0700301 memcpy(new_mc, mc, total_size);
302 uci->mc = new_mc;
303 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700304}
305
Shaohua Li9a3110b2006-09-27 01:50:51 -0700306static void apply_microcode(int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700307{
308 unsigned long flags;
309 unsigned int val[2];
Shaohua Li9a3110b2006-09-27 01:50:51 -0700310 int cpu_num = raw_smp_processor_id();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700311 struct ucode_cpu_info *uci = ucode_cpu_info + cpu_num;
312
Shaohua Li9a3110b2006-09-27 01:50:51 -0700313 /* We should bind the task to the CPU */
314 BUG_ON(cpu_num != cpu);
315
316 if (uci->mc == NULL)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700317 return;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700318
319 /* serialize access to the physical write to MSR 0x79 */
Ben Castricumbc4e0f92008-06-10 13:15:12 +0200320 spin_lock_irqsave(&microcode_update_lock, flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700321
322 /* write microcode via MSR 0x79 */
323 wrmsr(MSR_IA32_UCODE_WRITE,
Ben Castricumbc4e0f92008-06-10 13:15:12 +0200324 (unsigned long) uci->mc->bits,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700325 (unsigned long) uci->mc->bits >> 16 >> 16);
326 wrmsr(MSR_IA32_UCODE_REV, 0, 0);
327
Zachary Amsden245067d2005-09-03 15:56:37 -0700328 /* see notes above for revision 1.07. Apparent chip bug */
Andi Kleen487472b2006-01-11 22:45:27 +0100329 sync_core();
Zachary Amsden245067d2005-09-03 15:56:37 -0700330
Linus Torvalds1da177e2005-04-16 15:20:36 -0700331 /* get the current revision from MSR 0x8B */
332 rdmsr(MSR_IA32_UCODE_REV, val[0], val[1]);
333
Linus Torvalds1da177e2005-04-16 15:20:36 -0700334 spin_unlock_irqrestore(&microcode_update_lock, flags);
Shaohua Li9a3110b2006-09-27 01:50:51 -0700335 if (val[1] != uci->mc->hdr.rev) {
Ben Castricumfe176de2008-03-27 20:52:35 +0100336 printk(KERN_ERR "microcode: CPU%d update from revision "
Shaohua Li9a3110b2006-09-27 01:50:51 -0700337 "0x%x to 0x%x failed\n", cpu_num, uci->rev, val[1]);
338 return;
339 }
Ben Castricumfe176de2008-03-27 20:52:35 +0100340 printk(KERN_INFO "microcode: CPU%d updated from revision "
Ben Castricumbc4e0f92008-06-10 13:15:12 +0200341 "0x%x to 0x%x, date = %08x \n",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700342 cpu_num, uci->rev, val[1], uci->mc->hdr.date);
Shaohua Li9a3110b2006-09-27 01:50:51 -0700343 uci->rev = val[1];
344}
345
346#ifdef CONFIG_MICROCODE_OLD_INTERFACE
347static void __user *user_buffer; /* user area microcode data buffer */
348static unsigned int user_buffer_size; /* it's size */
349
350static long get_next_ucode(void **mc, long offset)
351{
Peter Oruba8e610282008-07-28 18:44:14 +0200352 struct microcode_header mc_header;
Shaohua Li9a3110b2006-09-27 01:50:51 -0700353 unsigned long total_size;
354
355 /* No more data */
356 if (offset >= user_buffer_size)
357 return 0;
358 if (copy_from_user(&mc_header, user_buffer + offset, MC_HEADER_SIZE)) {
359 printk(KERN_ERR "microcode: error! Can not read user data\n");
360 return -EFAULT;
361 }
362 total_size = get_totalsize(&mc_header);
Shaohua Libd8e39f2006-09-27 01:50:54 -0700363 if (offset + total_size > user_buffer_size) {
Shaohua Li9a3110b2006-09-27 01:50:51 -0700364 printk(KERN_ERR "microcode: error! Bad total size in microcode "
365 "data file\n");
366 return -EINVAL;
367 }
368 *mc = vmalloc(total_size);
369 if (!*mc)
370 return -ENOMEM;
371 if (copy_from_user(*mc, user_buffer + offset, total_size)) {
372 printk(KERN_ERR "microcode: error! Can not read user data\n");
373 vfree(*mc);
374 return -EFAULT;
375 }
376 return offset + total_size;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700377}
378
379static int do_microcode_update (void)
380{
Shaohua Li9a3110b2006-09-27 01:50:51 -0700381 long cursor = 0;
382 int error = 0;
Andi Kleen2ba1ff22007-02-13 13:26:25 +0100383 void *new_mc = NULL;
Shaohua Li9a3110b2006-09-27 01:50:51 -0700384 int cpu;
385 cpumask_t old;
Mike Travis65c01182008-07-15 14:14:30 -0700386 cpumask_of_cpu_ptr_declare(newmask);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700387
Shaohua Li9a3110b2006-09-27 01:50:51 -0700388 old = current->cpus_allowed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700389
Shaohua Li9a3110b2006-09-27 01:50:51 -0700390 while ((cursor = get_next_ucode(&new_mc, cursor)) > 0) {
391 error = microcode_sanity_check(new_mc);
392 if (error)
393 goto out;
394 /*
395 * It's possible the data file has multiple matching ucode,
396 * lets keep searching till the latest version
397 */
398 for_each_online_cpu(cpu) {
399 struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700400
Shaohua Li9a3110b2006-09-27 01:50:51 -0700401 if (!uci->valid)
402 continue;
Mike Travis65c01182008-07-15 14:14:30 -0700403 cpumask_of_cpu_ptr_next(newmask, cpu);
404 set_cpus_allowed_ptr(current, newmask);
Shaohua Li9a3110b2006-09-27 01:50:51 -0700405 error = get_maching_microcode(new_mc, cpu);
406 if (error < 0)
407 goto out;
408 if (error == 1)
409 apply_microcode(cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700410 }
Shaohua Li9a3110b2006-09-27 01:50:51 -0700411 vfree(new_mc);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700412 }
413out:
Shaohua Li9a3110b2006-09-27 01:50:51 -0700414 if (cursor > 0)
415 vfree(new_mc);
416 if (cursor < 0)
417 error = cursor;
Mike Travisfc0e4742008-04-04 18:11:05 -0700418 set_cpus_allowed_ptr(current, &old);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700419 return error;
420}
421
Shaohua Li9a3110b2006-09-27 01:50:51 -0700422static int microcode_open (struct inode *unused1, struct file *unused2)
423{
Arnd Bergmann77149362008-05-20 19:16:16 +0200424 cycle_kernel_lock();
Shaohua Li9a3110b2006-09-27 01:50:51 -0700425 return capable(CAP_SYS_RAWIO) ? 0 : -EPERM;
426}
427
Linus Torvalds1da177e2005-04-16 15:20:36 -0700428static ssize_t microcode_write (struct file *file, const char __user *buf, size_t len, loff_t *ppos)
429{
430 ssize_t ret;
431
Linus Torvalds1da177e2005-04-16 15:20:36 -0700432 if ((len >> PAGE_SHIFT) > num_physpages) {
433 printk(KERN_ERR "microcode: too much data (max %ld pages)\n", num_physpages);
434 return -EINVAL;
435 }
436
Gautham R Shenoy86ef5c92008-01-25 21:08:02 +0100437 get_online_cpus();
Ingo Molnar14cc3e22006-03-26 01:37:14 -0800438 mutex_lock(&microcode_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700439
440 user_buffer = (void __user *) buf;
441 user_buffer_size = (int) len;
442
443 ret = do_microcode_update();
444 if (!ret)
445 ret = (ssize_t)len;
446
Ingo Molnar14cc3e22006-03-26 01:37:14 -0800447 mutex_unlock(&microcode_mutex);
Gautham R Shenoy86ef5c92008-01-25 21:08:02 +0100448 put_online_cpus();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700449
450 return ret;
451}
452
Arjan van de Ven5dfe4c92007-02-12 00:55:31 -0800453static const struct file_operations microcode_fops = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700454 .owner = THIS_MODULE,
455 .write = microcode_write,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700456 .open = microcode_open,
457};
458
459static struct miscdevice microcode_dev = {
460 .minor = MICROCODE_MINOR,
461 .name = "microcode",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700462 .fops = &microcode_fops,
463};
464
Shaohua Li9a3110b2006-09-27 01:50:51 -0700465static int __init microcode_dev_init (void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700466{
467 int error;
468
469 error = misc_register(&microcode_dev);
470 if (error) {
471 printk(KERN_ERR
472 "microcode: can't misc_register on minor=%d\n",
473 MICROCODE_MINOR);
474 return error;
475 }
476
Shaohua Li9a3110b2006-09-27 01:50:51 -0700477 return 0;
478}
479
Sam Ravnborgf8281a22007-06-01 00:47:10 -0700480static void microcode_dev_exit (void)
Shaohua Li9a3110b2006-09-27 01:50:51 -0700481{
482 misc_deregister(&microcode_dev);
483}
484
485MODULE_ALIAS_MISCDEV(MICROCODE_MINOR);
486#else
487#define microcode_dev_init() 0
488#define microcode_dev_exit() do { } while(0)
489#endif
490
Greg Kroah-Hartmana13b04a2008-05-29 10:05:08 -0700491static long get_next_ucode_from_buffer(void **mc, const u8 *buf,
Shaohua Lia30a6a22006-09-27 01:50:52 -0700492 unsigned long size, long offset)
493{
Peter Oruba8e610282008-07-28 18:44:14 +0200494 struct microcode_header *mc_header;
Shaohua Lia30a6a22006-09-27 01:50:52 -0700495 unsigned long total_size;
496
497 /* No more data */
498 if (offset >= size)
499 return 0;
Peter Oruba8e610282008-07-28 18:44:14 +0200500 mc_header = (struct microcode_header *)(buf + offset);
Shaohua Lia30a6a22006-09-27 01:50:52 -0700501 total_size = get_totalsize(mc_header);
502
Shaohua Libd8e39f2006-09-27 01:50:54 -0700503 if (offset + total_size > size) {
Shaohua Lia30a6a22006-09-27 01:50:52 -0700504 printk(KERN_ERR "microcode: error! Bad data in microcode data file\n");
505 return -EINVAL;
506 }
507
508 *mc = vmalloc(total_size);
509 if (!*mc) {
510 printk(KERN_ERR "microcode: error! Can not allocate memory\n");
511 return -ENOMEM;
512 }
513 memcpy(*mc, buf + offset, total_size);
514 return offset + total_size;
515}
516
517/* fake device for request_firmware */
518static struct platform_device *microcode_pdev;
519
520static int cpu_request_microcode(int cpu)
521{
522 char name[30];
Mike Travis92cb7612007-10-19 20:35:04 +0200523 struct cpuinfo_x86 *c = &cpu_data(cpu);
Shaohua Lia30a6a22006-09-27 01:50:52 -0700524 const struct firmware *firmware;
Greg Kroah-Hartmana13b04a2008-05-29 10:05:08 -0700525 const u8 *buf;
Shaohua Lia30a6a22006-09-27 01:50:52 -0700526 unsigned long size;
527 long offset = 0;
528 int error;
529 void *mc;
530
531 /* We should bind the task to the CPU */
532 BUG_ON(cpu != raw_smp_processor_id());
533 sprintf(name,"intel-ucode/%02x-%02x-%02x",
534 c->x86, c->x86_model, c->x86_mask);
535 error = request_firmware(&firmware, name, &microcode_pdev->dev);
536 if (error) {
Ben Castricumbc4e0f92008-06-10 13:15:12 +0200537 pr_debug("microcode: data file %s load failed\n", name);
Shaohua Lia30a6a22006-09-27 01:50:52 -0700538 return error;
539 }
Jan Engelhardtade1af72008-01-30 13:33:23 +0100540 buf = firmware->data;
Shaohua Lia30a6a22006-09-27 01:50:52 -0700541 size = firmware->size;
542 while ((offset = get_next_ucode_from_buffer(&mc, buf, size, offset))
543 > 0) {
544 error = microcode_sanity_check(mc);
545 if (error)
546 break;
547 error = get_maching_microcode(mc, cpu);
548 if (error < 0)
549 break;
550 /*
551 * It's possible the data file has multiple matching ucode,
552 * lets keep searching till the latest version
553 */
554 if (error == 1) {
555 apply_microcode(cpu);
556 error = 0;
557 }
558 vfree(mc);
559 }
560 if (offset > 0)
561 vfree(mc);
562 if (offset < 0)
563 error = offset;
564 release_firmware(firmware);
565
566 return error;
567}
568
Rafael J. Wysocki455c0172007-05-09 02:35:11 -0700569static int apply_microcode_check_cpu(int cpu)
Rafael J. Wysocki1d64b9c2007-04-01 23:49:49 -0700570{
Mike Travis92cb7612007-10-19 20:35:04 +0200571 struct cpuinfo_x86 *c = &cpu_data(cpu);
Rafael J. Wysocki1d64b9c2007-04-01 23:49:49 -0700572 struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
573 cpumask_t old;
Mike Travis65c01182008-07-15 14:14:30 -0700574 cpumask_of_cpu_ptr(newmask, cpu);
Rafael J. Wysocki1d64b9c2007-04-01 23:49:49 -0700575 unsigned int val[2];
576 int err = 0;
577
Rafael J. Wysocki455c0172007-05-09 02:35:11 -0700578 /* Check if the microcode is available */
Rafael J. Wysocki1d64b9c2007-04-01 23:49:49 -0700579 if (!uci->mc)
Rafael J. Wysocki455c0172007-05-09 02:35:11 -0700580 return 0;
Rafael J. Wysocki1d64b9c2007-04-01 23:49:49 -0700581
582 old = current->cpus_allowed;
Mike Travis65c01182008-07-15 14:14:30 -0700583 set_cpus_allowed_ptr(current, newmask);
Rafael J. Wysocki1d64b9c2007-04-01 23:49:49 -0700584
585 /* Check if the microcode we have in memory matches the CPU */
586 if (c->x86_vendor != X86_VENDOR_INTEL || c->x86 < 6 ||
587 cpu_has(c, X86_FEATURE_IA64) || uci->sig != cpuid_eax(0x00000001))
588 err = -EINVAL;
589
590 if (!err && ((c->x86_model >= 5) || (c->x86 > 6))) {
591 /* get processor flags from MSR 0x17 */
592 rdmsr(MSR_IA32_PLATFORM_ID, val[0], val[1]);
593 if (uci->pf != (1 << ((val[1] >> 18) & 7)))
594 err = -EINVAL;
595 }
596
597 if (!err) {
598 wrmsr(MSR_IA32_UCODE_REV, 0, 0);
599 /* see notes above for revision 1.07. Apparent chip bug */
600 sync_core();
601 /* get the current revision from MSR 0x8B */
602 rdmsr(MSR_IA32_UCODE_REV, val[0], val[1]);
603 if (uci->rev != val[1])
604 err = -EINVAL;
605 }
606
607 if (!err)
608 apply_microcode(cpu);
609 else
610 printk(KERN_ERR "microcode: Could not apply microcode to CPU%d:"
611 " sig=0x%x, pf=0x%x, rev=0x%x\n",
612 cpu, uci->sig, uci->pf, uci->rev);
613
Mike Travisfc0e4742008-04-04 18:11:05 -0700614 set_cpus_allowed_ptr(current, &old);
Rafael J. Wysocki1d64b9c2007-04-01 23:49:49 -0700615 return err;
616}
617
Rafael J. Wysocki455c0172007-05-09 02:35:11 -0700618static void microcode_init_cpu(int cpu, int resume)
Shaohua Lia30a6a22006-09-27 01:50:52 -0700619{
620 cpumask_t old;
Mike Travis65c01182008-07-15 14:14:30 -0700621 cpumask_of_cpu_ptr(newmask, cpu);
Shaohua Lia30a6a22006-09-27 01:50:52 -0700622 struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
623
624 old = current->cpus_allowed;
625
Mike Travis65c01182008-07-15 14:14:30 -0700626 set_cpus_allowed_ptr(current, newmask);
Shaohua Lia30a6a22006-09-27 01:50:52 -0700627 mutex_lock(&microcode_mutex);
628 collect_cpu_info(cpu);
Rafael J. Wysocki455c0172007-05-09 02:35:11 -0700629 if (uci->valid && system_state == SYSTEM_RUNNING && !resume)
Shaohua Lia30a6a22006-09-27 01:50:52 -0700630 cpu_request_microcode(cpu);
631 mutex_unlock(&microcode_mutex);
Mike Travisfc0e4742008-04-04 18:11:05 -0700632 set_cpus_allowed_ptr(current, &old);
Shaohua Lia30a6a22006-09-27 01:50:52 -0700633}
634
635static void microcode_fini_cpu(int cpu)
636{
637 struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
638
639 mutex_lock(&microcode_mutex);
640 uci->valid = 0;
641 vfree(uci->mc);
642 uci->mc = NULL;
643 mutex_unlock(&microcode_mutex);
644}
645
Andi Kleen4a0b2b42008-07-01 18:48:41 +0200646static ssize_t reload_store(struct sys_device *dev,
647 struct sysdev_attribute *attr,
648 const char *buf, size_t sz)
Shaohua Li9a4b9ef2006-09-27 01:50:53 -0700649{
650 struct ucode_cpu_info *uci = ucode_cpu_info + dev->id;
651 char *end;
652 unsigned long val = simple_strtoul(buf, &end, 0);
653 int err = 0;
654 int cpu = dev->id;
655
656 if (end == buf)
657 return -EINVAL;
658 if (val == 1) {
659 cpumask_t old;
Mike Travis65c01182008-07-15 14:14:30 -0700660 cpumask_of_cpu_ptr(newmask, cpu);
Shaohua Li9a4b9ef2006-09-27 01:50:53 -0700661
662 old = current->cpus_allowed;
663
Gautham R Shenoy86ef5c92008-01-25 21:08:02 +0100664 get_online_cpus();
Mike Travis65c01182008-07-15 14:14:30 -0700665 set_cpus_allowed_ptr(current, newmask);
Shaohua Li9a4b9ef2006-09-27 01:50:53 -0700666
667 mutex_lock(&microcode_mutex);
668 if (uci->valid)
669 err = cpu_request_microcode(cpu);
670 mutex_unlock(&microcode_mutex);
Gautham R Shenoy86ef5c92008-01-25 21:08:02 +0100671 put_online_cpus();
Mike Travisfc0e4742008-04-04 18:11:05 -0700672 set_cpus_allowed_ptr(current, &old);
Shaohua Li9a4b9ef2006-09-27 01:50:53 -0700673 }
674 if (err)
675 return err;
676 return sz;
677}
678
Andi Kleen4a0b2b42008-07-01 18:48:41 +0200679static ssize_t version_show(struct sys_device *dev,
680 struct sysdev_attribute *attr, char *buf)
Shaohua Li9a4b9ef2006-09-27 01:50:53 -0700681{
682 struct ucode_cpu_info *uci = ucode_cpu_info + dev->id;
683
684 return sprintf(buf, "0x%x\n", uci->rev);
685}
686
Andi Kleen4a0b2b42008-07-01 18:48:41 +0200687static ssize_t pf_show(struct sys_device *dev,
688 struct sysdev_attribute *attr, char *buf)
Shaohua Li9a4b9ef2006-09-27 01:50:53 -0700689{
690 struct ucode_cpu_info *uci = ucode_cpu_info + dev->id;
691
692 return sprintf(buf, "0x%x\n", uci->pf);
693}
694
695static SYSDEV_ATTR(reload, 0200, NULL, reload_store);
696static SYSDEV_ATTR(version, 0400, version_show, NULL);
697static SYSDEV_ATTR(processor_flags, 0400, pf_show, NULL);
698
699static struct attribute *mc_default_attrs[] = {
700 &attr_reload.attr,
701 &attr_version.attr,
702 &attr_processor_flags.attr,
703 NULL
704};
705
706static struct attribute_group mc_attr_group = {
707 .attrs = mc_default_attrs,
708 .name = "microcode",
709};
710
Rafael J. Wysocki455c0172007-05-09 02:35:11 -0700711static int __mc_sysdev_add(struct sys_device *sys_dev, int resume)
Shaohua Li9a4b9ef2006-09-27 01:50:53 -0700712{
Jeff Garzik2e3ad8a2006-10-11 01:21:53 -0700713 int err, cpu = sys_dev->id;
Shaohua Li9a4b9ef2006-09-27 01:50:53 -0700714 struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
715
716 if (!cpu_online(cpu))
717 return 0;
Jeff Garzik2e3ad8a2006-10-11 01:21:53 -0700718
Ben Castricumfe176de2008-03-27 20:52:35 +0100719 pr_debug("microcode: CPU%d added\n", cpu);
Rafael J. Wysocki455c0172007-05-09 02:35:11 -0700720 memset(uci, 0, sizeof(*uci));
Jeff Garzik2e3ad8a2006-10-11 01:21:53 -0700721
722 err = sysfs_create_group(&sys_dev->kobj, &mc_attr_group);
723 if (err)
724 return err;
Shaohua Li9a4b9ef2006-09-27 01:50:53 -0700725
Rafael J. Wysocki455c0172007-05-09 02:35:11 -0700726 microcode_init_cpu(cpu, resume);
Rafael J. Wysocki1d64b9c2007-04-01 23:49:49 -0700727
Shaohua Li9a4b9ef2006-09-27 01:50:53 -0700728 return 0;
729}
730
Rafael J. Wysocki455c0172007-05-09 02:35:11 -0700731static int mc_sysdev_add(struct sys_device *sys_dev)
732{
733 return __mc_sysdev_add(sys_dev, 0);
734}
735
Shaohua Li9a4b9ef2006-09-27 01:50:53 -0700736static int mc_sysdev_remove(struct sys_device *sys_dev)
737{
738 int cpu = sys_dev->id;
739
740 if (!cpu_online(cpu))
741 return 0;
Rafael J. Wysocki455c0172007-05-09 02:35:11 -0700742
Ben Castricumfe176de2008-03-27 20:52:35 +0100743 pr_debug("microcode: CPU%d removed\n", cpu);
Rafael J. Wysocki455c0172007-05-09 02:35:11 -0700744 microcode_fini_cpu(cpu);
Shaohua Li9a4b9ef2006-09-27 01:50:53 -0700745 sysfs_remove_group(&sys_dev->kobj, &mc_attr_group);
746 return 0;
747}
748
749static int mc_sysdev_resume(struct sys_device *dev)
750{
751 int cpu = dev->id;
752
753 if (!cpu_online(cpu))
754 return 0;
Ben Castricumfe176de2008-03-27 20:52:35 +0100755 pr_debug("microcode: CPU%d resumed\n", cpu);
Shaohua Li9a4b9ef2006-09-27 01:50:53 -0700756 /* only CPU 0 will apply ucode here */
757 apply_microcode(0);
758 return 0;
759}
760
761static struct sysdev_driver mc_sysdev_driver = {
762 .add = mc_sysdev_add,
763 .remove = mc_sysdev_remove,
764 .resume = mc_sysdev_resume,
765};
766
Shaohua Li9a4b9ef2006-09-27 01:50:53 -0700767static __cpuinit int
768mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
769{
770 unsigned int cpu = (unsigned long)hcpu;
771 struct sys_device *sys_dev;
772
773 sys_dev = get_cpu_sysdev(cpu);
774 switch (action) {
Rafael J. Wysocki455c0172007-05-09 02:35:11 -0700775 case CPU_UP_CANCELED_FROZEN:
776 /* The CPU refused to come up during a system resume */
777 microcode_fini_cpu(cpu);
778 break;
Shaohua Li9a4b9ef2006-09-27 01:50:53 -0700779 case CPU_ONLINE:
780 case CPU_DOWN_FAILED:
781 mc_sysdev_add(sys_dev);
782 break;
Rafael J. Wysocki455c0172007-05-09 02:35:11 -0700783 case CPU_ONLINE_FROZEN:
784 /* System-wide resume is in progress, try to apply microcode */
785 if (apply_microcode_check_cpu(cpu)) {
786 /* The application of microcode failed */
787 microcode_fini_cpu(cpu);
788 __mc_sysdev_add(sys_dev, 1);
789 break;
790 }
791 case CPU_DOWN_FAILED_FROZEN:
792 if (sysfs_create_group(&sys_dev->kobj, &mc_attr_group))
Ben Castricumfe176de2008-03-27 20:52:35 +0100793 printk(KERN_ERR "microcode: Failed to create the sysfs "
Rafael J. Wysocki455c0172007-05-09 02:35:11 -0700794 "group for CPU%d\n", cpu);
795 break;
Shaohua Li9a4b9ef2006-09-27 01:50:53 -0700796 case CPU_DOWN_PREPARE:
797 mc_sysdev_remove(sys_dev);
798 break;
Rafael J. Wysocki455c0172007-05-09 02:35:11 -0700799 case CPU_DOWN_PREPARE_FROZEN:
800 /* Suspend is in progress, only remove the interface */
801 sysfs_remove_group(&sys_dev->kobj, &mc_attr_group);
802 break;
Shaohua Li9a4b9ef2006-09-27 01:50:53 -0700803 }
804 return NOTIFY_OK;
805}
806
Sam Ravnborgc72258c2008-02-01 17:49:42 +0100807static struct notifier_block __refdata mc_cpu_notifier = {
Shaohua Li9a4b9ef2006-09-27 01:50:53 -0700808 .notifier_call = mc_cpu_callback,
809};
Shaohua Li9a4b9ef2006-09-27 01:50:53 -0700810
Shaohua Li9a3110b2006-09-27 01:50:51 -0700811static int __init microcode_init (void)
812{
813 int error;
814
Ben Castricumbc4e0f92008-06-10 13:15:12 +0200815 printk(KERN_INFO
816 "IA-32 Microcode Update Driver: v" MICROCODE_VERSION " <tigran@aivazian.fsnet.co.uk>\n");
817
Shaohua Li9a3110b2006-09-27 01:50:51 -0700818 error = microcode_dev_init();
819 if (error)
820 return error;
Shaohua Lia30a6a22006-09-27 01:50:52 -0700821 microcode_pdev = platform_device_register_simple("microcode", -1,
822 NULL, 0);
823 if (IS_ERR(microcode_pdev)) {
824 microcode_dev_exit();
825 return PTR_ERR(microcode_pdev);
826 }
Shaohua Li9a3110b2006-09-27 01:50:51 -0700827
Gautham R Shenoy86ef5c92008-01-25 21:08:02 +0100828 get_online_cpus();
Shaohua Li9a4b9ef2006-09-27 01:50:53 -0700829 error = sysdev_driver_register(&cpu_sysdev_class, &mc_sysdev_driver);
Gautham R Shenoy86ef5c92008-01-25 21:08:02 +0100830 put_online_cpus();
Shaohua Li9a4b9ef2006-09-27 01:50:53 -0700831 if (error) {
832 microcode_dev_exit();
833 platform_device_unregister(microcode_pdev);
834 return error;
835 }
836
837 register_hotcpu_notifier(&mc_cpu_notifier);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700838 return 0;
839}
840
841static void __exit microcode_exit (void)
842{
Shaohua Li9a3110b2006-09-27 01:50:51 -0700843 microcode_dev_exit();
Shaohua Li9a4b9ef2006-09-27 01:50:53 -0700844
845 unregister_hotcpu_notifier(&mc_cpu_notifier);
846
Gautham R Shenoy86ef5c92008-01-25 21:08:02 +0100847 get_online_cpus();
Shaohua Li9a4b9ef2006-09-27 01:50:53 -0700848 sysdev_driver_unregister(&cpu_sysdev_class, &mc_sysdev_driver);
Gautham R Shenoy86ef5c92008-01-25 21:08:02 +0100849 put_online_cpus();
Shaohua Li9a4b9ef2006-09-27 01:50:53 -0700850
Shaohua Lia30a6a22006-09-27 01:50:52 -0700851 platform_device_unregister(microcode_pdev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700852}
853
854module_init(microcode_init)
855module_exit(microcode_exit)