Skip to content

Commit 2229a12

Browse files
ardbiesheuvelrafaeljw
authored andcommitted
ACPI: tables: avoid relocations for table signature array
On architectures that implement KASLR using the ELF native RELA relocation format (such as arm64), every absolute reference in the code incurs an overhead of 24 bytes in the .rela section. So storing a 41 element array of 4 character signature strings using an array of pointer-to-char incurs an 8x overhead (32 bytes per entry => ~1500 bytes), and given the fixed length of the entries, and the fact that the array is only used locally, it is much better to use an array of arrays here, which gets rid of the overhead entirely. While at it, make it __initconst, as it is never referenced except from __init code. Signed-off-by: Ard Biesheuvel <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 4877846 commit 2229a12

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/acpi/tables.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ static u8 __init acpi_table_checksum(u8 *buffer, u32 length)
490490
}
491491

492492
/* All but ACPI_SIG_RSDP and ACPI_SIG_FACS: */
493-
static const char * const table_sigs[] = {
493+
static const char table_sigs[][ACPI_NAMESEG_SIZE] __initconst = {
494494
ACPI_SIG_BERT, ACPI_SIG_BGRT, ACPI_SIG_CPEP, ACPI_SIG_ECDT,
495495
ACPI_SIG_EINJ, ACPI_SIG_ERST, ACPI_SIG_HEST, ACPI_SIG_MADT,
496496
ACPI_SIG_MSCT, ACPI_SIG_SBST, ACPI_SIG_SLIT, ACPI_SIG_SRAT,
@@ -501,7 +501,7 @@ static const char * const table_sigs[] = {
501501
ACPI_SIG_WDDT, ACPI_SIG_WDRT, ACPI_SIG_DSDT, ACPI_SIG_FADT,
502502
ACPI_SIG_PSDT, ACPI_SIG_RSDT, ACPI_SIG_XSDT, ACPI_SIG_SSDT,
503503
ACPI_SIG_IORT, ACPI_SIG_NFIT, ACPI_SIG_HMAT, ACPI_SIG_PPTT,
504-
ACPI_SIG_NHLT, NULL };
504+
ACPI_SIG_NHLT };
505505

506506
#define ACPI_HEADER_SIZE sizeof(struct acpi_table_header)
507507

@@ -548,11 +548,11 @@ void __init acpi_table_upgrade(void)
548548

549549
table = file.data;
550550

551-
for (sig = 0; table_sigs[sig]; sig++)
551+
for (sig = 0; sig < ARRAY_SIZE(table_sigs); sig++)
552552
if (!memcmp(table->signature, table_sigs[sig], 4))
553553
break;
554554

555-
if (!table_sigs[sig]) {
555+
if (sig >= ARRAY_SIZE(table_sigs)) {
556556
pr_err("ACPI OVERRIDE: Unknown signature [%s%s]\n",
557557
cpio_path, file.name);
558558
continue;

0 commit comments

Comments
 (0)