[PATCH v5 3/3] makedumpfile/arm64: Add support for ARMv8.2-LVA (52-bit kernel VA support)

HAGIO KAZUHITO(萩尾 一仁) k-hagio-ab at nec.com
Wed Jan 13 19:43:36 EST 2021


-----Original Message-----
> Considering the following related commit order
> 
>     b6d00d47e81a arm64: mm: Introduce 52-bit Kernel VAs                        (2)
>     ce3aaed87344 arm64: mm: Modify calculation of VMEMMAP_SIZE
>     c8b6d2ccf9b1 arm64: mm: Separate out vmemmap
>     c812026c54cf arm64: mm: Logic to make offset_ttbr1 conditional
>     5383cc6efed1 arm64: mm: Introduce vabits_actual
>     90ec95cda91a arm64: mm: Introduce VA_BITS_MIN
>     99426e5e8c9f arm64: dump: De-constify VA_START and KASAN_SHADOW_START
>     6bd1d0be0e97 arm64: kasan: Switch to using KASAN_SHADOW_OFFSET
>     14c127c957c1 arm64: mm: Flip kernel VA space                               (1)
> 
> And
>     #define _PAGE_END(va)		(-(UL(1) << ((va) - 1)))
>     #define PAGE_OFFSET (((0xffffffffffffffffUL) - ((1UL) << (vabits_actual - 1)) + 1))  //old
>     #define PAGE_OFFSET (-(1UL << vabits_actual))                                        //new
> 
> before (1), SYMBOL(_text) < PAGE_OFFSET, afterward, SYMBOL(_text) > PAGE_END == "old PAGE_OFFSET"
> 
> So the comparasion of kernel version can be replaced by
>     if SYMBOL(_text) > PAGE_END
> 	info->page_offset = new PAGE_OFFSET
>     else
> 	info->page_offset = old PAGE_OFFSET

Oh, if we use PAGE_END(VA_BITS_MIN) here, which was actually changed in 5.11
from PAGE_END(vabits_actual), that sounds good to me.  Excellent!

I've been splitting and rewriting this patch of Bhupesh to remove some parts
I mentioned and for easier review and adding my ideas [1], though still halfway.
I'd like to try taking Pingfan's idea in.

[1] https://github.com/k-hagio/makedumpfile/commits/arm64.kh.test2


BTW, we have one more challenge, for 5.4+ kernels without NUMBER(TCR_EL1_T1SZ),
I'm thinking about using SYMBOL(mem_section) to get vabits_actual, because it
should be an address in kernel linear space.

+       if (NUMBER(TCR_EL1_T1SZ) != NOT_FOUND_NUMBER) {
+               vabits_actual = 64 - NUMBER(TCR_EL1_T1SZ);
+               DEBUG_MSG("vabits_actual : %d (vmcoreinfo)\n", vabits_actual);
+       } else if ((info->kernel_version >= KERNEL_VERSION(5, 4, 0)) &&
+                   (va_bits == 52) && (SYMBOL(mem_section) != NOT_FOUND_SYMBOL)) {
+               /*
+                * Linux 5.4 through 5.10 have the following linear space:
+                *  48-bit: 0xffff000000000000 - 0xffff7fffffffffff
+                *  58-bit: 0xfff0000000000000 - 0xfff7ffffffffffff
+                */
+               if (SYMBOL(mem_section) & (1UL << (52 - 1)))
+                       vabits_actual = 48;
+               else
+                       vabits_actual = 52;
+       } else {
+               vabits_actual = va_bits;
+               DEBUG_MSG("vabits_actual : %d (same as va_bits)\n", vabits_actual);
+       }

This might not work with 5.11, but work through 5.10.

Any comments?

Thanks,
Kazu


More information about the kexec mailing list