Skip to content

Commit 11f64f6

Browse files
committed
make Cr2::read return a result
1 parent 64a7ca7 commit 11f64f6

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/registers/control.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,10 @@ bitflags! {
160160
#[cfg(feature = "instructions")]
161161
mod x86_64 {
162162
use super::*;
163-
use crate::{instructions::tlb::Pcid, structures::paging::PhysFrame, PhysAddr, VirtAddr};
163+
use crate::{
164+
addr::VirtAddrNotValid, instructions::tlb::Pcid, structures::paging::PhysFrame, PhysAddr,
165+
VirtAddr,
166+
};
164167
#[cfg(feature = "inline_asm")]
165168
use core::arch::asm;
166169

@@ -252,8 +255,8 @@ mod x86_64 {
252255
impl Cr2 {
253256
/// Read the current page fault linear address from the CR2 register.
254257
#[inline]
255-
pub fn read() -> VirtAddr {
256-
VirtAddr::new(Self::read_raw())
258+
pub fn read() -> Result<VirtAddr, VirtAddrNotValid> {
259+
VirtAddr::try_new(Self::read_raw())
257260
}
258261

259262
/// Read the current page fault linear address from the CR2 register as a raw `u64`.

0 commit comments

Comments
 (0)