From 4384c6fdfb48399fc7b82f4f5c14055fc57f7948 Mon Sep 17 00:00:00 2001 From: Tianhao Wang Date: Wed, 5 Jun 2024 08:07:38 +0200 Subject: chore: add page fault test code Signed-off-by: Tianhao Wang --- src/lib.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/lib.rs') diff --git a/src/lib.rs b/src/lib.rs index e711688..fb68168 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,5 @@ #![allow(dead_code)] #![allow(unused_imports)] -#![allow(unexpected_cfgs)] #![no_std] #![no_main] #![feature(const_option)] @@ -66,3 +65,11 @@ pub extern "C" fn _entry() -> ! { } } } + +pub unsafe fn _test_pf() { + // try a page fault + use core::arch::asm; + use core::slice; + let name_buf = slice::from_raw_parts_mut(0xffffffffffff0000 as *mut u64, 10); + asm!("mov [rdi], rax", in("rdi") name_buf.as_mut_ptr()); +} -- cgit v1.2.3-70-g09d2