Subject: RE: [ARMv8] kernel entry point
From: Pankaj Bansal <[email-masked]>
To: Mark Rutland <[email-masked]>
Cc: Catalin Marinas <[email-masked]>, Will Deacon <[email-masked]>, Ard Biesheuvel <[email-masked]>, Wasim Khan <[email-masked]>, Varun Sethi <[email-masked]>, "[email-masked]" <[email-masked]>
Date: Fri, 10 May 2019 14:36:37 +0000

Hi Mark,

> -----Original Message-----
> From: Mark Rutland <[email-masked]>
> Sent: Friday, 10 May, 2019 07:11 PM
> To: Pankaj Bansal <[email-masked]>
> Cc: Catalin Marinas <[email-masked]>; Will Deacon
> <[email-masked]>; Ard Biesheuvel <[email-masked]>; Wasim
> Khan <[email-masked]>; Varun Sethi <[email-masked]>; linux-arm-
> [email-masked]
> Subject: Re: [ARMv8] kernel entry point
>
> Hi Pankaj,
>
> On Fri, May 10, 2019 at 01:24:55PM +0000, Pankaj Bansal wrote:
> > + Ard,
> > Hi Ard,
> >
> > Can you please check below mail? We are not able to boot linux loading
> > Image at 16MB offset (0x81000000) from DDR start address (0x80000000)
> > I have tested with both u-boot as well as atf.
> >
> > This issue is occurring with latest kernel (5.1) Image.  If I revert
> > kernel code to commit a7f8de168ace ("arm64: allow kernel Image to be
> > loaded anywhere in physical memory "), then this issue doesn't occur.
>
> That commit allows the 2MiB base to be arbitrary, but the text_offset must still
> be taken into account. That's all documented in:
>
> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit.kernel
> .org%2Fpub%2Fscm%2Flinux%2Fkernel%2Fgit%2Ftorvalds%2Flinux.git%2Ftree%
> 2FDocumentation%2Farm64%2Fbooting.txt%3Fh%3Dv5.1%23n125&amp;data=
> 02%7C01%7Cpankaj.bansal%40nxp.com%7C045f77d8202040db896108d6d54d1
> 5f2%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C636930924443311
> 148&amp;sdata=nOHlA67bfSc21hS0kTnHGJ%2BqxSa2KvAGnRPq7%2FEQgmg%3
> D&amp;reserved=0
>
> .. where we say:
>
> | The Image must be placed text_offset bytes from a 2MB aligned base
> | address anywhere in usable system RAM and called there. The region
> | between the 2 MB aligned base address and the start of the image has
> | no special significance to the kernel, and may be used for other purposes.
> | At least image_size bytes from the start of the image must be free for
> | use by the kernel.
>
> ... and where text_offset is defined in the Image header:
>
> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit.kernel
> .org%2Fpub%2Fscm%2Flinux%2Fkernel%2Fgit%2Ftorvalds%2Flinux.git%2Ftree%
> 2FDocumentation%2Farm64%2Fbooting.txt%3Fh%3Dv5.1%23n73&amp;data=0
> 2%7C01%7Cpankaj.bansal%40nxp.com%7C045f77d8202040db896108d6d54d15
> f2%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C6369309244433111
> 48&amp;sdata=Zw2JQ176V6cFXz%2BFcS1uJuYkCZUISjHI%2Bb3HNnkf30k%3D&a
> mp;reserved=0
>
> On a contemporary defconfig kernel, text_offset is 0x80000, so
> 0x81000000 is not a valid address to load the kernel at.
>
> I suspect that things will work if you load your kernel at 0x81080000.

Thank you for this tip. It worked.

>
> I would strongly recommend you use a bootloader that parses the kernel Image
> header, and respects text_offset automatically.

I am using u-boot. I don't know if uboot takes into account text_offset in kernel Image header.
I don't think it's there, otherwise uboot would have given an error to respect the load address requirements.
I will ask uboot maintainer if such checks (load address = 2MB aligned + text_offset) can be added in uboot.
Thanks again for your help.

>
> Thanks,
> Mark.
>
> >
> > Do you know why the support of "loading kernel Image anywhere in
> > memory" has been removed in latest kernel ?
> >
> > Regards,
> > Pankaj Bansal
> >
> > > -----Original Message-----
> > > From: Pankaj Bansal
> > > Sent: Tuesday, 7 May, 2019 04:03 PM
> > > To: 'Catalin Marinas' <[email-masked]>; 'Will Deacon'
> > > <[email-masked]>
> > > Cc: [email-masked]' <linux-arm-
> > > [email-masked]>; Varun Sethi <[email-masked]>
> > > Subject: [ARMv8] kernel entry point
> > >
> > > Hi Catalin/Will et. Al,
> > >
> > > I am s/w engineer from NXP India Pvt. Ltd.
> > > I am facing an issue while booting linux on our ARMv8 based platform.
> > > In our platform DDR address starts from 0x80000000.
> > > If I load kernel image @ address 0x80080000 and then try to boot
> > > linux image from this address, then linux is booting fine.
> > > BUT if I load kernel image @ address 0x81000000 and then try to boot
> > > linux image from this address, then linux is not booting.
> > > I have tried to boot linux using u-boot as well as arm trusted firmware.
> > > Linux is not booting with either of these if the linux load address is
> 0x81000000.
> > >
> > > I get no kernel logs like "[    0.000000] Booting Linux on physical CPU 0x0"
> > >
> > > The linux version that I am using is 4.14.53 Can you please help me
> > > in debugging this issue?
> > >
> > > Regards,
> > > Pankaj Bansal
> >
> > _______________________________________________
> > linux-arm-kernel mailing list
> > [email-masked]
> > https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Flists
> > .infradead.org%2Fmailman%2Flistinfo%2Flinux-arm-
> kernel&amp;data=02%7C0
> >
> 1%7Cpankaj.bansal%40nxp.com%7C045f77d8202040db896108d6d54d15f2%7C
> 686ea
> >
> 1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C636930924443311148&amp;sda
> ta=Ykm
> > rBwDOYYLdrOtWFDeBxY2on3xwBP%2F8O1seKm9aiio%3D&amp;reserved=0