From patchwork Wed Sep 13 22:05:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 813636 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="EAv9cObD"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3xswj54vPRz9sNV for ; Thu, 14 Sep 2017 08:06:01 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 6B5ECC2250A; Wed, 13 Sep 2017 22:05:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 7A41DC21EE1; Wed, 13 Sep 2017 22:05:53 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 44052C21EE1; Wed, 13 Sep 2017 22:05:52 +0000 (UTC) Received: from mail-qt0-f194.google.com (mail-qt0-f194.google.com [209.85.216.194]) by lists.denx.de (Postfix) with ESMTPS id 117BCC21EC9 for ; Wed, 13 Sep 2017 22:05:51 +0000 (UTC) Received: by mail-qt0-f194.google.com with SMTP id q8so948372qtb.1 for ; Wed, 13 Sep 2017 15:05:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=PSbgkCKZQPdD8sfvuoTEjWPCczgrpMjxTvkVlTpA2RY=; b=EAv9cObD1+ZVhW3aHk3vbtu0gg674D707XwaGUGXeG2z8ECZPlvN8+yVcAJ/pORBo8 ZpkWLkzxl8FfTFQuwoITsZdexZ8vWp8GSQIh1NISoipIHkz29aML29uUVKAKIHomq72B BGjYc5iXngr43xHUUdLXAAcAqtED5HNxNVYhGD0KCxt0RxAGQfbEC2Q+eDRluKUQ0bUg y4zVCdN9+ZbcmTpja1wrWE6Uf7x+/79RgRr/WBrTXwxHDY6LTrkUWHfPaYz6LSb8Xdjb EPh3j2XkNkzQwWOreag88FzeoEqsao+/Jn8nM6JVlmnlVboM06YBu21KUgec6QOniE2Z +z0g== 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=PSbgkCKZQPdD8sfvuoTEjWPCczgrpMjxTvkVlTpA2RY=; b=Uxq+1tt0zhBLX/UN2gcDs4yRUJF1M+H7wzw8qXQW6yE4Rsr4r/o7aES7pNWTe/Bepg MVstPIQJ5ohorcCVTztrxK94dJ4la18MaDv4iWt8yA4bX5z0s+W/mUDQVlzc1GfFcIBq bxfRiKa6uQXySHs/l/N9xyuUulJoeqj3EWMd+l6odFsLqAoW5t4R04lNLinx8P6o6ULj TW0LUZJ38gycvN7b6Ml7tVbp+j2bGL4cgcb1bnXNp3lQ/b/JPkJifSuoU+uTNu+6y8hd fmTUBJoHJp0QJJvSF6N1gmQp114thK970Axn7gvNmQ+EJ4h0AlDlPBdOnES65xdT6/0r e2qQ== X-Gm-Message-State: AHPjjUhXBvCQspvyEJDD3lPsfHODsrY0A0dVDsa+oqUFiG48gYs5JY52 PfFTFW5bHfyuboDBHDc= X-Google-Smtp-Source: AOwi7QBQ7NAJdhulLh7PTe051ExEBm1dG5ZnOE/e7PNymfT72aCXjd6PWYmhtmDP2e0rZGZ2F/x6Ng== X-Received: by 10.200.15.13 with SMTP id e13mr28200570qtk.295.1505340349443; Wed, 13 Sep 2017 15:05:49 -0700 (PDT) Received: from localhost ([2601:184:4780:aac0:25f8:dd96:a084:785a]) by smtp.gmail.com with ESMTPSA id e64sm9883642qkc.15.2017.09.13.15.05.47 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 13 Sep 2017 15:05:48 -0700 (PDT) From: Rob Clark To: U-Boot Mailing List Date: Wed, 13 Sep 2017 18:05:23 -0400 Message-Id: <20170913220546.19560-1-robdclark@gmail.com> X-Mailer: git-send-email 2.13.5 Cc: Heinrich Schuchardt Subject: [U-Boot] [PATCH v3 00/21] efi_loader: enough UEFI for standard distro boot X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" This patchset fleshes out EFI_LOADER enough to support booting an upstream \EFI\BOOT\bootaa64.efi (which then loads fallback.efi and then eventually the per-distro shim.efi which loads the per-distro grubaa64.efi) without resorting to hacks to hard-code u-boot to load a particular distro's grub, or other hacks like setting up the distro installation as live-media. Background: with a normal UEFI implementation, the boot process is: a) firmware (u-boot) looks at BootOrder and the BootXXXX variables to try to determine what to boot. b) the firmware will look at the BootXXXX variables (which contain an EFI_LOAD_OPTION "struct" in order specified by BootOrder, and will boot the first bootable option. c) The EFI_LOAD_OPTION specifies a device-path which identifies the device and file path of the .efi payload to exectute. This is implemented with the 'bootefi bootmgr' command. If there are no bootable options the firmware falls back to loading \EFI\BOOT\bootaa64.efi (exact name varies depending on arch), which for distro's using fallback/shim (which should include most modern linux distros) then loads fallback.efi which uses the EFI_SIMPLE_FILE_SYSTEM_PROTCOL and EFI_FILE_PROTOCOL to search for any \EFI\*\boot.csv, and will then set BootOrder and BootXXXX EFI variables accordingly so that on next boot fallback.efi is not necessary. The last 5 patches are a bit unrelated, just pulling forward some of the patches I have from the next patchset, to get Shell.efi and SCT working. v2: updates for review comments v3: rebase on latest master and additional comments Peter Jones (2): part: extract MBR signature from partitions efi: add some more device path structures Rob Clark (19): part: move efi_guid_t efi: add some missing __packed efi_loader: add device-path utils efi_loader: drop redundant efi_device_path_protocol efi_loader: flesh out device-path to text efi_loader: use proper device-paths for partitions efi_loader: use proper device-paths for net efi_loader: refactor boot device and loaded_image handling efi_loader: add file/filesys support efi_loader: support load_image() from a file-path efi_loader: make pool allocations cacheline aligned efi_loader: efi variable support efi_loader: add bootmgr efi_loader: file_path should be variable length efi_loader: set loaded image code/data type properly efi_loader: print GUIDs efi_loader: split out escape sequence based size query efi_loader: Correctly figure out size for vidconsole efi_loader: Some console improvements for vidconsole cmd/bootefi.c | 249 ++++++-------- disk/part_dos.c | 12 +- disk/part_efi.c | 20 ++ include/blk.h | 18 + include/config_distro_bootcmd.h | 5 + include/efi.h | 25 ++ include/efi_api.h | 162 ++++++++- include/efi_loader.h | 62 +++- include/part.h | 3 +- include/part_efi.h | 4 - include/pe.h | 6 + lib/efi_loader/Makefile | 3 +- lib/efi_loader/efi_bootmgr.c | 180 ++++++++++ lib/efi_loader/efi_boottime.c | 162 +++++++-- lib/efi_loader/efi_console.c | 123 ++++--- lib/efi_loader/efi_device_path.c | 563 +++++++++++++++++++++++++++++++ lib/efi_loader/efi_device_path_to_text.c | 242 +++++++++---- lib/efi_loader/efi_disk.c | 86 +++-- lib/efi_loader/efi_file.c | 560 ++++++++++++++++++++++++++++++ lib/efi_loader/efi_image_loader.c | 26 ++ lib/efi_loader/efi_memory.c | 5 +- lib/efi_loader/efi_net.c | 24 +- lib/efi_loader/efi_runtime.c | 17 +- lib/efi_loader/efi_variable.c | 335 ++++++++++++++++++ 24 files changed, 2538 insertions(+), 354 deletions(-) create mode 100644 lib/efi_loader/efi_bootmgr.c create mode 100644 lib/efi_loader/efi_device_path.c create mode 100644 lib/efi_loader/efi_file.c create mode 100644 lib/efi_loader/efi_variable.c