lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <87wnbhv7yo.wl-maz@kernel.org>
Date:   Tue, 09 Aug 2022 14:53:51 +0100
From:   Marc Zyngier <maz@...nel.org>
To:     Yang Yingliang <yangyingliang@...wei.com>
Cc:     <linux-kernel@...r.kernel.org>, <kvmarm@...ts.cs.columbia.edu>,
        <linux-arm-kernel@...ts.infradead.org>, <james.morse@....com>,
        <alexandru.elisei@....com>, <suzuki.poulose@....com>,
        <oliver.upton@...ux.dev>
Subject: Re: [PATCH v2] KVM: arm64: fix compile error because of shift overflow

On Tue, 09 Aug 2022 14:51:27 +0100,
Yang Yingliang <yangyingliang@...wei.com> 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__)
> 
> Fixes: 9f968c9266aa ("KVM: arm64: vgic-v2: Add helper for legacy dist/cpuif base address setting")
> Signed-off-by: Yang Yingliang <yangyingliang@...wei.com>
> ---
> v2:
>   Using GENMASK() to generate the masks.
> ---
>  arch/arm64/include/uapi/asm/kvm.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/arm64/include/uapi/asm/kvm.h b/arch/arm64/include/uapi/asm/kvm.h
> index 3bb134355874..5e7dfaf76ec1 100644
> --- a/arch/arm64/include/uapi/asm/kvm.h
> +++ b/arch/arm64/include/uapi/asm/kvm.h
> @@ -75,9 +75,9 @@ 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(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(31, KVM_ARM_DEVICE_ID_SHIFT)
>  
>  /* Supported device IDs */
>  #define KVM_ARM_DEVICE_VGIC_V2		0

This is marginally better, but what I was expecting is something like:

#define KVM_ARM_DEVICE_ID_MASK	GENMASK(KVM_ARM_DEVICE_ID_SHIFT + 15, \
					KVM_ARM_DEVICE_ID_SHIFT)

which I find a bit more readable.

Thanks,

	M.

-- 
Without deviation from the norm, progress is not possible.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ