All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] KVM: arm64: fix compile error because of shift overflow
@ 2022-08-10  1:34 ` Yang Yingliang
  0 siblings, 0 replies; 6+ messages in thread
From: Yang Yingliang @ 2022-08-10  1:34 UTC (permalink / raw)
  To: linux-kernel, kvmarm, linux-arm-kernel
  Cc: maz, james.morse, alexandru.elisei, suzuki.poulose, oliver.upton

Using GENMASK() to generate the masks of device type and device id, it makes
code unambiguous, also it can 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>
---
v3:
 replace '15/31' with 'SHIFT + 15' to make it more readable.
v2:
  Using GENMASK() to generate the masks.
---
 arch/arm64/include/uapi/asm/kvm.h | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/include/uapi/asm/kvm.h b/arch/arm64/include/uapi/asm/kvm.h
index 3bb134355874..316917b98707 100644
--- a/arch/arm64/include/uapi/asm/kvm.h
+++ b/arch/arm64/include/uapi/asm/kvm.h
@@ -75,9 +75,11 @@ struct kvm_regs {
 
 /* KVM_ARM_SET_DEVICE_ADDR ioctl id encoding */
 #define KVM_ARM_DEVICE_TYPE_SHIFT	0
-#define KVM_ARM_DEVICE_TYPE_MASK	(0xffff << KVM_ARM_DEVICE_TYPE_SHIFT)
+#define KVM_ARM_DEVICE_TYPE_MASK	GENMASK(KVM_ARM_DEVICE_TYPE_SHIFT + 15, \
+						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		GENMASK(KVM_ARM_DEVICE_ID_SHIFT + 15, \
+						KVM_ARM_DEVICE_ID_SHIFT)
 
 /* Supported device IDs */
 #define KVM_ARM_DEVICE_VGIC_V2		0
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v3] KVM: arm64: fix compile error because of shift overflow
@ 2022-08-10  1:34 ` Yang Yingliang
  0 siblings, 0 replies; 6+ messages in thread
From: Yang Yingliang @ 2022-08-10  1:34 UTC (permalink / raw)
  To: linux-kernel, kvmarm, linux-arm-kernel; +Cc: maz

Using GENMASK() to generate the masks of device type and device id, it makes
code unambiguous, also it can 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>
---
v3:
 replace '15/31' with 'SHIFT + 15' to make it more readable.
v2:
  Using GENMASK() to generate the masks.
---
 arch/arm64/include/uapi/asm/kvm.h | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/include/uapi/asm/kvm.h b/arch/arm64/include/uapi/asm/kvm.h
index 3bb134355874..316917b98707 100644
--- a/arch/arm64/include/uapi/asm/kvm.h
+++ b/arch/arm64/include/uapi/asm/kvm.h
@@ -75,9 +75,11 @@ struct kvm_regs {
 
 /* KVM_ARM_SET_DEVICE_ADDR ioctl id encoding */
 #define KVM_ARM_DEVICE_TYPE_SHIFT	0
-#define KVM_ARM_DEVICE_TYPE_MASK	(0xffff << KVM_ARM_DEVICE_TYPE_SHIFT)
+#define KVM_ARM_DEVICE_TYPE_MASK	GENMASK(KVM_ARM_DEVICE_TYPE_SHIFT + 15, \
+						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		GENMASK(KVM_ARM_DEVICE_ID_SHIFT + 15, \
+						KVM_ARM_DEVICE_ID_SHIFT)
 
 /* Supported device IDs */
 #define KVM_ARM_DEVICE_VGIC_V2		0
-- 
2.25.1

_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v3] KVM: arm64: fix compile error because of shift overflow
@ 2022-08-10  1:34 ` Yang Yingliang
  0 siblings, 0 replies; 6+ messages in thread
From: Yang Yingliang @ 2022-08-10  1:34 UTC (permalink / raw)
  To: linux-kernel, kvmarm, linux-arm-kernel
  Cc: maz, james.morse, alexandru.elisei, suzuki.poulose, oliver.upton

Using GENMASK() to generate the masks of device type and device id, it makes
code unambiguous, also it can 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>
---
v3:
 replace '15/31' with 'SHIFT + 15' to make it more readable.
v2:
  Using GENMASK() to generate the masks.
---
 arch/arm64/include/uapi/asm/kvm.h | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/include/uapi/asm/kvm.h b/arch/arm64/include/uapi/asm/kvm.h
index 3bb134355874..316917b98707 100644
--- a/arch/arm64/include/uapi/asm/kvm.h
+++ b/arch/arm64/include/uapi/asm/kvm.h
@@ -75,9 +75,11 @@ struct kvm_regs {
 
 /* KVM_ARM_SET_DEVICE_ADDR ioctl id encoding */
 #define KVM_ARM_DEVICE_TYPE_SHIFT	0
-#define KVM_ARM_DEVICE_TYPE_MASK	(0xffff << KVM_ARM_DEVICE_TYPE_SHIFT)
+#define KVM_ARM_DEVICE_TYPE_MASK	GENMASK(KVM_ARM_DEVICE_TYPE_SHIFT + 15, \
+						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		GENMASK(KVM_ARM_DEVICE_ID_SHIFT + 15, \
+						KVM_ARM_DEVICE_ID_SHIFT)
 
 /* Supported device IDs */
 #define KVM_ARM_DEVICE_VGIC_V2		0
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v3] KVM: arm64: fix compile error because of shift overflow
  2022-08-10  1:34 ` Yang Yingliang
  (?)
@ 2022-08-10  9:08   ` Marc Zyngier
  -1 siblings, 0 replies; 6+ messages in thread
From: Marc Zyngier @ 2022-08-10  9:08 UTC (permalink / raw)
  To: kvmarm, linux-arm-kernel, Yang Yingliang, linux-kernel
  Cc: oliver.upton, suzuki.poulose, james.morse, alexandru.elisei

On Wed, 10 Aug 2022 09:34:35 +0800, Yang Yingliang wrote:
> Using GENMASK() to generate the masks of device type and device id, it makes
> code unambiguous, also it can 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__)

Applied to fixes, thanks!

[1/1] KVM: arm64: fix compile error because of shift overflow
      commit: ae3b1da95413614f96ffa23d200929c6f809c807

Cheers,

	M.
-- 
Marc Zyngier <maz@kernel.org>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v3] KVM: arm64: fix compile error because of shift overflow
@ 2022-08-10  9:08   ` Marc Zyngier
  0 siblings, 0 replies; 6+ messages in thread
From: Marc Zyngier @ 2022-08-10  9:08 UTC (permalink / raw)
  To: kvmarm, linux-arm-kernel, Yang Yingliang, linux-kernel

On Wed, 10 Aug 2022 09:34:35 +0800, Yang Yingliang wrote:
> Using GENMASK() to generate the masks of device type and device id, it makes
> code unambiguous, also it can 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__)

Applied to fixes, thanks!

[1/1] KVM: arm64: fix compile error because of shift overflow
      commit: ae3b1da95413614f96ffa23d200929c6f809c807

Cheers,

	M.
-- 
Marc Zyngier <maz@kernel.org>

_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v3] KVM: arm64: fix compile error because of shift overflow
@ 2022-08-10  9:08   ` Marc Zyngier
  0 siblings, 0 replies; 6+ messages in thread
From: Marc Zyngier @ 2022-08-10  9:08 UTC (permalink / raw)
  To: kvmarm, linux-arm-kernel, Yang Yingliang, linux-kernel
  Cc: oliver.upton, suzuki.poulose, james.morse, alexandru.elisei

On Wed, 10 Aug 2022 09:34:35 +0800, Yang Yingliang wrote:
> Using GENMASK() to generate the masks of device type and device id, it makes
> code unambiguous, also it can 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__)

Applied to fixes, thanks!

[1/1] KVM: arm64: fix compile error because of shift overflow
      commit: ae3b1da95413614f96ffa23d200929c6f809c807

Cheers,

	M.
-- 
Marc Zyngier <maz@kernel.org>


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-08-10  9:09 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-10  1:34 [PATCH v3] KVM: arm64: fix compile error because of shift overflow Yang Yingliang
2022-08-10  1:34 ` Yang Yingliang
2022-08-10  1:34 ` Yang Yingliang
2022-08-10  9:08 ` Marc Zyngier
2022-08-10  9:08   ` Marc Zyngier
2022-08-10  9:08   ` Marc Zyngier

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.