-
Notifications
You must be signed in to change notification settings - Fork 58
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
Cleanup code and remove unsupported dependencies #31
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
josephlr
force-pushed
the
cleanup
branch
3 times, most recently
from
February 29, 2020 06:23
c46ee93
to
72cb91a
Compare
rbradford
reviewed
Feb 29, 2020
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.
With the exception of my concerns over deleting the rust-toolchain file very happy with this PR. Thanks.
rbradford
changed the title
Cleanup code and remove unsupported dependancies
Cleanup code and remove unsupported dependencies
Feb 29, 2020
I confirmed that this toolchain has all the necessary components. See: https://rust-lang.github.io/rustup-components-history/x86_64-unknown-linux-gnu.html Signed-off-by: Joe Richey <[email protected]>
Make sure that we consistently use the tree import syntax. Also, consistently order code like: - Global attributes/comments - `use` from `core` - `use` from external crates - `mod` declarations (if applicable) - `use` from current crate - Rest of code This makes the code easier to read/edit. Signed-off-by: Joe Richey <[email protected]>
- The `spin` crate is unmaintained - Replace it with `atomic_refcell` - We don't need spin locks, just a checked refcount - Use `x86_64` instead of `cpuio` - It has better abstractions - It has more functionality that we can user later - Fixup existing port usage Signed-off-by: Joe Richey <[email protected]>
Signed-off-by: Joe Richey <[email protected]>
Now that we are using the x86_64 crate, we don't need ASM to set the flags on the CR0 and CR4 registers. This also makes the code much more readable. Signed-off-by: Joe Richey <[email protected]>
Like PortIO the page tables are a fundamentally global structure. By moving the paging logic to a separate file, the requirement for exclusive access is now correctly modeled with Rust types. Signed-off-by: Joe Richey <[email protected]>
This allows for less complex linking and less `unsafe` code. It also frees up Rust to place the page tables wherever it wants. Signed-off-by: Joe Richey <[email protected]>
Adding a bss section reduces binary size by ~30%. We also only use a single Program Header. This better reflects the fact that the entire firmware is loaded as a single Read/Write/Execute blob. Right now, the hypervisor's loader does not read PHDR types: https://github.com/rust-vmm/linux-loader/blob/e5c6d66d3121421672c9b25b02e8954f0ed5f58d/src/loader/mod.rs#L248-L274 Signed-off-by: Joe Richey <[email protected]>
This makes the directory/module structure more consistent. It also avoids cluttering `main.rs`. Signed-off-by: Joe Richey <[email protected]>
rbradford
approved these changes
Mar 2, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
For more information see each commit. I'm rebasing all my other changes (#24 #26) on top of this.
The
spin
crate is unsupported andcpuio
hasn't been updated in 4 years. There are better crates for our use cases.For x86 primitives, we can use
x86_64
. This crate provides structures and functions for Control Registers, Paging Structures, and miscellaneous instructions. This means we can now have much cleaner Rust code for paging, setting up the XMM registers, Port IO, halting, etc...For replacing the
spin
crate, we use theatomic_refcell
crate. Spin locks have issues, and we don't actually need them here. We just need to check that we aren't violating the borrowing rules. It's fine for us to panic if we are violating them (as it indicates a bug).This PR puts certain global resources inside an
AtomicRefCell
, namely: