1 |
commit: febc1b12b5b393e918da94b9f1c029f2adcea215 |
2 |
Author: Robin H. Johnson <robbat2 <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sat Aug 4 23:19:46 2018 +0000 |
4 |
Commit: Robin H. Johnson <robbat2 <AT> gentoo <DOT> org> |
5 |
CommitDate: Sat Aug 4 23:25:31 2018 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=febc1b12 |
7 |
|
8 |
microcode: add flexability: type & initramfs control |
9 |
|
10 |
Bug reported that the MICROCODE option did not provide enough |
11 |
flexability, as it enabled both AMD & Intel options by default, and |
12 |
placed both sets of microcode into the initramfs. |
13 |
|
14 |
Existing boolean option MICROCODE is now a string, which takes |
15 |
no/all/amd/intel as inputs, describing which variant of kernel options |
16 |
to enable. Boolean inputs are converted to no/all settings. This option |
17 |
no longer include microcode in initramfs. |
18 |
|
19 |
New option MICROCODE_INITRAMFS, enabled by default, includes the |
20 |
microcode for matching kernel config options (INTEL/AMD) into the |
21 |
initramfs. For users using sys-boot/grub-2.02-r1 or another bootloader |
22 |
that supports multiple initramfs options, this option can be safely |
23 |
disabled. |
24 |
|
25 |
Fixes: https://bugs.gentoo.org/662492 |
26 |
Reported-by: Joerg Schaible <joerg.schaible <AT> gmx.de> |
27 |
Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org> |
28 |
|
29 |
gen_cmdline.sh | 18 +++++++++++++++--- |
30 |
gen_configkernel.sh | 18 ++++++++---------- |
31 |
gen_determineargs.sh | 11 ++++++++++- |
32 |
gen_initramfs.sh | 3 ++- |
33 |
genkernel.conf | 10 ++++++++-- |
34 |
5 files changed, 43 insertions(+), 17 deletions(-) |
35 |
|
36 |
diff --git a/gen_cmdline.sh b/gen_cmdline.sh |
37 |
index 3d9611f..853723b 100755 |
38 |
--- a/gen_cmdline.sh |
39 |
+++ b/gen_cmdline.sh |
40 |
@@ -98,8 +98,9 @@ longusage() { |
41 |
echo " --mdadm Include MDADM/MDMON support" |
42 |
echo " --no-mdadm Exclude MDADM/MDMON support" |
43 |
echo " --mdadm-config=<file> Use file as mdadm.conf in initramfs" |
44 |
- echo " --microcode Include early microcode support" |
45 |
- echo " --no-microcode Exclude early microcode support" |
46 |
+ echo " --microcode[=<type>] Include early microcode support, for 'all'/'amd'/'intel' CPU types" |
47 |
+ echo " --no-microcode Exclude early microcode support" |
48 |
+ echo " --microcode-initramfs Include early microcode in initramfs" |
49 |
echo " --nfs Include NFS support" |
50 |
echo " --no-nfs Exclude NFS support" |
51 |
echo " --dmraid Include DMRAID support" |
52 |
@@ -330,9 +331,20 @@ parse_cmdline() { |
53 |
print_info 2 "CMD_BUSYBOX: ${CMD_BUSYBOX}" |
54 |
;; |
55 |
--microcode|--no-microcode) |
56 |
- CMD_MICROCODE=`parse_optbool "$*"` |
57 |
+ case `parse_optbool "$*"` in |
58 |
+ 0) CMD_MICROCODE='no' ;; |
59 |
+ 1) CMD_MICROCODE='all' ;; |
60 |
+ esac |
61 |
print_info 2 "CMD_MICROCODE: ${CMD_MICROCODE}" |
62 |
;; |
63 |
+ --microcode=*) |
64 |
+ CMD_MICROCODE="${*#*=}" |
65 |
+ print_info 2 "CMD_MICROCODE: $CMD_MICROCODE" |
66 |
+ ;; |
67 |
+ --microcode-initramfs|--no-microcode-initramfs) |
68 |
+ CMD_MICROCODE_INITRAMFS=`parse_optbool "$*"` |
69 |
+ print_info 2 "CMD_MICROCODE_INITRAMFS: ${CMD_MICROCODE_INITRAMFS}" |
70 |
+ ;; |
71 |
--nfs|--no-nfs) |
72 |
CMD_NFS=`parse_optbool "$*"` |
73 |
print_info 2 "CMD_NFS: ${CMD_NFS}" |
74 |
|
75 |
diff --git a/gen_configkernel.sh b/gen_configkernel.sh |
76 |
index 697c478..475526a 100755 |
77 |
--- a/gen_configkernel.sh |
78 |
+++ b/gen_configkernel.sh |
79 |
@@ -277,17 +277,15 @@ config_kernel() { |
80 |
|
81 |
# Microcode setting, intended for early microcode loading |
82 |
# needs to be compiled in. |
83 |
- if isTrue ${MICROCODE} |
84 |
+ kconfig_microcode_intel=(CONFIG_MICROCODE_INTEL CONFIG_MICROCODE_INTEL_EARLY) |
85 |
+ kconfig_microcode_amd=(CONFIG_MICROCODE_AMD CONFIG_MICROCODE_AMD_EARLY) |
86 |
+ if [[ -n "${MICROCODE}" ]] |
87 |
then |
88 |
- for k in \ |
89 |
- CONFIG_MICROCODE \ |
90 |
- CONFIG_MICROCODE_INTEL \ |
91 |
- CONFIG_MICROCODE_AMD \ |
92 |
- CONFIG_MICROCODE_OLD_INTERFACE \ |
93 |
- CONFIG_MICROCODE_INTEL_EARLY \ |
94 |
- CONFIG_MICROCODE_AMD_EARLY \ |
95 |
- CONFIG_MICROCODE_EARLY \ |
96 |
- ; do |
97 |
+ kconfigs=(CONFIG_MICROCODE CONFIG_MICROCODE_OLD_INTERFACE CONFIG_MICROCODE_EARLY) |
98 |
+ [[ "$MICROCODE" == all ]] && kconfigs+=( ${kconfig_microcode_amd[@]} ${kconfig_microcode_intel[@]} ) |
99 |
+ [[ "$MICROCODE" == amd ]] && kconfigs+=( ${kconfig_microcode_amd[@]} ) |
100 |
+ [[ "$MICROCODE" == intel ]] && kconfigs+=( ${kconfig_microcode_intel[@]} ) |
101 |
+ for k in "${kconfigs[@]}" ; do |
102 |
cfg=$(kconfig_get_opt "${KERNEL_OUTPUTDIR}/.config" "$k") |
103 |
case "$cfg" in |
104 |
y) ;; # Do nothing |
105 |
|
106 |
diff --git a/gen_determineargs.sh b/gen_determineargs.sh |
107 |
index b686fca..bd0150a 100755 |
108 |
--- a/gen_determineargs.sh |
109 |
+++ b/gen_determineargs.sh |
110 |
@@ -121,7 +121,8 @@ determine_real_args() { |
111 |
set_config_with_override BOOL HYPERV CMD_HYPERV |
112 |
set_config_with_override BOOL BUSYBOX CMD_BUSYBOX "yes" |
113 |
set_config_with_override BOOL NFS CMD_NFS "yes" |
114 |
- set_config_with_override BOOL MICROCODE CMD_MICROCODE |
115 |
+ set_config_with_override STRING MICROCODE CMD_MICROCODE "all" |
116 |
+ set_config_with_override BOOL MICROCODE_INITRAMFS CMD_MICROCODE_INITRAMFS "yes" |
117 |
set_config_with_override BOOL UNIONFS CMD_UNIONFS |
118 |
set_config_with_override BOOL NETBOOT CMD_NETBOOT |
119 |
set_config_with_override STRING REAL_ROOT CMD_REAL_ROOT |
120 |
@@ -234,5 +235,13 @@ determine_real_args() { |
121 |
INTEGRATED_INITRAMFS=0 |
122 |
fi |
123 |
|
124 |
+ MICROCODE=${MICROCODE,,} |
125 |
+ case ${MICROCODE} in |
126 |
+ all|amd|intel) ;; |
127 |
+ y|yes|1|true|t) MICROCODE='all' ;; |
128 |
+ n|no|none|0|false|f) MICROCODE='' ;; |
129 |
+ *) gen_die "Invalid microcode '${MICROCODE}', --microcode=<type> requires one of: no, all, intel, amd" ;; |
130 |
+ esac |
131 |
+ |
132 |
get_KV |
133 |
} |
134 |
|
135 |
diff --git a/gen_initramfs.sh b/gen_initramfs.sh |
136 |
index 768f291..a2c55c6 100755 |
137 |
--- a/gen_initramfs.sh |
138 |
+++ b/gen_initramfs.sh |
139 |
@@ -1149,7 +1149,8 @@ create_initramfs() { |
140 |
## It only loads monolithic ucode from an uncompressed cpio, which MUST |
141 |
## be before the other cpio archives in the stream. |
142 |
cfg_CONFIG_MICROCODE=$(kconfig_get_opt "${KERNEL_OUTPUTDIR}"/.config CONFIG_MICROCODE) |
143 |
- if isTrue "${MICROCODE}" && [ "${cfg_CONFIG_MICROCODE}" == "y" ]; then |
144 |
+ if isTrue "${MICROCODE_INITRAMFS}" && [ "${cfg_CONFIG_MICROCODE}" == "y" ]; then |
145 |
+ print_info 1 "--microcode-initramfs is enabled by default for compatability but made obsolete by sys-boot/grub-2.02-r1" |
146 |
cfg_CONFIG_MICROCODE_INTEL=$(kconfig_get_opt "${KERNEL_OUTPUTDIR}"/.config CONFIG_MICROCODE_INTEL) |
147 |
cfg_CONFIG_MICROCODE_AMD=$(kconfig_get_opt "${KERNEL_OUTPUTDIR}"/.config CONFIG_MICROCODE_AMD) |
148 |
print_info 1 "early-microcode: >> Preparing..." |
149 |
|
150 |
diff --git a/genkernel.conf b/genkernel.conf |
151 |
index 5e5a67b..57cb2b0 100644 |
152 |
--- a/genkernel.conf |
153 |
+++ b/genkernel.conf |
154 |
@@ -74,8 +74,14 @@ USECOLOR="yes" |
155 |
# Add in GnuPG support |
156 |
#GPG="no" |
157 |
|
158 |
-# Add in early microcode support |
159 |
-#MICROCODE="no" |
160 |
+# Add in early microcode support: this sets the kernel options for early microcode loading |
161 |
+# Acceptible values: empty/"no", "all", "intel", "amd" |
162 |
+#MICROCODE="all" |
163 |
+ |
164 |
+# Include early microcode in generated initramfs |
165 |
+# This is enabled by default for upgrade compatability, however is obsoleted by |
166 |
+# sys-boot/grub-2.02-r1, which supports multiple initramfs in the bootloader. |
167 |
+#MICROCODE_INITRAMFS="no" |
168 |
|
169 |
# Add in NFS support |
170 |
#NFS="no" |