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 9352EC433EF for ; Sat, 22 Jan 2022 01:17:08 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E8CAB828FD; Sat, 22 Jan 2022 02:17:05 +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="GuIP5FFf"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D23B2832E6; Sat, 22 Jan 2022 02:17:03 +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 D525281B53 for ; Sat, 22 Jan 2022 02:17:00 +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 h79so5065338iof.4 for ; Fri, 21 Jan 2022 17:17:00 -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=pnA6kNRNqFkhzXI0U2ziWpS9zzJe+gzWhZBLhbE9QhM=; b=GuIP5FFfUQkaHQbvuS3nNtua0EARjp+O0jws69yr/eyjrvTKxNvVKrfKOc+PX4v8lI SJNcRKie3oSV1RjBbxwU5WfRJ/BqCw000yFhw1OX+IPxL8tbOpn9adJ6wyyxrB1On6AI DRUJelXNPXxxtvYqjAi9KQ9tI4gnTr5Z7Mx9Y= 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=pnA6kNRNqFkhzXI0U2ziWpS9zzJe+gzWhZBLhbE9QhM=; b=6GfuzhB9XOXYyc+l6ygzvabpP1RECorPKm5EBcd1Al5uZMvVBZGJnRr0+VQFJkTu30 1V5oyKruxRdSmX0C4kIlRuLpqQQG8WzEf9MgP7WPLgHcTtmUUQWAp1qlpOphIdp/Oxvl jMsmnmzVK3UwsPtM9oi74I+Kxa0cs5CSWZFZBEyWQPBo5915ozBZxsUilvtYW511li8F F4HyQBh7ON/idm2sJ03GvmP6S2HgZ403SGcWnIQC2ucDGPblR1CTHo56DxjHJTssOjcz 7QHXiV4J0COtTJhwTUIt3PlC9Vxps2wwUsQoxqUu7/Xge/eMc3TZAp7uQwgSm2AE02hZ +6vw== X-Gm-Message-State: AOAM533z7DoNihpjd9bCepaR++ye5LeLnmsvMDJfPg23N5JkonOKJ7+B soptuGWLVOxGg9r7iw8+jdE8EgoS4WYB2w== X-Google-Smtp-Source: ABdhPJw3Nai3s8p+vfEn7qWNbYiHuvffLWzUOv4wWEEib5YJkRbitb/io/vxSYrpXSAazJKit1CE0w== X-Received: by 2002:a05:6638:338c:: with SMTP id h12mr3134901jav.34.1642814219272; Fri, 21 Jan 2022 17:16:59 -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 p4sm2424551iod.37.2022.01.21.17.16.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Jan 2022 17:16:58 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Heinrich Schuchardt , Simon Glass , Alexander Graf Subject: [PATCH 1/3] efi: Add debugging to efi_set_bootdev() Date: Fri, 21 Jan 2022 18:16:54 -0700 Message-Id: <20220122011656.2724166-1-sjg@chromium.org> X-Mailer: git-send-email 2.35.0.rc0.227.g00780c9af4-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 --- cmd/bootefi.c | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/cmd/bootefi.c b/cmd/bootefi.c index 3a8b2b60618..d8685f0e878 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("- invalid 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.rc0.227.g00780c9af4-goog