Skip to content
This repository has been archived by the owner on Feb 3, 2020. It is now read-only.

Commit

Permalink
add exit reason for syncing arm cortem-m sregs between tcg env and kv…
Browse files Browse the repository at this point in the history
…m env

If cpu exit due to sregs updated, the env->kvm_exit_code will be set as 1. When sregs have been synced the kvm_exit_code will be reset to 0.

Signed-off-by: wei zhou <[email protected]>
  • Loading branch information
weizhou-chaojixx committed Jan 5, 2020
1 parent efb6b48 commit 01b472e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
12 changes: 5 additions & 7 deletions src/s2e-kvm-state-arm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ int VCPU::setRegs(kvm_m_regs *regs) {
WR_cpu(m_env, regs[12], regs->regs[12]);
WR_cpu(m_env, regs[13], regs->regs[13]);
WR_cpu(m_env, regs[14], regs->regs[14]);
WR_cpu(m_env, regs[15], regs->regs[15]);
#else
m_env->regs[0] = regs->regs[0];
m_env->regs[1] = regs->regs[1];
Expand All @@ -65,15 +64,15 @@ int VCPU::setRegs(kvm_m_regs *regs) {
m_env->regs[12] = regs->regs[12];
m_env->regs[13] = regs->regs[13];
m_env->regs[14] = regs->regs[14];
#endif
m_env->regs[15] = regs->regs[15];
printf("r15=%#x\n", m_env->regs[15]);
#endif

return 0;
}

int VCPU::setSRegs(kvm_m_sregs *sregs) {
// XXX: what about the interrupt bitmap?
// XXX: what about the nvic interrupt controller ?
m_env->v7m.other_sp = sregs->other_sp;
m_env->v7m.vecbase = sregs->vecbase;
m_env->v7m.basepri = sregs->basepri;
Expand Down Expand Up @@ -131,7 +130,6 @@ int VCPU::getRegs(kvm_m_regs *regs) {
RR_cpu(m_env, regs[12], regs->regs[12]);
RR_cpu(m_env, regs[13], regs->regs[13]);
RR_cpu(m_env, regs[14], regs->regs[14]);
RR_cpu(m_env, regs[15], regs->regs[15]);
#else
regs->regs[0] = m_env->regs[0];
regs->regs[1] = m_env->regs[1];
Expand All @@ -148,9 +146,9 @@ int VCPU::getRegs(kvm_m_regs *regs) {
regs->regs[12] = m_env->regs[12];
regs->regs[13] = m_env->regs[13];
regs->regs[14] = m_env->regs[14];
regs->regs[15] = m_env->regs[15];
#endif

regs->regs[15] = m_env->regs[15];
return 0;
}

Expand All @@ -165,8 +163,7 @@ int VCPU::getSRegs(kvm_m_sregs *sregs) {
sregs->thumb = m_env->thumb;
printf("sregs basepri=%#x\n", sregs->basepri);
printf("sregs control=%#x\n", sregs->control);
// sregs have been synced, so reset the exit code
m_env->kvm_exit_code = 0;

return 0;
}

Expand Down Expand Up @@ -387,5 +384,6 @@ int VCPU::setIrqLine(kvm_irq_level *irq_level) {
arm_cpu_set_irq(m_env, level);
return 0;
}

}
}
5 changes: 1 addition & 4 deletions src/s2e-kvm-vcpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -390,10 +390,6 @@ int VCPU::run(int vcpu_fd) {
return -1;
}

// add exit reason for msr basepri
if (m_env->kvm_exit_code == 1) {
m_cpuBuffer->exit_reason = KVM_EXIT_SYNC_ARM_V7M_SREGS;
}
m_handlingKvmCallback =
m_cpuBuffer->exit_reason == KVM_EXIT_IO || m_cpuBuffer->exit_reason == KVM_EXIT_MMIO ||
m_cpuBuffer->exit_reason == KVM_EXIT_FLUSH_DISK || m_cpuBuffer->exit_reason == KVM_EXIT_SAVE_DEV_STATE ||
Expand Down Expand Up @@ -845,4 +841,5 @@ void s2e_kvm_restore_device_state(void) {
void s2e_kvm_clone_process(void) {
s2e::kvm::s_vcpu->cloneProcess();
}

}

0 comments on commit 01b472e

Please sign in to comment.