]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
Check kernel config for early microcode and ACPI override
authorHarald Hoyer <harald@redhat.com>
Wed, 20 Aug 2014 08:13:55 +0000 (10:13 +0200)
committerHarald Hoyer <harald@redhat.com>
Wed, 20 Aug 2014 08:13:55 +0000 (10:13 +0200)
Disable early microcode and ACPI override, if the kernel does not
support it.

dracut-functions.sh
dracut.sh

index 9286828277858c10cf6d1b34fabb170772f0fd5e..4ad77aa58ad2f958670c3174693e297dbf433983 100755 (executable)
@@ -739,7 +739,6 @@ fs_get_option() {
     done
 }
 
-
 if ! [[ $DRACUT_INSTALL ]]; then
     DRACUT_INSTALL=$(find_binary dracut-install)
 fi
@@ -1740,6 +1739,24 @@ instmods() {
     _ret=$?
     return $_ret
 }
+
+check_kernel_config()
+{
+    local _config_opt="$1"
+    local _config_file
+    [[ -f /boot/config-$kernel ]] \
+        && _config_file="/boot/config-$kernel"
+    [[ -f /lib/modules/$kernel/config ]] \
+        && _config_file="/lib/modules/$kernel/config"
+
+    # no kernel config file, so return true
+    [[ $_config_file ]] || return 0
+
+    grep -q -F "${_config_opt}=" "$_config_file" && return 0
+    return 1
+}
+
+
 # get_cpu_vendor
 # Only two values are returned: AMD or Intel
 get_cpu_vendor ()
index 2cce85b47a8bd638bdfc7dea0c35e551a3d0ff93..0e9b2a54f1fe1b073b755a8de77fb413fc3f94da 100755 (executable)
--- a/dracut.sh
+++ b/dracut.sh
@@ -983,6 +983,28 @@ if [[ ! $print_cmdline ]]; then
     fi
 fi
 
+if [[ $acpi_override = yes ]] && ! check_kernel_config CONFIG_ACPI_INITRD_TABLE_OVERRIDE; then
+    dwarn "Disabling ACPI override, because kernel does not support it. CONFIG_ACPI_INITRD_TABLE_OVERRIDE!=y"
+    unset acpi_override
+fi
+
+if [[ $early_microcode = yes ]]; then
+    if [[ $hostonly ]]; then
+        [[ $(get_cpu_vendor) == "AMD" ]] \
+            && ! check_kernel_config CONFIG_MICROCODE_AMD_EARLY \
+            && unset early_microcode
+        [[ $(get_cpu_vendor) == "Intel" ]] \
+            && ! check_kernel_config CONFIG_MICROCODE_INTEL_EARLY \
+            && unset early_microcode
+    else
+        ! check_kernel_config CONFIG_MICROCODE_AMD_EARLY \
+            && ! check_kernel_config CONFIG_MICROCODE_INTEL_EARLY \
+            && unset early_microcode
+    fi
+    [[ $early_microcode != yes ]] \
+        && dwarn "Disabling early microcode, because kernel does not support it. CONFIG_MICROCODE_[AMD|INTEL]_EARLY!=y"
+fi
+
 # Need to be able to have non-root users read stuff (rpcbind etc)
 chmod 755 "$initdir"