-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Add support for 64-bit machines with 32-bit UEFI implementations #1098
base: main
Are you sure you want to change the base?
Conversation
Cant reproduce build errors locally. |
Clang seems to ignore -Wint-to-pointer-cast and -Wpointer-to-int-cast when -m32 is specified. |
This makes it easier for me to look at this and to have a conversation. I got too busy last time and naybe this way we'll keep momentum. |
94f816b
to
2c0413d
Compare
Fixed. |
Fixed rsdp cast |
OK. I've ordered an inexpensive laptop to see if I can use it to test this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's get started at breaking this down into smaller chunks, but I think we can do that as a series of commits. Remember to git push --force-with-lease
to update the changes and to rebase forward please. Thanks!
Alright, I split everything into a total of 5 commits:
I put LOADER_IA32 on its own since it doesn't really fit with adding libefi32. Of course, let me know if you want any of these reverted, thanks! |
I'll take a look at this. |
Yea, thats how I did it |
Just a little cleanup: Use NULL instead of 0. |
I'll try to get to this before we have the 14.1 freeze. |
Great :) |
I've changed all of the Also, thers a typo at https://github.com/freebsd/freebsd-src/blob/main/stand/liblua/lutils.h#L37 and I have no idea why it causes the 32-bit loader to crash, but not the 64-bit one, probably some linker weirdness. Edit: Oh, I didn't realize I had to request a review manually. |
I thought I'd fixed that typo... It should make it not compile at all.. |
Wouldn't it just make a set called As long as the set isn't accessed outside the macros, there shouldn't be any problems |
I was actually interested in finding out why it only crashed on the 32-bit loader, turns out its fairly straightforward. With the 32-bit loader, the addend is expected to be present in the Ah, also, while looking into this I noticed that the i386 script I re-added wasn't up to date with d024bc7, I'll check the rest of the script and push a fix soon. |
Pushed the changes that aren't being discussed / that I don't have questions about. |
This can be useful when making alternate versions of the loader. Reviewed by: imp Pull Request: #1098
Prevent G(4) and over from overflowing for 32-bit builds. Reviewed by: imp Pull Request: #1098
OK. I landed a little bit of this PR, and updated the PR to rebase it and resolve the conflicts that I created due to minor tweaking I did. Hope that doesn't mess up any other WIP around this. |
Okay, a lot of changes this time. Hopefully I don't forget anything. We can't get addresses over 4G from UEFIThe UEFI spec requires all memory to be identity mapped if paging is enabled. It also allows PAE, but that doesn't change the size of the virtual address space. So we don't have to worry about getting addresses over 4G.
|
Kernel build failures seem unrelated (it doesn't even get to Edit: Ah, looks like its failing on other PRs too Edit2: Looks like everything builds and runs fine. Cirrus-CI just complains about Edit3: I see the style issues, I'll fix them the next time I push. |
@@ -0,0 +1,5 @@ | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extra blank line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't a blank line left at the top of the other Makefiles? (At least, the ones that don't start with comments)
If that's not an enforced style, then yeah I'll remove it.
Moved everything to
|
In preparation for supporting 64-bit machines with 32-bit UEFI firmware, add a build option for compiling the ia32 loader. Currently unused.
In preparation for supporting 64-bit machines with 32-bit UEFI firmware, add a 32-bit variant of libefi since we need to compile both the 64-bit version and the 32-bit version at the same time.
Using AllocateMaxAddress here means that gfx_state->tg_shadow_fb is treated as the highest address we can receive. Since gfx_state->tg_shadow_fb is NULL, we never receive anything. Use AllocateAnyPages instead.
main.c - Fix rsdp cast. framebuffer.c - - Use temp variable instead of directly passing pointer when EFI_PHYSICAL_ADDRESS is expected. Also fix FreePages cast. - Mask framebuffer address given to us by UEFI.
Some machines have 64-bit capable cpus but are stuck on 32-bit uefi firmware. Add support for them by building a new "loader_ia32" with LOADER_DEFAULT_INTERP along with the 64-bit one. The loader can be disabled using MK_LOADER_IA32.
With the new 32-bit UEFI loader, it's convenient to have a sysctl to figure out how we booted. Can be accessed at machdep.efi_arch
This handles copying in install-boot.sh and bsdinstall's bootconfig. In install-boot.sh we try to figure which loader we need. If we do, it's copied to .../EFI/freebsd/loader.efi. However, if we can't, we copy both. The 64-bit one goes to loader.efi and the 32-bit one goes to loader_ia32.efi bsdconfig simply checks the machdep.efi_arch variable and copies accordingly.
Some small cleanup. Diff |
Some machines (mostly baytrail notebooks) have 64-bit capable cpus but are stuck on
32-bit uefi firmware, with so CSM.
Add support for them by making the amd64 loader compile itself again with DO32=1,
(see the amd64 Makefile.inc) all of the extra ia32 specific code is in loader/arch/amd64/ia32.
The loader can be disabled using MK_LOADER_IA32.
Tested on qemu and the Acer one 10 s1002
Also cross-compiled to armv6 to make sure nothing broke.