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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A6386C433EF for ; Thu, 4 Nov 2021 15:55:49 +0000 (UTC) Received: from shelob.surriel.com (shelob.surriel.com [96.67.55.147]) (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 2C87C60FE3 for ; Thu, 4 Nov 2021 15:55:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 2C87C60FE3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kernelnewbies.org Received: from localhost ([::1] helo=shelob.surriel.com) by shelob.surriel.com with esmtp (Exim 4.94.2) (envelope-from ) id 1miej8-0003Ca-MW for kernelnewbies@archiver.kernel.org; Thu, 04 Nov 2021 11:32:30 -0400 Received: from mail-qk1-x72c.google.com ([2607:f8b0:4864:20::72c]) by shelob.surriel.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1miefn-0001lp-Kt for kernelnewbies@kernelnewbies.org; Thu, 04 Nov 2021 11:29:03 -0400 Received: by mail-qk1-x72c.google.com with SMTP id bj27so4357008qkb.11 for ; Thu, 04 Nov 2021 08:29:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=lbOBWm+fBfBOcHEpQxN5JqnRTMrToE3GSSS5d6wxeMo=; b=fFsuz+4oMnRhvbvz/4w452u49pGAiCl5yFoZLiFFBqpbbr9pKS8lzzyxP5xRZGSVSf YEimyv9KKPha3PsckEGd50ENG3uGtQt9c8ENZJ6hsFtKA3Z4SfosObt+LABEvZLz3hdP WQoyS9sYPNU1WYzwD0UzAnuIf/XbjwlaOmIeHI7/LJ9FywSk0RhmC6ZhDFzoolz6gI5J tsNKfReZ+V7d9Rb/9XbneCasebyaetSCtNl33p4bXssOuCBMeLyCajH+2NXU5xYG4k1q W63WudGgu6lgaDPkEfky/fKIeHnO9MCxwD9iCj4cI3Z2oG5MK7DaW6FeYCt9UVncNCUw 9/VA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=lbOBWm+fBfBOcHEpQxN5JqnRTMrToE3GSSS5d6wxeMo=; b=bKaV2xstrKit9R5fG9+SH8p2AsAh68nHgg+C7ZKQgHLZg+aLFTdCsJIRS8UVF4XexY mvNgF80hD8yxkzVKcK2Kvk4cD7shfMsobXg0jA+Va8vzXG7mYpfWfOrABUFxRoNYwrUz x/URwcCmQJjxn0/ufYvn3YLgGrCk7B6yyfzAQ5S0n7zccDkLLoAvXtUUamv5IEFslrjl jOjGsdyqR3cf7fpb5tu/XW8o+qr6HuVzZ0eRHzrfYJIKOoSWPWM1t++YamEGDQtOy4W8 GmxS8Spt+b3kPalYtI0nLfjDWTy5vfWmMoN2fWr8/IhQbScq8pCozXfFCT5yFtE661gq 72bg== X-Gm-Message-State: AOAM531KuU8xzwDpYboOCs5zEAfNABvTallNTrUT/tw05dJRdmB9rXjK xkARWIEfBaXso6GoV/YO4nn7lUjuxh67N6BZiaJaeAWL/dHIcA== X-Google-Smtp-Source: ABdhPJxC6zSS+ivaQ8rd+2N89ZxxGuC3J39e0H40HHERWj2fCjds7+2UGcd404CuSalY7ywU2eKPa+lt7wBgP0j6osw= X-Received: by 2002:ae9:edc5:: with SMTP id c188mr9407524qkg.391.1636039742635; Thu, 04 Nov 2021 08:29:02 -0700 (PDT) MIME-Version: 1.0 References: <282088.1635890374@turing-police> In-Reply-To: <282088.1635890374@turing-police> From: Mushahid Hussain Date: Thu, 4 Nov 2021 20:28:51 +0500 Message-ID: Subject: Re: Loading a simple "kernel" at the address other than default on Raspberry Pi 4 To: =?UTF-8?Q?Valdis_Kl=C4=93tnieks?= Cc: kernelnewbies@kernelnewbies.org X-BeenThere: kernelnewbies@kernelnewbies.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Learn about the Linux kernel List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: multipart/mixed; boundary="===============3854561000331926737==" Errors-To: kernelnewbies-bounces+kernelnewbies=archiver.kernel.org@kernelnewbies.org --===============3854561000331926737== Content-Type: multipart/alternative; boundary="000000000000b2dde205cff82fb1" --000000000000b2dde205cff82fb1 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable >There's another number, set during the kernel build, that tells the kernel what address it should expect to be loaded at. Thank you for the reply. I have added a linker script specifying the same load address as one one config.txt. The simple kernel(hello world) is only able to run, when both addresses(in linker script and config.txt) are 0x80000. I don't know how that number can be set during the build other than in the linker script. I would love to know about it. Can you point me towards the resources to learn about it? >You need to find some way to ensure that the boot loader and the initial part of the kernel (the one that proceeds to unpack the rest of the kernel, set up KASLR, and relocation if neded) agree on what address things start off at. How can I set the load address for the initial part of the kernel other than in the linker script? On Wed, 3 Nov 2021 at 02:59, Valdis Kl=C4=93tnieks wrote: > On Tue, 02 Nov 2021 17:13:16 +0500, Mushahid Hussain said: > > > I have written a simple kernel which prints Hello World to UART. The > simple > > kernel works successfully and prints Hello World to UART, if I load it = at > > 0x80000, which is the default load address for the 64-bit kernel. > > > > There's a configuration(config.txt)[1] kernel_address on Raspberry Pi 4 > but > > whenever I change the load address by even 1 byte, the simple kernel > would > > not run. It is only able to run at 0x80000. > > The config.txt value is for the boot loader, to tell it where the kernel > should > be loaded. There's another number, set during the kernel build, that > tells the > kernel what address it should expect to be loaded at. > > So if your micro-kernel is build to load at 0x80000 and then you tell the > boot > loader to load at 0x80001, or vice versa, things will go badly. > > You need to find some way to ensure that the boot loader and the initial > part > of the kernel (the one that proceeds to unpack the rest of the kernel, se= t > up > KASLR, and relocation if neded) agree on what address things start off at= . > --=20 Mushahid Hussain --000000000000b2dde205cff82fb1 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
>There's another number, set during the kernel buil= d, that tells the
kernel what address it should expect to be loaded at.

<= div>Thank you for the reply. I have added a linker script specifying the sa= me load address as one one config.txt. The simple kernel(hello world) is on= ly able to run, when both addresses(in linker script and config.txt) are 0x= 80000. I don't know how that number can be set during the build other t= han in the linker script. I would love to know about it. Can you point me t= owards the resources to learn about it?

>You ne= ed to find some way to ensure that the boot loader and the initial part
of the kernel (the one that proceeds to unpack the rest of the kernel, set = up
KASLR, and relocation if neded) agree on what address things start off at.<= div class=3D"gmail-adL">
How can I set the load address for the initi= al part of the kernel other than in the linker script?

On We= d, 3 Nov 2021 at 02:59, Valdis Kl=C4=93tnieks <valdis.kletnieks@vt.edu> wrote:<= br>
On Tue, 02 Nov 2= 021 17:13:16 +0500, Mushahid Hussain said:

> I have written a simple kernel which prints Hello World to UART. The s= imple
> kernel works successfully and prints Hello World to UART, if I load it= at
> 0x80000, which is the default load address for the 64-bit kernel.
>
> There's a configuration(config.txt)[1] kernel_address on Raspberry= Pi 4 but
> whenever I change the load address by even 1 byte, the simple kernel w= ould
> not run. It is only able to run at 0x80000.

The config.txt value is for the boot loader, to tell it where the kernel sh= ould
be loaded.=C2=A0 There's another number, set during the kernel build, t= hat tells the
kernel what address it should expect to be loaded at.

So if your micro-kernel is build to load at 0x80000 and then you tell the b= oot
loader to load at 0x80001, or vice versa, things will go badly.

You need to find some way to ensure that the boot loader and the initial pa= rt
of the kernel (the one that proceeds to unpack the rest of the kernel, set = up
KASLR, and relocation if neded) agree on what address things start off at.<= br>


--
Mushahid Hussain
--000000000000b2dde205cff82fb1-- --===============3854561000331926737== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies --===============3854561000331926737==--