From patchwork Mon Jun 25 06:34:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 10485105 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 4A4346031B for ; Mon, 25 Jun 2018 06:34:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 218D728518 for ; Mon, 25 Jun 2018 06:34:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 11B76286C1; Mon, 25 Jun 2018 06:34:38 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.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 E2F7828518 for ; Mon, 25 Jun 2018 06:34:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=76X29akZ0jGlHQKCD5a1kdeB1dw69t1NGnNZH55ZB+w=; b=tYv TUVDiLONwPKX62BdYV50YsjHFe2BAb5tNYQYGwWZzemm1aRbZCGlvWJyo5c7U3NxTYMRy5Vz8rlJ8 7LVhYmj9W9K5b586gNvfbc984QF0UF5xWBPOZJUjUIHc0Vqo5vw7DGbVbSzbDySIHRgQ23rApCAjo tBNpXdoC933ZRmZUr08gFQqb+HZyJrlho3gqUmy/EtKpv5A4kVxCeq/BQazbvagZX+3RKoPSQ7zpC hKgM928hMNhSjZLDjtPFMwZMwbltUtV+fPzMdSpR85kpQZDy39R5/GFPpo8xuMSZ5CcFfh0XOMp5d yGsplST2q0GHM3ggX4+4mOITB1yuK5g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fXL54-00084c-L6; Mon, 25 Jun 2018 06:34:30 +0000 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fXL50-000842-PV for linux-arm-kernel@lists.infradead.org; Mon, 25 Jun 2018 06:34:28 +0000 Received: by mail-wm0-x241.google.com with SMTP id z13-v6so2369119wma.5 for ; Sun, 24 Jun 2018 23:34:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=9mUdit5rP71DvYMj7u5kJ1RkS+5ADZZM2pznLZbCzN8=; b=O8lQpVUXXBY/lHukmRn/zeI0l3MHs8DD5m4Z3aImDGIaxh/xH0kZxMvd5tF4+503dg 6reqBwhY5wIqe/5lEosOznHhh9ozv2gyC9dN6h5YB86q8Cu1RRNRUq/Ieg0KISndl+Mw XZywuTXB+TVpdssniSF9LUqI/guSXZhIn3gwI= 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=9mUdit5rP71DvYMj7u5kJ1RkS+5ADZZM2pznLZbCzN8=; b=Jw5Zz0cSH1Liqz4dEUb/qmOk2Q7ggs1tuYtqQH3vo5Ex1u9JORy12id1NEIVTLEszT GgYGpWdulSNaKEjOCi/VRo7s/7Mcx5EFFgJzOBv6yW/aZP0ZtA07rVBOv7rruNYQN1jq zxtLhAGujxgJIYqIF/TsqJmCJ79E2Vt8m19Ru6Vp46SitGKXT4vmG5bImXXPNFIHDapl 8188d4g1SrZCbjTOO+yDZlDOvBztOT5hbYJAAxeM6bQzM/w1mImo0sBMZ45ayRrpKu4f nnA0N/rkEYQXJueXiYLYVE/vMgmKiVfbTRWKhS2hOjSIO9mpswkd9rhua6x3c9nV8zPC kDow== X-Gm-Message-State: APt69E1P1WB1XZ8M9uNEI+dUn5zBLQhynCZ1RkJWgtjKmdg5vFbvfpfD 8Iwrpj8k6xdJ2BuLLGJ3WtamSg== X-Google-Smtp-Source: ADUXVKKPnxjuLrr3r0yJQjsDqyMuOgaBCO8hKAFEniySG92T83W0BF9chkEmErmmlaL6LC4hUs+0rg== X-Received: by 2002:a1c:6943:: with SMTP id e64-v6mr8288914wmc.14.1529908452637; Sun, 24 Jun 2018 23:34:12 -0700 (PDT) Received: from rev02.home ([2a01:cb1d:112:6f00:2103:b672:319b:2cbb]) by smtp.gmail.com with ESMTPSA id l5-v6sm11498537wrn.92.2018.06.24.23.34.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 Jun 2018 23:34:11 -0700 (PDT) From: Ard Biesheuvel To: linux-efi@vger.kernel.org Subject: [PATCH] efi/libstub/arm: add opt-in Kconfig option for the DTB loader Date: Mon, 25 Jun 2018 08:34:05 +0200 Message-Id: <20180625063405.24387-1-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180624_233426_836879_5F676A77 X-CRM114-Status: GOOD ( 19.16 ) 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: Ard Biesheuvel , leif.lindholm@linaro.org, linux-arm-kernel@lists.infradead.org, agraf@suse.de 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 There are various ways a platform can provide a device tree binary to the kernel, with different levels of sophistication: - ideally, the UEFI firmware, which is tightly coupled with the platform, provides a device tree image directly as a UEFI configuration table, and typically permits the contents to be manipulated either via menu options or via UEFI environment variables that specify a replacement image, - GRUB for ARM has a 'devicetree' directive which allows a device tree image to be loaded from any location accessible to GRUB, and supersede the one provided by the firmware, - the EFI stub implements a dtb= command line option that allows a device tree image to be loaded from a file residing in the same file system as the one the kernel image was loaded from. The dtb= command line option was never intended to be more than a development feature, to allow the other options to be implemented in parallel. So let's make it an opt-in feature that is disabled by default, but can be re-enabled at will. Note that we already disable the dtb= command line option when we detect that we are running with UEFI Secure Boot enabled. Signed-off-by: Ard Biesheuvel Acked-by: Leif Lindholm Reviewed-by: Alexander Graf --- drivers/firmware/efi/Kconfig | 12 ++++++++++++ drivers/firmware/efi/libstub/arm-stub.c | 7 ++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/drivers/firmware/efi/Kconfig b/drivers/firmware/efi/Kconfig index 781a4a337557..fc1cb2961d5b 100644 --- a/drivers/firmware/efi/Kconfig +++ b/drivers/firmware/efi/Kconfig @@ -87,6 +87,18 @@ config EFI_RUNTIME_WRAPPERS config EFI_ARMSTUB bool +config EFI_ARMSTUB_DTB_LOADER + bool "Enable the DTB loader" + depends on EFI_ARMSTUB + help + Select this config option to add support for the dtb= command + line parameter, allowing a device tree blob to be loaded into + memory from the EFI System Partition by the stub. + + The device tree is typically provided by the platform or by + the bootloader, and so this option is mostly for development + purposes only. + config EFI_BOOTLOADER_CONTROL tristate "EFI Bootloader Control" depends on EFI_VARS diff --git a/drivers/firmware/efi/libstub/arm-stub.c b/drivers/firmware/efi/libstub/arm-stub.c index 01a9d78ee415..c98b1856fc3d 100644 --- a/drivers/firmware/efi/libstub/arm-stub.c +++ b/drivers/firmware/efi/libstub/arm-stub.c @@ -202,9 +202,10 @@ unsigned long efi_entry(void *handle, efi_system_table_t *sys_table, * 'dtb=' unless UEFI Secure Boot is disabled. We assume that secure * boot is enabled if we can't determine its state. */ - if (secure_boot != efi_secureboot_mode_disabled && - strstr(cmdline_ptr, "dtb=")) { - pr_efi(sys_table, "Ignoring DTB from command line.\n"); + if (!IS_ENABLED(CONFIG_EFI_ARMSTUB_DTB_LOADER) || + secure_boot != efi_secureboot_mode_disabled) { + if (strstr(cmdline_ptr, "dtb=")) + pr_efi(sys_table, "Ignoring DTB from command line.\n"); } else { status = handle_cmdline_files(sys_table, image, cmdline_ptr, "dtb=",