-
Notifications
You must be signed in to change notification settings - Fork 32
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
uki: Add .ucode section #98
Conversation
This documents the `.ucode` section implemented in systemd/systemd#31872, see there for most details. It is relatively straightforward, just an initrd that is guaranteed to be handed to the kernel first.
LGTM too. We might want to add some details here, but it's good to merge the short description too. |
Uh, was about to reply here. So I was wondering what the goal is with multiple microcode files, i.e. kernel only looks in the first initrd for microcode, hence we cannot just paste together microcode cpios like we paste together regular initrd cpios. Hence, if there's an add-on with a .ucode file, and an embedded UKI, what's the strategy this should be handled in? We could say:
Opinions? |
@tfg13 I think you were going to submit another PR here to specify the exact mechanics of microcode addons. See Lennart's comments for all that needs to be taken into account |
So i think right now, most distros generate a single cpio of both intel and amd microcode when updating initrds, right? i.e. rpms/debs ship unpacked firmware, and it's the initrd generator that turns this into a cpio, right? |
I think the spec should say that .ucode should not be compressed (and maybe conversely that .initrd typically is compressed). (iirc, that's how this works in the kernel, right? microcode cpios should not be compressed, but real initrds should be) |
From looking around, this seems mostly true:
For the cpio generation:
I suppose this means we can get away with only supporting one ucode image. So we just have to resolve the embedded ucode vs. addon file conflict. That would point to option 1. Does this make sense to people?
Correct, I just added a comment in the stub-pr, can add a similar one here.
That is what https://www.kernel.org/doc/html/next/x86/microcode.html says at least |
I really think this statement requires proof. Everything I've found on this says otherwise: archiso happily passes |
You are correct, I just tested it. The kernel happily loads microcode from the second (uncompressed) initrd. I also confirmed it cannot see the microcode if it is placed after a compressed image. |
@poettering do you have opinions where this leaves us wrt to this discussion? Turns out the kernel will load ucode from initrds other than the first, unless they are after another compressed initrd. Since the "primary" initrd is likely compressed, I think the main idea behind this new section still makes sense. I am still leaning towards keeping things simple (for now?) and only doing one ucode section. However, there doesn't seem to be a fundamental reason why we can't allow multiple (in the future?) - we don't need to mess with the cpio in the stub or require them to be special formats, the normal concatenation will work fine. |
Early draft of implementing addons with the "just one gets passed" policy: tfg13/systemd#2 After writing the code, I would also be open to doing multiple ucode initrds right away - it might actually simplify the code, the version with only one has some dancing with the measurements that seems a bit fragile longer term (I decided to only measure the one that actually gets passed to the kernel, not sure that is correct (but not super important for the policy discussion)). |
So, did I understand this this right, you verified the kernel logic basically reads microcode from any of the the initrds passed, except that it stops when it hits the first compressed initrd? If it's easy I'd probably actually say:
|
hmm, what actually happens if a cpio archive contains some microcode file X and a later cpio contains the very same file X on the same path? My understanding is that:
That's very confusing I guess. But I guess no up to us, but simply kernel behaviour? |
Correct.
Correct. I just checked again, it only cares about the first match, here: https://github.com/torvalds/linux/blob/2668e3ae2ef36d5e7c52f818ad7d90822c037de4/arch/x86/kernel/cpu/microcode/core.c#L218
Yes that is my understanding. |
Sure, I can do that. Will rework the draft addon PR. (this doesn't change systemd/systemd#31872) |
Implemented in systemd/systemd#32463 Note I changed the order from what was discussed here:
to
This was done because both cmdline and devicetree use this order, I think it makes more sense (one can put an addon file to change what a (distro-) supplied UKI does, and it greatly simplifies the measurement code (I have more confidence in it being correct). |
This documents the
.ucode
section implemented in systemd/systemd#31872, see there for most details.It is relatively straightforward, just an initrd that is guaranteed to be handed to the kernel first.