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