blob: 2856955ddab191214f82ac61feb0dd4ed8a6a9ea [file] [log] [blame]
Peter Oruba80cc9f12008-07-28 18:44:22 +02001/*
2 * AMD CPU Microcode Update Driver for Linux
3 * Copyright (C) 2008 Advanced Micro Devices Inc.
4 *
5 * Author: Peter Oruba <peter.oruba@amd.com>
6 *
7 * Based on work by:
8 * Tigran Aivazian <tigran@aivazian.fsnet.co.uk>
9 *
10 * This driver allows to upgrade microcode on AMD
11 * family 0x10 and 0x11 processors.
12 *
Andreas Herrmann2a3282a72008-12-16 19:08:53 +010013 * Licensed under the terms of the GNU General Public
Peter Oruba80cc9f12008-07-28 18:44:22 +020014 * License version 2. See file COPYING for details.
15*/
16
17#include <linux/capability.h>
18#include <linux/kernel.h>
19#include <linux/init.h>
20#include <linux/sched.h>
21#include <linux/cpumask.h>
22#include <linux/module.h>
23#include <linux/slab.h>
24#include <linux/vmalloc.h>
25#include <linux/miscdevice.h>
26#include <linux/spinlock.h>
27#include <linux/mm.h>
28#include <linux/fs.h>
29#include <linux/mutex.h>
30#include <linux/cpu.h>
31#include <linux/firmware.h>
32#include <linux/platform_device.h>
33#include <linux/pci.h>
34#include <linux/pci_ids.h>
Andreas Herrmannbe957762008-12-16 19:11:23 +010035#include <linux/uaccess.h>
Peter Oruba80cc9f12008-07-28 18:44:22 +020036
37#include <asm/msr.h>
Peter Oruba80cc9f12008-07-28 18:44:22 +020038#include <asm/processor.h>
39#include <asm/microcode.h>
40
41MODULE_DESCRIPTION("AMD Microcode Update Driver");
Peter Oruba3c522042008-10-17 15:30:38 +020042MODULE_AUTHOR("Peter Oruba");
Ingo Molnar5d7b6052008-07-29 10:07:36 +020043MODULE_LICENSE("GPL v2");
Peter Oruba80cc9f12008-07-28 18:44:22 +020044
45#define UCODE_MAGIC 0x00414d44
46#define UCODE_EQUIV_CPU_TABLE_TYPE 0x00000000
47#define UCODE_UCODE_TYPE 0x00000001
48
Dmitry Adamushko18dbc912008-09-23 12:08:44 +020049struct equiv_cpu_entry {
50 unsigned int installed_cpu;
51 unsigned int fixed_errata_mask;
52 unsigned int fixed_errata_compare;
53 unsigned int equiv_cpu;
54};
55
56struct microcode_header_amd {
57 unsigned int data_code;
58 unsigned int patch_id;
59 unsigned char mc_patch_data_id[2];
60 unsigned char mc_patch_data_len;
61 unsigned char init_flag;
62 unsigned int mc_patch_data_checksum;
63 unsigned int nb_dev_id;
64 unsigned int sb_dev_id;
Andreas Herrmann3c763fd2008-12-16 19:07:47 +010065 u16 processor_rev_id;
Dmitry Adamushko18dbc912008-09-23 12:08:44 +020066 unsigned char nb_rev_id;
67 unsigned char sb_rev_id;
68 unsigned char bios_api_rev;
69 unsigned char reserved1[3];
70 unsigned int match_reg[8];
71};
72
73struct microcode_amd {
74 struct microcode_header_amd hdr;
75 unsigned int mpb[0];
76};
77
Peter Oruba80cc9f12008-07-28 18:44:22 +020078#define UCODE_MAX_SIZE (2048)
Peter Orubaa0ac87d2008-07-29 17:41:04 +020079#define DEFAULT_UCODE_DATASIZE (896)
80#define MC_HEADER_SIZE (sizeof(struct microcode_header_amd))
81#define DEFAULT_UCODE_TOTALSIZE (DEFAULT_UCODE_DATASIZE + MC_HEADER_SIZE)
Peter Oruba80cc9f12008-07-28 18:44:22 +020082#define DWSIZE (sizeof(u32))
83/* For now we support a fixed ucode total size only */
84#define get_totalsize(mc) \
85 ((((struct microcode_amd *)mc)->hdr.mc_patch_data_len * 28) \
86 + MC_HEADER_SIZE)
87
Peter Oruba80cc9f12008-07-28 18:44:22 +020088/* serialize access to the physical write */
89static DEFINE_SPINLOCK(microcode_update_lock);
90
Dmitry Adamushkoa0a29b62008-09-11 23:27:52 +020091static struct equiv_cpu_entry *equiv_cpu_table;
Peter Oruba80cc9f12008-07-28 18:44:22 +020092
Dmitry Adamushkod45de402008-08-20 00:22:26 +020093static int collect_cpu_info_amd(int cpu, struct cpu_signature *csig)
Peter Oruba80cc9f12008-07-28 18:44:22 +020094{
95 struct cpuinfo_x86 *c = &cpu_data(cpu);
Andreas Herrmann29d08872008-12-16 19:16:34 +010096 u32 dummy;
Peter Oruba80cc9f12008-07-28 18:44:22 +020097
Dmitry Adamushkod45de402008-08-20 00:22:26 +020098 memset(csig, 0, sizeof(*csig));
Peter Oruba80cc9f12008-07-28 18:44:22 +020099
100 if (c->x86_vendor != X86_VENDOR_AMD || c->x86 < 0x10) {
101 printk(KERN_ERR "microcode: CPU%d not a capable AMD processor\n",
102 cpu);
Dmitry Adamushkod45de402008-08-20 00:22:26 +0200103 return -1;
Peter Oruba80cc9f12008-07-28 18:44:22 +0200104 }
105
Andreas Herrmann29d08872008-12-16 19:16:34 +0100106 rdmsr(MSR_AMD64_PATCH_LEVEL, csig->rev, dummy);
Peter Oruba80cc9f12008-07-28 18:44:22 +0200107
108 printk(KERN_INFO "microcode: collect_cpu_info_amd : patch_id=0x%x\n",
Dmitry Adamushkod45de402008-08-20 00:22:26 +0200109 csig->rev);
110
111 return 0;
Peter Oruba80cc9f12008-07-28 18:44:22 +0200112}
113
Dmitry Adamushkoa0a29b62008-09-11 23:27:52 +0200114static int get_matching_microcode(int cpu, void *mc, int rev)
Peter Oruba80cc9f12008-07-28 18:44:22 +0200115{
Peter Oruba80cc9f12008-07-28 18:44:22 +0200116 struct microcode_header_amd *mc_header = mc;
Peter Oruba80cc9f12008-07-28 18:44:22 +0200117 struct pci_dev *nb_pci_dev, *sb_pci_dev;
118 unsigned int current_cpu_id;
119 unsigned int equiv_cpu_id = 0x00;
120 unsigned int i = 0;
121
Dmitry Adamushkoa0a29b62008-09-11 23:27:52 +0200122 BUG_ON(equiv_cpu_table == NULL);
Peter Oruba80cc9f12008-07-28 18:44:22 +0200123 current_cpu_id = cpuid_eax(0x00000001);
124
125 while (equiv_cpu_table[i].installed_cpu != 0) {
126 if (current_cpu_id == equiv_cpu_table[i].installed_cpu) {
Andreas Herrmann3c763fd2008-12-16 19:07:47 +0100127 equiv_cpu_id = equiv_cpu_table[i].equiv_cpu & 0xffff;
Peter Oruba80cc9f12008-07-28 18:44:22 +0200128 break;
129 }
130 i++;
131 }
132
133 if (!equiv_cpu_id) {
134 printk(KERN_ERR "microcode: CPU%d cpu_id "
Andreas Herrmann2a3282a72008-12-16 19:08:53 +0100135 "not found in equivalent cpu table\n", cpu);
Peter Oruba80cc9f12008-07-28 18:44:22 +0200136 return 0;
137 }
138
Andreas Herrmann3c763fd2008-12-16 19:07:47 +0100139 if (mc_header->processor_rev_id != equiv_cpu_id) {
140 printk(KERN_ERR "microcode: CPU%d patch does not match "
141 "(processor_rev_id: %x, eqiv_cpu_id: %x)\n",
142 cpu, mc_header->processor_rev_id, equiv_cpu_id);
Peter Oruba80cc9f12008-07-28 18:44:22 +0200143 return 0;
144 }
145
146 /* ucode may be northbridge specific */
147 if (mc_header->nb_dev_id) {
148 nb_pci_dev = pci_get_device(PCI_VENDOR_ID_AMD,
149 (mc_header->nb_dev_id & 0xff),
150 NULL);
151 if ((!nb_pci_dev) ||
152 (mc_header->nb_rev_id != nb_pci_dev->revision)) {
Andreas Herrmann2a3282a72008-12-16 19:08:53 +0100153 printk(KERN_ERR "microcode: CPU%d NB mismatch\n", cpu);
Peter Oruba80cc9f12008-07-28 18:44:22 +0200154 pci_dev_put(nb_pci_dev);
155 return 0;
156 }
157 pci_dev_put(nb_pci_dev);
158 }
159
160 /* ucode may be southbridge specific */
161 if (mc_header->sb_dev_id) {
162 sb_pci_dev = pci_get_device(PCI_VENDOR_ID_AMD,
163 (mc_header->sb_dev_id & 0xff),
164 NULL);
165 if ((!sb_pci_dev) ||
166 (mc_header->sb_rev_id != sb_pci_dev->revision)) {
Andreas Herrmann2a3282a72008-12-16 19:08:53 +0100167 printk(KERN_ERR "microcode: CPU%d SB mismatch\n", cpu);
Peter Oruba80cc9f12008-07-28 18:44:22 +0200168 pci_dev_put(sb_pci_dev);
169 return 0;
170 }
171 pci_dev_put(sb_pci_dev);
172 }
173
Dmitry Adamushkoa0a29b62008-09-11 23:27:52 +0200174 if (mc_header->patch_id <= rev)
Peter Oruba80cc9f12008-07-28 18:44:22 +0200175 return 0;
176
Peter Oruba80cc9f12008-07-28 18:44:22 +0200177 return 1;
178}
179
180static void apply_microcode_amd(int cpu)
181{
182 unsigned long flags;
Andreas Herrmann29d08872008-12-16 19:16:34 +0100183 u32 rev, dummy;
Peter Oruba80cc9f12008-07-28 18:44:22 +0200184 int cpu_num = raw_smp_processor_id();
185 struct ucode_cpu_info *uci = ucode_cpu_info + cpu_num;
Dmitry Adamushko18dbc912008-09-23 12:08:44 +0200186 struct microcode_amd *mc_amd = uci->mc;
Peter Oruba80cc9f12008-07-28 18:44:22 +0200187
188 /* We should bind the task to the CPU */
189 BUG_ON(cpu_num != cpu);
190
Dmitry Adamushko18dbc912008-09-23 12:08:44 +0200191 if (mc_amd == NULL)
Peter Oruba80cc9f12008-07-28 18:44:22 +0200192 return;
193
194 spin_lock_irqsave(&microcode_update_lock, flags);
Andreas Herrmann29d08872008-12-16 19:16:34 +0100195 wrmsrl(MSR_AMD64_PATCH_LOADER, &mc_amd->hdr.data_code);
Peter Oruba80cc9f12008-07-28 18:44:22 +0200196 /* get patch id after patching */
Andreas Herrmann29d08872008-12-16 19:16:34 +0100197 rdmsr(MSR_AMD64_PATCH_LEVEL, rev, dummy);
Peter Oruba80cc9f12008-07-28 18:44:22 +0200198 spin_unlock_irqrestore(&microcode_update_lock, flags);
199
200 /* check current patch id and patch's id for match */
Dmitry Adamushko18dbc912008-09-23 12:08:44 +0200201 if (rev != mc_amd->hdr.patch_id) {
Peter Oruba80cc9f12008-07-28 18:44:22 +0200202 printk(KERN_ERR "microcode: CPU%d update from revision "
203 "0x%x to 0x%x failed\n", cpu_num,
Dmitry Adamushko18dbc912008-09-23 12:08:44 +0200204 mc_amd->hdr.patch_id, rev);
Peter Oruba80cc9f12008-07-28 18:44:22 +0200205 return;
206 }
207
208 printk(KERN_INFO "microcode: CPU%d updated from revision "
Andreas Herrmann2a3282a72008-12-16 19:08:53 +0100209 "0x%x to 0x%x\n",
Dmitry Adamushko18dbc912008-09-23 12:08:44 +0200210 cpu_num, uci->cpu_sig.rev, mc_amd->hdr.patch_id);
Peter Oruba80cc9f12008-07-28 18:44:22 +0200211
Dmitry Adamushkod45de402008-08-20 00:22:26 +0200212 uci->cpu_sig.rev = rev;
Peter Oruba80cc9f12008-07-28 18:44:22 +0200213}
214
Andreas Herrmann0657d9e2008-12-16 19:14:05 +0100215static int get_ucode_data(void *to, const u8 *from, size_t n)
216{
217 memcpy(to, from, n);
218 return 0;
219}
220
Andreas Herrmann8c135202008-12-16 19:13:00 +0100221static void *get_next_ucode(const u8 *buf, unsigned int size,
Andreas Herrmann0657d9e2008-12-16 19:14:05 +0100222 unsigned int *mc_size)
Peter Oruba80cc9f12008-07-28 18:44:22 +0200223{
Dmitry Adamushkoa0a29b62008-09-11 23:27:52 +0200224 unsigned int total_size;
Peter Orubad4738792008-09-17 15:39:18 +0200225#define UCODE_CONTAINER_SECTION_HDR 8
226 u8 section_hdr[UCODE_CONTAINER_SECTION_HDR];
Dmitry Adamushkoa0a29b62008-09-11 23:27:52 +0200227 void *mc;
Peter Oruba80cc9f12008-07-28 18:44:22 +0200228
Peter Orubad4738792008-09-17 15:39:18 +0200229 if (get_ucode_data(section_hdr, buf, UCODE_CONTAINER_SECTION_HDR))
Dmitry Adamushkoa0a29b62008-09-11 23:27:52 +0200230 return NULL;
Peter Oruba80cc9f12008-07-28 18:44:22 +0200231
Peter Orubad4738792008-09-17 15:39:18 +0200232 if (section_hdr[0] != UCODE_UCODE_TYPE) {
Peter Oruba80cc9f12008-07-28 18:44:22 +0200233 printk(KERN_ERR "microcode: error! "
234 "Wrong microcode payload type field\n");
Dmitry Adamushkoa0a29b62008-09-11 23:27:52 +0200235 return NULL;
Peter Oruba80cc9f12008-07-28 18:44:22 +0200236 }
237
Peter Orubad4738792008-09-17 15:39:18 +0200238 total_size = (unsigned long) (section_hdr[4] + (section_hdr[5] << 8));
Peter Oruba80cc9f12008-07-28 18:44:22 +0200239
Dmitry Adamushkoa0a29b62008-09-11 23:27:52 +0200240 printk(KERN_INFO "microcode: size %u, total_size %u\n",
241 size, total_size);
Peter Oruba80cc9f12008-07-28 18:44:22 +0200242
Dmitry Adamushkoa0a29b62008-09-11 23:27:52 +0200243 if (total_size > size || total_size > UCODE_MAX_SIZE) {
Peter Oruba80cc9f12008-07-28 18:44:22 +0200244 printk(KERN_ERR "microcode: error! Bad data in microcode data file\n");
Dmitry Adamushkoa0a29b62008-09-11 23:27:52 +0200245 return NULL;
Peter Oruba80cc9f12008-07-28 18:44:22 +0200246 }
247
Dmitry Adamushkoa0a29b62008-09-11 23:27:52 +0200248 mc = vmalloc(UCODE_MAX_SIZE);
249 if (mc) {
250 memset(mc, 0, UCODE_MAX_SIZE);
Andreas Herrmannbe957762008-12-16 19:11:23 +0100251 if (get_ucode_data(mc, buf + UCODE_CONTAINER_SECTION_HDR,
252 total_size)) {
Dmitry Adamushkoa0a29b62008-09-11 23:27:52 +0200253 vfree(mc);
254 mc = NULL;
255 } else
Peter Orubad4738792008-09-17 15:39:18 +0200256 *mc_size = total_size + UCODE_CONTAINER_SECTION_HDR;
Peter Oruba80cc9f12008-07-28 18:44:22 +0200257 }
Peter Orubad4738792008-09-17 15:39:18 +0200258#undef UCODE_CONTAINER_SECTION_HDR
Dmitry Adamushkoa0a29b62008-09-11 23:27:52 +0200259 return mc;
Peter Oruba80cc9f12008-07-28 18:44:22 +0200260}
261
Dmitry Adamushkoa0a29b62008-09-11 23:27:52 +0200262
Andreas Herrmann0657d9e2008-12-16 19:14:05 +0100263static int install_equiv_cpu_table(const u8 *buf)
Peter Oruba80cc9f12008-07-28 18:44:22 +0200264{
Peter Orubab6cffde2008-09-17 15:05:52 +0200265#define UCODE_CONTAINER_HEADER_SIZE 12
266 u8 *container_hdr[UCODE_CONTAINER_HEADER_SIZE];
267 unsigned int *buf_pos = (unsigned int *)container_hdr;
Dmitry Adamushkoa0a29b62008-09-11 23:27:52 +0200268 unsigned long size;
Peter Oruba80cc9f12008-07-28 18:44:22 +0200269
Peter Orubab6cffde2008-09-17 15:05:52 +0200270 if (get_ucode_data(&container_hdr, buf, UCODE_CONTAINER_HEADER_SIZE))
Peter Oruba80cc9f12008-07-28 18:44:22 +0200271 return 0;
272
Dmitry Adamushkoa0a29b62008-09-11 23:27:52 +0200273 size = buf_pos[2];
Peter Oruba80cc9f12008-07-28 18:44:22 +0200274
Dmitry Adamushkoa0a29b62008-09-11 23:27:52 +0200275 if (buf_pos[1] != UCODE_EQUIV_CPU_TABLE_TYPE || !size) {
Peter Oruba80cc9f12008-07-28 18:44:22 +0200276 printk(KERN_ERR "microcode: error! "
Andreas Herrmann2a3282a72008-12-16 19:08:53 +0100277 "Wrong microcode equivalent cpu table\n");
Peter Oruba80cc9f12008-07-28 18:44:22 +0200278 return 0;
279 }
280
281 equiv_cpu_table = (struct equiv_cpu_entry *) vmalloc(size);
282 if (!equiv_cpu_table) {
283 printk(KERN_ERR "microcode: error, can't allocate memory for equiv CPU table\n");
284 return 0;
285 }
286
Peter Orubab6cffde2008-09-17 15:05:52 +0200287 buf += UCODE_CONTAINER_HEADER_SIZE;
Dmitry Adamushkoa0a29b62008-09-11 23:27:52 +0200288 if (get_ucode_data(equiv_cpu_table, buf, size)) {
289 vfree(equiv_cpu_table);
290 return 0;
291 }
Peter Oruba80cc9f12008-07-28 18:44:22 +0200292
Peter Orubab6cffde2008-09-17 15:05:52 +0200293 return size + UCODE_CONTAINER_HEADER_SIZE; /* add header length */
294#undef UCODE_CONTAINER_HEADER_SIZE
Peter Oruba80cc9f12008-07-28 18:44:22 +0200295}
296
Dmitry Adamushkoa0a29b62008-09-11 23:27:52 +0200297static void free_equiv_cpu_table(void)
Peter Oruba80cc9f12008-07-28 18:44:22 +0200298{
Dmitry Adamushkoa0a29b62008-09-11 23:27:52 +0200299 if (equiv_cpu_table) {
300 vfree(equiv_cpu_table);
301 equiv_cpu_table = NULL;
Peter Oruba80cc9f12008-07-28 18:44:22 +0200302 }
Dmitry Adamushkoa0a29b62008-09-11 23:27:52 +0200303}
Peter Oruba80cc9f12008-07-28 18:44:22 +0200304
Andreas Herrmann0657d9e2008-12-16 19:14:05 +0100305static int generic_load_microcode(int cpu, const u8 *data, size_t size)
Dmitry Adamushkoa0a29b62008-09-11 23:27:52 +0200306{
307 struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
Andreas Herrmann8c135202008-12-16 19:13:00 +0100308 const u8 *ucode_ptr = data;
309 void *new_mc = NULL;
310 void *mc;
Dmitry Adamushkoa0a29b62008-09-11 23:27:52 +0200311 int new_rev = uci->cpu_sig.rev;
312 unsigned int leftover;
313 unsigned long offset;
Peter Oruba80cc9f12008-07-28 18:44:22 +0200314
Andreas Herrmann0657d9e2008-12-16 19:14:05 +0100315 offset = install_equiv_cpu_table(ucode_ptr);
Peter Oruba80cc9f12008-07-28 18:44:22 +0200316 if (!offset) {
317 printk(KERN_ERR "microcode: installing equivalent cpu table failed\n");
318 return -EINVAL;
319 }
320
Dmitry Adamushkoa0a29b62008-09-11 23:27:52 +0200321 ucode_ptr += offset;
322 leftover = size - offset;
323
324 while (leftover) {
Dmitry Adamushko2f9284e2008-09-23 22:56:35 +0200325 unsigned int uninitialized_var(mc_size);
Dmitry Adamushkoa0a29b62008-09-11 23:27:52 +0200326 struct microcode_header_amd *mc_header;
327
Andreas Herrmann0657d9e2008-12-16 19:14:05 +0100328 mc = get_next_ucode(ucode_ptr, leftover, &mc_size);
Dmitry Adamushkoa0a29b62008-09-11 23:27:52 +0200329 if (!mc)
Peter Oruba80cc9f12008-07-28 18:44:22 +0200330 break;
Dmitry Adamushkoa0a29b62008-09-11 23:27:52 +0200331
332 mc_header = (struct microcode_header_amd *)mc;
333 if (get_matching_microcode(cpu, mc, new_rev)) {
Ingo Molnara1c75cc2008-09-14 14:50:26 +0200334 if (new_mc)
335 vfree(new_mc);
Dmitry Adamushkoa0a29b62008-09-11 23:27:52 +0200336 new_rev = mc_header->patch_id;
337 new_mc = mc;
Andreas Herrmannbe957762008-12-16 19:11:23 +0100338 } else
Dmitry Adamushkoa0a29b62008-09-11 23:27:52 +0200339 vfree(mc);
340
341 ucode_ptr += mc_size;
342 leftover -= mc_size;
Peter Oruba80cc9f12008-07-28 18:44:22 +0200343 }
Dmitry Adamushkoa0a29b62008-09-11 23:27:52 +0200344
345 if (new_mc) {
346 if (!leftover) {
Dmitry Adamushko18dbc912008-09-23 12:08:44 +0200347 if (uci->mc)
348 vfree(uci->mc);
349 uci->mc = new_mc;
Andreas Herrmannbe957762008-12-16 19:11:23 +0100350 pr_debug("microcode: CPU%d found a matching microcode "
351 "update with version 0x%x (current=0x%x)\n",
352 cpu, new_rev, uci->cpu_sig.rev);
Dmitry Adamushkoa0a29b62008-09-11 23:27:52 +0200353 } else
354 vfree(new_mc);
Peter Oruba80cc9f12008-07-28 18:44:22 +0200355 }
Dmitry Adamushkoa0a29b62008-09-11 23:27:52 +0200356
357 free_equiv_cpu_table();
358
359 return (int)leftover;
360}
361
Dmitry Adamushkoa0a29b62008-09-11 23:27:52 +0200362static int request_microcode_fw(int cpu, struct device *device)
363{
364 const char *fw_name = "amd-ucode/microcode_amd.bin";
365 const struct firmware *firmware;
366 int ret;
367
368 /* We should bind the task to the CPU */
369 BUG_ON(cpu != raw_smp_processor_id());
370
371 ret = request_firmware(&firmware, fw_name, device);
372 if (ret) {
Andreas Herrmannbe957762008-12-16 19:11:23 +0100373 printk(KERN_ERR "microcode: ucode data file %s load failed\n",
374 fw_name);
Dmitry Adamushkoa0a29b62008-09-11 23:27:52 +0200375 return ret;
376 }
377
Andreas Herrmann0657d9e2008-12-16 19:14:05 +0100378 ret = generic_load_microcode(cpu, firmware->data, firmware->size);
Dmitry Adamushkoa0a29b62008-09-11 23:27:52 +0200379
Peter Oruba80cc9f12008-07-28 18:44:22 +0200380 release_firmware(firmware);
381
Dmitry Adamushkoa0a29b62008-09-11 23:27:52 +0200382 return ret;
383}
384
Dmitry Adamushkoa0a29b62008-09-11 23:27:52 +0200385static int request_microcode_user(int cpu, const void __user *buf, size_t size)
386{
Andreas Herrmannbe957762008-12-16 19:11:23 +0100387 printk(KERN_WARNING "microcode: AMD microcode update via "
388 "/dev/cpu/microcode is not supported\n");
Dmitry Adamushko2f9284e2008-09-23 22:56:35 +0200389 return -1;
Peter Oruba80cc9f12008-07-28 18:44:22 +0200390}
391
Peter Oruba80cc9f12008-07-28 18:44:22 +0200392static void microcode_fini_cpu_amd(int cpu)
393{
394 struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
395
Dmitry Adamushko18dbc912008-09-23 12:08:44 +0200396 vfree(uci->mc);
397 uci->mc = NULL;
Peter Oruba80cc9f12008-07-28 18:44:22 +0200398}
399
400static struct microcode_ops microcode_amd_ops = {
Dmitry Adamushkoa0a29b62008-09-11 23:27:52 +0200401 .request_microcode_user = request_microcode_user,
402 .request_microcode_fw = request_microcode_fw,
Peter Oruba80cc9f12008-07-28 18:44:22 +0200403 .collect_cpu_info = collect_cpu_info_amd,
404 .apply_microcode = apply_microcode_amd,
405 .microcode_fini_cpu = microcode_fini_cpu_amd,
406};
407
Dmitry Adamushko18dbc912008-09-23 12:08:44 +0200408struct microcode_ops * __init init_amd_microcode(void)
Peter Oruba80cc9f12008-07-28 18:44:22 +0200409{
Dmitry Adamushko18dbc912008-09-23 12:08:44 +0200410 return &microcode_amd_ops;
Peter Oruba80cc9f12008-07-28 18:44:22 +0200411}