From patchwork Thu Oct 26 05:30:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 738318 Delivered-To: patch@linaro.org Received: by 2002:adf:f842:0:b0:32d:baff:b0ca with SMTP id d2csp638343wrq; Wed, 25 Oct 2023 22:31:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEs8PHOxSD9KSTdCjeqClDgYuI6Qpkg0S30j4Dti2tUvuHoZ7vhJciODl+0hpTSIL4n7ebJ X-Received: by 2002:a05:600c:4fd6:b0:404:7670:90b8 with SMTP id o22-20020a05600c4fd600b00404767090b8mr14563537wmq.27.1698298295118; Wed, 25 Oct 2023 22:31:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698298295; cv=none; d=google.com; s=arc-20160816; b=gtXMAfQWRNmLNaqzQerPYPrvijZpt66IzRcmb2yvqQ97hNMVQhXQw76Q5RwCZY8St8 GSIitwFmnObOhEYSKK9F8cFhpFkdf4k5+IarKBknn67HhcXDqeZKzFwbnDkjLXav18UF dFZOs/nCgqa8yCRjtjUgIW6S2O8oiQnm/ZH1KhLP9YcLJ14WDgqtpBnYhHXOSDXAdIfJ oFjnAHXknA2+VuzwyP8JbgMGqZ3PQZ3L9pzJomgZ30CzA6onCDrwV6cs7/ogBjlhXW0+ XrEVYVk3O6XhpaTcDtW+uZWrj13AuDcq34Gf63smyyNz7DEi0QbfGSxRGRuAylosXlhh V6zg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=AiPfxibcuWyHJTACSDEMJICwhgTKdTU17rCnTuYhN8c=; fh=RsKNQde3hXRhkFNkXZDJxhxJUE2DI5qQDMHikPj4pmY=; b=0ThXNuwuXZwp7xPcZXnrdDV28x1PEn1enYv0tEYGCvTmsOd3nU6gtK9PuKQJxve6Ve E6aCfwMsG6yp1qLz6c3cSUSBiI4dV6Yzlj0VomLPZDfcx7J0YQfCBUmpTZ6F8FEOK9nR Pqx9MkDN1XxmkShV3VCl2hOZlxWzGTyiglOYS2sc3PEO+ADnS2TmJLXVUEQd8Jl2ENIv 9v4IkyEIXk4L3VS9VU+4w95I4o1Qy3DpRscinmBqb4YdXBW63zRuglCSeiiV/DqQ/SQM euGul++kqPIjxNoUeoXTU7WSsKZemJnji93g8DUV3qmcnxB0RHSArEFF6QYVHHH4Jfrh XCDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GBx+fjS1; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id d7-20020a05600c34c700b0040476b3f012si1098633wmq.72.2023.10.25.22.31.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 22:31:35 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GBx+fjS1; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8C1D587AF1; Thu, 26 Oct 2023 07:31:26 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="GBx+fjS1"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 43B6F87B00; Thu, 26 Oct 2023 07:31:25 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pg1-x531.google.com (mail-pg1-x531.google.com [IPv6:2607:f8b0:4864:20::531]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id B8D3687AEC for ; Thu, 26 Oct 2023 07:31:22 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pg1-x531.google.com with SMTP id 41be03b00d2f7-55b5a37acb6so58836a12.0 for ; Wed, 25 Oct 2023 22:31:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698298281; x=1698903081; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=AiPfxibcuWyHJTACSDEMJICwhgTKdTU17rCnTuYhN8c=; b=GBx+fjS18VrkDHW5ljsNR/yMGrLPUIanqn+jl6I0/KbnrAK6sACeodoBVnQePePRkP qVTYKnGlSEI40NavXW/ZQqQBE+Lc9zUZwHmov4r75XCdKE9w9CYRnMqFNvn8dH+sXqIC fh8kvzpautmoNBePojGqun0a34Lwi9h15a7mPM4y/pYKPKSYm3xFp9/md4CsbuqgxutL XcO/WF3GupRY4yVNZSyrsdZ0ix69xYvbbbaD1mxDXcTGTBzvpQnOzKGu9u6WvucUANJn 8WlKOz30PXnTg/GzkEyb7tMk+qF2i7drg2DTlumgO26OTv4Wk9eVj09H2ZAh+4PcXEIJ LzGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698298281; x=1698903081; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AiPfxibcuWyHJTACSDEMJICwhgTKdTU17rCnTuYhN8c=; b=fbcLoN0CvVKKaEfWKpOCI9k/6toFfbpMPxlcgJYLw8jCNCelms9jIgGOfX5bW+0fS7 /aUhMdkCaiFw3MQiy6MRUnmU1VAgCxHUIoDi73yLbXPJDQQr/Wx2jBe8BMmJelL1JOtN qETl9JtuViw3lx8Gy+n1399HR24TG40JAK993Ca9jaASEMzdOtJwBtnPsaxnl6XY1v2B 156DvfTn71P7q7L3/TbcAFUjWVWTnYu70nXgaBZHg4PgtIlaE+HpncBRSO4w4u4wNTTa jFWS24XtrTGdcvpOdMA4CLoPQzb8A7oJ8eaSLZ+7Vg7x/vGL+PptB2MWoN6fW3n4cERM ZDQA== X-Gm-Message-State: AOJu0YwYcQCrF06SwlTL8hT8K5n6GsLyTQUsHYhrlU6VpRq8qGt4yG7+ LW90FLc4adOE3AQQL/ipGMgCrg== X-Received: by 2002:a05:6a00:3a0a:b0:690:d0d4:6fb0 with SMTP id fj10-20020a056a003a0a00b00690d0d46fb0mr17678465pfb.3.1698298280762; Wed, 25 Oct 2023 22:31:20 -0700 (PDT) Received: from octopus.. ([2400:4050:c3e1:100:bca9:3af7:89e9:80b7]) by smtp.gmail.com with ESMTPSA id fa13-20020a056a002d0d00b006c06804cd39sm440715pfb.153.2023.10.25.22.31.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 22:31:20 -0700 (PDT) From: AKASHI Takahiro To: trini@konsulko.com, sjg@chromium.org, xypron.glpk@gmx.de, ilias.apalodimas@linaro.org Cc: jbx6244@gmail.com, u-boot@lists.denx.de, AKASHI Takahiro Subject: [RFC 01/13] cmd: bootefi: unfold do_bootefi_image() Date: Thu, 26 Oct 2023 14:30:40 +0900 Message-Id: <20231026053052.622453-2-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231026053052.622453-1-takahiro.akashi@linaro.org> References: <20231026053052.622453-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Unfold do_bootefi_image() into do_bootefi() for the sake of the succeeding refactor work. Signed-off-by: AKASHI Takahiro --- cmd/bootefi.c | 101 ++++++++++++++++++-------------------------------- 1 file changed, 37 insertions(+), 64 deletions(-) diff --git a/cmd/bootefi.c b/cmd/bootefi.c index 20e5c94a33a4..1b28bf5a318d 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -425,58 +425,6 @@ static int do_efibootmgr(void) return CMD_RET_SUCCESS; } -/** - * do_bootefi_image() - execute EFI binary - * - * Set up memory image for the binary to be loaded, prepare device path, and - * then call do_bootefi_exec() to execute it. - * - * @image_opt: string with image start address - * @size_opt: string with image size or NULL - * Return: status code - */ -static int do_bootefi_image(const char *image_opt, const char *size_opt) -{ - void *image_buf; - unsigned long addr, size; - efi_status_t ret; - -#ifdef CONFIG_CMD_BOOTEFI_HELLO - if (!strcmp(image_opt, "hello")) { - image_buf = __efi_helloworld_begin; - size = __efi_helloworld_end - __efi_helloworld_begin; - efi_clear_bootdev(); - } else -#endif - { - addr = strtoul(image_opt, NULL, 16); - /* Check that a numeric value was passed */ - if (!addr) - return CMD_RET_USAGE; - image_buf = map_sysmem(addr, 0); - - if (size_opt) { - size = strtoul(size_opt, NULL, 16); - if (!size) - return CMD_RET_USAGE; - efi_clear_bootdev(); - } else { - if (image_buf != image_addr) { - log_err("No UEFI binary known at %s\n", - image_opt); - return CMD_RET_FAILURE; - } - size = image_size; - } - } - ret = efi_run_image(image_buf, size); - - if (ret != EFI_SUCCESS) - return CMD_RET_FAILURE; - - return CMD_RET_SUCCESS; -} - /** * efi_run_image() - run loaded UEFI image * @@ -648,8 +596,9 @@ static int do_bootefi(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { efi_status_t ret; - char *img_addr, *img_size, *str_copy, *pos; - void *fdt; + char *p; + void *fdt, *image_buf; + unsigned long addr, size; if (argc < 2) return CMD_RET_USAGE; @@ -684,18 +633,42 @@ static int do_bootefi(struct cmd_tbl *cmdtp, int flag, int argc, if (!strcmp(argv[1], "selftest")) return do_efi_selftest(); #endif - str_copy = strdup(argv[1]); - if (!str_copy) { - log_err("Out of memory\n"); - return CMD_RET_FAILURE; + +#ifdef CONFIG_CMD_BOOTEFI_HELLO + if (!strcmp(argv[1], "hello")) { + image_buf = __efi_helloworld_begin; + size = __efi_helloworld_end - __efi_helloworld_begin; + efi_clear_bootdev(); + } else +#endif + { + addr = strtoul(argv[1], NULL, 16); + /* Check that a numeric value was passed */ + if (!addr) + return CMD_RET_USAGE; + image_buf = map_sysmem(addr, 0); + + p = strchr(argv[1], ':'); + if (p) { + size = strtoul(++p, NULL, 16); + if (!size) + return CMD_RET_USAGE; + efi_clear_bootdev(); + } else { + if (image_buf != image_addr) { + log_err("No UEFI binary known at %s\n", + argv[1]); + return CMD_RET_FAILURE; + } + size = image_size; + } } - pos = str_copy; - img_addr = strsep(&pos, ":"); - img_size = strsep(&pos, ":"); - ret = do_bootefi_image(img_addr, img_size); - free(str_copy); + ret = efi_run_image(image_buf, size); - return ret; + if (ret != EFI_SUCCESS) + return CMD_RET_FAILURE; + + return CMD_RET_SUCCESS; } U_BOOT_LONGHELP(bootefi, From patchwork Thu Oct 26 05:30:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 738319 Delivered-To: patch@linaro.org Received: by 2002:adf:f842:0:b0:32d:baff:b0ca with SMTP id d2csp638402wrq; Wed, 25 Oct 2023 22:31:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF2zVU0YBYE9NN9cuo+p5F0CCdtoAvfVIzfgebTIRfCc4jKX5kcDc8x/JyVR0UwEq2skNzl X-Received: by 2002:a05:600c:4b96:b0:404:6ed9:98d1 with SMTP id e22-20020a05600c4b9600b004046ed998d1mr13117244wmp.41.1698298305863; Wed, 25 Oct 2023 22:31:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698298305; cv=none; d=google.com; s=arc-20160816; b=GTK3r7WtY7BCEWqjmHhYb5pYRo2mPTumLbEhh+6gUyTIlP6ZMqVgBhXnSjW6lWqk5q NCYaEHmCAN+dtPlRHZ2qF2i404MfuYfx6eUor+ptg2qqgLyEdWFLSSp3csbDWubLLBbj EBCsFROBMmkQ+JKEKbPYRtlN/0zd2EGg9EFPh1TEKNd9LJpgekhwLA3WCaaf8lde3JPS ZUdJr4rQ1UiaOEVVwpQ5dQY1fck9fy9vs82YmeWmpTVAcszuD+F9/u+mJclihoZ5IBtl xhAKnF1NkkvwrRtWbJBd261k7LG/Qc0RAjNg8eOPvz5SOGFhyJliZcoUU8Fdex3iVwie B7Yw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=+czYVJWy61Hd8zv5Ht+HcoSUNO1gaLWG95az3su/V98=; fh=RsKNQde3hXRhkFNkXZDJxhxJUE2DI5qQDMHikPj4pmY=; b=VRJLDhqALJo+pRsg7hmYBvV7TtDCGumVb+/5DDsajmmPhlPPsXmDEYXEr1uxi81TRQ yvhUoUxCZt/Scjf+S2hr8rS4F8217+ZpqqpvPncchghtaFYrkiY+aDdRi0iEVJD/9JaC 9iEgZfFjLWKl14fJcDyelvfube+X3DovnHXc4Goee9cU9buEELQVfwBgNMrita9sthVM mZJQGsi83JabUWC69h1GCi4rzqbK7VuT/IGesgJ2RCguWDKGq/elrBUx9MGY3GDOaW7k OY1cDn1+MAKYDm16vr+jFvJ8ZFomToJne6tL8Uh2r1M6972cd6hrZDAXkwYeQz3xsTg5 j2wg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eccwVnTu; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id fc16-20020a05600c525000b00406608a80aasi1091488wmb.150.2023.10.25.22.31.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 22:31:45 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eccwVnTu; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2A1A987AEE; Thu, 26 Oct 2023 07:31:32 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="eccwVnTu"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6A0FE87AF6; Thu, 26 Oct 2023 07:31:27 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 0CAE18755E for ; Thu, 26 Oct 2023 07:31:25 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-6bbfb8f7ac4so121612b3a.0 for ; Wed, 25 Oct 2023 22:31:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698298283; x=1698903083; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+czYVJWy61Hd8zv5Ht+HcoSUNO1gaLWG95az3su/V98=; b=eccwVnTu+sEmmlG23e71YEG8W9qEgJSbgE0rKeidslWk6+jT8EZ1FWgRQjjfTE3H3b lh+PZzBUAb6SJ5unIxSHlKFo/6DLneWxjfkrGhOlncFKeJyGi+seG6UMQDv8eFCX1raL z21RlgXhAvAQ/VsA1Hl9XpXn6zy1ES5P/5pdXsuDZdSuVx7ptURR0VQLMLqxxQl9HPVv eJblnBcMFBTypmYkDcwSTS3ya6TDoatnLxekQRA4TLp0O+My/971mQ+RhJwuN62Z0Hd9 pxkyD97GxpXakAdMxtXIH7JqEAJsWKIS3bG+Ai2kJswiosUJPMYR6ltbMOpohtfk4HCZ 4a3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698298283; x=1698903083; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+czYVJWy61Hd8zv5Ht+HcoSUNO1gaLWG95az3su/V98=; b=j3NkZr6ny4y+fhCt2UmEoRKbPTsobOYcGZHg3JbOiHqMDY5qpU8REG5iqgYCsDJbDu JaYWYNnjwhpelX884ZJoDNJU8vvxs03OI47/j7hlsBF0SR28CR79T+M0Q3PkMHjMl70S BmoXoB2rtw+2USwXjRqlea7CJ0CMlXBTxYXcLQOIRVsLFZOgAIx+PewyBqtuZHKJBZVQ nmi/zCqGZph+ZJ3R3mNBStBkQk625CbGbWfeqxiELOBaDBr20bRDu42EAeRJfMEPhvQB kPvqDJ4daV1TaKU8RXrr5HL/u67W1OVisHJGDoB87Wis/O4ErA6hkFgLZhNVjz+KTyBN 5zPQ== X-Gm-Message-State: AOJu0YxIGzk3bJlqvzjp24twN6o+AlOewGlC69rJcZmlHrcg4Ka/Ca10 6Cwl4XWzM5luTXZugNllvsRDOA== X-Received: by 2002:a05:6a00:2c8e:b0:6bc:67ca:671d with SMTP id ef14-20020a056a002c8e00b006bc67ca671dmr16997858pfb.1.1698298283329; Wed, 25 Oct 2023 22:31:23 -0700 (PDT) Received: from octopus.. ([2400:4050:c3e1:100:bca9:3af7:89e9:80b7]) by smtp.gmail.com with ESMTPSA id fa13-20020a056a002d0d00b006c06804cd39sm440715pfb.153.2023.10.25.22.31.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 22:31:23 -0700 (PDT) From: AKASHI Takahiro To: trini@konsulko.com, sjg@chromium.org, xypron.glpk@gmx.de, ilias.apalodimas@linaro.org Cc: jbx6244@gmail.com, u-boot@lists.denx.de, AKASHI Takahiro Subject: [RFC 02/13] cmd: bootefi: re-organize do_bootefi_image() Date: Thu, 26 Oct 2023 14:30:41 +0900 Message-Id: <20231026053052.622453-3-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231026053052.622453-1-takahiro.akashi@linaro.org> References: <20231026053052.622453-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Decompose and re-organize do_bootefi_image() into three parts for the succeeding refactor work. Signed-off-by: AKASHI Takahiro --- cmd/Kconfig | 15 ++++++-- cmd/bootefi.c | 82 ++++++++++++++++++++++++++++++-------------- include/efi_loader.h | 2 -- 3 files changed, 69 insertions(+), 30 deletions(-) diff --git a/cmd/Kconfig b/cmd/Kconfig index 0eb739203ade..825a41d68aad 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -363,9 +363,19 @@ config CMD_BOOTEFI help Boot an EFI image from memory. +if CMD_BOOTEFI +config CMD_BOOTEFI_BINARY + bool "Allow booting an EFI binary directly" + depends on BOOTEFI_BOOTMGR + default y + help + Select this option to enable direct execution of binary at 'bootefi'. + This subcommand will allow you to load the UEFI binary using + other U-Boot commands or external methods and then run it. + config CMD_BOOTEFI_BOOTMGR bool "UEFI Boot Manager command" - depends on BOOTEFI_BOOTMGR && CMD_BOOTEFI + depends on BOOTEFI_BOOTMGR default y help Select this option to enable the 'bootmgr' subcommand of 'bootefi'. @@ -374,7 +384,7 @@ config CMD_BOOTEFI_BOOTMGR config CMD_BOOTEFI_HELLO_COMPILE bool "Compile a standard EFI hello world binary for testing" - depends on CMD_BOOTEFI && !CPU_V7M + depends on !CPU_V7M default y help This compiles a standard EFI hello world application with U-Boot so @@ -396,6 +406,7 @@ config CMD_BOOTEFI_HELLO up EFI support on a new architecture. source lib/efi_selftest/Kconfig +endif config CMD_BOOTMENU bool "bootmenu" diff --git a/cmd/bootefi.c b/cmd/bootefi.c index 1b28bf5a318d..ae00bba3b4f0 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -491,7 +491,6 @@ out: return (ret != EFI_SUCCESS) ? ret : ret2; } -#ifdef CONFIG_CMD_BOOTEFI_SELFTEST static efi_status_t bootefi_run_prepare(const char *load_options_path, struct efi_device_path *device_path, struct efi_device_path *image_path, @@ -581,7 +580,6 @@ static int do_efi_selftest(void) return ret != EFI_SUCCESS; } -#endif /* CONFIG_CMD_BOOTEFI_SELFTEST */ /** * do_bootefi() - execute `bootefi` command @@ -603,14 +601,6 @@ static int do_bootefi(struct cmd_tbl *cmdtp, int flag, int argc, if (argc < 2) return CMD_RET_USAGE; - /* Initialize EFI drivers */ - ret = efi_init_obj_list(); - if (ret != EFI_SUCCESS) { - log_err("Error: Cannot initialize UEFI sub-system, r = %lu\n", - ret & ~EFI_ERROR_MASK); - return CMD_RET_FAILURE; - } - if (argc > 2) { uintptr_t fdt_addr; @@ -619,29 +609,54 @@ static int do_bootefi(struct cmd_tbl *cmdtp, int flag, int argc, } else { fdt = EFI_FDT_USE_INTERNAL; } - ret = efi_install_fdt(fdt); - if (ret == EFI_INVALID_PARAMETER) - return CMD_RET_USAGE; - else if (ret != EFI_SUCCESS) - return CMD_RET_FAILURE; - if (IS_ENABLED(CONFIG_CMD_BOOTEFI_BOOTMGR)) { - if (!strcmp(argv[1], "bootmgr")) - return do_efibootmgr(); + if (IS_ENABLED(CONFIG_CMD_BOOTEFI_BOOTMGR) && + !strcmp(argv[1], "bootmgr")) { + /* Initialize EFI drivers */ + ret = efi_init_obj_list(); + if (ret != EFI_SUCCESS) { + log_err("Error: Cannot initialize UEFI sub-system, r = %lu\n", + ret & ~EFI_ERROR_MASK); + return CMD_RET_FAILURE; + } + + ret = efi_install_fdt(fdt); + if (ret == EFI_INVALID_PARAMETER) + return CMD_RET_USAGE; + else if (ret != EFI_SUCCESS) + return CMD_RET_FAILURE; + + return do_efibootmgr(); } -#ifdef CONFIG_CMD_BOOTEFI_SELFTEST - if (!strcmp(argv[1], "selftest")) + + if (IS_ENABLED(CONFIG_CMD_BOOTEFI_SELFTEST) && + !strcmp(argv[1], "selftest")) { + /* Initialize EFI drivers */ + ret = efi_init_obj_list(); + if (ret != EFI_SUCCESS) { + log_err("Error: Cannot initialize UEFI sub-system, r = %lu\n", + ret & ~EFI_ERROR_MASK); + return CMD_RET_FAILURE; + } + + ret = efi_install_fdt(fdt); + if (ret == EFI_INVALID_PARAMETER) + return CMD_RET_USAGE; + else if (ret != EFI_SUCCESS) + return CMD_RET_FAILURE; + return do_efi_selftest(); -#endif + } -#ifdef CONFIG_CMD_BOOTEFI_HELLO - if (!strcmp(argv[1], "hello")) { + if (!IS_ENABLED(CONFIG_CMD_BOOTEFI_BINARY)) + return CMD_RET_SUCCESS; + + if (IS_ENABLED(CONFIG_CMD_BOOTEFI_HELLO) && + !strcmp(argv[1], "hello")) { image_buf = __efi_helloworld_begin; size = __efi_helloworld_end - __efi_helloworld_begin; efi_clear_bootdev(); - } else -#endif - { + } else { addr = strtoul(argv[1], NULL, 16); /* Check that a numeric value was passed */ if (!addr) @@ -663,6 +678,21 @@ static int do_bootefi(struct cmd_tbl *cmdtp, int flag, int argc, size = image_size; } } + + /* Initialize EFI drivers */ + ret = efi_init_obj_list(); + if (ret != EFI_SUCCESS) { + log_err("Error: Cannot initialize UEFI sub-system, r = %lu\n", + ret & ~EFI_ERROR_MASK); + return CMD_RET_FAILURE; + } + + ret = efi_install_fdt(fdt); + if (ret == EFI_INVALID_PARAMETER) + return CMD_RET_USAGE; + else if (ret != EFI_SUCCESS) + return CMD_RET_FAILURE; + ret = efi_run_image(image_buf, size); if (ret != EFI_SUCCESS) diff --git a/include/efi_loader.h b/include/efi_loader.h index e24410505f40..48d4999e56a9 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -878,14 +878,12 @@ efi_status_t __efi_runtime EFIAPI efi_get_time( efi_status_t __efi_runtime EFIAPI efi_set_time(struct efi_time *time); -#ifdef CONFIG_CMD_BOOTEFI_SELFTEST /* * Entry point for the tests of the EFI API. * It is called by 'bootefi selftest' */ efi_status_t EFIAPI efi_selftest(efi_handle_t image_handle, struct efi_system_table *systab); -#endif efi_status_t EFIAPI efi_get_variable(u16 *variable_name, const efi_guid_t *vendor, u32 *attributes, From patchwork Thu Oct 26 05:30:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 738320 Delivered-To: patch@linaro.org Received: by 2002:adf:f842:0:b0:32d:baff:b0ca with SMTP id d2csp638451wrq; Wed, 25 Oct 2023 22:31:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH0a/lG8Uu+LdmuB3MQVBDedJX+fHtH9dwLgO4zo21/TTCQr9UUumW9XE1cOC5AWNUHc4GK X-Received: by 2002:a5d:67d2:0:b0:32d:90e6:c477 with SMTP id n18-20020a5d67d2000000b0032d90e6c477mr6569147wrw.26.1698298316606; Wed, 25 Oct 2023 22:31:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698298316; cv=none; d=google.com; s=arc-20160816; b=e3kAX58WLQlAv5MkHgFwXHp7YCT4qFZjgPVp+1r4PGQNk73wlt8HGfkyL4GKWUjcVI ZLqWq8lTfoTYiPp0Z/mQ1m6/YgPZCH5nxrGxw8XD5GQNe4nlozvD0qYrUZ1K4bx843dF aipLmkkpyb7IiCw7o84kdjGONbsQvAgKYojXkWZK4tFrZ33+TpF/S9iG/rZ1jIy7+kBx UjimntkAFh2JY5LoNBZPcIhlaI84z7nUdS6yYc1QObRqgh5dH0P2FdqOpp4VwgFeU1Ci saKgHa3utF3vZUTp3J+VApXp/zDScF320SPlUOIRRLbh4vQPX2zNSsMHwjqmN9k2zXLa SKwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=cJUUfPbIuNsqhILYNiWpep1gG/D41daasmggqowkL8Y=; fh=RsKNQde3hXRhkFNkXZDJxhxJUE2DI5qQDMHikPj4pmY=; b=kq151+az/MFDqfl4J/WmYreyth8JUMzN5zCzYCBkXGtsgAmNKam5RYe3HpoZJrv63p anEY6ZKTNdvM1hmeqWHIcgw2v1szlqFR2bus3I1aLcx+wPSq4x/N7y1jM/qddNU+UIx1 IAO1YiF0tavLu9UgvRdPmpQVdxwDjd0LysTbTqAKggJlk+N9Fn+MaiSE3gcTkMSGfjqT qsgOtGFs4oDelwVJVAuqdUhO+dDiD8uprjg6afzQCJ8QEM5/x6+0VlcKnnDb3QWgSrh4 iDNaPkz9WxiaUsB38KETEynQqC4OrwH3J4vUVl5JshkV1NH+81Gnx+My3mPb6a+239ik +v5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=T5y4xP9j; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id u2-20020a5d4682000000b00327174cf8b3si8536279wrq.311.2023.10.25.22.31.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 22:31:56 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=T5y4xP9j; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id AF05E87B1B; Thu, 26 Oct 2023 07:31:37 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="T5y4xP9j"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C5A0787B0F; Thu, 26 Oct 2023 07:31:36 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pg1-x530.google.com (mail-pg1-x530.google.com [IPv6:2607:f8b0:4864:20::530]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 9EAF88755E for ; Thu, 26 Oct 2023 07:31:27 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pg1-x530.google.com with SMTP id 41be03b00d2f7-51f64817809so54527a12.1 for ; Wed, 25 Oct 2023 22:31:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698298286; x=1698903086; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=cJUUfPbIuNsqhILYNiWpep1gG/D41daasmggqowkL8Y=; b=T5y4xP9jE35M6zl5gBWUF5V5it0i43SkrXB7VgTVZUJObmjs2YF1fcdL1T4LwWNtVm AEEekA+XdMlYVsDmPIYdJBlQi5X8U1nGsrKvfQ0QkZoLp52IB+S7EV0LP3M3HdWJm2Ir G6sRys4CU1fTtnYcrFggWVFRhbDpFb4siKHlk+LaxMKCf0S7WfpKQBZt4SUB2kj9PPF1 TzBAOn5iwI8hqlGSCIJgI6UcJHrqejt8oen76XB8SU/5KqoBjxg5zAlGZYpmuQklOshg prj5z09vXTB1IClHtKqf3w3Htf5G0Tb72p1jhQobVFQP8MC9LgVkMnvMJ8GOjABHK6K8 lU4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698298286; x=1698903086; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cJUUfPbIuNsqhILYNiWpep1gG/D41daasmggqowkL8Y=; b=wRdmelLankFAeVsBEYaQuNM/Jyci8xNvv2524W2bIMqdVHac/CRLmO45hLB2Mrstqx 3ysnD2myoBS3eJNtmzm/PijG6g1cmXQKawJMNM3Ju6ayOTDOFzyduNn8l13VZS9Wmb/4 cfhDCNTQkON5aV1Kpvvmotf+XRMoPYbKxA/8dmofAzeyDciQARETQR7rxhUFdIiO2M4Y zjOL37yfw4IRh0Um4Tead+BRhQ5JWGmh48WlslOtAMMUIRPU1zdA5cpn6/ctQYcAocCZ MaUKnN6VQARGa4VxpdRZJowH5kmE9d52Af0SPcXHixLcjkmTkumjWV9EuYONhf0mimUl 107w== X-Gm-Message-State: AOJu0YyotXgS+cvQTv4VB2DY0cB4MHGb+d653dXudJ4sEV+6Upy3gWSk PaKpbz82IImt8dF2bqU9ZGYmkQ== X-Received: by 2002:a05:6a00:3a0a:b0:690:d0d4:6fb0 with SMTP id fj10-20020a056a003a0a00b00690d0d46fb0mr17678650pfb.3.1698298285885; Wed, 25 Oct 2023 22:31:25 -0700 (PDT) Received: from octopus.. ([2400:4050:c3e1:100:bca9:3af7:89e9:80b7]) by smtp.gmail.com with ESMTPSA id fa13-20020a056a002d0d00b006c06804cd39sm440715pfb.153.2023.10.25.22.31.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 22:31:25 -0700 (PDT) From: AKASHI Takahiro To: trini@konsulko.com, sjg@chromium.org, xypron.glpk@gmx.de, ilias.apalodimas@linaro.org Cc: jbx6244@gmail.com, u-boot@lists.denx.de, AKASHI Takahiro Subject: [RFC 03/13] cmd: bootefi: carve out EFI boot manager interface Date: Thu, 26 Oct 2023 14:30:42 +0900 Message-Id: <20231026053052.622453-4-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231026053052.622453-1-takahiro.akashi@linaro.org> References: <20231026053052.622453-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Carve EFI boot manager related code out of do_bootefi_image(). Signed-off-by: AKASHI Takahiro --- cmd/bootefi.c | 43 ++++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/cmd/bootefi.c b/cmd/bootefi.c index ae00bba3b4f0..899ed90f6817 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -401,28 +401,40 @@ out: } /** - * do_efibootmgr() - execute EFI boot manager + * efi_bootmgr_run() - execute EFI boot manager + * fdt: Flat device tree + * + * Invoke EFI boot manager and execute a binary depending on + * boot options. If @fdt is not NULL, it will be passed to + * the executed binary. * * Return: status code */ -static int do_efibootmgr(void) +static efi_status_t efi_bootmgr_run(void *fdt) { efi_handle_t handle; - efi_status_t ret; void *load_options; + efi_status_t ret; - ret = efi_bootmgr_load(&handle, &load_options); + /* Initialize EFI drivers */ + ret = efi_init_obj_list(); if (ret != EFI_SUCCESS) { - log_notice("EFI boot manager: Cannot load any image\n"); + log_err("Error: Cannot initialize UEFI sub-system, r = %lu\n", + ret & ~EFI_ERROR_MASK); return CMD_RET_FAILURE; } - ret = do_bootefi_exec(handle, load_options); - + ret = efi_install_fdt(fdt); if (ret != EFI_SUCCESS) - return CMD_RET_FAILURE; + return ret; - return CMD_RET_SUCCESS; + ret = efi_bootmgr_load(&handle, &load_options); + if (ret != EFI_SUCCESS) { + log_notice("EFI boot manager: Cannot load any image\n"); + return ret; + } + + return do_bootefi_exec(handle, load_options); } /** @@ -612,21 +624,14 @@ static int do_bootefi(struct cmd_tbl *cmdtp, int flag, int argc, if (IS_ENABLED(CONFIG_CMD_BOOTEFI_BOOTMGR) && !strcmp(argv[1], "bootmgr")) { - /* Initialize EFI drivers */ - ret = efi_init_obj_list(); - if (ret != EFI_SUCCESS) { - log_err("Error: Cannot initialize UEFI sub-system, r = %lu\n", - ret & ~EFI_ERROR_MASK); - return CMD_RET_FAILURE; - } + ret = efi_bootmgr_run(fdt); - ret = efi_install_fdt(fdt); if (ret == EFI_INVALID_PARAMETER) return CMD_RET_USAGE; - else if (ret != EFI_SUCCESS) + else if (ret) return CMD_RET_FAILURE; - return do_efibootmgr(); + return CMD_RET_SUCCESS; } if (IS_ENABLED(CONFIG_CMD_BOOTEFI_SELFTEST) && From patchwork Thu Oct 26 05:30:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 738321 Delivered-To: patch@linaro.org Received: by 2002:adf:f842:0:b0:32d:baff:b0ca with SMTP id d2csp638511wrq; Wed, 25 Oct 2023 22:32:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEE5nQ0AZQcBy2F2+sRET0cGOKaQNO6oA1x9x6F/vlpLPNy1dJu82abothd4Z22vyIO7/q1 X-Received: by 2002:ac2:44b7:0:b0:507:9ef2:fb1c with SMTP id c23-20020ac244b7000000b005079ef2fb1cmr12166320lfm.2.1698298327818; Wed, 25 Oct 2023 22:32:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698298327; cv=none; d=google.com; s=arc-20160816; b=Fhpz6MGcGfjtIuWpuZRvedkH/jCk1Z2AvRztEx3yjFdp8Utr4KiOhQUfMcXxmuA6jZ QFXORxqjzJd2WLDbGA/rxdhwQnYJ4A1KBspJSNMooOvAlHCN/5j3xP+geVtt6hbs7mn3 PR3KKeZQD3n93SwcwIpuY6x+kL2Feny43gg7vpTCw5PFaUu/BeVV7VYibwg5Gw/x368p 8cKflbqjTQhIhaebG3q7yeERCSlT9RyOSuiB0aP1iFvvenRrA8DE5D/gMKa7GkZbxCcV FJOYSJH83mnetTd2hAVEBfgLbHxQPUDhhV9X5+8yMOXE8P6IUichzkCbc2yf+CLj9KUr 0Njw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=6+J5usD39CP5UGT3vRbfD1+bZNGQekjxYCJ+xApneyg=; fh=RsKNQde3hXRhkFNkXZDJxhxJUE2DI5qQDMHikPj4pmY=; b=YPwStv0+IhmlKoxcijT+qaunVA696tXVwbQ7QQFhRbIDBYF6ixy6cPtSl/p2Dc+oP8 mu5kj3arn+CQC2FSih41LEGis5ZozM+CfyPR48IEOxO4xuD3jFN6mUjLxv9jP3qFJk99 Mh8Bp2Zkn1dW9Go9T1QzFtRu6ofgXRYpQ7TKdWWIxL9rwdw6LzyFrSf8fJcERqH5HF8A ImStxmN+/foCuDWguW4NP/RIW/TKZMaUZW3RfrUriA/MfIn+afyoxrZk1cNJ78CyqsFB p+UDY8YPpAb1gDfa8HWmueuqdQqFTDLL0iK0bDkENpPPsI5VkClWCs9E0E2+/uA+4eYD 0QHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wNIcGpBs; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id f17-20020adfe911000000b0032dd849a3fesi8669721wrm.1076.2023.10.25.22.32.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 22:32:07 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wNIcGpBs; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 666A387B0F; Thu, 26 Oct 2023 07:31:41 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="wNIcGpBs"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C787487AED; Thu, 26 Oct 2023 07:31:37 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 22B0187AEC for ; Thu, 26 Oct 2023 07:31:30 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-6bd20c30831so109100b3a.1 for ; Wed, 25 Oct 2023 22:31:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698298288; x=1698903088; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=6+J5usD39CP5UGT3vRbfD1+bZNGQekjxYCJ+xApneyg=; b=wNIcGpBstEY5vpiZnUkqkLEA5AnnhenzbUpVczEZxnsnpQjb+A3J83Blwnml+Cvrnr s6b8dNDyUBwboN8Kg9inN6NXzGu4yf0hNmFd+FYvmdeAPDMxmbETQhePYS4LlDPOU2EZ 180vjhKiWr2Co6jL2L6+pf8da6wH5Cs3NWvhOynR1c7oM7ECeNeB9XEseo7a6TWEox1d 9QubJhDT1NqhzZm6mloo6vmFBUTWRmInYE0Db+3ImUv5P/o686nH4m1FhLW1qGo9Cs7d UOFHMFAueFYCFPTyLpAlROMBZDjfS78Q+hFGWHq710kSBGo2A+g2wB2jfIRY78UtB3oA i6Gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698298288; x=1698903088; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6+J5usD39CP5UGT3vRbfD1+bZNGQekjxYCJ+xApneyg=; b=tHo/y0h/mw2VHdcXewBnHknHXhHFNiUXCHn9vKCg1L0OJQcNztT9SRnj+VKuhrPB8S Tgyhqm3pwx5XEUEI/svBR7ceqlbxQmPLjZuGs83G8h/65XfPNzx5pJz9MU57lLCgthUC aOxa3plsNYox/IDnHoZIBO5yLGsGzfsJXm+flHvgOmaJnTjRNU8pmE7YnTQLCGgNJtSU 3HlezSaPuYnIfhgnQXPvRTkrpi0ip1SFyrJmnxpsqwXaiiupJTqRBYW6QBL8KdmjTGQ7 TVvsDkgYH1iObcN037neyA6Ej2hbhOZNe3OH6q4nS060O4cTbinTS0DGLQMgelkeDU7d GqmA== X-Gm-Message-State: AOJu0YxcpWg7b8ZwuW1Z3Ax+9rtZQVRAkblO373XFr9h1gYxFpmwuPgH B/EiEcS7QVd0ygzFKLEtAuuDuXn334vTDh40hmxI8A== X-Received: by 2002:a05:6a20:2451:b0:171:737:df97 with SMTP id t17-20020a056a20245100b001710737df97mr20631240pzc.2.1698298288338; Wed, 25 Oct 2023 22:31:28 -0700 (PDT) Received: from octopus.. ([2400:4050:c3e1:100:bca9:3af7:89e9:80b7]) by smtp.gmail.com with ESMTPSA id fa13-20020a056a002d0d00b006c06804cd39sm440715pfb.153.2023.10.25.22.31.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 22:31:27 -0700 (PDT) From: AKASHI Takahiro To: trini@konsulko.com, sjg@chromium.org, xypron.glpk@gmx.de, ilias.apalodimas@linaro.org Cc: jbx6244@gmail.com, u-boot@lists.denx.de, AKASHI Takahiro Subject: [RFC 04/13] cmd: bootefi: carve out binary execution interface Date: Thu, 26 Oct 2023 14:30:43 +0900 Message-Id: <20231026053052.622453-5-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231026053052.622453-1-takahiro.akashi@linaro.org> References: <20231026053052.622453-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Carve binary execution code out of do_bootefi_image(). Signed-off-by: AKASHI Takahiro --- cmd/bootefi.c | 46 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 14 deletions(-) diff --git a/cmd/bootefi.c b/cmd/bootefi.c index 899ed90f6817..8b0bd07f1ff8 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -503,6 +503,36 @@ out: return (ret != EFI_SUCCESS) ? ret : ret2; } +/** + * efi_binary_run() - run loaded UEFI image + * + * @image: memory address of the UEFI image + * @size: size of the UEFI image + * + * Execute an EFI binary image loaded at @image. + * @size may be zero if the binary is loaded with U-Boot load command. + * + * Return: status code + */ +static efi_status_t efi_binary_run(void *image, size_t size, void *fdt) +{ + efi_status_t ret; + + /* Initialize EFI drivers */ + ret = efi_init_obj_list(); + if (ret != EFI_SUCCESS) { + log_err("Error: Cannot initialize UEFI sub-system, r = %lu\n", + ret & ~EFI_ERROR_MASK); + return ret; + } + + ret = efi_install_fdt(fdt); + if (ret != EFI_SUCCESS) + return ret; + + return efi_run_image(image, size); +} + static efi_status_t bootefi_run_prepare(const char *load_options_path, struct efi_device_path *device_path, struct efi_device_path *image_path, @@ -684,23 +714,11 @@ static int do_bootefi(struct cmd_tbl *cmdtp, int flag, int argc, } } - /* Initialize EFI drivers */ - ret = efi_init_obj_list(); - if (ret != EFI_SUCCESS) { - log_err("Error: Cannot initialize UEFI sub-system, r = %lu\n", - ret & ~EFI_ERROR_MASK); - return CMD_RET_FAILURE; - } + ret = efi_binary_run(image_buf, size, fdt); - ret = efi_install_fdt(fdt); if (ret == EFI_INVALID_PARAMETER) return CMD_RET_USAGE; - else if (ret != EFI_SUCCESS) - return CMD_RET_FAILURE; - - ret = efi_run_image(image_buf, size); - - if (ret != EFI_SUCCESS) + else if (ret) return CMD_RET_FAILURE; return CMD_RET_SUCCESS; From patchwork Thu Oct 26 05:30:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 738324 Delivered-To: patch@linaro.org Received: by 2002:adf:f842:0:b0:32d:baff:b0ca with SMTP id d2csp638670wrq; Wed, 25 Oct 2023 22:32:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHC9XrT3Aq60N6KWb7haXgi75oyx1CNHWViyAjxpUxSEixVgIVYT8mThQ5Zcp8HCESKv+FR X-Received: by 2002:a05:600c:c6:b0:3fe:1af6:6542 with SMTP id u6-20020a05600c00c600b003fe1af66542mr13527322wmm.33.1698298360509; Wed, 25 Oct 2023 22:32:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698298360; cv=none; d=google.com; s=arc-20160816; b=vnzwUEut37vH40MxI4ERe3YJsNhkqsfgxpBi2fja7E1meXcZGYBrB56YoyzPHQK+4t 5uzsoYKOWoZEm7kiJx+MLR0784Eyi/Qwktwb1zhNpFNqPq5dSkjONzzbrq9KUAs9ISXA Iui/lm79Ee8djq/4SEHJpkG4BBAmAK4lBByuUmqUiMuL2PF5fJtYAYQyOVSUHEoz4+Wu ibytfO4REHrIR5xadKrawRkiQzqPpxip3PQ0gM3ZB05lgABlzkAf1Yg1121M3Vb//8KC 6w9WoUEiEBbH09azt+/PnQjLENBn402gmNxDxgGOxL9y2pvkzzsmAcPR0MbGY7EWH05t MQ9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=i0QWNGDWZWqFlbHbgmjf3Qu/D22Ot8nFYw5l5+ss66E=; fh=RsKNQde3hXRhkFNkXZDJxhxJUE2DI5qQDMHikPj4pmY=; b=0ii8x2qjta8P38PsTFA+oxgyaPo0DOfgHMp9ZuxELPROuN0ObY41xIXvlphZ70yDSc G9CVK9jFEKDNng2kj7KtYLlUYnbUjO7LwPowI/jcHR7WrJNrREJTykPBnhVnpqigG+1r 47NZe5TtWSXAoHZQhTm16NmyEq46yoci19CxHKM5bD6XsGKgiQoRPaVuhONuQne6wTS5 XnMEtcqermpnbvn3T1Hh30aEuaXVFf24AoONM9vpbdz/l+II10D0LIPukkyCd+ECqGaB 3Pwj/F44vcdA7P4VoNHODeg40VxpSyTNG0O7xH0lWhjjSbPOkn8g/9kuPyaApquzNboF Y9+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YlkaZ5PL; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id s5-20020a05600c45c500b004057e9e9972si1083733wmo.205.2023.10.25.22.32.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 22:32:40 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YlkaZ5PL; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 38C0287B29; Thu, 26 Oct 2023 07:31:44 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="YlkaZ5PL"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 59C6687AFF; Thu, 26 Oct 2023 07:31:40 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id ECFFD87B09 for ; Thu, 26 Oct 2023 07:31:32 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-6bcbfecf314so118416b3a.1 for ; Wed, 25 Oct 2023 22:31:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698298291; x=1698903091; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=i0QWNGDWZWqFlbHbgmjf3Qu/D22Ot8nFYw5l5+ss66E=; b=YlkaZ5PLi7NOC+m34BCvp1ebs5cJQV0dMI8pKl0M72Wyne/J6No59N/jzs50iT/jCX DojGEI7O3eqd9BxroCH5PEIwO9sA852dVNGXw3pnU5vDo+J6uonv+yfPcq6pwUqDeERR qGQYNxMJlRmoJ76St5/n7X79gS074lCWM4mHDDiRyWDQISXUVnBvPbtLgfiBYg4B0KrP ebBaFl5dPRufGHH4vROjYvXMnlcHoUVDE7AtvQGSpHpWb4rGGDKm2Fg3b+f6reNuMsCu i1jLhFCaZ3hUxWcak6OPLp2Fa7+Pt/OMYEtJ77LdrcB8XXC07lMDqRgAVjx+IioyRkmd 7uFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698298291; x=1698903091; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=i0QWNGDWZWqFlbHbgmjf3Qu/D22Ot8nFYw5l5+ss66E=; b=DU/V2uv70pyD9gVZUjGev8IT3mEhxC3sKCv0nXaobhZ/4b+jssLE0i7/HEKHoaeISY pYieIcNouQjqdn2nCfY1dI25JEYTJ4QL6Vw9O/Ep433tr8AvxpQcAWT3s9CXCwqzR4Zf msXFDsUGPSvL/fz17gM/eOY53le3T7Zr89rebBCzxUdSQw2g6XZ8S3hjDSqZADM+QGOg qNYCOnHlMTdHBj+RJ0urVr6/RKsuNd77T4Ttfzi/xtUW4PkV6XuNnWdv0Febec0H0hlw +cpD/DTtlN4JbLto0ZtFBC8PQhmN0LW5s3Pre0ApvuIUOseGXDi9LDnwKeNQWx5XVQlf FKOA== X-Gm-Message-State: AOJu0YxRX6NmWe7+S6bI/axhAKkIchsTemRw6G4H8gQyoCHdS+cucHF2 lblV4DMw71dC16GPkQEq+DJevHydotA8u8BCyK12Mw== X-Received: by 2002:a05:6a00:80ee:b0:68a:6cbe:35a7 with SMTP id ei46-20020a056a0080ee00b0068a6cbe35a7mr16957006pfb.2.1698298290977; Wed, 25 Oct 2023 22:31:30 -0700 (PDT) Received: from octopus.. ([2400:4050:c3e1:100:bca9:3af7:89e9:80b7]) by smtp.gmail.com with ESMTPSA id fa13-20020a056a002d0d00b006c06804cd39sm440715pfb.153.2023.10.25.22.31.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 22:31:30 -0700 (PDT) From: AKASHI Takahiro To: trini@konsulko.com, sjg@chromium.org, xypron.glpk@gmx.de, ilias.apalodimas@linaro.org Cc: jbx6244@gmail.com, u-boot@lists.denx.de, AKASHI Takahiro Subject: [RFC 05/13] cmd: bootefi: move library interfaces under lib/efi_loader Date: Thu, 26 Oct 2023 14:30:44 +0900 Message-Id: <20231026053052.622453-6-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231026053052.622453-1-takahiro.akashi@linaro.org> References: <20231026053052.622453-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean In the prior commits, interfaces for executing EFI binary or boot manager were carved out. Move them under efi_loader directory so that they can be called from other places without depending on bootefi command. Signed-off-by: AKASHI Takahiro --- cmd/bootefi.c | 546 ++--------------------------------- include/efi_loader.h | 10 + lib/efi_loader/efi_bootmgr.c | 517 +++++++++++++++++++++++++++++++++ 3 files changed, 551 insertions(+), 522 deletions(-) diff --git a/cmd/bootefi.c b/cmd/bootefi.c index 8b0bd07f1ff8..9cf9027bf409 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -7,531 +7,22 @@ #define LOG_CATEGORY LOGC_EFI -#include -#include -#include #include -#include +#include #include -#include -#include -#include -#include +#include #include #include -#include -#include -#include #include -#include +#include #include -#include +#include +#include DECLARE_GLOBAL_DATA_PTR; -static struct efi_device_path *bootefi_image_path; -static struct efi_device_path *bootefi_device_path; -static void *image_addr; -static size_t image_size; - -/** - * efi_get_image_parameters() - return image parameters - * - * @img_addr: address of loaded image in memory - * @img_size: size of loaded image - */ -void efi_get_image_parameters(void **img_addr, size_t *img_size) -{ - *img_addr = image_addr; - *img_size = image_size; -} - -/** - * efi_clear_bootdev() - clear boot device - */ -static void efi_clear_bootdev(void) -{ - efi_free_pool(bootefi_device_path); - efi_free_pool(bootefi_image_path); - bootefi_device_path = NULL; - bootefi_image_path = NULL; - image_addr = NULL; - image_size = 0; -} - -/** - * efi_set_bootdev() - set boot device - * - * This function is called when a file is loaded, e.g. via the 'load' command. - * We use the path to this file to inform the UEFI binary about the boot device. - * - * @dev: device, e.g. "MMC" - * @devnr: number of the device, e.g. "1:2" - * @path: path to file loaded - * @buffer: buffer with file loaded - * @buffer_size: size of file loaded - */ -void efi_set_bootdev(const char *dev, const char *devnr, const char *path, - void *buffer, size_t buffer_size) -{ - struct efi_device_path *device, *image; - efi_status_t ret; - - log_debug("dev=%s, devnr=%s, path=%s, buffer=%p, size=%zx\n", dev, - devnr, path, buffer, buffer_size); - - /* Forget overwritten image */ - if (buffer + buffer_size >= image_addr && - image_addr + image_size >= buffer) - efi_clear_bootdev(); - - /* Remember only PE-COFF and FIT images */ - if (efi_check_pe(buffer, buffer_size, NULL) != EFI_SUCCESS) { - if (IS_ENABLED(CONFIG_FIT) && - !fit_check_format(buffer, IMAGE_SIZE_INVAL)) { - /* - * FIT images of type EFI_OS are started via command - * bootm. We should not use their boot device with the - * bootefi command. - */ - buffer = 0; - buffer_size = 0; - } else { - log_debug("- not remembering image\n"); - return; - } - } - - /* efi_set_bootdev() is typically called repeatedly, recover memory */ - efi_clear_bootdev(); - - image_addr = buffer; - image_size = buffer_size; - - ret = efi_dp_from_name(dev, devnr, path, &device, &image); - if (ret == EFI_SUCCESS) { - bootefi_device_path = device; - if (image) { - /* FIXME: image should not contain device */ - struct efi_device_path *image_tmp = image; - - efi_dp_split_file_path(image, &device, &image); - efi_free_pool(image_tmp); - } - bootefi_image_path = image; - log_debug("- boot device %pD\n", device); - if (image) - log_debug("- image %pD\n", image); - } else { - log_debug("- efi_dp_from_name() failed, err=%lx\n", ret); - efi_clear_bootdev(); - } -} - -/** - * efi_env_set_load_options() - set load options from environment variable - * - * @handle: the image handle - * @env_var: name of the environment variable - * @load_options: pointer to load options (output) - * Return: status code - */ -static efi_status_t efi_env_set_load_options(efi_handle_t handle, - const char *env_var, - u16 **load_options) -{ - const char *env = env_get(env_var); - size_t size; - u16 *pos; - efi_status_t ret; - - *load_options = NULL; - if (!env) - return EFI_SUCCESS; - size = sizeof(u16) * (utf8_utf16_strlen(env) + 1); - pos = calloc(size, 1); - if (!pos) - return EFI_OUT_OF_RESOURCES; - *load_options = pos; - utf8_utf16_strcpy(&pos, env); - ret = efi_set_load_options(handle, size, *load_options); - if (ret != EFI_SUCCESS) { - free(*load_options); - *load_options = NULL; - } - return ret; -} - -#if !CONFIG_IS_ENABLED(GENERATE_ACPI_TABLE) - -/** - * copy_fdt() - Copy the device tree to a new location available to EFI - * - * The FDT is copied to a suitable location within the EFI memory map. - * Additional 12 KiB are added to the space in case the device tree needs to be - * expanded later with fdt_open_into(). - * - * @fdtp: On entry a pointer to the flattened device tree. - * On exit a pointer to the copy of the flattened device tree. - * FDT start - * Return: status code - */ -static efi_status_t copy_fdt(void **fdtp) -{ - unsigned long fdt_ram_start = -1L, fdt_pages; - efi_status_t ret = 0; - void *fdt, *new_fdt; - u64 new_fdt_addr; - uint fdt_size; - int i; - - for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) { - u64 ram_start = gd->bd->bi_dram[i].start; - u64 ram_size = gd->bd->bi_dram[i].size; - - if (!ram_size) - continue; - - if (ram_start < fdt_ram_start) - fdt_ram_start = ram_start; - } - - /* - * Give us at least 12 KiB of breathing room in case the device tree - * needs to be expanded later. - */ - fdt = *fdtp; - fdt_pages = efi_size_in_pages(fdt_totalsize(fdt) + 0x3000); - fdt_size = fdt_pages << EFI_PAGE_SHIFT; - - ret = efi_allocate_pages(EFI_ALLOCATE_ANY_PAGES, - EFI_ACPI_RECLAIM_MEMORY, fdt_pages, - &new_fdt_addr); - if (ret != EFI_SUCCESS) { - log_err("ERROR: Failed to reserve space for FDT\n"); - goto done; - } - new_fdt = (void *)(uintptr_t)new_fdt_addr; - memcpy(new_fdt, fdt, fdt_totalsize(fdt)); - fdt_set_totalsize(new_fdt, fdt_size); - - *fdtp = (void *)(uintptr_t)new_fdt_addr; -done: - return ret; -} - -/** - * get_config_table() - get configuration table - * - * @guid: GUID of the configuration table - * Return: pointer to configuration table or NULL - */ -static void *get_config_table(const efi_guid_t *guid) -{ - size_t i; - - for (i = 0; i < systab.nr_tables; i++) { - if (!guidcmp(guid, &systab.tables[i].guid)) - return systab.tables[i].table; - } - return NULL; -} - -#endif /* !CONFIG_IS_ENABLED(GENERATE_ACPI_TABLE) */ - -/** - * efi_install_fdt() - install device tree - * - * If fdt is not EFI_FDT_USE_INTERNAL, the device tree located at that memory - * address will will be installed as configuration table, otherwise the device - * tree located at the address indicated by environment variable fdt_addr or as - * fallback fdtcontroladdr will be used. - * - * On architectures using ACPI tables device trees shall not be installed as - * configuration table. - * - * @fdt: address of device tree or EFI_FDT_USE_INTERNAL to use the - * the hardware device tree as indicated by environment variable - * fdt_addr or as fallback the internal device tree as indicated by - * the environment variable fdtcontroladdr - * Return: status code - */ -efi_status_t efi_install_fdt(void *fdt) -{ - /* - * The EBBR spec requires that we have either an FDT or an ACPI table - * but not both. - */ -#if CONFIG_IS_ENABLED(GENERATE_ACPI_TABLE) - if (fdt) { - log_warning("WARNING: Can't have ACPI table and device tree - ignoring DT.\n"); - return EFI_SUCCESS; - } -#else - struct bootm_headers img = { 0 }; - efi_status_t ret; - - if (fdt == EFI_FDT_USE_INTERNAL) { - const char *fdt_opt; - uintptr_t fdt_addr; - - /* Look for device tree that is already installed */ - if (get_config_table(&efi_guid_fdt)) - return EFI_SUCCESS; - /* Check if there is a hardware device tree */ - fdt_opt = env_get("fdt_addr"); - /* Use our own device tree as fallback */ - if (!fdt_opt) { - fdt_opt = env_get("fdtcontroladdr"); - if (!fdt_opt) { - log_err("ERROR: need device tree\n"); - return EFI_NOT_FOUND; - } - } - fdt_addr = hextoul(fdt_opt, NULL); - if (!fdt_addr) { - log_err("ERROR: invalid $fdt_addr or $fdtcontroladdr\n"); - return EFI_LOAD_ERROR; - } - fdt = map_sysmem(fdt_addr, 0); - } - - /* Install device tree */ - if (fdt_check_header(fdt)) { - log_err("ERROR: invalid device tree\n"); - return EFI_LOAD_ERROR; - } - - /* Prepare device tree for payload */ - ret = copy_fdt(&fdt); - if (ret) { - log_err("ERROR: out of memory\n"); - return EFI_OUT_OF_RESOURCES; - } - - if (image_setup_libfdt(&img, fdt, 0, NULL)) { - log_err("ERROR: failed to process device tree\n"); - return EFI_LOAD_ERROR; - } - - /* Create memory reservations as indicated by the device tree */ - efi_carve_out_dt_rsv(fdt); - - efi_try_purge_kaslr_seed(fdt); - - if (CONFIG_IS_ENABLED(EFI_TCG2_PROTOCOL_MEASURE_DTB)) { - ret = efi_tcg2_measure_dtb(fdt); - if (ret == EFI_SECURITY_VIOLATION) { - log_err("ERROR: failed to measure DTB\n"); - return ret; - } - } - - /* Install device tree as UEFI table */ - ret = efi_install_configuration_table(&efi_guid_fdt, fdt); - if (ret != EFI_SUCCESS) { - log_err("ERROR: failed to install device tree\n"); - return ret; - } -#endif /* GENERATE_ACPI_TABLE */ - - return EFI_SUCCESS; -} - -/** - * do_bootefi_exec() - execute EFI binary - * - * The image indicated by @handle is started. When it returns the allocated - * memory for the @load_options is freed. - * - * @handle: handle of loaded image - * @load_options: load options - * Return: status code - * - * Load the EFI binary into a newly assigned memory unwinding the relocation - * information, install the loaded image protocol, and call the binary. - */ -static efi_status_t do_bootefi_exec(efi_handle_t handle, void *load_options) -{ - efi_status_t ret; - efi_uintn_t exit_data_size = 0; - u16 *exit_data = NULL; - - /* On ARM switch from EL3 or secure mode to EL2 or non-secure mode */ - switch_to_non_secure_mode(); - - /* - * The UEFI standard requires that the watchdog timer is set to five - * minutes when invoking an EFI boot option. - * - * Unified Extensible Firmware Interface (UEFI), version 2.7 Errata A - * 7.5. Miscellaneous Boot Services - EFI_BOOT_SERVICES.SetWatchdogTimer - */ - ret = efi_set_watchdog(300); - if (ret != EFI_SUCCESS) { - log_err("ERROR: Failed to set watchdog timer\n"); - goto out; - } - - /* Call our payload! */ - ret = EFI_CALL(efi_start_image(handle, &exit_data_size, &exit_data)); - if (ret != EFI_SUCCESS) { - log_err("## Application failed, r = %lu\n", - ret & ~EFI_ERROR_MASK); - if (exit_data) { - log_err("## %ls\n", exit_data); - efi_free_pool(exit_data); - } - } - - efi_restore_gd(); - -out: - free(load_options); - - if (IS_ENABLED(CONFIG_EFI_LOAD_FILE2_INITRD)) { - if (efi_initrd_deregister() != EFI_SUCCESS) - log_err("Failed to remove loadfile2 for initrd\n"); - } - - /* Control is returned to U-Boot, disable EFI watchdog */ - efi_set_watchdog(0); - - return ret; -} - -/** - * efi_bootmgr_run() - execute EFI boot manager - * fdt: Flat device tree - * - * Invoke EFI boot manager and execute a binary depending on - * boot options. If @fdt is not NULL, it will be passed to - * the executed binary. - * - * Return: status code - */ -static efi_status_t efi_bootmgr_run(void *fdt) -{ - efi_handle_t handle; - void *load_options; - efi_status_t ret; - - /* Initialize EFI drivers */ - ret = efi_init_obj_list(); - if (ret != EFI_SUCCESS) { - log_err("Error: Cannot initialize UEFI sub-system, r = %lu\n", - ret & ~EFI_ERROR_MASK); - return CMD_RET_FAILURE; - } - - ret = efi_install_fdt(fdt); - if (ret != EFI_SUCCESS) - return ret; - - ret = efi_bootmgr_load(&handle, &load_options); - if (ret != EFI_SUCCESS) { - log_notice("EFI boot manager: Cannot load any image\n"); - return ret; - } - - return do_bootefi_exec(handle, load_options); -} - -/** - * efi_run_image() - run loaded UEFI image - * - * @source_buffer: memory address of the UEFI image - * @source_size: size of the UEFI image - * Return: status code - */ -efi_status_t efi_run_image(void *source_buffer, efi_uintn_t source_size) -{ - efi_handle_t mem_handle = NULL, handle; - struct efi_device_path *file_path = NULL; - struct efi_device_path *msg_path; - efi_status_t ret, ret2; - u16 *load_options; - - if (!bootefi_device_path || !bootefi_image_path) { - log_debug("Not loaded from disk\n"); - /* - * Special case for efi payload not loaded from disk, - * such as 'bootefi hello' or for example payload - * loaded directly into memory via JTAG, etc: - */ - file_path = efi_dp_from_mem(EFI_RESERVED_MEMORY_TYPE, - (uintptr_t)source_buffer, - source_size); - /* - * Make sure that device for device_path exist - * in load_image(). Otherwise, shell and grub will fail. - */ - ret = efi_install_multiple_protocol_interfaces(&mem_handle, - &efi_guid_device_path, - file_path, NULL); - if (ret != EFI_SUCCESS) - goto out; - msg_path = file_path; - } else { - file_path = efi_dp_append(bootefi_device_path, - bootefi_image_path); - msg_path = bootefi_image_path; - log_debug("Loaded from disk\n"); - } - - log_info("Booting %pD\n", msg_path); - - ret = EFI_CALL(efi_load_image(false, efi_root, file_path, source_buffer, - source_size, &handle)); - if (ret != EFI_SUCCESS) { - log_err("Loading image failed\n"); - goto out; - } - - /* Transfer environment variable as load options */ - ret = efi_env_set_load_options(handle, "bootargs", &load_options); - if (ret != EFI_SUCCESS) - goto out; - - ret = do_bootefi_exec(handle, load_options); - -out: - ret2 = efi_uninstall_multiple_protocol_interfaces(mem_handle, - &efi_guid_device_path, - file_path, NULL); - efi_free_pool(file_path); - return (ret != EFI_SUCCESS) ? ret : ret2; -} - -/** - * efi_binary_run() - run loaded UEFI image - * - * @image: memory address of the UEFI image - * @size: size of the UEFI image - * - * Execute an EFI binary image loaded at @image. - * @size may be zero if the binary is loaded with U-Boot load command. - * - * Return: status code - */ -static efi_status_t efi_binary_run(void *image, size_t size, void *fdt) -{ - efi_status_t ret; - - /* Initialize EFI drivers */ - ret = efi_init_obj_list(); - if (ret != EFI_SUCCESS) { - log_err("Error: Cannot initialize UEFI sub-system, r = %lu\n", - ret & ~EFI_ERROR_MASK); - return ret; - } - - ret = efi_install_fdt(fdt); - if (ret != EFI_SUCCESS) - return ret; - - return efi_run_image(image, size); -} +static struct efi_device_path *test_image_path; +static struct efi_device_path *test_device_path; static efi_status_t bootefi_run_prepare(const char *load_options_path, struct efi_device_path *device_path, @@ -574,23 +65,26 @@ static efi_status_t bootefi_test_prepare efi_status_t ret; /* Construct a dummy device path */ - bootefi_device_path = efi_dp_from_mem(EFI_RESERVED_MEMORY_TYPE, 0, 0); - if (!bootefi_device_path) + test_device_path = efi_dp_from_mem(EFI_RESERVED_MEMORY_TYPE, 0, 0); + if (!test_device_path) return EFI_OUT_OF_RESOURCES; - bootefi_image_path = efi_dp_from_file(NULL, path); - if (!bootefi_image_path) { + test_image_path = efi_dp_from_file(NULL, path); + if (!test_image_path) { ret = EFI_OUT_OF_RESOURCES; goto failure; } - ret = bootefi_run_prepare(load_options_path, bootefi_device_path, - bootefi_image_path, image_objp, + ret = bootefi_run_prepare(load_options_path, test_device_path, + test_image_path, image_objp, loaded_image_infop); if (ret == EFI_SUCCESS) return ret; failure: + efi_free_pool(test_device_path); + efi_free_pool(test_image_path); + /* TODO: not sure calling clear function is necessary */ efi_clear_bootdev(); return ret; } @@ -615,6 +109,8 @@ static int do_efi_selftest(void) ret = EFI_CALL(efi_selftest(&image_obj->header, &systab)); efi_restore_gd(); free(loaded_image_info->load_options); + efi_free_pool(test_device_path); + efi_free_pool(test_image_path); if (ret != EFI_SUCCESS) efi_delete_handle(&image_obj->header); else @@ -639,6 +135,8 @@ static int do_bootefi(struct cmd_tbl *cmdtp, int flag, int argc, char *p; void *fdt, *image_buf; unsigned long addr, size; + void *image_addr; + size_t image_size; if (argc < 2) return CMD_RET_USAGE; @@ -690,6 +188,7 @@ static int do_bootefi(struct cmd_tbl *cmdtp, int flag, int argc, !strcmp(argv[1], "hello")) { image_buf = __efi_helloworld_begin; size = __efi_helloworld_end - __efi_helloworld_begin; + /* TODO: not sure calling clear function is necessary */ efi_clear_bootdev(); } else { addr = strtoul(argv[1], NULL, 16); @@ -705,6 +204,9 @@ static int do_bootefi(struct cmd_tbl *cmdtp, int flag, int argc, return CMD_RET_USAGE; efi_clear_bootdev(); } else { + /* Image should be already loaded */ + efi_get_image_parameters(&image_addr, &image_size); + if (image_buf != image_addr) { log_err("No UEFI binary known at %s\n", argv[1]); diff --git a/include/efi_loader.h b/include/efi_loader.h index 48d4999e56a9..031a8f76846a 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -91,6 +91,8 @@ efi_status_t efi_add_runtime_mmio(void *mmio_ptr, u64 len); * back to u-boot world */ void efi_restore_gd(void); +/* Call this to unset the current device name */ +void efi_clear_bootdev(void); /* Call this to set the current device name */ void efi_set_bootdev(const char *dev, const char *devnr, const char *path, void *buffer, size_t buffer_size); @@ -115,6 +117,7 @@ static inline efi_status_t efi_add_runtime_mmio(void *mmio_ptr, u64 len) /* No loader configured, stub out EFI_ENTRY */ static inline void efi_restore_gd(void) { } +static inline void efi_clear_bootdev(void) { } static inline void efi_set_bootdev(const char *dev, const char *devnr, const char *path, void *buffer, size_t buffer_size) { } @@ -526,14 +529,21 @@ efi_status_t efi_bootmgr_get_unused_bootoption(u16 *buf, efi_status_t efi_bootmgr_update_media_device_boot_option(void); /* Delete selected boot option */ efi_status_t efi_bootmgr_delete_boot_option(u16 boot_index); +/* Invoke EFI boot manager */ +efi_status_t efi_bootmgr_run(void *fdt); /* search the boot option index in BootOrder */ bool efi_search_bootorder(u16 *bootorder, efi_uintn_t num, u32 target, u32 *index); /* Set up console modes */ void efi_setup_console_size(void); +/* Set up load options from environment variable */ +efi_status_t efi_env_set_load_options(efi_handle_t handle, const char *env_var, + u16 **load_options); /* Install device tree */ efi_status_t efi_install_fdt(void *fdt); /* Run loaded UEFI image */ efi_status_t efi_run_image(void *source_buffer, efi_uintn_t source_size); +/* Run loaded UEFI image with given fdt */ +efi_status_t efi_binary_run(void *image, size_t size, void *fdt); /* Initialize variable services */ efi_status_t efi_init_variables(void); /* Notify ExitBootServices() is called */ diff --git a/lib/efi_loader/efi_bootmgr.c b/lib/efi_loader/efi_bootmgr.c index a40762c74c83..cc8d88b4b025 100644 --- a/lib/efi_loader/efi_bootmgr.c +++ b/lib/efi_loader/efi_bootmgr.c @@ -3,6 +3,8 @@ * EFI boot manager * * Copyright (c) 2017 Rob Clark + * For the code moved from cmd/bootefi.c + * Copyright (c) 2016 Alexander Graf */ #define LOG_CATEGORY LOGC_EFI @@ -16,6 +18,17 @@ #include #include +/* TODO: temporarily added here; clean up later */ +#include +#include +#include +#include +#include +#include +#include + +DECLARE_GLOBAL_DATA_PTR; + static const struct efi_boot_services *bs; static const struct efi_runtime_services *rs; @@ -729,3 +742,507 @@ out: return EFI_SUCCESS; return ret; } + +static struct efi_device_path *bootefi_image_path; +static struct efi_device_path *bootefi_device_path; +static void *image_addr; +static size_t image_size; + +/** + * efi_get_image_parameters() - return image parameters + * + * @img_addr: address of loaded image in memory + * @img_size: size of loaded image + */ +void efi_get_image_parameters(void **img_addr, size_t *img_size) +{ + *img_addr = image_addr; + *img_size = image_size; +} + +/** + * efi_clear_bootdev() - clear boot device + */ +void efi_clear_bootdev(void) +{ + efi_free_pool(bootefi_device_path); + efi_free_pool(bootefi_image_path); + bootefi_device_path = NULL; + bootefi_image_path = NULL; + image_addr = NULL; + image_size = 0; +} + +/** + * efi_set_bootdev() - set boot device + * + * This function is called when a file is loaded, e.g. via the 'load' command. + * We use the path to this file to inform the UEFI binary about the boot device. + * + * @dev: device, e.g. "MMC" + * @devnr: number of the device, e.g. "1:2" + * @path: path to file loaded + * @buffer: buffer with file loaded + * @buffer_size: size of file loaded + */ +void efi_set_bootdev(const char *dev, const char *devnr, const char *path, + void *buffer, size_t buffer_size) +{ + struct efi_device_path *device, *image; + efi_status_t ret; + + log_debug("dev=%s, devnr=%s, path=%s, buffer=%p, size=%zx\n", dev, + devnr, path, buffer, buffer_size); + + /* Forget overwritten image */ + if (buffer + buffer_size >= image_addr && + image_addr + image_size >= buffer) + efi_clear_bootdev(); + + /* Remember only PE-COFF and FIT images */ + if (efi_check_pe(buffer, buffer_size, NULL) != EFI_SUCCESS) { + if (IS_ENABLED(CONFIG_FIT) && + !fit_check_format(buffer, IMAGE_SIZE_INVAL)) { + /* + * FIT images of type EFI_OS are started via command + * bootm. We should not use their boot device with the + * bootefi command. + */ + buffer = 0; + buffer_size = 0; + } else { + log_debug("- not remembering image\n"); + return; + } + } + + /* efi_set_bootdev() is typically called repeatedly, recover memory */ + efi_clear_bootdev(); + + image_addr = buffer; + image_size = buffer_size; + + ret = efi_dp_from_name(dev, devnr, path, &device, &image); + if (ret == EFI_SUCCESS) { + bootefi_device_path = device; + if (image) { + /* FIXME: image should not contain device */ + struct efi_device_path *image_tmp = image; + + efi_dp_split_file_path(image, &device, &image); + efi_free_pool(image_tmp); + } + bootefi_image_path = image; + log_debug("- boot device %pD\n", device); + if (image) + log_debug("- image %pD\n", image); + } else { + log_debug("- efi_dp_from_name() failed, err=%lx\n", ret); + efi_clear_bootdev(); + } +} + +/** + * efi_env_set_load_options() - set load options from environment variable + * + * @handle: the image handle + * @env_var: name of the environment variable + * @load_options: pointer to load options (output) + * Return: status code + */ +efi_status_t efi_env_set_load_options(efi_handle_t handle, + const char *env_var, + u16 **load_options) +{ + const char *env = env_get(env_var); + size_t size; + u16 *pos; + efi_status_t ret; + + *load_options = NULL; + if (!env) + return EFI_SUCCESS; + size = sizeof(u16) * (utf8_utf16_strlen(env) + 1); + pos = calloc(size, 1); + if (!pos) + return EFI_OUT_OF_RESOURCES; + *load_options = pos; + utf8_utf16_strcpy(&pos, env); + ret = efi_set_load_options(handle, size, *load_options); + if (ret != EFI_SUCCESS) { + free(*load_options); + *load_options = NULL; + } + return ret; +} + +#if !CONFIG_IS_ENABLED(GENERATE_ACPI_TABLE) + +/** + * copy_fdt() - Copy the device tree to a new location available to EFI + * + * The FDT is copied to a suitable location within the EFI memory map. + * Additional 12 KiB are added to the space in case the device tree needs to be + * expanded later with fdt_open_into(). + * + * @fdtp: On entry a pointer to the flattened device tree. + * On exit a pointer to the copy of the flattened device tree. + * FDT start + * Return: status code + */ +static efi_status_t copy_fdt(void **fdtp) +{ + unsigned long fdt_ram_start = -1L, fdt_pages; + efi_status_t ret = 0; + void *fdt, *new_fdt; + u64 new_fdt_addr; + uint fdt_size; + int i; + + for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) { + u64 ram_start = gd->bd->bi_dram[i].start; + u64 ram_size = gd->bd->bi_dram[i].size; + + if (!ram_size) + continue; + + if (ram_start < fdt_ram_start) + fdt_ram_start = ram_start; + } + + /* + * Give us at least 12 KiB of breathing room in case the device tree + * needs to be expanded later. + */ + fdt = *fdtp; + fdt_pages = efi_size_in_pages(fdt_totalsize(fdt) + 0x3000); + fdt_size = fdt_pages << EFI_PAGE_SHIFT; + + ret = efi_allocate_pages(EFI_ALLOCATE_ANY_PAGES, + EFI_ACPI_RECLAIM_MEMORY, fdt_pages, + &new_fdt_addr); + if (ret != EFI_SUCCESS) { + log_err("ERROR: Failed to reserve space for FDT\n"); + goto done; + } + new_fdt = (void *)(uintptr_t)new_fdt_addr; + memcpy(new_fdt, fdt, fdt_totalsize(fdt)); + fdt_set_totalsize(new_fdt, fdt_size); + + *fdtp = (void *)(uintptr_t)new_fdt_addr; +done: + return ret; +} + +/** + * get_config_table() - get configuration table + * + * @guid: GUID of the configuration table + * Return: pointer to configuration table or NULL + */ +static void *get_config_table(const efi_guid_t *guid) +{ + size_t i; + + for (i = 0; i < systab.nr_tables; i++) { + if (!guidcmp(guid, &systab.tables[i].guid)) + return systab.tables[i].table; + } + return NULL; +} + +#endif /* !CONFIG_IS_ENABLED(GENERATE_ACPI_TABLE) */ + +/** + * efi_install_fdt() - install device tree + * + * If fdt is not EFI_FDT_USE_INTERNAL, the device tree located at that memory + * address will be installed as configuration table, otherwise the device + * tree located at the address indicated by environment variable fdt_addr or as + * fallback fdtcontroladdr will be used. + * + * On architectures using ACPI tables device trees shall not be installed as + * configuration table. + * + * @fdt: address of device tree or EFI_FDT_USE_INTERNAL to use + * the hardware device tree as indicated by environment variable + * fdt_addr or as fallback the internal device tree as indicated by + * the environment variable fdtcontroladdr + * Return: status code + */ +efi_status_t efi_install_fdt(void *fdt) +{ + /* + * The EBBR spec requires that we have either an FDT or an ACPI table + * but not both. + */ +#if CONFIG_IS_ENABLED(GENERATE_ACPI_TABLE) + if (fdt) { + log_warning("WARNING: Can't have ACPI table and device tree - ignoring DT.\n"); + return EFI_SUCCESS; + } +#else + struct bootm_headers img = { 0 }; + efi_status_t ret; + + if (fdt == EFI_FDT_USE_INTERNAL) { + const char *fdt_opt; + uintptr_t fdt_addr; + + /* Look for device tree that is already installed */ + if (get_config_table(&efi_guid_fdt)) + return EFI_SUCCESS; + /* Check if there is a hardware device tree */ + fdt_opt = env_get("fdt_addr"); + /* Use our own device tree as fallback */ + if (!fdt_opt) { + fdt_opt = env_get("fdtcontroladdr"); + if (!fdt_opt) { + log_err("ERROR: need device tree\n"); + return EFI_NOT_FOUND; + } + } + fdt_addr = hextoul(fdt_opt, NULL); + if (!fdt_addr) { + log_err("ERROR: invalid $fdt_addr or $fdtcontroladdr\n"); + return EFI_LOAD_ERROR; + } + fdt = map_sysmem(fdt_addr, 0); + } + + /* Install device tree */ + if (fdt_check_header(fdt)) { + log_err("ERROR: invalid device tree\n"); + return EFI_LOAD_ERROR; + } + + /* Prepare device tree for payload */ + ret = copy_fdt(&fdt); + if (ret) { + log_err("ERROR: out of memory\n"); + return EFI_OUT_OF_RESOURCES; + } + + if (image_setup_libfdt(&img, fdt, 0, NULL)) { + log_err("ERROR: failed to process device tree\n"); + return EFI_LOAD_ERROR; + } + + /* Create memory reservations as indicated by the device tree */ + efi_carve_out_dt_rsv(fdt); + + efi_try_purge_kaslr_seed(fdt); + + if (CONFIG_IS_ENABLED(EFI_TCG2_PROTOCOL_MEASURE_DTB)) { + ret = efi_tcg2_measure_dtb(fdt); + if (ret == EFI_SECURITY_VIOLATION) { + log_err("ERROR: failed to measure DTB\n"); + return ret; + } + } + + /* Install device tree as UEFI table */ + ret = efi_install_configuration_table(&efi_guid_fdt, fdt); + if (ret != EFI_SUCCESS) { + log_err("ERROR: failed to install device tree\n"); + return ret; + } +#endif /* GENERATE_ACPI_TABLE */ + + return EFI_SUCCESS; +} + +/** + * do_bootefi_exec() - execute EFI binary + * + * The image indicated by @handle is started. When it returns the allocated + * memory for the @load_options is freed. + * + * @handle: handle of loaded image + * @load_options: load options + * Return: status code + * + * Load the EFI binary into a newly assigned memory unwinding the relocation + * information, install the loaded image protocol, and call the binary. + */ +static efi_status_t do_bootefi_exec(efi_handle_t handle, void *load_options) +{ + efi_status_t ret; + efi_uintn_t exit_data_size = 0; + u16 *exit_data = NULL; + + /* On ARM switch from EL3 or secure mode to EL2 or non-secure mode */ + switch_to_non_secure_mode(); + + /* + * The UEFI standard requires that the watchdog timer is set to five + * minutes when invoking an EFI boot option. + * + * Unified Extensible Firmware Interface (UEFI), version 2.7 Errata A + * 7.5. Miscellaneous Boot Services - EFI_BOOT_SERVICES.SetWatchdogTimer + */ + ret = efi_set_watchdog(300); + if (ret != EFI_SUCCESS) { + log_err("ERROR: Failed to set watchdog timer\n"); + goto out; + } + + /* Call our payload! */ + ret = EFI_CALL(efi_start_image(handle, &exit_data_size, &exit_data)); + if (ret != EFI_SUCCESS) { + log_err("## Application failed, r = %lu\n", + ret & ~EFI_ERROR_MASK); + if (exit_data) { + log_err("## %ls\n", exit_data); + efi_free_pool(exit_data); + } + } + + efi_restore_gd(); + +out: + free(load_options); + + if (IS_ENABLED(CONFIG_EFI_LOAD_FILE2_INITRD)) { + if (efi_initrd_deregister() != EFI_SUCCESS) + log_err("Failed to remove loadfile2 for initrd\n"); + } + + /* Control is returned to U-Boot, disable EFI watchdog */ + efi_set_watchdog(0); + + return ret; +} + +/** + * efi_bootmgr_run() - execute EFI boot manager + * fdt: Flat device tree + * + * Invoke EFI boot manager and execute a binary depending on + * boot options. If @fdt is not NULL, it will be passed to + * the executed binary. + * + * Return: status code + */ +efi_status_t efi_bootmgr_run(void *fdt) +{ + efi_handle_t handle; + void *load_options; + efi_status_t ret; + + /* Initialize EFI drivers */ + ret = efi_init_obj_list(); + if (ret != EFI_SUCCESS) { + log_err("Error: Cannot initialize UEFI sub-system, r = %lu\n", + ret & ~EFI_ERROR_MASK); + return CMD_RET_FAILURE; + } + + ret = efi_install_fdt(fdt); + if (ret != EFI_SUCCESS) + return ret; + + ret = efi_bootmgr_load(&handle, &load_options); + if (ret != EFI_SUCCESS) { + log_notice("EFI boot manager: Cannot load any image\n"); + return ret; + } + + return do_bootefi_exec(handle, load_options); +} + +/** + * efi_run_image() - run loaded UEFI image + * + * @source_buffer: memory address of the UEFI image + * @source_size: size of the UEFI image + * Return: status code + */ +efi_status_t efi_run_image(void *source_buffer, efi_uintn_t source_size) +{ + efi_handle_t mem_handle = NULL, handle; + struct efi_device_path *file_path = NULL; + struct efi_device_path *msg_path; + efi_status_t ret, ret2; + u16 *load_options; + + if (!bootefi_device_path || !bootefi_image_path) { + log_debug("Not loaded from disk\n"); + /* + * Special case for efi payload not loaded from disk, + * such as 'bootefi hello' or for example payload + * loaded directly into memory via JTAG, etc: + */ + file_path = efi_dp_from_mem(EFI_RESERVED_MEMORY_TYPE, + (uintptr_t)source_buffer, + source_size); + /* + * Make sure that device for device_path exist + * in load_image(). Otherwise, shell and grub will fail. + */ + ret = efi_install_multiple_protocol_interfaces(&mem_handle, + &efi_guid_device_path, + file_path, NULL); + if (ret != EFI_SUCCESS) + goto out; + msg_path = file_path; + } else { + file_path = efi_dp_append(bootefi_device_path, + bootefi_image_path); + msg_path = bootefi_image_path; + log_debug("Loaded from disk\n"); + } + + log_info("Booting %pD\n", msg_path); + + ret = EFI_CALL(efi_load_image(false, efi_root, file_path, source_buffer, + source_size, &handle)); + if (ret != EFI_SUCCESS) { + log_err("Loading image failed\n"); + goto out; + } + + /* Transfer environment variable as load options */ + ret = efi_env_set_load_options(handle, "bootargs", &load_options); + if (ret != EFI_SUCCESS) + goto out; + + ret = do_bootefi_exec(handle, load_options); + +out: + ret2 = efi_uninstall_multiple_protocol_interfaces(mem_handle, + &efi_guid_device_path, + file_path, NULL); + efi_free_pool(file_path); + return (ret != EFI_SUCCESS) ? ret : ret2; +} + +/** + * efi_binary_run() - run loaded UEFI image + * + * @image: memory address of the UEFI image + * @size: size of the UEFI image + * + * Execute an EFI binary image loaded at @image. + * @size may be zero if the binary is loaded with U-Boot load command. + * + * Return: status code + */ +efi_status_t efi_binary_run(void *image, size_t size, void *fdt) +{ + efi_status_t ret; + + /* Initialize EFI drivers */ + ret = efi_init_obj_list(); + if (ret != EFI_SUCCESS) { + log_err("Error: Cannot initialize UEFI sub-system, r = %lu\n", + ret & ~EFI_ERROR_MASK); + return -1; + } + + ret = efi_install_fdt(fdt); + if (ret != EFI_SUCCESS) + return ret; + + return efi_run_image(image, size); +} From patchwork Thu Oct 26 05:30:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 738322 Delivered-To: patch@linaro.org Received: by 2002:adf:f842:0:b0:32d:baff:b0ca with SMTP id d2csp638588wrq; Wed, 25 Oct 2023 22:32:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFliF4EJLlm2ZxHxDUJAOYUZZjQ8oWF0RDpdkav3/IifJKNz9JIQwTrT9X/BqO7rW1Pn/1Q X-Received: by 2002:a05:600c:45c7:b0:408:4918:590e with SMTP id s7-20020a05600c45c700b004084918590emr12679209wmo.39.1698298343849; Wed, 25 Oct 2023 22:32:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698298343; cv=none; d=google.com; s=arc-20160816; b=lhIjCAYqbTgjl1OFIX0OZmR34EntD3lZthUozMlpHsSIQMSTZF9HsOctlPgLUzPcub WASOjJ2tkcMYGXL/u4t25ya3fCz0zfgNnQot6Y9pbFJJQK0nvrkOveuDt+v1qm8lZLSM RPAx+k7V34ENEbF/vIrzoPDx1OaJJt8z9wBYbDD0BFdoJlATTw0IYwTyqPsie+xPST0t /9NVe5fxHmN5Dt2MkBzOi757sZH7l5KMs5iSc6s3uK1ujfXrU10vkCbKbeCDOKt5vFZX HLUz9CsUYZdVXMHuHn4uOhPKC3RjSXCc0weCSXc43E9qVjOoFtCWiceO3syPrQHIN2YS Opfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=pfq1FrnLfG/WgO7sHG0nzAgt3mqwveg6HoTHbERWVSc=; fh=RsKNQde3hXRhkFNkXZDJxhxJUE2DI5qQDMHikPj4pmY=; b=EbfC/TWaelc7tIgzPOI38anUh1apUJxo9TRsl2sU7ggGIQwN632d5udm7FJOf3B4mx F2aY/ZC5M6JvE0oQ/eRPHEFc4pOy1sZXpwZk5iwDZ2fh5rvmLujAVfZlpVtmEYyppGqt JPjJd3kB0ANqspSJu33OWG19gY6pHR6ylCVjkW52WEAEWgshhjG+9RJvg+QMM+JWOZ8b IvL7KhcGENyjc86IFzp+xnYQJ8QGS3Dm3eg/OhYmKASX1fyH1sKrjwQP85eX12ISPNKT 60jfNQIRd/Q7rhmDRihjy8P/XVGC0pwxq+5FJ63AzwjcmaAn29M1LpKdaD5/gj+D2AZs YxEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pZnjFIUN; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id t14-20020a05600c450e00b004083bad7a60si1095131wmo.198.2023.10.25.22.32.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 22:32:23 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pZnjFIUN; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 519FA87B1F; Thu, 26 Oct 2023 07:31:43 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="pZnjFIUN"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D527087AF6; Thu, 26 Oct 2023 07:31:39 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pg1-x534.google.com (mail-pg1-x534.google.com [IPv6:2607:f8b0:4864:20::534]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 9E29A87B11 for ; Thu, 26 Oct 2023 07:31:35 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pg1-x534.google.com with SMTP id 41be03b00d2f7-51f64817809so54562a12.1 for ; Wed, 25 Oct 2023 22:31:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698298293; x=1698903093; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=pfq1FrnLfG/WgO7sHG0nzAgt3mqwveg6HoTHbERWVSc=; b=pZnjFIUNcAImjxxvqKj+uMpo2bADd0aEjHJ+BXqIBXrRAkQD5Zq+Y/SBw+migZ/9dw 78ymg7rNpqfuZN44U3g2MRugptlFwB/rILhFkzgwzmG2ItxlaF3b1O6O43VkOXAH4XHB 2KCVNxgSUOKIFeVXwCnosC0eFzuPuwPwmINzpk9+kkXvuYzJQfrrw7FfDZWNVqnf/GWb Re3Kl1//vmN2t+3MCuFn33E44g5yZST4awy+viLW/8LE9OaoAHqnVX0bLt7seWv0BU+b 0vmhNNAR6VxAKPmXd/nneCpJIgkEonuN6REb3Hwem/uk4jUjscONr0MHfDE3EEBgpsbC VgAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698298293; x=1698903093; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pfq1FrnLfG/WgO7sHG0nzAgt3mqwveg6HoTHbERWVSc=; b=FZHeMxh5D+tlVmb/VGOFEcz7nKjTi6MiCJrGOGT0kqRju7FjhE/WRz/VABDwbzMwvl Fdb5u4UYWjvOsmDO+08wrxCThYeQ6eqrfQo5oQkNfRCITf1N+qvVCvECqj4E3Us/9Zzs uBERC1GgJ1bVWaY4HLNu0gGLMhL48um1QT4cA/kMTts8d1lk70SiLmngMIg3fo06C8lc HciSRuYBcAh3tQeicyfeuX81T8qXS3AWDC+jS7VTLooQFYDe+47YGx3kU58jdF8LqdSn AROoEjJsfBabGJGPPKfYdfZQeHQOGqDTtfV9EWQNnkQjbii8vF98BZG5a7+bs2HO6fJT PWpQ== X-Gm-Message-State: AOJu0YxlfdQC2svMjdMejW2+Nnjo+QGh9jC4t5PSATZ9Sxf+br0jDmRS aT39jtnIv6qTzhMqkcmqMtoZQQ== X-Received: by 2002:a62:e816:0:b0:6bf:1621:ccad with SMTP id c22-20020a62e816000000b006bf1621ccadmr17729606pfi.0.1698298293464; Wed, 25 Oct 2023 22:31:33 -0700 (PDT) Received: from octopus.. ([2400:4050:c3e1:100:bca9:3af7:89e9:80b7]) by smtp.gmail.com with ESMTPSA id fa13-20020a056a002d0d00b006c06804cd39sm440715pfb.153.2023.10.25.22.31.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 22:31:33 -0700 (PDT) From: AKASHI Takahiro To: trini@konsulko.com, sjg@chromium.org, xypron.glpk@gmx.de, ilias.apalodimas@linaro.org Cc: jbx6244@gmail.com, u-boot@lists.denx.de, AKASHI Takahiro Subject: [RFC 06/13] cmd: efidebug: ease efi configuration dependency Date: Thu, 26 Oct 2023 14:30:45 +0900 Message-Id: <20231026053052.622453-7-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231026053052.622453-1-takahiro.akashi@linaro.org> References: <20231026053052.622453-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Now it is clear that the command actually depends on interfaces, not "bootefi bootmgr" command. Signed-off-by: AKASHI Takahiro --- cmd/efidebug.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/efidebug.c b/cmd/efidebug.c index 201531ac19fc..c2b2b074e094 100644 --- a/cmd/efidebug.c +++ b/cmd/efidebug.c @@ -1335,7 +1335,7 @@ static __maybe_unused int do_efi_test_bootmgr(struct cmd_tbl *cmdtp, int flag, } static struct cmd_tbl cmd_efidebug_test_sub[] = { -#ifdef CONFIG_CMD_BOOTEFI_BOOTMGR +#ifdef CONFIG_BOOTEFI_BOOTMGR U_BOOT_CMD_MKENT(bootmgr, CONFIG_SYS_MAXARGS, 1, do_efi_test_bootmgr, "", ""), #endif @@ -1526,7 +1526,7 @@ U_BOOT_LONGHELP(efidebug, " - show UEFI memory map\n" "efidebug tables\n" " - show UEFI configuration tables\n" -#ifdef CONFIG_CMD_BOOTEFI_BOOTMGR +#ifdef CONFIG_BOOTEFI_BOOTMGR "efidebug test bootmgr\n" " - run simple bootmgr for test\n" #endif From patchwork Thu Oct 26 05:30:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 738323 Delivered-To: patch@linaro.org Received: by 2002:adf:f842:0:b0:32d:baff:b0ca with SMTP id d2csp638626wrq; Wed, 25 Oct 2023 22:32:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG30cStz7MQ8280vlK8QWhO4iWNSZ4wTPIBX1AC6rbX1rIET2jmUV9oIQBT9pxDyh8sE0PF X-Received: by 2002:adf:f346:0:b0:32d:bc6e:7f0d with SMTP id e6-20020adff346000000b0032dbc6e7f0dmr11546945wrp.18.1698298350402; Wed, 25 Oct 2023 22:32:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698298350; cv=none; d=google.com; s=arc-20160816; b=CmRsfEnGUWbyt+qPQ4vEobXoiYWsC4k00S31LhrHm1IoAasrE+XcfMYhDPSsiDTq6M WhhDNpCZIS1ZXFvsbc97UVp17Daa6P/Ul4GvFWtMcZfqY6GaMl9+3ZqPv867cY9pimOO HrlLrzsv4L2RssDqGvlKMKmgFfJkr/CP5wmu8B2qtg7GJp6762ZmHRFRH5OC68v9nQkG GUitxv3dAHnZCvZa/ZeYolSL+vrrYgZ2K0cIrbFtlZe4ayP6KInE3q4DCtk7iktVgFko OjY3lB07vujfPbdRBdwkTceuk6P00OoSh2I1avZRjRRVfrc3El9fo7QadY6fhbQolKtD +LWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=1rIcLEYEWKO2skUJC4f8/vOUI8ckO6+/lqe/F/PC0jQ=; fh=RsKNQde3hXRhkFNkXZDJxhxJUE2DI5qQDMHikPj4pmY=; b=OUs6yQ7XXoyjfPJ/17OO0GnTdCgX8hiAUYG7dejHA11HKn3I54pGBkb48U6fu/4V3L ywFW85zOWhLUUEs/kMNYCS/XKg4DWqvIKXTtgDiJG2sL/55yy4SyL82vE/ouKr/sJ9/y Lvcd5XmqWutXw10doBQpZA50m2+cztF9IVRg/6smqlEJi38kLrDj5978/jpYjJOLa+Y7 AOnXKID//iZl2r4nuXKAs6J0A0tGJiJz7hijXlN3aEqzw0cR7SlgunKrYURaDDlSSFOy q+drmBOI4Li2xphtV2VldfPSzwX1J2losK68jN/rVimwQJ+iUYS8R6pyXq4swLhDH+0U Pr2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oJVzt6qp; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id x1-20020adfdd81000000b003296bddbbd1si8383354wrl.437.2023.10.25.22.32.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 22:32:30 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oJVzt6qp; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id BDB6B87B0D; Thu, 26 Oct 2023 07:31:43 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="oJVzt6qp"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1DDAB87B18; Thu, 26 Oct 2023 07:31:40 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pg1-x534.google.com (mail-pg1-x534.google.com [IPv6:2607:f8b0:4864:20::534]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id A12BD87B0F for ; Thu, 26 Oct 2023 07:31:37 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pg1-x534.google.com with SMTP id 41be03b00d2f7-55b5a37acb6so58912a12.0 for ; Wed, 25 Oct 2023 22:31:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698298296; x=1698903096; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1rIcLEYEWKO2skUJC4f8/vOUI8ckO6+/lqe/F/PC0jQ=; b=oJVzt6qpzdJN2+Wek6bbrFmXNLvUw2xaP2V32vgOxaMZJLpQ4GnsQkCzc6nxDZ7t8m uHktIExV4Ibe18+cTnn/PMXCCyTk9H/zkaDkHorzLF1HHE49ew/ndL99RxHEdFX4/+iQ Jj8QXMhcC3DxFTg70Jw3j9J4Ve5m9JXJClyTxVsVPjnrA434p9xfCLV5Oj25M48feM9D wPr56c4u6kCaUrn9CDaXQhjZeftVKoJ4obJ+ls07iFac+noHkomJ/neHpO7z9VbYI3Kv LDNYRJiX0U9mGj9YNn4s4hIpC7tZsfyVSt5h5pA1u+5G3mqxqIhzNbcrFjMzlXo4U1Ed ptqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698298296; x=1698903096; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1rIcLEYEWKO2skUJC4f8/vOUI8ckO6+/lqe/F/PC0jQ=; b=WuQ3rXcsJq9yyCMbG1l6jM11RqC4Aj2bls5dSiYZoHh+zUzbY9PYA+rXvLSgq+awQx ABhPObd+t31NZLhsss4RUNlPmz0b/+NKhgB83HG3P4FHCU/B0+1WevB7AuM4AYFKPOnW 2+BWk1iaEWG+rbX1XUPGgUaAylQ3ZWSjBi7PVg8OuLVrTDyekqKvkbJVINNbBQXsyEIe X4ddmTm0ANk+TWwFhZYJHBdOnSD96yaoiSf521Xwm6kSOYTthtRLXQXgXVoDLwerZ+JD HSMP/XB+babZhfPCjPPrhCMvzCaXqfHJWSXSRBun6rMbVlAstjLEnr//IWtxmAfR6z/x 92dg== X-Gm-Message-State: AOJu0Yzo9JzOtIG1eKJxv2px+jjF/DpsyfKp0OlwMF3ZaXRQ+F8CWWyO mf5VRqlISzfAPo6CW33Y8tS1Ow== X-Received: by 2002:a05:6a00:26dd:b0:6b2:51a0:e1c9 with SMTP id p29-20020a056a0026dd00b006b251a0e1c9mr17701119pfw.1.1698298295635; Wed, 25 Oct 2023 22:31:35 -0700 (PDT) Received: from octopus.. ([2400:4050:c3e1:100:bca9:3af7:89e9:80b7]) by smtp.gmail.com with ESMTPSA id fa13-20020a056a002d0d00b006c06804cd39sm440715pfb.153.2023.10.25.22.31.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 22:31:35 -0700 (PDT) From: AKASHI Takahiro To: trini@konsulko.com, sjg@chromium.org, xypron.glpk@gmx.de, ilias.apalodimas@linaro.org Cc: jbx6244@gmail.com, u-boot@lists.denx.de, AKASHI Takahiro Subject: [RFC 07/13] bootmeth: use efi_loader interfaces instead of bootefi command Date: Thu, 26 Oct 2023 14:30:46 +0900 Message-Id: <20231026053052.622453-8-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231026053052.622453-1-takahiro.akashi@linaro.org> References: <20231026053052.622453-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Now that efi_loader subsystem provides interfaces that are equivalent with bootefi command, we can replace command invocations with APIs. Signed-off-by: AKASHI Takahiro --- boot/Kconfig | 4 ++-- boot/Makefile | 2 +- boot/bootm_os.c | 31 +++++++------------------------ boot/bootmeth_efi.c | 8 +------- boot/bootmeth_efi_mgr.c | 3 ++- cmd/Kconfig | 2 +- test/boot/bootflow.c | 2 +- 7 files changed, 15 insertions(+), 37 deletions(-) diff --git a/boot/Kconfig b/boot/Kconfig index fabf6fec2195..a441fac8ade1 100644 --- a/boot/Kconfig +++ b/boot/Kconfig @@ -511,7 +511,7 @@ config BOOTMETH_EXTLINUX_PXE config BOOTMETH_EFILOADER bool "Bootdev support for EFI boot" - depends on CMD_BOOTEFI + depends on BOOTEFI_BOOTMGR default y help Enables support for EFI boot using bootdevs. This makes the @@ -546,7 +546,7 @@ config BOOTMETH_DISTRO select BOOTMETH_SCRIPT if CMDLINE # E.g. Armbian uses scripts select BOOTMETH_EXTLINUX # E.g. Debian uses these select BOOTMETH_EXTLINUX_PXE if CMD_PXE && CMD_NET && DM_ETH - select BOOTMETH_EFILOADER if CMD_BOOTEFI # E.g. Ubuntu uses this + select BOOTMETH_EFILOADER if BOOTEFI_BOOTMGR # E.g. Ubuntu uses this config SPL_BOOTMETH_VBE bool "Bootdev support for Verified Boot for Embedded (SPL)" diff --git a/boot/Makefile b/boot/Makefile index 3fd048bb41ab..4eaa5eab4b77 100644 --- a/boot/Makefile +++ b/boot/Makefile @@ -32,7 +32,7 @@ obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_CROS) += bootm.o bootm_os.o bootmeth_cros.o obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_SANDBOX) += bootmeth_sandbox.o obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_SCRIPT) += bootmeth_script.o ifdef CONFIG_$(SPL_TPL_)BOOTSTD_FULL -obj-$(CONFIG_CMD_BOOTEFI_BOOTMGR) += bootmeth_efi_mgr.o +obj-$(CONFIG_BOOTEFI_BOOTMGR) += bootmeth_efi_mgr.o obj-$(CONFIG_$(SPL_TPL_)EXPO) += bootflow_menu.o obj-$(CONFIG_$(SPL_TPL_)BOOTSTD) += bootflow_menu.o obj-$(CONFIG_$(SPL_TPL_)CEDIT) += cedit.o diff --git a/boot/bootm_os.c b/boot/bootm_os.c index 9c035b5be886..029baac478ae 100644 --- a/boot/bootm_os.c +++ b/boot/bootm_os.c @@ -494,7 +494,6 @@ static int do_bootm_efi(int flag, int argc, char *const argv[], struct bootm_headers *images) { int ret; - efi_status_t efi_ret; void *image_buf; if (flag != BOOTM_STATE_OS_GO) @@ -505,37 +504,21 @@ static int do_bootm_efi(int flag, int argc, char *const argv[], if (ret) return ret; - /* Initialize EFI drivers */ - efi_ret = efi_init_obj_list(); - if (efi_ret != EFI_SUCCESS) { - printf("## Failed to initialize UEFI sub-system: r = %lu\n", - efi_ret & ~EFI_ERROR_MASK); - return 1; - } + /* We expect to return */ + images->os.type = IH_TYPE_STANDALONE; - /* Install device tree */ - efi_ret = efi_install_fdt(images->ft_len - ? images->ft_addr : EFI_FDT_USE_INTERNAL); - if (efi_ret != EFI_SUCCESS) { - printf("## Failed to install device tree: r = %lu\n", - efi_ret & ~EFI_ERROR_MASK); - return 1; - } + image_buf = map_sysmem(images->ep, images->os.image_len); /* Run EFI image */ printf("## Transferring control to EFI (at address %08lx) ...\n", images->ep); bootstage_mark(BOOTSTAGE_ID_RUN_OS); - /* We expect to return */ - images->os.type = IH_TYPE_STANDALONE; - - image_buf = map_sysmem(images->ep, images->os.image_len); + ret = efi_binary_run(image_buf, images->os.image_len, + images->ft_len + ? images->ft_addr : EFI_FDT_USE_INTERNAL); - efi_ret = efi_run_image(image_buf, images->os.image_len); - if (efi_ret != EFI_SUCCESS) - return 1; - return 0; + return ret; } #endif diff --git a/boot/bootmeth_efi.c b/boot/bootmeth_efi.c index ae936c8daa18..2a9f29f9db5a 100644 --- a/boot/bootmeth_efi.c +++ b/boot/bootmeth_efi.c @@ -412,7 +412,6 @@ static int distro_efi_read_bootflow(struct udevice *dev, struct bootflow *bflow) static int distro_efi_boot(struct udevice *dev, struct bootflow *bflow) { ulong kernel, fdt; - char cmd[50]; int ret; kernel = env_get_hex("kernel_addr_r", 0); @@ -441,12 +440,7 @@ static int distro_efi_boot(struct udevice *dev, struct bootflow *bflow) fdt = env_get_hex("fdt_addr_r", 0); } - /* - * At some point we can add a real interface to bootefi so we can call - * this directly. For now, go through the CLI, like distro boot. - */ - snprintf(cmd, sizeof(cmd), "bootefi %lx %lx", kernel, fdt); - if (run_command(cmd, 0)) + if (efi_binary_run(map_sysmem(kernel, 0), 0, map_sysmem(fdt, 0))) return log_msg_ret("run", -EINVAL); return 0; diff --git a/boot/bootmeth_efi_mgr.c b/boot/bootmeth_efi_mgr.c index e9d973429f75..f2b47fac190f 100644 --- a/boot/bootmeth_efi_mgr.c +++ b/boot/bootmeth_efi_mgr.c @@ -14,6 +14,7 @@ #include #include #include +#include /** * struct efi_mgr_priv - private info for the efi-mgr driver @@ -70,7 +71,7 @@ static int efi_mgr_boot(struct udevice *dev, struct bootflow *bflow) int ret; /* Booting is handled by the 'bootefi bootmgr' command */ - ret = run_command("bootefi bootmgr", 0); + ret = efi_bootmgr_run(EFI_FDT_USE_INTERNAL); return 0; } diff --git a/cmd/Kconfig b/cmd/Kconfig index 825a41d68aad..81e959c96207 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -274,7 +274,7 @@ config CMD_BOOTMETH config BOOTM_EFI bool "Support booting UEFI FIT images" - depends on CMD_BOOTEFI && CMD_BOOTM && FIT + depends on BOOTEFI_BOOTMGR && CMD_BOOTM && FIT default y help Support booting UEFI FIT images via the bootm command. diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c index f5b2059140ac..47c552a94165 100644 --- a/test/boot/bootflow.c +++ b/test/boot/bootflow.c @@ -374,7 +374,7 @@ static int bootflow_system(struct unit_test_state *uts) { struct udevice *bootstd, *dev; - if (!IS_ENABLED(CONFIG_CMD_BOOTEFI_BOOTMGR)) + if (!IS_ENABLED(CONFIG_BOOTEFI_BOOTMGR)) return -EAGAIN; ut_assertok(uclass_first_device_err(UCLASS_BOOTSTD, &bootstd)); ut_assertok(device_bind(bootstd, DM_DRIVER_GET(bootmeth_efi_mgr), From patchwork Thu Oct 26 05:30:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 738325 Delivered-To: patch@linaro.org Received: by 2002:adf:f842:0:b0:32d:baff:b0ca with SMTP id d2csp638711wrq; Wed, 25 Oct 2023 22:32:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEectExuaaD1a6UMqcy5ObGdP/hqCp3m5vQvCFXcC/KakhHPQPwloebeCipyIFiRq1owlCC X-Received: by 2002:a05:6512:4014:b0:508:1975:5b1d with SMTP id br20-20020a056512401400b0050819755b1dmr3074710lfb.3.1698298373434; Wed, 25 Oct 2023 22:32:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698298373; cv=none; d=google.com; s=arc-20160816; b=N8ptUJRmk414ZErGyRC3H8wgSVmsW+uZTe7UwoBcXyVvoeoVgqFTru0YmJlAbXRP1p xFd/fYmvmZ8Zo2WpJdkyw71z1ZBJue5J6WLJM6I4KXnF2RuE75QurqjxpUrS4uyy8Kw+ EuoFBrMBdaPxCPlWzPO57nyLvwm9DGjFwSSm/gZAol11Va2N23bQYUW23duyva7JSWUn lqA2+sDSIZ9BVGxHKG9IojwVaP+PtmHU7tCoh240U/rsPYVAAL6FsPKdqpS3psoIh49g yv6vYlMgoY7C8U4leUEu4UyCfgogop+Q7PJ7gTi4yZ+Kp0tfNQl7Az0mfGFv2Mcyh6ax +u+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Mp+jJdsybsFZl/y8I7LNTzhx+AD5dMlIqa+WWExkuyo=; fh=RsKNQde3hXRhkFNkXZDJxhxJUE2DI5qQDMHikPj4pmY=; b=w0O5Z7rfCcuNv8TsEOd4yFxBkrH/kNVome9DvUBBj/mwf/9fg+Beplgnulmjim2VwH B6d/0rEbNM1EWJvp2GRAngPXevbfmjLn2uOko4n6lkCrXVaPsrKYsOml9Rfuzjmh/fRx NzsiSinCxAX5xt1rpxo4tDmhlQr9zm/MypgX1fGByf3nHTws1xH/goa06tKuMryl98pm fuoICl/mRxOY3D/hrx0RDCDfAyZNvyrSkJdE5+yfIjBfCZePxerzT3PWB/B6epGmXp0+ kZmN/jTz4dejUVgxPuB93mquaPNbxKU4iSXAKfKRhfYGS3xmT2RXo83DEa/dIqpi6izC e8BQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jbdCRyJI; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id m11-20020a056000024b00b003247a95fbaesi8345315wrz.411.2023.10.25.22.32.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 22:32:53 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jbdCRyJI; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CB3E787B25; Thu, 26 Oct 2023 07:31:47 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="jbdCRyJI"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4FEBE87B28; Thu, 26 Oct 2023 07:31:44 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 1050287B17 for ; Thu, 26 Oct 2023 07:31:40 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pf1-x42b.google.com with SMTP id d2e1a72fcca58-6bbfb8f7ac4so121642b3a.0 for ; Wed, 25 Oct 2023 22:31:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698298298; x=1698903098; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Mp+jJdsybsFZl/y8I7LNTzhx+AD5dMlIqa+WWExkuyo=; b=jbdCRyJIPwCpwpi+4JBszCN8XOZA+lmquN3uDYbG6qbLlx0EbJ+wGj1DL0FUOj2ao6 17jHA1rTOdmp0KEFVYDvYR/uxHWuhD+3Px6zC8sC6V5XQFSFseD2+9YLv9y8rFcLP1wK 1i1mV0SfofF6lxDy2BozByexJI+UIpZCKvSSRhGHy/tm7HuUSSTSbks4tokLIjgSzSQd O/6X6pPEBy4+qhmCDHy5GgvwY/nSnO5l0OJSMs6VpF9+mDwfzVK5zMPWnNrJukBNTzu/ C/hWa/oOiSt/E1zjNTL34gvMsUx4Z3wEbnEWgzr6+cZldr5iRhw15/HcBbiVW57NsInp STmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698298298; x=1698903098; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Mp+jJdsybsFZl/y8I7LNTzhx+AD5dMlIqa+WWExkuyo=; b=vLnpb5dfIlCGTlVNbhbDpA9TenXpS1SaFOJkP8bOCtIlrLYp1BELZs5zLOD2DWyp5Y oajj2g1nYq6IZm+81fkrlyAa5FqNBS1mG9RxKJA7ra9qdZRpgnMFxI0EAdYLdflVqs+S tBhwP72oVg3vSL/8TLAxAj8gRuzUoVMisuXOjvY382dczJGO5b8LB/b0IB0yAWS+pmfS cxPDv+Fcumz9OaLN7J0AAjRY3WLMX3Hm54v1iLHhjcWCkJu6pseWnNECSYEA48KvouPz g+oMBXSAJWBOWYiC9CRg8Ry8l67pxMI98745V8p6HHwNSVo88L919LZFnZll/Z8iCmXQ 3paA== X-Gm-Message-State: AOJu0YzhtjTg3cqO3bqZyrR0iSJ7NogzABdQEtOb49mElcUiHqmauKGZ u2otFZSR4WgI2tdD/2+2R3zUgSBb/yIwQfvw8RxP+g== X-Received: by 2002:a05:6a21:3286:b0:163:ab09:196d with SMTP id yt6-20020a056a21328600b00163ab09196dmr20200338pzb.1.1698298297975; Wed, 25 Oct 2023 22:31:37 -0700 (PDT) Received: from octopus.. ([2400:4050:c3e1:100:bca9:3af7:89e9:80b7]) by smtp.gmail.com with ESMTPSA id fa13-20020a056a002d0d00b006c06804cd39sm440715pfb.153.2023.10.25.22.31.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 22:31:37 -0700 (PDT) From: AKASHI Takahiro To: trini@konsulko.com, sjg@chromium.org, xypron.glpk@gmx.de, ilias.apalodimas@linaro.org Cc: jbx6244@gmail.com, u-boot@lists.denx.de, AKASHI Takahiro Subject: [RFC 08/13] efi_loader: split unrelated code from efi_bootmgr.c Date: Thu, 26 Oct 2023 14:30:47 +0900 Message-Id: <20231026053052.622453-9-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231026053052.622453-1-takahiro.akashi@linaro.org> References: <20231026053052.622453-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Some code moved from cmd/bootefi.c is actually necessary only for "bootefi " command (starting an image manually loaded by a user using U-Boot load commands or other methods (like JTAG debugger). The code will never been opted out as unused code by a compiler which doesn't know how EFI boot manager is implemented. So introduce a new configuration, CONFIG_EFI_BINARY_EXEC, to enforce theem opted out explicitly. Signed-off-by: AKASHI Takahiro --- boot/Kconfig | 4 +- cmd/Kconfig | 6 +- include/efi_loader.h | 28 +- lib/efi_loader/Kconfig | 9 + lib/efi_loader/efi_bootmgr.c | 480 ------------------------------ lib/efi_loader/efi_device_path.c | 3 +- lib/efi_loader/efi_helper.c | 486 ++++++++++++++++++++++++++++++- 7 files changed, 516 insertions(+), 500 deletions(-) diff --git a/boot/Kconfig b/boot/Kconfig index a441fac8ade1..d371d0a25962 100644 --- a/boot/Kconfig +++ b/boot/Kconfig @@ -511,7 +511,7 @@ config BOOTMETH_EXTLINUX_PXE config BOOTMETH_EFILOADER bool "Bootdev support for EFI boot" - depends on BOOTEFI_BOOTMGR + depends on EFI_BINARY_EXEC default y help Enables support for EFI boot using bootdevs. This makes the @@ -546,7 +546,7 @@ config BOOTMETH_DISTRO select BOOTMETH_SCRIPT if CMDLINE # E.g. Armbian uses scripts select BOOTMETH_EXTLINUX # E.g. Debian uses these select BOOTMETH_EXTLINUX_PXE if CMD_PXE && CMD_NET && DM_ETH - select BOOTMETH_EFILOADER if BOOTEFI_BOOTMGR # E.g. Ubuntu uses this + select BOOTMETH_EFILOADER if EFI_BINARY_EXEC # E.g. Ubuntu uses this config SPL_BOOTMETH_VBE bool "Bootdev support for Verified Boot for Embedded (SPL)" diff --git a/cmd/Kconfig b/cmd/Kconfig index 81e959c96207..bf16fad04d37 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -274,7 +274,7 @@ config CMD_BOOTMETH config BOOTM_EFI bool "Support booting UEFI FIT images" - depends on BOOTEFI_BOOTMGR && CMD_BOOTM && FIT + depends on EFI_BINARY_EXEC && CMD_BOOTM && FIT default y help Support booting UEFI FIT images via the bootm command. @@ -366,7 +366,7 @@ config CMD_BOOTEFI if CMD_BOOTEFI config CMD_BOOTEFI_BINARY bool "Allow booting an EFI binary directly" - depends on BOOTEFI_BOOTMGR + depends on EFI_BINARY_EXEC default y help Select this option to enable direct execution of binary at 'bootefi'. @@ -397,7 +397,7 @@ config CMD_BOOTEFI_HELLO_COMPILE config CMD_BOOTEFI_HELLO bool "Allow booting a standard EFI hello world for testing" - depends on CMD_BOOTEFI_HELLO_COMPILE + depends on CMD_BOOTEFI_BINARY && CMD_BOOTEFI_HELLO_COMPILE default y if CMD_BOOTEFI_SELFTEST help This adds a standard EFI hello world application to U-Boot so that diff --git a/include/efi_loader.h b/include/efi_loader.h index 031a8f76846a..e9bc2f540cc8 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -91,11 +91,7 @@ efi_status_t efi_add_runtime_mmio(void *mmio_ptr, u64 len); * back to u-boot world */ void efi_restore_gd(void); -/* Call this to unset the current device name */ -void efi_clear_bootdev(void); -/* Call this to set the current device name */ -void efi_set_bootdev(const char *dev, const char *devnr, const char *path, - void *buffer, size_t buffer_size); + /* Called by networking code to memorize the dhcp ack package */ void efi_net_set_dhcp_ack(void *pkt, int len); /* Print information about all loaded images */ @@ -117,10 +113,6 @@ static inline efi_status_t efi_add_runtime_mmio(void *mmio_ptr, u64 len) /* No loader configured, stub out EFI_ENTRY */ static inline void efi_restore_gd(void) { } -static inline void efi_clear_bootdev(void) { } -static inline void efi_set_bootdev(const char *dev, const char *devnr, - const char *path, void *buffer, - size_t buffer_size) { } static inline void efi_net_set_dhcp_ack(void *pkt, int len) { } static inline void efi_print_image_infos(void *pc) { } static inline efi_status_t efi_launch_capsules(void) @@ -130,6 +122,20 @@ static inline efi_status_t efi_launch_capsules(void) #endif /* CONFIG_IS_ENABLED(EFI_LOADER) */ +#if CONFIG_IS_ENABLED(EFI_BINARY_EXEC) +/* Call this to unset the current device name */ +void efi_clear_bootdev(void); +/* Call this to set the current device name */ +void efi_set_bootdev(const char *dev, const char *devnr, const char *path, + void *buffer, size_t buffer_size); +#else +static inline void efi_clear_bootdev(void) { } + +static inline void efi_set_bootdev(const char *dev, const char *devnr, + const char *path, void *buffer, + size_t buffer_size) { } +#endif + /* Maximum number of configuration tables */ #define EFI_MAX_CONFIGURATION_TABLES 16 @@ -540,8 +546,8 @@ efi_status_t efi_env_set_load_options(efi_handle_t handle, const char *env_var, u16 **load_options); /* Install device tree */ efi_status_t efi_install_fdt(void *fdt); -/* Run loaded UEFI image */ -efi_status_t efi_run_image(void *source_buffer, efi_uintn_t source_size); +/* Execute loaded UEFI image */ +efi_status_t do_bootefi_exec(efi_handle_t handle, void *load_options); /* Run loaded UEFI image with given fdt */ efi_status_t efi_binary_run(void *image, size_t size, void *fdt); /* Initialize variable services */ diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig index 13cad6342c36..987a990509f3 100644 --- a/lib/efi_loader/Kconfig +++ b/lib/efi_loader/Kconfig @@ -32,6 +32,15 @@ config EFI_LOADER if EFI_LOADER +config EFI_BINARY_EXEC + bool "Execute UEFI binary" + default y + help + Select this option if you want to execute the UEFI binary after + loading it with U-Boot load commands or other methods. + You may enable CMD_BOOTEFI_BINARY so that you can use bootefi + command to do that. + config BOOTEFI_BOOTMGR bool "UEFI Boot Manager" default y diff --git a/lib/efi_loader/efi_bootmgr.c b/lib/efi_loader/efi_bootmgr.c index cc8d88b4b025..06799277f5b5 100644 --- a/lib/efi_loader/efi_bootmgr.c +++ b/lib/efi_loader/efi_bootmgr.c @@ -3,8 +3,6 @@ * EFI boot manager * * Copyright (c) 2017 Rob Clark - * For the code moved from cmd/bootefi.c - * Copyright (c) 2016 Alexander Graf */ #define LOG_CATEGORY LOGC_EFI @@ -18,17 +16,6 @@ #include #include -/* TODO: temporarily added here; clean up later */ -#include -#include -#include -#include -#include -#include -#include - -DECLARE_GLOBAL_DATA_PTR; - static const struct efi_boot_services *bs; static const struct efi_runtime_services *rs; @@ -743,377 +730,6 @@ out: return ret; } -static struct efi_device_path *bootefi_image_path; -static struct efi_device_path *bootefi_device_path; -static void *image_addr; -static size_t image_size; - -/** - * efi_get_image_parameters() - return image parameters - * - * @img_addr: address of loaded image in memory - * @img_size: size of loaded image - */ -void efi_get_image_parameters(void **img_addr, size_t *img_size) -{ - *img_addr = image_addr; - *img_size = image_size; -} - -/** - * efi_clear_bootdev() - clear boot device - */ -void efi_clear_bootdev(void) -{ - efi_free_pool(bootefi_device_path); - efi_free_pool(bootefi_image_path); - bootefi_device_path = NULL; - bootefi_image_path = NULL; - image_addr = NULL; - image_size = 0; -} - -/** - * efi_set_bootdev() - set boot device - * - * This function is called when a file is loaded, e.g. via the 'load' command. - * We use the path to this file to inform the UEFI binary about the boot device. - * - * @dev: device, e.g. "MMC" - * @devnr: number of the device, e.g. "1:2" - * @path: path to file loaded - * @buffer: buffer with file loaded - * @buffer_size: size of file loaded - */ -void efi_set_bootdev(const char *dev, const char *devnr, const char *path, - void *buffer, size_t buffer_size) -{ - struct efi_device_path *device, *image; - efi_status_t ret; - - log_debug("dev=%s, devnr=%s, path=%s, buffer=%p, size=%zx\n", dev, - devnr, path, buffer, buffer_size); - - /* Forget overwritten image */ - if (buffer + buffer_size >= image_addr && - image_addr + image_size >= buffer) - efi_clear_bootdev(); - - /* Remember only PE-COFF and FIT images */ - if (efi_check_pe(buffer, buffer_size, NULL) != EFI_SUCCESS) { - if (IS_ENABLED(CONFIG_FIT) && - !fit_check_format(buffer, IMAGE_SIZE_INVAL)) { - /* - * FIT images of type EFI_OS are started via command - * bootm. We should not use their boot device with the - * bootefi command. - */ - buffer = 0; - buffer_size = 0; - } else { - log_debug("- not remembering image\n"); - return; - } - } - - /* efi_set_bootdev() is typically called repeatedly, recover memory */ - efi_clear_bootdev(); - - image_addr = buffer; - image_size = buffer_size; - - ret = efi_dp_from_name(dev, devnr, path, &device, &image); - if (ret == EFI_SUCCESS) { - bootefi_device_path = device; - if (image) { - /* FIXME: image should not contain device */ - struct efi_device_path *image_tmp = image; - - efi_dp_split_file_path(image, &device, &image); - efi_free_pool(image_tmp); - } - bootefi_image_path = image; - log_debug("- boot device %pD\n", device); - if (image) - log_debug("- image %pD\n", image); - } else { - log_debug("- efi_dp_from_name() failed, err=%lx\n", ret); - efi_clear_bootdev(); - } -} - -/** - * efi_env_set_load_options() - set load options from environment variable - * - * @handle: the image handle - * @env_var: name of the environment variable - * @load_options: pointer to load options (output) - * Return: status code - */ -efi_status_t efi_env_set_load_options(efi_handle_t handle, - const char *env_var, - u16 **load_options) -{ - const char *env = env_get(env_var); - size_t size; - u16 *pos; - efi_status_t ret; - - *load_options = NULL; - if (!env) - return EFI_SUCCESS; - size = sizeof(u16) * (utf8_utf16_strlen(env) + 1); - pos = calloc(size, 1); - if (!pos) - return EFI_OUT_OF_RESOURCES; - *load_options = pos; - utf8_utf16_strcpy(&pos, env); - ret = efi_set_load_options(handle, size, *load_options); - if (ret != EFI_SUCCESS) { - free(*load_options); - *load_options = NULL; - } - return ret; -} - -#if !CONFIG_IS_ENABLED(GENERATE_ACPI_TABLE) - -/** - * copy_fdt() - Copy the device tree to a new location available to EFI - * - * The FDT is copied to a suitable location within the EFI memory map. - * Additional 12 KiB are added to the space in case the device tree needs to be - * expanded later with fdt_open_into(). - * - * @fdtp: On entry a pointer to the flattened device tree. - * On exit a pointer to the copy of the flattened device tree. - * FDT start - * Return: status code - */ -static efi_status_t copy_fdt(void **fdtp) -{ - unsigned long fdt_ram_start = -1L, fdt_pages; - efi_status_t ret = 0; - void *fdt, *new_fdt; - u64 new_fdt_addr; - uint fdt_size; - int i; - - for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) { - u64 ram_start = gd->bd->bi_dram[i].start; - u64 ram_size = gd->bd->bi_dram[i].size; - - if (!ram_size) - continue; - - if (ram_start < fdt_ram_start) - fdt_ram_start = ram_start; - } - - /* - * Give us at least 12 KiB of breathing room in case the device tree - * needs to be expanded later. - */ - fdt = *fdtp; - fdt_pages = efi_size_in_pages(fdt_totalsize(fdt) + 0x3000); - fdt_size = fdt_pages << EFI_PAGE_SHIFT; - - ret = efi_allocate_pages(EFI_ALLOCATE_ANY_PAGES, - EFI_ACPI_RECLAIM_MEMORY, fdt_pages, - &new_fdt_addr); - if (ret != EFI_SUCCESS) { - log_err("ERROR: Failed to reserve space for FDT\n"); - goto done; - } - new_fdt = (void *)(uintptr_t)new_fdt_addr; - memcpy(new_fdt, fdt, fdt_totalsize(fdt)); - fdt_set_totalsize(new_fdt, fdt_size); - - *fdtp = (void *)(uintptr_t)new_fdt_addr; -done: - return ret; -} - -/** - * get_config_table() - get configuration table - * - * @guid: GUID of the configuration table - * Return: pointer to configuration table or NULL - */ -static void *get_config_table(const efi_guid_t *guid) -{ - size_t i; - - for (i = 0; i < systab.nr_tables; i++) { - if (!guidcmp(guid, &systab.tables[i].guid)) - return systab.tables[i].table; - } - return NULL; -} - -#endif /* !CONFIG_IS_ENABLED(GENERATE_ACPI_TABLE) */ - -/** - * efi_install_fdt() - install device tree - * - * If fdt is not EFI_FDT_USE_INTERNAL, the device tree located at that memory - * address will be installed as configuration table, otherwise the device - * tree located at the address indicated by environment variable fdt_addr or as - * fallback fdtcontroladdr will be used. - * - * On architectures using ACPI tables device trees shall not be installed as - * configuration table. - * - * @fdt: address of device tree or EFI_FDT_USE_INTERNAL to use - * the hardware device tree as indicated by environment variable - * fdt_addr or as fallback the internal device tree as indicated by - * the environment variable fdtcontroladdr - * Return: status code - */ -efi_status_t efi_install_fdt(void *fdt) -{ - /* - * The EBBR spec requires that we have either an FDT or an ACPI table - * but not both. - */ -#if CONFIG_IS_ENABLED(GENERATE_ACPI_TABLE) - if (fdt) { - log_warning("WARNING: Can't have ACPI table and device tree - ignoring DT.\n"); - return EFI_SUCCESS; - } -#else - struct bootm_headers img = { 0 }; - efi_status_t ret; - - if (fdt == EFI_FDT_USE_INTERNAL) { - const char *fdt_opt; - uintptr_t fdt_addr; - - /* Look for device tree that is already installed */ - if (get_config_table(&efi_guid_fdt)) - return EFI_SUCCESS; - /* Check if there is a hardware device tree */ - fdt_opt = env_get("fdt_addr"); - /* Use our own device tree as fallback */ - if (!fdt_opt) { - fdt_opt = env_get("fdtcontroladdr"); - if (!fdt_opt) { - log_err("ERROR: need device tree\n"); - return EFI_NOT_FOUND; - } - } - fdt_addr = hextoul(fdt_opt, NULL); - if (!fdt_addr) { - log_err("ERROR: invalid $fdt_addr or $fdtcontroladdr\n"); - return EFI_LOAD_ERROR; - } - fdt = map_sysmem(fdt_addr, 0); - } - - /* Install device tree */ - if (fdt_check_header(fdt)) { - log_err("ERROR: invalid device tree\n"); - return EFI_LOAD_ERROR; - } - - /* Prepare device tree for payload */ - ret = copy_fdt(&fdt); - if (ret) { - log_err("ERROR: out of memory\n"); - return EFI_OUT_OF_RESOURCES; - } - - if (image_setup_libfdt(&img, fdt, 0, NULL)) { - log_err("ERROR: failed to process device tree\n"); - return EFI_LOAD_ERROR; - } - - /* Create memory reservations as indicated by the device tree */ - efi_carve_out_dt_rsv(fdt); - - efi_try_purge_kaslr_seed(fdt); - - if (CONFIG_IS_ENABLED(EFI_TCG2_PROTOCOL_MEASURE_DTB)) { - ret = efi_tcg2_measure_dtb(fdt); - if (ret == EFI_SECURITY_VIOLATION) { - log_err("ERROR: failed to measure DTB\n"); - return ret; - } - } - - /* Install device tree as UEFI table */ - ret = efi_install_configuration_table(&efi_guid_fdt, fdt); - if (ret != EFI_SUCCESS) { - log_err("ERROR: failed to install device tree\n"); - return ret; - } -#endif /* GENERATE_ACPI_TABLE */ - - return EFI_SUCCESS; -} - -/** - * do_bootefi_exec() - execute EFI binary - * - * The image indicated by @handle is started. When it returns the allocated - * memory for the @load_options is freed. - * - * @handle: handle of loaded image - * @load_options: load options - * Return: status code - * - * Load the EFI binary into a newly assigned memory unwinding the relocation - * information, install the loaded image protocol, and call the binary. - */ -static efi_status_t do_bootefi_exec(efi_handle_t handle, void *load_options) -{ - efi_status_t ret; - efi_uintn_t exit_data_size = 0; - u16 *exit_data = NULL; - - /* On ARM switch from EL3 or secure mode to EL2 or non-secure mode */ - switch_to_non_secure_mode(); - - /* - * The UEFI standard requires that the watchdog timer is set to five - * minutes when invoking an EFI boot option. - * - * Unified Extensible Firmware Interface (UEFI), version 2.7 Errata A - * 7.5. Miscellaneous Boot Services - EFI_BOOT_SERVICES.SetWatchdogTimer - */ - ret = efi_set_watchdog(300); - if (ret != EFI_SUCCESS) { - log_err("ERROR: Failed to set watchdog timer\n"); - goto out; - } - - /* Call our payload! */ - ret = EFI_CALL(efi_start_image(handle, &exit_data_size, &exit_data)); - if (ret != EFI_SUCCESS) { - log_err("## Application failed, r = %lu\n", - ret & ~EFI_ERROR_MASK); - if (exit_data) { - log_err("## %ls\n", exit_data); - efi_free_pool(exit_data); - } - } - - efi_restore_gd(); - -out: - free(load_options); - - if (IS_ENABLED(CONFIG_EFI_LOAD_FILE2_INITRD)) { - if (efi_initrd_deregister() != EFI_SUCCESS) - log_err("Failed to remove loadfile2 for initrd\n"); - } - - /* Control is returned to U-Boot, disable EFI watchdog */ - efi_set_watchdog(0); - - return ret; -} - /** * efi_bootmgr_run() - execute EFI boot manager * fdt: Flat device tree @@ -1150,99 +766,3 @@ efi_status_t efi_bootmgr_run(void *fdt) return do_bootefi_exec(handle, load_options); } - -/** - * efi_run_image() - run loaded UEFI image - * - * @source_buffer: memory address of the UEFI image - * @source_size: size of the UEFI image - * Return: status code - */ -efi_status_t efi_run_image(void *source_buffer, efi_uintn_t source_size) -{ - efi_handle_t mem_handle = NULL, handle; - struct efi_device_path *file_path = NULL; - struct efi_device_path *msg_path; - efi_status_t ret, ret2; - u16 *load_options; - - if (!bootefi_device_path || !bootefi_image_path) { - log_debug("Not loaded from disk\n"); - /* - * Special case for efi payload not loaded from disk, - * such as 'bootefi hello' or for example payload - * loaded directly into memory via JTAG, etc: - */ - file_path = efi_dp_from_mem(EFI_RESERVED_MEMORY_TYPE, - (uintptr_t)source_buffer, - source_size); - /* - * Make sure that device for device_path exist - * in load_image(). Otherwise, shell and grub will fail. - */ - ret = efi_install_multiple_protocol_interfaces(&mem_handle, - &efi_guid_device_path, - file_path, NULL); - if (ret != EFI_SUCCESS) - goto out; - msg_path = file_path; - } else { - file_path = efi_dp_append(bootefi_device_path, - bootefi_image_path); - msg_path = bootefi_image_path; - log_debug("Loaded from disk\n"); - } - - log_info("Booting %pD\n", msg_path); - - ret = EFI_CALL(efi_load_image(false, efi_root, file_path, source_buffer, - source_size, &handle)); - if (ret != EFI_SUCCESS) { - log_err("Loading image failed\n"); - goto out; - } - - /* Transfer environment variable as load options */ - ret = efi_env_set_load_options(handle, "bootargs", &load_options); - if (ret != EFI_SUCCESS) - goto out; - - ret = do_bootefi_exec(handle, load_options); - -out: - ret2 = efi_uninstall_multiple_protocol_interfaces(mem_handle, - &efi_guid_device_path, - file_path, NULL); - efi_free_pool(file_path); - return (ret != EFI_SUCCESS) ? ret : ret2; -} - -/** - * efi_binary_run() - run loaded UEFI image - * - * @image: memory address of the UEFI image - * @size: size of the UEFI image - * - * Execute an EFI binary image loaded at @image. - * @size may be zero if the binary is loaded with U-Boot load command. - * - * Return: status code - */ -efi_status_t efi_binary_run(void *image, size_t size, void *fdt) -{ - efi_status_t ret; - - /* Initialize EFI drivers */ - ret = efi_init_obj_list(); - if (ret != EFI_SUCCESS) { - log_err("Error: Cannot initialize UEFI sub-system, r = %lu\n", - ret & ~EFI_ERROR_MASK); - return -1; - } - - ret = efi_install_fdt(fdt); - if (ret != EFI_SUCCESS) - return ret; - - return efi_run_image(image, size); -} diff --git a/lib/efi_loader/efi_device_path.c b/lib/efi_loader/efi_device_path.c index ed7214f3a347..786d8a70e2ad 100644 --- a/lib/efi_loader/efi_device_path.c +++ b/lib/efi_loader/efi_device_path.c @@ -1090,7 +1090,8 @@ efi_status_t efi_dp_from_name(const char *dev, const char *devnr, if (path && !file) return EFI_INVALID_PARAMETER; - if (!strcmp(dev, "Mem") || !strcmp(dev, "hostfs")) { + if (IS_ENABLED(CONFIG_EFI_BINARY_EXEC) && + (!strcmp(dev, "Mem") || !strcmp(dev, "hostfs"))) { /* loadm command and semihosting */ efi_get_image_parameters(&image_addr, &image_size); diff --git a/lib/efi_loader/efi_helper.c b/lib/efi_loader/efi_helper.c index cdfd16ea7742..dd8c38f0cb5c 100644 --- a/lib/efi_loader/efi_helper.c +++ b/lib/efi_loader/efi_helper.c @@ -1,17 +1,28 @@ // SPDX-License-Identifier: GPL-2.0+ /* * Copyright (c) 2020, Linaro Limited + * For the code moved from cmd/bootefi.c + * Copyright (c) 2016 Alexander Graf */ #define LOG_CATEGORY LOGC_EFI +#include #include -#include -#include #include -#include #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +DECLARE_GLOBAL_DATA_PTR; #if defined(CONFIG_CMD_EFIDEBUG) || defined(CONFIG_EFI_LOAD_FILE2_INITRD) /* GUID used by Linux to identify the LoadFile2 protocol with the initrd */ @@ -282,3 +293,472 @@ bool efi_search_bootorder(u16 *bootorder, efi_uintn_t num, u32 target, u32 *inde return false; } + +#if !CONFIG_IS_ENABLED(GENERATE_ACPI_TABLE) + +/** + * copy_fdt() - Copy the device tree to a new location available to EFI + * + * The FDT is copied to a suitable location within the EFI memory map. + * Additional 12 KiB are added to the space in case the device tree needs to be + * expanded later with fdt_open_into(). + * + * @fdtp: On entry a pointer to the flattened device tree. + * On exit a pointer to the copy of the flattened device tree. + * FDT start + * Return: status code + */ +static efi_status_t copy_fdt(void **fdtp) +{ + unsigned long fdt_ram_start = -1L, fdt_pages; + efi_status_t ret = 0; + void *fdt, *new_fdt; + u64 new_fdt_addr; + uint fdt_size; + int i; + + for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) { + u64 ram_start = gd->bd->bi_dram[i].start; + u64 ram_size = gd->bd->bi_dram[i].size; + + if (!ram_size) + continue; + + if (ram_start < fdt_ram_start) + fdt_ram_start = ram_start; + } + + /* + * Give us at least 12 KiB of breathing room in case the device tree + * needs to be expanded later. + */ + fdt = *fdtp; + fdt_pages = efi_size_in_pages(fdt_totalsize(fdt) + 0x3000); + fdt_size = fdt_pages << EFI_PAGE_SHIFT; + + ret = efi_allocate_pages(EFI_ALLOCATE_ANY_PAGES, + EFI_ACPI_RECLAIM_MEMORY, fdt_pages, + &new_fdt_addr); + if (ret != EFI_SUCCESS) { + log_err("ERROR: Failed to reserve space for FDT\n"); + goto done; + } + new_fdt = (void *)(uintptr_t)new_fdt_addr; + memcpy(new_fdt, fdt, fdt_totalsize(fdt)); + fdt_set_totalsize(new_fdt, fdt_size); + + *fdtp = (void *)(uintptr_t)new_fdt_addr; +done: + return ret; +} + +/** + * get_config_table() - get configuration table + * + * @guid: GUID of the configuration table + * Return: pointer to configuration table or NULL + */ +static void *get_config_table(const efi_guid_t *guid) +{ + size_t i; + + for (i = 0; i < systab.nr_tables; i++) { + if (!guidcmp(guid, &systab.tables[i].guid)) + return systab.tables[i].table; + } + return NULL; +} + +#endif /* !CONFIG_IS_ENABLED(GENERATE_ACPI_TABLE) */ + +/** + * efi_install_fdt() - install device tree + * + * If fdt is not EFI_FDT_USE_INTERNAL, the device tree located at that memory + * address will be installed as configuration table, otherwise the device + * tree located at the address indicated by environment variable fdt_addr or as + * fallback fdtcontroladdr will be used. + * + * On architectures using ACPI tables device trees shall not be installed as + * configuration table. + * + * @fdt: address of device tree or EFI_FDT_USE_INTERNAL to use + * the hardware device tree as indicated by environment variable + * fdt_addr or as fallback the internal device tree as indicated by + * the environment variable fdtcontroladdr + * Return: status code + */ +efi_status_t efi_install_fdt(void *fdt) +{ + /* + * The EBBR spec requires that we have either an FDT or an ACPI table + * but not both. + */ +#if CONFIG_IS_ENABLED(GENERATE_ACPI_TABLE) + if (fdt) { + log_warning("WARNING: Can't have ACPI table and device tree - ignoring DT.\n"); + return EFI_SUCCESS; + } +#else + struct bootm_headers img = { 0 }; + efi_status_t ret; + + if (fdt == EFI_FDT_USE_INTERNAL) { + const char *fdt_opt; + uintptr_t fdt_addr; + + /* Look for device tree that is already installed */ + if (get_config_table(&efi_guid_fdt)) + return EFI_SUCCESS; + /* Check if there is a hardware device tree */ + fdt_opt = env_get("fdt_addr"); + /* Use our own device tree as fallback */ + if (!fdt_opt) { + fdt_opt = env_get("fdtcontroladdr"); + if (!fdt_opt) { + log_err("ERROR: need device tree\n"); + return EFI_NOT_FOUND; + } + } + fdt_addr = hextoul(fdt_opt, NULL); + if (!fdt_addr) { + log_err("ERROR: invalid $fdt_addr or $fdtcontroladdr\n"); + return EFI_LOAD_ERROR; + } + fdt = map_sysmem(fdt_addr, 0); + } + + /* Install device tree */ + if (fdt_check_header(fdt)) { + log_err("ERROR: invalid device tree\n"); + return EFI_LOAD_ERROR; + } + + /* Prepare device tree for payload */ + ret = copy_fdt(&fdt); + if (ret) { + log_err("ERROR: out of memory\n"); + return EFI_OUT_OF_RESOURCES; + } + + if (image_setup_libfdt(&img, fdt, 0, NULL)) { + log_err("ERROR: failed to process device tree\n"); + return EFI_LOAD_ERROR; + } + + /* Create memory reservations as indicated by the device tree */ + efi_carve_out_dt_rsv(fdt); + + efi_try_purge_kaslr_seed(fdt); + + if (CONFIG_IS_ENABLED(EFI_TCG2_PROTOCOL_MEASURE_DTB)) { + ret = efi_tcg2_measure_dtb(fdt); + if (ret == EFI_SECURITY_VIOLATION) { + log_err("ERROR: failed to measure DTB\n"); + return ret; + } + } + + /* Install device tree as UEFI table */ + ret = efi_install_configuration_table(&efi_guid_fdt, fdt); + if (ret != EFI_SUCCESS) { + log_err("ERROR: failed to install device tree\n"); + return ret; + } +#endif /* GENERATE_ACPI_TABLE */ + + return EFI_SUCCESS; +} + +/** + * do_bootefi_exec() - execute EFI binary + * + * The image indicated by @handle is started. When it returns the allocated + * memory for the @load_options is freed. + * + * @handle: handle of loaded image + * @load_options: load options + * Return: status code + * + * Load the EFI binary into a newly assigned memory unwinding the relocation + * information, install the loaded image protocol, and call the binary. + */ +efi_status_t do_bootefi_exec(efi_handle_t handle, void *load_options) +{ + efi_status_t ret; + efi_uintn_t exit_data_size = 0; + u16 *exit_data = NULL; + + /* On ARM switch from EL3 or secure mode to EL2 or non-secure mode */ + switch_to_non_secure_mode(); + + /* + * The UEFI standard requires that the watchdog timer is set to five + * minutes when invoking an EFI boot option. + * + * Unified Extensible Firmware Interface (UEFI), version 2.7 Errata A + * 7.5. Miscellaneous Boot Services - EFI_BOOT_SERVICES.SetWatchdogTimer + */ + ret = efi_set_watchdog(300); + if (ret != EFI_SUCCESS) { + log_err("ERROR: Failed to set watchdog timer\n"); + goto out; + } + + /* Call our payload! */ + ret = EFI_CALL(efi_start_image(handle, &exit_data_size, &exit_data)); + if (ret != EFI_SUCCESS) { + log_err("## Application failed, r = %lu\n", + ret & ~EFI_ERROR_MASK); + if (exit_data) { + log_err("## %ls\n", exit_data); + efi_free_pool(exit_data); + } + } + + efi_restore_gd(); + +out: + free(load_options); + + if (IS_ENABLED(CONFIG_EFI_LOAD_FILE2_INITRD)) { + if (efi_initrd_deregister() != EFI_SUCCESS) + log_err("Failed to remove loadfile2 for initrd\n"); + } + + /* Control is returned to U-Boot, disable EFI watchdog */ + efi_set_watchdog(0); + + return ret; +} + +#if CONFIG_IS_ENABLED(EFI_BINARY_EXEC) +static struct efi_device_path *bootefi_image_path; +static struct efi_device_path *bootefi_device_path; +static void *image_addr; +static size_t image_size; + +/** + * efi_get_image_parameters() - return image parameters + * + * @img_addr: address of loaded image in memory + * @img_size: size of loaded image + */ +void efi_get_image_parameters(void **img_addr, size_t *img_size) +{ + *img_addr = image_addr; + *img_size = image_size; +} + +/** + * efi_clear_bootdev() - clear boot device + */ +void efi_clear_bootdev(void) +{ + efi_free_pool(bootefi_device_path); + efi_free_pool(bootefi_image_path); + bootefi_device_path = NULL; + bootefi_image_path = NULL; + image_addr = NULL; + image_size = 0; +} + +/** + * efi_set_bootdev() - set boot device + * + * This function is called when a file is loaded, e.g. via the 'load' command. + * We use the path to this file to inform the UEFI binary about the boot device. + * + * @dev: device, e.g. "MMC" + * @devnr: number of the device, e.g. "1:2" + * @path: path to file loaded + * @buffer: buffer with file loaded + * @buffer_size: size of file loaded + */ +void efi_set_bootdev(const char *dev, const char *devnr, const char *path, + void *buffer, size_t buffer_size) +{ + struct efi_device_path *device, *image; + efi_status_t ret; + + log_debug("dev=%s, devnr=%s, path=%s, buffer=%p, size=%zx\n", dev, + devnr, path, buffer, buffer_size); + + /* Forget overwritten image */ + if (buffer + buffer_size >= image_addr && + image_addr + image_size >= buffer) + efi_clear_bootdev(); + + /* Remember only PE-COFF and FIT images */ + if (efi_check_pe(buffer, buffer_size, NULL) != EFI_SUCCESS) { + if (IS_ENABLED(CONFIG_FIT) && + !fit_check_format(buffer, IMAGE_SIZE_INVAL)) { + /* + * FIT images of type EFI_OS are started via command + * bootm. We should not use their boot device with the + * bootefi command. + */ + buffer = 0; + buffer_size = 0; + } else { + log_debug("- not remembering image\n"); + return; + } + } + + /* efi_set_bootdev() is typically called repeatedly, recover memory */ + efi_clear_bootdev(); + + image_addr = buffer; + image_size = buffer_size; + + ret = efi_dp_from_name(dev, devnr, path, &device, &image); + if (ret == EFI_SUCCESS) { + bootefi_device_path = device; + if (image) { + /* FIXME: image should not contain device */ + struct efi_device_path *image_tmp = image; + + efi_dp_split_file_path(image, &device, &image); + efi_free_pool(image_tmp); + } + bootefi_image_path = image; + log_debug("- boot device %pD\n", device); + if (image) + log_debug("- image %pD\n", image); + } else { + log_debug("- efi_dp_from_name() failed, err=%lx\n", ret); + efi_clear_bootdev(); + } +} + +/** + * efi_env_set_load_options() - set load options from environment variable + * + * @handle: the image handle + * @env_var: name of the environment variable + * @load_options: pointer to load options (output) + * Return: status code + */ +efi_status_t efi_env_set_load_options(efi_handle_t handle, + const char *env_var, + u16 **load_options) +{ + const char *env = env_get(env_var); + size_t size; + u16 *pos; + efi_status_t ret; + + *load_options = NULL; + if (!env) + return EFI_SUCCESS; + size = sizeof(u16) * (utf8_utf16_strlen(env) + 1); + pos = calloc(size, 1); + if (!pos) + return EFI_OUT_OF_RESOURCES; + *load_options = pos; + utf8_utf16_strcpy(&pos, env); + ret = efi_set_load_options(handle, size, *load_options); + if (ret != EFI_SUCCESS) { + free(*load_options); + *load_options = NULL; + } + return ret; +} + +/** + * efi_run_image() - run loaded UEFI image + * + * @source_buffer: memory address of the UEFI image + * @source_size: size of the UEFI image + * Return: status code + */ +static efi_status_t efi_run_image(void *source_buffer, efi_uintn_t source_size) +{ + efi_handle_t mem_handle = NULL, handle; + struct efi_device_path *file_path = NULL; + struct efi_device_path *msg_path; + efi_status_t ret, ret2; + u16 *load_options; + + if (!bootefi_device_path || !bootefi_image_path) { + log_debug("Not loaded from disk\n"); + /* + * Special case for efi payload not loaded from disk, + * such as 'bootefi hello' or for example payload + * loaded directly into memory via JTAG, etc: + */ + file_path = efi_dp_from_mem(EFI_RESERVED_MEMORY_TYPE, + (uintptr_t)source_buffer, + source_size); + /* + * Make sure that device for device_path exist + * in load_image(). Otherwise, shell and grub will fail. + */ + ret = efi_install_multiple_protocol_interfaces(&mem_handle, + &efi_guid_device_path, + file_path, NULL); + if (ret != EFI_SUCCESS) + goto out; + msg_path = file_path; + } else { + file_path = efi_dp_append(bootefi_device_path, + bootefi_image_path); + msg_path = bootefi_image_path; + log_debug("Loaded from disk\n"); + } + + log_info("Booting %pD\n", msg_path); + + ret = EFI_CALL(efi_load_image(false, efi_root, file_path, source_buffer, + source_size, &handle)); + if (ret != EFI_SUCCESS) { + log_err("Loading image failed\n"); + goto out; + } + + /* Transfer environment variable as load options */ + ret = efi_env_set_load_options(handle, "bootargs", &load_options); + if (ret != EFI_SUCCESS) + goto out; + + ret = do_bootefi_exec(handle, load_options); + +out: + ret2 = efi_uninstall_multiple_protocol_interfaces(mem_handle, + &efi_guid_device_path, + file_path, NULL); + efi_free_pool(file_path); + return (ret != EFI_SUCCESS) ? ret : ret2; +} + +/** + * efi_binary_run() - run loaded UEFI image + * + * @image: memory address of the UEFI image + * @size: size of the UEFI image + * + * Execute an EFI binary image loaded at @image. + * @size may be zero if the binary is loaded with U-Boot load command. + * + * Return: status code + */ +efi_status_t efi_binary_run(void *image, size_t size, void *fdt) +{ + efi_status_t ret; + + /* Initialize EFI drivers */ + ret = efi_init_obj_list(); + if (ret != EFI_SUCCESS) { + log_err("Error: Cannot initialize UEFI sub-system, r = %lu\n", + ret & ~EFI_ERROR_MASK); + return ret; + } + + ret = efi_install_fdt(fdt); + if (ret != EFI_SUCCESS) + return ret; + + return efi_run_image(image, size); +} +#endif /* CONFIG_EFI_BINARY_EXEC */ From patchwork Thu Oct 26 05:30:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 738326 Delivered-To: patch@linaro.org Received: by 2002:adf:f842:0:b0:32d:baff:b0ca with SMTP id d2csp638810wrq; Wed, 25 Oct 2023 22:33:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHID7J991zZav0RNYVtDSq3AoBTjgh9HOPOV8isshjVILf7iaYCNSCGPzDCy56cKUKYMpGp X-Received: by 2002:a2e:a549:0:b0:2c5:1a20:3ea9 with SMTP id e9-20020a2ea549000000b002c51a203ea9mr12477304ljn.40.1698298393364; Wed, 25 Oct 2023 22:33:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698298393; cv=none; d=google.com; s=arc-20160816; b=ZqqCDS02NGOoO2ihhx0noUT05oBRYTiitH32Po+TD8VrE9pIJI7+bm8KUc/WZl6x6p eTvDdHjSGdUsff+GeEB6P/ImJyOqGUIdhxTJwR0bdtsBPQ10jgGOs0BopI8vS6PmE2q7 BISwSesGF/pbt1+9rjoDrR7U9iV7YQ4s/GMyG67fCUeTMu0mfvUpNpyE/skJZ5qEBS90 EgZzsHH47c634owdSJVpU5mUnYH5328ejgn/JxN9Sfrg+9680GhDV6WEdwtYNiq/OA9q VLfUoE8u7VDjjcUCFVtlUbRhRu2H3ulgEV5ecYE6wNQt3vdR79d9Hbv7umKCix7LmvMB 375g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=hzM3GADLVfsOYyYUTe9ShM0/j77yEgOVI6Qe6mqlMxI=; fh=RsKNQde3hXRhkFNkXZDJxhxJUE2DI5qQDMHikPj4pmY=; b=UWT7/NYDQGa6NimGz5If3NUGpApPa8ZYkUKX0wHJG31XQRzctMW+XsyD4gA3UGMuvW CEVChiFwasvPLSiufv3nLQPjDHsi2tN6ADG7RYlhYnwSHr+QgpzlydNZbNvO7Hr5UwQ8 zNEKly0DKOOjY8ogbS5EJvwJf7tJX59lbkC9B03Vs2sUpsXq5CkjlIdhHZ218s/UEoen tUM9hxXtoxAGgpL1A0/fDj6/5v+OKpmzVlf/AsdPIE+7kxe+ifXYwtvrbhmStpHN08ew ZG2z84axJtjLXUtOgOM6DxoSohUSnrszTDr1nSjSepsMpgplnsw2Gx+evkiMsw35khTg D+jA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SvaD8gPf; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id fc10-20020a05600c524a00b0040670f20ec4si1121872wmb.28.2023.10.25.22.33.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 22:33:13 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SvaD8gPf; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 44A2F87B31; Thu, 26 Oct 2023 07:31:49 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="SvaD8gPf"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id EA5AB87B28; Thu, 26 Oct 2023 07:31:44 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 38DC287B1D for ; Thu, 26 Oct 2023 07:31:42 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pf1-x42a.google.com with SMTP id d2e1a72fcca58-6bb744262caso113153b3a.0 for ; Wed, 25 Oct 2023 22:31:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698298300; x=1698903100; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=hzM3GADLVfsOYyYUTe9ShM0/j77yEgOVI6Qe6mqlMxI=; b=SvaD8gPfp7VFlNnQcWD4WlJh2nnrgwEDOU2Eze7indAM7pil8uj4LXE7FKZvFF7ZZZ /JIyWwSTzLoQqsVx6xPCVy5kk1KCivpTtj9jKZa9C6RSBP4P0eR/Cyb7XTygVhnnAwuG Hb2lTFoLn4fTpBOH+kbksPu+sIbQFDUhhsky8OkS2sK2rpvg2LoilU3VaRGBDTwWNKVL PqdVHz4Vl5Wy/GfnVK8IZ2ByxaC/HCsol17lNmasHVElU1z8mywqblBBXO9klJjYge5l 1me+o+VftPdtl5I7VXNsgk5kgxZ5D+rXK+bIIUL2youKW1cqIA6uChB/7PRKf8aTHbu2 ERdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698298300; x=1698903100; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hzM3GADLVfsOYyYUTe9ShM0/j77yEgOVI6Qe6mqlMxI=; b=DxpGYPghJ2YZBKiLn/zJmFDiRFcxTK+ozkawybzzs2IFKELZSqO628iXTNEIHmOt+d 9hM+beqLKSrmBAL7ZA4tnchP5GGeeARyam5rxgKRMyG5bspSC1mCfOkVYmzvbgzJazng KdMzIQ3Hgdf81cp0Jll7399QFo8j1JV85EaQJ57n4OIp2tqk9mERCj0TM7pkfLH4KKCP bTFG85fpBf64Fpk1uG+JVymBceLSppmcckMuH9B9Z2y/w3Vv6JlnBLb50fP8XKiGcZj4 AN9ZqCFJ69XGz5nCp0B1pPwuF+ZiY7bw7mejj/CB8/tuAsTVXRkY+UBrBOHApBxyVPr0 iH2A== X-Gm-Message-State: AOJu0YzV8W74Gg6UT6D7fsdHwVVEvz5jGKGNT7YYkORmYuXCDojtCxtk 66gZGZkLV3tCoz8hBvZWzClOTg== X-Received: by 2002:a05:6a21:33a4:b0:163:c167:964a with SMTP id yy36-20020a056a2133a400b00163c167964amr21429946pzb.1.1698298300114; Wed, 25 Oct 2023 22:31:40 -0700 (PDT) Received: from octopus.. ([2400:4050:c3e1:100:bca9:3af7:89e9:80b7]) by smtp.gmail.com with ESMTPSA id fa13-20020a056a002d0d00b006c06804cd39sm440715pfb.153.2023.10.25.22.31.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 22:31:39 -0700 (PDT) From: AKASHI Takahiro To: trini@konsulko.com, sjg@chromium.org, xypron.glpk@gmx.de, ilias.apalodimas@linaro.org Cc: jbx6244@gmail.com, u-boot@lists.denx.de, AKASHI Takahiro Subject: [RFC 09/13] efi_loader: rename BOOTEFI_BOOTMGR to EFI_BOOTMGR Date: Thu, 26 Oct 2023 14:30:48 +0900 Message-Id: <20231026053052.622453-10-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231026053052.622453-1-takahiro.akashi@linaro.org> References: <20231026053052.622453-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean At this point, EFI boot manager interfaces is fully independent from bootefi command. So just rename the configuration parameter. Signed-off-by: AKASHI Takahiro --- boot/Makefile | 2 +- cmd/Kconfig | 4 ++-- cmd/efidebug.c | 4 ++-- lib/efi_loader/Kconfig | 2 +- lib/efi_loader/Makefile | 2 +- test/boot/bootflow.c | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/boot/Makefile b/boot/Makefile index 4eaa5eab4b77..48d74c67d680 100644 --- a/boot/Makefile +++ b/boot/Makefile @@ -32,7 +32,7 @@ obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_CROS) += bootm.o bootm_os.o bootmeth_cros.o obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_SANDBOX) += bootmeth_sandbox.o obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_SCRIPT) += bootmeth_script.o ifdef CONFIG_$(SPL_TPL_)BOOTSTD_FULL -obj-$(CONFIG_BOOTEFI_BOOTMGR) += bootmeth_efi_mgr.o +obj-$(CONFIG_EFI_BOOTMGR) += bootmeth_efi_mgr.o obj-$(CONFIG_$(SPL_TPL_)EXPO) += bootflow_menu.o obj-$(CONFIG_$(SPL_TPL_)BOOTSTD) += bootflow_menu.o obj-$(CONFIG_$(SPL_TPL_)CEDIT) += cedit.o diff --git a/cmd/Kconfig b/cmd/Kconfig index bf16fad04d37..3a8483f7d042 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -375,7 +375,7 @@ config CMD_BOOTEFI_BINARY config CMD_BOOTEFI_BOOTMGR bool "UEFI Boot Manager command" - depends on BOOTEFI_BOOTMGR + depends on EFI_BOOTMGR default y help Select this option to enable the 'bootmgr' subcommand of 'bootefi'. @@ -2122,7 +2122,7 @@ config CMD_EFIDEBUG config CMD_EFICONFIG bool "eficonfig - provide menu-driven uefi variables maintenance interface" default y if !HAS_BOARD_SIZE_LIMIT - depends on BOOTEFI_BOOTMGR + depends on EFI_BOOTMGR select MENU help Enable the 'eficonfig' command which provides the menu-driven UEFI diff --git a/cmd/efidebug.c b/cmd/efidebug.c index c2b2b074e094..7ba2331ad19f 100644 --- a/cmd/efidebug.c +++ b/cmd/efidebug.c @@ -1335,7 +1335,7 @@ static __maybe_unused int do_efi_test_bootmgr(struct cmd_tbl *cmdtp, int flag, } static struct cmd_tbl cmd_efidebug_test_sub[] = { -#ifdef CONFIG_BOOTEFI_BOOTMGR +#ifdef CONFIG_EFI_BOOTMGR U_BOOT_CMD_MKENT(bootmgr, CONFIG_SYS_MAXARGS, 1, do_efi_test_bootmgr, "", ""), #endif @@ -1526,7 +1526,7 @@ U_BOOT_LONGHELP(efidebug, " - show UEFI memory map\n" "efidebug tables\n" " - show UEFI configuration tables\n" -#ifdef CONFIG_BOOTEFI_BOOTMGR +#ifdef CONFIG_EFI_BOOTMGR "efidebug test bootmgr\n" " - run simple bootmgr for test\n" #endif diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig index 987a990509f3..27d3f52897a9 100644 --- a/lib/efi_loader/Kconfig +++ b/lib/efi_loader/Kconfig @@ -41,7 +41,7 @@ config EFI_BINARY_EXEC You may enable CMD_BOOTEFI_BINARY so that you can use bootefi command to do that. -config BOOTEFI_BOOTMGR +config EFI_BOOTMGR bool "UEFI Boot Manager" default y select BOOTMETH_GLOBAL if BOOTSTD diff --git a/lib/efi_loader/Makefile b/lib/efi_loader/Makefile index 0a2cb6e3c476..f882474bba6f 100644 --- a/lib/efi_loader/Makefile +++ b/lib/efi_loader/Makefile @@ -42,7 +42,7 @@ targets += initrddump.o endif obj-$(CONFIG_CMD_BOOTEFI_HELLO) += helloworld_efi.o -obj-$(CONFIG_BOOTEFI_BOOTMGR) += efi_bootmgr.o +obj-$(CONFIG_EFI_BOOTMGR) += efi_bootmgr.o obj-y += efi_boottime.o obj-y += efi_helper.o obj-$(CONFIG_EFI_HAVE_CAPSULE_SUPPORT) += efi_capsule.o diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c index 47c552a94165..7eafdc79de3b 100644 --- a/test/boot/bootflow.c +++ b/test/boot/bootflow.c @@ -374,7 +374,7 @@ static int bootflow_system(struct unit_test_state *uts) { struct udevice *bootstd, *dev; - if (!IS_ENABLED(CONFIG_BOOTEFI_BOOTMGR)) + if (!IS_ENABLED(CONFIG_EFI_BOOTMGR)) return -EAGAIN; ut_assertok(uclass_first_device_err(UCLASS_BOOTSTD, &bootstd)); ut_assertok(device_bind(bootstd, DM_DRIVER_GET(bootmeth_efi_mgr), From patchwork Thu Oct 26 05:30:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 738327 Delivered-To: patch@linaro.org Received: by 2002:adf:f842:0:b0:32d:baff:b0ca with SMTP id d2csp638895wrq; Wed, 25 Oct 2023 22:33:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHv//zmVoG92omYcyizoadm//bbKg4moXDJRvblviyBeiK9bZaU+ZbdHejW08KNSQYfNTAY X-Received: by 2002:adf:e852:0:b0:31f:fdd8:7d56 with SMTP id d18-20020adfe852000000b0031ffdd87d56mr11552139wrn.12.1698298405160; Wed, 25 Oct 2023 22:33:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698298405; cv=none; d=google.com; s=arc-20160816; b=DOKrKbnIxhL/PXQSQPhe0Hr/KtdGh6STZnQ3Q0+b4IO9CtiX5ZikmH39E1Y7iv8JKP vX+JC5u1+Btb+/F3LXO9bVDu+Rw4iJXnU6aHEHUXPWYWYc1+gaslfylfX+xCVe14DdCA j6QRzAbklvmkK45UJHiFry0J+0bW11onwwsyzfsq+9vVmvzvpgVigAOqwTJsA9Z94UGv A03zXO/aH9P4AdWrqyk5F6Hx6HBr1cnsqX+qD8lBTtISOB7qgK8a8bPvf30SGlvs15YF 0X8ayA8680higGealeuq+O3K50iITFlq16EuKFN4giBNSqLjQXv65WZNmwsBV/9imGvX Rwfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=f1xnsDhYxoGq8Q7UUWBB8Cvz7zbisEXPmyyhu/S5S0E=; fh=RsKNQde3hXRhkFNkXZDJxhxJUE2DI5qQDMHikPj4pmY=; b=0hrfVbv2mt1E6p2NRYYpJMuRjMIQVXGmoivwPB/YdXS1izF0NyY7uevygDat0LoySB kaV72lrq6Nb3k7ImSokjWAI3YARnpGkv6A9isUzqDsHVTIg4byDQwpaSG/jeB+Yb0z4+ G260j45pyEe57/ehZeTBVh9TUV9d6ozNzBNI8aIUz8QFI5xdbNBcBEvfgjoBXtqEpQUL qZjLmQ3ZFB/CZXuEpd2d/+awzgHqHJqfPY8Lvk3+PFzXbm1fCSYSAbxB8o7cBiomv6PJ XI0QPV1z+u+sRnA/AJgvXNZ6XulcRmD9rh0bVPlTMYuyzghUG3eMgB0htU2Pr5azQ45u XbIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Xm2zPg85; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id v5-20020a5d4a45000000b0032da2b8abcesi8380859wrs.491.2023.10.25.22.33.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 22:33:25 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Xm2zPg85; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C245D87B2A; Thu, 26 Oct 2023 07:31:50 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="Xm2zPg85"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6A65F87B24; Thu, 26 Oct 2023 07:31:48 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id DE68187B24 for ; Thu, 26 Oct 2023 07:31:43 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-6bcbfecf314so118441b3a.1 for ; Wed, 25 Oct 2023 22:31:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698298302; x=1698903102; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=f1xnsDhYxoGq8Q7UUWBB8Cvz7zbisEXPmyyhu/S5S0E=; b=Xm2zPg85WSbfHiYc68b/h4SqPGdnWUrMnJEXybgpTf/xxaObOzH1yF1KvQzwV5PWo8 QcKSNqJRSEBkpnSDngfZw+r7oGJ85vBEucBsvSE4kFOr0oSZlNbty7YSqYGlDCdljmxv hW9FKiMye2ypWvCiDcGZ5k2lL2P0zrO4azXplTXw9QfY1noD5kisLD4NjLt0uFEVBMZO T6eCL46JI2wMvoMbcDHIVblyTS+AqA6ur/Zo4fM3qE+lZIDQrEgLHofxleYOjWuXPw4F jzys78/BmTbWq/tG3gR3DBsIaU8STvsOfCSpK9e/9ZBijUIj7NT3rMLrxn4SXSQxh+CG v0dQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698298302; x=1698903102; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=f1xnsDhYxoGq8Q7UUWBB8Cvz7zbisEXPmyyhu/S5S0E=; b=lv+baN1Rm0cHC57lwMzZjDNSU0MR3HuWdEEWN7bN2qYorMs3Hxwxsls59eaUM6AwLh /x2QanDamW4IHjWD7vDgGgWtSpzyeUEnmgozemN+uV+qYg9s7CdMYGPRV/za+sKWb65b SQeeABEOvbR/2w3P5QzaQnjVTnmY0/bZHWLAbJLjO2fGCotz2bUT2yrdA2WlTh0XpYoA Ltx33gC4HsHxterTdHs+RiQW2pBCj1zMgE1xaeQlK/jPO4XSmbfdwjOS+Z7cA+1HO+/V zMGeJ2PcSQWBfPnbGFwcZFiHlaDLfTnhetMDg0BN4MeVq22hfzzR2F/RGB3hQBUW3GGq 8+NA== X-Gm-Message-State: AOJu0Ywuj/Exx5WgNC4a/SORXrAeiaC1h+v9CuZooECin7xSx6Z5I8w0 Lk9/duK/IEurWEK6hD7G0oF75g== X-Received: by 2002:a05:6a20:a10c:b0:15d:f804:6907 with SMTP id q12-20020a056a20a10c00b0015df8046907mr21131824pzk.0.1698298302260; Wed, 25 Oct 2023 22:31:42 -0700 (PDT) Received: from octopus.. ([2400:4050:c3e1:100:bca9:3af7:89e9:80b7]) by smtp.gmail.com with ESMTPSA id fa13-20020a056a002d0d00b006c06804cd39sm440715pfb.153.2023.10.25.22.31.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 22:31:41 -0700 (PDT) From: AKASHI Takahiro To: trini@konsulko.com, sjg@chromium.org, xypron.glpk@gmx.de, ilias.apalodimas@linaro.org Cc: jbx6244@gmail.com, u-boot@lists.denx.de, AKASHI Takahiro Subject: [RFC 10/13] net: tftp: remove explicit efi configuration dependency Date: Thu, 26 Oct 2023 14:30:49 +0900 Message-Id: <20231026053052.622453-11-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231026053052.622453-1-takahiro.akashi@linaro.org> References: <20231026053052.622453-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Now it is clear that the feature actually depends on efi interfaces, not "bootefi" command. efi_set_bootdev() will automatically be nullified if necessary efi component is disabled. Signed-off-by: AKASHI Takahiro --- net/tftp.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/net/tftp.c b/net/tftp.c index 88e71e67de35..2e335413492b 100644 --- a/net/tftp.c +++ b/net/tftp.c @@ -302,12 +302,10 @@ static void tftp_complete(void) time_start * 1000, "/s"); } puts("\ndone\n"); - if (IS_ENABLED(CONFIG_CMD_BOOTEFI)) { - if (!tftp_put_active) - efi_set_bootdev("Net", "", tftp_filename, - map_sysmem(tftp_load_addr, 0), - net_boot_file_size); - } + if (!tftp_put_active) + efi_set_bootdev("Net", "", tftp_filename, + map_sysmem(tftp_load_addr, 0), + net_boot_file_size); net_set_state(NETLOOP_SUCCESS); } From patchwork Thu Oct 26 05:30:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 738328 Delivered-To: patch@linaro.org Received: by 2002:adf:f842:0:b0:32d:baff:b0ca with SMTP id d2csp638949wrq; Wed, 25 Oct 2023 22:33:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHkphEt2r7FZGnalSVzjS5HROIWod0YkegkvJujGk5ofGnsao4OmIWiA5ecPgEbjXJRFX9T X-Received: by 2002:a05:600c:4f0f:b0:405:3885:490a with SMTP id l15-20020a05600c4f0f00b004053885490amr13046107wmq.0.1698298418982; Wed, 25 Oct 2023 22:33:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698298418; cv=none; d=google.com; s=arc-20160816; b=s33+YwXFGYVLbWM7eIg0lAms49lBkEG3O1j8U0zOBXLxLIL09oHEx+IHod0Fjce2TH jGa3MqoEuZCIL6ZdFEpHGimuuB38XpVw8MeGsmSSCOJwqkbviBPEorerHqYbNoLSLdd7 +c9owmrsAqbysX1UQJEPCDps3x0+Sl7IVZGxPDHuIoc5XIr0107q9d9wZs1I+P5ORuYD O9N32oOpH5JLSoBGZ5hqu5ivlLqUaW97es1OPu0+XD9pvAZoXyFS5/vuMfpN3y0tUyEt PP5Jau4ng7DxM+OPmDGSJ2o1/g4J0ofONrioCqXjhWwQY55qwG5UeR3rYLgQFyyKK23j P1eg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=OCUBljU3l7bLi+2Mof6yKcdAJGAgEsp6V13IE4RoUsg=; fh=RsKNQde3hXRhkFNkXZDJxhxJUE2DI5qQDMHikPj4pmY=; b=c+HSNL1hX5GsZe76Rt3rMZi9Q7RpECPSgOUQixa3MZhwqt4PzL7Zgmz5AgOoB8grr9 SYSL13ODgOiei8uEwSciJMOQsUeCnQkpwEdV5cdr9dNaJuGnmiDpwWTNFhirMjnaOtWX Do4jnoGXQJGPyrXIkWLicbUq4+rnBQ05C0kzwqm2fzrNCH08+bSq8zONlj4IvXKSQrto 7NCbX2YNh7Ope8gt63bNqjzbLXXKpsMaHZp/BrSfN4YB9BIrM9/xEPmsRvB2EsP08efj vYFnIT5f3Ac2nzzADq5IRpXwkvoRB2PoLQAVv9tCt1elL4ru0nGGljSbgir8JnmoJnI+ 6mdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rSs3bZ4e; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id q10-20020a05600c46ca00b004064b67428dsi1104117wmo.2.2023.10.25.22.33.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 22:33:38 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rSs3bZ4e; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3F03487B3B; Thu, 26 Oct 2023 07:31:51 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="rSs3bZ4e"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id F35D187B2C; Thu, 26 Oct 2023 07:31:49 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 26B2387B09 for ; Thu, 26 Oct 2023 07:31:46 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pg1-x536.google.com with SMTP id 41be03b00d2f7-51f64817809so54607a12.1 for ; Wed, 25 Oct 2023 22:31:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698298304; x=1698903104; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=OCUBljU3l7bLi+2Mof6yKcdAJGAgEsp6V13IE4RoUsg=; b=rSs3bZ4e4ihjZQtAf+mbfgRGVrkTNLFeiL6/7/5+e7gGKdYv1gA6+D3gqUD8csoy5a kgAwuiar+4WGZubt7+B6s5RY2s3AdR9ZQhGq7CkWJRngPf6JHKylddoRa3oMNysxGTui /1GQI1GTB7RBuFXq/YncAUsi7kQyUlgOzESIgL/04t5p3yBwTpBogsSedYT4xTYIJ3nG 17WVB6KpxQHZ8efEuDS7HEWDaEDXds7TOtGPGTLdgrNbJz36ndpASLaqejgN7bHQh1W/ R2EoAxHR5tdw/RjH8Cnq2dkTvyAMo2ofP5+YsoJKKb5hCmWdH6BtacM2Tr4hocoLpQgQ a+yQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698298304; x=1698903104; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OCUBljU3l7bLi+2Mof6yKcdAJGAgEsp6V13IE4RoUsg=; b=EhhMgtTdo2IQlJq5klFQYKCI8eyyb31JJ0+wa+A3r9LoAexXOAJF8o0aNBUJOpou5W YrOpki9wFGxMrYBGU5uQm0pct7rCPY+iUE5BZTnJe9o/Gh0Hsw0HxiAdYmLpUMOeM77P 0Yis+ksuwnZ7k7yuGrBb6d6sgjzuoUntEaFkBxwauozi8p4b9BBwqcELXx8y5azffnnM vhpuayYSw01gjMznMexPhNSKzuf6DewzsyRTRe0F3hsuN+P7Xje08Nb8Uo6S0ZrsmQXN nqpmLBUHWkkUCMaJF8T8FkCNDUAL9botmM7G9/CWw7t8w/b2U4yqhSmTHXEEi+GTkVid +6XQ== X-Gm-Message-State: AOJu0YwTeCHsoPwkI3OULRmL+laH5P6Jmy4Gb5nRryfezxA6fgE9ukc5 XoLYbDPfgF7yGONvpmDa/0A8Ww== X-Received: by 2002:a05:6a20:e68c:b0:15c:b7ba:e9ba with SMTP id mz12-20020a056a20e68c00b0015cb7bae9bamr17078542pzb.0.1698298304383; Wed, 25 Oct 2023 22:31:44 -0700 (PDT) Received: from octopus.. ([2400:4050:c3e1:100:bca9:3af7:89e9:80b7]) by smtp.gmail.com with ESMTPSA id fa13-20020a056a002d0d00b006c06804cd39sm440715pfb.153.2023.10.25.22.31.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 22:31:44 -0700 (PDT) From: AKASHI Takahiro To: trini@konsulko.com, sjg@chromium.org, xypron.glpk@gmx.de, ilias.apalodimas@linaro.org Cc: jbx6244@gmail.com, u-boot@lists.denx.de, AKASHI Takahiro Subject: [RFC 11/13] fs: remove explicit efi configuration dependency Date: Thu, 26 Oct 2023 14:30:50 +0900 Message-Id: <20231026053052.622453-12-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231026053052.622453-1-takahiro.akashi@linaro.org> References: <20231026053052.622453-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Now it is clear that the feature actually depends on efi interfaces, not "bootefi" command. efi_set_bootdev() will automatically be nullified if necessary efi component is disabled. Signed-off-by: AKASHI Takahiro --- fs/fs.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/fs/fs.c b/fs/fs.c index 4cb4310c9cc2..70cdb594c4c8 100644 --- a/fs/fs.c +++ b/fs/fs.c @@ -791,10 +791,9 @@ int do_load(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[], return 1; } - if (IS_ENABLED(CONFIG_CMD_BOOTEFI)) - efi_set_bootdev(argv[1], (argc > 2) ? argv[2] : "", - (argc > 4) ? argv[4] : "", map_sysmem(addr, 0), - len_read); + efi_set_bootdev(argv[1], (argc > 2) ? argv[2] : "", + (argc > 4) ? argv[4] : "", map_sysmem(addr, 0), + len_read); printf("%llu bytes read in %lu ms", len_read, time); if (time > 0) { From patchwork Thu Oct 26 05:30:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 738329 Delivered-To: patch@linaro.org Received: by 2002:adf:f842:0:b0:32d:baff:b0ca with SMTP id d2csp638978wrq; Wed, 25 Oct 2023 22:33:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGI0sMrAzuzUNe6/bj3fOOOFPPsb5vUgTnf75HmBY3x5LoswaXra+ZNEVTrkZTcEAG3O6IK X-Received: by 2002:adf:e4cf:0:b0:32d:81f7:43e4 with SMTP id v15-20020adfe4cf000000b0032d81f743e4mr12888491wrm.51.1698298428219; Wed, 25 Oct 2023 22:33:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698298428; cv=none; d=google.com; s=arc-20160816; b=u5t4vrSJqiNnvQh7vk5ulv9MuUgmN8S470GhC+SlbZSmVtyNMLi+OvZzuDfWC/RONn PIrbsWnnmzBK4OzGNdsZ0iYNek5FzmzyyCvMzEbbPtHgbWy34fps/Gd5baL/tWxSFiZX UMX13j2z+jjuCQYa291EsMaf744Chnp2x6zOmaNwFZ9zbsRhBbODoFjIQPI2sHdIqhQo LzcypmQCac9/hhdj2x8VtxVzBSlGZNrsB0IwwqTUjN5QlfQGJJmP1hx8ApsjUhyKXWtb FsmjHafmQVDhkKXI00lLl7FAKI6LLvnSG6gFLeUoejrMZ42flBxshuOYLppaok0QA6Ys slxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ZfuXMOte++LWMschC/mgpQI0os8sthmLuLMLob48M3U=; fh=RsKNQde3hXRhkFNkXZDJxhxJUE2DI5qQDMHikPj4pmY=; b=C1SjR6kBJuR52YgPm6muWKO4iVSiB4xL2RInnTM0F9xWYuPzmEphslRx0WIjcy1yUf xe9wwdBBpXymGKi9vaY8qTreqPGAXMreP12DnUyIlUjrT64S/PfMe8DqGudkkGuU52xO W9qSnmo2zrYpAUFQt95DPiNruWOCeUNs2M+5D4JA6O1lA1avAdCKXejGYI4idPZbE1fR X9nqPPbcS0VsMXN0GQBdEj31FPh76ZJS5ESfGy3kqmDRiHf57Gy+HW5NGYzXbKFthvuA v7UEqCjuuykQ7xX9ntKOHgRdmrhdcJ/rA27XwvmpsKm69RizXbAvE5AGR7zzK+msqxCY lAqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ICLZhNb8; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id a7-20020adfe5c7000000b0031ffe1596e3si8817184wrn.702.2023.10.25.22.33.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 22:33:48 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ICLZhNb8; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A1E2587B40; Thu, 26 Oct 2023 07:31:51 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="ICLZhNb8"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8560987B24; Thu, 26 Oct 2023 07:31:50 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 2E08787B27 for ; Thu, 26 Oct 2023 07:31:48 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-6bcdfcde944so109762b3a.1 for ; Wed, 25 Oct 2023 22:31:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698298306; x=1698903106; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ZfuXMOte++LWMschC/mgpQI0os8sthmLuLMLob48M3U=; b=ICLZhNb8b9pUSwMIljvtVxQYfeclkOQqRkxicFgDdV1BrXq9KPhole/9yS3fGWtIkN g+EFylgTtrJB+OSBE625yWwo4YQVRxTuFGtLoohIKNvrhxgvSGD8J9/0ZwrriwLfhKFd izzKv8qtjRWfSXJnU70zc5SFV1mnxYRqVdgiT5FMt/ZXTLydsoDx2aURCk3Dn20xG4ul TBIP6HId+gYZKdcx4wLDg8kI8aSv1p/xn83uRlM9Y3ZXU8oRGTng+ADhHqnq8Qs1wCsK 6j3pRS4+KDi6Vla4v3FUi0A2KTUcGE8kPc/0R6FJ58YDwiMDFLq/t0iz2zzkoXFzaKC3 qTRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698298306; x=1698903106; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZfuXMOte++LWMschC/mgpQI0os8sthmLuLMLob48M3U=; b=Z4HYXNvBBztek0ogC5kb/RmFZhqlemob3fRtRd6GsJMsawaL271e9NZR6Pbu01ClTY 2hvRQJ2DzaUAqd9TjdFxZakrThHX5rhbtpycByE5TQtcdUyD2WUjsD3sVTiwTB7H51OM ZXN2h6uVo739UTKlVUNQnvJeO3yollKS5+g8VjA7ShbOau+1mRH3z3WRuAuKZe+CGQ0k Z5lJaq1e8gm7IuDYzG0rLFbDU5twXbeqcxNqWOYn5opV/KMroo5r4stLoQ472ojFEG2n uIdekvfaWOsnabxj9JT0mvGJgXo54WR6lUXFDHdkQ8qgStEIFI5i4pZMYkbsqr6BKC/S SSog== X-Gm-Message-State: AOJu0YxrNp3E6VfkqqmMCPN2LKXGBWlT+Qog98jZ/NsKe+DHJ2JRm2UX LCXtvGNMXiVRa6yL1QSip9pjmA== X-Received: by 2002:a05:6a21:33a4:b0:163:c167:964a with SMTP id yy36-20020a056a2133a400b00163c167964amr21430176pzb.1.1698298306544; Wed, 25 Oct 2023 22:31:46 -0700 (PDT) Received: from octopus.. ([2400:4050:c3e1:100:bca9:3af7:89e9:80b7]) by smtp.gmail.com with ESMTPSA id fa13-20020a056a002d0d00b006c06804cd39sm440715pfb.153.2023.10.25.22.31.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 22:31:46 -0700 (PDT) From: AKASHI Takahiro To: trini@konsulko.com, sjg@chromium.org, xypron.glpk@gmx.de, ilias.apalodimas@linaro.org Cc: jbx6244@gmail.com, u-boot@lists.denx.de, AKASHI Takahiro Subject: [RFC 12/13] lib: uuid: move CONFIG_RANDOM_UUID Date: Thu, 26 Oct 2023 14:30:51 +0900 Message-Id: <20231026053052.622453-13-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231026053052.622453-1-takahiro.akashi@linaro.org> References: <20231026053052.622453-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean This option is independent from any commands and should be managed under lib. For instance, drivers/block/rkmtd.c is a user. It would be better to remove this configuration. Signed-off-by: AKASHI Takahiro Reviewed-by: Tom Rini Reviewed-by: Ilias Apalodimas --- cmd/Kconfig | 7 ------- lib/Kconfig | 7 +++++++ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cmd/Kconfig b/cmd/Kconfig index 3a8483f7d042..c42745d06b39 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -1143,13 +1143,6 @@ config CMD_GPT Enable the 'gpt' command to ready and write GPT style partition tables. -config RANDOM_UUID - bool "GPT Random UUID generation" - select LIB_UUID - help - Enable the generation of partitions with random UUIDs if none - are provided. - config CMD_GPT_RENAME bool "GPT partition renaming commands" depends on CMD_GPT diff --git a/lib/Kconfig b/lib/Kconfig index f6ca559897e7..b6d580c30615 100644 --- a/lib/Kconfig +++ b/lib/Kconfig @@ -74,6 +74,13 @@ config HAVE_PRIVATE_LIBGCC config LIB_UUID bool +config RANDOM_UUID + bool "GPT Random UUID generation" + select LIB_UUID + help + Enable the generation of partitions with random UUIDs if none + are provided. + config SPL_LIB_UUID depends on SPL bool From patchwork Thu Oct 26 05:30:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 738330 Delivered-To: patch@linaro.org Received: by 2002:adf:f842:0:b0:32d:baff:b0ca with SMTP id d2csp639017wrq; Wed, 25 Oct 2023 22:33:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGp5YPDUIqCu43beK5dGldrw3OtZCNJOB+glI4uIF4iNlGd0Ag2ZuAQdhsfY+QASsSEy6pO X-Received: by 2002:a19:7419:0:b0:4fd:c715:5667 with SMTP id v25-20020a197419000000b004fdc7155667mr11412900lfe.20.1698298437967; Wed, 25 Oct 2023 22:33:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698298437; cv=none; d=google.com; s=arc-20160816; b=ygIXT11RPuSU9+tWojlfLTq+AlvnV+WhY7YU2qIuAZ0gHl8WGS59J4ab7DV/Nd49lx TUoMlyS9+2y6XKi1oaShxlKDHNFd0x2g1nyfNdcpH/vlBVq/CNTvamk1T+0gAYWV8NqP wlgfhszfPdSDBPq23I9wZDbNVo59Z76B3uJfjJWPJ4BhZiF81YpE2Ah1fgg6v+BRFH4M vyChWQKxVhVr8KUy4bz3MAmM6iA5zcWY6NFm+B556jY8/HIGcfXUw7LV8Zju6ZZEVDf8 9C92GnE+48y26AAEItmFpGeJQjZtEsbXzbhsQT+ygrOwCIUbcPT8YB8tDSd1hNYTNhlc y0Tw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=XSlmcmhian9jA6bQ6FwNP+u6e3gkMVRlAhlaAxq2KoQ=; fh=RsKNQde3hXRhkFNkXZDJxhxJUE2DI5qQDMHikPj4pmY=; b=t5toD4dvXkXBo1RPiVykio458E2TwlGpxrNXukcUYgQO3r4N72S65aje8n1Kzajda5 gJtnRAu2pZXDS8mEB+XvbY+RtJ/6zVM8y6NVRMC4RgxLZLUlNXM1jYkI2lcV8xV/8Fpr tbO72zLL0Me+0dacSo2y6DgwyLnDGp7j0sX0y5zjlV7VOu3cGcWa44n2/Y5aT8lZE1w1 fG+5D/fZaJ5X66XAZJpXdcMNlfMZRIoir31EQkabq/roQeSZI+f2BIGRrpuxLH0Xhqth fc5olNnuPkH6POOsgY9dDPcl3ey4OUEqorU//pJ+PLfS7dJZF4c9a4D/4NZbNyDVTKqx Y9Gw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=G4VAIw7J; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id g16-20020a7bc4d0000000b00402036a2b2dsi1056326wmk.164.2023.10.25.22.33.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 22:33:57 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=G4VAIw7J; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1201987B2E; Thu, 26 Oct 2023 07:31:56 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="G4VAIw7J"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 42ED787B24; Thu, 26 Oct 2023 07:31:53 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 99DEA87B1E for ; Thu, 26 Oct 2023 07:31:50 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-6ba8eb7e581so112003b3a.0 for ; Wed, 25 Oct 2023 22:31:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698298309; x=1698903109; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=XSlmcmhian9jA6bQ6FwNP+u6e3gkMVRlAhlaAxq2KoQ=; b=G4VAIw7JloRVA3AXa5Ufp+NCoy5d6LnpP8Xfd9BTraAm3mnhdY3rC/r9+D3SuzHhi3 9fyhMN3keaKeU6kF3uFOTMglpqy99yMAIF6q1C0izdFkJjAeJC91eigPu9F6+A+XmkqU ktj0jsz6qaZo24uzZSGJNJe2R4W9o3HEF2XvZBPva3CttqwIJchz0VtVqxZpiwWmPtfJ ZtbD2KbOgqirqk4irS/0Gp/0xAbQUP+qlYvtL8hQfvPhBeWHluGUkk93tIFcYxM4BM3a +NPDUQeTi6fyD4x+gAY2PBm1VEao4RWS+Dq344jbeewfbUO9NmDoSgMWSBMnWlC7xDov KRXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698298309; x=1698903109; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XSlmcmhian9jA6bQ6FwNP+u6e3gkMVRlAhlaAxq2KoQ=; b=IzY5suwRuq4N0vWoZegQ5vZsQn9wbbVtp48acXlWwF9bSuDZzp+sUBwupYBBH5tvxw eND9Udp7+IHbWrmFnHc8VQ/ZckkqtX945FYPDFqWER05a1LhTEZpNwtjoXEdcxr4OCSZ q2XzpWQSGxaWnSZpvqxWZvCwJG92Mluz3rVcKjS4dHdX/GtPu9sOVMy4l/WH1UWYx7v5 7OvSTn0qHZd1IL1EFHvm0XAgj/ZhcPmRoZF4uuH3SMK7HhDY67bfzEuFVTj0p8e3KpRA vOuZ5F4CTQOmNXL/qaPpStbsZVwu4vmpdEwmbRe0BrAbqQW8eXH5j92xvQiMGWRlDeJS z7xw== X-Gm-Message-State: AOJu0YzBR2SWQlpiQNwEQzNW43/2bSXeMsSLdmkiT1gZwUxIRvyQqxn6 bv8fmUfsQ0jGPcOCfnkbtGVRyg== X-Received: by 2002:a05:6a00:1a8f:b0:6be:cb8c:92c7 with SMTP id e15-20020a056a001a8f00b006becb8c92c7mr18554087pfv.3.1698298308908; Wed, 25 Oct 2023 22:31:48 -0700 (PDT) Received: from octopus.. ([2400:4050:c3e1:100:bca9:3af7:89e9:80b7]) by smtp.gmail.com with ESMTPSA id fa13-20020a056a002d0d00b006c06804cd39sm440715pfb.153.2023.10.25.22.31.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 22:31:48 -0700 (PDT) From: AKASHI Takahiro To: trini@konsulko.com, sjg@chromium.org, xypron.glpk@gmx.de, ilias.apalodimas@linaro.org Cc: jbx6244@gmail.com, u-boot@lists.denx.de, AKASHI Takahiro Subject: [RFC 13/13] block: rkmtd: select CONFIG_RANDOM_UUID explicitly Date: Thu, 26 Oct 2023 14:30:52 +0900 Message-Id: <20231026053052.622453-14-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231026053052.622453-1-takahiro.akashi@linaro.org> References: <20231026053052.622453-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean This option is necessary to compile any way. Signed-off-by: AKASHI Takahiro --- drivers/block/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig index 048a6caef00f..5cda21551043 100644 --- a/drivers/block/Kconfig +++ b/drivers/block/Kconfig @@ -265,6 +265,7 @@ config SYS_64BIT_LBA config RKMTD bool "Rockchip rkmtd virtual block device" + imply RANDOM_UUID help Enable "rkmtd" class and driver to create a virtual block device to transfer Rockchip boot block data to and from NAND with block