tools/testing/selftests/kvm/lib/arm64/spinlock.c

Source file repositories/reference/linux-study-clean/tools/testing/selftests/kvm/lib/arm64/spinlock.c

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/kvm/lib/arm64/spinlock.c
Extension
.c
Size
462 bytes
Lines
28
Domain
Support Tooling And Documentation
Bucket
tools
Inferred role
Support Tooling And Documentation: implementation source
Status
source implementation candidate

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

// SPDX-License-Identifier: GPL-2.0
/*
 * ARM64 Spinlock support
 */
#include <stdint.h>

#include "spinlock.h"

void spin_lock(struct spinlock *lock)
{
	int val, res;

	asm volatile(
	"1:	ldaxr	%w0, [%2]\n"
	"	cbnz	%w0, 1b\n"
	"	mov	%w0, #1\n"
	"	stxr	%w1, %w0, [%2]\n"
	"	cbnz	%w1, 1b\n"
	: "=&r" (val), "=&r" (res)
	: "r" (&lock->v)
	: "memory");
}

void spin_unlock(struct spinlock *lock)
{
	asm volatile("stlr wzr, [%0]\n"	: : "r" (&lock->v) : "memory");
}

Annotation

Implementation Notes