diff options
| author | Borislav Petkov <bp@alien8.de> | 2016-09-04 05:37:36 -0400 |
|---|---|---|
| committer | Thomas Gleixner <tglx@linutronix.de> | 2016-09-05 04:38:56 -0400 |
| commit | cc2187a6e037bc64404f63c6d650ff263c2200c0 (patch) | |
| tree | 7f0e0d1694f907eb88d1c9842854eee9307055c7 /arch/x86/kernel/cpu/microcode | |
| parent | c6935931c1894ff857616ff8549b61236a19148f (diff) | |
x86/microcode/AMD: Fix load of builtin microcode with randomized memory
We do not need to add the randomization offset when the microcode is
built in.
Reported-and-tested-by: Emanuel Czirai <icanrealizeum@gmail.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Link: http://lkml.kernel.org/r/20160904093736.GA11939@pd.tnic
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'arch/x86/kernel/cpu/microcode')
| -rw-r--r-- | arch/x86/kernel/cpu/microcode/amd.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/arch/x86/kernel/cpu/microcode/amd.c b/arch/x86/kernel/cpu/microcode/amd.c index b816971f5da4..620ab06bcf45 100644 --- a/arch/x86/kernel/cpu/microcode/amd.c +++ b/arch/x86/kernel/cpu/microcode/amd.c | |||
| @@ -54,6 +54,7 @@ static LIST_HEAD(pcache); | |||
| 54 | */ | 54 | */ |
| 55 | static u8 *container; | 55 | static u8 *container; |
| 56 | static size_t container_size; | 56 | static size_t container_size; |
| 57 | static bool ucode_builtin; | ||
| 57 | 58 | ||
| 58 | static u32 ucode_new_rev; | 59 | static u32 ucode_new_rev; |
| 59 | static u8 amd_ucode_patch[PATCH_MAX_SIZE]; | 60 | static u8 amd_ucode_patch[PATCH_MAX_SIZE]; |
| @@ -281,18 +282,22 @@ static bool __init load_builtin_amd_microcode(struct cpio_data *cp, | |||
| 281 | void __init load_ucode_amd_bsp(unsigned int family) | 282 | void __init load_ucode_amd_bsp(unsigned int family) |
| 282 | { | 283 | { |
| 283 | struct cpio_data cp; | 284 | struct cpio_data cp; |
| 285 | bool *builtin; | ||
| 284 | void **data; | 286 | void **data; |
| 285 | size_t *size; | 287 | size_t *size; |
| 286 | 288 | ||
| 287 | #ifdef CONFIG_X86_32 | 289 | #ifdef CONFIG_X86_32 |
| 288 | data = (void **)__pa_nodebug(&ucode_cpio.data); | 290 | data = (void **)__pa_nodebug(&ucode_cpio.data); |
| 289 | size = (size_t *)__pa_nodebug(&ucode_cpio.size); | 291 | size = (size_t *)__pa_nodebug(&ucode_cpio.size); |
| 292 | builtin = (bool *)__pa_nodebug(&ucode_builtin); | ||
| 290 | #else | 293 | #else |
| 291 | data = &ucode_cpio.data; | 294 | data = &ucode_cpio.data; |
| 292 | size = &ucode_cpio.size; | 295 | size = &ucode_cpio.size; |
| 296 | builtin = &ucode_builtin; | ||
| 293 | #endif | 297 | #endif |
| 294 | 298 | ||
| 295 | if (!load_builtin_amd_microcode(&cp, family)) | 299 | *builtin = load_builtin_amd_microcode(&cp, family); |
| 300 | if (!*builtin) | ||
| 296 | cp = find_ucode_in_initrd(); | 301 | cp = find_ucode_in_initrd(); |
| 297 | 302 | ||
| 298 | if (!(cp.data && cp.size)) | 303 | if (!(cp.data && cp.size)) |
| @@ -373,7 +378,8 @@ void load_ucode_amd_ap(void) | |||
| 373 | return; | 378 | return; |
| 374 | 379 | ||
| 375 | /* Add CONFIG_RANDOMIZE_MEMORY offset. */ | 380 | /* Add CONFIG_RANDOMIZE_MEMORY offset. */ |
| 376 | cont += PAGE_OFFSET - __PAGE_OFFSET_BASE; | 381 | if (!ucode_builtin) |
| 382 | cont += PAGE_OFFSET - __PAGE_OFFSET_BASE; | ||
| 377 | 383 | ||
| 378 | eax = cpuid_eax(0x00000001); | 384 | eax = cpuid_eax(0x00000001); |
| 379 | eq = (struct equiv_cpu_entry *)(cont + CONTAINER_HDR_SZ); | 385 | eq = (struct equiv_cpu_entry *)(cont + CONTAINER_HDR_SZ); |
| @@ -439,7 +445,8 @@ int __init save_microcode_in_initrd_amd(void) | |||
| 439 | container = cont_va; | 445 | container = cont_va; |
| 440 | 446 | ||
| 441 | /* Add CONFIG_RANDOMIZE_MEMORY offset. */ | 447 | /* Add CONFIG_RANDOMIZE_MEMORY offset. */ |
| 442 | container += PAGE_OFFSET - __PAGE_OFFSET_BASE; | 448 | if (!ucode_builtin) |
| 449 | container += PAGE_OFFSET - __PAGE_OFFSET_BASE; | ||
| 443 | 450 | ||
| 444 | eax = cpuid_eax(0x00000001); | 451 | eax = cpuid_eax(0x00000001); |
| 445 | eax = ((eax >> 8) & 0xf) + ((eax >> 20) & 0xff); | 452 | eax = ((eax >> 8) & 0xf) + ((eax >> 20) & 0xff); |
