FS#76390 - [memtest86+-efi] cannot boot EFI through systemd-boot

Attached to Project: Arch Linux
Opened by mattia (nTia89) - Wednesday, 02 November 2022, 17:16 GMT
Last edited by Toolybird (Toolybird) - Friday, 10 February 2023, 20:46 GMT
Task Type Bug Report
Category Packages: Extra
Status Closed
Assigned To No-one
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 2
Private No

Details

Description:
even if version 6 of memtest86+ sports an EFI compatibility,
I cannot boot it via systemd-boot.


Additional info:
* memtest86+-efi-6.00-2
* systemd-251.7-1

Steps to reproduce:
- install `memtest86+-efi`
- create a .conf file under `/boot/loader/entries/` , containing these lines:
"title Memory Tester (memtest86+)
efi /memtest86+/memtest.efi"
- boot this new entry
- it results in a blank black screen
This task depends upon

Closed by  Toolybird (Toolybird)
Friday, 10 February 2023, 20:46 GMT
Reason for closing:  Fixed
Additional comments about closing:  memtest86+-efi 6.10-1
Comment by Andreas Radke (AndyRTR) - Wednesday, 02 November 2022, 17:45 GMT
It works for me booting the grub entry here. Make sure to recreate the grub config after installation.
Comment by mattia (nTia89) - Wednesday, 02 November 2022, 17:52 GMT
That it works is good: it is a systemd-boot issue.

Any ideas about why it does not work with systemd-boot?
Comment by Andreas Radke (AndyRTR) - Wednesday, 02 November 2022, 17:58 GMT
It should work from this: https://github.com/memtest86plus/memtest86plus/discussions/96

Maybe file a github issue to check whether it's a configuration/systemd-boot or memtest issue.
Comment by mattia (nTia89) - Wednesday, 02 November 2022, 19:11 GMT
Thanks for this resource!
Since I have done my self exactly what they did but with no results, it deserves a deeper analysis.

I'll be back here as soon as I have a good answer to my issue...
Comment by Jan (medhefgo) - Monday, 07 November 2022, 17:15 GMT
This works for me in VM and on real hardware, so it's likely an issue with your firmware. Easiest way to make sure is to try starting memtest through EFI shell.

The most likely cause it that your firmware is tripping over the PE optional header being too small (sbverify doesn't like this binary because of this). grub might be employing its own PE loader instead of using the firmware LoadImage (that's my best guess).

You can also try creating a fixed binary with objcopy and boot that instead:
$ objcopy /boot/memtest86+/memtest.efi /boot/memtest86+/memtest-fixed.efi
Comment by mattia (nTia89) - Tuesday, 08 November 2022, 16:20 GMT
You are right!

with your command:
$ sudo objcopy memtest.efi memtest-fixed.efi

I can boot the "fixed" binary.

PS: I am not an expert in this field but this can be a proof...
$ file /boot/memtest86+/*
/boot/memtest86+/memtest.efi: Linux kernel x86 boot executable bzImage, version \353fHdrS\014\002, RW-rootFS,
/boot/memtest86+/memtest-fixed.efi: PE32+ executable (EFI application) x86-64 (stripped to external PDB), for MS Windows
Comment by Jan (medhefgo) - Tuesday, 08 November 2022, 17:00 GMT
You should report this upstream then.

The output of file explains why it works with grub. They use the same trick the kernel efi stub uses: the binary is both a regular bzImage and a efi binary (the necessary info doesn't overlap if done correctly). And grub uses the kernel x86 boot protocol to boot this image, while sd-boot is using the PE loader from the firmware, which trips up on this. (In theory you could load this by wrapping it in a sd-stub image, but the sd-stub bzImage loader expects a relocatable image and the memtest image is not marked as such.)
Comment by mattia (nTia89) - Tuesday, 08 November 2022, 17:42 GMT
Reported in the discussion above-mentioned
Comment by Jan (medhefgo) - Tuesday, 08 November 2022, 17:58 GMT
Gee, github discussions are not issue reports.

https://github.com/memtest86plus/memtest86plus/issues/202
Comment by mattia (nTia89) - Tuesday, 08 November 2022, 18:01 GMT
Thanks Jan! You are super-efficient!
Comment by Andreas Radke (AndyRTR) - Tuesday, 24 January 2023, 19:55 GMT
Please recheck 6.0.1 out now.
Comment by mattia (nTia89) - Tuesday, 24 January 2023, 20:14 GMT
No, v6.01 does not fix the issue
Comment by mattia (nTia89) - Friday, 10 February 2023, 19:39 GMT
Fixed upstream with version 6.10