Page MenuHomeFreeBSD

libsa: smbios: Detect less-than-64-bit platforms via __SIZEOF_SIZE_T__
ClosedPublic

Authored by olce on Mar 11 2025, 5:01 PM.
Tags
None
Referenced Files
F175685102: D49318.diff
Mon, Oct 12, 12:44 PM
Unknown Object (File)
Sat, Oct 10, 9:04 PM
Unknown Object (File)
Sat, Oct 10, 12:54 PM
Unknown Object (File)
Wed, Oct 7, 3:49 PM
Unknown Object (File)
Mon, Oct 5, 12:16 PM
Unknown Object (File)
Mon, Oct 5, 11:12 AM
Unknown Object (File)
Sat, Oct 3, 10:46 AM
Unknown Object (File)
Fri, Oct 2, 5:19 PM
Subscribers

Details

Summary

What is really wanted here is to know if pointers can refer to 64-bit
addresses, regardless of whether they also hold other information (such
as capabilities in CHERI). SIZEOF_SIZE_T provides that exact
information, so let's use it. ILP32 wasn't wrong in practice
though, as no 32-bit CHERI hardware currently exists (and likely, won't
either in the future).

Consistently with this change, test whether we can actually address the
64-bit SMBIOS's structure table by converting the end address to
'size_t' and checking whether its value is preserved.

Suggested by: jhb (for the ILP32 => SIZEOF_SIZE_T part)
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

Diff Detail

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

Event Timeline

olce requested review of this revision.Mar 11 2025, 5:01 PM

I'm not completely sure if this change is worth it.

Additionally, according to what's in the C standard, wouldn't using __SIZEOF_PTRDIFF_T__ instead of __SIZEOF_SIZE_T__ be more accurate?

PTRDIFF_T isn't quite the same thing. Also, 32-bit CHERI hardware does exist (CHERI-RISC-V such as CHERIoT), it's just that FreeBSD won't be ported to them.

stand/libsa/smbios.c
194

These comments are still fine, so you don't have to change them if you don't want to. In particular, it's still a 32-bit limit.

This revision is now accepted and ready to land.Mar 13 2025, 2:31 PM