Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8A1EBC433EF for ; Sat, 29 Jan 2022 21:58:50 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 62C1F836A3; Sat, 29 Jan 2022 22:58:48 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="gQftc8xo"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6AA2283678; Sat, 29 Jan 2022 22:58:46 +0100 (CET) Received: from mail-io1-xd2f.google.com (mail-io1-xd2f.google.com [IPv6:2607:f8b0:4864:20::d2f]) (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 5A0548192A for ; Sat, 29 Jan 2022 22:58:43 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd2f.google.com with SMTP id h7so12133510iof.3 for ; Sat, 29 Jan 2022 13:58:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=7b4LiG9w+PJsR8A3tptlBSebQAvVGTYiXPhEJY23Wrw=; b=gQftc8xosv+9o4Z8cEfmKG9jXUISrleuVne5GzzUzOJHyuOsRejvajBHfATZM7Hnt0 4KOgL69RUolrGMsqUkk98A7anf0LSLjDQSrFtZJjlIHc+cnWwL0Ah5Qy37aOonVi4snR ZDjXuoGVxTMgCPYLYwDy6cPF0yzcqiXcXIb/I= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=7b4LiG9w+PJsR8A3tptlBSebQAvVGTYiXPhEJY23Wrw=; b=MrPd44g7Pp74wiE+7hQn2MCt9I1YSJ0QaBY2ANmIPGZ1CLSCy1mPdZViZHoP0npot2 FunpyNT9OL693YTMP+Jrtf8RrWXsI8ICHJC4i8bEmhbJbQz4/+vW6c3ccEb4/r8G4kK2 xH5yoirZzrzW+/XyUulV3YiPdtHezEOJHEPsk+qRx31tp7B704edCmcIxboD/NggXEk5 aWVwylyDhGCYlAI9OfZRAvh7Er6v+KKeMgw2D+mnVYtdSggPXUi0PIMjFrEMTteqDTKH eoUt6EaIu5FVNbaIvcyQCrhkn/octJBOocs1q+bRbZVkYpROkogO0ui6dP2ArhbirXl3 PuAA== X-Gm-Message-State: AOAM531/lwt9ybiaJ1W+2uZpz7AkLtX8l0ywLUMmJQsqtp2Qi1xlbf02 LqxW2/nlsvacboz6tBad5QWt5/dtHe8ipg== X-Google-Smtp-Source: ABdhPJw9Vpaf6fruwxjxQI0IFB94GX8ZuP8p3ctVJVFYqxrhC7TrZLlnl7Mo13Wpzc1O3y8Evj2s9A== X-Received: by 2002:a05:6638:ecd:: with SMTP id q13mr2632770jas.297.1643493521981; Sat, 29 Jan 2022 13:58:41 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id o11sm15693953ilm.20.2022.01.29.13.58.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 29 Jan 2022 13:58:41 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Heinrich Schuchardt , Simon Glass , Alexander Graf Subject: [PATCH v2 1/3] efi: Add debugging to efi_set_bootdev() Date: Sat, 29 Jan 2022 14:58:37 -0700 Message-Id: <20220129215839.535809-1-sjg@chromium.org> X-Mailer: git-send-email 2.35.0.rc2.247.g8bbb082509-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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.5 at phobos.denx.de X-Virus-Status: Clean The operation of this function can be confusing. Add some debugging so we can see what it is doing and when it is called. Also drop the preprocessor usage. Signed-off-by: Simon Glass --- Changes in v2: - Update one of the debug messages cmd/bootefi.c | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/cmd/bootefi.c b/cmd/bootefi.c index 3a8b2b60618..94d18ca73fa 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -65,6 +65,9 @@ void efi_set_bootdev(const char *dev, const char *devnr, const char *path, 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) @@ -72,18 +75,19 @@ void efi_set_bootdev(const char *dev, const char *devnr, const char *path, /* Remember only PE-COFF and FIT images */ if (efi_check_pe(buffer, buffer_size, NULL) != EFI_SUCCESS) { -#ifdef CONFIG_FIT - if (fit_check_format(buffer, IMAGE_SIZE_INVAL)) + 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; - /* - * 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 - return; -#endif + } } /* efi_set_bootdev() is typically called repeatedly, recover memory */ @@ -103,7 +107,11 @@ void efi_set_bootdev(const char *dev, const char *devnr, const char *path, efi_free_pool(image_tmp); } bootefi_image_path = image; + log_debug("- recorded device %ls\n", efi_dp_str(device)); + if (image) + log_debug("- and image %ls\n", efi_dp_str(image)); } else { + log_debug("- efi_dp_from_name() failed, err=%lx\n", ret); efi_clear_bootdev(); } } @@ -451,6 +459,7 @@ efi_status_t efi_run_image(void *source_buffer, efi_uintn_t source_size) 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 @@ -476,6 +485,7 @@ efi_status_t efi_run_image(void *source_buffer, efi_uintn_t source_size) 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); -- 2.35.0.rc2.247.g8bbb082509-goog