nix-community / lanzaboote

Secure Boot for NixOS [maintainers=@blitz @raitobezarius @nikstur]
GNU General Public License v3.0
878 stars 45 forks source link

Not able to boot any generation on Surface Laptop 5 with secure boot #395

Open TimoVerbrugghe opened 5 days ago

TimoVerbrugghe commented 5 days ago

Big thanks already for all the work done here :).

My setup:

Currently able to load bootloader in secure boot, but not able to boot any generation that I select (the auto detected windows 11 entry does boot). If I select a nixos generation, screen goes black for a few seconds, then the boot menu comes up again.

Information below, anything else you want me to add in terms of logs?

Steps I've taken:

Bootctl status output:

[timo@timo-surface-nixos:/etc/secureboot]$ bootctl status
System:
      Firmware: UEFI 2.70 (EDK II 1.00)
 Firmware Arch: x64
   Secure Boot: disabled (setup)
  TPM2 Support: yes
  Measured UKI: yes
  Boot into FW: supported

Current Boot Loader:
      Product: systemd-boot 255.9
     Features: ✓ Boot counting
               ✓ Menu timeout control
               ✓ One-shot menu timeout control
               ✓ Default entry control
               ✓ One-shot entry control
               ✓ Support for XBOOTLDR partition
               ✓ Support for passing random seed to OS
               ✓ Load drop-in drivers
               ✓ Support Type #1 sort-key field
               ✓ Support @saved pseudo-entry
               ✓ Support Type #1 devicetree field
               ✓ Enroll SecureBoot keys
               ✓ Retain SHIM protocols
               ✓ Menu can be disabled
               ✓ Boot loader sets ESP information
         Stub: lanzastub 0.4.1
     Features: ✓ Stub sets ESP information
               ✗ Picks up credentials from boot partition
               ✗ Picks up system extension images from boot partition
               ✗ Measures kernel+command line+sysexts
               ✗ Support for passing random seed to OS
               ✗ Pick up .cmdline from addons
               ✗ Pick up .cmdline from SMBIOS Type 11
               ✗ Pick up .dtb from addons
          ESP: /dev/disk/by-partuuid/38ec6b10-0153-42ca-bec6-81bcc55aec93
         File: └─/EFI/systemd/systemd-bootx64.efi

Random Seed:
 System Token: set
       Exists: yes

Available Boot Loaders on ESP:
          ESP: /boot (/dev/disk/by-partuuid/38ec6b10-0153-42ca-bec6-81bcc55aec93)
         File: ├─/EFI/systemd/systemd-bootx64.efi (systemd-boot 255.9)
               └─/EFI/BOOT/bootx64.efi (systemd-boot 255.9)

Boot Loaders Listed in EFI Variables:
        Title: Linux Boot Manager
           ID: 0x0005
       Status: active, boot-order
    Partition: /dev/disk/by-partuuid/38ec6b10-0153-42ca-bec6-81bcc55aec93
         File: └─/EFI/systemd/systemd-bootx64.efi

        Title: Windows Boot Manager
           ID: 0x0004
       Status: active, boot-order
    Partition: /dev/disk/by-partuuid/38ec6b10-0153-42ca-bec6-81bcc55aec93
         File: └─/EFI/Microsoft/Boot/bootmgfw.efi

Boot Loader Entries:
        $BOOT: /boot (/dev/disk/by-partuuid/38ec6b10-0153-42ca-bec6-81bcc55aec93)
TimoVerbrugghe commented 5 days ago

Dump of PK, KEK & db files from /sys/firmware/efi/efivars/... at the request of @RaitoBezarius

PK: https://pastebin.com/e1q6NPU7 db: https://pastebin.com/LayiAD4V KEK: https://pastebin.com/Tgs6RFz3

TimoVerbrugghe commented 5 days ago

For additional context, just tried by manually adding Preloader.efi & HashTool.efi to my boot partition, copying systemd-bootx64.efi to loader.efi and then adding the hashes using HashTool.efi

This only worked when I added both the hashes of loader.efi & the hash of initrd in /boot/EFI/nixos/initrd... so I could boot. This did work and I can boot with secureboot into nixos this way (however I would have to readd every nixos generation I build using HashTool.efi this way)

I believe lanzaboote creates efi stubs in /boot/EFI/Linux which include a hash of the initrd efi file, but don't know if there is something wrong going on there?