Skip to content

Check table version before calling UEFI 2.0+ functions #436

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

Merged
merged 2 commits into from
May 30, 2022

Conversation

nicholasbishop
Copy link
Member

The create_event_ex function (in boot services) and query_variable_info (in runtime services) were added to their respective tables in UEFI 2.0. In earlier versions these functions can't be called, so check the table revision before using these function pointers.

@nicholasbishop nicholasbishop force-pushed the bishop-check-rev branch 2 times, most recently from c3e6f73 to b3fe281 Compare May 24, 2022 22:02
@namazso
Copy link

namazso commented May 29, 2022

What platform is this relevant for? EFI 1.10 (the last EFI) only supports ia32 and ia64. ia64 is not supported by Rust or LLVM, and I don't know of a single 32-bit x86 device that uses EFI 1.10 or older. Also the crate is called uefi and not efi, so I'd assume requiring UEFI is reasonable.

@nicholasbishop
Copy link
Member Author

nicholasbishop commented May 29, 2022

What platform is this relevant for? EFI 1.10 (the last EFI) only supports ia32 and ia64. ia64 is not supported by Rust or LLVM, and I don't know of a single 32-bit x86 device that uses EFI 1.10 or older. Also the crate is called uefi and not efi, so I'd assume requiring UEFI is reasonable.

Unfortunately some x86_64 machines use the ia32 mode of UEFI (for example some Intel Compute Sticks). The specific machines I had in mind with this change though are old (but not that old) Apple machines, which were stuck on EFI 1.10 for a long time. See torvalds/linux@f5390cd for example.

@namazso
Copy link

namazso commented May 29, 2022

Unfortunately some x86_64 machines use the ia32 mode of UEFI (for example some Intel Compute Sticks).

I knew about those, but they're all UEFI already, not stuck on EFI

The specific machines I had in mind with this change though are old Apple machines, which were stuck on EFI 1.10 for a long time. See torvalds/linux@f5390cd for example.

I see. The mentioned Linux patch disables using 2.0 features on Apple hardware even when they're reported as supported. Should this be replicated here too then? As from what I understand without this the single platform this patch targets still won't work.

@nicholasbishop
Copy link
Member Author

nicholasbishop commented May 29, 2022

Oops, I somehow edited your comment instead of replying, sorry about that. I believe I have restored your comment to its original form :)


The mentioned Linux patch disables using 2.0 features on Apple hardware even when they're reported as supported. Should this be replicated here too then? As from what I understand without this the single platform this patch targets still won't work.

For older Macs that report 1.10 this change will work fine, but you are right that for the MacBookPro16,1 described here it will still be broken. I don't think we have a way to check for system vendor here currently though.

Copy link
Collaborator

@GabrielMajeri GabrielMajeri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything looks fine now 👍

Add constants for all the EFI versions (from section 4.3 "EFI System
Table"). Also make the new/major/minor methods of Revision const.
The create_event_ex function (in boot services) and query_variable_info
(in runtime services) were added to their respective tables in UEFI
2.0. In earlier versions these functions can't be called, so check the
table revision before using these function pointers.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants