-
Notifications
You must be signed in to change notification settings - Fork 133
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 a SelectorErrorCode to segment_not_present in IDT #274
Conversation
@budde25 thanks for contributing to this crate!! The definitions for this type look good, but changing the type of Could you change this PR to just declare the |
@josephlr |
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.
As for the breaking change would it be enough to just remove the change to
segment_not_present
? What would the change toSegmentNotPresentHandlerFunc
type definitions be? or would it just be removed since it would be unused now.
You're exactly correct here, I would want us to remove SegmentNotPresentHandlerFunc
so that users don't get confused and try to use it with this crate when it won't (currently) work.
src/structures/idt.rs
Outdated
/// A segment not present handler function that pushes a selector error code. | ||
/// | ||
/// This type alias is only usable with the `abi_x86_interrupt` feature enabled. | ||
#[cfg(feature = "abi_x86_interrupt")] | ||
pub type SegmentNotPresentHandlerFunc = | ||
extern "x86-interrupt" fn(InterruptStackFrame, error_code: SelectorErrorCode); | ||
|
||
/// This type is not usable without the `abi_x86_interrupt` feature. | ||
#[cfg(not(feature = "abi_x86_interrupt"))] | ||
#[derive(Copy, Clone, Debug)] | ||
pub struct SegmentNotPresentHandlerFunc(()); | ||
|
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.
Remove (for now). Also when we add this back, note that the #NP
exception isn't the only exception that uses this error code.
#TS
, #NP
: SelectorErrorCode
#SS
, #GP
: SelectorErrorCode
or zero (depending on context)
#AC
, #DF
: Error code always 0
#PF
, #CP
, #VC
, #SX
: Custom error code
Co-authored-by: Joseph Richey <[email protected]>
Co-authored-by: Joseph Richey <[email protected]>
Co-authored-by: Joseph Richey <[email protected]>
Co-authored-by: Joseph Richey <[email protected]>
Co-authored-by: Joseph Richey <[email protected]>
Alright, I have implemented the requested changes. Sorry for the delay. |
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.
LGTM, thanks for making the chanes!
I also added a
new_truncate
to theSelectorErrorCode
as convenience method. Similar to thefrom_bits_truncate
in an effort to provide a similar interface.
Nice addition, I like it. It's also similar to how VirtAddr
works, so that's also great.
As documented here: https://wiki.osdev.org/Exceptions#Selector_Error_Code
Similar to the
PageFaultHandlerFunc
this adds aSegmentNotPresentHandlerFunc
The struct does need to be a repr(transparent) u64 otherwise a LLVM error occurs