Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751930AbdHBWwu (ORCPT ); Wed, 2 Aug 2017 18:52:50 -0400 Received: from mail-pg0-f46.google.com ([74.125.83.46]:33081 "EHLO mail-pg0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751184AbdHBWws (ORCPT ); Wed, 2 Aug 2017 18:52:48 -0400 From: Matthias Kaehlcke To: zijun_hu , Andrew Morton , Catalin Marinas , Will Deacon , Mark Rutland , Laura Abbott Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Doug Anderson , Nick Desaulniers , Greg Hackmann , Matthias Kaehlcke Subject: [PATCH 2/2] arm64: Define PAGE_OFFSET using GENMASK_ULL Date: Wed, 2 Aug 2017 15:51:59 -0700 Message-Id: <20170802225159.159536-2-mka@chromium.org> X-Mailer: git-send-email 2.14.0.rc1.383.gd1ce394fe2-goog In-Reply-To: <20170802225159.159536-1-mka@chromium.org> References: <20170802225159.159536-1-mka@chromium.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1429 Lines: 36 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) -#define PAGE_OFFSET (UL(0xffffffffffffffff) << (VA_BITS - 1)) +#define PAGE_OFFSET GENMASK_ULL(BITS_PER_LONG_LONG - 1, VA_BITS - 1) #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