/* SPDX-License-Identifier: GPL-2.0-only */12#include <linux/export.h>3#include <linux/linkage.h>4#include <asm/percpu.h>5#include <asm/processor-flags.h>67.text89#ifndef CONFIG_X86_CX81011/*12* Emulate 'cmpxchg8b (%esi)' on UP13*14* Inputs:15* %esi : memory location to compare16* %eax : low 32 bits of old value17* %edx : high 32 bits of old value18* %ebx : low 32 bits of new value19* %ecx : high 32 bits of new value20*/21SYM_FUNC_START(cmpxchg8b_emu)2223pushfl24cli2526cmpl (%esi), %eax27jne .Lnot_same28cmpl 4(%esi), %edx29jne .Lnot_same3031movl %ebx, (%esi)32movl %ecx, 4(%esi)3334orl $X86_EFLAGS_ZF, (%esp)3536popfl37RET3839.Lnot_same:40movl (%esi), %eax41movl 4(%esi), %edx4243andl $(~X86_EFLAGS_ZF), (%esp)4445popfl46RET4748SYM_FUNC_END(cmpxchg8b_emu)49EXPORT_SYMBOL(cmpxchg8b_emu)5051#endif5253#ifndef CONFIG_UML5455/*56* Emulate 'cmpxchg8b %fs:(%rsi)'57*58* Inputs:59* %esi : memory location to compare60* %eax : low 32 bits of old value61* %edx : high 32 bits of old value62* %ebx : low 32 bits of new value63* %ecx : high 32 bits of new value64*65* Notably this is not LOCK prefixed and is not safe against NMIs66*/67SYM_FUNC_START(this_cpu_cmpxchg8b_emu)6869pushfl70cli7172cmpl __percpu (%esi), %eax73jne .Lnot_same274cmpl __percpu 4(%esi), %edx75jne .Lnot_same27677movl %ebx, __percpu (%esi)78movl %ecx, __percpu 4(%esi)7980orl $X86_EFLAGS_ZF, (%esp)8182popfl83RET8485.Lnot_same2:86movl __percpu (%esi), %eax87movl __percpu 4(%esi), %edx8889andl $(~X86_EFLAGS_ZF), (%esp)9091popfl92RET9394SYM_FUNC_END(this_cpu_cmpxchg8b_emu)9596#endif979899