[PATCH 6/6] ARM: mm: truncate memory banks to fit in 4GB space for classic MMU

Will Deacon will.deacon at arm.com
Tue Mar 6 12:58:53 EST 2012


On Tue, Mar 06, 2012 at 06:06:40PM +0000, Sergei Shtylyov wrote:
> Hello.

Hi Sergei,

> On 03/06/2012 07:54 PM, Will Deacon wrote:
> 
> > If a bank of memory spanning the 4GB boundary is added on a !CONFIG_LPAE
> > kernel then we will hang early during boot since the memory bank will
> > have wrapped around to zero.
> 
> > This patch truncates memory banks for !LPAE configurations when the end
> > address is not representable in 32 bits.
> 
> > Signed-off-by: Will Deacon<will.deacon at arm.com>
> > ---
> >   arch/arm/kernel/setup.c |   11 ++++++++++-
> >   1 files changed, 10 insertions(+), 1 deletions(-)
> 
> > diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
> > index a255c39..aeaa048 100644
> > --- a/arch/arm/kernel/setup.c
> > +++ b/arch/arm/kernel/setup.c
> > @@ -521,7 +521,16 @@ int __init arm_add_memory(phys_addr_t start, unsigned long size)
> >   	 */
> >   	size -= start&  ~PAGE_MASK;
> >   	bank->start = PAGE_ALIGN(start);
> > -	bank->size  = size&  PAGE_MASK;
> > +
> > +#ifndef CONFIG_LPAE
> > +	if (bank->start + size<  bank->start) {
> > +		printk(KERN_CRIT "Truncating memory at 0x%08llx to fit in "
> > +			"32-bit physical address space\n", (long long)start);
> > +		size = ULONG_MAX - bank->start;
> 
>     I think you forgot to add one here.

No, I deliberately omit the last page because otherwise we end up with the
end address of the bank being calculated as 0, which leads to boot failure.

Will



More information about the linux-arm-kernel mailing list