[PATCH 2/2] Revert "[PATCH V2 1/4] x86_64: Calculate page_offset from pt_load"

Pratyush Anand panand at redhat.com
Tue May 23 22:43:53 PDT 2017


Hi Hatayama,


On Wednesday 24 May 2017 07:39 AM, Hatayama, Daisuke wrote:
> How about this?
> - return immediately in case of kaslr because there's no need to refer to PT_LOAD entries,
> - refer to PT_LOAD entries only if they exist, and
> - finally try to get page offset according to kernel versions.

It looks fine to me.
So if you agree then I can send next revision with your "Suggested-by" tag.

https://github.com/pratyushanand/makedumpfile/commit/16655ce1f4c2da8d4066072db2a03c84bf2553fe

>
>     static int
>     get_page_offset_x86_64(void)
>     {
>             if (info->kaslr_offset) {
>                     unsigned long page_offset_base;
>
>                     page_offset_base = get_symbol_addr("page_offset_base");
>                     page_offset_base += info->kaslr_offset;
>                     if (!readmem(VADDR, page_offset_base, &info->page_offset,
>                                  sizeof(info->page_offset))) {
>                              ERRMSG("Can't read page_offset_base.\n");
>                              return FALSE;
>                     }
>                     return TRUE;
>             }
>
>             if (get_num_pt_loads()) {
>                     int i;
>                     unsigned long long phys_start;
>                     unsigned long long virt_start;
>
>                     for (i = 0;
>                          get_pt_load(i, &phys_start, NULL, &virt_start, NULL);
>                          i++) {
>                             if (virt_start != NOT_KV_ADDR
>                                 && virt_start < __START_KERNEL_map
>                                 && phys_start != NOT_PADDR) {
>                                     info->page_offset = virt_start - phys_start;
>                                     return TRUE;
>                             }
>                     }
>             }
>
>             if (info->kernel_version < KERNEL_VERSION(2, 6, 27)) {
>                     info->page_offset = __PAGE_OFFSET_ORIG;
>             } else {
>                     info->page_offset = __PAGE_OFFSET_2_6_27;
>             }
>
>             return TRUE;
>     }

Thanks

~Pratyush



More information about the kexec mailing list