Replies: 3 comments 3 replies
|
Hi, glad to hear you've tried the library out. The refactor to the new allocator API was relatively recent and has not been pushed over the line in a form that is yet completely usable. There would definitely be appetite for making this possible, and if that requires making all the raw structures public then so be it - feel free to get something working in a fork and submitting a PR :) Design wise, most users will still find it most useful to have an allocator available, and to let the library allocate freely and provide higher-level data structures. This is not yet easily done on Hopefully that answers some questions - lmk if not and if you've found any other pain points in using the libraries. |
|
Ik this is super old but I want to comment on this specific topic. After working extensively with Zig and nightly Rust’s allocator_api, my question has mostly become: why is this still not stable? unsafe impl Allocator<const N: usize> for AmlArena<N> { // ... }
const BYTES_FOR_AML = 2 << 20; // Now I only need to define this one constant
Interpreter<SomeHandler, AmlArena<BYTES_FOR_AML>> // Now I can sleep at night knowing that any overflow would mostly require just one capacity bumpThe arena is the important part: one capacity defines the dynamic-memory budget for the AML path, its lifetime remains explicit, and malformed firmware can exhaust only that domain rather than silently consuming a global kernel heap. With fallible allocation at the relevant boundaries, failures are also much more self-contained. Bit of an info dump; moral of my story is that I think |
Well because we haven't done it yet 😉 More seriously - because Isaac and (more recently) me only have limited time due to work & family commitments and it hasn't been useful for us, personally. Per the notes in #306, both Isaac and me are OK with the idea of allowing Although I must point out that if the reason you want it to use a separate allocator is to keep it separate from other kernel memory, you could consider other methods of isolation that would be more robust (such as entirely separate processes). To me, it seems that a big benefit of custom allocators (as compared to other isolation methods) would be more fine-grained control over caching and/or paging behaviour. If anyone else picks this up in advance of @SnowCheetos, please take a look at their previous work and the notes in #306, there's plenty of good stuff there. Some notes of my own - hopefully interesting questions for your own hobby OS. I want to emphasise that your proposal has value, these are just me doing a bit of bikeshedding: First though - some good news! Allocator API seems to be progressing again: rust-lang/rust#156882
Why? Especially why #UD? Presumably splitting allocations between allocators makes this problem worse as you've added the possibility of the wrong allocator being called to release memory.
Yet if there's only one domain (the global allocator), presumably allocation domain can never contribute to incorrectness? Whereas with multiple allocation domains you could accidentally introduce incorrect or unsound behaviour.
Does it? That feels like a design choice you could alter... My most recent kernel takes a memory map from the firmware and starts the global allocator before using any AML. Alternatively, if you're getting something more advanced from ACPI such as NUMA, you could start with a "startup allocator" that is consumed/replaced by the "main allocator" once the system/ACPI is more fully running. I'd be curious to see your OS some more if you're open to sharing it - I always learn something from other people's code!
Hence your PR I suppose! Although see my next bit of bikeshedding - there are ways to encapsulate
To me, this sounds a bit like encapsulating |
Uh oh!
There was an error while loading. Please reload this page.
I initially attempted to use the
acpicrate on ano_stdsystem...However, I found it is difficult to use (especially the
masterbranch without theallocator_apifeature being enabled.Aside from a minor compile error, many of the table structs have all private fields and only seem usable by the
allocator_apienabled code. (At least my initial interest was theMCFGandMADTtables).Would there be any appetite for making all the low-level structs have public fields? Or is there some other design goal that I'm not aware of?
All reactions