libsa: smbios: Detect less-than-64-bit platforms via __SIZEOF_SIZE_T__
What we really want 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__ is probably the closest indication to that piece of information, so let's use it. __ILP32__ wasn't wrong in practice though, as we don't support 32-bit CHERI hardware (and likely never will). 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) Reviewed by: jhb, imp MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D49318
This commit is contained in:
@@ -186,14 +186,17 @@ smbios_sigsearch(const caddr_t addr, const uint32_t len)
|
||||
*/
|
||||
SMBIOS_GET8(cp, 0x0a) != 0 &&
|
||||
smbios_checksum(cp, SMBIOS_GET8(cp, 0x06)) == 0) {
|
||||
#ifdef __ILP32__
|
||||
#if __SIZEOF_SIZE_T__ < 8
|
||||
uint64_t end_addr;
|
||||
|
||||
end_addr = SMBIOS_GET64(cp, 0x10) + /* Start address. */
|
||||
SMBIOS_GET32(cp, 0x0c); /* Maximum size. */
|
||||
/* Is the table (or part of it) located above 4G? */
|
||||
if (end_addr >= (uint64_t)1 << 32)
|
||||
/* Can't access it with 32-bit addressing. */
|
||||
/*
|
||||
* Is the table (or part of it) located above what we
|
||||
* can address?
|
||||
*/
|
||||
if ((size_t)end_addr != end_addr)
|
||||
/* Yes, give it up. */
|
||||
continue;
|
||||
#endif
|
||||
smbios.is_64bit_ep = 1;
|
||||
|
||||
Reference in New Issue
Block a user