diff options
author | Robin H. Johnson <robbat2@gentoo.org> | 2018-08-04 16:19:46 -0700 |
---|---|---|
committer | Robin H. Johnson <robbat2@gentoo.org> | 2018-08-04 16:25:31 -0700 |
commit | febc1b12b5b393e918da94b9f1c029f2adcea215 (patch) | |
tree | c1f2282171b55da54994072469ccb041c87c269e | |
parent | linuxrc: Add detection of squashfs in initrd root (diff) | |
download | genkernel-febc1b12b5b393e918da94b9f1c029f2adcea215.tar.gz genkernel-febc1b12b5b393e918da94b9f1c029f2adcea215.tar.bz2 genkernel-febc1b12b5b393e918da94b9f1c029f2adcea215.zip |
microcode: add flexability: type & initramfs control
Bug reported that the MICROCODE option did not provide enough
flexability, as it enabled both AMD & Intel options by default, and
placed both sets of microcode into the initramfs.
Existing boolean option MICROCODE is now a string, which takes
no/all/amd/intel as inputs, describing which variant of kernel options
to enable. Boolean inputs are converted to no/all settings. This option
no longer include microcode in initramfs.
New option MICROCODE_INITRAMFS, enabled by default, includes the
microcode for matching kernel config options (INTEL/AMD) into the
initramfs. For users using sys-boot/grub-2.02-r1 or another bootloader
that supports multiple initramfs options, this option can be safely
disabled.
Fixes: https://bugs.gentoo.org/662492
Reported-by: Joerg Schaible <joerg.schaible@gmx.de>
Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
-rwxr-xr-x | gen_cmdline.sh | 18 | ||||
-rwxr-xr-x | gen_configkernel.sh | 18 | ||||
-rwxr-xr-x | gen_determineargs.sh | 11 | ||||
-rwxr-xr-x | gen_initramfs.sh | 3 | ||||
-rw-r--r-- | genkernel.conf | 10 |
5 files changed, 43 insertions, 17 deletions
diff --git a/gen_cmdline.sh b/gen_cmdline.sh index 3d9611fd..853723b7 100755 --- a/gen_cmdline.sh +++ b/gen_cmdline.sh @@ -98,8 +98,9 @@ longusage() { echo " --mdadm Include MDADM/MDMON support" echo " --no-mdadm Exclude MDADM/MDMON support" echo " --mdadm-config=<file> Use file as mdadm.conf in initramfs" - echo " --microcode Include early microcode support" - echo " --no-microcode Exclude early microcode support" + echo " --microcode[=<type>] Include early microcode support, for 'all'/'amd'/'intel' CPU types" + echo " --no-microcode Exclude early microcode support" + echo " --microcode-initramfs Include early microcode in initramfs" echo " --nfs Include NFS support" echo " --no-nfs Exclude NFS support" echo " --dmraid Include DMRAID support" @@ -330,9 +331,20 @@ parse_cmdline() { print_info 2 "CMD_BUSYBOX: ${CMD_BUSYBOX}" ;; --microcode|--no-microcode) - CMD_MICROCODE=`parse_optbool "$*"` + case `parse_optbool "$*"` in + 0) CMD_MICROCODE='no' ;; + 1) CMD_MICROCODE='all' ;; + esac print_info 2 "CMD_MICROCODE: ${CMD_MICROCODE}" ;; + --microcode=*) + CMD_MICROCODE="${*#*=}" + print_info 2 "CMD_MICROCODE: $CMD_MICROCODE" + ;; + --microcode-initramfs|--no-microcode-initramfs) + CMD_MICROCODE_INITRAMFS=`parse_optbool "$*"` + print_info 2 "CMD_MICROCODE_INITRAMFS: ${CMD_MICROCODE_INITRAMFS}" + ;; --nfs|--no-nfs) CMD_NFS=`parse_optbool "$*"` print_info 2 "CMD_NFS: ${CMD_NFS}" diff --git a/gen_configkernel.sh b/gen_configkernel.sh index 697c478d..475526ab 100755 --- a/gen_configkernel.sh +++ b/gen_configkernel.sh @@ -277,17 +277,15 @@ config_kernel() { # Microcode setting, intended for early microcode loading # needs to be compiled in. - if isTrue ${MICROCODE} + kconfig_microcode_intel=(CONFIG_MICROCODE_INTEL CONFIG_MICROCODE_INTEL_EARLY) + kconfig_microcode_amd=(CONFIG_MICROCODE_AMD CONFIG_MICROCODE_AMD_EARLY) + if [[ -n "${MICROCODE}" ]] then - for k in \ - CONFIG_MICROCODE \ - CONFIG_MICROCODE_INTEL \ - CONFIG_MICROCODE_AMD \ - CONFIG_MICROCODE_OLD_INTERFACE \ - CONFIG_MICROCODE_INTEL_EARLY \ - CONFIG_MICROCODE_AMD_EARLY \ - CONFIG_MICROCODE_EARLY \ - ; do + kconfigs=(CONFIG_MICROCODE CONFIG_MICROCODE_OLD_INTERFACE CONFIG_MICROCODE_EARLY) + [[ "$MICROCODE" == all ]] && kconfigs+=( ${kconfig_microcode_amd[@]} ${kconfig_microcode_intel[@]} ) + [[ "$MICROCODE" == amd ]] && kconfigs+=( ${kconfig_microcode_amd[@]} ) + [[ "$MICROCODE" == intel ]] && kconfigs+=( ${kconfig_microcode_intel[@]} ) + for k in "${kconfigs[@]}" ; do cfg=$(kconfig_get_opt "${KERNEL_OUTPUTDIR}/.config" "$k") case "$cfg" in y) ;; # Do nothing diff --git a/gen_determineargs.sh b/gen_determineargs.sh index b686fca9..bd0150a5 100755 --- a/gen_determineargs.sh +++ b/gen_determineargs.sh @@ -121,7 +121,8 @@ determine_real_args() { set_config_with_override BOOL HYPERV CMD_HYPERV set_config_with_override BOOL BUSYBOX CMD_BUSYBOX "yes" set_config_with_override BOOL NFS CMD_NFS "yes" - set_config_with_override BOOL MICROCODE CMD_MICROCODE + set_config_with_override STRING MICROCODE CMD_MICROCODE "all" + set_config_with_override BOOL MICROCODE_INITRAMFS CMD_MICROCODE_INITRAMFS "yes" set_config_with_override BOOL UNIONFS CMD_UNIONFS set_config_with_override BOOL NETBOOT CMD_NETBOOT set_config_with_override STRING REAL_ROOT CMD_REAL_ROOT @@ -234,5 +235,13 @@ determine_real_args() { INTEGRATED_INITRAMFS=0 fi + MICROCODE=${MICROCODE,,} + case ${MICROCODE} in + all|amd|intel) ;; + y|yes|1|true|t) MICROCODE='all' ;; + n|no|none|0|false|f) MICROCODE='' ;; + *) gen_die "Invalid microcode '${MICROCODE}', --microcode=<type> requires one of: no, all, intel, amd" ;; + esac + get_KV } diff --git a/gen_initramfs.sh b/gen_initramfs.sh index 768f2915..a2c55c6e 100755 --- a/gen_initramfs.sh +++ b/gen_initramfs.sh @@ -1149,7 +1149,8 @@ create_initramfs() { ## It only loads monolithic ucode from an uncompressed cpio, which MUST ## be before the other cpio archives in the stream. cfg_CONFIG_MICROCODE=$(kconfig_get_opt "${KERNEL_OUTPUTDIR}"/.config CONFIG_MICROCODE) - if isTrue "${MICROCODE}" && [ "${cfg_CONFIG_MICROCODE}" == "y" ]; then + if isTrue "${MICROCODE_INITRAMFS}" && [ "${cfg_CONFIG_MICROCODE}" == "y" ]; then + print_info 1 "--microcode-initramfs is enabled by default for compatability but made obsolete by sys-boot/grub-2.02-r1" cfg_CONFIG_MICROCODE_INTEL=$(kconfig_get_opt "${KERNEL_OUTPUTDIR}"/.config CONFIG_MICROCODE_INTEL) cfg_CONFIG_MICROCODE_AMD=$(kconfig_get_opt "${KERNEL_OUTPUTDIR}"/.config CONFIG_MICROCODE_AMD) print_info 1 "early-microcode: >> Preparing..." diff --git a/genkernel.conf b/genkernel.conf index 5e5a67b7..57cb2b0d 100644 --- a/genkernel.conf +++ b/genkernel.conf @@ -74,8 +74,14 @@ USECOLOR="yes" # Add in GnuPG support #GPG="no" -# Add in early microcode support -#MICROCODE="no" +# Add in early microcode support: this sets the kernel options for early microcode loading +# Acceptible values: empty/"no", "all", "intel", "amd" +#MICROCODE="all" + +# Include early microcode in generated initramfs +# This is enabled by default for upgrade compatability, however is obsoleted by +# sys-boot/grub-2.02-r1, which supports multiple initramfs in the bootloader. +#MICROCODE_INITRAMFS="no" # Add in NFS support #NFS="no" |