Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp8112302imu; Tue, 4 Dec 2018 03:12:40 -0800 (PST) X-Google-Smtp-Source: AFSGD/UXi599JNCAPLvZCU6nkZqzxlVLZwzg2daEiJyuDKzP8L1ggdR2X3s8g4TXSpjRHmreHvM8 X-Received: by 2002:a62:4181:: with SMTP id g1mr19527611pfd.45.1543921960223; Tue, 04 Dec 2018 03:12:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543921960; cv=none; d=google.com; s=arc-20160816; b=NkUlJ2e2zzNtR1ciHaDXFCqafqKFtqWhODAyVLoKboQw0fDIB58GNiIDIAY6KxUNRx H4crIABahtyQTqi2LWkWKl1WWd6WvgnSsrL6ak7n2k4CCLe7wJWYC6SfA2TMW3RRErWr Tsl7OTv3Ql2BC5uwbUcFXf1+oAxq58zgB+QbIfbw7spx5cRCcCVlyzzwszZjzscLE5pL SzRpsNG2jIzR17WpqF5ALlSiz7uNYpYB8XFR1AHVGydY8WlwzFn8qJjSzFOOzDV/pIur 2C6P7+BXb4jZyw0YPY8wwJnro6/qMPAANPGcm5lEtCfFqmhRlkRmeIPvRIj0Dk8GQLYK zB5w== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=M2HDwiCySb0nr2Z8cr/JnWXZlzWNehQXeKmSSJeVkfA=; b=DIfsiHhGhSgVZECCvIHEYcHuGw95uWwGvpphBTO6cM/CG1UX4OeLHgGx6C18Ru6E3l lGXOEgy24D7oiHqzuTdZzuWQ3EZtyoGjeykSrLkv809rAM+awyAJbIja+DnJIFgwu1o0 8+vOgUL1R8Db5fGSTi6bepHsuQmjnJa5H9ENAOZNzwIwG4o1yQrKbivf8c9sezmaIshA LjZ1cRN8JUGIHbtYccHUIxPw7Tk3w9vzO0OqDcfQiq1ZyPcGz3TZVDL7ZRCBU/e21UtJ J+Snu65UeSxbBYBNW9ZjjQ7c/wdzMNFb0IqCWCsFMk+fsGykrcsYUkwTIaKDy2pbcs3O +gFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vsks0E3R; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 187si17700293pfv.238.2018.12.04.03.12.25; Tue, 04 Dec 2018 03:12:40 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vsks0E3R; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728781AbeLDLJV (ORCPT + 99 others); Tue, 4 Dec 2018 06:09:21 -0500 Received: from mail.kernel.org ([198.145.29.99]:59140 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727990AbeLDLJU (ORCPT ); Tue, 4 Dec 2018 06:09:20 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B37E2214E0; Tue, 4 Dec 2018 11:09:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1543921759; bh=T6XfOrwrjQ4num1BT5tVLSkgpdHfU1XVLnoo+kGxywI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vsks0E3RNAPyP/cAH1q9vcNnSTTOFODJg3L+5o5hwyHXST2xv94GQVMtcM5MeMkNJ cJ9PtNup1cPhci2tlnz0vKPb1bZGZOh3mr+mHHcxk9KPdk0oCXUbpGwPNEDgwj+Rzc MhfKXhlLuZTMzD4eG3NQ9VJgKLuzGG7mhrR7yFog= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Arnd Bergmann , Ard Biesheuvel , Matt Fleming , Linus Torvalds , Peter Zijlstra , Thomas Gleixner , linux-efi@vger.kernel.org, Ingo Molnar , Nick Desaulniers Subject: [PATCH 4.9 49/50] efi/libstub: Make file I/O chunking x86-specific Date: Tue, 4 Dec 2018 11:50:44 +0100 Message-Id: <20181204103716.938039643@linuxfoundation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181204103714.485546262@linuxfoundation.org> References: <20181204103714.485546262@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ard Biesheuvel (commit b3879a4d3a31ef14265a52e8d941cf4b0f6627ae upstream) 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. Tested-by: Arnd Bergmann Signed-off-by: Ard Biesheuvel Reviewed-by: Matt Fleming Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: linux-efi@vger.kernel.org Link: http://lkml.kernel.org/r/1486380166-31868-8-git-send-email-ard.biesheuvel@linaro.org [ Small readability edits. ] Signed-off-by: Ingo Molnar Signed-off-by: Nick Desaulniers Signed-off-by: Greg Kroah-Hartman --- drivers/firmware/efi/libstub/efi-stub-helper.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) --- a/drivers/firmware/efi/libstub/efi-stub-helper.c +++ b/drivers/firmware/efi/libstub/efi-stub-helper.c @@ -356,6 +356,14 @@ efi_status_t efi_parse_options(char *cmd 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. */ @@ -528,7 +536,8 @@ efi_status_t handle_cmdline_files(efi_sy 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;