Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp12647094ybl; Sat, 28 Dec 2019 17:32:47 -0800 (PST) X-Google-Smtp-Source: APXvYqygqz0rC+zgCWR1x7OyRRYtFIDfIAzM+n1BFhSM2rWvz3//kw6hvejUm7Pgk+sae1u6Ai6N X-Received: by 2002:a05:6830:2116:: with SMTP id i22mr68650455otc.0.1577583167926; Sat, 28 Dec 2019 17:32:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577583167; cv=none; d=google.com; s=arc-20160816; b=Mij+vi1wBUnbPfOwF4TVHgApj47S806cTLC9opUDHLI6LwPbktzVpSfaIa8POdVNQM z4NExdhTcq8vD0Bgqc9SpEkgZDhCucraWOd4S8BIhpu8yHYYG9yllr5lkSE0EHK7Ojw+ E0Kma63ldVInyHCfiYzEeTco3kM8pHVBbHHZoErWsgY2J3T3iaLe4G86qPvf2ECpxRPJ /0RmB2cBdQahkOpQnjuKT1KrCpQPYiyb8uBoiTKLnSSxuOsM45IfZ1eut//gW3iCw04Y IjHHfnz9z+KeqInqmZGMKP5+8lBCDyyFH8W0nnbyuTftwQ21CuKGYnpp7meHZkWo9WaY CteA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id :dkim-signature:dkim-signature; bh=WNYhcjhj9MAeI/B6Jk8c6BS9EmSY+DFpWoiFMX2hB4A=; b=pCH8323hzMeYLuid5p9DCdbmAdjnwqXzoRrYb8x+AGqWIxGjWEetPAnfsufpIycjTA cqamDb8eVH89D0RCZl3vp4kFos6rbtZ9Ft0A7Nnzy7lR1oRZxNRPWHIXzgrFSZYuzM74 yc8l6vDM/JbsRz7NvFUCJUV1QcpQ8gk7+rwUN2Ds4kHvm0p8sWAuFNMYflNhaLmaMIgy GhNhfemDgZ5XlwTNeUQ1gJVZCghYer5I7w2P6chuAu7kVJE9vri9hRKiuAn4FEYFzHTS t7G1l9Zt0jVlMamQJyL1OcuXmRMgxVtoHxSLM+eQcvVRbNzUdLoG5Yg6z8NYiUnmwv9N 2TCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@hansenpartnership.com header.s=20151216 header.b=BPxXS8BV; dkim=fail header.i=@hansenpartnership.com header.s=20151216 header.b="f/jP5S5b"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=hansenpartnership.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z14si21273738oth.15.2019.12.28.17.32.34; Sat, 28 Dec 2019 17:32:47 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@hansenpartnership.com header.s=20151216 header.b=BPxXS8BV; dkim=fail header.i=@hansenpartnership.com header.s=20151216 header.b="f/jP5S5b"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=hansenpartnership.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726366AbfL2Bbk (ORCPT + 99 others); Sat, 28 Dec 2019 20:31:40 -0500 Received: from bedivere.hansenpartnership.com ([66.63.167.143]:39492 "EHLO bedivere.hansenpartnership.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726187AbfL2Bbk (ORCPT ); Sat, 28 Dec 2019 20:31:40 -0500 Received: from localhost (localhost [127.0.0.1]) by bedivere.hansenpartnership.com (Postfix) with ESMTP id 0C43E8EE0DA; Sat, 28 Dec 2019 17:31:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=hansenpartnership.com; s=20151216; t=1577583100; bh=zbW9WWjeZOxIUrHi9cV0hkGSGh9fn/LBCcZFRjsx/Eo=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=BPxXS8BVm4iNWQthxVc54Px8MbXMUronXvfS+qIJe9n7MU5v6jgY+bdi41eGNLQ/I lOJtGbs5/oXzj3btPfzdfpW7qDQB83/FItyOLigClUosLNTSsfYa6F/fGB8/yvc7Ch lBTMYOgbiLGgmuV9ue9DuP36FyixXfYtS7klfO8g= Received: from bedivere.hansenpartnership.com ([127.0.0.1]) by localhost (bedivere.hansenpartnership.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 8mcakcWKeBlo; Sat, 28 Dec 2019 17:31:39 -0800 (PST) Received: from jarvis.lan (unknown [50.35.76.230]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bedivere.hansenpartnership.com (Postfix) with ESMTPSA id 4249A8EE007; Sat, 28 Dec 2019 17:31:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=hansenpartnership.com; s=20151216; t=1577583099; bh=zbW9WWjeZOxIUrHi9cV0hkGSGh9fn/LBCcZFRjsx/Eo=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=f/jP5S5bhWkg9HidRZ3o4rOA2Ptr0sXFqzGTvye0iM2M0CpR0w1yZ2isI5SAdiQXI fErms7c40y+32/icy7WsoWUZfnPpmK42uolC3zC4PBmPFXd30n6QNlHKo5sPxux3hc bjvQ6QilqR3HEoc4V1OiR6u2MH5KrbAjJZqoglug= Message-ID: <1577583097.5661.6.camel@HansenPartnership.com> Subject: Re: [PATCH] mm/hugetlb: ensure signedness of large numbers From: James Bottomley To: isidentical Cc: Arnd Bergmann , linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Date: Sat, 28 Dec 2019 17:31:37 -0800 In-Reply-To: <20191228103357.23904-1-batuhanosmantaskaya@gmail.com> References: <20191228103357.23904-1-batuhanosmantaskaya@gmail.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.26.6 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 2019-12-28 at 13:33 +0300, isidentical wrote: > This change introduces a sanitity helper for > numbers that are larger than 2^5. What's the rationale for this ... i.e. what problem are you trying to solve? left to its own devices, gcc will assume int size for all literals, so 34<<26 doesn't appear to have a problem, except that it will be sign extended as a negative number into a 64 bit variable. However, it's designed use is for an int flags in mmap, so its current definition seems to be fine. > Signed-off-by: isidentical > --- > include/uapi/asm-generic/hugetlb_encode.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/include/uapi/asm-generic/hugetlb_encode.h > b/include/uapi/asm-generic/hugetlb_encode.h > index b0f8e87235bd..42c06c62ae17 100644 > --- a/include/uapi/asm-generic/hugetlb_encode.h > +++ b/include/uapi/asm-generic/hugetlb_encode.h > @@ -31,6 +31,6 @@ > #define HUGETLB_FLAG_ENCODE_512MB (29 << > HUGETLB_FLAG_ENCODE_SHIFT) > #define HUGETLB_FLAG_ENCODE_1GB (30 << > HUGETLB_FLAG_ENCODE_SHIFT) > #define HUGETLB_FLAG_ENCODE_2GB (31 << > HUGETLB_FLAG_ENCODE_SHIFT) > -#define HUGETLB_FLAG_ENCODE_16GB (34 << > HUGETLB_FLAG_ENCODE_SHIFT) > +#define HUGETLB_FLAG_ENCODE_16GB (UINT32_C(34) << > HUGETLB_FLAG_ENCODE_SHIFT) And if there is a literal problem here, it can't be solved like this: UINT32_C is a Cism which has no analogue in the kernel because we don't pull in the /usr/include headers where it is defined. Usually in the kernel we solve this by making the literal type explicit, like 34U, but as I said above, I don't see a problem that this would solve. James