* Re: [PATCH v24 5/9] arm64: kdump: add kdump support
[not found] ` <20160823112343.GC13501-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
@ 2016-08-24 8:04 ` Dave Young
[not found] ` <20160824080443.GA12902-0VdLhd/A9Pl+NNSt+8eSiB/sF2h8X+2i0E9HWUfgJXw@public.gmane.org>
0 siblings, 1 reply; 3+ messages in thread
From: Dave Young @ 2016-08-24 8:04 UTC (permalink / raw)
To: Pratyush Anand
Cc: mark.rutland-5wv7dgnIgG8, linux-efi-u79uwXL29TY76Z2rM5mHXA,
ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A,
geoff-wEGCiKHe2LqWVfeAwA7xHQ, catalin.marinas-5wv7dgnIgG8,
will.deacon-5wv7dgnIgG8, AKASHI Takahiro,
matt-mF/unelCI9GS6iBeEJttW/XRex20P6io, James Morse,
bauerman-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8,
kexec-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
Ccing uefi people.
On 08/23/16 at 04:53pm, Pratyush Anand wrote:
> On 23/08/2016:09:38:16 AM, AKASHI Takahiro wrote:
> > On Mon, Aug 22, 2016 at 02:47:30PM +0100, James Morse wrote:
> > > On 22/08/16 02:29, AKASHI Takahiro wrote:
> > > > On Fri, Aug 19, 2016 at 04:52:17PM +0530, Pratyush Anand wrote:
> > > >> It will help kexec-tools to prevent copying of any unnecessary data. I
> > > >> think, then you also need to change phys_offset calculation in kexec-tools. That
> > > >> should be start of either of first "reserved" or "System RAM" block.
> > > >
> > > > Good point, but I'm not sure this is always true.
> > >
> > > > Is there any system whose ACPI memory is *not* part of DRAM
> > >
> > > From the spec, it looks like this is allowed.
> > >
> > > What do you mean by 'DRAM'? Any ACPI region will be in the UEFI memory map, so
> > > the question is what is its type and memory attributes?
> >
> > Yes.
> >
> > > The UEFI spec[0] says ACPI regions can have a type of EfiACPIReclaimMemory or
> > > EfiACPIMemoryNVS, the memory attributes aren't specified, so are chosen by the
> > > firmware.
> > >
> > > It is possible these regions have to be mapped non-cacheable, page 40 has a
> > > couple of:
> > > > If no information about the table location exists in the UEFI memory map or
> > > ACPI memory
> > > > descriptors, the table is assumed to be non-cached.
> > >
> > > reserve_regions() in drivers/firmware/efi/arm-init.c will add any entry in the
> > > memory map that has a 'WB' attribute to the memblock.memory list (via
> > > early_init_dt_add_memory_arch()), it will also mark as no-map regions that have
> > > this attribute and aren't in the is_reserve_region() list.
Looking the arm-init.c, I suspect it missed the some efi ranges as
reserved ranges like runtime code and runtime data etc. But I might be
wrong.
Below is the is_reserve_region, it will regard any regions which is not
in the EFI_* below as normal memory, it does not include the runtime
ranges and other types.
static __init int is_reserve_region(efi_memory_desc_t *md)
{
switch (md->type) {
case EFI_LOADER_CODE:
case EFI_LOADER_DATA:
case EFI_BOOT_SERVICES_CODE:
case EFI_BOOT_SERVICES_DATA:
case EFI_CONVENTIONAL_MEMORY:
case EFI_PERSISTENT_MEMORY:
return 0;
default:
break;
}
return is_normal_ram(md);
}
Let's see the x86 do_add_efi_mem_map, the default case set all other
types as reserved. Shouldn't this be same in all arches though there's
no e820 in arm(64)?
static void __init do_add_efi_memmap(void)
{
[snip]
switch (md->type) {
case EFI_LOADER_CODE:
case EFI_LOADER_DATA:
case EFI_BOOT_SERVICES_CODE:
case EFI_BOOT_SERVICES_DATA:
case EFI_CONVENTIONAL_MEMORY:
if (md->attribute & EFI_MEMORY_WB)
e820_type = E820_RAM;
else
e820_type = E820_RESERVED;
break;
[snip]
default:
/*
* EFI_RESERVED_TYPE EFI_RUNTIME_SERVICES_CODE
* EFI_RUNTIME_SERVICES_DATA
* EFI_MEMORY_MAPPED_IO
* EFI_MEMORY_MAPPED_IO_PORT_SPACE EFI_PAL_CODE
*/
e820_type = E820_RESERVED;
break;
}
[snip]
}
> > >
> > > If these ACPI regions have the 'WB' attribute, we add them as memory and mark
> > > them nomap. These show up as either a hole, or 'reserved' in /proc/iomem.
> > > If they don't have the 'WB' attribute, then then they are left out of memblock
> > > and aren't part of DRAM, I don't think these will show up in /proc/iomem at all.
> >
> > Let's say,
> > 0x1000-0x1fff: reserved (SRAM for UEFI, WB)
> > 0x80000000-0xffffffff: System RAM (DRAM)
>
> May be slightly more complicated:
> 0x80000000-0x80001fff: System RAM (DRAM) for UEFI, WB
> 0x80002000-0xffffffff: System RAM (DRAM)
>
> Kernel will have phys_offset 0x80000000, however kexec-tools will calculate it
> as 0x80002000.
>
> >
> > If, as Pratyush suggested, "reserved" resources are added to phys_offset
> > calculation, the kernel linear mapping area starts at PAGE_OFFSET, but
> > there is no actual mapping around PAGE_OFFSET.
> > It won't hurt anything, but looks funny.
> > So we'd better not include "reserved" in phys_offset calculation anyway.
> > -> Pratyush
>
> My only concern is that, then we will have different values of phys_offset in
> kernel and kexec-tools, which might lead to further confusion.
>
> ~Pratyush
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v24 5/9] arm64: kdump: add kdump support
[not found] ` <20160824080443.GA12902-0VdLhd/A9Pl+NNSt+8eSiB/sF2h8X+2i0E9HWUfgJXw@public.gmane.org>
@ 2016-08-24 10:25 ` James Morse
[not found] ` <57BD7619.1040406-5wv7dgnIgG8@public.gmane.org>
0 siblings, 1 reply; 3+ messages in thread
From: James Morse @ 2016-08-24 10:25 UTC (permalink / raw)
To: Dave Young
Cc: Pratyush Anand, AKASHI Takahiro, catalin.marinas-5wv7dgnIgG8,
will.deacon-5wv7dgnIgG8, geoff-wEGCiKHe2LqWVfeAwA7xHQ,
bauerman-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8,
mark.rutland-5wv7dgnIgG8, kexec-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A,
matt-mF/unelCI9GS6iBeEJttW/XRex20P6io,
linux-efi-u79uwXL29TY76Z2rM5mHXA
Hi Dave,
On 24/08/16 09:04, Dave Young wrote:
> Looking the arm-init.c, I suspect it missed the some efi ranges as
> reserved ranges like runtime code and runtime data etc. But I might be
> wrong.
This had me confused for too... I think I get it, my understanding is:
> static __init int is_reserve_region(efi_memory_desc_t *md)
> {
> switch (md->type) {
> case EFI_LOADER_CODE:
> case EFI_LOADER_DATA:
> case EFI_BOOT_SERVICES_CODE:
> case EFI_BOOT_SERVICES_DATA:
> case EFI_CONVENTIONAL_MEMORY:
> case EFI_PERSISTENT_MEMORY:
> return 0;
return false - this is the list of region-types to never reserve, regardless of
memory attributes.
> default:
> break;
> }
> return is_normal_ram(md);
If its not in the 'never reserve' list above, then we check if the region is
'normal' ram. If it is then it will end up in memblock.memory so we return true,
causing it to be marked nomap too.
reserve_regions() in that same file calls is_normal_ram() directly before adding
all regions with the WB attribute to memblock.memory via
early_init_dt_add_memory_arch().
A runtime region with the WB attribute will be caught by is_reserve_region(),
and is_normal_ram(), so it ends up in memblock.memory and memblock.nomap.
> }
>
> Let's see the x86 do_add_efi_mem_map, the default case set all other
> types as reserved. Shouldn't this be same in all arches though there's
> no e820 in arm(64)?
> static void __init do_add_efi_memmap(void)
> {
>
> [snip]
> switch (md->type) {
> case EFI_LOADER_CODE:
> case EFI_LOADER_DATA:
> case EFI_BOOT_SERVICES_CODE:
> case EFI_BOOT_SERVICES_DATA:
> case EFI_CONVENTIONAL_MEMORY:
> if (md->attribute & EFI_MEMORY_WB)
> e820_type = E820_RAM;
In this case reserve_regions() will add the memory to memblock.memory because it
has the WB attribute, and not reserve it.
> else
> e820_type = E820_RESERVED;
Without the WB attribute, these regions are in neither memblock.memory nor
memblock.nomap.
> break;
> [snip]
> default:
> /*
> * EFI_RESERVED_TYPE EFI_RUNTIME_SERVICES_CODE
> * EFI_RUNTIME_SERVICES_DATA
> * EFI_MEMORY_MAPPED_IO
> * EFI_MEMORY_MAPPED_IO_PORT_SPACE EFI_PAL_CODE
> */
> e820_type = E820_RESERVED;
> break;
If any other regions has the WB attribute, it will be added to memblock.memory
and memblock.nomap. If it doesn't, it will appear in neither.
> }
> [snip]
> }
Does this help at all?
Thanks,
James
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v24 5/9] arm64: kdump: add kdump support
[not found] ` <57BD7619.1040406-5wv7dgnIgG8@public.gmane.org>
@ 2016-08-25 1:04 ` Dave Young
0 siblings, 0 replies; 3+ messages in thread
From: Dave Young @ 2016-08-25 1:04 UTC (permalink / raw)
To: James Morse
Cc: Pratyush Anand, mark.rutland-5wv7dgnIgG8,
linux-efi-u79uwXL29TY76Z2rM5mHXA,
ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A,
geoff-wEGCiKHe2LqWVfeAwA7xHQ, catalin.marinas-5wv7dgnIgG8,
will.deacon-5wv7dgnIgG8, AKASHI Takahiro,
matt-mF/unelCI9GS6iBeEJttW/XRex20P6io,
bauerman-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8,
kexec-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
On 08/24/16 at 11:25am, James Morse wrote:
> Hi Dave,
>
> On 24/08/16 09:04, Dave Young wrote:
> > Looking the arm-init.c, I suspect it missed the some efi ranges as
> > reserved ranges like runtime code and runtime data etc. But I might be
> > wrong.
>
> This had me confused for too... I think I get it, my understanding is:
>
James, thanks for your clarification.
>
> > static __init int is_reserve_region(efi_memory_desc_t *md)
> > {
> > switch (md->type) {
> > case EFI_LOADER_CODE:
> > case EFI_LOADER_DATA:
> > case EFI_BOOT_SERVICES_CODE:
> > case EFI_BOOT_SERVICES_DATA:
> > case EFI_CONVENTIONAL_MEMORY:
> > case EFI_PERSISTENT_MEMORY:
> > return 0;
>
> return false - this is the list of region-types to never reserve, regardless of
> memory attributes.
>
>
> > default:
> > break;
> > }
> > return is_normal_ram(md);
>
> If its not in the 'never reserve' list above, then we check if the region is
> 'normal' ram. If it is then it will end up in memblock.memory so we return true,
> causing it to be marked nomap too.
>
> reserve_regions() in that same file calls is_normal_ram() directly before adding
> all regions with the WB attribute to memblock.memory via
> early_init_dt_add_memory_arch().
>
> A runtime region with the WB attribute will be caught by is_reserve_region(),
> and is_normal_ram(), so it ends up in memblock.memory and memblock.nomap.
Hmm, It is not straitforward like the do_add_efi_memmap. I got it.
BTW, I believe there is same problem in arm as well as arm64, it also
need mark the runtime ranges as "reserved" /proc/iomem.
>
>
> > }
> >
> > Let's see the x86 do_add_efi_mem_map, the default case set all other
> > types as reserved. Shouldn't this be same in all arches though there's
> > no e820 in arm(64)?
>
> > static void __init do_add_efi_memmap(void)
> > {
> >
> > [snip]
> > switch (md->type) {
> > case EFI_LOADER_CODE:
> > case EFI_LOADER_DATA:
> > case EFI_BOOT_SERVICES_CODE:
> > case EFI_BOOT_SERVICES_DATA:
> > case EFI_CONVENTIONAL_MEMORY:
> > if (md->attribute & EFI_MEMORY_WB)
> > e820_type = E820_RAM;
>
> In this case reserve_regions() will add the memory to memblock.memory because it
> has the WB attribute, and not reserve it.
>
>
> > else
> > e820_type = E820_RESERVED;
>
> Without the WB attribute, these regions are in neither memblock.memory nor
> memblock.nomap.
>
>
> > break;
> > [snip]
> > default:
> > /*
> > * EFI_RESERVED_TYPE EFI_RUNTIME_SERVICES_CODE
> > * EFI_RUNTIME_SERVICES_DATA
> > * EFI_MEMORY_MAPPED_IO
> > * EFI_MEMORY_MAPPED_IO_PORT_SPACE EFI_PAL_CODE
> > */
> > e820_type = E820_RESERVED;
> > break;
>
> If any other regions has the WB attribute, it will be added to memblock.memory
> and memblock.nomap. If it doesn't, it will appear in neither.
>
>
> > }
> > [snip]
> > }
>
> Does this help at all?
>
Yes, thanks a lot!
Dave
>
> Thanks,
>
> James
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-08-25 1:04 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20160809015615.28527-1-takahiro.akashi@linaro.org>
[not found] ` <20160809015615.28527-3-takahiro.akashi@linaro.org>
[not found] ` <57AB586D.3080900@arm.com>
[not found] ` <20160818071547.GC20080@linaro.org>
[not found] ` <20160819012651.GE20080@linaro.org>
[not found] ` <20160819112217.GB22221@localhost.localdomain>
[not found] ` <20160822012919.GI20080@linaro.org>
[not found] ` <57BB0272.1000008@arm.com>
[not found] ` <20160823003815.GL20080@linaro.org>
[not found] ` <20160823112343.GC13501@localhost.localdomain>
[not found] ` <20160823112343.GC13501-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2016-08-24 8:04 ` [PATCH v24 5/9] arm64: kdump: add kdump support Dave Young
[not found] ` <20160824080443.GA12902-0VdLhd/A9Pl+NNSt+8eSiB/sF2h8X+2i0E9HWUfgJXw@public.gmane.org>
2016-08-24 10:25 ` James Morse
[not found] ` <57BD7619.1040406-5wv7dgnIgG8@public.gmane.org>
2016-08-25 1:04 ` Dave Young
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox