summaryrefslogtreecommitdiff
path: root/source/compiler/aslcache.c
diff options
context:
space:
mode:
authorJessica Clarke <jrtc27@jrtc27.com>2021-10-03 16:54:25 +0100
committerJessica Clarke <jrtc27@jrtc27.com>2021-10-03 16:54:25 +0100
commitbc08cde8ffe45d1a7f2c32ed72e719c58eec4bcb (patch)
tree380880874c0b8e5b5acf5ae7cd2a011963e52b95 /source/compiler/aslcache.c
parente01cc6b3d12b5f73f44d46fa15a7f569c793b328 (diff)
downloadacpica-bc08cde8ffe45d1a7f2c32ed72e719c58eec4bcb.tar.gz
iASL: Fix unaligned accesses to local cache allocations
Despite the documentation talking of strings, and the various constants and variables used in the function also doing so, UtLocalCacheCalloc gets used for things other than strings, such as FlInitOneFile using it to allocate an ASL_GLOBAL_FILE_NODE. The easiest way to fix that for a bump the pointer allocator is to just round up every allocation's size; there are more complex alternatives, as allocations smaller than the maximum native alignment only need to be rounded up to the next power of two, but optimising for that case seems unnecessarily complicated. It might make sense to split this into a string allocator and a separate generic object allocator (to complement the existing specific object allocators) to ensure strings can still be packed tightly in memory, but that is a more invasive change that may not be worth it for the small decrease in memory footprint.
Diffstat (limited to 'source/compiler/aslcache.c')
-rw-r--r--source/compiler/aslcache.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/source/compiler/aslcache.c b/source/compiler/aslcache.c
index 51e6f4c46..05ae19b74 100644
--- a/source/compiler/aslcache.c
+++ b/source/compiler/aslcache.c
@@ -183,6 +183,11 @@ UtLocalCacheCalloc (
UINT32 CacheSize = ASL_STRING_CACHE_SIZE;
+#ifdef ACPI_MISALIGNMENT_NOT_SUPPORTED
+ /* Used for objects other than strings, so keep allocations aligned */
+ Length = ACPI_ROUND_UP_TO_NATIVE_WORD (Length);
+#endif
+
if (Length > CacheSize)
{
CacheSize = Length;