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, Oct 10, 11:44 PM
Unknown Object (File)
Fri, Oct 10, 11:44 PM
Unknown Object (File)
Fri, Oct 10, 11:44 PM
Unknown Object (File)
Fri, Oct 10, 5:22 PM
Unknown Object (File)
Tue, Oct 7, 4:22 PM
Unknown Object (File)
Wed, Oct 1, 8:19 AM
Unknown Object (File)
Mon, Sep 29, 4:53 AM
Unknown Object (File)
Jul 29 2025, 4:58 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