From: Andreas Sandberg Date: Wed, 5 Feb 2014 13:08:13 +0000 (+0100) Subject: x86: Fix x87 state transfer bug X-Git-Tag: stable_2014_08_26~173 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e76a37985f9ab9678ed00809cc2ec8385c293ba5;p=gem5.git x86: Fix x87 state transfer bug Changeset 7274310be1bb (isa: clean up register constants) increased the value of NumFloatRegs, which triggered a bug in X86ISA::copyRegs(). This bug is caused by the x87 stack being copied twice since register indexes past NUM_FLOATREGS are mapped into the x87 stack relative to the top of the stack, which is undefined when the copy takes place. This changeset updates the copyRegs() function to use access registers using the non-flattening interface, which guarantees that undesirable register folding does not happen. --- diff --git a/src/arch/x86/utility.cc b/src/arch/x86/utility.cc index 8f1a419f1..fcd52d38a 100644 --- a/src/arch/x86/utility.cc +++ b/src/arch/x86/utility.cc @@ -240,13 +240,13 @@ copyRegs(ThreadContext *src, ThreadContext *dest) { //copy int regs for (int i = 0; i < NumIntRegs; ++i) - dest->setIntReg(i, src->readIntReg(i)); + dest->setIntRegFlat(i, src->readIntRegFlat(i)); //copy float regs for (int i = 0; i < NumFloatRegs; ++i) - dest->setFloatRegBits(i, src->readFloatRegBits(i)); + dest->setFloatRegBitsFlat(i, src->readFloatRegBitsFlat(i)); //copy condition-code regs for (int i = 0; i < NumCCRegs; ++i) - dest->setCCReg(i, src->readCCReg(i)); + dest->setCCRegFlat(i, src->readCCRegFlat(i)); copyMiscRegs(src, dest); dest->pcState(src->pcState()); }