aboutsummaryrefslogtreecommitdiff
path: root/acpi
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2023-02-02 00:38:13 +0100
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2023-02-02 00:38:13 +0100
commit21cd3b718a2311671ef283759b6d3723fa9db232 (patch)
tree379794e8f2cde7b4ceb39f22a0b6d9b97ca66f72 /acpi
parent0cc80b3913489e74f6d5a0ac9b8a4c5523d9cecd (diff)
downloadhurd-21cd3b718a2311671ef283759b6d3723fa9db232.tar.gz
hurd-21cd3b718a2311671ef283759b6d3723fa9db232.tar.bz2
hurd-21cd3b718a2311671ef283759b6d3723fa9db232.zip
Avoid unaligned memory accesses
Diffstat (limited to 'acpi')
-rw-r--r--acpi/acpi.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/acpi/acpi.c b/acpi/acpi.c
index dd32d60f..736728ae 100644
--- a/acpi/acpi.c
+++ b/acpi/acpi.c
@@ -95,17 +95,19 @@ acpi_get_num_tables(size_t *num_tables)
ntables = (root_sdt->length - sizeof(*root_sdt)) / sz_ptr;
/* Get pointer to first ACPI table */
- uintptr_t acpi_ptr = (uintptr_t)root_sdt + sizeof(*root_sdt);
+ void *acpi_ptr = (void*)root_sdt + sizeof(*root_sdt);
/* Get number of readable tables */
*num_tables = 0;
for (int i = 0; i < ntables; i++)
{
- uintptr_t acpi_ptr32 = (uintptr_t)*((uint32_t *)(acpi_ptr + i*sz_ptr));
- uintptr_t acpi_ptr64 = (uintptr_t)*((uint64_t *)(acpi_ptr + i*sz_ptr));
if (is_64bit) {
+ uint64_t acpi_ptr64;
+ memcpy(&acpi_ptr64, acpi_ptr + i*sz_ptr, sizeof(acpi_ptr64));
next = acpi_os_map_memory(acpi_ptr64, ESCD_SIZE);
} else {
+ uint32_t acpi_ptr32;
+ memcpy(&acpi_ptr32, acpi_ptr + i*sz_ptr, sizeof(acpi_ptr32));
next = acpi_os_map_memory(acpi_ptr32, ESCD_SIZE);
}
@@ -198,16 +200,18 @@ acpi_get_tables(struct acpi_table **tables)
ntables = (root_sdt->length - sizeof(*root_sdt)) / sz_ptr;
/* Get pointer to first ACPI table */
- uintptr_t acpi_ptr = (uintptr_t)root_sdt + sizeof(*root_sdt);
+ void *acpi_ptr = (void*)root_sdt + sizeof(*root_sdt);
/* Get all tables and data */
for (int i = 0; i < ntables; i++)
{
- uintptr_t acpi_ptr32 = (uintptr_t)*((uint32_t *)(acpi_ptr + i*sz_ptr));
- uintptr_t acpi_ptr64 = (uintptr_t)*((uint64_t *)(acpi_ptr + i*sz_ptr));
if (is_64bit) {
+ uint64_t acpi_ptr64;
+ memcpy(&acpi_ptr64, acpi_ptr + i*sz_ptr, sizeof(acpi_ptr64));
next = acpi_os_map_memory(acpi_ptr64, ESCD_SIZE);
} else {
+ uint32_t acpi_ptr32;
+ memcpy(&acpi_ptr32, acpi_ptr + i*sz_ptr, sizeof(acpi_ptr32));
next = acpi_os_map_memory(acpi_ptr32, ESCD_SIZE);
}