Page MenuHomeFreeBSD

linuxkpi: Accept NULL as a value in `linux_xarray`
ClosedPublic

Authored by dumbbell on Feb 12 2023, 10:09 AM.
Tags
None
Referenced Files
Unknown Object (File)
Jan 12 2024, 4:40 AM
Unknown Object (File)
Dec 20 2023, 7:29 AM
Unknown Object (File)
Jul 2 2023, 12:44 PM
Unknown Object (File)
Jul 2 2023, 12:43 PM
Unknown Object (File)
Jul 2 2023, 12:41 PM
Unknown Object (File)
Jul 2 2023, 12:20 PM
Unknown Object (File)
Jun 19 2023, 8:59 PM
Unknown Object (File)
Jun 14 2023, 12:38 AM

Details

Summary

Linux' XArray allows to store a NULL pointer as a value. xa_load() would return NULL for both an unused index and an index set to NULL. But it impacts xa_alloc() which needs to find the next available index.

However, our implementation relies on a radix tree (see linux_radix.c) which does not accept NULL pointers as values. I'm not sure if this is a limitation or a feature, so to work around this, a NULL value is replaced by NULL_VALUE, an unlikely address, when we pass it to linux_radix.

This is part of the update of the DRM drivers to Linux 5.15.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

manu added a subscriber: hselasky.

Maybe wait for @hselasky comment

This revision is now accepted and ready to land.Feb 13 2023, 11:40 AM

Looks like an acceptable solution, thank you for the detailed comment describing the situation.

markj added inline comments.
sys/compat/linuxkpi/common/src/linux_xarray.c
250

Should we assert that the passed-in value for ptr isn't equal to NULL_VALUE?

sys/compat/linuxkpi/common/src/linux_xarray.c
250

Good idea, I will prepare another patch. Thanks!