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: 139806 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp3618839lji; Sun, 24 Jun 2018 23:34:15 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKZE7VVwbuE0eGDJWC+tOcrbTCKQnOKBxkHHx60/1NEvxCZCHhNMpqar4Uyuu6xgJxBJZxu X-Received: by 2002:a63:4244:: with SMTP id p65-v6mr9557813pga.432.1529908455530; Sun, 24 Jun 2018 23:34:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529908455; cv=none; d=google.com; s=arc-20160816; b=Ysp0y63kr6FUdYA1pkg7Vi4/lHM51h6e4gNXqKIz5KzLEKJEZTEj8IuULwYJufpZQx 1+rUItXCESIwfPKVe+jzmUoohMhvKbDvB9qrglp9qZGM6halIfEdhwHRSH596H7W/C6O BHso3hTn4UIqZEH0p9XtUCxrSa/7aCXbdzkNLpfWNAYYNflXIlFrklAlxFXXG3yhlujN AXdC09mTzZaNh0NBeONt9P+lk8EAfE7aWEKu5vq5VCtvzUyXiVvKjwVQDkvrXu/QoByA 4jRtgpVEnhe3smfGlV+it3dWy7DA2T9rfniL24fVuyIeryDtzbVlXVxTpX7RjtQRxunB W2Kg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=JETiWFGIiAaa63dkl/L5yBvRZwog1Im3e0vrnDqqnHM=; b=Y6Jcd9SX06KxJuvTIHeHSO8SScmZoUGTkFFzitjsvC61feGkc9aC+7ABpF/8N/Dtzm gvMOGmS+BvclN/FwBIo1mvxOF+RFNdXgkYJM/PcXy/xRYfKrXJ9FeRONZngiO70uMZE6 i7AYuTwzJdu8fhiBYn3EO2ZwVTG6SA2IKVF9n9sqA4FIm+rnwew4iyajan+Fd63nXtQ7 sKkmHaWZ8qMK4JM8I9Reqvmhg/2plfWDIcsCa+xj8MirPdtRQrGhJ9ryCmSZH9akQzBn EM2y7MZcwx7NonLnO2UqDeTfpUs34L2ym/ullSeE6kUpT4qZQ5q4lUlJSjcE9o2QgiGp d4mg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=O8lQpVUX; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t20-v6si12734810plr.240.2018.06.24.23.34.15; Sun, 24 Jun 2018 23:34:15 -0700 (PDT) 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 header.s=google header.b=O8lQpVUX; 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 S1752395AbeFYGeO (ORCPT + 3 others); Mon, 25 Jun 2018 02:34:14 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:40781 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752316AbeFYGeO (ORCPT ); Mon, 25 Jun 2018 02:34:14 -0400 Received: by mail-wm0-f65.google.com with SMTP id z13-v6so2369126wma.5 for ; Sun, 24 Jun 2018 23:34:13 -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=GWW3oxxCDq/1A6tNJAtUWrFjFGzbsqFtH3vy1zAIVj+oFfxiWFsMsOpf73dkg0CyLf AjX1OdhIrWUCgZyNT5PnWLvD9IxLxu80goPIYY60X1x75+y9wrBb2KZmYZxnKo/DXF+F HA1nF26Cj6mGLhTBN5mkQ26XYsGVFhDeFFVl0z+rL+wQ9WH0PFF4+pkePKdy7FkO4ZTd nZP4uiMNONq6znKqUBm29F34eS+u+VjGVgQklybZVOJcX0zeBkv2aXwWjNRKn5zkqkiL R2Cdq46b+KExgL5O9kZNTHou9wcJ2hkxSU6OEi1Q7QBSWB5JrqUIewIldk+Nq7S3irZY Lbtg== X-Gm-Message-State: APt69E2c1TUPE+caYSmCgXabdGA9TEwV69TH1kRMSCHAxnj/5V3+IxRj 6NLG05zLJogihV4KZopnTfQod4kcBlk= 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 Cc: linux-arm-kernel@lists.infradead.org, leif.lindholm@linaro.org, agraf@suse.de, Ard Biesheuvel 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 Sender: linux-efi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org 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 --- drivers/firmware/efi/Kconfig | 12 ++++++++++++ drivers/firmware/efi/libstub/arm-stub.c | 7 ++++--- 2 files changed, 16 insertions(+), 3 deletions(-) -- 2.11.0 -- 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 Acked-by: Leif Lindholm Reviewed-by: Alexander Graf 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=",