1
0
mirror of https://github.com/rcore-os/rCore.git synced 2024-11-25 01:16:18 +04:00

add rkprobes to probe function and instructions,change parameter of trap_handler, update rust-toolchain

This commit is contained in:
hm 2022-01-30 20:18:59 -08:00
parent 13ad2d1905
commit d27908d11d
4 changed files with 26 additions and 6 deletions

19
kernel/Cargo.lock generated
View File

@ -514,6 +514,7 @@ dependencies = [
"rcore-fs-sfs",
"rcore-memory",
"riscv",
"rkprobes",
"rlibc",
"rvm",
"smoltcp",
@ -642,6 +643,12 @@ dependencies = [
"riscv-target",
]
[[package]]
name = "riscv-decode"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "920466101a1ec4ffac2ab9b72fa780eff62defa0ae9c4f77a07fa41dfd5450e6"
[[package]]
name = "riscv-target"
version = "0.1.2"
@ -652,6 +659,18 @@ dependencies = [
"regex",
]
[[package]]
name = "rkprobes"
version = "0.1.0"
source = "git+https://github.com/hm1229/rkprobes?rev=d6e0f96#d6e0f962618329315f7806cec66f2891822e8999"
dependencies = [
"lazy_static",
"log",
"riscv-decode",
"spin",
"trapframe",
]
[[package]]
name = "rlibc"
version = "1.0.0"

View File

@ -90,6 +90,7 @@ x86_64 = "0.11"
[target.'cfg(any(target_arch = "riscv32", target_arch = "riscv64"))'.dependencies]
riscv = { git = "https://github.com/rcore-riscv-hypervisor-dev/riscv" , rev = "3f5efb1", features = ["inline-asm", "hypervisor"] }
rkprobes = { git = "https://github.com/hm1229/rkprobes", rev = "d6e0f96" }
[target.'cfg(target_arch = "aarch64")'.dependencies]
aarch64 = { git = "https://github.com/rcore-os/aarch64", version = "3.0.1" }

View File

@ -36,12 +36,12 @@ pub unsafe fn restore(flags: usize) {
/// This function is called from `trap.asm`.
#[no_mangle]
pub extern "C" fn trap_handler(tf: &mut TrapFrame) {
trap_handler_no_frame(&mut tf.sepc);
trap_handler_no_frame(tf);
}
use crate::memory::AccessType;
#[inline]
pub fn trap_handler_no_frame(sepc: &mut usize) {
pub fn trap_handler_no_frame(tf: &mut TrapFrame) {
use self::scause::{Exception as E, Interrupt as I, Trap};
let scause = scause::read();
let stval = stval::read();
@ -51,11 +51,12 @@ pub fn trap_handler_no_frame(sepc: &mut usize) {
Trap::Interrupt(I::SupervisorExternal) => external(),
Trap::Interrupt(I::SupervisorSoft) => ipi(),
Trap::Interrupt(I::SupervisorTimer) => timer(),
Trap::Exception(E::LoadPageFault) => page_fault(stval, sepc, AccessType::read(is_user)),
Trap::Exception(E::StorePageFault) => page_fault(stval, sepc, AccessType::write(is_user)),
Trap::Exception(E::LoadPageFault) => page_fault(stval, &mut tf.sepc, AccessType::read(is_user)),
Trap::Exception(E::StorePageFault) => page_fault(stval, &mut tf.sepc, AccessType::write(is_user)),
Trap::Exception(E::InstructionPageFault) => {
page_fault(stval, sepc, AccessType::execute(is_user))
page_fault(stval, &mut tf.sepc, AccessType::execute(is_user))
}
Trap::Exception(E::Breakpoint) => rkprobes::kprobes_trap_handler(tf),
_ => {
let bits = scause.bits();
panic!("unhandled trap {:?} ({})", scause.cause(), bits);

View File

@ -8,7 +8,6 @@
#![feature(negative_impls)]
#![feature(alloc_prelude)]
#![feature(const_fn)]
#![feature(const_if_match)]
#![feature(const_in_array_repeat_expressions)]
#![deny(unused_must_use)]
#![deny(stable_features)]