mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-11-14 19:02:02 +00:00
extract common barrier interface to include/lib/barrier.h, and invoke the variant implementation of arch. Tracked-On: #8803 Signed-off-by: Haoyu Tang <haoyu.tang@intel.com> Reviewed-by: Yifan Liu <yifan1.liu@intel.com> Acked-by: Wang, Yu1 <yu1.wang@intel.com>
27 lines
634 B
C
27 lines
634 B
C
/*
|
|
* Copyright (C) 2025 Intel Corporation.
|
|
*
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
*/
|
|
|
|
#ifndef X86_LIB_BARRIER_H
|
|
#define X86_LIB_BARRIER_H
|
|
/* Synchronizes all read accesses to memory */
|
|
static inline void arch_cpu_read_memory_barrier(void)
|
|
{
|
|
asm volatile ("lfence\n" : : : "memory");
|
|
}
|
|
|
|
/* Synchronizes all write accesses to memory */
|
|
static inline void arch_cpu_write_memory_barrier(void)
|
|
{
|
|
asm volatile ("sfence\n" : : : "memory");
|
|
}
|
|
|
|
/* Synchronizes all read and write accesses to/from memory */
|
|
static inline void arch_cpu_memory_barrier(void)
|
|
{
|
|
asm volatile ("mfence\n" : : : "memory");
|
|
}
|
|
#endif /* X86_LIB_BARRIER_H */
|