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 X-Spam-Level: X-Spam-Status: No, score=-4.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ED0DFC433DF for ; Fri, 14 Aug 2020 14:06:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C71FA20838 for ; Fri, 14 Aug 2020 14:06:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597413996; bh=dslG9lAnq1w0dbslkszSchExW5P9tHNSwKHwP4Mxf9Y=; h=References:In-Reply-To:From:Date:Subject:To:Cc:List-ID:From; b=hSEznXGTjZ8GuWeRDr2rGc9Y+JaVJ/c39qsXQj+tAY6UGh/jTNnHI2gRVzclOV591 oCCk3Ob7nnHrO5jdXeen0Bdam5Dmp/uUGzvbVBUg/LgnXbk5FjtAyCZq33USkx96XQ iRMH6CvFqVjvSrbI8FSFvpOtIDKv1VOazKEWJU9I= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728284AbgHNOG2 (ORCPT ); Fri, 14 Aug 2020 10:06:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:53506 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728219AbgHNOGP (ORCPT ); Fri, 14 Aug 2020 10:06:15 -0400 Received: from mail-oo1-f48.google.com (mail-oo1-f48.google.com [209.85.161.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1534222BEF for ; Fri, 14 Aug 2020 14:06:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597413975; bh=dslG9lAnq1w0dbslkszSchExW5P9tHNSwKHwP4Mxf9Y=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=lMXQjq93P4LrSNvfxDLZPswDA0fpYBfx6VPlO8ScGHsjvzhK/RAdQfSS/leaQYWUY xD89EH+AtJrB9WpZ0aQR+oEGA/Qmd2WeW0Kes8r7uRshfTs6mW1zRnWEHG6Hm+r/kA EiXCm9YzHRnvoqRYPTh7nDWpjI5G+/QotzcWrOqc= Received: by mail-oo1-f48.google.com with SMTP id u28so1919547ooe.12 for ; Fri, 14 Aug 2020 07:06:15 -0700 (PDT) X-Gm-Message-State: AOAM531DwS+BU3XBhB+EgHSd62zU/0TMfdi0fOEEJ08vG2jeTkAOpvHJ xL/jWKNbRxKm4rUmylIzlzFUvcEIwdlB0eAtYsw= X-Google-Smtp-Source: ABdhPJyR/Zs3Ngi1209NXw3lIninpFG8tYBsvnPmxBDSKNmpf1q3M9WPhKAdNPjDNPym5Qdgd+/bHh6dJRbuYKbmsac= X-Received: by 2002:a4a:da4c:: with SMTP id f12mr1790142oou.41.1597413974324; Fri, 14 Aug 2020 07:06:14 -0700 (PDT) MIME-Version: 1.0 References: <20200706150205.22053-1-geert+renesas@glider.be> <159546718359.3847286.13460778905630969897@swboyd.mtv.corp.google.com> In-Reply-To: From: Ard Biesheuvel Date: Fri, 14 Aug 2020 16:06:03 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH/RFC v7] ARM: boot: Obtain start of physical memory from DTB To: Linus Walleij Cc: Stephen Boyd , Arnd Bergmann , Bjorn Andersson , Laura Abbott , Kumar Gala , Geert Uytterhoeven , Nicolas Pitre , Masahiro Yamada , Lukasz Stelmach , Russell King , Linux-Renesas , Chris Brandt , =?UTF-8?Q?Uwe_Kleine=2DK=C3=B6nig?= , Eric Miao , Dmitry Osipenko , Linux ARM , Marek Szyprowski Content-Type: text/plain; charset="UTF-8" Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org On Fri, 14 Aug 2020 at 16:03, Linus Walleij wrote: > > On Thu, Jul 23, 2020 at 3:19 AM Stephen Boyd wrote: > > > > > textofs-$(CONFIG_ARCH_IPQ40XX) := 0x00208000 > > > > textofs-$(CONFIG_ARCH_MSM8X60) := 0x00208000 > > > > textofs-$(CONFIG_ARCH_MSM8960) := 0x00208000 > > > > > > But what on earth is this? I just deleted this and the platform > > > boots just as well. > > > > We need to shift the kernel text to start 2MB beyond the start of memory > > because there is the shared memory region used to communicate with other > > processors in the SoC there. It took a while for us to convince other OS > > folks in the company to put shared memory somewhere else besides the > > start of RAM, but eventually we won that battle. > > > > Does your booted kernel have its text section at the start of RAM or is > > it offset by 2MB without this change? Check out /proc/iomem to see where > > the kernel text is in relation to the start of RAM. > > The memory on this machine starts at 0x40200000 since the effect > of the current code is to take pc &= 0xf8000000 and that results in > 0x40000000 and then this adds textofs 0x00208000 to that > resulting in 0x40208000 for the kernel physical RAM. Which > is what we want to achieve since the RAM starts at > 0x40200000. > > But TEXT_OFFSET is also used inside the kernel to offset the > virtual memory. This means that when we set up the virtual > memory split, the kernel virtual memory is also bumped by > these 2 MB so the virtual memory starts at 0xC0208000 > instead of 0xC0008000 as is normal. > > It looks weird to me but maybe someone can explain how > logical that is? > The ARM mm code assumes that the relative alignment between PA and VA is 16 MB, so if we skip 2 MB in the physical space, we must do the same in the virtual space. 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 X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 24187C433DF for ; Fri, 14 Aug 2020 14:07:58 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C719B20838 for ; Fri, 14 Aug 2020 14:07:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="vdN4ty4u"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="lMXQjq93" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C719B20838 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=w18tJGguQxeeEJ1hyqele18wG35Xwdj2C6bosh8gXek=; b=vdN4ty4uyVJRdDk+yYPKHn4RL hNwsKgWS/d12lzqdxstvQ/HHgwKURC5YtSPiGFzKcS+oAZBWXbXQpSlohZmo7hfa8IBkQ+OxT171b Ew8C4GqQ8QCdeYxhQR7RbtKvlZfrxZYjWzvRnJODLf3wRgd0dDWjy7LTTzD589zy2CvqwqfcNPb9+ QiIkwQ8MDFOBgRDL521/HPSvEt+B5v6r0pA11BlToOvHXmfyr+LSo3XBQfHlDjpobgPKFiXSLq1M8 IBvGCIiJFTgVDaAcFiKxfye+g9UpSEGx7/xqaSUCip/wijU2Nd9dERRTHmZeRMHxB9l1Exw+eoRYN KbYlXlVUw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k6aLb-0005xl-1h; Fri, 14 Aug 2020 14:06:19 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k6aLY-0005xA-BH for linux-arm-kernel@lists.infradead.org; Fri, 14 Aug 2020 14:06:17 +0000 Received: from mail-oo1-f47.google.com (mail-oo1-f47.google.com [209.85.161.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 10F4622BEB for ; Fri, 14 Aug 2020 14:06:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597413975; bh=dslG9lAnq1w0dbslkszSchExW5P9tHNSwKHwP4Mxf9Y=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=lMXQjq93P4LrSNvfxDLZPswDA0fpYBfx6VPlO8ScGHsjvzhK/RAdQfSS/leaQYWUY xD89EH+AtJrB9WpZ0aQR+oEGA/Qmd2WeW0Kes8r7uRshfTs6mW1zRnWEHG6Hm+r/kA EiXCm9YzHRnvoqRYPTh7nDWpjI5G+/QotzcWrOqc= Received: by mail-oo1-f47.google.com with SMTP id u28so1919546ooe.12 for ; Fri, 14 Aug 2020 07:06:15 -0700 (PDT) X-Gm-Message-State: AOAM532Cfr6NaVzbH8mpXesKn+LKAtKytAnUm5lHZTn5DgN95VqqJeZe w79RUPbhtAjJyAAjbXAkaCF6RPrmO3tlAvEw0p8= X-Google-Smtp-Source: ABdhPJyR/Zs3Ngi1209NXw3lIninpFG8tYBsvnPmxBDSKNmpf1q3M9WPhKAdNPjDNPym5Qdgd+/bHh6dJRbuYKbmsac= X-Received: by 2002:a4a:da4c:: with SMTP id f12mr1790142oou.41.1597413974324; Fri, 14 Aug 2020 07:06:14 -0700 (PDT) MIME-Version: 1.0 References: <20200706150205.22053-1-geert+renesas@glider.be> <159546718359.3847286.13460778905630969897@swboyd.mtv.corp.google.com> In-Reply-To: From: Ard Biesheuvel Date: Fri, 14 Aug 2020 16:06:03 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH/RFC v7] ARM: boot: Obtain start of physical memory from DTB To: Linus Walleij X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200814_100616_525809_2A8591CE X-CRM114-Status: GOOD ( 28.41 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kumar Gala , Arnd Bergmann , Geert Uytterhoeven , Nicolas Pitre , Stephen Boyd , Masahiro Yamada , Lukasz Stelmach , Russell King , Bjorn Andersson , Linux-Renesas , Chris Brandt , =?UTF-8?Q?Uwe_Kleine=2DK=C3=B6nig?= , Eric Miao , Dmitry Osipenko , Laura Abbott , Linux ARM , Marek Szyprowski 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, 14 Aug 2020 at 16:03, Linus Walleij wrote: > > On Thu, Jul 23, 2020 at 3:19 AM Stephen Boyd wrote: > > > > > textofs-$(CONFIG_ARCH_IPQ40XX) := 0x00208000 > > > > textofs-$(CONFIG_ARCH_MSM8X60) := 0x00208000 > > > > textofs-$(CONFIG_ARCH_MSM8960) := 0x00208000 > > > > > > But what on earth is this? I just deleted this and the platform > > > boots just as well. > > > > We need to shift the kernel text to start 2MB beyond the start of memory > > because there is the shared memory region used to communicate with other > > processors in the SoC there. It took a while for us to convince other OS > > folks in the company to put shared memory somewhere else besides the > > start of RAM, but eventually we won that battle. > > > > Does your booted kernel have its text section at the start of RAM or is > > it offset by 2MB without this change? Check out /proc/iomem to see where > > the kernel text is in relation to the start of RAM. > > The memory on this machine starts at 0x40200000 since the effect > of the current code is to take pc &= 0xf8000000 and that results in > 0x40000000 and then this adds textofs 0x00208000 to that > resulting in 0x40208000 for the kernel physical RAM. Which > is what we want to achieve since the RAM starts at > 0x40200000. > > But TEXT_OFFSET is also used inside the kernel to offset the > virtual memory. This means that when we set up the virtual > memory split, the kernel virtual memory is also bumped by > these 2 MB so the virtual memory starts at 0xC0208000 > instead of 0xC0008000 as is normal. > > It looks weird to me but maybe someone can explain how > logical that is? > The ARM mm code assumes that the relative alignment between PA and VA is 16 MB, so if we skip 2 MB in the physical space, we must do the same in the virtual space. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel