From dfa33ce1245a4b88402947fa0a847e179044d2fc Mon Sep 17 00:00:00 2001 From: Heiko Carstens Date: Mon, 11 Sep 2023 21:39:59 +0200 Subject: [PATCH] s390/ctlreg: add local_ctl_load() and local_ctl_store() Add local_ctl_load() and local_ctl_store() which load and store contents for only a single control register. This allows for easier to read code, but also better type checking, since __local_ctl_load() and __local_ctl_store() do not come with any type checking at all (which will be changed with subsequent patches). Reviewed-by: Alexander Gordeev Signed-off-by: Heiko Carstens Signed-off-by: Vasily Gorbik --- arch/s390/include/asm/ctlreg.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/arch/s390/include/asm/ctlreg.h b/arch/s390/include/asm/ctlreg.h index 09d35ab3d1ced..e8e5aef08bfd8 100644 --- a/arch/s390/include/asm/ctlreg.h +++ b/arch/s390/include/asm/ctlreg.h @@ -69,6 +69,23 @@ : [_low] "i" (low), [_high] "i" (high)); \ } while (0) +static __always_inline void local_ctl_load(unsigned int cr, unsigned long *reg) +{ + asm volatile( + " lctlg %[cr],%[cr],%[reg]\n" + : + : [reg] "Q" (*reg), [cr] "i" (cr) + : "memory"); +} + +static __always_inline void local_ctl_store(unsigned int cr, unsigned long *reg) +{ + asm volatile( + " stctg %[cr],%[cr],%[reg]\n" + : [reg] "=Q" (*reg) + : [cr] "i" (cr)); +} + static __always_inline void local_ctl_set_bit(unsigned int cr, unsigned int bit) { unsigned long reg; -- 2.30.2