Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp1037494lqm; Thu, 2 May 2024 03:30:03 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW0LwWV4413u4G/qz4YRV+Mo3KTZehegi/uA2E0cvMB8WPcIWo/Ea91a1WuurjZZpAwt6dXr4417DrBOxbqZTL29a8y93NqmIw6MHceuQ== X-Google-Smtp-Source: AGHT+IFmHrCyvTAgSPRh8VnxCEGcW1wOkTIWwcJZnU8nF/z9jxe1nKq61D4vophLYkAZMXaqafDp X-Received: by 2002:a05:651c:2106:b0:2d4:5370:5e8a with SMTP id a6-20020a05651c210600b002d453705e8amr4851377ljq.22.1714645802364; Thu, 02 May 2024 03:30:02 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714645802; cv=pass; d=google.com; s=arc-20160816; b=kKds2cTHKErnaSQVyuobfUwXElv0g85xu5hix/VJ1mtc71Coa116yFVC0OKLi8W2+a TyAnmaH0gWvzKCEHf09/eBmHbexL1DZUk0Fd4tP4i+Jwpr2yTjW4t8/zbMg+2ygY/XdA yOrpLPonKLwa3W0Gp8jfrEVlzvSM9vgSjP6U6eKhemU+3zs+0yHtpqysUHL6J+bE+ZWI TsgdxxUe7I1ZZBU8AWOosaEjVHyumlnGPhUH6Gz1YGGK1IF5znXb2xByv2I/kWrZDmyL 8IDv5VlclLb1TfVcZBeaFNASd6IqZR/yGUqqFSzW2i3K91kUYp9OVu77Rag4QTqoFE8V WLFg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:content-transfer-encoding:references:in-reply-to:date:cc :to:from:subject:message-id:dkim-signature; bh=PPcqclq5JazTzzPM+WzlgQe+U+YyPREGD6xfGzxYCAg=; fh=Sft5RbBmRN2jByB9itvde5mN+D5477idYI+FoJL4n5M=; b=bRLmnjoYMC+UqsE48BNJ4JQyFnqz1JpB2lmCYZ15eE9BljTwFHKxJ1M+tNw+uB2uXs S9HPMgAr2Hieu+JMyqpozFMxxd23rp9Z1g/IXO28zsLnz/IDy0eIQnfuqAXCbh7lR1vB CKpfEiotz5vN0S+wEVrHK36QqOnOg/3uS/XCCJLOCiEhzOoMNT64MRIBu6M8yiLd7XZO ZkzK0j8FPrP/2CZAOQrS+TfImZqJK+HRrVTf1apTzKDQC04C3SSt8FZhGzTJA/xspXI4 rQA5i7dGkpXQGm6ly69ncawszXgg+uprzPxwmQgWKZ5m2ef767c1CdsClhdyePVBZ9kV XJAQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=fail header.i=@fu-berlin.de header.s=fub01 header.b=aBfG9AzH; arc=pass (i=1 spf=pass spfdomain=zedat.fu-berlin.de dkim=pass dkdomain=fu-berlin.de dmarc=pass fromdomain=physik.fu-berlin.de); spf=pass (google.com: domain of linux-kernel+bounces-166305-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-166305-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=fu-berlin.de Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id jo26-20020a170906f6da00b00a556b8692e7si382971ejb.259.2024.05.02.03.30.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 May 2024 03:30:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-166305-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=fail header.i=@fu-berlin.de header.s=fub01 header.b=aBfG9AzH; arc=pass (i=1 spf=pass spfdomain=zedat.fu-berlin.de dkim=pass dkdomain=fu-berlin.de dmarc=pass fromdomain=physik.fu-berlin.de); spf=pass (google.com: domain of linux-kernel+bounces-166305-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-166305-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=fu-berlin.de 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 am.mirrors.kernel.org (Postfix) with ESMTPS id C86C81F24032 for ; Thu, 2 May 2024 10:30:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7A1A358ABF; Thu, 2 May 2024 10:29:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=fu-berlin.de header.i=@fu-berlin.de header.b="aBfG9AzH" Received: from outpost1.zedat.fu-berlin.de (outpost1.zedat.fu-berlin.de [130.133.4.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DE21557333; Thu, 2 May 2024 10:29:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=130.133.4.66 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714645793; cv=none; b=dqWHpJHzz3oHzMOA8m96bMFEXpzCw8j1x/m8Ec9f3jQG32dNwSy426bEfVnt5TDkpeXfV0Ht2jnu4LnxyvzDK+SbWh2LpxJTeH5glBAa9uBBtm0ag5qCJBaepqD5Wo9Pg36DkTcmhq2SUyu8pZSE9igLHOYkdjzY8RIL4KG5PZ4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714645793; c=relaxed/simple; bh=O+x6zlED+zDMOemCx1e2RcNkUseJEOjblAholmx+D/0=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=lvp0X5/1xKqVlFq3drSd4d+UCuXQgc7rCmLpBVIRFMbTuZHtjiTXD4Y31w0bvwsGoWSwQ9zNHxPY0VmUcrenyqPozzuZy3OIWEHZ3Ss/kMa4iNYeDd9IsyMG304jAcQn44bdRbZ3Ys9+4alqv7wiXF1jP8W4i4DdzWY+fpFG3uQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=physik.fu-berlin.de; spf=pass smtp.mailfrom=zedat.fu-berlin.de; dkim=pass (2048-bit key) header.d=fu-berlin.de header.i=@fu-berlin.de header.b=aBfG9AzH; arc=none smtp.client-ip=130.133.4.66 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=physik.fu-berlin.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=zedat.fu-berlin.de DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=fu-berlin.de; s=fub01; h=MIME-Version:Content-Transfer-Encoding: Content-Type:References:In-Reply-To:Date:Cc:To:From:Subject:Message-ID:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=PPcqclq5JazTzzPM+WzlgQe+U+YyPREGD6xfGzxYCAg=; t=1714645792; x=1715250592; b=aBfG9AzHudapO//64X1AkPDh+zAuauV8WXkqxFw6QJajcqMlxmXj1NsfJiM4jgMGyv4NKeRCXzQ asRC2vusRcSeo2WGs2X1M87fOwbFZiltCKTF/n6X+7zPutdo1U65y/Gx9+BMcFSlzWRXt3YrEBfMa ey2F5rFA78hjLZl0EB/ETb4KlsESAJHUU/QsFc/Td0oqQ81eFIAaTOv0WArDi7u8VkVXNzrOnQG5s eNYHtGtVIQmVx2ENofhbHPwsQapDgxY81NPdW/8lJJcvZIHLe8sq/3AHkvBSwSNAm1n4eu3Y1DkQ9 Ll31B0FOWzaOOJPAEo1t+hgUp2HiDq1nL+ew==; Received: from inpost2.zedat.fu-berlin.de ([130.133.4.69]) by outpost.zedat.fu-berlin.de (Exim 4.97) with esmtps (TLS1.3) tls TLS_AES_256_GCM_SHA384 (envelope-from ) id 1s2ThE-00000001zK7-1ayC; Thu, 02 May 2024 12:29:48 +0200 Received: from p57bd90e8.dip0.t-ipconnect.de ([87.189.144.232] helo=[192.168.178.20]) by inpost2.zedat.fu-berlin.de (Exim 4.97) with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (envelope-from ) id 1s2ThE-000000007k2-0fxW; Thu, 02 May 2024 12:29:48 +0200 Message-ID: Subject: Re: [PATCH v2] sh: Call paging_init() earlier in the init sequence From: John Paul Adrian Glaubitz To: Oreoluwa Babatunde , ysato@users.sourceforge.jp, dalias@libc.org Cc: akpm@linux-foundation.org, linux-sh@vger.kernel.org, linux-kernel@vger.kernel.org, robh+dt@kernel.org, kernel@quicinc.com, Rob Herring , Rob Landley Date: Thu, 02 May 2024 12:29:47 +0200 In-Reply-To: <72ec7831604326e852eb228072b1d817bab829fb.camel@physik.fu-berlin.de> References: <20240423233150.74302-1-quic_obabatun@quicinc.com> <72ec7831604326e852eb228072b1d817bab829fb.camel@physik.fu-berlin.de> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.52.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Original-Sender: glaubitz@physik.fu-berlin.de X-ZEDAT-Hint: PO Hi Oreoluwa, On Wed, 2024-05-01 at 19:18 +0200, John Paul Adrian Glaubitz wrote: > Hi Oreoluwa, >=20 > On Tue, 2024-04-23 at 16:31 -0700, Oreoluwa Babatunde wrote: > > The unflatten_device_tree() function contains a call to > > memblock_alloc(). This is a problem because this allocation is done > > before any of the reserved memory is set aside in paging_init(). > > This means that there is a possibility for memblock to allocate from > > any of the memory regions that are supposed to be set aside as reserved= . > >=20 > > Hence, move the call to paging_init() to be earlier in the init > > sequence so that the reserved memory regions are set aside before any > > allocations are done using memblock. >=20 > I was just about to merge your patch when I ran a git blame on the code i= n > arch/sh/kernel/setup.c and noticed the following commit by Rich Felker: >=20 > commit eb6b6930a70faefe04479a71088cc10366782d9a > Author: Rich Felker > Date: Mon Jul 31 01:27:50 2017 -0400 >=20 > sh: fix memory corruption of unflattened device tree > =20 > unflatten_device_tree() makes use of memblock allocation, and > therefore must be called before paging_init() migrates the memblock > allocation data to the bootmem framework. Otherwise the record of the > allocation for the expanded device tree will be lost, and will > eventually be clobbered when allocated for another use. > =20 > Signed-off-by: Rich Felker >=20 > It looks like that the call to unflatten_device_tree() before paging_init= () > is intentional and needed for the device tree to be preserved in memory > after running paging_init(). >=20 > @Geert: Do you have any comments on this patch? > @Rob: Could you test this patch on your J2 board and report back? I'm skipping this patch for v6.10 now for the aforementioned reasons. Adrian --=20 .''`. John Paul Adrian Glaubitz : :' : Debian Developer `. `' Physicist `- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913