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, Mar 27, 5:22 AM
Unknown Object (File)
Thu, Mar 26, 6:40 PM
Unknown Object (File)
Wed, Mar 18, 12:46 PM
Unknown Object (File)
Wed, Mar 18, 3:53 AM
Unknown Object (File)
Tue, Mar 17, 10:17 AM
Unknown Object (File)
Fri, Mar 13, 6:26 AM
Unknown Object (File)
Thu, Mar 12, 5:51 PM
Unknown Object (File)
Thu, Mar 12, 1:52 AM
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