blob: 6a912d58fecc3f65ca6044a636b838161e1b74a6 [file] [log] [blame]
Thomas Gleixnerb886d83c2019-06-01 10:08:55 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Arjan van de Ven79e1dd02009-09-30 17:07:54 +02002
3#include <linux/linkage.h>
Al Viro784d5692016-01-11 11:04:34 -05004#include <asm/export.h>
Arjan van de Ven79e1dd02009-09-30 17:07:54 +02005
Arjan van de Ven79e1dd02009-09-30 17:07:54 +02006.text
7
8/*
9 * Inputs:
10 * %esi : memory location to compare
11 * %eax : low 32 bits of old value
12 * %edx : high 32 bits of old value
13 * %ebx : low 32 bits of new value
14 * %ecx : high 32 bits of new value
15 */
Jiri Slaby6dcc5622019-10-11 13:51:04 +020016SYM_FUNC_START(cmpxchg8b_emu)
Arjan van de Ven79e1dd02009-09-30 17:07:54 +020017
18#
19# Emulate 'cmpxchg8b (%esi)' on UP except we don't
20# set the whole ZF thing (caller will just compare
21# eax:edx with the expected value)
22#
Ingo Molnar131484c2015-05-28 12:21:47 +020023 pushfl
Arjan van de Ven79e1dd02009-09-30 17:07:54 +020024 cli
25
26 cmpl (%esi), %eax
Jan Beulich5f1d9192014-09-24 08:40:14 +010027 jne .Lnot_same
Arjan van de Ven79e1dd02009-09-30 17:07:54 +020028 cmpl 4(%esi), %edx
Jan Beulich5f1d9192014-09-24 08:40:14 +010029 jne .Lhalf_same
Arjan van de Ven79e1dd02009-09-30 17:07:54 +020030
31 movl %ebx, (%esi)
32 movl %ecx, 4(%esi)
33
Ingo Molnar131484c2015-05-28 12:21:47 +020034 popfl
Peter Zijlstraf94909c2021-12-04 14:43:40 +010035 RET
Arjan van de Ven79e1dd02009-09-30 17:07:54 +020036
Jan Beulich5f1d9192014-09-24 08:40:14 +010037.Lnot_same:
Arjan van de Ven79e1dd02009-09-30 17:07:54 +020038 movl (%esi), %eax
Jan Beulich5f1d9192014-09-24 08:40:14 +010039.Lhalf_same:
Arjan van de Ven79e1dd02009-09-30 17:07:54 +020040 movl 4(%esi), %edx
41
Ingo Molnar131484c2015-05-28 12:21:47 +020042 popfl
Peter Zijlstraf94909c2021-12-04 14:43:40 +010043 RET
Arjan van de Ven79e1dd02009-09-30 17:07:54 +020044
Jiri Slaby6dcc5622019-10-11 13:51:04 +020045SYM_FUNC_END(cmpxchg8b_emu)
Al Viro784d5692016-01-11 11:04:34 -050046EXPORT_SYMBOL(cmpxchg8b_emu)