Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp315152ybt; Wed, 17 Jun 2020 01:27:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxxXSM8hglp9M+EV3dAjU1iSCbQSmu5FUdHoCFa37XmyWT1X5CGHqRKEsYXaXzwLWRkNw6S X-Received: by 2002:a17:906:694c:: with SMTP id c12mr6513129ejs.495.1592382458303; Wed, 17 Jun 2020 01:27:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592382458; cv=none; d=google.com; s=arc-20160816; b=gwL4LOcH/TTXxmXA6TWg2Cy+6VoOUF9zspxnKJa9ObYhqyx55GpiSZM2V6KJgROQ0+ /xnl5So9LOebTqjYzCMotF+cjxSYrprCVTw7INONtB1aYEiJlgg+i8hMJ3BLTMa/sBMa jmMy1FJPsEAJKCZPGtB+GeAVwloKzDLULr6KfrKDvBDiV4Lot7Em9h2a/UTIcJavrdMg pTDcjZhrc4GOXv3KHUvZeM601x4T27Qf/ZyJ/38F9JpzH+bvWfDp5T7S3ZgV+JNy1FHc dDYSNhf9IdiKZDiF7PmdOhGhN2gsgL7GBApat52u5pyli86DVewdcc4E7baV74dkcOyy ksZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=5DtacwDjBSNEn9PFrALMuhNKTLfYiIOUDiuxFd/7Z7k=; b=LwmvOffjroQgRwO609QdB/P5gm0HJd96FxAgXQygbTPqHp93aKHK858anLcXugZ2nA 6dO07vEx4XP9M3jXRDB3io7Q7zt126jGk+o2OTQ23MNXAZWtKQ4Wm99D2nCv430AEUum tWQie5eqOAzzeirRhEouDm+iiTcNa7kZFjm8vBKz1QFHAwlgZs0xyud34DgSe18rN2ot EGYyjLFMBVrgtTjGyKNF1IPtuOPJ1QIoLXINXdFe/sAxxGgP3nraFvU/CkxBthCRhQxt +cRspqLa22ZAhMbyGgONWs8Ye03kCJ94O73SevJSM7Ej4JZLAGIYyIH3SIEk0JTngxCw d+SQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="0bc/kx5H"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i21si12469546edv.162.2020.06.17.01.27.15; Wed, 17 Jun 2020 01:27:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="0bc/kx5H"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726341AbgFQIZN (ORCPT + 99 others); Wed, 17 Jun 2020 04:25:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:46314 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725901AbgFQIZM (ORCPT ); Wed, 17 Jun 2020 04:25:12 -0400 Received: from localhost.localdomain (lfbn-nic-1-188-42.w2-15.abo.wanadoo.fr [2.15.37.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2EF642100A; Wed, 17 Jun 2020 08:25:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592382312; bh=WE28cH+mnd/5QSfDhggdio7ufTc6leSAfR4Hjh8Tn1s=; h=From:To:Cc:Subject:Date:From; b=0bc/kx5HTLQkQkU30PmG/f7Is5rojzFBguZQoSq+KzGrH/Y2vGr/sVgCE2PNY2t8X lSLzZ/4wuZEKLmmv3t/PxChdkfo76chUxCN8hlq7aIYaqkNKisbKkZS0VbpAjkLh+M piit97Z6H5W7/dtjeRswAOj64rOiai+npqqjtNbg= From: Ard Biesheuvel To: linux-kernel@vger.kernel.org Cc: linux-acpi@vger.kernel.org, lenb@kernel.org, rjw@rjwysocki.net, Ard Biesheuvel Subject: [PATCH] ACPI: avoid relocations for table signature array Date: Wed, 17 Jun 2020 10:25:05 +0200 Message-Id: <20200617082505.1159131-1-ardb@kernel.org> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- drivers/acpi/tables.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c index 0e905c3d1645..ada36bc40c2b 100644 --- a/drivers/acpi/tables.c +++ b/drivers/acpi/tables.c @@ -490,7 +490,7 @@ static u8 __init acpi_table_checksum(u8 *buffer, u32 length) } /* All but ACPI_SIG_RSDP and ACPI_SIG_FACS: */ -static const char * const table_sigs[] = { +static const char table_sigs[][ACPI_NAMESEG_SIZE] __initconst = { ACPI_SIG_BERT, ACPI_SIG_BGRT, ACPI_SIG_CPEP, ACPI_SIG_ECDT, ACPI_SIG_EINJ, ACPI_SIG_ERST, ACPI_SIG_HEST, ACPI_SIG_MADT, ACPI_SIG_MSCT, ACPI_SIG_SBST, ACPI_SIG_SLIT, ACPI_SIG_SRAT, @@ -501,7 +501,7 @@ static const char * const table_sigs[] = { ACPI_SIG_WDDT, ACPI_SIG_WDRT, ACPI_SIG_DSDT, ACPI_SIG_FADT, ACPI_SIG_PSDT, ACPI_SIG_RSDT, ACPI_SIG_XSDT, ACPI_SIG_SSDT, ACPI_SIG_IORT, ACPI_SIG_NFIT, ACPI_SIG_HMAT, ACPI_SIG_PPTT, - ACPI_SIG_NHLT, NULL }; + ACPI_SIG_NHLT }; #define ACPI_HEADER_SIZE sizeof(struct acpi_table_header) @@ -548,11 +548,11 @@ void __init acpi_table_upgrade(void) table = file.data; - for (sig = 0; table_sigs[sig]; sig++) + for (sig = 0; sig < ARRAY_SIZE(table_sigs); sig++) if (!memcmp(table->signature, table_sigs[sig], 4)) break; - if (!table_sigs[sig]) { + if (sig >= ARRAY_SIZE(table_sigs)) { pr_err("ACPI OVERRIDE: Unknown signature [%s%s]\n", cpio_path, file.name); continue; -- 2.27.0