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 15161C25B75 for ; Thu, 23 May 2024 13:03:13 +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=BGV6t3gnZHJv/08fB3iOF9OcWP8awh4IYLvOeAV854c=; b=WMYm8ohk8CHK4A 6S/KZTW4FiAbFHW4fB6KDaJEd6QTJ4ZeIQOe7a7nrwr0MirQTjwQVY+I5liemtj5sgzj83xShnQEK kRdprLsRcNE+OEA7FNSi66G0fF6wF/hTAApEutMki5v90E93SSlz8mU9+dZK1c0Xem1q5501En2h2 Wn/SVc86bY8CZSJnFqsrriLgdzweYdDhhDAqJOFHRAzbdrwx0cL72JGJ0KBPoYEIfm05bRpiJzftj jR4xgm0/Pi4R6Fro3RY8S3plsH+SnASRYQZq+hgvhedjqM+5IMVSjGVxnWNYXqehO97EVkoCU8Aoz BN42nFCC8eSdWyxdGnsw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sA85y-00000006J4B-137J; Thu, 23 May 2024 13:02:58 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sA85u-00000006J2b-0f8p for linux-arm-kernel@lists.infradead.org; Thu, 23 May 2024 13:02:56 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 34DA1339; Thu, 23 May 2024 06:03:11 -0700 (PDT) Received: from e133380.arm.com (e133380.arm.com [10.1.197.52]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B97613F641; Thu, 23 May 2024 06:02:45 -0700 (PDT) Date: Thu, 23 May 2024 14:02:37 +0100 From: Dave Martin To: Catalin Marinas 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_060254_261806_330C2286 X-CRM114-Status: GOOD ( 11.08 ) 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 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); [...] Cheers ---Dave _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel