cmpxchg8b_emu.S 751 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. #include <linux/linkage.h>
  3. #include <asm/export.h>
  4. .text
  5. /*
  6. * Inputs:
  7. * %esi : memory location to compare
  8. * %eax : low 32 bits of old value
  9. * %edx : high 32 bits of old value
  10. * %ebx : low 32 bits of new value
  11. * %ecx : high 32 bits of new value
  12. */
  13. SYM_FUNC_START(cmpxchg8b_emu)
  14. #
  15. # Emulate 'cmpxchg8b (%esi)' on UP except we don't
  16. # set the whole ZF thing (caller will just compare
  17. # eax:edx with the expected value)
  18. #
  19. pushfl
  20. cli
  21. cmpl (%esi), %eax
  22. jne .Lnot_same
  23. cmpl 4(%esi), %edx
  24. jne .Lhalf_same
  25. movl %ebx, (%esi)
  26. movl %ecx, 4(%esi)
  27. popfl
  28. RET
  29. .Lnot_same:
  30. movl (%esi), %eax
  31. .Lhalf_same:
  32. movl 4(%esi), %edx
  33. popfl
  34. RET
  35. SYM_FUNC_END(cmpxchg8b_emu)
  36. EXPORT_SYMBOL(cmpxchg8b_emu)