Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于非法指令的转发行为 #26

Closed
yztz opened this issue Jun 2, 2022 · 2 comments
Closed

关于非法指令的转发行为 #26

yztz opened this issue Jun 2, 2022 · 2 comments

Comments

@yztz
Copy link

yztz commented Jun 2, 2022

在现有的处理中:

mstatus::set_spp(SPP::Supervisor);

仅仅设置SPP为S态似乎有些草率。比如在xv6中,若是在用户态触发了非法指令异常,那么在异常处理函数中会判断该异常是否来自于用户态:

if((r_sstatus() & SSTATUS_SPP) != 0){
  panic("usertrap: not from user mode");
}

若按上述设置,那么将会触发panic,这对于debug来说颇具误导性...

比较合适的设置方法应该是根据现有的MPP来设置SPP:

// 设置中断位
if ctx.mstatus.mpp() == MPP::User {
    mstatus::set_spp(SPP::User);
} else {
    mstatus::set_spp(SPP::Supervisor);
}
    
mstatus::set_mpp(MPP::Supervisor);
@luojia65
Copy link
Member

luojia65 commented Jun 2, 2022

感谢!这应该是一个实现中出现的错误,是需要修复的。我会等项目重构结束后注意这个问题

@YdrMaster YdrMaster mentioned this issue Jun 9, 2022
18 tasks
@YdrMaster
Copy link
Member

转发函数已经改了,但其实现在是直接把非法指令也代理掉了,没有做模拟

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants