From 4b525bb1ee15739291845798bd8d733d01fb7563 Mon Sep 17 00:00:00 2001 From: Tom Dohrmann Date: Sun, 16 Jan 2022 14:52:38 +0100 Subject: [PATCH 1/2] add `Cr2::read_raw` --- src/registers/control.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/registers/control.rs b/src/registers/control.rs index 47ad99f3c..1f149673b 100644 --- a/src/registers/control.rs +++ b/src/registers/control.rs @@ -253,6 +253,12 @@ mod x86_64 { /// Read the current page fault linear address from the CR2 register. #[inline] pub fn read() -> VirtAddr { + VirtAddr::new(Self::read_raw()) + } + + /// Read the current page fault linear address from the CR2 register. + #[inline] + pub fn read_raw() -> u64 { let value: u64; #[cfg(feature = "inline_asm")] @@ -264,7 +270,7 @@ mod x86_64 { value = crate::asm::x86_64_asm_read_cr2(); } - VirtAddr::new(value) + value } } From 38537d12a01e90f0219797fa4b3780a3eb5966f4 Mon Sep 17 00:00:00 2001 From: Tom Dohrmann Date: Mon, 17 Jan 2022 11:48:29 +0100 Subject: [PATCH 2/2] improve doc comment Co-authored-by: Philipp Oppermann --- src/registers/control.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/registers/control.rs b/src/registers/control.rs index 1f149673b..bd2b06316 100644 --- a/src/registers/control.rs +++ b/src/registers/control.rs @@ -256,7 +256,7 @@ mod x86_64 { VirtAddr::new(Self::read_raw()) } - /// Read the current page fault linear address from the CR2 register. + /// Read the current page fault linear address from the CR2 register as a raw `u64`. #[inline] pub fn read_raw() -> u64 { let value: u64;