To those of you with more x86 ISA implementation knowledge than I have:

I've been working through a bug one of our users found (thanks Sanchayan!).
It looks like current versions of ld use the 0x67 instruction prefix
(address size override) as an optimization instead of using a nop. See
https://www.sourceware.org/ml/binutils/2016-05/msg00323.html.

This causes the call instruction to be decoded with with the "address size
override prefix", which is correct, in a sense. From what I can tell, this
is passed to the call instruction via "-env.dataSize" (see call instruction
implementation below).

def macroop CALL_NEAR_I
{
    # Make the default data size of calls 64 bits in 64 bit mode
    .adjust_env oszIn64Override
    .function_call

    limm t1, imm
    rdip t7
    # Check target of call
    st t7, ss, [0, t0, rsp], "-env.dataSize"
    subi rsp, rsp, ssz
    wrip t7, t1
};

Now, the bug is, according to the x86 manual, "For instructions that
implicitly access the stack segment (SS), the address size for stack
accesses is determined by the D (default) bit in the stack-segment
descriptor. In 64-bit mode, the D bit is ignored, and all stack references
have a 64-bit address size." See
https://support.amd.com/TechDocs/24594.pdf page
9.

Thoughts on how to fix this?

Thanks,
Jason
_______________________________________________
gem5-dev mailing list
gem5-dev@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to