Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 923029

Summary: genkernel forces CONFIG_MICROCODE INTEL AND AMD microcode loading options
Product: Gentoo Hosted Projects Reporter: yves.caniou
Component: genkernelAssignee: Gentoo Genkernel Maintainers <genkernel>
Status: UNCONFIRMED ---    
Severity: normal CC: bkohler, hjckr, xdudka00, yves.caniou
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
See Also: https://bugs.gentoo.org/show_bug.cgi?id=913659
Whiteboard:
Package list:
Runtime testing required: ---
Attachments: Kernel config file example for 4.19.270 kernel version

Description yves.caniou 2024-01-27 13:52:24 UTC
This bug is a total duplicate of the initial bug https://bugs.gentoo.org/913659 that has been renamed after I posted it, and been told to open.



I updated genkernel to 4.3.10.
Compiling kernel 4 19 306, there is still the error, first of this post that has since been renamed:

x86_64-pc-linux-gnu-ld: arch/x86/kernel/cpu/common.o: in function `microcode_check':
(.text+0x14ae): undefined reference to `amd_check_microcode'
make: *** [Makefile:1066: vmlinux] Error 1

due to the addition of AMD when it is not required/wanted :

 >> Ensure that required kernel options for early microcode loading support are set ...
*                  - Option 'CONFIG_MICROCODE=y' already set in '/usr/src/linux/.config'; Skipping ...
*                  - Setting option 'CONFIG_MICROCODE_AMD' to 'y' in '/usr/src/linux/.config'...
*                  - Option 'CONFIG_MICROCODE_INTEL=y' already set in '/usr/src/linux/.config'; Skipping ...

In /etc/genkernel.conf, I have :
# Possible values: empty/"no", "all", "intel", "amd"
#MICROCODE="all"
so nothing/no check should be done by default, with no unwanted addition.
Why would genkernel behave like "all" was set, and force things? Empty/"no" should lead to only what has been configured in the kernel.

One have to set explicitly (for example)
MICROCODE="intel"
to expect a full error-free compilation, with only this configured (if /usr/src/.config hasn't AMD microcode set actually).

And in this case, there should be more to do since genkernel overpass the configuration done in /usr/src/.config: setting 
MICROCODE="intel"
should actually also disable CONFIG_MICROCODE_AMD in /usr/src/linux/.config, which is not done (genkernel sets it when MICROCODE is not defined in /etc/genkernel.conf, but does not unset it when MICROCODE is set to "intel").
Comment 1 Ben Kohler gentoo-dev 2024-01-30 14:00:59 UTC
(In reply to yves.caniou from comment #0)
> 
> In /etc/genkernel.conf, I have :
> # Possible values: empty/"no", "all", "intel", "amd"
> #MICROCODE="all"
> so nothing/no check should be done by default, with no unwanted addition.
> Why would genkernel behave like "all" was set, and force things? Empty/"no"
> should lead to only what has been configured in the kernel.
> 

The commented line there tells what the default is, "all".  The default is defined here:
https://gitweb.gentoo.org/proj/genkernel.git/tree/gen_determineargs.sh#n431

Can you share your kernel config which is causing failure out of the box with the defaults?
Comment 2 yves.caniou 2024-02-03 17:13:21 UTC
Created attachment 884147 [details]
Kernel config file example for 4.19.270 kernel version
Comment 3 yves.caniou 2024-02-03 17:15:01 UTC
(In reply to Ben Kohler from comment #1)
> (In reply to yves.caniou from comment #0)
> > 
> > In /etc/genkernel.conf, I have :
> > # Possible values: empty/"no", "all", "intel", "amd"
> > #MICROCODE="all"
> > so nothing/no check should be done by default, with no unwanted addition.
> > Why would genkernel behave like "all" was set, and force things? Empty/"no"
> > should lead to only what has been configured in the kernel.
> > 
> 
> The commented line there tells what the default is, "all".  The default is
> defined here:
> https://gitweb.gentoo.org/proj/genkernel.git/tree/gen_determineargs.sh#n431

> Can you share your kernel config which is causing failure out of the box
> with the defaults?

- I join a a kernel config file for 4.19.279 version.
If you download the corresponding kernel, copy this file as .config and run genkernel --no-clean --no-zfs --save-config --luks all
it compiles well.
You can see that the file has both intel and AMD microcode options (actually set by genkernel).

Using the same config file for 4.19.306 kernel leads to 
x86_64-pc-linux-gnu-ld: arch/x86/kernel/cpu/common.o: in function `microcode_check'
undefined reference to `amd_check_microcode'

- As written previously, I don't really get why the unset is defaulted to all. MICROCODE could be explicitly set defaulted to all in the config file in that case, which is more expressive.
Also, to my opinion, MICROCODE="intel" should unset AMD microcode option from the config file (same with AMD and intel of course).
Comment 4 yves.caniou 2024-02-03 17:16:05 UTC
Typo:
- I join a a kernel config file for 4.19.279 version.
-----> - I join a a kernel config file for 4.19.270 version.
Comment 5 Nikolay Kichukov 2024-04-12 08:55:32 UTC
I can second this issue, where if one decides to disable CONFIG_CPU_SUP_INTEL=y because they run their kernel on AMD, genkernel reverts it by default, essentially modifying the user kernel configuration. It not only re-adds CONFIG_CPU_SUP_INTEL, but also all of its dependencies, so the list grows for a non-intel build.

Took me a while to realize I had to feed a genkernel option to avoid it modify my kernel configuration, --microcode=amd in my case.

Noticed it by looking in dmesg for something else when I noticed:

[    0.000000] KERNEL supported cpus:
[    0.000000]   Intel GenuineIntel
[    0.000000]   AMD AuthenticAMD

and I new I've turned intel off long time ago... well, only to realize it has resurfaced... now it is gone for good.

I'd rather had genkernel complain(and fail if needed) that I mixed --microcode=all with a missing CONFIG_CPU_SUP_INTEL=y option than have it silently modify my configuration.
Comment 6 Nikolay Kichukov 2024-04-12 09:27:38 UTC
and just before I have forgotten, the resulting kernel, system map and initrd files are smaller:

old, amd and intel:
-rwxr-xr-x 1 root root 4.4M Apr 11 13:34 /boot/System.map-6.8.5-gentoo-x86_64.old
-rwxr-xr-x 1 root root 8.6M Apr 11 13:34 /boot/vmlinuz-6.8.5-gentoo-x86_64.old
-rwxr-xr-x 1 root root 5.8M Apr 11 13:38 /boot/initramfs-6.8.5-gentoo-x86_64.img.old

new, without intel:
-rwxr-xr-x 1 root root 2.6M Apr 12 11:43 /boot/System.map-6.8.5-gentoo-x86_64
-rwxr-xr-x 1 root root 7.9M Apr 12 11:43 /boot/vmlinuz-6.8.5-gentoo-x86_64
-rwxr-xr-x 1 root root 5.7M Apr 12 11:46 /boot/initramfs-6.8.5-gentoo-x86_64.img