Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751911AbdHCNVC (ORCPT ); Thu, 3 Aug 2017 09:21:02 -0400 Received: from mail-sn1nam02on0042.outbound.protection.outlook.com ([104.47.36.42]:42070 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751134AbdHCNU7 (ORCPT ); Thu, 3 Aug 2017 09:20:59 -0400 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Yuri.Norov@cavium.com; Date: Thu, 3 Aug 2017 16:20:35 +0300 From: Yury Norov To: Matthias Kaehlcke Cc: zijun_hu , Andrew Morton , Catalin Marinas , Will Deacon , Mark Rutland , Laura Abbott , Nick Desaulniers , linux-kernel@vger.kernel.org, Greg Hackmann , Doug Anderson , linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH 2/2] arm64: Define PAGE_OFFSET using GENMASK_ULL Message-ID: <20170803132035.gixd7m7oxtehpquu@yury-thinkpad> References: <20170802225159.159536-1-mka@chromium.org> <20170802225159.159536-2-mka@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170802225159.159536-2-mka@chromium.org> User-Agent: NeoMutt/20170113 (1.7.2) X-Originating-IP: [41.141.206.184] X-ClientProxiedBy: VI1P190CA0002.EURP190.PROD.OUTLOOK.COM (10.165.188.143) To BN4PR07MB2115.namprd07.prod.outlook.com (10.164.62.157) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 70417958-62a3-40e3-f02b-08d4da72798d X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(300000503095)(300135400095)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:BN4PR07MB2115; X-Microsoft-Exchange-Diagnostics: 1;BN4PR07MB2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o/DWTCGE17YAS1JEYLmVmMFm8BCFuk1gu+0HwbmCZQ1+p9pt8EJW9BQTYGN7BObfVbaZossiioxvuGYZAjCfjcCM7hWi7tGRvpjP8tIy5hnCZFiZQn3889tUOCpwtR8hoAtOhtvcYXwpSCse6OqhBzb7Cg7PEX+uJ0utqgQvaol4rMBsLGC7IM8e3mVxyUJmwJWFwBkVkVUCb7XRE2x2BvJelHj03ckSEgfhM5Ohb5NJi7jkMIHO1xsTj/RpAUGcqnLfvYefdtWTYYP2otize4m+gKsgxhXI3qQpzD+AQWjVdKS/soRthmmgC+MTdzmYiQ9A/ltyt0folySpev48GZMH1kwGzPtw4D9+xWjALCEgVuBCHH+Ls9VUNS+ODCgcceGKGy7i5il9PipK/PwRLylGc10t+KdZR67M3Iq+4L90RfmOVf4u/KyxGDvmnkRUIUS1Ko3YHE9Q= X-Exchange-Antispam-Report-Test: UriScan:(258649278758335)(211936372134217)(153496737603132); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(8121501046)(5005006)(100000703101)(100105400095)(93006095)(10201501046)(3002001)(920507026)(6041248)(20161123564025)(20161123560025)(20161123562025)(20161123555025)(20161123558100)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(6072148)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:BN4PR07MB2115;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:BN4PR07MB2115; X-Microsoft-Exchange-Diagnostics: 1;BN4PR07MB2115;4:2J8Tng5RJVZm4F+NZCn0dZUHTsnsCLZ8u1EJbLNrd4MZRwSziJqVpAaFcAAwgroqBUHHuyAEhKY1UrD/jTnk694ne367RnsCWQ6EXZa5C8r0Den5CTc6bxQK41PTfhCC2nfJ9Urjm10lr1Cgk9UwQd7yuQoVlc8iwMlVW0SG1TY9KxM+aglMiTASYnxq7eTMrXt3hgtEaL4zgj/qzM1VojeQqKYf+9I0YYzSyGZAXb380151cjVQWuA0cJ16lVLAzv1hyLn+DROCD86Z8DwnW5giL8TxLwRX12bzRtl627C6EYsWQCqof/pF16vsMH7jqEm+3yK+Q39i9paADrk8bCHQ+dSLnTzNUyTNVFJ9zzw= X-Forefront-PRVS: 03883BD916 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(7370300001)(4630300001)(6069001)(6009001)(39840400002)(39410400002)(39400400002)(39450400003)(39850400002)(189002)(24454002)(199003)(6306002)(9686003)(53936002)(33716001)(54906002)(6246003)(2906002)(110136004)(6496005)(2950100002)(6666003)(42882006)(50466002)(6916009)(38730400002)(1720100001)(66066001)(47776003)(5001810100001)(189998001)(97736004)(229853002)(4001350100001)(305945005)(7736002)(8676002)(81166006)(81156014)(6486002)(478600001)(76176999)(50986999)(54356999)(106356001)(23726003)(105586002)(34040400001)(7350300001)(25786009)(68736007)(1076002)(33646002)(83506001)(4326008)(10646004)(72206003)(3846002)(42186005)(10916006)(6116002)(101416001)(5660300001)(76506005)(966005)(7416002)(3486003);DIR:OUT;SFP:1101;SCL:1;SRVR:BN4PR07MB2115;H:localhost;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BN4PR07MB2115;23:jhel0DqHXLdpzS1o4BY+L1BS7Ya+m04sDQtnZwfqm?= =?us-ascii?Q?Pgd4IPNMbXSZ0mZc4u9WJ5jnUSzxQlkq5iL9ZVelgguE7pd5DJabISlyO5ZJ?= =?us-ascii?Q?XYooUil2iEANLr2mBGka/l4xlDkB6x0GjCxufPkW5HkrPoK2l//e2MHwexe4?= =?us-ascii?Q?n3GvqIZdG7CQWwJKiIrbryrdGeYNi+jyH467tk0sWRzGUR3s7YEEDVrD9JV4?= =?us-ascii?Q?wbOyw4mD1X+97JBfhu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B7UtkUE4iV7CKfraWpTagirGdj6diqeglarXwP0RXqCrxrRuUKVeY7EtKUCxc58nxhzFqgPAO9x8YOS8+EMWuVcLaw==;24:T4iThvR557MUbMhk6I3r5S+GLQAoCKn0zdF9zdpJ4uyN33J6f5G4yH0FSdrM2xg18MhtZ/TH2S1Ev+ODIznEzVxuCQQFjjOzqZMER07maHg=;7:UXYlF3+nnFDVYnTSujvnT1U28lOs/Xae4Pca0iXP1MjQ6GEAO1F8oFI1w4NT8W5TRAD8RLO1ZKd867bpnr8RNdSmupOOSLL2mwgPnRDiRwb03C4e7R066tJ8vUIGCb+ylDppKo3BXPAsbWuhPUcicU3TZCDIhGss/IGqrcsibO3KemEpJV7yfnf2k4S1o9mwSye4o+ayAIu7nRLHZKEL45zxspWDqf/hWYzLvQQ96AA= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Aug 2017 13:20:54.3428 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN4PR07MB2115 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2062 Lines: 53 Hi Matthias, On Wed, Aug 02, 2017 at 03:51:59PM -0700, Matthias Kaehlcke wrote: > As is the definition causes an integer overflow, which is expected, > however clang raises the following warning: > > arch/arm64/kernel/head.S:47:8: warning: > integer overflow in preprocessor expression > #elif (PAGE_OFFSET & 0x1fffff) != 0 > ^~~~~~~~~~~ > arch/arm64/include/asm/memory.h:52:46: note: > expanded from macro 'PAGE_OFFSET' > #define PAGE_OFFSET (UL(0xffffffffffffffff) << (VA_BITS - 1)) > ~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~ > > Use GENMASK_ULL() instead of shifting explicitly, the macro takes care > of avoiding the overflow. > > Reported-by: Nick Desaulniers > Signed-off-by: Matthias Kaehlcke > --- > arch/arm64/include/asm/memory.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h > index 32f82723338a..732d4eed8edd 100644 > --- a/arch/arm64/include/asm/memory.h > +++ b/arch/arm64/include/asm/memory.h > @@ -65,7 +65,7 @@ > */ > #define VA_BITS (CONFIG_ARM64_VA_BITS) > #define VA_START (UL(0xffffffffffffffff) << VA_BITS) IIUC VA_START should also produce warnings and should be also reworked. > -#define PAGE_OFFSET (UL(0xffffffffffffffff) << (VA_BITS - 1)) > +#define PAGE_OFFSET GENMASK_ULL(BITS_PER_LONG_LONG - 1, VA_BITS - 1) The original type of PAGE_OFFSET is UL, and after your patch becomes ULL. This is the same for arm64. But it would be less questionable if you will specify it explicitly, or use GENMASK() instead of GENMASK_ULL(). > #define KIMAGE_VADDR (MODULES_END) > #define MODULES_END (MODULES_VADDR + MODULES_VSIZE) > #define MODULES_VADDR (VA_START + KASAN_SHADOW_SIZE) > -- > 2.14.0.rc1.383.gd1ce394fe2-goog > > > _______________________________________________ > linux-arm-kernel mailing list > linux-arm-kernel@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel