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 17E5EC19F28 for ; Sat, 30 Jul 2022 21:57:21 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9985784547; Sat, 30 Jul 2022 23:54:03 +0200 (CEST) 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="GuJefeyo"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D6B67844CF; Sat, 30 Jul 2022 23:53:44 +0200 (CEST) Received: from mail-oi1-x22f.google.com (mail-oi1-x22f.google.com [IPv6:2607:f8b0:4864:20::22f]) (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 4955D8412C for ; Sat, 30 Jul 2022 23:53:42 +0200 (CEST) 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-oi1-x22f.google.com with SMTP id h188so8908259oia.13 for ; Sat, 30 Jul 2022 14:53:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=BoMLxw7WouCH8fkj0ncmhxkal2jz5+XUVuC7JsuRFwI=; b=GuJefeyopV7Shglqr1zCEPhLqwi1cAmynTlBjIY5thBC9xEJA9nZN2jFMkOuKB3yFn nj12l7gjg0v4/uDnQ0T+yF5bNzFbU6qmR8/ZnPSy2G469fLN4bOgpW0F6vCLn8iv54bN Mqxt6urwLFIIZAPEZ9YkGf153K4LbrQNbB3QQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=BoMLxw7WouCH8fkj0ncmhxkal2jz5+XUVuC7JsuRFwI=; b=3LHd7ONJ7JSNrd8V0/kuSO7sJBUl4CH8/qK77EivTeEWxdAIx6dhGClHk6ZWpLfJqk cOgywwQGlnClynrHGtckVH5YVAs71if4PNu8lRQjeQlMYNK6DrYnp1CTQ2rr7YqMvHRy HcCMFI9EBSpH/QkPjoefEsH14P3mt720YQg1r7bDTlWRROKkY86303N4u5RxNhVQWGMG 0BVmw3ODNI5FT7WgPk2YSOHRAS1dsLaGaz+/rGgG+IxZEK8KuXJdEPk3pXBLZIgFkB9j f8eEtcH90AanN2aEmFPAQWeqLtg3vfX8DN978RcWBg9p5mRjCIOMaTZyKISHXS4rYmVr zYAw== X-Gm-Message-State: AJIora9n/1jtZJM/kpvtIBLJT6nhYNzWs0rG1JLivzQclCTWxxZoCxPY TQE3N9Zx/PrOvZOiCWmDEm4GJ6FJiWhHov1f X-Google-Smtp-Source: AGRyM1s3T6nVByxDOADn74O1wqDI6Bc9I6WrFqhgCIwfzSMt+fRSkrHpNaj/Q/JOz/JsgOrvX3Cb3g== X-Received: by 2002:a05:6808:14d4:b0:33b:1489:8752 with SMTP id f20-20020a05680814d400b0033b14898752mr4257000oiw.174.1659218005885; Sat, 30 Jul 2022 14:53:25 -0700 (PDT) Received: from sjg1.lan (c-67-190-102-125.hsd1.co.comcast.net. [67.190.102.125]) by smtp.gmail.com with ESMTPSA id 19-20020a544193000000b0032f75714af1sm1699656oiy.18.2022.07.30.14.53.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 30 Jul 2022 14:53:25 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Bin Meng , Simon Glass Subject: [PATCH v2 20/35] bootstd: Allow EFI bootmgr to support an invalid bootflow Date: Sat, 30 Jul 2022 15:52:22 -0600 Message-Id: <20220730215237.818368-16-sjg@chromium.org> X-Mailer: git-send-email 2.37.1.455.g008518b4e5-goog In-Reply-To: <20220730215237.818368-1-sjg@chromium.org> References: <20220730215237.818368-1-sjg@chromium.org> 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.6 at phobos.denx.de X-Virus-Status: Clean For most testing we don't want this bootmeth to actually do anything. For the one test where we do, add a test hook to obtain the correct behaviour. This will allow us to bind the device always, rather than just doing it for this test. Signed-off-by: Simon Glass --- (no changes since v1) arch/sandbox/include/asm/test.h | 11 +++++++++++ boot/bootmeth_efi_mgr.c | 32 ++++++++++++++++++++++++++------ test/boot/bootflow.c | 4 ++++ 3 files changed, 41 insertions(+), 6 deletions(-) diff --git a/arch/sandbox/include/asm/test.h b/arch/sandbox/include/asm/test.h index 015e96d53f8..53a036b3abf 100644 --- a/arch/sandbox/include/asm/test.h +++ b/arch/sandbox/include/asm/test.h @@ -304,4 +304,15 @@ int sandbox_cros_ec_get_pwm_duty(struct udevice *dev, uint index, uint *duty); */ int sandbox_sdl_set_bpp(struct udevice *dev, enum video_log2_bpp l2bpp); +/** + * sandbox_set_fake_efi_mgr_dev() - Control EFI bootmgr producing valid bootflow + * + * This is only used for testing. + * + * @dev: efi_mgr bootmeth device + * @fake_dev: true to produce a valid bootflow when requested, false to produce + * an error + */ +void sandbox_set_fake_efi_mgr_dev(struct udevice *dev, bool fake_dev); + #endif diff --git a/boot/bootmeth_efi_mgr.c b/boot/bootmeth_efi_mgr.c index 08d9328af4e..2f327c1f8ce 100644 --- a/boot/bootmeth_efi_mgr.c +++ b/boot/bootmeth_efi_mgr.c @@ -15,6 +15,22 @@ #include #include +/** + * struct efi_mgr_priv - private info for the efi-mgr driver + * + * @fake_bootflow: Fake a valid bootflow for testing + */ +struct efi_mgr_priv { + bool fake_dev; +}; + +void sandbox_set_fake_efi_mgr_dev(struct udevice *dev, bool fake_dev) +{ + struct efi_mgr_priv *priv = dev_get_priv(dev); + + priv->fake_dev = fake_dev; +} + static int efi_mgr_check(struct udevice *dev, struct bootflow_iter *iter) { int ret; @@ -29,13 +45,16 @@ static int efi_mgr_check(struct udevice *dev, struct bootflow_iter *iter) static int efi_mgr_read_bootflow(struct udevice *dev, struct bootflow *bflow) { - /* - * Just assume there is something to boot since we don't have any way - * of knowing in advance - */ - bflow->state = BOOTFLOWST_READY; + struct efi_mgr_priv *priv = dev_get_priv(dev); - return 0; + if (priv->fake_dev) { + bflow->state = BOOTFLOWST_READY; + return 0; + } + + /* To be implemented */ + + return -EINVAL; } static int efi_mgr_read_file(struct udevice *dev, struct bootflow *bflow, @@ -84,4 +103,5 @@ U_BOOT_DRIVER(bootmeth_efi_mgr) = { .of_match = efi_mgr_bootmeth_ids, .ops = &efi_mgr_bootmeth_ops, .bind = bootmeth_efi_mgr_bind, + .priv_auto = sizeof(struct efi_mgr_priv), }; diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c index a2ed8ac774f..22eef40c0e3 100644 --- a/test/boot/bootflow.c +++ b/test/boot/bootflow.c @@ -11,6 +11,8 @@ #include #include #include +#include +#include #include #include #include @@ -328,6 +330,8 @@ static int bootflow_system(struct unit_test_state *uts) ut_assertok(uclass_first_device_err(UCLASS_BOOTSTD, &bootstd)); ut_assertok(device_bind_driver(bootstd, "bootmeth_efi_mgr", "bootmgr", &dev)); + ut_assertok(device_probe(dev)); + sandbox_set_fake_efi_mgr_dev(dev, true); /* Add the system bootdev that it uses */ ut_assertok(device_bind_driver(bootstd, "system_bootdev", -- 2.37.1.455.g008518b4e5-goog