From patchwork Tue Jan 31 15:52:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 9547557 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A4F7260415 for ; Tue, 31 Jan 2017 15:53:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 954AD281E1 for ; Tue, 31 Jan 2017 15:53:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 87D33281A7; Tue, 31 Jan 2017 15:53:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, T_DKIM_INVALID autolearn=no version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0BD48281A7 for ; Tue, 31 Jan 2017 15:53:10 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cYak0-0000GU-Sf; Tue, 31 Jan 2017 15:53:08 +0000 Received: from mail-wm0-x22c.google.com ([2a00:1450:400c:c09::22c]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cYajs-0008Tl-SB for linux-arm-kernel@lists.infradead.org; Tue, 31 Jan 2017 15:53:07 +0000 Received: by mail-wm0-x22c.google.com with SMTP id b65so84877325wmf.0 for ; Tue, 31 Jan 2017 07:52:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=Bm2x+yZf/enabwSOl8iKeT7CMqEX+mEBbDvuPNzg5yE=; b=P2AzsDnlbAuX5YamlO7K0k4i2l/O4+exep9SN/LR7n0u+v1ivQFM39+P7YuLo8H1an tibK0XVJMQCJoI/h61TVRT/btltOYb6vaSruNrbg8LpnyzPcoqo4awnkUpqPfhCz9FW5 bE6P6BouDNSAfg+9KQQzASBqa6r9inDLig/qE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Bm2x+yZf/enabwSOl8iKeT7CMqEX+mEBbDvuPNzg5yE=; b=PqW84dCLHt5MbMlvk4Idq/O/BMKy7OakfUXW+GnttJwEOh4rPoxIUd9Qvy0LbSR7qb j3yEIAlxg3TBbkT3efa8JywRfGx7xTsipKTrGEV+uyHP5SgoJSIb229FptHR2YqBsoNU EkyK00hAGSt2oAGeFuzh6n8/mdYFw2ARBmEYXRFo/ANEf1QSDP6y4/MKdc+y0T7vFRa1 r+bxrzGDedzj6tHab1oluhoZhpV7duz3emkJYtiavh27hCLQeWdFq6z4eXBD4ohOFZzI gwVpM1D4XVMVw2A5QdKHzaLs8ddzb+e+afe6HsSiOjiBKd8ytavJJo1Z5Bx0bo8macGV BabQ== X-Gm-Message-State: AIkVDXIeHxjXZI/AcA5R346QtCCwWEfaoSIU+M1XjDzWil79pKcdpaAsPUwBhrhTgFPqywLX X-Received: by 10.28.206.199 with SMTP id e190mr19753447wmg.98.1485877958598; Tue, 31 Jan 2017 07:52:38 -0800 (PST) Received: from localhost.localdomain ([105.130.17.13]) by smtp.gmail.com with ESMTPSA id a72sm29090986wrc.48.2017.01.31.07.52.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 31 Jan 2017 07:52:37 -0800 (PST) From: Ard Biesheuvel To: linux-efi@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH] efi: libstub: Make file I/O chunking x86-specific Date: Tue, 31 Jan 2017 15:52:29 +0000 Message-Id: <1485877949-21981-1-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170131_075301_205015_80BE361C X-CRM114-Status: GOOD ( 14.25 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: matt@codeblueprint.co.uk, arnd@arndb.de, Ard Biesheuvel MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The ARM decompressor is finicky when it comes to uninitialized variables with local linkage, the reason being that it may relocate .text and .bss independently when executing from ROM. This is only possible if all references into .bss from .text are absolute, and this happens to be the case for references emitted under -fpic to symbols with external linkage, and so all .bss references must involve symbols with external linkage. When building the ARM stub using clang, the initialized local variable __chunk_size is optimized into a zero-initialized flag that indicates whether chunking is in effect or not. This flag is therefore emitted into .bss, which triggers the ARM decompressor's diagnostics, resulting in a failed build. Under UEFI, we never execute the decompressor from ROM, so the diagnostic makes little sense here. But we can easily work around the issue by making __chunk_size global instead. However, given that the file I/O chunking that is controlled by the __chunk_size variable is intended to work around known bugs on various x86 implementations of UEFI, we can simply make the chunking an x86 specific feature. This is an improvement by itself, and also removes the need to parse the efi= options in the stub entirely. Signed-off-by: Ard Biesheuvel Tested-by: Arnd Bergmann --- drivers/firmware/efi/libstub/efi-stub-helper.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/firmware/efi/libstub/efi-stub-helper.c b/drivers/firmware/efi/libstub/efi-stub-helper.c index 757badc1debb..5a418a6a33bf 100644 --- a/drivers/firmware/efi/libstub/efi-stub-helper.c +++ b/drivers/firmware/efi/libstub/efi-stub-helper.c @@ -351,6 +351,14 @@ efi_status_t efi_parse_options(char *cmdline) char *str; /* + * Currently, the only efi= option we look for is 'nochunk', which + * is intended to work around known issues on certain x86 UEFI + * versions. So ignore for now on other architectures. + */ + if (!IS_ENABLED(CONFIG_X86)) + return EFI_SUCCESS; + + /* * If no EFI parameters were specified on the cmdline we've got * nothing to do. */ @@ -523,7 +531,9 @@ efi_status_t handle_cmdline_files(efi_system_table_t *sys_table_arg, size = files[j].size; while (size) { unsigned long chunksize; - if (size > __chunk_size) + + if (IS_ENABLED(CONFIG_X86) && + size > __chunk_size) chunksize = __chunk_size; else chunksize = size;