From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A2499C25B7C for ; Thu, 23 May 2024 17:00:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=OweqfDFH+gMbhGQDn4iU19JeGlczxPrZ1e+sBH8D96Q=; b=PdiCVnGxLAqtuj KHMKTjjWRER/ZM2vgI7JIOZNYANSpv5X9L5ldUkKZ7LQ9PP512RX7DoGbLzQqWIQO7iGgok+MgSyj Dhw7bt4SCeIWNKWDSr1MCjB4jNhVW1zwdoyrNDxbDIEAfPq+b7iKP81/GwxaO+yzOXqDNcer2+cKh 2fXfNTOv8wsOm0t9VEWURhqGXUk86xK/EsZvQugIOSG6rMSNmZRnZfBMIc2jlfuTWVgGBCj2E7QPH TAm2tYIwIV1T7HNpqov9UyMI9RSGD7hz2WhNrR0syMxV9uAcE1c2DlX3gOycxVU816pnRuTTdx7Pv 3WqlvKDZhHNvXjIfyVMg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sABnH-00000006qDI-1SaX; Thu, 23 May 2024 16:59:55 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sABnB-00000006qCY-3iaW for linux-arm-kernel@lists.infradead.org; Thu, 23 May 2024 16:59:53 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 0338662E5D; Thu, 23 May 2024 16:59:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A38CAC2BD10; Thu, 23 May 2024 16:59:46 +0000 (UTC) Date: Thu, 23 May 2024 17:59:44 +0100 From: Catalin Marinas To: Dave Martin Cc: Dev Jain , linux-arm-kernel@lists.infradead.org, will@kernel.org, ardb@kernel.org, ryan.roberts@arm.com, mark.rutland@arm.com, suzuki.poulose@arm.com, broonie@kernel.org, James.Morse@arm.com, Anshuman.Khandual@arm.com Subject: Re: [PATCH] arm64: kernel: Replace manual computation with macro Message-ID: References: <20240517132421.285667-1-dev.jain@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240523_095951_366069_4B0228BE X-CRM114-Status: GOOD ( 12.30 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, May 23, 2024 at 02:02:37PM +0100, Dave P Martin wrote: > On Fri, May 17, 2024 at 04:31:12PM +0100, Catalin Marinas wrote: > > On Fri, May 17, 2024 at 06:54:21PM +0530, Dev Jain wrote: > > > diff --git a/arch/arm64/kernel/pi/map_range.c b/arch/arm64/kernel/pi/map_range.c > > > index 5410b2cac590..4b145be7f846 100644 > > > --- a/arch/arm64/kernel/pi/map_range.c > > > +++ b/arch/arm64/kernel/pi/map_range.c > > > @@ -31,14 +31,14 @@ void __init map_range(u64 *pte, u64 start, u64 end, u64 pa, pgprot_t prot, > > > { > > > u64 cmask = (level == 3) ? CONT_PTE_SIZE - 1 : U64_MAX; > > > u64 protval = pgprot_val(prot) & ~PTE_TYPE_MASK; > > > - int lshift = (3 - level) * (PAGE_SHIFT - 3); > > > - u64 lmask = (PAGE_SIZE << lshift) - 1; > > > + int lshift = ARM64_HW_PGTABLE_LEVEL_SHIFT(level); > > > + u64 lmask = ((u64)1 << lshift) - 1; > > > > Nitpick: you can use 1UL instead of (u64)1. > > Or, rather than reinventing this again, how about: > > #include > > u64 lmask = GENMASK_ULL(lshift - 1, 0); Even better. Thanks Dave. -- Catalin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel