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

Support struct arguments and return values in kmodify #434

Open
osandov opened this issue Sep 27, 2024 · 0 comments
Open

Support struct arguments and return values in kmodify #434

osandov opened this issue Sep 27, 2024 · 0 comments
Labels
enhancement New feature or request help wanted Seeking volunteers

Comments

@osandov
Copy link
Owner

osandov commented Sep 27, 2024

Struct/union arguments (passed by value) and struct/union return values have a special calling convention. drgn.helpers.experimental.kmodify.call_function() currently doesn't support either:

if return_type.kind not in {
TypeKind.VOID,
TypeKind.INT,
TypeKind.BOOL,
TypeKind.ENUM,
TypeKind.POINTER,
}:
raise NotImplementedError(f"{return_type} return values not implemented")
if type.kind in {
TypeKind.FLOAT,
TypeKind.STRUCT,
TypeKind.UNION,
TypeKind.CLASS,
}:
raise NotImplementedError(
f"passing {type} by value not implemented"
)

It's not super common to pass or return structs in the kernel, but it does happen, so it'd be good to support it. The calling convention on x86-64 is something like small structs get split up and passed/returned in registers, and large structs are put on the stack. The psABI has the details.

We'll definitely want tests for all of the cases in tests/linux_kernel/helpers/test_kmodify.py using tests/linux_kernel/kmod/drgn_test.c.

@osandov osandov added help wanted Seeking volunteers enhancement New feature or request labels Sep 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Seeking volunteers
Projects
None yet
Development

No branches or pull requests

1 participant