Harald Hoyer 460d2c
From d8d5cb839cbddff7d73a12450055f14dce4ce1e2 Mon Sep 17 00:00:00 2001
Harald Hoyer 460d2c
From: q66 <daniel@octaforge.org>
Harald Hoyer 460d2c
Date: Sat, 25 Jul 2020 17:28:16 +0200
Harald Hoyer 460d2c
Subject: [PATCH] dracut.sh: fix early microcode detection logic
Harald Hoyer 460d2c
Harald Hoyer 460d2c
This fixes two issues:
Harald Hoyer 460d2c
Harald Hoyer 460d2c
1) on non-x86 systems in non-hostonly config this would cause
Harald Hoyer 460d2c
   an annoying warning on every initramfs generation
Harald Hoyer 460d2c
2) on non-x86 systems in hostonly config this would result in
Harald Hoyer 460d2c
   early microcode not getting disabled
Harald Hoyer 460d2c
---
Harald Hoyer 460d2c
 dracut.sh | 23 +++++++++++++++--------
Harald Hoyer 460d2c
 1 file changed, 15 insertions(+), 8 deletions(-)
Harald Hoyer 460d2c
Harald Hoyer 460d2c
diff --git a/dracut.sh b/dracut.sh
Harald Hoyer 460d2c
index e3195499..d5dfa77d 100755
Harald Hoyer 460d2c
--- a/dracut.sh
Harald Hoyer 460d2c
+++ b/dracut.sh
Harald Hoyer 460d2c
@@ -1194,19 +1194,26 @@ fi
Harald Hoyer 460d2c
 
Harald Hoyer 460d2c
 if [[ $early_microcode = yes ]]; then
Harald Hoyer 460d2c
     if [[ $hostonly ]]; then
Harald Hoyer 460d2c
-        [[ $(get_cpu_vendor) == "AMD" ]] \
Harald Hoyer 460d2c
-            && ! check_kernel_config CONFIG_MICROCODE_AMD \
Harald Hoyer 460d2c
-            && unset early_microcode
Harald Hoyer 460d2c
-        [[ $(get_cpu_vendor) == "Intel" ]] \
Harald Hoyer 460d2c
-            && ! check_kernel_config CONFIG_MICROCODE_INTEL \
Harald Hoyer 460d2c
-            && unset early_microcode
Harald Hoyer 460d2c
+        if [[ $(get_cpu_vendor) == "AMD" ]]; then
Harald Hoyer 460d2c
+            check_kernel_config CONFIG_MICROCODE_AMD || unset early_microcode
Harald Hoyer 460d2c
+        elif [[ $(get_cpu_vendor) == "Intel" ]]; then
Harald Hoyer 460d2c
+            check_kernel_config CONFIG_MICROCODE_INTEL || unset early_microcode
Harald Hoyer 460d2c
+        else
Harald Hoyer 460d2c
+            unset early_microcode
Harald Hoyer 460d2c
+        fi
Harald Hoyer 460d2c
     else
Harald Hoyer 460d2c
         ! check_kernel_config CONFIG_MICROCODE_AMD \
Harald Hoyer 460d2c
             && ! check_kernel_config CONFIG_MICROCODE_INTEL \
Harald Hoyer 460d2c
             && unset early_microcode
Harald Hoyer 460d2c
     fi
Harald Hoyer 460d2c
-    [[ $early_microcode != yes ]] \
Harald Hoyer 460d2c
-        && dwarn "Disabling early microcode, because kernel does not support it. CONFIG_MICROCODE_[AMD|INTEL]!=y"
Harald Hoyer 460d2c
+    # Do not complain on non-x86 architectures as it makes no sense
Harald Hoyer 460d2c
+    case $(uname -m) in
Harald Hoyer 460d2c
+        x86_64|i?86)
Harald Hoyer 460d2c
+            [[ $early_microcode != yes ]] \
Harald Hoyer 460d2c
+                && dwarn "Disabling early microcode, because kernel does not support it. CONFIG_MICROCODE_[AMD|INTEL]!=y"
Harald Hoyer 460d2c
+            ;;
Harald Hoyer 460d2c
+        *) ;;
Harald Hoyer 460d2c
+    esac
Harald Hoyer 460d2c
 fi
Harald Hoyer 460d2c
 
Harald Hoyer 460d2c
 # Need to be able to have non-root users read stuff (rpcbind etc)
Harald Hoyer 460d2c