Skip to contentSkip to conversation

Facing issue with va to pa conversion in arm64/makedumpfile

DISCUSSION [email protected] 3 participants 3 messages Nov 18, 2020 – Nov 20, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi Pratyush/ Kazuhito ,

While attempting to create dumpfile on arm64, I was face issues with virtual address to physical address conversion when kalsr is enable. Linux kernel version is 5.4.42 stable kernel.

The following patch seems to add patch to enable kalsr support :

[PATCH 10/10] arm64: fix memory layout as per changes in v4.6 kernel

https://sourceforge.net/p/makedumpfile/code/ci/b6fe70c7ffef9affb540412407702b15d4a196e9

static unsigned long long
+__pa(unsigned long vaddr)
+{
+ if (kimage_voffset == NOT_FOUND_NUMBER ||
+ (vaddr >= PAGE_OFFSET))
+ return (vaddr - PAGE_OFFSET + info->phys_base);
+ else
+ return (vaddr - kimage_voffset);
+}

I see that even when kimage_voffset is available , it calculates pa using PAGE_OFFSET. But as KALSR is enabled it should ideally use kimage_voffset.

Not sure what is the significance of the check (vaddr >= PAGE_OFFSET) if kimage_voffset is available.

i think this should be something like

+ if (kimage_voffset == NOT_FOUND_NUMBER) && (vaddr >= PAGE_OFFSET))
+ return (vaddr - PAGE_OFFSET + info->phys_base);
+ else
+ return (vaddr - kimage_voffset);

Because we want to check vaddr is greater than PAGE_OFFSET when we are considering linear mapping without kaslr seed.

Or may be we should have a separate check which will error out all vaddr less than PAGE_OFFSET and kimage_voffset.

+ if (vaddr < PAGE_OFFSET)
+ return -EINVAL;
+ if (kimage_voffset == NOT_FOUND_NUMBER)
+ return (vaddr - PAGE_OFFSET + info->phys_base);
+ else
+ return (vaddr - kimage_voffset);

Signature · 7 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#1 lore raw

Hi Akshay,
(Cc Bhupesh)

-----Original Message-----

Quoted 5 lines

Hi Pratyush/ Kazuhito ,

While attempting to create dumpfile on arm64, I was face issues with virtual address to physical address conversion when kalsr is enable. Linux kernel version is 5.4.42 stable kernel.

It seems that it would be due to the flipped VA space at 5.4 arm64 kernel. Bhupesh has been addressing this for us, but not merged yet. How does it work with this patch?
http://lists.infradead.org/pipermail/kexec/2020-September/021336.html

(Its 1/3 and 2/3 patches were already merged, so I think the 3/3 patch can be applied on top of the latest makedumpfile.)

Thanks,
Kazu

Quoted 54 lines

The following patch seems to add patch to enable kalsr support :

[PATCH 10/10] arm64: fix memory layout as per changes in v4.6 kernel

https://sourceforge.net/p/makedumpfile/code/ci/b6fe70c7ffef9affb540412407702b15d4a196e9

static unsigned long long

(quoted diff) +8 -0
+__pa(unsigned long vaddr)
+{
+       if (kimage_voffset == NOT_FOUND_NUMBER ||
+                       (vaddr >= PAGE_OFFSET))
+               return (vaddr - PAGE_OFFSET + info->phys_base);
+       else
+               return (vaddr - kimage_voffset);
+}

I see that even when kimage_voffset is available , it calculates pa using PAGE_OFFSET.
But as KALSR is enabled it should ideally use kimage_voffset.

Not sure what is the significance of the check (vaddr >= PAGE_OFFSET) if kimage_voffset is available.

i think this should be something like

+ if (kimage_voffset == NOT_FOUND_NUMBER) && (vaddr >=
PAGE_OFFSET))

(quoted diff) +3 -0
+               return (vaddr - PAGE_OFFSET + info->phys_base);
+       else
+               return (vaddr - kimage_voffset);

Because we want to check vaddr is greater than PAGE_OFFSET when we are considering linear mapping without kaslr seed.

Or may be we should have a separate check which will error out all vaddr less than PAGE_OFFSET and kimage_voffset.

(quoted diff) +6 -1
+       if  (vaddr < PAGE_OFFSET)
+              return -EINVAL;
+       if (kimage_voffset == NOT_FOUND_NUMBER)
+               return (vaddr - PAGE_OFFSET + info->phys_base);
+       else
+               return (vaddr - kimage_voffset);
 
--

The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project

Quoted 4 lines

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#2 lore raw

Hello Akshay,

As Kazu mentioned please try the patch :
http://lists.infradead.org/pipermail/kexec/2020-September/021336.html
and let me know your observations.

I am still on my holidays but will try to check my emails from today, so will help you with any further issues.

Thanks,
Bhupesh

Quoted 76 lines · HAGIO KAZUHITO(萩尾 一仁)

Hi Akshay,
(Cc Bhupesh)

-----Original Message-----

Quoted 5 lines

Hi Pratyush/ Kazuhito ,

While attempting to create dumpfile on arm64, I was face issues with virtual address to physical address conversion when kalsr is enable. Linux kernel version is 5.4.42 stable kernel.

It seems that it would be due to the flipped VA space at 5.4 arm64 kernel. Bhupesh has been addressing this for us, but not merged yet. How does it work with this patch?
http://lists.infradead.org/pipermail/kexec/2020-September/021336.html

(Its 1/3 and 2/3 patches were already merged, so I think the 3/3 patch can be applied on top of the latest makedumpfile.)

Thanks,
Kazu

Quoted 54 lines

The following patch seems to add patch to enable kalsr support :

[PATCH 10/10] arm64: fix memory layout as per changes in v4.6 kernel

https://sourceforge.net/p/makedumpfile/code/ci/b6fe70c7ffef9affb540412407702b15d4a196e9

static unsigned long long

(quoted diff) +8 -0
+__pa(unsigned long vaddr)
+{
+       if (kimage_voffset == NOT_FOUND_NUMBER ||
+                       (vaddr >= PAGE_OFFSET))
+               return (vaddr - PAGE_OFFSET + info->phys_base);
+       else
+               return (vaddr - kimage_voffset);
+}

I see that even when kimage_voffset is available , it calculates pa using PAGE_OFFSET.
But as KALSR is enabled it should ideally use kimage_voffset.

Not sure what is the significance of the check (vaddr >= PAGE_OFFSET) if kimage_voffset is available.

i think this should be something like

+ if (kimage_voffset == NOT_FOUND_NUMBER) && (vaddr >=
PAGE_OFFSET))

(quoted diff) +3 -0
+               return (vaddr - PAGE_OFFSET + info->phys_base);
+       else
+               return (vaddr - kimage_voffset);

Because we want to check vaddr is greater than PAGE_OFFSET when we are considering linear mapping without kaslr seed.

Or may be we should have a separate check which will error out all vaddr less than PAGE_OFFSET and kimage_voffset.

(quoted diff) +6 -1
+       if  (vaddr < PAGE_OFFSET)
+              return -EINVAL;
+       if (kimage_voffset == NOT_FOUND_NUMBER)
+               return (vaddr - PAGE_OFFSET + info->phys_base);
+       else
+               return (vaddr - kimage_voffset);
 
--

The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project

Quoted 5 lines
Quoted 4 lines

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec