From patchwork Mon Feb 6 11:22:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 93409 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp1661044qgi; Mon, 6 Feb 2017 03:24:10 -0800 (PST) X-Received: by 10.99.48.68 with SMTP id w65mr12724095pgw.107.1486380249978; Mon, 06 Feb 2017 03:24:09 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l33si421891pld.26.2017.02.06.03.24.09; Mon, 06 Feb 2017 03:24:09 -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 S1751887AbdBFLYB (ORCPT + 2 others); Mon, 6 Feb 2017 06:24:01 -0500 Received: from mail-wr0-f179.google.com ([209.85.128.179]:34281 "EHLO mail-wr0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751473AbdBFLYA (ORCPT ); Mon, 6 Feb 2017 06:24:00 -0500 Received: by mail-wr0-f179.google.com with SMTP id o16so21721306wra.1 for ; Mon, 06 Feb 2017 03:23:54 -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:in-reply-to:references; bh=ROKcIhM4fG3zwMNC6zOqiTeytdqVa8CunxyL9zVRgDA=; b=TSi3u9u+HUrv62M/tsLxYWhQ1fCWtM+RRCE508KCgpATP+WS6Ix2k4ihBjx9OXIUMT dmgndMl8onSNwXHYYzJund/fPJfeMG/0RUx2DlxYg43jyv1/lokbWFaFBQu0KPhnAJz2 kJBVi6zHT4kth3wbecj+rq2lReLj3ymtUAjHA= 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:in-reply-to :references; bh=ROKcIhM4fG3zwMNC6zOqiTeytdqVa8CunxyL9zVRgDA=; b=DOykqo2kzPDEKUnNv0rx9o0ZIeZZ4TuSn+Tqvd/R+vgNFteVpmHFNdGfHzuoZWZIQe xkOhaiGaEGKoXBSsRpMWimiQZLn0UDd+AyKqChO3VeqkFD73VdDnA15w6qXs6/NRyUav 4vqU08kwxcDY26Rmsf1a8UMkMWxPbks8YkI9vBSvxp2pog3wIw1VvZHqgAPOecpqcyaB ihbFaDnbF/gNol7+yBFyoarpYlsdb0WomVpqx1pTi5sG+/9jwbaYFEIMPqomDSppulLN 3B4Gb7KgZImJefp+OX7Q23bi3i+VPKdF5GNTqMUqeUS1ehz6o2D42f38yKvfTRsoxoab RS2A== X-Gm-Message-State: AIkVDXJRcVHBLsP3q4jloDRi3JH7sP+B18qfcoCL4yz4RMNebVDsI+auxXsXMSvDNbJ+k/aW X-Received: by 10.223.160.132 with SMTP id m4mr10449431wrm.116.1486380233990; Mon, 06 Feb 2017 03:23:53 -0800 (PST) Received: from localhost.localdomain ([160.169.163.122]) by smtp.gmail.com with ESMTPSA id o70sm903698wrc.20.2017.02.06.03.23.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 06 Feb 2017 03:23:53 -0800 (PST) From: Ard Biesheuvel To: matt@codeblueprint.co.uk, Ingo Molnar , Thomas Gleixner , "H . Peter Anvin" Cc: Ard Biesheuvel , linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org Subject: [PATCH 7/7] efi: libstub: Make file I/O chunking x86-specific Date: Mon, 6 Feb 2017 11:22:46 +0000 Message-Id: <1486380166-31868-8-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1486380166-31868-1-git-send-email-ard.biesheuvel@linaro.org> References: <1486380166-31868-1-git-send-email-ard.biesheuvel@linaro.org> 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 Tested-by: Arnd Bergmann Reviewed-by: Matt Fleming --- 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 diff --git a/drivers/firmware/efi/libstub/efi-stub-helper.c b/drivers/firmware/efi/libstub/efi-stub-helper.c index 6ee9164251a9..2a07b867bec7 100644 --- a/drivers/firmware/efi/libstub/efi-stub-helper.c +++ b/drivers/firmware/efi/libstub/efi-stub-helper.c @@ -414,6 +414,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. */ @@ -586,7 +594,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;