diff options
author | Borislav Petkov <bp@suse.de> | 2016-10-25 05:55:15 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2016-10-25 06:28:58 -0400 |
commit | 058dc49803171f37b25f053182835f2969d1c43f (patch) | |
tree | 1b31395bfb5edc9a71aafb51a606694931b98f0f | |
parent | f5bdfefbf96279b4eb431606cec7a662f5d3ba88 (diff) |
x86/microcode: Export the microcode cache linked list
It will be used by both drivers so move it to core.c.
No functionality change.
Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/20161025095522.11964-6-bp@alien8.de
Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r-- | arch/x86/include/asm/microcode.h | 9 | ||||
-rw-r--r-- | arch/x86/kernel/cpu/microcode/amd.c | 23 | ||||
-rw-r--r-- | arch/x86/kernel/cpu/microcode/core.c | 2 |
3 files changed, 18 insertions, 16 deletions
diff --git a/arch/x86/include/asm/microcode.h b/arch/x86/include/asm/microcode.h index 05e56d0968d4..91595ecb3689 100644 --- a/arch/x86/include/asm/microcode.h +++ b/arch/x86/include/asm/microcode.h | |||
@@ -20,6 +20,15 @@ do { \ | |||
20 | (u32)((u64)(val)), \ | 20 | (u32)((u64)(val)), \ |
21 | (u32)((u64)(val) >> 32)) | 21 | (u32)((u64)(val) >> 32)) |
22 | 22 | ||
23 | struct ucode_patch { | ||
24 | struct list_head plist; | ||
25 | void *data; /* Intel uses only this one */ | ||
26 | u32 patch_id; | ||
27 | u16 equiv_cpu; | ||
28 | }; | ||
29 | |||
30 | extern struct list_head microcode_cache; | ||
31 | |||
23 | struct cpu_signature { | 32 | struct cpu_signature { |
24 | unsigned int sig; | 33 | unsigned int sig; |
25 | unsigned int pf; | 34 | unsigned int pf; |
diff --git a/arch/x86/kernel/cpu/microcode/amd.c b/arch/x86/kernel/cpu/microcode/amd.c index 6b3929e80fd4..8cb20e3e9436 100644 --- a/arch/x86/kernel/cpu/microcode/amd.c +++ b/arch/x86/kernel/cpu/microcode/amd.c | |||
@@ -39,15 +39,6 @@ | |||
39 | 39 | ||
40 | static struct equiv_cpu_entry *equiv_cpu_table; | 40 | static struct equiv_cpu_entry *equiv_cpu_table; |
41 | 41 | ||
42 | struct ucode_patch { | ||
43 | struct list_head plist; | ||
44 | void *data; | ||
45 | u32 patch_id; | ||
46 | u16 equiv_cpu; | ||
47 | }; | ||
48 | |||
49 | static LIST_HEAD(pcache); | ||
50 | |||
51 | /* | 42 | /* |
52 | * This points to the current valid container of microcode patches which we will | 43 | * This points to the current valid container of microcode patches which we will |
53 | * save from the initrd before jettisoning its contents. | 44 | * save from the initrd before jettisoning its contents. |
@@ -312,9 +303,9 @@ void __init load_ucode_amd_bsp(unsigned int family) | |||
312 | #ifdef CONFIG_X86_32 | 303 | #ifdef CONFIG_X86_32 |
313 | /* | 304 | /* |
314 | * On 32-bit, since AP's early load occurs before paging is turned on, we | 305 | * On 32-bit, since AP's early load occurs before paging is turned on, we |
315 | * cannot traverse cpu_equiv_table and pcache in kernel heap memory. So during | 306 | * cannot traverse cpu_equiv_table and microcode_cache in kernel heap memory. |
316 | * cold boot, AP will apply_ucode_in_initrd() just like the BSP. During | 307 | * So during cold boot, AP will apply_ucode_in_initrd() just like the BSP. |
317 | * save_microcode_in_initrd_amd() BSP's patch is copied to amd_ucode_patch, | 308 | * In save_microcode_in_initrd_amd() BSP's patch is copied to amd_ucode_patch, |
318 | * which is used upon resume from suspend. | 309 | * which is used upon resume from suspend. |
319 | */ | 310 | */ |
320 | void load_ucode_amd_ap(void) | 311 | void load_ucode_amd_ap(void) |
@@ -508,7 +499,7 @@ static struct ucode_patch *cache_find_patch(u16 equiv_cpu) | |||
508 | { | 499 | { |
509 | struct ucode_patch *p; | 500 | struct ucode_patch *p; |
510 | 501 | ||
511 | list_for_each_entry(p, &pcache, plist) | 502 | list_for_each_entry(p, µcode_cache, plist) |
512 | if (p->equiv_cpu == equiv_cpu) | 503 | if (p->equiv_cpu == equiv_cpu) |
513 | return p; | 504 | return p; |
514 | return NULL; | 505 | return NULL; |
@@ -518,7 +509,7 @@ static void update_cache(struct ucode_patch *new_patch) | |||
518 | { | 509 | { |
519 | struct ucode_patch *p; | 510 | struct ucode_patch *p; |
520 | 511 | ||
521 | list_for_each_entry(p, &pcache, plist) { | 512 | list_for_each_entry(p, µcode_cache, plist) { |
522 | if (p->equiv_cpu == new_patch->equiv_cpu) { | 513 | if (p->equiv_cpu == new_patch->equiv_cpu) { |
523 | if (p->patch_id >= new_patch->patch_id) | 514 | if (p->patch_id >= new_patch->patch_id) |
524 | /* we already have the latest patch */ | 515 | /* we already have the latest patch */ |
@@ -531,14 +522,14 @@ static void update_cache(struct ucode_patch *new_patch) | |||
531 | } | 522 | } |
532 | } | 523 | } |
533 | /* no patch found, add it */ | 524 | /* no patch found, add it */ |
534 | list_add_tail(&new_patch->plist, &pcache); | 525 | list_add_tail(&new_patch->plist, µcode_cache); |
535 | } | 526 | } |
536 | 527 | ||
537 | static void free_cache(void) | 528 | static void free_cache(void) |
538 | { | 529 | { |
539 | struct ucode_patch *p, *tmp; | 530 | struct ucode_patch *p, *tmp; |
540 | 531 | ||
541 | list_for_each_entry_safe(p, tmp, &pcache, plist) { | 532 | list_for_each_entry_safe(p, tmp, µcode_cache, plist) { |
542 | __list_del(p->plist.prev, p->plist.next); | 533 | __list_del(p->plist.prev, p->plist.next); |
543 | kfree(p->data); | 534 | kfree(p->data); |
544 | kfree(p); | 535 | kfree(p); |
diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c index d0d1a0f5a497..55a2b24b2bdd 100644 --- a/arch/x86/kernel/cpu/microcode/core.c +++ b/arch/x86/kernel/cpu/microcode/core.c | |||
@@ -45,6 +45,8 @@ | |||
45 | static struct microcode_ops *microcode_ops; | 45 | static struct microcode_ops *microcode_ops; |
46 | static bool dis_ucode_ldr; | 46 | static bool dis_ucode_ldr; |
47 | 47 | ||
48 | LIST_HEAD(microcode_cache); | ||
49 | |||
48 | /* | 50 | /* |
49 | * Synchronization. | 51 | * Synchronization. |
50 | * | 52 | * |