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 75A4BC433F5 for ; Fri, 21 Jan 2022 17:09:05 +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=M9sghIKOn9MYz2SDBD/hOhpCZs1oCQ4mhJEYniuw4Zs=; b=iKRSLHlV5lYDNO fSa/A9L7L3g1JvfUJDincCiUQV79qo/womcnuZ5b5TFQfJjR4QUCzGqNh4sVx7hRWLgaq0FC4MR5O N0Gq1aVWSB5gP7Xh7VuBiBRYiQbkPxo2Ot+oulKa3F6Js5bHH1NGnaxL12MWlMiD13L2BUaPYHh9l jJttUdMwVOz6qZKflQscQqqtcYJdqgwmY+rlTjPIn5d1TTspvetKQGRX3KiNuBWr87AFK/TA+oUpo Ye5ZHZglDzAYGpA2Y+d1CGHiGooJdmYJSAkEnynRTnuTUYx71FT4DKDJxWUqb+gUbJI6LJuYnsa0L qk+lw1/m6+cVwNJb6S4w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nAxO5-00Felw-Uf; Fri, 21 Jan 2022 17:07:46 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nAxO1-00FelQ-Ei for linux-arm-kernel@lists.infradead.org; Fri, 21 Jan 2022 17:07:42 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0303061A88; Fri, 21 Jan 2022 17:07:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 03999C340E1; Fri, 21 Jan 2022 17:07:38 +0000 (UTC) Date: Fri, 21 Jan 2022 17:07:35 +0000 From: Catalin Marinas To: cgel.zte@gmail.com Cc: pasha.tatashin@soleen.com, si.hao@zte.com.cn, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, will@kernel.org, james.morse@arm.com Subject: Re: [PATCH linux-next] arm64: kexec: Support the case of VA_BITS=39 in trans_pgd_idmap_page() Message-ID: References: <20220121065216.1001021-1-si.hao@zte.com.cn> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220121065216.1001021-1-si.hao@zte.com.cn> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220121_090741_560380_82857B14 X-CRM114-Status: GOOD ( 18.02 ) 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, Jan 21, 2022 at 06:52:16AM +0000, cgel.zte@gmail.com wrote: > From: sihao > > When the values of CONFIG_ARM64_VA_BITS and CONFIG_ARM64_PA_BITS are not > equal, the following panic occurs when kexec is executed. > > This happens because trans_pgd_idmap_page() does not support VA_BITS=39. > So the patch supports the case of VA_BITS=39. [...] > diff --git a/arch/arm64/mm/trans_pgd.c b/arch/arm64/mm/trans_pgd.c > index d7da8ca40d2e..3d88185adcf5 100644 > --- a/arch/arm64/mm/trans_pgd.c > +++ b/arch/arm64/mm/trans_pgd.c > @@ -232,7 +232,7 @@ int trans_pgd_idmap_page(struct trans_pgd_info *info, phys_addr_t *trans_ttbr0, > { > phys_addr_t dst_addr = virt_to_phys(page); > unsigned long pfn = __phys_to_pfn(dst_addr); > - int max_msb = (dst_addr & GENMASK(52, 48)) ? 51 : 47; This should have been GENMASK(51, 48), though it doesn't make any difference and may work better with the change below: > + int max_msb = (dst_addr & GENMASK(52, VA_BITS)) ? 51 : (VA_BITS - 1); So when VA_BITS == 52, the mask is 0 and we set max_msb to 51. I wonder, could we use fls64() instead here? -- Catalin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 19FB5C433EF for ; Fri, 21 Jan 2022 17:07:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350681AbiAURHw (ORCPT ); Fri, 21 Jan 2022 12:07:52 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:56860 "EHLO ams.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349733AbiAURHn (ORCPT ); Fri, 21 Jan 2022 12:07:43 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id B528FB82066 for ; Fri, 21 Jan 2022 17:07:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 03999C340E1; Fri, 21 Jan 2022 17:07:38 +0000 (UTC) Date: Fri, 21 Jan 2022 17:07:35 +0000 From: Catalin Marinas To: cgel.zte@gmail.com Cc: pasha.tatashin@soleen.com, si.hao@zte.com.cn, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, will@kernel.org, james.morse@arm.com Subject: Re: [PATCH linux-next] arm64: kexec: Support the case of VA_BITS=39 in trans_pgd_idmap_page() Message-ID: References: <20220121065216.1001021-1-si.hao@zte.com.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220121065216.1001021-1-si.hao@zte.com.cn> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 21, 2022 at 06:52:16AM +0000, cgel.zte@gmail.com wrote: > From: sihao > > When the values of CONFIG_ARM64_VA_BITS and CONFIG_ARM64_PA_BITS are not > equal, the following panic occurs when kexec is executed. > > This happens because trans_pgd_idmap_page() does not support VA_BITS=39. > So the patch supports the case of VA_BITS=39. [...] > diff --git a/arch/arm64/mm/trans_pgd.c b/arch/arm64/mm/trans_pgd.c > index d7da8ca40d2e..3d88185adcf5 100644 > --- a/arch/arm64/mm/trans_pgd.c > +++ b/arch/arm64/mm/trans_pgd.c > @@ -232,7 +232,7 @@ int trans_pgd_idmap_page(struct trans_pgd_info *info, phys_addr_t *trans_ttbr0, > { > phys_addr_t dst_addr = virt_to_phys(page); > unsigned long pfn = __phys_to_pfn(dst_addr); > - int max_msb = (dst_addr & GENMASK(52, 48)) ? 51 : 47; This should have been GENMASK(51, 48), though it doesn't make any difference and may work better with the change below: > + int max_msb = (dst_addr & GENMASK(52, VA_BITS)) ? 51 : (VA_BITS - 1); So when VA_BITS == 52, the mask is 0 and we set max_msb to 51. I wonder, could we use fls64() instead here? -- Catalin