[PATCH] arm64: Get 'info->page_offset' from PT_LOAD segments to support KASLR boot cases
The existing methodology to obtain 'info->page_offset' from reading
_stext symbol (from kallsyms) doesn't work well in KASLR boot cases on
arm64 machines as the PAGE_OFFSET (or the virtual address which
indicates the start of the linear region) can be randomized as well
on basis of the kaslr-seed.
Since the value of PAGE_OFFSET inside the kernel is randomized in such
cases and there is no existing mechanism of conveying this value from
kernel-space to user-space, so we can use the method used by archs like
x86_64 to generate the 'info->page_offset' value from the PT_LOAD
segments by subtracting the phy_addr from virt_addr of a PT_LOAD
segment.
This approach works fine both with KASLR and non-KASLR boot cases.
I tested this on my qualcomm-amberwing board. Here are some logs from
the KASLR boot cases:
- Verify that the EFI firmware supports 'kaslr-seed':
chosen {
kaslr-seed = <0x0 0x0>;
<..snip..>
};
- Verify that '--mem-usage' works well after this fix as well (I used
kernel 4.18.0-rc4+ for my checks):
The kernel version is not supported.
The makedumpfile operation may be incomplete.
TYPE PAGES EXCLUDABLE DESCRIPTION
----------------------------------------------------------------------
ZERO 4396 yes Pages filled with zero
NON_PRI_CACHE 27859 yes Cache pages without private flag
PRI_CACHE 18490 yes Cache pages with private flag
USER 2728 yes User process pages
FREE 1465848 yes Free pages
KERN_DATA 18537 no Dumpable kernel data
page size: 65536
Total pages on system: 1537858
Total size on system: 100785061888 Byte
Signed-off-by:
Bhupesh Sharma <bhsharma@redhat.com>
Signed-off-by:
Kazuhito Hagio <k-hagio@ab.jp.nec.com>
Loading