blob: 03a186fc06eab6217a4d461174409ac1cc9366ee [file] [log] [blame]
Arjan van de Ven79e1dd02009-09-30 17:07:54 +02001/*
2 * This program is free software; you can redistribute it and/or
3 * modify it under the terms of the GNU General Public License
4 * as published by the Free Software Foundation; version 2
5 * of the License.
6 *
7 */
8
9#include <linux/linkage.h>
Al Viro784d5692016-01-11 11:04:34 -050010#include <asm/export.h>
Arjan van de Ven79e1dd02009-09-30 17:07:54 +020011
Arjan van de Ven79e1dd02009-09-30 17:07:54 +020012.text
13
14/*
15 * Inputs:
16 * %esi : memory location to compare
17 * %eax : low 32 bits of old value
18 * %edx : high 32 bits of old value
19 * %ebx : low 32 bits of new value
20 * %ecx : high 32 bits of new value
21 */
22ENTRY(cmpxchg8b_emu)
Arjan van de Ven79e1dd02009-09-30 17:07:54 +020023
24#
25# Emulate 'cmpxchg8b (%esi)' on UP except we don't
26# set the whole ZF thing (caller will just compare
27# eax:edx with the expected value)
28#
Ingo Molnar131484c2015-05-28 12:21:47 +020029 pushfl
Arjan van de Ven79e1dd02009-09-30 17:07:54 +020030 cli
31
32 cmpl (%esi), %eax
Jan Beulich5f1d9192014-09-24 08:40:14 +010033 jne .Lnot_same
Arjan van de Ven79e1dd02009-09-30 17:07:54 +020034 cmpl 4(%esi), %edx
Jan Beulich5f1d9192014-09-24 08:40:14 +010035 jne .Lhalf_same
Arjan van de Ven79e1dd02009-09-30 17:07:54 +020036
37 movl %ebx, (%esi)
38 movl %ecx, 4(%esi)
39
Ingo Molnar131484c2015-05-28 12:21:47 +020040 popfl
Arjan van de Ven79e1dd02009-09-30 17:07:54 +020041 ret
42
Jan Beulich5f1d9192014-09-24 08:40:14 +010043.Lnot_same:
Arjan van de Ven79e1dd02009-09-30 17:07:54 +020044 movl (%esi), %eax
Jan Beulich5f1d9192014-09-24 08:40:14 +010045.Lhalf_same:
Arjan van de Ven79e1dd02009-09-30 17:07:54 +020046 movl 4(%esi), %edx
47
Ingo Molnar131484c2015-05-28 12:21:47 +020048 popfl
Arjan van de Ven79e1dd02009-09-30 17:07:54 +020049 ret
50
Arjan van de Ven79e1dd02009-09-30 17:07:54 +020051ENDPROC(cmpxchg8b_emu)
Al Viro784d5692016-01-11 11:04:34 -050052EXPORT_SYMBOL(cmpxchg8b_emu)