diff mbox series

KVM: arm64: fix compile error because of shift overflow

Message ID 20220809094158.4080636-1-yangyingliang@huawei.com (mailing list archive)
State New, archived
Headers show
Series KVM: arm64: fix compile error because of shift overflow | expand

Commit Message

Yang Yingliang Aug. 9, 2022, 9:41 a.m. UTC
Change the mask to unsigned to fix the following fix compile error
because of shift overflow when using low verison gcc(mine version is 7.5):

In function ‘kvm_vm_ioctl_set_device_addr.isra.38’,
    inlined from ‘kvm_arch_vm_ioctl’ at arch/arm64/kvm/arm.c:1454:10:
././include/linux/compiler_types.h:354:38: error: call to ‘__compiletime_assert_599’ \
declared with attribute error: FIELD_GET: mask is not constant
  _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)

Fixes: 9f968c9266aa ("KVM: arm64: vgic-v2: Add helper for legacy dist/cpuif base address setting")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
 arch/arm64/include/uapi/asm/kvm.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Marc Zyngier Aug. 9, 2022, 10:16 a.m. UTC | #1
Hi Yang,

In the future, please add all the KVM/arm64 reviewers mentioned in
MAINTAINERS when sending KVM/arm64 patches.

On Tue, 09 Aug 2022 10:41:58 +0100,
Yang Yingliang <yangyingliang@huawei.com> wrote:
> 
> Change the mask to unsigned to fix the following fix compile error
> because of shift overflow when using low verison gcc(mine version is 7.5):
> 
> In function ‘kvm_vm_ioctl_set_device_addr.isra.38’,
>     inlined from ‘kvm_arch_vm_ioctl’ at arch/arm64/kvm/arm.c:1454:10:
> ././include/linux/compiler_types.h:354:38: error: call to ‘__compiletime_assert_599’ \
> declared with attribute error: FIELD_GET: mask is not constant
>   _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
> 
> Fixes: 9f968c9266aa ("KVM: arm64: vgic-v2: Add helper for legacy dist/cpuif base address setting")
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
> ---
>  arch/arm64/include/uapi/asm/kvm.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/arm64/include/uapi/asm/kvm.h b/arch/arm64/include/uapi/asm/kvm.h
> index 3bb134355874..04ffa13d5e0a 100644
> --- a/arch/arm64/include/uapi/asm/kvm.h
> +++ b/arch/arm64/include/uapi/asm/kvm.h
> @@ -77,7 +77,7 @@ struct kvm_regs {
>  #define KVM_ARM_DEVICE_TYPE_SHIFT	0
>  #define KVM_ARM_DEVICE_TYPE_MASK	(0xffff << KVM_ARM_DEVICE_TYPE_SHIFT)
>  #define KVM_ARM_DEVICE_ID_SHIFT		16
> -#define KVM_ARM_DEVICE_ID_MASK		(0xffff << KVM_ARM_DEVICE_ID_SHIFT)
> +#define KVM_ARM_DEVICE_ID_MASK		(0xffffu << KVM_ARM_DEVICE_ID_SHIFT)

I'd rather you use GENMASK() for this, making it completely
unambiguous (and for KVM_ARM_DEVICE_TYPE_MASK as well).

Thanks,

	M.
diff mbox series

Patch

diff --git a/arch/arm64/include/uapi/asm/kvm.h b/arch/arm64/include/uapi/asm/kvm.h
index 3bb134355874..04ffa13d5e0a 100644
--- a/arch/arm64/include/uapi/asm/kvm.h
+++ b/arch/arm64/include/uapi/asm/kvm.h
@@ -77,7 +77,7 @@  struct kvm_regs {
 #define KVM_ARM_DEVICE_TYPE_SHIFT	0
 #define KVM_ARM_DEVICE_TYPE_MASK	(0xffff << KVM_ARM_DEVICE_TYPE_SHIFT)
 #define KVM_ARM_DEVICE_ID_SHIFT		16
-#define KVM_ARM_DEVICE_ID_MASK		(0xffff << KVM_ARM_DEVICE_ID_SHIFT)
+#define KVM_ARM_DEVICE_ID_MASK		(0xffffu << KVM_ARM_DEVICE_ID_SHIFT)
 
 /* Supported device IDs */
 #define KVM_ARM_DEVICE_VGIC_V2		0