s390/traps: get rid of magic cast for per code
authorHeiko Carstens <hca@linux.ibm.com>
Sun, 6 Mar 2022 09:59:05 +0000 (10:59 +0100)
committerVasily Gorbik <gor@linux.ibm.com>
Mon, 7 Mar 2022 23:33:01 +0000 (00:33 +0100)
Add a proper union in lowcore to reflect architecture and get rid of a
"magic" cast in order to read the full per code.

Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
arch/s390/include/asm/lowcore.h
arch/s390/kernel/traps.c

index 28a2c6ba795e7a51433276f4051fc796a66a3b2c..9829d6b44a20d0f99c81f527796b66254970da8c 100644 (file)
@@ -43,8 +43,13 @@ struct lowcore {
        };
        __u32   data_exc_code;                  /* 0x0090 */
        __u16   mon_class_num;                  /* 0x0094 */
-       __u8    per_code;                       /* 0x0096 */
-       __u8    per_atmid;                      /* 0x0097 */
+       union {
+               struct {
+                       __u8    per_code;       /* 0x0096 */
+                       __u8    per_atmid;      /* 0x0097 */
+               };
+               __u16 per_code_combined;
+       };
        __u64   per_address;                    /* 0x0098 */
        __u8    exc_access_id;                  /* 0x00a0 */
        __u8    per_access_id;                  /* 0x00a1 */
index a3c94dfcbe16cfffbc9843ac41d384c1dbc6b597..674c65019434e1b8fee354031943a0ba4ffbb794 100644 (file)
@@ -322,7 +322,7 @@ void noinstr __do_pgm_check(struct pt_regs *regs)
 
                        set_thread_flag(TIF_PER_TRAP);
                        ev->address = S390_lowcore.per_address;
-                       ev->cause = *(u16 *)&S390_lowcore.per_code;
+                       ev->cause = S390_lowcore.per_code_combined;
                        ev->paid = S390_lowcore.per_access_id;
                } else {
                        /* PER event in kernel is kprobes */