cmpxchg16b_emu.S 1.1 KB
Newer Older
1 2 3 4 5 6 7 8
/*
 *	This program is free software; you can redistribute it and/or
 *	modify it under the terms of the GNU General Public License
 *	as published by the Free Software Foundation; version 2
 *	of the License.
 *
 */
#include <linux/linkage.h>
J
Jan Beulich 已提交
9
#include <asm/percpu.h>
10

11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
.text

/*
 * Inputs:
 * %rsi : memory location to compare
 * %rax : low 64 bits of old value
 * %rdx : high 64 bits of old value
 * %rbx : low 64 bits of new value
 * %rcx : high 64 bits of new value
 * %al  : Operation successful
 */
ENTRY(this_cpu_cmpxchg16b_emu)

#
# Emulate 'cmpxchg16b %gs:(%rsi)' except we return the result in %al not
# via the ZF.  Caller will access %al to get result.
#
# Note that this is only useful for a cpuops operation.  Meaning that we
# do *not* have a fully atomic operation but just an operation that is
# *atomic* on a single cpu (as provided by the this_cpu_xx class of
# macros).
#
33
	pushfq
34 35
	cli

J
Jan Beulich 已提交
36 37 38 39
	cmpq PER_CPU_VAR((%rsi)), %rax
	jne .Lnot_same
	cmpq PER_CPU_VAR(8(%rsi)), %rdx
	jne .Lnot_same
40

J
Jan Beulich 已提交
41 42
	movq %rbx, PER_CPU_VAR((%rsi))
	movq %rcx, PER_CPU_VAR(8(%rsi))
43

44
	popfq
45 46 47
	mov $1, %al
	ret

J
Jan Beulich 已提交
48
.Lnot_same:
49
	popfq
50 51 52 53
	xor %al,%al
	ret

ENDPROC(this_cpu_cmpxchg16b_emu)