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

gdt: Check that MAX is in range #365

Merged
merged 1 commit into from
Mar 30, 2022
Merged

gdt: Check that MAX is in range #365

merged 1 commit into from
Mar 30, 2022

Conversation

josephlr
Copy link
Contributor

The GDT can have a maxium length of 2^16 bytes, and must contain at
least one null descriptor. As MAX counts the number of u64 entries,
we must have 0 < MAX <= 2^13.

Unfortunely, we cannot do this check with a where clause, as
feature(generic_const_expers) is not yet stable. However, we can do
this check with an assert! in GlobalDescriptorTable::empty(), which
is a const fn.

Pointed out by @Freax13 in
#360 (comment)

Signed-off-by: Joe Richey joerichey@google.com

The GDT can have a maxium length of 2^16 bytes, and must contain at
least one null descriptor. As `MAX` counts the number of `u64` entries,
we must have `0 < MAX <= 2^13`.

Unfortunely, we cannot do this check with a `where` clause, as
`feature(generic_const_expers)` is not yet stable. However, we can do
this check with an `assert!` in `GlobalDescriptorTable::empty()`, which
is a `const fn`.

Pointed out by @Freax13 in
#360 (comment)

Signed-off-by: Joe Richey <joerichey@google.com>
@josephlr josephlr requested review from phil-opp and Freax13 March 29, 2022 01:13
Copy link
Member

@Freax13 Freax13 left a 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, thanks!

@josephlr josephlr merged commit d4e330f into next Mar 30, 2022
@josephlr josephlr deleted the gdt1 branch March 30, 2022 20:33
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.

2 participants