diff options
author | Heiko Carstens <hca@linux.ibm.com> | 2023-09-11 22:40:04 +0300 |
---|---|---|
committer | Vasily Gorbik <gor@linux.ibm.com> | 2023-09-19 14:26:56 +0300 |
commit | 527618abb92793b9d4dba548d55822dcebd95317 (patch) | |
tree | a33943001b1f0134ffc09e4cf0ecf1d267e44779 /arch/s390/include/asm | |
parent | ecc53818f60447177e24ea11b7f136c405150976 (diff) | |
download | linux-527618abb92793b9d4dba548d55822dcebd95317.tar.xz |
s390/ctlreg: add struct ctlreg
Add struct ctlreg to enforce strict type checking / usage for control
register functions.
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>
Diffstat (limited to 'arch/s390/include/asm')
-rw-r--r-- | arch/s390/include/asm/ctlreg.h | 28 | ||||
-rw-r--r-- | arch/s390/include/asm/kprobes.h | 3 | ||||
-rw-r--r-- | arch/s390/include/asm/lowcore.h | 7 | ||||
-rw-r--r-- | arch/s390/include/asm/mmu_context.h | 2 | ||||
-rw-r--r-- | arch/s390/include/asm/pgtable.h | 3 |
5 files changed, 27 insertions, 16 deletions
diff --git a/arch/s390/include/asm/ctlreg.h b/arch/s390/include/asm/ctlreg.h index a49459adba9d..57cc610dd997 100644 --- a/arch/s390/include/asm/ctlreg.h +++ b/arch/s390/include/asm/ctlreg.h @@ -35,6 +35,10 @@ #include <linux/bug.h> +struct ctlreg { + unsigned long val; +}; + #define __local_ctl_load(low, high, array) do { \ struct addrtype { \ char _[sizeof(array)]; \ @@ -43,9 +47,9 @@ int _low = low; \ int _esize; \ \ - _esize = (_high - _low + 1) * sizeof(unsigned long); \ + _esize = (_high - _low + 1) * sizeof(struct ctlreg); \ BUILD_BUG_ON(sizeof(struct addrtype) != _esize); \ - typecheck(unsigned long, array[0]); \ + typecheck(struct ctlreg, array[0]); \ asm volatile( \ " lctlg %[_low],%[_high],%[_arr]\n" \ : \ @@ -62,16 +66,16 @@ int _low = low; \ int _esize; \ \ - _esize = (_high - _low + 1) * sizeof(unsigned long); \ + _esize = (_high - _low + 1) * sizeof(struct ctlreg); \ BUILD_BUG_ON(sizeof(struct addrtype) != _esize); \ - typecheck(unsigned long, array[0]); \ + typecheck(struct ctlreg, array[0]); \ asm volatile( \ " stctg %[_low],%[_high],%[_arr]\n" \ : [_arr] "=Q" (*(struct addrtype *)(&array)) \ : [_low] "i" (low), [_high] "i" (high)); \ } while (0) -static __always_inline void local_ctl_load(unsigned int cr, unsigned long *reg) +static __always_inline void local_ctl_load(unsigned int cr, struct ctlreg *reg) { asm volatile( " lctlg %[cr],%[cr],%[reg]\n" @@ -80,7 +84,7 @@ static __always_inline void local_ctl_load(unsigned int cr, unsigned long *reg) : "memory"); } -static __always_inline void local_ctl_store(unsigned int cr, unsigned long *reg) +static __always_inline void local_ctl_store(unsigned int cr, struct ctlreg *reg) { asm volatile( " stctg %[cr],%[cr],%[reg]\n" @@ -90,19 +94,19 @@ static __always_inline void local_ctl_store(unsigned int cr, unsigned long *reg) static __always_inline void local_ctl_set_bit(unsigned int cr, unsigned int bit) { - unsigned long reg; + struct ctlreg reg; local_ctl_store(cr, ®); - reg |= 1UL << bit; + reg.val |= 1UL << bit; local_ctl_load(cr, ®); } static __always_inline void local_ctl_clear_bit(unsigned int cr, unsigned int bit) { - unsigned long reg; + struct ctlreg reg; local_ctl_store(cr, ®); - reg &= ~(1UL << bit); + reg.val &= ~(1UL << bit); local_ctl_load(cr, ®); } @@ -122,6 +126,7 @@ static inline void system_ctl_clear_bit(unsigned int cr, unsigned int bit) union ctlreg0 { unsigned long val; + struct ctlreg reg; struct { unsigned long : 8; unsigned long tcx : 1; /* Transactional-Execution control */ @@ -148,6 +153,7 @@ union ctlreg0 { union ctlreg2 { unsigned long val; + struct ctlreg reg; struct { unsigned long : 33; unsigned long ducto : 25; @@ -161,6 +167,7 @@ union ctlreg2 { union ctlreg5 { unsigned long val; + struct ctlreg reg; struct { unsigned long : 33; unsigned long pasteo: 25; @@ -170,6 +177,7 @@ union ctlreg5 { union ctlreg15 { unsigned long val; + struct ctlreg reg; struct { unsigned long lsea : 61; unsigned long : 3; diff --git a/arch/s390/include/asm/kprobes.h b/arch/s390/include/asm/kprobes.h index 83f732ca3af4..21b9e5290c04 100644 --- a/arch/s390/include/asm/kprobes.h +++ b/arch/s390/include/asm/kprobes.h @@ -15,6 +15,7 @@ * <grundym@us.ibm.com> */ #include <linux/types.h> +#include <asm/ctlreg.h> #include <asm-generic/kprobes.h> #define BREAKPOINT_INSTRUCTION 0x0002 @@ -65,7 +66,7 @@ struct prev_kprobe { struct kprobe_ctlblk { unsigned long kprobe_status; unsigned long kprobe_saved_imask; - unsigned long kprobe_saved_ctl[3]; + struct ctlreg kprobe_saved_ctl[3]; struct prev_kprobe prev_kprobe; }; diff --git a/arch/s390/include/asm/lowcore.h b/arch/s390/include/asm/lowcore.h index 2174f00e188b..3366431dcad5 100644 --- a/arch/s390/include/asm/lowcore.h +++ b/arch/s390/include/asm/lowcore.h @@ -11,6 +11,7 @@ #include <linux/types.h> #include <asm/ptrace.h> +#include <asm/ctlreg.h> #include <asm/cpu.h> #include <asm/types.h> @@ -139,8 +140,8 @@ struct lowcore { __u32 restart_flags; /* 0x0384 */ /* Address space pointer. */ - unsigned long kernel_asce; /* 0x0388 */ - unsigned long user_asce; /* 0x0390 */ + struct ctlreg kernel_asce; /* 0x0388 */ + struct ctlreg user_asce; /* 0x0390 */ /* * The lpp and current_pid fields form a @@ -199,7 +200,7 @@ struct lowcore { __u32 clock_comp_save_area[2]; /* 0x1330 */ __u64 last_break_save_area; /* 0x1338 */ __u32 access_regs_save_area[16]; /* 0x1340 */ - unsigned long cregs_save_area[16]; /* 0x1380 */ + struct ctlreg cregs_save_area[16]; /* 0x1380 */ __u8 pad_0x1400[0x1500-0x1400]; /* 0x1400 */ /* Cryptography-counter designation */ __u64 ccd; /* 0x1500 */ diff --git a/arch/s390/include/asm/mmu_context.h b/arch/s390/include/asm/mmu_context.h index 0e93275f80f0..757fe6f0d802 100644 --- a/arch/s390/include/asm/mmu_context.h +++ b/arch/s390/include/asm/mmu_context.h @@ -78,7 +78,7 @@ static inline void switch_mm_irqs_off(struct mm_struct *prev, struct mm_struct * if (next == &init_mm) S390_lowcore.user_asce = s390_invalid_asce; else - S390_lowcore.user_asce = next->context.asce; + S390_lowcore.user_asce.val = next->context.asce; cpumask_set_cpu(cpu, &next->context.cpu_attach_mask); /* Clear previous user-ASCE from CR7 */ local_ctl_load(7, &s390_invalid_asce); diff --git a/arch/s390/include/asm/pgtable.h b/arch/s390/include/asm/pgtable.h index fb3ee7758b76..601e87fa8a9a 100644 --- a/arch/s390/include/asm/pgtable.h +++ b/arch/s390/include/asm/pgtable.h @@ -18,6 +18,7 @@ #include <linux/radix-tree.h> #include <linux/atomic.h> #include <asm/sections.h> +#include <asm/ctlreg.h> #include <asm/bug.h> #include <asm/page.h> #include <asm/uv.h> @@ -25,7 +26,7 @@ extern pgd_t swapper_pg_dir[]; extern pgd_t invalid_pg_dir[]; extern void paging_init(void); -extern unsigned long s390_invalid_asce; +extern struct ctlreg s390_invalid_asce; enum { PG_DIRECT_MAP_4K = 0, |