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

Merge verified chunk into frame allocator #976

Draft
wants to merge 24 commits into
base: theseus_main
Choose a base branch
from

Conversation

Ramla-I
Copy link
Member

@Ramla-I Ramla-I commented Jun 14, 2023

This PR merges a verified TrustedChunk type into the frame allocator code. The main changes are:

trusted_chunk crate:

  • submodule that contains the TrustedChunk type, a linked list and static array for bookkeeping, and their verified functions.

frame_allocator crate:

  • The frame allocator no longer uses Chunk for bookkeeping. It used a linear Frames type in the free lists which represents ownership of a range of frames, and a separate type Region for bookkeeping.
  • Since Frames can't be cloned, the frame allocator logic to find and merge frames is slightly changed. A Frames object has to be removed from the free list before it can be merged or split.
  • Frames owns an instance of a verified TrustedChunk, and its functions are wrappers over the TrustedChunk new, merge, split and split_at methods.
  • I use my own version of RangeInclusive within the frame allocator that implements an iterator that doesn't mutate the range.
  • AllocatedFrames is merged into the Frames type. There are two states for a Frames object: Unmapped and Mapped. Mapped is only used briefly once a MappedPages is created.
  • AllocatedFrame type is renamed to UnmappedFrame

frame_range_callbacks crate:

  • the callbacks that crate a TrustedChunk and AllocatedFrames from an UnmappedFrames are in this crate. This is to minimize the amount of code that has access to these callbacks.

memory crate:

  • use the callbacks in the frame_range_callbacks crate rather than storing them in the memory crate

memory_structs:

  • use our own range inclusive and the provided iterator
  • add a to_range_inclusive function for PageRange and FrameRange

Ramla-I and others added 23 commits June 9, 2023 14:25
…seus-os#970)

* Currently this is only used for allocating pages for new
  executable .text sections on aarch64, which itself is a
  workaround to enable runtime loading of crates (see theseus-os#940).
  * Based on the limitations of aarch64's ISA (branch instructions),
    we reserve 128MiB of virtual address space for this purpose.
  * This 128MiB region is for executable .text sections only,
    and is contiguous with the base kernel image's .text section.

* This is available but not used by default on x86_64 yet.
@Ramla-I Ramla-I requested a review from kevinaboos June 14, 2023 12:40
@kevinaboos kevinaboos marked this pull request as draft June 21, 2023 19:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants