From mboxrd@z Thu Jan 1 00:00:00 1970 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 BB20DC38142 for ; Tue, 31 Jan 2023 15:07:36 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7019985A8F; Tue, 31 Jan 2023 16:07:33 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=konsulko.com 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=konsulko.com header.i=@konsulko.com header.b="moQ2fgXY"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5FC4785A8F; Tue, 31 Jan 2023 16:07:31 +0100 (CET) Received: from mail-yw1-x1134.google.com (mail-yw1-x1134.google.com [IPv6:2607:f8b0:4864:20::1134]) (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 E037F858B3 for ; Tue, 31 Jan 2023 16:07:27 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=trini@konsulko.com Received: by mail-yw1-x1134.google.com with SMTP id 00721157ae682-506609635cbso207118017b3.4 for ; Tue, 31 Jan 2023 07:07:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; s=google; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=QPGNJF4dcUuk3riC+SppdJDrUEZmUBCR/FbsLkCyiuc=; b=moQ2fgXYuyk4frT+28PZPReV+Qbd4MhLH1GC7g4XGx6wHI01jduNFf+b8NqFKIjOMY QCBhvGGnQHHZ0hy+Hc4eer77qgqDGL9wcAEUQkvxg8cpt28KC4MwjOGAaoaC7mNU86o6 rGha1dBPXF4XGqbrdJTwY6BYNCeApcipLhWQU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=QPGNJF4dcUuk3riC+SppdJDrUEZmUBCR/FbsLkCyiuc=; b=wwhD1xza05QJYXxcbT1MuLRZAz8StkKmDCIQuwOCSxnm+k3KpmT3+s611PVQjZPsEz h5/GH06dMXYhHxzaol/+GY9X66aLa8lJiPb+uRW2d0izJqarNXX62sgRW564oSKEF7uX dp21qyPRGtvjlxQh5EFg2kLHzDpO+5aBhvEyZlvFub5dVUZrVPDLEqBBcI22/Fet8VjH QXqJtoo7mUAGgYUBkrxfAUcXAfx2TGstBSFippQGKSlixkHMk1EL/wzTmWn+cjuLpfAG luXay/dkfeBIddb+i6Opt4qHZk7V43ZxEBy6wo/sDDMNr9Uq4MEcJUy24lfftl89T1je /NYw== X-Gm-Message-State: AO0yUKU3p4+/+cSvHt39jTJx8KfF2kuWnwXnDIUtPZ4+pZE3EMlfjtXr 9yOACWNnT0Hl0BQh4X1F5PIBBg== X-Google-Smtp-Source: AK7set/8opKRoAjOwZM40fWFRfKEStMcRcY2v6bv8/3AW5s/s38VFy3ZGObzvHeqyvEnHrUTleZwdg== X-Received: by 2002:a05:7500:2249:b0:f3:b3d9:2e78 with SMTP id k9-20020a057500224900b000f3b3d92e78mr768662gac.69.1675177646403; Tue, 31 Jan 2023 07:07:26 -0800 (PST) Received: from bill-the-cat (2603-6081-7b00-6400-ab18-c1e6-432f-199f.res6.spectrum.com. [2603:6081:7b00:6400:ab18:c1e6:432f:199f]) by smtp.gmail.com with ESMTPSA id l190-20020a3789c7000000b006cfc9846594sm10235218qkd.93.2023.01.31.07.07.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Jan 2023 07:07:25 -0800 (PST) Date: Tue, 31 Jan 2023 10:07:24 -0500 From: Tom Rini To: Ilias Apalodimas Cc: Heinrich Schuchardt , u-boot@lists.denx.de, Andre Przywara Subject: Re: [PATCH 1/1] efi_loader: stop watchdogs in ExitBootServices() Message-ID: References: <20230128085745.18389-1-heinrich.schuchardt@canonical.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="b09jQvgiVs+SZNr4" Content-Disposition: inline In-Reply-To: X-Clacks-Overhead: GNU Terry Pratchett 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 --b09jQvgiVs+SZNr4 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Jan 31, 2023 at 02:03:10PM +0200, Ilias Apalodimas wrote: > Hi all, >=20 > On Mon, Jan 30, 2023 at 01:30:49PM -0500, Tom Rini wrote: > > On Mon, Jan 30, 2023 at 01:13:55PM -0500, Tom Rini wrote: > > > On Sat, Jan 28, 2023 at 09:57:45AM +0100, Heinrich Schuchardt wrote: > > > > > > > The UEFI specification requires for ExitBootServices() that "the bo= ot > > > > services watchdog timer is disabled". We already disable the softwa= re > > > > watchdog. We should additionally disable the hardware watchdogs. > > > > > > > > Reported-by: Andre Przywara > > > > Signed-off-by: Heinrich Schuchardt > > > > --- > > > > lib/efi_loader/efi_boottime.c | 10 ++++++---- > > > > 1 file changed, 6 insertions(+), 4 deletions(-) > > > > > > > > diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boo= ttime.c > > > > index ba28989f36..71215af9d2 100644 > > > > --- a/lib/efi_loader/efi_boottime.c > > > > +++ b/lib/efi_loader/efi_boottime.c > > > > @@ -19,6 +19,7 @@ > > > > #include > > > > #include > > > > #include > > > > +#include > > > > #include > > > > #include > > > > #include > > > > @@ -2171,6 +2172,11 @@ static efi_status_t EFIAPI efi_exit_boot_ser= vices(efi_handle_t image_handle, > > > > list_del(&evt->link); > > > > } > > > > > > > > + /* Disable watchdogs */ > > > > + efi_set_watchdog(0); > > > > + if IS_ENABLED(CONFIG_WDT) > > > > + wdt_stop_all(); > > > > + > > > > if (!efi_st_keep_devices) { > > > > bootm_disable_interrupts(); > > > > if (IS_ENABLED(CONFIG_USB_DEVICE)) > > > > @@ -2196,10 +2202,6 @@ static efi_status_t EFIAPI efi_exit_boot_ser= vices(efi_handle_t image_handle, > > > > > > > > /* Recalculate CRC32 */ > > > > efi_update_table_header_crc32(&systab.hdr); > > > > - > > > > - /* Give the payload some time to boot */ > > > > - efi_set_watchdog(0); > > > > - schedule(); > > > > out: > > > > if (IS_ENABLED(CONFIG_EFI_TCG2_PROTOCOL)) { > > > > if (ret !=3D EFI_SUCCESS) > > > > > > I thought we had rejected going down this path since the UEFI spec is > > > unhelpfully wrong if it insists this? > > > > Because, to be clear, stopping hardware watchdogs is not to be done. The > > one in-tree caller of wdt_stop_all is very questionable. You cannot > > seriously stop a watchdog until someone else can hopefully resume it as > > that violates the function of a hardware watchdog. A pure software > > watchdog is one thing, and a hardware watchdog is another. I feel like > > the most likely answer here is that someone needs to, still, push back > > to the UEFI specification to get hardware watchdogs better understood > > and handled, as it must never be stopped once started and if you cannot > > reach the next stage in time, that's an engineering issue to resolve. My > > first guess is that ExitBootServices should service the watchdog one > > last time to ensure the largest window of time for the OS to take over > > servicing of the watchdog. > > >=20 > There's two scenarios I can think of > 1. After U-Boot is done it can disable the hardware watchdog. > The kernel will go through the EFI-stub -> kernel proper -> watchdog > gets re-initialized. In that case you are *hoping* that device won't > hang in the efi-stub or until the wd is up again. > 2. EFI makes sure the hardware wd gets configured with the highest allowed > value. The efi-stub doesn't have any driver to refresh the wd, so we > will again rely on the wd driver coming up and refreshing the timers. You cannot stop the hardware watchdog, period. I think in the previous thread about this it was noted that some hardware watchdogs cannot be disabled, it's not function that the watchdog supports. Someone needs to go and talk with the UEFI specification people and get this addressed. There is no sane path for "disable the hardware watchdog". --=20 Tom --b09jQvgiVs+SZNr4 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQGzBAABCgAdFiEEGjx/cOCPqxcHgJu/FHw5/5Y0tywFAmPZLqwACgkQFHw5/5Y0 tyxbPwv+Ns03xTiGxDA3dEGeZC6PepOwMutG4L757nCiHq4g2VkTO75TzvM2+MKc but0VGyupwkCaDz3q0MNzBv8fnBR9WB8Q4zsejpwzf7DVHHLqRNhhjhCt3XnB2Qp W+YAvuC2qXEZE08eUIMxkNA7nB+prbfxdY1aJ8KOKPv0sE2QneLeHrp4cZvcGvDq faJMNKFlPnq2ohkVpvfGALXkyaR9AlPshgngY33FvSq/Y6PjOVv96Z3oMJ3RyXm1 imQK3kAUlIjpxMTBaEwX0iJHS3WRTw7PigunRDugJ3rmPhw77vvi4riq2vGdQp3x E1Cm+vn33byP9QbEIlnlOObN4XaoangFvyIHFGbfwNkjnjNjNZju85ZSYL6Kgvj2 esqBULi6c88ZSCPw37OkzEt0ecM+SnbwR7BzyqQ4J0eHzViSfCTMMzebqQ/sd1PZ mmL8Y8+JlwM6v4oCBl46iytbRAtCFuy/ypY6yr72BzrjQi4z4KZq1s/AcCd9Oxdc uE8WLEEQ =2BKn -----END PGP SIGNATURE----- --b09jQvgiVs+SZNr4--