FOREACH_IREG();
#undef APPLY_IREG
- regs.rip = tc->instAddr();
+ regs.rip = tc->instAddr() - tc->readMiscReg(MISCREG_CS_BASE);
/* You might think that setting regs.rflags to the contents
* MISCREG_RFLAGS here would suffice. In that case you're
void
X86KvmCPU::updateThreadContext()
{
+ struct kvm_regs regs;
+ struct kvm_sregs sregs;
+
+ getRegisters(regs);
+ getSpecialRegisters(sregs);
+
DPRINTF(KvmContext, "X86KvmCPU::updateThreadContext():\n");
if (DTRACE(KvmContext))
dump();
- updateThreadContextRegs();
- updateThreadContextSRegs();
- if (useXSave)
- updateThreadContextXSave();
- else
- updateThreadContextFPU();
+ updateThreadContextRegs(regs, sregs);
+ updateThreadContextSRegs(sregs);
+ if (useXSave) {
+ struct kvm_xsave xsave;
+ getXSave(xsave);
+
+ updateThreadContextXSave(xsave);
+ } else {
+ struct kvm_fpu fpu;
+ getFPUState(fpu);
+
+ updateThreadContextFPU(fpu);
+ }
updateThreadContextMSRs();
// The M5 misc reg caches some values from other
}
void
-X86KvmCPU::updateThreadContextRegs()
+X86KvmCPU::updateThreadContextRegs(const struct kvm_regs ®s,
+ const struct kvm_sregs &sregs)
{
- struct kvm_regs regs;
- getRegisters(regs);
-
#define APPLY_IREG(kreg, mreg) tc->setIntReg(mreg, regs.kreg)
FOREACH_IREG();
#undef APPLY_IREG
- tc->pcState(PCState(regs.rip));
+ tc->pcState(PCState(regs.rip + sregs.cs.base));
// Flags are spread out across multiple semi-magic registers so we
// need some special care when updating them.
}
void
-X86KvmCPU::updateThreadContextSRegs()
+X86KvmCPU::updateThreadContextSRegs(const struct kvm_sregs &sregs)
{
- struct kvm_sregs sregs;
- getSpecialRegisters(sregs);
-
assert(getKvmRunState()->apic_base == sregs.apic_base);
assert(getKvmRunState()->cr8 == sregs.cr8);
}
void
-X86KvmCPU::updateThreadContextFPU()
+X86KvmCPU::updateThreadContextFPU(const struct kvm_fpu &fpu)
{
- struct kvm_fpu fpu;
- getFPUState(fpu);
-
updateThreadContextFPUCommon(tc, fpu);
tc->setMiscRegNoEffect(MISCREG_FISEG, 0);
}
void
-X86KvmCPU::updateThreadContextXSave()
+X86KvmCPU::updateThreadContextXSave(const struct kvm_xsave &kxsave)
{
- struct kvm_xsave kxsave;
- FXSave &xsave(*(FXSave *)kxsave.region);
- getXSave(kxsave);
+ const FXSave &xsave(*(const FXSave *)kxsave.region);
updateThreadContextFPUCommon(tc, xsave);
* @{
*/
/** Update integer registers */
- void updateThreadContextRegs();
+ void updateThreadContextRegs(const struct kvm_regs ®s,
+ const struct kvm_sregs &sregs);
/** Update control registers (CRx, segments, etc.) */
- void updateThreadContextSRegs();
+ void updateThreadContextSRegs(const struct kvm_sregs &sregs);
/** Update FPU and SIMD registers using the legacy API */
- void updateThreadContextFPU();
+ void updateThreadContextFPU(const struct kvm_fpu &fpu);
/** Update FPU and SIMD registers using the XSave API */
- void updateThreadContextXSave();
+ void updateThreadContextXSave(const struct kvm_xsave &kxsave);
/** Update MSR registers */
void updateThreadContextMSRs();
/** @} */