Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp1053915rdb; Mon, 19 Feb 2024 02:48:44 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXUlTSEItqkkbQaK3CVm+UDSMMh4Pcw6P07VXy3bfIQpKChluuenjGxOtgNZv5pqrKyVF8PvRncOm8DNuFNTWXE5s7kxPlaOoq4YL5VBg== X-Google-Smtp-Source: AGHT+IEBESdm2odR3v8S1CLcd19hkw415RtqV+KClFzUFOqtjHFH0IGI5cXgaZmtM2tchKMoZwA2 X-Received: by 2002:a17:902:bb81:b0:1db:9e2a:7e50 with SMTP id m1-20020a170902bb8100b001db9e2a7e50mr8311700pls.63.1708339724579; Mon, 19 Feb 2024 02:48:44 -0800 (PST) Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d8-20020a170902cec800b001db2aefa918si4240781plg.159.2024.02.19.02.48.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 02:48:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-71147-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=fail (body hash mismatch); spf=pass (google.com: domain of linux-kernel+bounces-71147-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71147-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 1B70828243F for ; Mon, 19 Feb 2024 10:48:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C522B28DCB; Mon, 19 Feb 2024 10:48:37 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 182E528DC6 for ; Mon, 19 Feb 2024 10:48:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708339717; cv=none; b=XeD+NWncq0MdGQQk+h59FReI5+y/cCAy53HThuuxnLXQUMO2S9pkHTvTT4qGJdyzG49XBMWVqBPq7OoBGfkAFjS6PhzLsIAZgnEAyoUnnwaWBieh2TXG5KtFIKvkm5s4CBafYnKCVXpEbL57rjcK7vftuskt9ybBlIO+rEulw/c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708339717; c=relaxed/simple; bh=C1GsjsFw5uaZhBTJ8BwnJ+MEAALKzYl16o3lM+wB1o0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=hfCT5Wid6ZSy+WWXDY/QXNM+MUbOmuKBn+nRKsbbCuvTwTOZwI2gZtUOSsezW3TpTWkAVeGIgHLBpcrlpe+fSeCMCvkF8iisbEsTjqW2ycvc0JtjEwyQ/nrXO9L33KRkdi74sB/DipCEHHeJPoPwufr+ac47kdliZBUHJYq9KRk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 475EFFEC; Mon, 19 Feb 2024 02:49:14 -0800 (PST) Received: from FVFF77S0Q05N (unknown [10.57.66.18]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6DBDA3F762; Mon, 19 Feb 2024 02:48:33 -0800 (PST) Date: Mon, 19 Feb 2024 10:48:26 +0000 From: Mark Rutland To: skseofh@gmail.com Cc: catalin.marinas@arm.com, will@kernel.org, ryan.roberts@arm.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] arm64: add early fixmap initialization flag Message-ID: References: <20240217140326.2367186-1-skseofh@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240217140326.2367186-1-skseofh@gmail.com> On Sat, Feb 17, 2024 at 11:03:26PM +0900, skseofh@gmail.com wrote: > From: Daero Lee > > early_fixmap_init may be called multiple times. Since there is no > change in the page table after early fixmap initialization, an > initialization flag was added. Why is that better? We call early_fixmap_init() in two places: * early_fdt_map() * setup_arch() .. and to get to setup_arch() we *must* have gone through early_fdt_map(), since __primary_switched() calls that before going to setup_arch(). So AFAICT we can remove the second call to early_fixmap_init() in setup_arch(), and rely on the earlier one in early_fdt_map(). Mark. > > Signed-off-by: Daero Lee > --- > arch/arm64/mm/fixmap.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/arch/arm64/mm/fixmap.c b/arch/arm64/mm/fixmap.c > index c0a3301203bd..fbdd5f30f3a1 100644 > --- a/arch/arm64/mm/fixmap.c > +++ b/arch/arm64/mm/fixmap.c > @@ -32,6 +32,8 @@ static pte_t bm_pte[NR_BM_PTE_TABLES][PTRS_PER_PTE] __page_aligned_bss; > static pmd_t bm_pmd[PTRS_PER_PMD] __page_aligned_bss __maybe_unused; > static pud_t bm_pud[PTRS_PER_PUD] __page_aligned_bss __maybe_unused; > > +static int early_fixmap_initialized __initdata; > + > static inline pte_t *fixmap_pte(unsigned long addr) > { > return &bm_pte[BM_PTE_TABLE_IDX(addr)][pte_index(addr)]; > @@ -100,10 +102,15 @@ void __init early_fixmap_init(void) > unsigned long addr = FIXADDR_TOT_START; > unsigned long end = FIXADDR_TOP; > > + if (early_fixmap_initialized) > + return; > + > pgd_t *pgdp = pgd_offset_k(addr); > p4d_t *p4dp = p4d_offset(pgdp, addr); > > early_fixmap_init_pud(p4dp, addr, end); > + > + early_fixmap_initialized = 1; > } > > /* > -- > 2.25.1 >