mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-12-29 17:25:38 +00:00
59bec00ace
Introduce x86_64 %rip-relative addressing to the PER_CPU_VAR() macro. Instructions using %rip-relative address operand are one byte shorter than their absolute address counterparts and are also compatible with position independent executable (-fpie) builds. The patch reduces code size of a test kernel build by 150 bytes. The PER_CPU_VAR() macro is intended to be applied to a symbol and should not be used with register operands. Introduce the new __percpu macro and use it in cmpxchg{8,16}b_emu.S instead. Also add a missing function comment to this_cpu_cmpxchg8b_emu(). No functional changes intended. Signed-off-by: Uros Bizjak <ubizjak@gmail.com> Signed-off-by: Ingo Molnar <mingo@kernel.org> Cc: linux-kernel@vger.kernel.org Cc: Brian Gerst <brgerst@gmail.com> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Sean Christopherson <seanjc@google.com>
55 lines
1009 B
ArmAsm
55 lines
1009 B
ArmAsm
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
#include <linux/linkage.h>
|
|
#include <asm/percpu.h>
|
|
#include <asm/processor-flags.h>
|
|
|
|
.text
|
|
|
|
/*
|
|
* Emulate 'cmpxchg16b %gs:(%rsi)'
|
|
*
|
|
* 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
|
|
*
|
|
* Notably this is not LOCK prefixed and is not safe against NMIs
|
|
*/
|
|
SYM_FUNC_START(this_cpu_cmpxchg16b_emu)
|
|
|
|
pushfq
|
|
cli
|
|
|
|
/* if (*ptr == old) */
|
|
cmpq __percpu (%rsi), %rax
|
|
jne .Lnot_same
|
|
cmpq __percpu 8(%rsi), %rdx
|
|
jne .Lnot_same
|
|
|
|
/* *ptr = new */
|
|
movq %rbx, __percpu (%rsi)
|
|
movq %rcx, __percpu 8(%rsi)
|
|
|
|
/* set ZF in EFLAGS to indicate success */
|
|
orl $X86_EFLAGS_ZF, (%rsp)
|
|
|
|
popfq
|
|
RET
|
|
|
|
.Lnot_same:
|
|
/* *ptr != old */
|
|
|
|
/* old = *ptr */
|
|
movq __percpu (%rsi), %rax
|
|
movq __percpu 8(%rsi), %rdx
|
|
|
|
/* clear ZF in EFLAGS to indicate failure */
|
|
andl $(~X86_EFLAGS_ZF), (%rsp)
|
|
|
|
popfq
|
|
RET
|
|
|
|
SYM_FUNC_END(this_cpu_cmpxchg16b_emu)
|