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: 92993 Delivered-To: patch@linaro.org Received: by 10.182.3.34 with SMTP id 2csp1902041obz; Tue, 31 Jan 2017 08:02:50 -0800 (PST) X-Received: by 10.99.94.198 with SMTP id s189mr31516753pgb.211.1485878570677; Tue, 31 Jan 2017 08:02:50 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b5si11562539pgj.395.2017.01.31.08.02.50; Tue, 31 Jan 2017 08:02:50 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-efi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751214AbdAaQCu (ORCPT + 2 others); Tue, 31 Jan 2017 11:02:50 -0500 Received: from mail-wm0-f45.google.com ([74.125.82.45]:37453 "EHLO mail-wm0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751043AbdAaQCt (ORCPT ); Tue, 31 Jan 2017 11:02:49 -0500 Received: by mail-wm0-f45.google.com with SMTP id v77so99309834wmv.0 for ; Tue, 31 Jan 2017 08:01:11 -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=qtP0712wQYQIuBwhQnzyme7JIBMt1tWNwtCK6uMzGg3NYn5Krq+A5Sf8d2cv/zMvlk 5QYXX5DXa9L+gpI6YtroZPHXk4YYYPeVi3ILvoS353GiZ+2VxMvTGGNnEKygZ3mV0eJM xErRxMU35Z9pc3AuLsmlUZIwQeOiyKVLqdFOC9YFcuJgozDhHedMQ2htfkWnpgSjc0ej h+mpry9y2EZjbuTllgUcWZ5VCJYAtrellA+8MEveW1pq1c0mSNIJjv0mYgNPBb4va9r2 eWhV4vBencs6DeIYyu45AbhA1vqWvWQIQuDBEhYQmaMqYv6gzgGWhuVe0gKCxGz4H0Kd s3ig== X-Gm-Message-State: AIkVDXJHqm/+tzTOsG5lJF3IDlykkVcQ0TR1EuHO5RI1B/b92lghmuLxN0EDcF8aqqarCAtE 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 Cc: matt@codeblueprint.co.uk, arnd@arndb.de, Ard Biesheuvel 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 Sender: linux-efi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org 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 --- drivers/firmware/efi/libstub/efi-stub-helper.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-efi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Tested-by: Arnd Bergmann 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;