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