Skip to content

Support struct arguments and return values in kmodify #434

Open
@osandov

Description

@osandov

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions