s390/ctlreg: add local_ctl_load() and local_ctl_store()
authorHeiko Carstens <hca@linux.ibm.com>
Mon, 11 Sep 2023 19:39:59 +0000 (21:39 +0200)
committerVasily Gorbik <gor@linux.ibm.com>
Tue, 19 Sep 2023 11:26:56 +0000 (13:26 +0200)
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 <agordeev@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
arch/s390/include/asm/ctlreg.h

index 09d35ab3d1cedd34dff83798635a36c9dabfb7a0..e8e5aef08bfd8183f6c92fc7df3661b07a70b880 100644 (file)
                : [_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;