Page MenuHomeFreeBSD

LinuxKPI,lindebugfs: add more base type support
ClosedPublic

Authored by bz on Oct 22 2022, 6:15 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Jun 9, 4:46 PM
Unknown Object (File)
Sun, Jun 9, 4:46 PM
Unknown Object (File)
Sun, Jun 9, 4:46 PM
Unknown Object (File)
May 21 2024, 9:29 PM
Unknown Object (File)
May 21 2024, 9:29 PM
Unknown Object (File)
May 21 2024, 9:12 PM
Unknown Object (File)
May 21 2024, 8:57 PM
Unknown Object (File)
Mar 18 2024, 12:48 AM

Details

Summary

Add debugfs_create_u8() based on other already present implementations.
I am unclear if we need to add extra checks.

Add a dummy (no real implementation yet) for debugfs_create_blob().

Both are needed for iwlwifi debugfs support.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 48208
Build 45095: arc lint + arc unit

Event Timeline

bz requested review of this revision.Oct 22 2022, 6:15 PM

This is just so to have the skeleton for a discussion on how to implement "blob" properly. I am hoping @jfree may have a good idea.

Add missing struct definition already in my local file from earlier work.

I feel like the scattered nature of debugfs material makes it incredibly difficult to work with.
Perhaps something along the lines of this would work:

static int
debugfs_blob_get(void *data, uint64_t *value)
{
	struct debugfs_blob_wrapper *blob = data;
	memcpy(value, blob->data, blob->size);
	return (0);
}

static int
debugfs_blob_set(void *data, uint64_t value)
{
	struct debugfs_blob_wrapper *blob = data;
	blob->size = sizeof(value);
	memcpy(blob->data, &value, blob->size);
	return (0);
}

I think the blob's fops should be defined manually rather than using DEFINE_DEBUGFS_ATTRIBUTE.
This will allow us to malloc the blob->data member in an open fop and free data in the release fop.
The problem is, this malloc would only account for a single sized blob. We would need to add bounds
checking in the blob's get and set functions to ensure safety.

Alternatively, we could dynamically malloc in debugfs_blob_set, but I do not know how to reliably free that.

I am not sure what the origin authors intended for the implementation. Let me know what you think.

Implement ro blob support.

I just took a quick glance, but everything looks good :)
Take a look at my inline comment, though.

sys/compat/lindebugfs/lindebugfs.c
461–463

You can probably use debugfs_create_file() instead of debugfs_create_mode_unsafe() since both of your fops are RO.

Use debugfs_create_file() to create blobs as suggested by @jfree

bz marked an inline comment as done.Nov 7 2022, 1:23 PM

Anyone care to further review / accept this?

This revision was not accepted when it landed; it landed in state Needs Review.Nov 28 2022, 5:25 PM
This revision was automatically updated to reflect the committed changes.