From patchwork Tue Jul 5 05:48:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 587433 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1ec:0:0:0:0 with SMTP id 12csp1446794map; Mon, 4 Jul 2022 22:49:39 -0700 (PDT) X-Google-Smtp-Source: AGRyM1s6VfMZSwuqzMkmZrPRUR71SXmgc+sgxyn8nelCXqz3TgtAk5om+CaZ05n6d9usxSITKxWC X-Received: by 2002:a05:6512:2524:b0:47f:b0d9:d096 with SMTP id be36-20020a056512252400b0047fb0d9d096mr20757040lfb.243.1657000179264; Mon, 04 Jul 2022 22:49:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657000179; cv=none; d=google.com; s=arc-20160816; b=N2DxLCTpWBCBRCOS2V9twg2iaRmaD1tjtWOJrPKmqi6M+svfrHbb8WwthPU+7wePeH 6SQXzOrXcG/n28ZAZQZLmz93xcVpmFLaU3cotOZGMFZMLMDBrvv45ZQbYQYPZE8ndKEJ EgbgJkVcJPUwMQWSIT/iJAaPoeURJKGtPvhWrZM30J1Cz9fRCfSy5chc2F7rG/WOwSgR cA15/x66ADrxbrmhi1qCW3dkmRHEcWBNNF8y/toBOpF61kJoyAdwu89A5EDlQ3jD/uvX poDhZuwVT2svCDsOrz97PrExX+8U7qN+JkckYpQwNEUfOBZML2gDXWNKYJCBas38NBJi sVPQ== 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=gn37kIi0eLNlo9l4VQMoB8+bXD/KJElKNvzFUvdQC68=; b=drTVGpT9CI8LNkuR+PgyQjcjGD+UcQVsF5/ftl3Ydene+2bP9142SicXhQx6xAYpTa PfF+xZT785igjAqSmASDCmhsrrDV+TWz+qVHnmXO1HDoGZJn7LLYoqMIXYKHJULPcnve fWvlN8HIW0y5yrKn+SXjm4NzTgPYwqnF0kxbSUEgt8ioZyiF/LXHTmZoJgP3Kc8HswK3 whZhkLJ2WI0PrZqEAANBLX4cdh5JfCqtHHgOF/fIPPrhl592G7mHZHzwfbeoiEfw7D4N BrZ08oG+aMl0N8B0bjmV9LSAbG5bpG49UnMnVBncKaYtrfXpHiQpk7nBt1EQqGXYw5pt YZQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=K56u1gVP; 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 o5-20020a05651c050500b0025aa01eb94csi5272862ljp.391.2022.07.04.22.49.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Jul 2022 22:49:39 -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=K56u1gVP; 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 A0D078451D; Tue, 5 Jul 2022 07:49:15 +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="K56u1gVP"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2F40E84516; Tue, 5 Jul 2022 07:49:12 +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, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pg1-x52f.google.com (mail-pg1-x52f.google.com [IPv6:2607:f8b0:4864:20::52f]) (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 D255C84512 for ; Tue, 5 Jul 2022 07:49:08 +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-x52f.google.com with SMTP id o18so9317559pgu.9 for ; Mon, 04 Jul 2022 22:49:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gn37kIi0eLNlo9l4VQMoB8+bXD/KJElKNvzFUvdQC68=; b=K56u1gVPDXfKQCSOhbM5l9zUWg7BhE+2/r1EfNc4OTyjb0Hpa0FkIlt6+v5eMS1YSr Tl8NI+MPROcbZ0Zpmuiq4xanat9jJpikPLuXWdXsMhwS+tZeFxE3SzoLOtJjSKbk1Hif xgyQ+XlR1y46aSV+YpXz+uImragxtIdXb1vrb1ywuIDoNtFj3/DZB4SIpuXbg69hb7On //q9K3XqSgB/nJVZrFYXf8n0C5kWAHFYXn4SoBnX0zUTQC8CmWhevZ/Tpm7OU6oAJWOC rLR9KP6/rTy+OTIz/DxFigjc2pmLmuvlDPDUuu79ocTO1yIDofjuc1ypZmkKGjXifLDE +cbg== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=gn37kIi0eLNlo9l4VQMoB8+bXD/KJElKNvzFUvdQC68=; b=qjqHcbXGnk5mohLo/SRCNRoHhh/vR427yjghtO3DhD1IM+Xd65b+gKx9tlMtYEgp+H HfWm2wUrifCp58OeM2nxSlVEKKCKHApZX7BKTY5uOK13QbvydsOPlaa260AdiRR1oiIx YJYmyaOhUKKxbuU9DEkbSkSg2SOZomb9AY4IEAOhl99uYNlZ6a6H2ZiaauhZ8sSJIH1N 1lsvKJcSIWUYEyr4SfnZfMvNAccTtd1+GYmkotL3RxSPiLzBFM2So5vMlgEmPKagnKFY wL1Syw3ZCTse9/AwnZXfhUPIzRxa/eMEC9cGqmLiFR3FKd4nDm/xOkwnRsCQNT2+moQ/ g2Sg== X-Gm-Message-State: AJIora+PhMQo+ceUNqAhK20zZ5DPxxz7C0QDk4uv1DRgx4U9TfUhDiHr 3L9lsFuGoeTZrWq+tfKQeHmzjg== X-Received: by 2002:a05:6a00:1a16:b0:528:692e:6637 with SMTP id g22-20020a056a001a1600b00528692e6637mr9159344pfv.69.1657000147060; Mon, 04 Jul 2022 22:49:07 -0700 (PDT) Received: from localhost.localdomain ([2400:4050:c3e1:100:8c42:b67b:3e2f:7653]) by smtp.gmail.com with ESMTPSA id a5-20020a1709027e4500b0016784c93f23sm22149390pln.197.2022.07.04.22.49.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Jul 2022 22:49:06 -0700 (PDT) From: AKASHI Takahiro To: xypron.glpk@gmx.de Cc: ilias.apalodimas@linaro.org, baocheng.su@siemens.com, jan.kiszka@siemens.com, u-boot@lists.denx.de, AKASHI Takahiro Subject: [PATCH 3/5] efi_loader: image_loader: replace EFI_PRINT with log macros Date: Tue, 5 Jul 2022 14:48:13 +0900 Message-Id: <20220705054815.30318-4-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220705054815.30318-1-takahiro.akashi@linaro.org> References: <20220705054815.30318-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.6 at phobos.denx.de X-Virus-Status: Clean Now We are migrating from EFI_PRINT() to log macro's. Signed-off-by: AKASHI Takahiro --- lib/efi_loader/efi_image_loader.c | 54 +++++++++++++++---------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/lib/efi_loader/efi_image_loader.c b/lib/efi_loader/efi_image_loader.c index 961139888504..fe8e4a89082c 100644 --- a/lib/efi_loader/efi_image_loader.c +++ b/lib/efi_loader/efi_image_loader.c @@ -238,7 +238,7 @@ efi_status_t efi_image_region_add(struct efi_image_regions *regs, int i, j; if (regs->num >= regs->max) { - EFI_PRINT("%s: no more room for regions\n", __func__); + log_err("%s: no more room for regions\n", __func__); return EFI_OUT_OF_RESOURCES; } @@ -263,7 +263,7 @@ efi_status_t efi_image_region_add(struct efi_image_regions *regs, } /* new data overlapping registered region */ - EFI_PRINT("%s: new region already part of another\n", __func__); + log_err("%s: new region already part of another\n", __func__); return EFI_INVALID_PARAMETER; } @@ -434,8 +434,8 @@ bool efi_image_parse(void *efi, size_t len, struct efi_image_regions **regp, bytes_hashed = opt->SizeOfHeaders; align = opt->FileAlignment; } else { - EFI_PRINT("%s: Invalid optional header magic %x\n", __func__, - nt->OptionalHeader.Magic); + log_err("%s: Invalid optional header magic %x\n", __func__, + nt->OptionalHeader.Magic); goto err; } @@ -445,7 +445,7 @@ bool efi_image_parse(void *efi, size_t len, struct efi_image_regions **regp, nt->FileHeader.SizeOfOptionalHeader); sorted = calloc(sizeof(IMAGE_SECTION_HEADER *), num_sections); if (!sorted) { - EFI_PRINT("%s: Out of memory\n", __func__); + log_err("%s: Out of memory\n", __func__); goto err; } @@ -464,7 +464,7 @@ bool efi_image_parse(void *efi, size_t len, struct efi_image_regions **regp, efi_image_region_add(regs, efi + sorted[i]->PointerToRawData, efi + sorted[i]->PointerToRawData + size, 0); - EFI_PRINT("section[%d](%s): raw: 0x%x-0x%x, virt: %x-%x\n", + log_debug("section[%d](%s): raw: 0x%x-0x%x, virt: %x-%x\n", i, sorted[i]->Name, sorted[i]->PointerToRawData, sorted[i]->PointerToRawData + size, @@ -478,7 +478,7 @@ bool efi_image_parse(void *efi, size_t len, struct efi_image_regions **regp, /* 3. Extra data excluding Certificates Table */ if (bytes_hashed + authsz < len) { - EFI_PRINT("extra data for hash: %zu\n", + log_debug("extra data for hash: %zu\n", len - (bytes_hashed + authsz)); efi_image_region_add(regs, efi + bytes_hashed, efi + len - authsz, 0); @@ -487,18 +487,18 @@ bool efi_image_parse(void *efi, size_t len, struct efi_image_regions **regp, /* Return Certificates Table */ if (authsz) { if (len < authoff + authsz) { - EFI_PRINT("%s: Size for auth too large: %u >= %zu\n", - __func__, authsz, len - authoff); + log_err("%s: Size for auth too large: %u >= %zu\n", + __func__, authsz, len - authoff); goto err; } if (authsz < sizeof(*auth)) { - EFI_PRINT("%s: Size for auth too small: %u < %zu\n", - __func__, authsz, sizeof(*auth)); + log_err("%s: Size for auth too small: %u < %zu\n", + __func__, authsz, sizeof(*auth)); goto err; } *auth = efi + authoff; *auth_len = authsz; - EFI_PRINT("WIN_CERTIFICATE: 0x%x, size: 0x%x\n", authoff, + log_debug("WIN_CERTIFICATE: 0x%x, size: 0x%x\n", authoff, authsz); } else { *auth = NULL; @@ -549,7 +549,7 @@ static bool efi_image_authenticate(void *efi, size_t efi_size) size_t auth_size; bool ret = false; - EFI_PRINT("%s: Enter, %d\n", __func__, ret); + log_debug("%s: Enter, %d\n", __func__, ret); if (!efi_secure_boot_enabled()) return true; @@ -560,7 +560,7 @@ static bool efi_image_authenticate(void *efi, size_t efi_size) if (!efi_image_parse(new_efi, efi_size, ®s, &wincerts, &wincerts_len)) { - EFI_PRINT("Parsing PE executable image failed\n"); + log_err("Parsing PE executable image failed\n"); goto out; } @@ -569,18 +569,18 @@ static bool efi_image_authenticate(void *efi, size_t efi_size) */ db = efi_sigstore_parse_sigdb(u"db"); if (!db) { - EFI_PRINT("Getting signature database(db) failed\n"); + log_err("Getting signature database(db) failed\n"); goto out; } dbx = efi_sigstore_parse_sigdb(u"dbx"); if (!dbx) { - EFI_PRINT("Getting signature database(dbx) failed\n"); + log_err("Getting signature database(dbx) failed\n"); goto out; } if (efi_signature_lookup_digest(regs, dbx, true)) { - EFI_PRINT("Image's digest was found in \"dbx\"\n"); + log_debug("Image's digest was found in \"dbx\"\n"); goto out; } @@ -602,12 +602,12 @@ static bool efi_image_authenticate(void *efi, size_t efi_size) break; if (wincert->dwLength <= sizeof(*wincert)) { - EFI_PRINT("dwLength too small: %u < %zu\n", + log_debug("dwLength too small: %u < %zu\n", wincert->dwLength, sizeof(*wincert)); continue; } - EFI_PRINT("WIN_CERTIFICATE_TYPE: 0x%x\n", + log_debug("WIN_CERTIFICATE_TYPE: 0x%x\n", wincert->wCertificateType); auth = (u8 *)wincert + sizeof(*wincert); @@ -617,12 +617,12 @@ static bool efi_image_authenticate(void *efi, size_t efi_size) break; if (auth_size <= sizeof(efi_guid_t)) { - EFI_PRINT("dwLength too small: %u < %zu\n", + log_debug("dwLength too small: %u < %zu\n", wincert->dwLength, sizeof(*wincert)); continue; } if (guidcmp(auth, &efi_guid_cert_type_pkcs7)) { - EFI_PRINT("Certificate type not supported: %pUs\n", + log_debug("Certificate type not supported: %pUs\n", auth); ret = false; goto out; @@ -632,14 +632,14 @@ static bool efi_image_authenticate(void *efi, size_t efi_size) auth_size -= sizeof(efi_guid_t); } else if (wincert->wCertificateType != WIN_CERT_TYPE_PKCS_SIGNED_DATA) { - EFI_PRINT("Certificate type not supported\n"); + log_debug("Certificate type not supported\n"); ret = false; goto out; } msg = pkcs7_parse_message(auth, auth_size); if (IS_ERR(msg)) { - EFI_PRINT("Parsing image's signature failed\n"); + log_err("Parsing image's signature failed\n"); msg = NULL; continue; } @@ -666,13 +666,13 @@ static bool efi_image_authenticate(void *efi, size_t efi_size) /* try black-list first */ if (efi_signature_verify_one(regs, msg, dbx)) { ret = false; - EFI_PRINT("Signature was rejected by \"dbx\"\n"); + log_debug("Signature was rejected by \"dbx\"\n"); goto out; } if (!efi_signature_check_signers(msg, dbx)) { ret = false; - EFI_PRINT("Signer(s) in \"dbx\"\n"); + log_debug("Signer(s) in \"dbx\"\n"); goto out; } @@ -682,7 +682,7 @@ static bool efi_image_authenticate(void *efi, size_t efi_size) continue; } - EFI_PRINT("Signature was not verified by \"db\"\n"); + log_debug("Signature was not verified by \"db\"\n"); } @@ -698,7 +698,7 @@ out: if (new_efi != efi) free(new_efi); - EFI_PRINT("%s: Exit, %d\n", __func__, ret); + log_debug("%s: Exit, %d\n", __func__, ret); return ret; } #else