-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
add infrastructure for x86 CPU microcode updates #4348
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
This change adds the infrastructure to enable early application of CPU microcodes for the generic-x86_64 platform once the BR2_PACKAGE_INTEL_MICROCODE or BR2_PACKAGE_LINUX_FIRMWARE_AMD_UCODE options are enabled. Once enabled a kconfig fragment will be generated which will then dynamically add CONFIG_EXTRA_FIRMWARE option to the kernel config for embedding all microcode files accordingly. This should help to get CPU microcode fixes in place once HAos is directly installed on a x86-64 system using the generic-x86_64 platform images.
📝 WalkthroughWalkthroughEnables Intel and AMD microcode packages in x86_64 defconfig, adds build logic to generate a kernel Kconfig fragment that embeds microcode when enabled, hooks it into the kernel pre-patch/config steps, and updates the rootfs script to remove microcode directories from the final image. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant BR as Buildroot
participant EXT as external.mk
participant LNX as Kernel Build
participant RFS as rootfs-layer.sh
BR->>EXT: Evaluate config (INTEL_MICROCODE / AMD_UCODE)
alt Microcode enabled
EXT->>EXT: Generate UCODE_FRAG (list firmware dirs/files)
note over EXT: Registered via LINUX_PRE_PATCH_HOOKS
EXT-->>LNX: Add fragment to LINUX_KCONFIG_FRAGMENT_FILES
else
EXT-->>LNX: No fragment added
end
rect rgba(230,240,255,0.5)
LNX->>LNX: Apply Kconfig fragments
LNX->>LNX: Build kernel (with embedded microcode if configured)
end
BR->>RFS: Run rootfs fix-up
RFS->>RFS: Remove lib/firmware/intel-ucode, amd-ucode
note over RFS: Ensures microcode not present in rootfs
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge base: Disabled due to data retention organization setting
📒 Files selected for processing (3)
buildroot-external/configs/generic_x86_64_defconfig(1 hunks)buildroot-external/external.mk(1 hunks)buildroot-external/scripts/rootfs-layer.sh(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
*/**(html|markdown|md)
⚙️ CodeRabbit configuration file
*/**(html|markdown|md): - For instructional content in documentation, use a direct and authoritative tone. Avoid expressions of politeness such as 'may' or 'please', and ensure the goal of the instruction is fronted.
- Apply the Microsoft Style Guide to ensure documentation maintains clarity and conciseness.
- In step-by-step instructions, front the location phrase in the instructional sentence.
- In step-by-step instructions, front the 'goal' in the instructional sentence.
- In step-by-step instructions, if in doubt what to front, front the 'goal' before the location phrase in the instructional sentence.
- do not hyphenate terms like 'top-right' or 'bottom-left' with 'corner'
*/**(html|markdown|md): - Use bold to mark UI strings.
If "" are used to mark UI strings, replace them by bold.
Be brief in your replies and don't add fluff like "thank you for..." and "Please let me know if"
Use sentence-style capitalization also in headings.
do not comment on HTML used for icons
Avoid flagging inline HTML for embedding videos in future reviews for this repository.
Files:
buildroot-external/external.mk
🔇 Additional comments (2)
buildroot-external/scripts/rootfs-layer.sh (1)
42-45: LGTM! Cleanup aligns with kernel embedding strategy.The removal of microcode directories is correct since the microcode is now embedded into the kernel via
CONFIG_EXTRA_FIRMWARE(as implemented in external.mk), making these firmware files in the rootfs redundant.buildroot-external/configs/generic_x86_64_defconfig (1)
105-106: LGTM! Package enablement is correctly placed.The AMD and Intel microcode packages are appropriately enabled and positioned after other firmware packages, following the existing configuration structure.
|
@sairon Any news of and when this PR might be integrated/merged? Would be great to get it potentially merged into 16.3! |
|
@jens-maus I intentionally postponed it after the 16.3 beta cut to stage it for the 17.0 release. I will have a closer look later this week. |
|
Thanks! Note, that I have this already integrated in two of my Buildroot projects and it works flawlessly so far! 😜 |
sairon
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Besides the formal or factual issues commented below, I don't like this being added in external.mk - per Buildroot docs external.mk should serve to define package recipes, yet this is fundamentally changing the build results. Looking into the docs, infrastructure described in docs/manual/adding-packages-linux-kernel-spec-infra.adoc might be more appropriate but honestly I haven't thought it through yet.
Also, IMHO the in-situ generated config fragment isn't a nice pattern either. It might be better to use KCONFIG_SET_OPT along with LINUX_KCONFIG_FIXUP_CMDS instead.
| BR2_PACKAGE_LINUX_FIRMWARE_RTL_815X=y | ||
| BR2_PACKAGE_LINUX_FIRMWARE_RTL_8169=y | ||
| BR2_PACKAGE_LINUX_FIRMWARE_USB_SERIAL_TI=y | ||
| BR2_PACKAGE_LINUX_FIRMWARE_AMD_UCODE=y |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This config option doesn't exist yet in 2025.02.x.
|
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
Co-authored-by: Jan Čermák <[email protected]>
Co-authored-by: Jan Čermák <[email protected]>
|
Thanks @sairon for your review. When I was first working on this PR I also thought if there might be a better idea than adding these things to Regarding the missing |
This PR adds the infrastructure to enable early application of CPU microcodes for the generic-x86_64 platform once the
BR2_PACKAGE_INTEL_MICROCODEorBR2_PACKAGE_LINUX_FIRMWARE_AMD_UCODEoptions are enabled. Once enabled a kconfig fragment will be generated which will then dynamically addCONFIG_EXTRA_FIRMWAREoption to the kernel config for embedding all microcode files accordingly. This should help to get CPU microcode fixes in place once HAos is directly installed on a x86-64 system using the generic-x86_64 platform images.Summary by CodeRabbit