#349 dynrec endianness unsafe access to Segs.val[x]

SVN
fixed
None
5
2015-10-20
2010-05-14
No

The dynrec core performs implicit casts of Segs.val[x] to Bit16u * inside of the MOV_SEG_VAL_TO_HOST_REG macro and the macros used therein.
This breaks on Big-endian, because Segs.val[x] is a Bitu, which is 32bit. So on casting of the pointer to the value we end up accessing the wrong word on big-endian machines.

This is fixed by declaring Segs.val as Bit16u. This gets rid of the the implicit pointer casting.
We could also make the pointer casting endianness-safe in this case, but this requires more intrusive changes. I also don't see an issue with making Segs.val being Bit16u anyway. I think it's a good idea anyway to have Segs.val have an explicit size constraint instead of using the loosely defined Bitu type (which is 32bits in practice, though)

The attached patch is tested on x86 and on PowerPC (to some degree, as I don't have a working PPC dynrec, yet).

Discussion

  • Peter Veenstra

    Peter Veenstra - 2015-10-20

    Sorry I missed this.
    You are right.
    Corrected it.

     
  • Peter Veenstra

    Peter Veenstra - 2015-10-20
    • status: open --> fixed
    • assigned_to: Peter Veenstra
    • Group: --> SVN
     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks