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 5C91AC04FFE for ; Fri, 17 May 2024 15:31:34 +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=4HbNd+imcUWV/F7iLIzvjpMs2xBcmqf+3BU4UlZ6cvg=; b=iSZr3iHdT9RB3M 39td/sQtRV9zRDDEnDDzXsrIYu0gjJhcGNMT6ZK72Oh3hQqKe+i8VL981S9FcOQ5aTTV0q7uvBDcH tJ0c8SwDXnsiIH1TWgR0JDFy3Od1kMwDxxn6X5oBwhx5GiSZiZYOALzof10Efm06KHsEUQ01vJhei U4t2yQSlsg9bGTGLOlUBmYsqpFC6QbfqfoQkI0UoD9y5QOJZ/f/UqayjUkrkoOzQzWJA8l+oS0w74 39FQEr6Co51otsQLGp7/w9dDChUcz8lOrxg4Q5Txbpu0zqLTphiaRya1eYKJXZ1O98XJVrrIKYiV3 aLe5B9Vg1jGfnpKtHmRA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s7zYH-00000008Ghd-02tr; Fri, 17 May 2024 15:31:21 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s7zYD-00000008Ggn-28f7 for linux-arm-kernel@lists.infradead.org; Fri, 17 May 2024 15:31:19 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 03B5461D68; Fri, 17 May 2024 15:31:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AF306C2BD10; Fri, 17 May 2024 15:31:14 +0000 (UTC) Date: Fri, 17 May 2024 16:31:12 +0100 From: Catalin Marinas To: Dev Jain Cc: 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: <20240517132421.285667-1-dev.jain@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240517_083117_646758_E7E61C4D X-CRM114-Status: GOOD ( 10.55 ) 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 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. > > start &= PAGE_MASK; > pa &= PAGE_MASK; > > /* Advance tbl to the entry that covers start */ > - tbl += (start >> (lshift + PAGE_SHIFT)) % PTRS_PER_PTE; > + tbl += (start >> lshift) % PTRS_PER_PTE; I did the maths as well my own way and the change is correct: lshift + PAGE_SHIT == ARM64_HW_PGTABLE_LEVEL_SHIFT(level) It probably is easier to read this way, so: Reviewed-by: Catalin Marinas _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel