-
Notifications
You must be signed in to change notification settings - Fork 142
[Question] Why at most 8 entries for the GDT? #395
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
Comments
The basic answer is we had to pick a size, and 8 was a reasonable value that worked for most use-cases. In theory, with const-generics now stable, we could add a parameter to make the maximum size user-configurable. Something like: #[derive(Debug, Clone)]
pub struct GlobalDescriptorTable<const MAX: usize = 8> {
table: [u64; MAX],
len: usize,
}
impl<const MAX: usize> GlobalDescriptorTable<MAX> {
#[inline]
pub const fn new() -> Self {
assert!(MAX >= 1);
Self {
table: [0; MAX],
len: 1,
}
}
...
} The main downside is that while this looks like it would be a non-breaking change, it is actually a very subtle breaking change: pub fn this_still_works() -> GlobalDescriptorTable {
let x = GlobalDescriptorTable::new();
x
} pub fn this_stops_working() {
let x = GlobalDescriptorTable::new();
...
} |
Hm... ok. Thank you for your response! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
May I ask why there can be only at most 8 entries in the GDT? According to the intel manual the GDT should be able to have at most 8.192 entries:

The text was updated successfully, but these errors were encountered: