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