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