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

expose Cr3::write_raw #445

Merged
merged 1 commit into from
Jan 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/registers/control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
///
/// When a page fault occurs, the CPU sets this register to the faulting virtual address.
#[derive(Debug)]
pub struct Cr2;

Check warning on line 57 in src/registers/control.rs

View workflow job for this annotation

GitHub Actions / Clippy

unsafe function's docs miss `# Safety` section

Check warning on line 57 in src/registers/control.rs

View workflow job for this annotation

GitHub Actions / Clippy

unsafe function's docs miss `# Safety` section

/// Contains the physical address of the highest-level page table.
#[derive(Debug)]
Expand Down Expand Up @@ -85,7 +85,7 @@
/// virtual-8086 mode.
const VIRTUAL_8086_MODE_EXTENSIONS = 1;
/// Enables support for protected-mode virtual interrupts.
const PROTECTED_MODE_VIRTUAL_INTERRUPTS = 1 << 1;

Check warning on line 88 in src/registers/control.rs

View workflow job for this annotation

GitHub Actions / Clippy

unsafe function's docs miss `# Safety` section

Check warning on line 88 in src/registers/control.rs

View workflow job for this annotation

GitHub Actions / Clippy

unsafe function's docs miss `# Safety` section
/// When set, only privilege-level 0 can execute the `RDTSC` or `RDTSCP` instructions.
const TIMESTAMP_DISABLE = 1 << 2;
/// Enables I/O breakpoint capability and enforces treatment of `DR4` and `DR5` registers
Expand Down Expand Up @@ -181,7 +181,7 @@
asm!("mov {}, cr0", out(reg) value, options(nomem, nostack, preserves_flags));
}

value

Check warning on line 184 in src/registers/control.rs

View workflow job for this annotation

GitHub Actions / Clippy

unsafe function's docs miss `# Safety` section

Check warning on line 184 in src/registers/control.rs

View workflow job for this annotation

GitHub Actions / Clippy

unsafe function's docs miss `# Safety` section
}

/// Write CR0 flags.
Expand Down Expand Up @@ -315,7 +315,7 @@
pub unsafe fn write_pcid(frame: PhysFrame, pcid: Pcid) {
unsafe {
Cr3::write_raw(frame, pcid.value());
}

Check warning on line 318 in src/registers/control.rs

View workflow job for this annotation

GitHub Actions / Clippy

casting to the same type is unnecessary (`u16` -> `u16`)

Check warning on line 318 in src/registers/control.rs

View workflow job for this annotation

GitHub Actions / Clippy

casting to the same type is unnecessary (`u16` -> `u16`)
}

/// Write a new P4 table address into the CR3 register.
Expand All @@ -325,7 +325,7 @@
/// Changing the level 4 page table is unsafe, because it's possible to violate memory safety by
/// changing the page mapping.
#[inline]
unsafe fn write_raw(frame: PhysFrame, val: u16) {
pub unsafe fn write_raw(frame: PhysFrame, val: u16) {
let addr = frame.start_address();
let value = addr.as_u64() | val as u64;

Expand Down