From patchwork Sat Mar 13 21:47:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 399598 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp2272382jai; Sat, 13 Mar 2021 13:48:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJyya64E+sKxvqUTFxUKxEwspRGK91JaLbKoy39eWSAKYg2wT0WGLg5qDEslubTQp4ezrTGR X-Received: by 2002:aa7:c450:: with SMTP id n16mr21216346edr.16.1615672084911; Sat, 13 Mar 2021 13:48:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615672084; cv=none; d=google.com; s=arc-20160816; b=rBsWZUCo13SvWWKNDSDrE4KCAcLlud/W/vcnGaVh+JNKJC7+1UhPLsydqB0jxsI0AO JAAaYyLF+f1+iBfEVWJ2D/yrvpwxeOSU9BCHl8juxIjMz9zS/OHVoY5czDwh+9ZcSrbc kwC+zTKYlbodXK62vHUPezd51PodiR2X8qaKL3KPu0XVLE2PFkYzm+qMYSkUIbmHLLxS TvLz5w4q0FzU6fnzwdLFXS9HG7iHd55tVjjyPSJuIiBeY3uc+g+uj2QVVGf8At2uf7iZ /kXzdrYaXissgHFf690ELV5I6ysZeX03Qem7kOI1+PGFmkk4snuaxC+T5YmgDwxHVbij J3fQ== 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=Qon6nL0U2Weku93eM44LZcRau2CQVcxyMQv7APJraU4=; b=BIRQjnoOGFeWEUjn6FoTygYk3Q6fw6qZXM4Zpck0sHT+9MtcXTSXthcUBoelQRikGa WwjbQiATVd/rTL3dJcmfz3HH/UqlRYr1Ob4DvpszlX0wfGLolBiAvrKzODWYvMpfeSni 7r5nHH7ATUQKsqAQTMpFPUR/WWM5uc6oZDGjmj4iS+tjKWIfCUZHWcDlat3e8p8Q8VaR 4TMen5XtfHvjoY8oDXtSkFtfIpSXv+rp8/khw3Gt//YPEO9Np3h0kVoywY3UhIziH3ur 3FzX8au5jpF+V4kQEdfsxVSoSIpgJ1zTywu+jUEHprKTeJj3zJo9KUUPDVmW56FUG7xL 1+9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=M4tfaNBD; 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 bx25si8132294edb.242.2021.03.13.13.48.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 13 Mar 2021 13:48:04 -0800 (PST) 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=M4tfaNBD; 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 F32E082822; Sat, 13 Mar 2021 22:47:50 +0100 (CET) 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="M4tfaNBD"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 72C4582829; Sat, 13 Mar 2021 22:47:48 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450: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 24B8382806 for ; Sat, 13 Mar 2021 22:47:45 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ilias.apalodimas@linaro.org Received: by mail-ed1-x534.google.com with SMTP id w18so12926719edc.0 for ; Sat, 13 Mar 2021 13:47:45 -0800 (PST) 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=Qon6nL0U2Weku93eM44LZcRau2CQVcxyMQv7APJraU4=; b=M4tfaNBD91APAqOjYdcAjxldI78Qx89Ativ87AS0+NdN/3ygDwLcNYTYnH3L4HYfEF IhNuCwim2YgWntVV8xHmUstcvBAvZcI9McZkmpQQ+qiifbTygWBqcG5noiLJ4GAQFmJL ozBYBB94Yp20ZT8UsIM7lI5Gz0Cd8XQfjUvgXi1ESuSd7mJDz+uNPJnujVFeQhA6tbnL sCxIvMVkmFm6FFRaNWFwGE1fajzcQeBEASBRATTaz/Up2CJRz0N6FQCGixnyIfiIR0vL vxC3QZnwKbKAgPOJJ2FrwU7OJWGPDzY2SKrL1xFtp74ihfpvhPkyjq6ufrcclzE6Da+C JHEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Qon6nL0U2Weku93eM44LZcRau2CQVcxyMQv7APJraU4=; b=AW8fJWECgCwf5V+LMxYjZG6UnDc0QQ5ZQIOGQ8N9JHDWsMWrvFvgc+CTrrTUIqcfLm uGX0dmccj9q5KAThQgezd8G/fOrUTgMQKiGa/fsFRiGgWUFqhr3tKD8UAVY7xG6/r8iH z0LMLPSoMdP1r6fbBZ+gK53I1FlR9uOQfz+l5J49dtLrK+4q90rq0ABipVVQ0b96zm4J qWYbfAuB+tVWKNlk62hhWG1VxpuceH0k1Ip1HXKG/wIKzCqlogr+H+RrozC8sy5YGDUH BfSur0g5xLgYgMUxtQqlsfo2pkWUiHPPzPqbNcuRo6DPLEhQdLE2/U92mu08Dq/5Uy9k Smbw== X-Gm-Message-State: AOAM53076tMUf9StjW2rfb2ZGj/z+kJ38frzGJGQlWW2GAOCcXTytBp6 ii2g8PejtwSlfCzhHHiwafuqkw== X-Received: by 2002:aa7:c1d5:: with SMTP id d21mr21440918edp.167.1615672064806; Sat, 13 Mar 2021 13:47:44 -0800 (PST) Received: from apalos.home ([2a02:587:4647:e6c6:2e56:dcff:fe9a:8f06]) by smtp.gmail.com with ESMTPSA id a9sm1571144eds.33.2021.03.13.13.47.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 13 Mar 2021 13:47:44 -0800 (PST) From: Ilias Apalodimas To: xypron.glpk@gmx.de Cc: takahiro.akashi@linaro.org, Ilias Apalodimas , Alexander Graf , Sughosh Ganu , u-boot@lists.denx.de Subject: [PATCH 1/6 v2] efi_selftest: Remove loadfile2 for initrd selftests Date: Sat, 13 Mar 2021 23:47:32 +0200 Message-Id: <20210313214738.3257922-2-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210313214738.3257922-1-ilias.apalodimas@linaro.org> References: <20210313214738.3257922-1-ilias.apalodimas@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.102.4 at phobos.denx.de X-Virus-Status: Clean We are redefining how u-boot locates the initrd to load via the kernel LoadFile2 protocol. This selftest is not relevant any more, so remove it. A new one will be added later Signed-off-by: Ilias Apalodimas Reviewed-by: Heinrich Schuchardt --- lib/efi_selftest/Makefile | 1 - lib/efi_selftest/efi_selftest_load_initrd.c | 221 -------------------- 2 files changed, 222 deletions(-) delete mode 100644 lib/efi_selftest/efi_selftest_load_initrd.c -- 2.30.1 diff --git a/lib/efi_selftest/Makefile b/lib/efi_selftest/Makefile index b02fd56e0a79..50de581b7763 100644 --- a/lib/efi_selftest/Makefile +++ b/lib/efi_selftest/Makefile @@ -61,7 +61,6 @@ obj-$(CONFIG_CPU_V7) += efi_selftest_unaligned.o obj-$(CONFIG_EFI_LOADER_HII) += efi_selftest_hii.o obj-$(CONFIG_EFI_RNG_PROTOCOL) += efi_selftest_rng.o obj-$(CONFIG_EFI_GET_TIME) += efi_selftest_rtc.o -obj-$(CONFIG_EFI_LOAD_FILE2_INITRD) += efi_selftest_load_initrd.o obj-$(CONFIG_EFI_TCG2_PROTOCOL) += efi_selftest_tcg2.o ifeq ($(CONFIG_GENERATE_ACPI_TABLE),) diff --git a/lib/efi_selftest/efi_selftest_load_initrd.c b/lib/efi_selftest/efi_selftest_load_initrd.c deleted file mode 100644 index f591dcd2115e..000000000000 --- a/lib/efi_selftest/efi_selftest_load_initrd.c +++ /dev/null @@ -1,221 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* - * efi_selftest_load_initrd - * - * Copyright (c) 2020 Ilias Apalodimas - * - * This test checks the FileLoad2 protocol. - * A known file is read from the file system and verified. - * - * An example usage - given a file image with a file system in partition 1 - * holding file initrd - is: - * - * * Configure the sandbox with - * - * CONFIG_EFI_SELFTEST=y - * CONFIG_EFI_LOAD_FILE2_INITRD=y - * CONFIG_EFI_INITRD_FILESPEC="host 0:1 initrd" - * - * * Run ./u-boot and execute - * - * host bind 0 image - * setenv efi_selftest load initrd - * bootefi selftest - * - * This would provide a test output like: - * - * Testing EFI API implementation - * - * Selected test: 'load initrd' - * - * Setting up 'load initrd' - * Setting up 'load initrd' succeeded - * - * Executing 'load initrd' - * Loaded 12378613 bytes - * CRC32 2997478465 - * - * Now the size and CRC32 can be compared to the provided file. - */ - -#include -#include -#include - -static struct efi_boot_services *boottime; - -static struct efi_initrd_dp dp = { - .vendor = { - { - DEVICE_PATH_TYPE_MEDIA_DEVICE, - DEVICE_PATH_SUB_TYPE_VENDOR_PATH, - sizeof(dp.vendor), - }, - EFI_INITRD_MEDIA_GUID, - }, - .end = { - DEVICE_PATH_TYPE_END, - DEVICE_PATH_SUB_TYPE_END, - sizeof(dp.end), - } -}; - -static struct efi_initrd_dp dp_invalid = { - .vendor = { - { - DEVICE_PATH_TYPE_MEDIA_DEVICE, - DEVICE_PATH_SUB_TYPE_VENDOR_PATH, - sizeof(dp.vendor), - }, - EFI_INITRD_MEDIA_GUID, - }, - .end = { - 0x8f, /* invalid */ - 0xfe, /* invalid */ - sizeof(dp.end), - } -}; - -static int setup(const efi_handle_t handle, - const struct efi_system_table *systable) -{ - boottime = systable->boottime; - - return EFI_ST_SUCCESS; -} - -static int execute(void) -{ - struct efi_load_file_protocol *lf2; - struct efi_device_path *dp2, *dp2_invalid; - efi_status_t status; - efi_handle_t handle; - char buffer[64]; - efi_uintn_t buffer_size; - void *buf; - u32 crc32; - - memset(buffer, 0, sizeof(buffer)); - - dp2 = (struct efi_device_path *)&dp; - status = boottime->locate_device_path(&efi_guid_load_file2_protocol, - &dp2, &handle); - if (status != EFI_SUCCESS) { - efi_st_error("Unable to locate device path\n"); - return EFI_ST_FAILURE; - } - - status = boottime->handle_protocol(handle, - &efi_guid_load_file2_protocol, - (void **)&lf2); - if (status != EFI_SUCCESS) { - efi_st_error("Unable to locate protocol\n"); - return EFI_ST_FAILURE; - } - - /* Case 1: - * buffer_size can't be NULL - * protocol can't be NULL - */ - status = lf2->load_file(lf2, dp2, false, NULL, &buffer); - if (status != EFI_INVALID_PARAMETER) { - efi_st_error("Buffer size can't be NULL\n"); - return EFI_ST_FAILURE; - } - buffer_size = sizeof(buffer); - status = lf2->load_file(NULL, dp2, false, &buffer_size, &buffer); - if (status != EFI_INVALID_PARAMETER) { - efi_st_error("Protocol can't be NULL\n"); - return EFI_ST_FAILURE; - } - - /* - * Case 2: Match end node type/sub-type on device path - */ - dp2_invalid = (struct efi_device_path *)&dp_invalid; - buffer_size = sizeof(buffer); - status = lf2->load_file(lf2, dp2_invalid, false, &buffer_size, &buffer); - if (status != EFI_INVALID_PARAMETER) { - efi_st_error("Invalid device path type must return EFI_INVALID_PARAMETER\n"); - return EFI_ST_FAILURE; - } - - status = lf2->load_file(lf2, dp2_invalid, false, &buffer_size, &buffer); - if (status != EFI_INVALID_PARAMETER) { - efi_st_error("Invalid device path sub-type must return EFI_INVALID_PARAMETER\n"); - return EFI_ST_FAILURE; - } - - /* - * Case 3: - * BootPolicy 'true' must return EFI_UNSUPPORTED - */ - buffer_size = sizeof(buffer); - status = lf2->load_file(lf2, dp2, true, &buffer_size, &buffer); - if (status != EFI_UNSUPPORTED) { - efi_st_error("BootPolicy true must return EFI_UNSUPPORTED\n"); - return EFI_ST_FAILURE; - } - - /* - * Case: Pass buffer size as zero, firmware must return - * EFI_BUFFER_TOO_SMALL and an appropriate size - */ - buffer_size = 0; - status = lf2->load_file(lf2, dp2, false, &buffer_size, NULL); - if (status != EFI_BUFFER_TOO_SMALL || !buffer_size) { - efi_st_printf("buffer_size: %u\n", (unsigned int)buffer_size); - efi_st_printf("status: %x\n", (unsigned int)status); - efi_st_error("Buffer size not updated\n"); - return EFI_ST_FAILURE; - } - - /* - * Case: Pass buffer size as smaller than the file_size, - * firmware must return * EFI_BUFFER_TOO_SMALL and an appropriate size - */ - buffer_size = 1; - status = lf2->load_file(lf2, dp2, false, &buffer_size, &buffer); - if (status != EFI_BUFFER_TOO_SMALL || buffer_size <= 1) { - efi_st_error("Buffer size not updated\n"); - return EFI_ST_FAILURE; - } - - status = boottime->allocate_pool(EFI_BOOT_SERVICES_DATA, buffer_size, - &buf); - if (status != EFI_SUCCESS) { - efi_st_error("Cannot allocate buffer\n"); - return EFI_ST_FAILURE; - } - - /* Case: Pass correct buffer, load the file and verify checksum*/ - status = lf2->load_file(lf2, dp2, false, &buffer_size, buf); - if (status != EFI_SUCCESS) { - efi_st_error("Loading initrd failed\n"); - return EFI_ST_FAILURE; - } - - efi_st_printf("Loaded %u bytes\n", (unsigned int)buffer_size); - status = boottime->calculate_crc32(buf, buffer_size, &crc32); - if (status != EFI_SUCCESS) { - efi_st_error("Could not determine CRC32\n"); - return EFI_ST_FAILURE; - } - efi_st_printf("CRC32 %.8x\n", (unsigned int)crc32); - - status = boottime->free_pool(buf); - if (status != EFI_SUCCESS) { - efi_st_error("Cannot free buffer\n"); - return EFI_ST_FAILURE; - } - - return EFI_ST_SUCCESS; -} - -EFI_UNIT_TEST(load_initrd) = { - .name = "load initrd", - .phase = EFI_EXECUTE_BEFORE_BOOTTIME_EXIT, - .setup = setup, - .execute = execute, - .on_request = true, -};