Page MenuHomeFreeBSD

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

Authored by olce on Tue, Mar 11, 5:01 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Mar 24, 2:27 AM
Unknown Object (File)
Wed, Mar 19, 11:18 AM
Unknown Object (File)
Tue, Mar 18, 3:30 AM
Unknown Object (File)
Sat, Mar 15, 5:11 AM
Unknown Object (File)
Fri, Mar 14, 6:38 PM
Unknown Object (File)
Wed, Mar 12, 1:22 AM
Unknown Object (File)
Tue, Mar 11, 5:39 PM
Subscribers

Details

Reviewers
jhb
imp
markj
manu
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 Skipped
Unit
Tests Skipped
Build Status
Buildable 62869
Build 59753: arc lint + arc unit

Event Timeline

olce requested review of this revision.Tue, Mar 11, 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.Thu, Mar 13, 2:31 PM