arch/x86/lib/atomic64_cx8_32.S

Source file repositories/reference/linux-study-clean/arch/x86/lib/atomic64_cx8_32.S

File Facts

System
Linux kernel
Corpus path
arch/x86/lib/atomic64_cx8_32.S
Extension
.S
Size
2768 bytes
Lines
186
Domain
Architecture Layer
Bucket
arch/x86
Inferred role
Architecture Layer: arch/x86
Status
atlas-only

Why This File Exists

CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.

Dependency Surface

Detected Declarations

Annotated Snippet

#include <linux/linkage.h>
#include <asm/alternative.h>

.macro read64 reg
	movl %ebx, %eax
	movl %ecx, %edx
/* we need LOCK_PREFIX since otherwise cmpxchg8b always does the write */
	LOCK_PREFIX
	cmpxchg8b (\reg)
.endm

.macro read64_nonatomic reg
	movl (\reg), %eax
	movl 4(\reg), %edx
.endm

SYM_FUNC_START(atomic64_read_cx8)
	read64 %ecx
	RET
SYM_FUNC_END(atomic64_read_cx8)

SYM_FUNC_START(atomic64_set_cx8)
1:
/* we don't need LOCK_PREFIX since aligned 64-bit writes
 * are atomic on 586 and newer */
	cmpxchg8b (%esi)
	jne 1b

	RET
SYM_FUNC_END(atomic64_set_cx8)

SYM_FUNC_START(atomic64_xchg_cx8)
1:
	LOCK_PREFIX
	cmpxchg8b (%esi)
	jne 1b

	RET
SYM_FUNC_END(atomic64_xchg_cx8)

.macro addsub_return func ins insc
SYM_FUNC_START(atomic64_\func\()_return_cx8)
	pushl %ebp
	pushl %ebx
	pushl %esi
	pushl %edi

	movl %eax, %esi
	movl %edx, %edi
	movl %ecx, %ebp

	read64_nonatomic %ecx
1:
	movl %eax, %ebx
	movl %edx, %ecx
	\ins\()l %esi, %ebx
	\insc\()l %edi, %ecx
	LOCK_PREFIX
	cmpxchg8b (%ebp)
	jne 1b

10:
	movl %ebx, %eax
	movl %ecx, %edx
	popl %edi
	popl %esi
	popl %ebx
	popl %ebp
	RET
SYM_FUNC_END(atomic64_\func\()_return_cx8)

Annotation

Implementation Notes