Skip to content

Commit 516f3f7

Browse files
murzinvAlex Shi
authored andcommitted
arm: KVM: Make kvm_arm.h friendly to assembly code
kvm_arm.h is included from both C code and assembly code; however some definitions in this header supplied with U/UL/ULL suffixes which might confuse assembly once they got evaluated. We have _AC macro for such cases, so just wrap problem places with it. Acked-by: Christoffer Dall <christoffer.dall@linaro.org> Signed-off-by: Vladimir Murzin <vladimir.murzin@arm.com> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com> (cherry picked from commit 8420dcd37ef34040c8fc5a27bf66887b3b2faf80) Signed-off-by: Alex Shi <alex.shi@linaro.org>
1 parent ab05402 commit 516f3f7

1 file changed

Lines changed: 17 additions & 16 deletions

File tree

arch/arm/include/asm/kvm_arm.h

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#ifndef __ARM_KVM_ARM_H__
2020
#define __ARM_KVM_ARM_H__
2121

22+
#include <linux/const.h>
2223
#include <linux/types.h>
2324

2425
/* Hyp Configuration Register (HCR) bits */
@@ -132,9 +133,9 @@
132133
* space.
133134
*/
134135
#define KVM_PHYS_SHIFT (40)
135-
#define KVM_PHYS_SIZE (1ULL << KVM_PHYS_SHIFT)
136-
#define KVM_PHYS_MASK (KVM_PHYS_SIZE - 1ULL)
137-
#define PTRS_PER_S2_PGD (1ULL << (KVM_PHYS_SHIFT - 30))
136+
#define KVM_PHYS_SIZE (_AC(1, ULL) << KVM_PHYS_SHIFT)
137+
#define KVM_PHYS_MASK (KVM_PHYS_SIZE - _AC(1, ULL))
138+
#define PTRS_PER_S2_PGD (_AC(1, ULL) << (KVM_PHYS_SHIFT - 30))
138139

139140
/* Virtualization Translation Control Register (VTCR) bits */
140141
#define VTCR_SH0 (3 << 12)
@@ -161,27 +162,27 @@
161162
#define VTTBR_X (5 - KVM_T0SZ)
162163
#endif
163164
#define VTTBR_BADDR_SHIFT (VTTBR_X - 1)
164-
#define VTTBR_BADDR_MASK (((1LLU << (40 - VTTBR_X)) - 1) << VTTBR_BADDR_SHIFT)
165-
#define VTTBR_VMID_SHIFT (48LLU)
166-
#define VTTBR_VMID_MASK (0xffLLU << VTTBR_VMID_SHIFT)
165+
#define VTTBR_BADDR_MASK (((_AC(1, ULL) << (40 - VTTBR_X)) - 1) << VTTBR_BADDR_SHIFT)
166+
#define VTTBR_VMID_SHIFT _AC(48, ULL)
167+
#define VTTBR_VMID_MASK (_AC(0xff, ULL) << VTTBR_VMID_SHIFT)
167168

168169
/* Hyp Syndrome Register (HSR) bits */
169170
#define HSR_EC_SHIFT (26)
170-
#define HSR_EC (0x3fU << HSR_EC_SHIFT)
171-
#define HSR_IL (1U << 25)
171+
#define HSR_EC (_AC(0x3f, UL) << HSR_EC_SHIFT)
172+
#define HSR_IL (_AC(1, UL) << 25)
172173
#define HSR_ISS (HSR_IL - 1)
173174
#define HSR_ISV_SHIFT (24)
174-
#define HSR_ISV (1U << HSR_ISV_SHIFT)
175+
#define HSR_ISV (_AC(1, UL) << HSR_ISV_SHIFT)
175176
#define HSR_SRT_SHIFT (16)
176177
#define HSR_SRT_MASK (0xf << HSR_SRT_SHIFT)
177178
#define HSR_FSC (0x3f)
178179
#define HSR_FSC_TYPE (0x3c)
179180
#define HSR_SSE (1 << 21)
180181
#define HSR_WNR (1 << 6)
181182
#define HSR_CV_SHIFT (24)
182-
#define HSR_CV (1U << HSR_CV_SHIFT)
183+
#define HSR_CV (_AC(1, UL) << HSR_CV_SHIFT)
183184
#define HSR_COND_SHIFT (20)
184-
#define HSR_COND (0xfU << HSR_COND_SHIFT)
185+
#define HSR_COND (_AC(0xf, UL) << HSR_COND_SHIFT)
185186

186187
#define FSC_FAULT (0x04)
187188
#define FSC_ACCESS (0x08)
@@ -209,13 +210,13 @@
209210
#define HSR_EC_DABT (0x24)
210211
#define HSR_EC_DABT_HYP (0x25)
211212

212-
#define HSR_WFI_IS_WFE (1U << 0)
213+
#define HSR_WFI_IS_WFE (_AC(1, UL) << 0)
213214

214-
#define HSR_HVC_IMM_MASK ((1UL << 16) - 1)
215+
#define HSR_HVC_IMM_MASK ((_AC(1, UL) << 16) - 1)
215216

216-
#define HSR_DABT_S1PTW (1U << 7)
217-
#define HSR_DABT_CM (1U << 8)
218-
#define HSR_DABT_EA (1U << 9)
217+
#define HSR_DABT_S1PTW (_AC(1, UL) << 7)
218+
#define HSR_DABT_CM (_AC(1, UL) << 8)
219+
#define HSR_DABT_EA (_AC(1, UL) << 9)
219220

220221
#define kvm_arm_exception_type \
221222
{0, "RESET" }, \

0 commit comments

Comments
 (0)