kernel: kernel_boot reads microcode from each initramfs image (issue 1977, L6)
Replaces the state record read (root's 0700) with images_with_microcode per /boot/initramfs-*.img: true when the first 64 KiB hold a path under kernel/x86/microcode/; an unreadable image goes to image_errors with its error. Test: 1977/AC5. Builds: L6 (issue 1977 note 3)
This commit is contained in:
@@ -123,15 +123,28 @@ func TestAC4AFailedMkinitcpioFailsTheUnitAndRecordsNothing(t *testing.T) {
|
||||
}
|
||||
|
||||
// 1977/AC5
|
||||
func TestAC5KernelBootNamesTheRunningMicrocodeAndWhetherTheImagesCarryTheDropIn(t *testing.T) {
|
||||
func TestAC5KernelBootNamesTheRunningMicrocodeAndWhichImagesCarryIt(t *testing.T) {
|
||||
root := t.TempDir()
|
||||
put(t, root, "proc/cpuinfo", "processor\t: 0\nmicrocode\t: 0x0a201016\nmodel name\t: x\n")
|
||||
put(t, root, "etc/mkinitcpio.conf.d/mesh-microcode.conf", "HOOKS+=(microcode)\n")
|
||||
if got := bootOf(t, root); got.MicrocodeRevision != "0x0a201016" || got.ImagesBuiltWithMicrocode {
|
||||
t.Fatalf("no record: %+v", got)
|
||||
// a stand-in early cpio: a name field, then padding, as the first member of an initramfs.
|
||||
put(t, root, "boot/initramfs-linux.img", "070701000000kernel/x86/microcode/AuthenticAMD.bin\x00\x00"+strings.Repeat("z", 100))
|
||||
put(t, root, "boot/initramfs-linux-lts.img", "070701000000early/other.bin\x00"+strings.Repeat("z", 100))
|
||||
got := bootOf(t, root)
|
||||
if got.MicrocodeRevision != "0x0a201016" || len(got.ImagesWithMicrocode) != 2 ||
|
||||
!got.ImagesWithMicrocode["initramfs-linux.img"] || got.ImagesWithMicrocode["initramfs-linux-lts.img"] || len(got.ImageErrors) != 0 {
|
||||
t.Fatalf("%+v", got)
|
||||
}
|
||||
put(t, root, "var/lib/mesh-kernel/initramfs-built", "HOOKS+=(microcode)\n")
|
||||
if got := bootOf(t, root); got.MicrocodeRevision != "0x0a201016" || !got.ImagesBuiltWithMicrocode {
|
||||
t.Fatalf("recorded: %+v", got)
|
||||
if os.Getuid() == 0 {
|
||||
t.Skip("root reads an unreadable file")
|
||||
}
|
||||
bad := filepath.Join(root, "boot/initramfs-linux-fallback.img")
|
||||
put(t, root, "boot/initramfs-linux-fallback.img", "x")
|
||||
if err := os.Chmod(bad, 0); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
got = bootOf(t, root)
|
||||
if _, in := got.ImagesWithMicrocode["initramfs-linux-fallback.img"]; in || len(got.ImageErrors) != 1 ||
|
||||
got.ImageErrors[0].Image != "initramfs-linux-fallback.img" || got.ImageErrors[0].Error == "" {
|
||||
t.Fatalf("unreadable: %+v", got)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user