[PATCH] x86/microcode: Adjust ramdisk address when accessing by virtual address

From: Boris Ostrovsky
Date: Mon Dec 19 2016 - 10:31:37 EST


When searching for microcode in the ramdisk image we need to adjust the
start address after paging has been turned on (in 32-bit mode).

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx>
---
arch/x86/kernel/cpu/microcode/core.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c
index c4bb2f7..bc8c3345 100644
--- a/arch/x86/kernel/cpu/microcode/core.c
+++ b/arch/x86/kernel/cpu/microcode/core.c
@@ -227,8 +227,11 @@ struct cpio_data find_microcode_in_initrd(const char *path, bool use_pa)
* Set start only if we have an initrd image. We cannot use initrd_start
* because it is not set that early yet.
*/
- if (size)
+ if (size) {
start = params->hdr.ramdisk_image;
+ if (!use_pa)
+ start += PAGE_OFFSET;
+ }

# else /* CONFIG_X86_64 */
size = (unsigned long)boot_params.ext_ramdisk_size << 32;
--
2.5.5