mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-27 12:57:53 +00:00
434b26605f
Add an s390 specific READ_ONCE_ALIGNED_128() helper, which can be used for fast block concurrent (atomic) 128-bit accesses. The used lpq instruction requires 128-bit alignment. This is also the reason why the compiler doesn't emit this instruction if __READ_ONCE() is used for 128-bit accesses. Link: https://lore.kernel.org/r/20230224100237.3247871-2-hca@linux.ibm.com Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
31 lines
691 B
C
31 lines
691 B
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
|
|
#ifndef __ASM_S390_RWONCE_H
|
|
#define __ASM_S390_RWONCE_H
|
|
|
|
#include <linux/compiler_types.h>
|
|
|
|
/*
|
|
* Use READ_ONCE_ALIGNED_128() for 128-bit block concurrent (atomic) read
|
|
* accesses. Note that x must be 128-bit aligned, otherwise a specification
|
|
* exception is generated.
|
|
*/
|
|
#define READ_ONCE_ALIGNED_128(x) \
|
|
({ \
|
|
union { \
|
|
typeof(x) __x; \
|
|
__uint128_t val; \
|
|
} __u; \
|
|
\
|
|
BUILD_BUG_ON(sizeof(x) != 16); \
|
|
asm volatile( \
|
|
" lpq %[val],%[_x]\n" \
|
|
: [val] "=d" (__u.val) \
|
|
: [_x] "QS" (x) \
|
|
: "memory"); \
|
|
__u.__x; \
|
|
})
|
|
|
|
#include <asm-generic/rwonce.h>
|
|
|
|
#endif /* __ASM_S390_RWONCE_H */
|