diff options
author | Heiko Carstens <hca@linux.ibm.com> | 2023-02-24 11:02:36 +0100 |
---|---|---|
committer | Heiko Carstens <hca@linux.ibm.com> | 2023-02-28 13:19:05 +0100 |
commit | 434b26605f6cc500c1a995587e5c4bc4bc1693c6 (patch) | |
tree | 6a8fc7fdd6f59486387ce18a1e325e8247457f71 /arch | |
parent | ebf95e884694b2c796ecb53d80d2b4cff8990d2f (diff) | |
download | linux-stable-434b26605f6cc500c1a995587e5c4bc4bc1693c6.tar.gz linux-stable-434b26605f6cc500c1a995587e5c4bc4bc1693c6.tar.bz2 linux-stable-434b26605f6cc500c1a995587e5c4bc4bc1693c6.zip |
s390/rwonce: add READ_ONCE_ALIGNED_128() macro
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>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/s390/include/asm/rwonce.h | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/arch/s390/include/asm/rwonce.h b/arch/s390/include/asm/rwonce.h new file mode 100644 index 000000000000..91fc24520e82 --- /dev/null +++ b/arch/s390/include/asm/rwonce.h @@ -0,0 +1,31 @@ +/* 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 */ |