Re: [kvm-unit-tests PATCH v2] x86: Do not assign values to unaligned pointer to 128 bits

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, May 06, 2021, Jacob Xu wrote:
> > memset() takes a void *, which it casts to an char, i.e. it works on one byte at
> a time.
> Huh, TIL. Based on this I'd thought that I don't need a cast at all,
> but doing so actually results in a movaps instruction.

Ewwww.  That's likely because emulator.c does:

  #define memset __builtin_memset

and the compiler is clever enough to know that __attribute__((vector_size(16)))
means the variable is (supposed to be) aligned.

> I've changed the cast back to (uint8_t *).

I assume removing the above #define and grabbing memset() from string.c fixes
the movaps generation?  If so, that has my vote, as opposed to fudging around
the compiler by casting to uint8_t *.

As evidenced by this issue, using the compiler's memset() in kvm-unit-tests seems
inherently dangerous since the tests are often doing intentionally stupid things.



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux