On Mon, 11 Apr 2022 at 17:56, Paolo Bonzini <pbonz...@redhat.com> wrote: > Yeah, I actually wrote the memcpy() invocation because I was going to > look at AVX later this year, which of course you couldn't know. :) > What I came up after stealing parts of your nice comment is the > following: > > /* > * Copy the relevant parts of a Reg value around. In the case where > * sizeof(Reg) > SIZE, these helpers operate only on the lower bytes of > * a 64 byte ZMMReg, so we must copy only those and keep the top bytes > * untouched in the guest-visible destination destination register. > * Note that the "lower bytes" are placed last in memory on big-endian > * hosts, which store the vector backwards in memory. In that case the > * copy *starts* at B(SIZE - 1) and ends at B(0), the opposite of > * the little-endian case. > */ > #ifdef HOST_WORDS_BIGENDIAN > #define MOVE(d, r) memcpy(&((d).B(SIZE - 1)), &(d).B(SIZE - 1), SIZE)
Typo -- 2nd argument should be operating on 'r', not 'd'. > #else > #define MOVE(d, r) memcpy(&(d).B(0), &(r).B(0), SIZE) > #endif Otherwise looks good. thanks -- PMM