x86: add intel microcode entries to grub config
authorTomasz Maciej Nowak <tomek_n@o2.pl>
Tue, 20 Nov 2018 16:20:43 +0000 (17:20 +0100)
committerJo-Philipp Wich <jo@mein.io>
Tue, 18 Dec 2018 16:48:15 +0000 (17:48 +0100)
Create initrd enries for x86 images, that'll load intel microcode as
early as possible. To achieve that the test module for grub is enabled
which provides shell-like conditionals. Also restrict the late load of
microcode to AMD processors.

Signed-off-by: Tomasz Maciej Nowak <tomek_n@o2.pl>
(backported from 546fced2a23557e95dd34246744c3aa6cad92fe6)

target/linux/x86/base-files/lib/preinit/02_load_x86_ucode
target/linux/x86/image/Makefile
target/linux/x86/image/grub-iso.cfg
target/linux/x86/image/grub.cfg

index fb309c75c115c16436209f0f69df0c3f491bd19e..d3a23e24b231b52ddf16cf3cbc722a5c7c2400de 100644 (file)
@@ -2,8 +2,10 @@
 # Copyright (C) 2018 OpenWrt.org
 
 do_load_x86_ucode() {
-       if [ -e "/sys/devices/system/cpu/microcode/reload" ]; then
-               echo 1 > /sys/devices/system/cpu/microcode/reload
+       if grep -q AuthenticAMD /proc/cpuinfo; then
+               if [ -e "/sys/devices/system/cpu/microcode/reload" ]; then
+                       echo 1 > /sys/devices/system/cpu/microcode/reload
+               fi
        fi
 }
 
index dbf8a8594b44865ef3ff509d8262d9d2103b4a56..f8c3700d321565ab9c0b41c4b072e6f81c203954 100644 (file)
@@ -9,8 +9,8 @@ include $(INCLUDE_DIR)/image.mk
 
 export PATH=$(TARGET_PATH):/sbin
 
-GRUB2_MODULES = biosdisk boot chain configfile ext2 linux ls part_msdos reboot serial vga
-GRUB2_MODULES_ISO = biosdisk boot chain configfile iso9660 linux ls part_msdos reboot serial vga
+GRUB2_MODULES = biosdisk boot chain configfile ext2 linux ls part_msdos reboot serial test vga
+GRUB2_MODULES_ISO = biosdisk boot chain configfile iso9660 linux ls part_msdos reboot serial test vga
 GRUB_TERMINALS =
 GRUB_SERIAL_CONFIG =
 GRUB_TERMINAL_CONFIG =
index 9c59bdf6d49e797ccecc310da08172d84aadf954..5d128aa3aab17ec4df050479dea16e51a5d9783b 100644 (file)
@@ -7,4 +7,7 @@ set root='(cd)'
 
 menuentry "@TITLE@" {
        linux /boot/vmlinuz @CMDLINE@ noinitrd
+       if [ -s /boot/intel-ucode.img ]; then
+               initrd /boot/intel-ucode.img
+       fi
 }
index dedfa0a6367524e51e24f1128a3b7786ed1cba3a..a665686863e230822b9ad26d43e9ffc54dcf0229 100644 (file)
@@ -7,6 +7,9 @@ set root='(@ROOT@)'
 
 menuentry "@TITLE@" {
        linux /boot/vmlinuz @CMDLINE@ noinitrd
+       if [ -s /boot/intel-ucode.img ]; then
+               initrd /boot/intel-ucode.img
+       fi
 }
 menuentry "@TITLE@ (failsafe)" {
        linux /boot/vmlinuz failsafe=true @CMDLINE@ noinitrd