[Crash-utility] [PATCH v5 0/3] Improve kaslr_offset detection
lijiang
lijiang at redhat.com
Thu Nov 12 02:27:10 UTC 2020
在 2020年11月11日 13:17, HAGIO KAZUHITO(萩尾 一仁) 写道:
> Hi Alexey,
>
> -----Original Message-----
>> v5 change: added ack by Lianbo Jiang.
>>
>> v4 changes: fixed GCC warnings reported by Kazu.
>
> Thanks for the update.
>
>>
>> Alexey Makhalov (3):
>> calc_kaslr_offset: try all CPUs
>> calc_kaslr_offset: 5-level paging support
>
> I tested the patchset on a qemu memory dump with 5-level paging (la57)
> and crash failed during starting session:
>
> crash: read error: physical address: 125a0c000 type: "p4d page"
>
Thank you for checking this error, Kazu.
I did not make the test for this patch because it was marked as Verified as below:
Patch #2: new patch. 5 level paging support. Verified.
Seems that making the test myself is a good way to check for errors ASAP.
Thanks.
Lianbo
> It seems that it needs something like:
>
> diff --git a/kaslr_helper.c b/kaslr_helper.c
> index f13b7ff0850b..b9fef825a290 100644
> --- a/kaslr_helper.c
> +++ b/kaslr_helper.c
> @@ -671,6 +671,8 @@ calc_kaslr_offset(ulong *ko, ulong *pb)
> machdep->machspec->physical_mask_shift = __PHYSICAL_MASK_SHIFT_5LEVEL;
> machdep->machspec->pgdir_shift = PGDIR_SHIFT_5LEVEL;
> machdep->machspec->ptrs_per_pgd = PTRS_PER_PGD_5LEVEL;
> + if ((machdep->machspec->p4d = (char *)malloc(PAGESIZE())) == NULL)
> + error(FATAL, "cannot malloc p4d space.");
> } else {
> machdep->machspec->physical_mask_shift = __PHYSICAL_MASK_SHIFT_2_6;
> machdep->machspec->pgdir_shift = PGDIR_SHIFT;
> diff --git a/x86_64.c b/x86_64.c
> index 0acef2b04faf..939c8a9fddd4 100644
> --- a/x86_64.c
> +++ b/x86_64.c
> @@ -356,9 +356,11 @@ x86_64_init(int when)
> machdep->machspec->physical_mask_shift = __PHYSICAL_MASK_SHIFT_5LEVEL;
> machdep->machspec->pgdir_shift = PGDIR_SHIFT_5LEVEL;
> machdep->machspec->ptrs_per_pgd = PTRS_PER_PGD_5LEVEL;
> - if ((machdep->machspec->p4d = (char *)malloc(PAGESIZE())) == NULL)
> - error(FATAL, "cannot malloc p4d space.");
> - machdep->machspec->last_p4d_read = 0;
> + if (!machdep->machspec->p4d) {
> + if ((machdep->machspec->p4d = (char *)malloc(PAGESIZE())) == NULL)
> + error(FATAL, "cannot malloc p4d space.");
> + machdep->machspec->last_p4d_read = 0;
> + }
> machdep->uvtop = x86_64_uvtop_level4; /* 5-level is optional per-task */
> machdep->kvbase = (ulong)PAGE_OFFSET;
> machdep->identity_map_base = (ulong)PAGE_OFFSET;
>
> With this, tested OK.
> If this looks good, I can fix 2/3 when merging, or you can repost.
>
> Thanks,
> Kazu
>
>> kaslr: get offset by walking page tree
>>
>> defs.h | 8 +-
>> diskdump.c | 6 +
>> kaslr_helper.c | 434 ++++++++++++++++++++++++++++++++++++++++++---------------
>> netdump.c | 6 +
>> sadump.c | 37 +----
>> symbols.c | 5 +-
>> vmware_vmss.c | 15 +-
>> 7 files changed, 359 insertions(+), 152 deletions(-)
>>
>> --
>> 2.11.0
>
More information about the Crash-utility
mailing list