-
Notifications
You must be signed in to change notification settings - Fork 56
Get mutable references to the memory information #140
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
Conversation
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.
fine with me. Users of this library could do this anyway with unsafe magic.. so just give them the necessary tools directly.
Please address the two open points. Otherwise, LGTM
Oh, yes, I missed that while rebasing. |
Wait. On legacy boot systems, the memory map describes which regions of the physical memory are valid RAM, which is for ACPI, and which is reserved. It does not contain the information that the area where your bootloader lives is "taken". A bootloader has to find this information by itself.. by it's load address and it's length. Hence, also the hope that an allocation should be reflected in the memory map is wrong/not possible. In a UEFI boot flow, the memory map reflects which memory is taken by your image/kernel. If you use a heap that is statically backed inside the binary, there is no need to update the memory map. |
Hm, I'm talking about UEFI and the default allocator: When I create boxes for the tags, they'll get put somewhere on the heap. This might be inside an existing memory region or it might allocate a new The legacy map is only really accurate after calling Doing static allocations might work, but I'm not quite fond of that. |
// SAFETY: BootInformation contains a const ptr to memory that is never mutated.
// Sending this pointer to other threads is sound.
unsafe impl Send for BootInformation {} If we merge this, this needs to be removed, probably. Another breaking change. I think this could be okay, as one can wrap the MBI in a (custom) Mutex.. |
Huh, I don't know? The struct does need to be mutable for these methods to be called, but I'm not sure that's enough. |
I'm going to postpone this a bit and merge a few other things first. The rebase needed here will have a few conflicts - I'm sorry for that! |
Sure, just ping me when I should rebase. |
ping :) |
So, this works, but it really moves the Edit: It's somehow usable, but the lifetimes of the |
I don't understand the miri failure, but this has better lifetimes and the integration test should work. I'm still not happy about having to touch so much code. |
Using |
I think this looks better, though I'm not sure combining |
That |
After thinking a lot about this, I came to the conclusion that this is indeed helpful. However, I'm unsure if the proposed design is too invasive. I think, there is a simpler approach. Let me try something and I'll get back to you! :) Thanks for your patience! TL;DR: My idea is to use |
Oh, great! (Don't mind me, this is just a rebase.) |
579f5a8
to
564ac4a
Compare
(This is just a rebase.) |
Hey. I somehow forgot about this, sorry. I'll look into it soon, hopefully. But I'm already concerned about API complexity and cognitive load |
Yeah sure, take your time. I think this is the simplest change I can come up with right now, but if you find a simpler one, that'd be great. |
Sorry. I'm closing this due to massive internal refactorings, necessary for memory safety and removing any UB, making this unmergable. However, I think that the new design (based in |
Hm, I've been trying to port this over to the new design, but I'm currently stuck with quite a lot of duplications ( |
I think having additional I'm not sure how PS: Did you find the provided write-up and diagrams helpful to understand the new design? I've put much work into it - would love to hear feedbacn |
Thanks for the input and pointing me to the diagrams! They make the two stages of parsing clearer, but I didn't fully grasp the last one, yet. In any case, this seems to be a bit harder than I thought; mostly because (In the mean time, what follows is a partial rebase; please ignore it. :) |
I'm sorry for the inconveniences. But all the refactorings were necessary to get rid of all UB.
What is "the last one", for you? Please reach out to me, so I can improve the docs or diagrams |
This is (hopefully) the last part I split off of #133.
This PR adds the functions
basic_memory_info_tag_mut
,memory_map_tag_mut
adnefi_memory_map_tag_mut
. The memory map tags each get their ownmemory_areas_mut
.This may sound wrong at first and yes, this is really hacky, but I'm afraid that I need this.
The correct way to pass memory information from the bootloader to the kernel would be
But steps 2 and 4 allocate memory which in turn might invalidate the gathered memory map.
One could either risk this and just pass possibly outdated information – or do it the other way round:
(The downside to this approach is that there may be empty areas at the end (which seems to be fine) or that there are not enough areas.)