From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 8B9C8138334 for ; Thu, 18 Jul 2019 00:44:52 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 7A4CFE0826; Thu, 18 Jul 2019 00:44:51 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 4C67DE0826 for ; Thu, 18 Jul 2019 00:44:51 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id B5257347E99 for ; Thu, 18 Jul 2019 00:44:49 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 30C666E9 for ; Thu, 18 Jul 2019 00:44:47 +0000 (UTC) From: "Thomas Deutschmann" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Thomas Deutschmann" Message-ID: <1563409508.ced7a8141c6d311eee4928959fb42919ed34e6e6.whissi@gentoo> Subject: [gentoo-commits] proj/genkernel:master commit in: / X-VCS-Repository: proj/genkernel X-VCS-Files: gen_determineargs.sh gen_initramfs.sh X-VCS-Directories: / X-VCS-Committer: whissi X-VCS-Committer-Name: Thomas Deutschmann X-VCS-Revision: ced7a8141c6d311eee4928959fb42919ed34e6e6 X-VCS-Branch: master Date: Thu, 18 Jul 2019 00:44:47 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: ba860f5f-ee6e-453f-a6ce-f840276713f2 X-Archives-Hash: a48d39b206a3bcdd4e779cd41b764cbc commit: ced7a8141c6d311eee4928959fb42919ed34e6e6 Author: Thomas Deutschmann gentoo org> AuthorDate: Thu Jul 18 00:25:08 2019 +0000 Commit: Thomas Deutschmann gentoo org> CommitDate: Thu Jul 18 00:25:08 2019 +0000 URL: https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=ced7a814 Change --microcode-initramfs handling - Always add microcode to initramfs when user has set --microcode-initramfs option despite kernel support. - Show warning when kernel will be unable to use microcode. - Inform user that --microcode-initramfs is not the recommended method to load microcode when bootloader supports multiple initramfs and /boot/{amd,intel}-uc.img is available (currently only true for --microcode=intel). - --microcode-initramfs and --integrated-initramfs options are mutually exclusive. Signed-off-by: Thomas Deutschmann gentoo.org> gen_determineargs.sh | 13 +++++++++++++ gen_initramfs.sh | 53 +++++++++++++++++++++++++++++++++++++--------------- 2 files changed, 51 insertions(+), 15 deletions(-) diff --git a/gen_determineargs.sh b/gen_determineargs.sh index 7bebea1..f345944 100755 --- a/gen_determineargs.sh +++ b/gen_determineargs.sh @@ -468,6 +468,19 @@ determine_real_args() { *) gen_die "Invalid microcode '${MICROCODE}', --microcode= requires one of: no, all, intel, amd" ;; esac + if isTrue "${BUILD_RAMDISK}" && isTrue "${MICROCODE_INITRAMFS}" && [[ -z "${MICROCODE}" ]] + then + print_warning 1 '--microcode=no implies --no-microcode-initramfs; Will not add any microcode to initramfs ...' + print_warning 1 '' 1 0 + MICROCODE_INITRAMFS=no + fi + + if isTrue "${BUILD_RAMDISK}" && isTrue "${MICROCODE_INITRAMFS}" && isTrue "${INTEGRATED_INITRAMFS}" + then + # Force a user decision + gen_die "Cannot embed microcode in initramfs when --integrated-initramfs is set. Either change option to --no-integrated-initramfs or --no-microcode-initramfs!" + fi + if isTrue "${FIRMWARE}" then for ff in ${FIRMWARE_FILES}; do diff --git a/gen_initramfs.sh b/gen_initramfs.sh index d5383f5..1479a5d 100755 --- a/gen_initramfs.sh +++ b/gen_initramfs.sh @@ -1728,16 +1728,9 @@ create_initramfs() { ## mostly laid out in linux/Documentation/x86/early-microcode.txt ## It only loads monolithic ucode from an uncompressed cpio, which MUST ## be before the other cpio archives in the stream. - local cfg_CONFIG_MICROCODE=$(kconfig_get_opt "${KERNEL_OUTPUTDIR}"/.config CONFIG_MICROCODE) - if isTrue "${MICROCODE_INITRAMFS}" && [ "${cfg_CONFIG_MICROCODE}" == "y" ] + if isTrue "${MICROCODE_INITRAMFS}" then - if [[ "${MICROCODE}" == intel ]] - then - # Only show this information for Intel users because we have no mechanism yet - # to generate amd-*.img in /boot after sys-kernel/linux-firmware update - print_info 1 "MICROCODE_INITRAMFS option is enabled by default for compatability but made obsolete by >=sys-boot/grub-2.02-r1" - fi - + local cfg_CONFIG_MICROCODE=$(kconfig_get_opt "${KERNEL_OUTPUTDIR}"/.config CONFIG_MICROCODE) local cfg_CONFIG_MICROCODE_INTEL=$(kconfig_get_opt "${KERNEL_OUTPUTDIR}"/.config CONFIG_MICROCODE_INTEL) local cfg_CONFIG_MICROCODE_AMD=$(kconfig_get_opt "${KERNEL_OUTPUTDIR}"/.config CONFIG_MICROCODE_AMD) print_info 1 "$(get_indent 1)>> Adding early-microcode support ..." @@ -1745,25 +1738,42 @@ create_initramfs() { mkdir -p "${UCODEDIR}" || gen_die "Failed to create '${UCODEDIR}'!" echo 1 > "${TEMP}/ucode_tmp/early_cpio" - if [[ "${cfg_CONFIG_MICROCODE_INTEL}" == "y" ]] + if [ "${cfg_CONFIG_MICROCODE}" != "y" ] then + print_warning 1 "$(get_indent 2)early-microcode: Will add microcode(s) like requested but kernel has set CONFIG_MICROCODE=n" + fi + + if [[ "${MICROCODE}" == 'all' || "${MICROCODE}" == 'intel' ]] + then + if [[ "${cfg_CONFIG_MICROCODE_INTEL}" != "y" ]] + then + print_warning 1 "$(get_indent 2)early-microcode: Will add Intel microcode(s) like requested (--microcode=${MICROCODE}) but kernel has set CONFIG_MICROCODE_INTEL=n" + fi + if [ -d /lib/firmware/intel-ucode ] then print_info 1 "$(get_indent 2)early-microcode: Adding GenuineIntel.bin ..." cat /lib/firmware/intel-ucode/* > "${UCODEDIR}/GenuineIntel.bin" || gen_die "Failed to concat intel cpu ucode" else - print_info 1 "$(get_indent 2)early-microcode: CONFIG_MICROCODE_INTEL=y set but no ucode available. Please install sys-firmware/intel-microcode[split-ucode]" + print_warning 1 "$(get_indent 2)early-microcode: Unable to add Intel microcode like requested (--microcode=${MICROCODE}); No ucode is available." + print_warning 1 "$(get_indent 2) Is sys-firmware/intel-microcode[split-ucode] installed?" fi fi - if [[ "${cfg_CONFIG_MICROCODE_AMD}" == "y" ]] + if [[ "${MICROCODE}" == 'all' || "${MICROCODE}" == 'amd' ]] then + if [[ "${cfg_CONFIG_MICROCODE_AMD}" != "y" ]] + then + print_warning 1 "$(get_indent 2)early-microcode: Will add AMD microcode(s) like requested (--microcode=${MICROCODE}) but kernel has set CONFIG_MICROCODE_AMD=n" + fi + if [ -d /lib/firmware/amd-ucode ] then print_info 1 "$(get_indent 2)early-microcode: Adding AuthenticAMD.bin ..." cat /lib/firmware/amd-ucode/*.bin > "${UCODEDIR}/AuthenticAMD.bin" || gen_dir "Failed to concat amd cpu ucode" else - print_info 1 "$(get_indent 2)early-microcode: CONFIG_MICROCODE_AMD=y set but no ucode available. Please install sys-firmware/linux-firmware" + print_warning 1 "$(get_indent 2)early-microcode: Unable to add AMD microcode like requested (--microcode=${MICROCODE}); No ucode is available." + print_warning 1 "$(get_indent 2) Is sys-firmware/linux-firmware installed?" fi fi @@ -1778,9 +1788,22 @@ create_initramfs() { cat "${TEMP}/ucode.cpio" "${CPIO}" > "${CPIO}.early-microcode" || gen_die "Failed to prepend early-microcode to initramfs" mv -f "${CPIO}.early-microcode" "${CPIO}" || gen_die "Rename failed" else - print_info 1 "$(get_indent 2)early-microcode: CONFIG_MICROCODE=y is set but no microcode found" - print_info 1 "$(get_indent 2)early-microcode: You can disable MICROCODE_INITRAMFS option if you use your bootloader to load AMD/Intel ucode initrd" + print_warning 1 "$(get_indent 2)early-microcode: No microcode found; Will not prepend any microcode to initramfs ..." + print_info 1 "$(get_indent 2) ${BOLD}Note:${NORMAL} You can set --no-microcode-initramfs if you load microcode on your own" + fi + + if ! isTrue "${WRAP_INITRD}" && [[ "${MICROCODE}" == intel ]] + then + # Only show this information for Intel users because we have no mechanism yet + # to generate amd-*.img in /boot after sys-kernel/linux-firmware update + print_info 1 '' + print_info 1 "${BOLD}Note:${NORMAL}" + print_info 1 '--microcode-initramfs option is enabled by default for backward compatability.' + print_info 1 'If your bootloader can load multiple initramfs it is recommended to load' + print_info 1 '/boot/intel-uc.img instead of embedding microcode into initramfs.' fi + else + print_info 3 "$(get_indent 1)>> --no-microcode-initramfs is set; Skipping early-microcode support ..." fi if isTrue "${WRAP_INITRD}"