-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'x86/microcode' of git://git.kernel.org/pub/scm/linux/ke…
…rnel/git/tip/tip Pull x86 microcode loading update from Peter Anvin: "This patchset lets us update the CPU microcode very, very early in initialization if the BIOS fails to do so (never happens, right?) This is handy for dealing with things like the Atom erratum where we have to run without PSE because microcode loading happens too late. As I mentioned in the x86/mm push request it depends on that infrastructure but it is otherwise a standalone feature." * 'x86/microcode' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/Kconfig: Make early microcode loading a configuration feature x86/mm/init.c: Copy ucode from initrd image to kernel memory x86/head64.c: Early update ucode in 64-bit x86/head_32.S: Early update ucode in 32-bit x86/microcode_intel_early.c: Early update ucode on Intel's CPU x86/tlbflush.h: Define __native_flush_tlb_global_irq_disabled() x86/microcode_intel_lib.c: Early update ucode on Intel's CPU x86/microcode_core_early.c: Define interfaces for early loading ucode x86/common.c: load ucode in 64 bit or show loading ucode info in 32 bit on AP x86/common.c: Make have_cpuid_p() a global function x86/microcode_intel.h: Define functions and macros for early loading ucode x86, doc: Documentation for early microcode loading
- Loading branch information
Showing
16 changed files
with
1,301 additions
and
183 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
Early load microcode | ||
==================== | ||
By Fenghua Yu <[email protected]> | ||
|
||
Kernel can update microcode in early phase of boot time. Loading microcode early | ||
can fix CPU issues before they are observed during kernel boot time. | ||
|
||
Microcode is stored in an initrd file. The microcode is read from the initrd | ||
file and loaded to CPUs during boot time. | ||
|
||
The format of the combined initrd image is microcode in cpio format followed by | ||
the initrd image (maybe compressed). Kernel parses the combined initrd image | ||
during boot time. The microcode file in cpio name space is: | ||
kernel/x86/microcode/GenuineIntel.bin | ||
|
||
During BSP boot (before SMP starts), if the kernel finds the microcode file in | ||
the initrd file, it parses the microcode and saves matching microcode in memory. | ||
If matching microcode is found, it will be uploaded in BSP and later on in all | ||
APs. | ||
|
||
The cached microcode patch is applied when CPUs resume from a sleep state. | ||
|
||
There are two legacy user space interfaces to load microcode, either through | ||
/dev/cpu/microcode or through /sys/devices/system/cpu/microcode/reload file | ||
in sysfs. | ||
|
||
In addition to these two legacy methods, the early loading method described | ||
here is the third method with which microcode can be uploaded to a system's | ||
CPUs. | ||
|
||
The following example script shows how to generate a new combined initrd file in | ||
/boot/initrd-3.5.0.ucode.img with original microcode microcode.bin and | ||
original initrd image /boot/initrd-3.5.0.img. | ||
|
||
mkdir initrd | ||
cd initrd | ||
mkdir kernel | ||
mkdir kernel/x86 | ||
mkdir kernel/x86/microcode | ||
cp ../microcode.bin kernel/x86/microcode/GenuineIntel.bin | ||
find .|cpio -oc >../ucode.cpio | ||
cd .. | ||
cat ucode.cpio /boot/initrd-3.5.0.img >/boot/initrd-3.5.0.ucode.img |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
#ifndef _ASM_X86_MICROCODE_INTEL_H | ||
#define _ASM_X86_MICROCODE_INTEL_H | ||
|
||
#include <asm/microcode.h> | ||
|
||
struct microcode_header_intel { | ||
unsigned int hdrver; | ||
unsigned int rev; | ||
unsigned int date; | ||
unsigned int sig; | ||
unsigned int cksum; | ||
unsigned int ldrver; | ||
unsigned int pf; | ||
unsigned int datasize; | ||
unsigned int totalsize; | ||
unsigned int reserved[3]; | ||
}; | ||
|
||
struct microcode_intel { | ||
struct microcode_header_intel hdr; | ||
unsigned int bits[0]; | ||
}; | ||
|
||
/* microcode format is extended from prescott processors */ | ||
struct extended_signature { | ||
unsigned int sig; | ||
unsigned int pf; | ||
unsigned int cksum; | ||
}; | ||
|
||
struct extended_sigtable { | ||
unsigned int count; | ||
unsigned int cksum; | ||
unsigned int reserved[3]; | ||
struct extended_signature sigs[0]; | ||
}; | ||
|
||
#define DEFAULT_UCODE_DATASIZE (2000) | ||
#define MC_HEADER_SIZE (sizeof(struct microcode_header_intel)) | ||
#define DEFAULT_UCODE_TOTALSIZE (DEFAULT_UCODE_DATASIZE + MC_HEADER_SIZE) | ||
#define EXT_HEADER_SIZE (sizeof(struct extended_sigtable)) | ||
#define EXT_SIGNATURE_SIZE (sizeof(struct extended_signature)) | ||
#define DWSIZE (sizeof(u32)) | ||
|
||
#define get_totalsize(mc) \ | ||
(((struct microcode_intel *)mc)->hdr.totalsize ? \ | ||
((struct microcode_intel *)mc)->hdr.totalsize : \ | ||
DEFAULT_UCODE_TOTALSIZE) | ||
|
||
#define get_datasize(mc) \ | ||
(((struct microcode_intel *)mc)->hdr.datasize ? \ | ||
((struct microcode_intel *)mc)->hdr.datasize : DEFAULT_UCODE_DATASIZE) | ||
|
||
#define sigmatch(s1, s2, p1, p2) \ | ||
(((s1) == (s2)) && (((p1) & (p2)) || (((p1) == 0) && ((p2) == 0)))) | ||
|
||
#define exttable_size(et) ((et)->count * EXT_SIGNATURE_SIZE + EXT_HEADER_SIZE) | ||
|
||
extern int | ||
get_matching_microcode(unsigned int csig, int cpf, void *mc, int rev); | ||
extern int microcode_sanity_check(void *mc, int print_err); | ||
extern int get_matching_sig(unsigned int csig, int cpf, void *mc, int rev); | ||
extern int | ||
update_match_revision(struct microcode_header_intel *mc_header, int rev); | ||
|
||
#ifdef CONFIG_MICROCODE_INTEL_EARLY | ||
extern void __init load_ucode_intel_bsp(void); | ||
extern void __cpuinit load_ucode_intel_ap(void); | ||
extern void show_ucode_info_early(void); | ||
#else | ||
static inline __init void load_ucode_intel_bsp(void) {} | ||
static inline __cpuinit void load_ucode_intel_ap(void) {} | ||
static inline void show_ucode_info_early(void) {} | ||
#endif | ||
|
||
#if defined(CONFIG_MICROCODE_INTEL_EARLY) && defined(CONFIG_HOTPLUG_CPU) | ||
extern int save_mc_for_early(u8 *mc); | ||
#else | ||
static inline int save_mc_for_early(u8 *mc) | ||
{ | ||
return 0; | ||
} | ||
#endif | ||
|
||
#endif /* _ASM_X86_MICROCODE_INTEL_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.