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)
Sat, Nov 22, 12:49 PM
Unknown Object (File)
Tue, Nov 18, 12:16 AM
Unknown Object (File)
Nov 4 2025, 6:14 PM
Unknown Object (File)
Nov 1 2025, 1:25 PM
Unknown Object (File)
Oct 27 2025, 3:45 AM
Unknown Object (File)
Oct 27 2025, 3:41 AM
Unknown Object (File)
Oct 27 2025, 3:40 AM
Unknown Object (File)
Oct 26 2025, 10:22 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