tg-rcore-tutorial-user 0.4.10

User-space apps for rCore Tutorial chapters (subset for ch2).
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#![no_std]
#![no_main]

#[macro_use]
extern crate user_lib;

// 教学目标:
// 主动触发用户态非法访存(向空指针写),验证内核异常处理与进程终止路径。

#[unsafe(no_mangle)]
extern "C" fn main() -> i32 {
    println!("Into Test store_fault, we will insert an invalid store operation...");
    println!("Kernel should kill this application!");
    // 故意制造 store page fault。
    unsafe { core::ptr::null_mut::<u8>().write_volatile(0) };
    0
}