mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-23 10:15:57 +01:00
userland/arch/aarch64/inline_asm/reg_var.c: use 64 bit variables
32-bit ones likely copy paste error from coming from arm v7. Also create userland/arch/aarch64/inline_asm/int_32.c: Also create aarch64_ldaxr_stlxr.cpp and start documenting LDAXR and STLXR.
This commit is contained in:
2
userland/cpp/atomic/aarch64_ldaxr_stlxr.cpp
Normal file
2
userland/cpp/atomic/aarch64_ldaxr_stlxr.cpp
Normal file
@@ -0,0 +1,2 @@
|
||||
#define LKMC_USERLAND_ATOMIC_LDAXR_STLXR 1
|
||||
#include "main.hpp"
|
||||
@@ -51,11 +51,28 @@ void threadMain() {
|
||||
:
|
||||
:
|
||||
);
|
||||
#elif LKMC_USERLAND_ATOMIC_LDAXR_STLXR
|
||||
// Was used by std::atomic before LDADD was added
|
||||
uint64_t scratch64;
|
||||
uint64_t scratch32;
|
||||
__asm__ __volatile__ (
|
||||
"1:"
|
||||
"ldaxr %[scratch64], [%[addr]];"
|
||||
"add %[scratch64], %[scratch64], 1;"
|
||||
"stlxr %w[scratch32], %[scratch64], [%[addr]];"
|
||||
"cbnz %w[scratch32], 1b;"
|
||||
: "=m" (global), // indicate that global is modified
|
||||
"+g" (i), // to prevent loop unrolling
|
||||
[scratch64] "=&r" (scratch64),
|
||||
[scratch32] "=&r" (scratch32)
|
||||
: [addr] "r" (&global)
|
||||
:
|
||||
);
|
||||
#elif LKMC_USERLAND_ATOMIC_AARCH64_LDADD
|
||||
// https://cirosantilli.com/linux-kernel-module-cheat#arm-lse
|
||||
__asm__ __volatile__ (
|
||||
"ldadd %[inc], xzr, [%[addr]];"
|
||||
: "=m" (global),
|
||||
: "=m" (global), // indicate that global is modified
|
||||
"+g" (i) // to prevent loop unrolling
|
||||
: [inc] "r" (1),
|
||||
[addr] "r" (&global)
|
||||
|
||||
Reference in New Issue
Block a user