It checks BIT(4) of Elf64_Phdr, currently only the former 3 bits are used by ELF. In kexec-tool, we extend the BIT(4) to indicate pmem or not. dump_Elf_load: phys_start phys_end virt_start virt_end is_pmem dump_Elf_load: LOAD[ 0] 6b800000 6e42c000 ffffffffbcc00000 ffffffffbf82c000 false dump_Elf_load: LOAD[ 1] 1000 9fc00 ffff975980001000 ffff97598009fc00 false dump_Elf_load: LOAD[ 2] 100000 7f000000 ffff975980100000 ffff9759ff000000 false dump_Elf_load: LOAD[ 3] bf000000 bffd7000 ffff975a3f000000 ffff975a3ffd7000 false dump_Elf_load: LOAD[ 4] 100000000 140000000 ffff975a80000000 ffff975ac0000000 false dump_Elf_load: LOAD[ 5] 140000000 23e200000 ffff975ac0000000 ffff975bbe200000 true CC: Baoquan He <bhe@xxxxxxxxxx> CC: Vivek Goyal <vgoyal@xxxxxxxxxx> CC: Dave Young <dyoung@xxxxxxxxxx> Signed-off-by: Li Zhijian <lizhijian@xxxxxxxxxxx> --- elf_info.c | 31 +++++++++++++++++++++++++++---- elf_info.h | 1 + 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/elf_info.c b/elf_info.c index bc24083655d6..41b36b2804d2 100644 --- a/elf_info.c +++ b/elf_info.c @@ -43,6 +43,7 @@ struct pt_load_segment { unsigned long long phys_end; unsigned long long virt_start; unsigned long long virt_end; + int is_pmem; }; static int nr_cpus; /* number of cpu */ @@ -153,6 +154,8 @@ check_elf_format(int fd, char *filename, int *phnum, unsigned int *num_load) return FALSE; } +#define PF_DEV (1 << 4) + static int dump_Elf_load(Elf64_Phdr *prog, int num_load) { @@ -170,17 +173,37 @@ dump_Elf_load(Elf64_Phdr *prog, int num_load) pls->virt_end = pls->virt_start + prog->p_memsz; pls->file_offset = prog->p_offset; pls->file_size = prog->p_filesz; + pls->is_pmem = !!(prog->p_flags & PF_DEV); if (num_load == 0) - DEBUG_MSG("%8s %16s %16s %16s %16s\n", "", - "phys_start", "phys_end", "virt_start", "virt_end"); + DEBUG_MSG("%8s %16s %16s %16s %16s %8s\n", "", + "phys_start", "phys_end", "virt_start", "virt_end", + "is_pmem"); - DEBUG_MSG("LOAD[%2d] %16llx %16llx %16llx %16llx\n", num_load, - pls->phys_start, pls->phys_end, pls->virt_start, pls->virt_end); + DEBUG_MSG("LOAD[%2d] %16llx %16llx %16llx %16llx %8s\n", num_load, + pls->phys_start, pls->phys_end, pls->virt_start, pls->virt_end, + pls->is_pmem ? "true": "false"); return TRUE; } +int is_pmem_pt_load_range(unsigned long long start, unsigned long long end) +{ + int i; + struct pt_load_segment *pls; + + for (i = 0; i < num_pt_loads; i++) { + pls = &pt_loads[i]; + if (pls->is_pmem && pls->phys_start == NOT_PADDR) + return TRUE; + if (pls->is_pmem && pls->phys_start != NOT_PADDR && + pls->phys_start <= start && pls->phys_end >= end) + return TRUE; + } + + return FALSE; +} + static off_t offset_next_note(void *note) { diff --git a/elf_info.h b/elf_info.h index d5416b32cdd7..a08d59a331f6 100644 --- a/elf_info.h +++ b/elf_info.h @@ -64,6 +64,7 @@ int get_pt_load_extents(int idx, off_t *file_offset, off_t *file_size); unsigned int get_num_pt_loads(void); +int is_pmem_pt_load_range(unsigned long long start, unsigned long long end); void set_nr_cpus(int num); int get_nr_cpus(void); -- 2.29.2 _______________________________________________ kexec mailing list kexec@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/kexec