Skip to content

aarch64: introduce user_rootpgt param to read user space memory #77

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: tip
Choose a base branch
from

Conversation

AlexanderKamensky
Copy link

Hi Petr,

My libkdumpfile based gdbserver
https://github.com/AlexanderKamensky/libkdumpfile/tree/new_20230805/gdbserver#process
does not work with your latest code.

The issue that now I cannot set rootpgt to read user-land
memory. This patch addresses it by introducing user_rootpgt.

Thanks,
Alexander

Commit dfa510f (aarch64:
Fix bottom VA range translation in Linux) introduced METH_UPGT
for user-space bottom addresses that cover TTBR0_EL1 addresses.
Unfortunately, it breaks the case where root pgt from user
land process was passed and used to translate vmcore memory
to get specified user land process virtual memory reads.
libkdumpfile based gdbserver was using such functionality before:

https://github.com/AlexanderKamensky/libkdumpfile/tree/new_20230805/gdbserver#process

This patch introduces new keyword parameter user_rootpgt for
System.os_init, that would be filled into METH_UPGT method
param.pgt.root. As result any kernel or user land virtual
addresses will be readable.

Signed-off-by: Alexander Kamensky <[email protected]>
@ptesarik
Copy link
Owner

ptesarik commented Nov 6, 2023

Hi Alexander!

Thank you for your PR. I am trying to understand why a user-space page table hierarchy is needed on AArch64. The address translation library is based on the idea of address spaces, and AFAIK AArch64 has a single page table hierarchy in hardware, so one root page table should be sufficient to represent any existing address space. The concept of user-space page table root was added to cover the case where two page table hierarchies are used to cover a single address space. This happens with Linux on IBM POWER without hardware page tables.

If the operating system implements page table isolation between kernel-space and user-space, libaddrxlat users are expected to build two translation systems and always use the one that is appropriate for the situation (kernel-space or user-space).

It seems that you want to represent an address space which does not actually exist in the real world, using a "kernel page table root" for one range of virtual addresses (kernel-space) and a "user page table root" for another range (user-space). I can see how such an aggregate system would be useful on architectures where kernel-space addresses are in a different range than user-space addresses, but I'm not 100% sure about the proposed API, because "user page table root" then has a different meaning for POWER and AArch64.

Please, can you confirm that I have understood the intended use case correctly?

@ptesarik
Copy link
Owner

ptesarik commented Nov 6, 2023

Hi Alexander,
I've had another look at your patch, and it doesn't do more than provide a way to set the existing user page table root in a call to addrxlat_sys_os_init(). It could be also achieved by modifying the address translation system at a later point, but if we there is an init-time option, it could be exposed in the kdumpfile attribute system.
In other words, I'm not against the option, but I suggest you also add it to the options array in src/kdumpfile/vtop.c.

@@ -829,6 +829,11 @@ typedef enum _addrxlat_optidx {
*/
ADDRXLAT_OPT_rootpgt,

/** User land root page table address. Used *only* in aarch64 case.
* Type: full address
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment is confusing. I don't see anything architecture-specific here, and in fact the option should also be very useful on IBM POWER.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants