Skip to content
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

Upgrade Limine crate and EFI binaries #216

Merged
merged 6 commits into from
Nov 20, 2024
Merged

Conversation

PandaZ3D
Copy link
Contributor

This patch upgrades the version of the Limine crate used and is meant to work with the latest version of the Limine EFI binaries (v8.4.0). We would have updated the Limine crate to the newest version, but it needs rustc v1.77. The new binaries introduce various fixes for example stability with U-Boot UEFI (used by Morello/Bhyve). Some of the changes we introduced are API changes. The only things that really needed updating was the format of the Limine configuration file, and issues surrounding the location of the identity map.

Turns out that newer versions of Limine place the identity map at the start of kernel memory (0xFFFF_0000_0000_0000), but for aarch64 only. So this caused the phys_to_virt function to not work correctly and MMIO address allocation to fail. Luckily we can fix this by asking Limine what the offset is (we need to do this since currently the kernel memory map is copied from the bootloader). Funny enough, the offset remains the same for amd64, but we implemented the logic to grab the offset anyways to prevent future breakage with Limine. In the future we might want to decide where our identity map (and other things) live in the kernel's address space.

What is needed to make this work is to update the hosted Limine EFI binaries to version 8.4.0. The binaries can either compile from source or downloaded as so:

git clone https://github.com/limine-bootloader/limine.git --branch=v8.4.0-binary --depth=1

Summary

  • Update limine config file format in image builder
  • Add various API changes for new Limine crate version
  • Ask Limine where identity map is and use info in phys_to_virt
  • Lazily initialize MMIO allocator

@PandaZ3D PandaZ3D added bug Something isn't working enhancement New feature or request kernel Internal kernel issues labels Nov 10, 2024
@PandaZ3D PandaZ3D self-assigned this Nov 10, 2024
@PandaZ3D
Copy link
Contributor Author

Will re-run the build once the binaries are synced

r.address.as_ptr().unwrap() as u64 - 0xffff800000000000
} /* TODO: MEGA HACK */),
rsdp: LIMINE_TABLE.get_response().map(
|r| r.address() as u64 - 0xffff800000000000, /* TODO: MEGA HACK */
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this be set to the value we get from the id map, now, I wonder?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If that is what that magic number is supposed to be then yeah.

@dbittman
Copy link
Contributor

Will syncing those binaries cause breakage for the current main branch?

Copy link
Contributor

@dbittman dbittman left a comment

Choose a reason for hiding this comment

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

LGTM

@PandaZ3D
Copy link
Contributor Author

Will syncing those binaries cause breakage for the current main branch?

I don't think so (at least after this is merged in). I have tested this locally and the kernel boots with the static and dynamic runtime.

@dbittman
Copy link
Contributor

I synced the binaries into the file server, but maybe I did it wrong?

@PandaZ3D
Copy link
Contributor Author

I downloaded the binaries from the file server and it seems that the version hosted is Limine 4.20230317.0. The test run on x86 hangs since the bootloader firmware fails to find the config file in the old format, and does not print the error message to serial.

@dbittman
Copy link
Contributor

Okay, I had forgotten to actually push the changes, but I think I did now. This failure looks different, though.

@PandaZ3D PandaZ3D merged commit f4c8eaf into main Nov 20, 2024
1 check passed
@PandaZ3D PandaZ3D deleted the aaboytes-upgrade-limine branch November 20, 2024 17:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request kernel Internal kernel issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants