-
Notifications
You must be signed in to change notification settings - Fork 215
Frame allocator assumes memory map is in ascending start address order #315
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
Comments
This does however complicate the |
Good catch, thanks a lot for reporting! Your proposed solution sounds good to me. To summarize:
I'd be happy to merge a PR that implements the above. |
Looking at the code for |
Oh yes, good point! I added an additional bullet point about this to the list above. |
Could we just sort the memory map? |
I don't think Iterators are sortable, so we would need to be able to collect the iterator, which would have to be able to be done on the stack, since we don't have access to a heap or dynamic allocation other than that. I don't think it's possible |
For BIOS the iterator is created from a slice. If we sort the slice, the iterator is also sorted. For UEFI the iterator is not created from a Rust slice but some raw bytes that are casted to descriptors. The uefi crate currently doesn't have an API to sort those descriptors, but I think it might be possible to add that. |
I am working on getting sorting implemented in the uefi crate, and then will start work on the bios sorting. |
Bios is already sorted: bootloader/bios/stage-4/src/main.rs Line 35 in 52a0a67
|
Once #360 is merged, we will be able to sort the UEFI memory map as well using the new |
I just merged #360. I PR to sort the memory map would be appreciated! |
Implemented sorting of uefi memory maps #315
Currently,
LegacyFrameAllocator::allocate_frame_from_descriptor
only ever increasesself.next_frame
. This is problematic, as the memory map descriptors aren't guaranteed to be in ascending start address order (at least for UEFI). If the first descriptor provided by the memory map were also the one with the largest start address, the frame allocator would not allocate from the other descriptors.Rather than checking whether
self.next_frame < self.start_frame
inallocate_frame_from_descriptor
, we should setself.next_frame
to the start address of the descriptor when we find the next suitable descriptor inallocate_frame
.The text was updated successfully, but these errors were encountered: