Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp617181lqm; Wed, 1 May 2024 10:18:37 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV43Qqdyq3uZxeFenvJSdJ33lSq+1vww40SbJ7c1R9MHMo0eEBaoZjU2ATquUs/aKW/qa0rQQuGC715UPKos43jeIEoBjSSzWGCjwX6oQ== X-Google-Smtp-Source: AGHT+IG9n/SD0ui//1hw24Y12VyDtigRJVDLek2Q0qbsgCICCaVeYrl7wte9Hb1s2eSJaCoMZnIR X-Received: by 2002:a05:6870:9409:b0:23d:4206:8d71 with SMTP id d9-20020a056870940900b0023d42068d71mr3407466oal.40.1714583916646; Wed, 01 May 2024 10:18:36 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714583916; cv=pass; d=google.com; s=arc-20160816; b=Pwb2LKo/zU0ezBDFqs/Im1GNJS75RWkmREeoBHfDTZEmGp3z8DNwxgqgDq4AzcrfF4 9l1lj1xHHPd6avksYThLxwy+Ei9HbUrAyQZP5uLt5HT7sQJg6XqoRDQT2ZUpn9mD0EKL lPn1OSq2XZayCwV7QYQ7L8lQ0Hye/9hjiIuvGhdIT+e77ULrqg5dB/K+Sr1N5RFkc8/g P5VnamU+daBvRKRgYo2LAVYH01L0kckHJWtbZxw7dJ+yy4xDZyrN6Z8FzGe8ukknxQWv OEcC/4P5eAtg9ISJP3nbO9W5tcezwYIug9ytLV4koTMfSv3KzOyei/P7kWMUK3COEUUG suuw== 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=uIgYMEKuj7hxe92rvJmgWaiFo3MDqmc6kRLX2X0/8qs=; fh=Sft5RbBmRN2jByB9itvde5mN+D5477idYI+FoJL4n5M=; b=s1Mp8oJpmjvM2URFVqLr/BHkg/bamcBt+K62Fg153GpRglVyoco+dQKl3FFtidaq0l pFTFNy/B1x2E0TtqxDtsTEAmsPxffioHEyvx+WORAr5Utcp5GUhew12OCb2S+i3iuUS2 jteG3qAUnh4cuhsaV25ZQrHl31Oi1gvD+xZ0BF1NfN1BYdk5sPi6KZbwYrkdgzmNItut iY2nPB8qI/1XvNO9UDGzHqDeRCBkE7F/KVEgu+DbRGyhcre7ar/vhZXY/22rLktqPKWI TXu5rIsLwuqEyb4fshDDzYBcNzwNOV7m3gElAdIfmLP6bqX9LtXYFb24I+zrHh7gb9x/ X4kg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=fail header.i=@fu-berlin.de header.s=fub01 header.b=cHhxykkL; 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-165636-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-165636-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 sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 32-20020a631960000000b005f751900b65si24098894pgz.486.2024.05.01.10.18.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 May 2024 10:18:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-165636-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; dkim=fail header.i=@fu-berlin.de header.s=fub01 header.b=cHhxykkL; 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-165636-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-165636-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id A0EE128246B for ; Wed, 1 May 2024 17:18:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A148018637; Wed, 1 May 2024 17:18:30 +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="cHhxykkL" 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 8AFAFDDAB; Wed, 1 May 2024 17:18:26 +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=1714583909; cv=none; b=DAfGuaE+7Y2JFQjzJQsnBFoF6D8rjmFPl0xeUzeKFaWgIACy3UJSvpmlromf1LWhlcrWTsmUKn2ChnvF1LxsF7Oz1sOpShdJYjzkRJwoqopPESbDL7DxXeZ30MwVusfBgy+IjkTAE9uYrGrLw416p9cQ9li4qAFUe21Fghf/gV0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714583909; c=relaxed/simple; bh=Q+1d4Gnsr2lrEMS3UmDxaI6tEyeZXyIHtm2WulLERJQ=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=LNHN8LfTLTxmIKh25Fl9JQ6sCfHBO5D6Glvf2odIeakeLztBdKgxRsrP+aDrHkEZ9dB2e2qz0gZuuiL3bz3Fig8H39AN2Xp4YdkdTmixpTEm4njUFhQqpfZ+lQBluDFIuRC5/RkS+wkbXErI2tUYIKhVnTxRJnPwfJjUx7u1mFA= 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=cHhxykkL; 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=uIgYMEKuj7hxe92rvJmgWaiFo3MDqmc6kRLX2X0/8qs=; t=1714583906; x=1715188706; b=cHhxykkL5qL+l4V6dKsWLWZ6wXCo5kbcczhVAM6MffKYgvoqSWdc4WsrgOJeF4kOHq2bsDaaGjx GcKh5OfgylF5xqVKmNE4adXmRdfdWk2sRpD9h3zPvgC0ZXL9I3De4T25tivZBLl1zh2vIUE3+mb6J zEjtgKx2BTKT8QcBLTRyjDbhKqRRQz8Qs3s3sO1GWo7NFkbJn9J122XcbvwHQMlDQ29Hc9ATzUKad 3iRCSdJQtxYNhn/o6SW0hoiwTyE2EWzj8OrySZEbQt5pmLd/rIB1lgTNBJUdG7oKbPCi8YdpmO53h 4JgcdR+KLhiAQZ1VFYxs6ice2qs+GZXKSqug==; 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 1s2Db4-00000001w6i-3M2S; Wed, 01 May 2024 19:18:22 +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 1s2Db4-00000001i3u-2CVD; Wed, 01 May 2024 19:18:22 +0200 Message-ID: <72ec7831604326e852eb228072b1d817bab829fb.camel@physik.fu-berlin.de> 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: Wed, 01 May 2024 19:18:21 +0200 In-Reply-To: <20240423233150.74302-1-quic_obabatun@quicinc.com> References: <20240423233150.74302-1-quic_obabatun@quicinc.com> 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 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. I was just about to merge your patch when I ran a git blame on the code in arch/sh/kernel/setup.c and noticed the following commit by Rich Felker: commit eb6b6930a70faefe04479a71088cc10366782d9a Author: Rich Felker Date: Mon Jul 31 01:27:50 2017 -0400 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 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(). @Geert: Do you have any comments on this patch? @Rob: Could you test this patch on your J2 board and report back? Thanks, Adrian --=20 .''`. John Paul Adrian Glaubitz : :' : Debian Developer `. `' Physicist `- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913