-
Notifications
You must be signed in to change notification settings - Fork 132
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
Add common abstractions for x86 Segments #258
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
seg
branch
2 times, most recently
from
May 29, 2021 11:06
3ee1f21
to
1929da3
Compare
josephlr
commented
May 29, 2021
Signed-off-by: Joe Richey <[email protected]>
Signed-off-by: Joe Richey <[email protected]>
Signed-off-by: Joe Richey <[email protected]>
phil-opp
approved these changes
Jun 5, 2021
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.
Looks good to me overall! I left a few minor comments inline.
Signed-off-by: Joe Richey <[email protected]>
This function only throws a #UD, which we generally consider to be safe. Also, add an `Exceptions` section to the `Segment64` docs (this is similar to the `Panic` section in normal Rust docs). Signed-off-by: Joe Richey <[email protected]>
Signed-off-by: Joe Richey <[email protected]>
Signed-off-by: Joe Richey <[email protected]>
Signed-off-by: Joe Richey <[email protected]>
phil-opp
approved these changes
Jun 12, 2021
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.
The updates all look good to me.
Signed-off-by: Joe Richey <[email protected]>
Signed-off-by: Joe Richey <[email protected]>
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.
When working on #257 I noticed it might be a good idea to have a common trait for the FS and GS segments, to make their use in things like wrapper structs easier. In fact, it makes sense to have a (different) common trait for all of the segments.
This change introduces the following traits:
Segment
CS
,DS
,ES
,SS
,FS
, andGS
Segment64
VirtAddr
instead ofu64
)const
for theMsr
FS
andGS
read_u64
/write_u64
methods from WIP: FS/GS-based TLS access abstraction #257Now that the code has a similar structure for all segments, we can use macros to implement the traits.
Also, this change adds some additional documentation about the segments and segment registers.
Outstanding questions:
rdfsbase()
/wrgsbase()
/set_ds()
/set_cs()
/cs()
etc...). Does this seem reasonable? We could also wait to deprecate them until0.15
(with removal in0.16
or later).Segment
andSegment64
traits just have static methods. Should I make these be normal methods? It doesn't really matter as the segment structs are singletons (CS::get_reg()
vsCS.get_reg()
). One advantage of normal methods is that the trait is then object safe, allowing users to use&dyn Segment
and&dyn Segment64
.