git: 597ffdc1d350 - main - LinuxKPI: Add smp_store_release and smp_load_acquire functions

From: Vladimir Kondratyev <wulf_at_FreeBSD.org>
Date: Wed, 26 Jun 2024 20:54:41 UTC
The branch main has been updated by wulf:

URL: https://cgit.FreeBSD.org/src/commit/?id=597ffdc1d3503110165dd57685c29da64386a7db

commit 597ffdc1d3503110165dd57685c29da64386a7db
Author:     Vladimir Kondratyev <wulf@FreeBSD.org>
AuthorDate: 2024-06-26 20:44:37 +0000
Commit:     Vladimir Kondratyev <wulf@FreeBSD.org>
CommitDate: 2024-06-26 20:44:37 +0000

    LinuxKPI: Add smp_store_release and smp_load_acquire functions
    
    Sponsored by:   Serenity Cyber Security, LLC
    MFC after:      1 week
    Reviewed by:    manu
    Differential Revision:  https://reviews.freebsd.org/D45611
---
 sys/compat/linuxkpi/common/include/asm/barrier.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/sys/compat/linuxkpi/common/include/asm/barrier.h b/sys/compat/linuxkpi/common/include/asm/barrier.h
index d09f9c6d2c97..39c5139cb322 100644
--- a/sys/compat/linuxkpi/common/include/asm/barrier.h
+++ b/sys/compat/linuxkpi/common/include/asm/barrier.h
@@ -58,4 +58,7 @@
 #define	smp_mb__before_atomic()	barrier()
 #define	smp_mb__after_atomic()	barrier()
 
+#define smp_store_release(p, v)	do { smp_mb(); WRITE_ONCE(*p, v); } while (0)
+#define smp_load_acquire(p) ({ typeof(*p) _v = READ_ONCE(*p); smp_mb(); _v; })
+
 #endif	/* _LINUXKPI_ASM_BARRIER_H_ */