]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/blame - arch/x86/lib/cmpxchg16b_emu.S
Merge tag 'soundwire-5.3-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/vkoul...
[mirror_ubuntu-eoan-kernel.git] / arch / x86 / lib / cmpxchg16b_emu.S
CommitLineData
b886d83c 1/* SPDX-License-Identifier: GPL-2.0-only */
b9ec40af 2#include <linux/linkage.h>
3f635721 3#include <asm/percpu.h>
d7c3f8ce 4
b9ec40af
CL
5.text
6
7/*
8 * Inputs:
9 * %rsi : memory location to compare
10 * %rax : low 64 bits of old value
11 * %rdx : high 64 bits of old value
12 * %rbx : low 64 bits of new value
13 * %rcx : high 64 bits of new value
14 * %al : Operation successful
15 */
16ENTRY(this_cpu_cmpxchg16b_emu)
b9ec40af
CL
17
18#
19# Emulate 'cmpxchg16b %gs:(%rsi)' except we return the result in %al not
20# via the ZF. Caller will access %al to get result.
21#
22# Note that this is only useful for a cpuops operation. Meaning that we
23# do *not* have a fully atomic operation but just an operation that is
24# *atomic* on a single cpu (as provided by the this_cpu_xx class of
25# macros).
26#
131484c8 27 pushfq
b9ec40af
CL
28 cli
29
3f635721
JB
30 cmpq PER_CPU_VAR((%rsi)), %rax
31 jne .Lnot_same
32 cmpq PER_CPU_VAR(8(%rsi)), %rdx
33 jne .Lnot_same
b9ec40af 34
3f635721
JB
35 movq %rbx, PER_CPU_VAR((%rsi))
36 movq %rcx, PER_CPU_VAR(8(%rsi))
b9ec40af 37
131484c8 38 popfq
b9ec40af
CL
39 mov $1, %al
40 ret
41
3f635721 42.Lnot_same:
131484c8 43 popfq
b9ec40af
CL
44 xor %al,%al
45 ret
46
b9ec40af 47ENDPROC(this_cpu_cmpxchg16b_emu)