1 |
commit: dae8d61f014283ef86ead2251f2b355004bc3f42 |
2 |
Author: Robin H. Johnson <robbat2 <AT> gentoo <DOT> org> |
3 |
AuthorDate: Mon Jan 2 22:50:20 2017 +0000 |
4 |
Commit: Robin H. Johnson <robbat2 <AT> gentoo <DOT> org> |
5 |
CommitDate: Mon Jan 2 22:50:20 2017 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=dae8d61f |
7 |
|
8 |
gen_initramfs: cleaner conditionals for microcode |
9 |
|
10 |
Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org> |
11 |
|
12 |
gen_initramfs.sh | 17 +++++++++++------ |
13 |
1 file changed, 11 insertions(+), 6 deletions(-) |
14 |
|
15 |
diff --git a/gen_initramfs.sh b/gen_initramfs.sh |
16 |
index 268bc2d..e968719 100755 |
17 |
--- a/gen_initramfs.sh |
18 |
+++ b/gen_initramfs.sh |
19 |
@@ -1053,27 +1053,32 @@ create_initramfs() { |
20 |
fi |
21 |
## To early load microcode we need to follow some pretty specific steps |
22 |
## mostly laid out in linux/Documentation/x86/early-microcode.txt |
23 |
- if grep -sq '^CONFIG_MICROCODE=y' "${KERNEL_OUTPUTDIR}"/.config; then |
24 |
+ ## It only loads monolithic ucode from an uncompressed cpio, which MUST |
25 |
+ ## be before the other cpio archives in the stream. |
26 |
+ cfg_CONFIG_MICROCODE=$(kconfig_get_opt "${KERNEL_OUTPUTDIR}"/.config CONFIG_MICROCODE) |
27 |
+ if [ "${cfg_CONFIG_MICROCODE}" == "y" ]; then |
28 |
+ cfg_CONFIG_MICROCODE_INTEL=$(kconfig_get_opt "${KERNEL_OUTPUTDIR}"/.config CONFIG_MICROCODE_INTEL) |
29 |
+ cfg_CONFIG_MICROCODE_AMD=$(kconfig_get_opt "${KERNEL_OUTPUTDIR}"/.config CONFIG_MICROCODE_AMD) |
30 |
print_info 1 "early-microcode: >> Preparing..." |
31 |
UCODEDIR="${TMPDIR}/ucode_tmp/kernel/x86/microcode/" |
32 |
mkdir -p "${UCODEDIR}" |
33 |
- if grep -sq '^CONFIG_MICROCODE_INTEL=y' "${KERNEL_OUTPUTDIR}"/.config; then |
34 |
- if [ "$(ls -A /lib/firmware/intel-ucode)" ]; then |
35 |
+ if [ "${cfg_CONFIG_MICROCODE_INTEL}" == "y" ]; then |
36 |
+ if [ -d /lib/firmware/intel-ucode ]; then |
37 |
print_info 1 " >> adding GenuineIntel.bin" |
38 |
cat /lib/firmware/intel-ucode/* > "${UCODEDIR}/GenuineIntel.bin" || gen_die "Failed to concat intel cpu ucode" |
39 |
else |
40 |
print_info 1 "CONFIG_MICROCODE_INTEL=y set but no ucode available. Please install sys-firmware/intel-microcode[split-ucode]" |
41 |
fi |
42 |
fi |
43 |
- if grep -sq '^CONFIG_MICROCODE_AMD=y' "${KERNEL_OUTPUTDIR}"/.config; then |
44 |
- if [ "$(ls -A /lib/firmware/amd-ucode)" ]; then |
45 |
+ if [ "${cfg_CONFIG_MICROCODE_AMD}" == "y" ]; then |
46 |
+ if [ -d /lib/firmware/amd-ucode ]; then |
47 |
print_info 1 " >> adding AuthenticAMD.bin" |
48 |
cat /lib/firmware/amd-ucode/*.bin > "${UCODEDIR}/AuthenticAMD.bin" || gen_dir "Failed to concat amd cpu ucode" |
49 |
else |
50 |
print_info 1 "CONFIG_MICROCODE_AMD=y set but no ucode available. Please install sys-firmware/linux-firmware" |
51 |
fi |
52 |
fi |
53 |
- if [ "$(ls -A ${UCODE})" ]; then |
54 |
+ if [ -f "${UCODEDIR}/AuthenticAMD.bin" -o -f "${UCODEDIR}/GenuineIntel.bin" ]; then |
55 |
print_info 1 "early-microcode: >> Creating cpio..." |
56 |
pushd "${TMPDIR}/ucode_tmp" > /dev/null |
57 |
find . | cpio -o -H newc > ../ucode.cpio || gen_die "Failed to create cpu microcode cpio" |