Skip to content

Commit b6db3eb

Browse files
Anastasia Belovawilldeacon
authored andcommitted
arm64: esr: Define ESR_ELx_EC_* constants as UL
Add explicit casting to prevent expantion of 32th bit of u32 into highest half of u64 in several places. For example, in inject_abt64: ESR_ELx_EC_DABT_LOW << ESR_ELx_EC_SHIFT = 0x24 << 26. This operation's result is int with 1 in 32th bit. While casting this value into u64 (esr is u64) 1 fills 32 highest bits. Found by Linux Verification Center (linuxtesting.org) with SVACE. Cc: <[email protected]> Fixes: aa8eff9 ("arm64: KVM: fault injection into a guest") Signed-off-by: Anastasia Belova <[email protected]> Acked-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/stable/20240910085016.32120-1-abelova%40astralinux.ru Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]>
1 parent 684fbd4 commit b6db3eb

File tree

1 file changed

+44
-44
lines changed
  • arch/arm64/include/asm

1 file changed

+44
-44
lines changed

arch/arm64/include/asm/esr.h

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -10,63 +10,63 @@
1010
#include <asm/memory.h>
1111
#include <asm/sysreg.h>
1212

13-
#define ESR_ELx_EC_UNKNOWN (0x00)
14-
#define ESR_ELx_EC_WFx (0x01)
13+
#define ESR_ELx_EC_UNKNOWN UL(0x00)
14+
#define ESR_ELx_EC_WFx UL(0x01)
1515
/* Unallocated EC: 0x02 */
16-
#define ESR_ELx_EC_CP15_32 (0x03)
17-
#define ESR_ELx_EC_CP15_64 (0x04)
18-
#define ESR_ELx_EC_CP14_MR (0x05)
19-
#define ESR_ELx_EC_CP14_LS (0x06)
20-
#define ESR_ELx_EC_FP_ASIMD (0x07)
21-
#define ESR_ELx_EC_CP10_ID (0x08) /* EL2 only */
22-
#define ESR_ELx_EC_PAC (0x09) /* EL2 and above */
16+
#define ESR_ELx_EC_CP15_32 UL(0x03)
17+
#define ESR_ELx_EC_CP15_64 UL(0x04)
18+
#define ESR_ELx_EC_CP14_MR UL(0x05)
19+
#define ESR_ELx_EC_CP14_LS UL(0x06)
20+
#define ESR_ELx_EC_FP_ASIMD UL(0x07)
21+
#define ESR_ELx_EC_CP10_ID UL(0x08) /* EL2 only */
22+
#define ESR_ELx_EC_PAC UL(0x09) /* EL2 and above */
2323
/* Unallocated EC: 0x0A - 0x0B */
24-
#define ESR_ELx_EC_CP14_64 (0x0C)
25-
#define ESR_ELx_EC_BTI (0x0D)
26-
#define ESR_ELx_EC_ILL (0x0E)
24+
#define ESR_ELx_EC_CP14_64 UL(0x0C)
25+
#define ESR_ELx_EC_BTI UL(0x0D)
26+
#define ESR_ELx_EC_ILL UL(0x0E)
2727
/* Unallocated EC: 0x0F - 0x10 */
28-
#define ESR_ELx_EC_SVC32 (0x11)
29-
#define ESR_ELx_EC_HVC32 (0x12) /* EL2 only */
30-
#define ESR_ELx_EC_SMC32 (0x13) /* EL2 and above */
28+
#define ESR_ELx_EC_SVC32 UL(0x11)
29+
#define ESR_ELx_EC_HVC32 UL(0x12) /* EL2 only */
30+
#define ESR_ELx_EC_SMC32 UL(0x13) /* EL2 and above */
3131
/* Unallocated EC: 0x14 */
32-
#define ESR_ELx_EC_SVC64 (0x15)
33-
#define ESR_ELx_EC_HVC64 (0x16) /* EL2 and above */
34-
#define ESR_ELx_EC_SMC64 (0x17) /* EL2 and above */
35-
#define ESR_ELx_EC_SYS64 (0x18)
36-
#define ESR_ELx_EC_SVE (0x19)
37-
#define ESR_ELx_EC_ERET (0x1a) /* EL2 only */
32+
#define ESR_ELx_EC_SVC64 UL(0x15)
33+
#define ESR_ELx_EC_HVC64 UL(0x16) /* EL2 and above */
34+
#define ESR_ELx_EC_SMC64 UL(0x17) /* EL2 and above */
35+
#define ESR_ELx_EC_SYS64 UL(0x18)
36+
#define ESR_ELx_EC_SVE UL(0x19)
37+
#define ESR_ELx_EC_ERET UL(0x1a) /* EL2 only */
3838
/* Unallocated EC: 0x1B */
39-
#define ESR_ELx_EC_FPAC (0x1C) /* EL1 and above */
40-
#define ESR_ELx_EC_SME (0x1D)
39+
#define ESR_ELx_EC_FPAC UL(0x1C) /* EL1 and above */
40+
#define ESR_ELx_EC_SME UL(0x1D)
4141
/* Unallocated EC: 0x1E */
42-
#define ESR_ELx_EC_IMP_DEF (0x1f) /* EL3 only */
43-
#define ESR_ELx_EC_IABT_LOW (0x20)
44-
#define ESR_ELx_EC_IABT_CUR (0x21)
45-
#define ESR_ELx_EC_PC_ALIGN (0x22)
42+
#define ESR_ELx_EC_IMP_DEF UL(0x1f) /* EL3 only */
43+
#define ESR_ELx_EC_IABT_LOW UL(0x20)
44+
#define ESR_ELx_EC_IABT_CUR UL(0x21)
45+
#define ESR_ELx_EC_PC_ALIGN UL(0x22)
4646
/* Unallocated EC: 0x23 */
47-
#define ESR_ELx_EC_DABT_LOW (0x24)
48-
#define ESR_ELx_EC_DABT_CUR (0x25)
49-
#define ESR_ELx_EC_SP_ALIGN (0x26)
50-
#define ESR_ELx_EC_MOPS (0x27)
51-
#define ESR_ELx_EC_FP_EXC32 (0x28)
47+
#define ESR_ELx_EC_DABT_LOW UL(0x24)
48+
#define ESR_ELx_EC_DABT_CUR UL(0x25)
49+
#define ESR_ELx_EC_SP_ALIGN UL(0x26)
50+
#define ESR_ELx_EC_MOPS UL(0x27)
51+
#define ESR_ELx_EC_FP_EXC32 UL(0x28)
5252
/* Unallocated EC: 0x29 - 0x2B */
53-
#define ESR_ELx_EC_FP_EXC64 (0x2C)
53+
#define ESR_ELx_EC_FP_EXC64 UL(0x2C)
5454
/* Unallocated EC: 0x2D - 0x2E */
55-
#define ESR_ELx_EC_SERROR (0x2F)
56-
#define ESR_ELx_EC_BREAKPT_LOW (0x30)
57-
#define ESR_ELx_EC_BREAKPT_CUR (0x31)
58-
#define ESR_ELx_EC_SOFTSTP_LOW (0x32)
59-
#define ESR_ELx_EC_SOFTSTP_CUR (0x33)
60-
#define ESR_ELx_EC_WATCHPT_LOW (0x34)
61-
#define ESR_ELx_EC_WATCHPT_CUR (0x35)
55+
#define ESR_ELx_EC_SERROR UL(0x2F)
56+
#define ESR_ELx_EC_BREAKPT_LOW UL(0x30)
57+
#define ESR_ELx_EC_BREAKPT_CUR UL(0x31)
58+
#define ESR_ELx_EC_SOFTSTP_LOW UL(0x32)
59+
#define ESR_ELx_EC_SOFTSTP_CUR UL(0x33)
60+
#define ESR_ELx_EC_WATCHPT_LOW UL(0x34)
61+
#define ESR_ELx_EC_WATCHPT_CUR UL(0x35)
6262
/* Unallocated EC: 0x36 - 0x37 */
63-
#define ESR_ELx_EC_BKPT32 (0x38)
63+
#define ESR_ELx_EC_BKPT32 UL(0x38)
6464
/* Unallocated EC: 0x39 */
65-
#define ESR_ELx_EC_VECTOR32 (0x3A) /* EL2 only */
65+
#define ESR_ELx_EC_VECTOR32 UL(0x3A) /* EL2 only */
6666
/* Unallocated EC: 0x3B */
67-
#define ESR_ELx_EC_BRK64 (0x3C)
67+
#define ESR_ELx_EC_BRK64 UL(0x3C)
6868
/* Unallocated EC: 0x3D - 0x3F */
69-
#define ESR_ELx_EC_MAX (0x3F)
69+
#define ESR_ELx_EC_MAX UL(0x3F)
7070

7171
#define ESR_ELx_EC_SHIFT (26)
7272
#define ESR_ELx_EC_WIDTH (6)

0 commit comments

Comments
 (0)