Subject: Re: [RFC/RFT PATCH 2/5] memblock: introduce generic memblock_setup_resources()

From: Mike Rapoport <[email-masked]>
Date: Wed, 2 Jun 2021 16:54:17 +0300

On Wed, Jun 02, 2021 at 11:15:21AM +0100, Russell King (Oracle) wrote:
> On Wed, Jun 02, 2021 at 11:33:10AM +0300, Mike Rapoport wrote:
> > On Tue, Jun 01, 2021 at 02:54:15PM +0100, Russell King (Oracle) wrote:
> > > On Mon, May 31, 2021 at 03:29:56PM +0300, Mike Rapoport wrote:
> > > > +	code_resource.start = __pa_symbol(_text);
> > > > +	code_resource.end = __pa_symbol(_etext)-1;
> > > > +	rodata_resource.start = __pa_symbol(__start_rodata);
> > > > +	rodata_resource.end = __pa_symbol(__end_rodata)-1;
> > > > +	data_resource.start = __pa_symbol(_sdata);
> > > > +	data_resource.end = __pa_symbol(_edata)-1;
> > > > +	bss_resource.start = __pa_symbol(__bss_start);
> > > > +	bss_resource.end = __pa_symbol(__bss_stop)-1;
> > > 
> > > This falls short on 32-bit ARM. The old code was:
> > > 
> > > -       kernel_code.start   = virt_to_phys(_text);
> > > -       kernel_code.end     = virt_to_phys(__init_begin - 1);
> > > -       kernel_data.start   = virt_to_phys(_sdata);                             
> > > -       kernel_data.end     = virt_to_phys(_end - 1);                           
> > > 
> > > If I look at one of my kernels:
> > > 
> > > c0008000 T _text
> > > c0b5b000 R __end_rodata
> > > ... exception and unwind tables live here ...
> > > c0c00000 T __init_begin
> > > c0e00000 D _sdata
> > > c0e68870 D _edata
> > > c0e68870 B __bss_start
> > > c0e995d4 B __bss_stop
> > > c0e995d4 B _end
> > > 
> > > So the original covers _text..__init_begin-1 which includes the
> > > exception and unwind tables. Your version above omits these, which
> > > leaves them exposed.
> > 
> > Right, this needs to be fixed. Is there any reason the exception and unwind
> > tables cannot be placed between _sdata and _edata? 
> > 
> > It seems to me that they were left outside for purely historical reasons.
> > Commit ee951c630c5c ("ARM: 7568/1: Sort exception table at compile time")
> > moved the exception tables out of .data section before _sdata existed.
> > Commit 14c4a533e099 ("ARM: 8583/1: mm: fix location of _etext") moved
> > _etext before the unwind tables and didn't bother to put them into data or
> > rodata areas.
> 
> You can not assume that all sections will be between these symbols. This
> isn't specific to 32-bit ARM. If you look at x86's vmlinux.lds.in, you
> will see that BUG_TABLE and ORC_UNWIND_TABLE are after _edata, along
> with many other undiscarded sections before __bss_start.

But if you look at x86's setup_arch() all these never make it to the
resource tree. So there are holes in /proc/iomem between the kernel
resources.

> So it seems your assumptions in trying to clean this up are somewhat
> false.

My assumption was that there is complete lack of consistency between what
is reserved memory and how it is reported in /proc/iomem or
/sys/firmware/memmap for that matter. I'm not trying to clean this up, I'm
trying to make different views of the physical memory consistent.
Consolidating several similar per-arch implementations is the first step in
this direction.
 
-- 
Sincerely yours,
Mike.

_______________________________________________
linux-arm-kernel mailing list
[email-masked]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel