On 3/18/25 18:05, Richard Henderson wrote:
On 3/18/25 16:52, Pierrick Bouvier wrote:
On 3/18/25 14:31, Richard Henderson wrote:
These routines are buggy in multiple ways:
- Use of target-endian loads, then a bswap that
depends on the host endiannness.
The code is very similar to do_ld*_mmu functions, so it's subtle to notice.
Was the endianness bug due to the fact we use oi (MemOpIdx) directly instead of
get_memop(oi) (MemOp)?
No, it was due to ...
- ret = lduw_p(haddr);
- ret = ldl_p(haddr);
- ret = ldq_p(haddr);
... these being target-endian macros.
What was intended, once upon a time, was ldl_he_p etc,
so that the load was host-endian. But using the atomicity
routines is even better.
Oh right, I missed the load_atom_* for size > 1, as I was looking at
do_ld1_mmu, which uses ldub_p.
Thanks
r~