Skip to content

Commit

Permalink
td-exception: fix clippy error masking with zero
Browse files Browse the repository at this point in the history
Zero mask here meant the 6th bit shall be 0 for ring0. When the
structure is used for non ring0 privileges, the corresponding
flag needs to be set.

Signed-off-by: Jiaqi Gao <[email protected]>
  • Loading branch information
gaojiaqi7 committed Aug 31, 2023
1 parent 42ca234 commit ad2b8d5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions td-exception/src/idt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ impl Idt {
bitflags! {
pub struct IdtFlags: u8 {
const PRESENT = 1 << 7;
const RING_0 = 0 << 5;
// RING_0 is 0 << 5
const RING_1 = 1 << 5;
const RING_2 = 2 << 5;
const RING_3 = 3 << 5;
Expand Down Expand Up @@ -178,7 +178,7 @@ impl IdtEntry {

// A function to set the offset more easily
pub fn set_func(&mut self, func: usize) {
self.set_flags(IdtFlags::PRESENT | IdtFlags::RING_0 | IdtFlags::INTERRUPT);
self.set_flags(IdtFlags::PRESENT | IdtFlags::INTERRUPT);
self.set_offset(CS::get_reg().0, func as usize); // GDT_KERNEL_CODE 1u16
}

Expand Down

0 comments on commit ad2b8d5

Please sign in to comment.