Skip to content
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

find user pt_regs from task_struct #13

Open
dvc94ch opened this issue Feb 28, 2021 · 0 comments
Open

find user pt_regs from task_struct #13

dvc94ch opened this issue Feb 28, 2021 · 0 comments
Labels
enhancement New feature or request hard

Comments

@dvc94ch
Copy link
Owner

dvc94ch commented Feb 28, 2021

not so hard in C but tricky in rust. needed for flamegraphing kprobe's and tracepoint and adding the kernel part to profile.

iovisor/bcc#2073

struct task_struct* __current = (struct task_struct*)bpf_get_current_task();
void* __current_stack_page = __current->stack;
void* __ptr = __current_stack_page + THREAD_SIZE - TOP_OF_KERNEL_STACK_PADDING;
struct pt_regs* _tctx = ((struct pt_regs *)__ptr) - 1;

THREAD_SIZE should be 2 * PAGE_SIZE and PAGE_SIZE 4096
TOP_OF_KERNEL_STACK_PADDING should be 0 on x86_64

@dvc94ch dvc94ch added the hard label Feb 28, 2021
@dvc94ch dvc94ch mentioned this issue Feb 28, 2021
3 tasks
@dvc94ch dvc94ch added the enhancement New feature or request label Feb 28, 2021
@dvc94ch dvc94ch self-assigned this Feb 28, 2021
@dvc94ch dvc94ch removed their assignment Apr 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request hard
Projects
None yet
Development

No branches or pull requests

1 participant