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
Unknown Object (File)
Fri, Jun 26, 5:41 AM
Unknown Object (File)
Fri, Jun 26, 5:41 AM
Unknown Object (File)
Tue, Jun 23, 5:55 PM
Unknown Object (File)
Tue, Jun 23, 12:14 AM
Unknown Object (File)
Sun, Jun 21, 8:54 PM
Unknown Object (File)
May 27 2026, 9:17 AM
Unknown Object (File)
Apr 30 2026, 8:38 PM
Unknown Object (File)
Apr 27 2026, 1:45 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