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 87B7BC38142 for ; Wed, 1 Feb 2023 08:33:44 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2F8F385C20; Wed, 1 Feb 2023 09:33:42 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=prevas.dk 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=prevas.dk header.i=@prevas.dk header.b="HZdoHPX+"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 60B5B85C1B; Wed, 1 Feb 2023 09:33:39 +0100 (CET) Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2072c.outbound.protection.outlook.com [IPv6:2a01:111:f400:7eaf::72c]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 5EE6485C1E for ; Wed, 1 Feb 2023 09:32:59 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=prevas.dk Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=rasmus.villemoes@prevas.dk ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KY0CYFH3QZ+Kxn1PIcBG8DqDYay0hc3bd/mnAKdC76PjZsBgBEOSSI7poghAY7zj3AqH3D50T3v6tt+hqmyxvvHDGlJPwwHGxXKJ6a0pxG+OREzOwhNkwbXTFlDbyoTL7je2m4e+b7NPqKV+WrFmoFLYyVkBmgVVcBZfGgKJeGi8ZmsmaqgiZlQ5x3sFFLTD17Q7TXrVAujiL8EqRYTf2rdSdryvsYP1obHFwsDFxVLuzP/U8pjErvmBNgnxkAHWn19yaCjG7UhAHA3Bf1FJ7tEgr+IaVxDuR4Y7BXulOxdlB36GsRwooOQAcpyyTHTMn5MMPFapNNZZJ6sNeog//Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=sSQc9uGssZiFCum6G60KPrJaXtjJaIOPNKdx7rW2jU8=; b=UhtZ/RBHNJsk7XvLutnf9L80YqiHQGGt8rqMlKBYMaTkiZi0/oObSCvKrcYIeFZYqHWfuYEjJsvTPqOKgKC/Uz4DESIiE3EayTbdf6QlvtUFvtbMgLdCMMUIsTUG0b3Mb0kncDTg1qW7VW0q8r/R5NhgW0bTW+fffhYLWeMNQ872qeRv5w2jkRiGFI05AQEp6yM6HGB1ZJGHAVHxcCG0+ord30/1cQ0EQ2TNcqxOo3jilcYVu9x33zHw/L5z5HInNq0P0qmXgDkffUD9Oyo9IV9LxgNlopyhAVCC0j+0WfRFvc6kusTNhrcnYooCiTMkFUvzcmNGvIjMku26+h5AyQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=prevas.dk; dmarc=pass action=none header.from=prevas.dk; dkim=pass header.d=prevas.dk; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=prevas.dk; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=sSQc9uGssZiFCum6G60KPrJaXtjJaIOPNKdx7rW2jU8=; b=HZdoHPX+hiYmCNU+8JNF6vkKwrKWgk7pfsG6qbZR/i69ZPuyGjmmqpLCf87z9zmok/gnkBukXgZME+jhrPjfvxQqsoMZEglRGfzvNK0aG6UuwYzVg2UvkztNRpS2YorzIeEwJJA1QO8ojz9r9ANiWWdByYx+yKLrvjI9XZ7Yn8E= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=prevas.dk; Received: from DU0PR10MB5266.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:10:34a::22) by PR3PR10MB3852.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:102:40::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.38; Wed, 1 Feb 2023 08:32:57 +0000 Received: from DU0PR10MB5266.EURPRD10.PROD.OUTLOOK.COM ([fe80::1286:27db:9d8a:4b72]) by DU0PR10MB5266.EURPRD10.PROD.OUTLOOK.COM ([fe80::1286:27db:9d8a:4b72%9]) with mapi id 15.20.6043.036; Wed, 1 Feb 2023 08:32:57 +0000 Message-ID: <071ebaa1-2f62-1628-106d-4f4e441c4f0d@prevas.dk> Date: Wed, 1 Feb 2023 09:32:54 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: [PATCH 1/1] efi_loader: stop watchdogs in ExitBootServices() Content-Language: en-US, da To: Tom Rini , Ilias Apalodimas Cc: Heinrich Schuchardt , u-boot@lists.denx.de, Andre Przywara References: <20230128085745.18389-1-heinrich.schuchardt@canonical.com> From: Rasmus Villemoes In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: AM4PR0101CA0055.eurprd01.prod.exchangelabs.com (2603:10a6:200:41::23) To DU0PR10MB5266.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:10:34a::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU0PR10MB5266:EE_|PR3PR10MB3852:EE_ X-MS-Office365-Filtering-Correlation-Id: badc7c4f-27bf-449f-1e4c-08db042eebc5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pj4ECRqWbx/GSfTume63paBGxeeY74hqOWeip5JA2xmJbZCnPUtby0LpEysWeBsQEs+mQmFLGwh3UcN/rs4mAiDlZszHwrKBctnUXa/DbmeecPuTKBDsZLVnnj7/1twkv5iQlhvsj8mvbQMGTxee6enOVM8X1q2A2YjRR8aMNWtwVySDGnWPyT6a9ROzxUc5HLfiWNwmKKhXPGhvqdvj5y5UcS1aKaPrtbZ9bydFeMcCbJuEqgkd7WwX72nJqI7pJg2XWRqpRMipY3PAXgMnzmLy0U6XuRSKp327FqArrVlOJmkVS5aWpH1utV2Ued1TkSkZgXQRrOybSc1SR/4CRg1uQdn7UudKcTPdvmQlUKQhx1Z03bXuMByVKJn3xWAbBHoOJaA9RgQg9qRd6gbnkQt6152T1AV2H0lS1Dm66GwDXHFDzdjiOTnN6u1QTmjNkmJz9/F89B5Hvtv+2J87U7ZDqeFb9gcSd7l8F/2KlD/CB/indpMjdVOf+yHQz0EPKyI6nFOJs5cAJIw7/KoldUILCsleMXWnk2VgWRMZvSE6GuZljRGMZCznlL9pP+z0zeX4siRAwlCsXfus897rRYT9pqZ/ILf8zCPB/N0yXaMViCmjcjRXU0JWv8nUi9Vzb2Og6DW9iizFk7Gb49oejYZz2N2Lp9ZRncBhdnytGusednlI24fPu5bVk6VW0UiGvq3GqHD2eEu8ZStaBNLu3RRGz5fntPfqs22od9fhgTBKChclR7tK+/Vs6c1w1CUYSzB+RWPqQwclI4j76UsSYD4UvfyyPtpkUBKsutZ9DcU= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DU0PR10MB5266.EURPRD10.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(13230025)(366004)(376002)(39850400004)(396003)(346002)(136003)(451199018)(31686004)(6666004)(41300700001)(36756003)(110136005)(54906003)(66946007)(8676002)(316002)(4326008)(66476007)(8936002)(66556008)(5660300002)(8976002)(38100700002)(38350700002)(86362001)(31696002)(6506007)(186003)(6512007)(26005)(2906002)(44832011)(478600001)(6486002)(52116002)(83380400001)(2616005)(207123002)(43740500002)(45980500001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?K2M0TnZ0VkRsSGNxcGRNOGxyVFcwWW9ReDlmNG1MT1ZMZXllY2owQzJnNCtR?= =?utf-8?B?QkhJZ3IzZHBKYStZc0pjUVlEN0hwcFdKam11bTFSZUpiSmJSd09ENHhMb2Ir?= =?utf-8?B?TExkMFpqaHZUcnIyWk9pRXpJd1dHTjVLZDFNNDZDd0lXS1EvZ1YrYVhIaDdt?= =?utf-8?B?aEphUjJ2cEFaamFjQWkwZVMxUGlkVnJNM1VBYm1TUWR1Sm5zYU5FL0RIZzVq?= =?utf-8?B?MzM2aXM0VW1rYWE0RkNmbWdnSUE0SCtKQ2xZSkdyWUs0VFc3U2NGaW55b203?= =?utf-8?B?SmtNNU5yczhTYXNpWXhwRmgwei92RFdiUnY5VUZDdldzWTNpaVlaUEVneHJL?= =?utf-8?B?ek5Hd3l4ZjFPMzhOTlN5RVpTdWZ6a0pGSTIvMCtka3E5b3FjSEx5dGs0bzg0?= =?utf-8?B?MERkK1BDdTBYcTNSQVZiRlhML2drYkZnZlhrdE83Tnp5ZmVwSGZtSmhkMTVZ?= =?utf-8?B?OENuc1BQL1JEcEdlUUZkM1Y0S2dpZ0tLWE91WWFxbFJkQXRGT3M4RUNmNFho?= =?utf-8?B?Q3FSc0FzbmF4eklrRnVnQzhqYk0zSTRmeWRvVG92UjlTcVBOT05kbWpyTjN5?= =?utf-8?B?RlF2bE82ZzlvS0dVL3QyVHljbVJ6UE1XSjJyaGlQOGZmb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GaFZVYkxJenJIODNGbFZj?= =?utf-8?B?SGFYYjY3blg4eldZaWJIT1JqY0RGSC8wYmJsZTIyY01pM0NwL09FUzdPWXJS?= =?utf-8?B?Q2RXRS8vRUF5L1laYy9DYzQzM3E1VHVsb0RxNUVVWG14NFF1dWx5VTF0YzB6?= =?utf-8?B?aEIzV2pPeWY5M2JHbE5VamU4RnpUcHJmS2dpcFk4WnV0VTFjZ0QwZHd0bnlR?= =?utf-8?B?QlBFeDNLdWsvZ3FpQjR1U2J3RHk1UTdnOGZEQTU0ZktUUWJhQXJNWTE1VUZh?= =?utf-8?B?bkRqUVdvZURTRUZyaHJtVW5ONGk2YUpGMlA5YWpNV0JEczg5cUtYbUFsQWdD?= =?utf-8?B?QmFPRGJaWVNMakpWcS8rNTBEZEJIT25hdUhUNG9SdjZ4S2RLdEpsU2EyN2FO?= =?utf-8?B?SFhUckI0RE5hU1JBVjNiWGQ1TFRlVWFtbURTL2pnRDM2Wk5DOFFucWtPd1Vo?= =?utf-8?B?ZGRJditkaURTcXJhYlkyR2NrVXg4b0R3dXlwd2V6cmRoaXpHM2JoZmhaY3k2?= =?utf-8?B?U0VxT0xLMmVXZ2NzOS9jeU5LMDRXU1VHYThPeUlmL3BabWcveitlZ1h0QjV3?= =?utf-8?B?U01qRkNSYVNRV09rRDAxZzZKMlJ2Q3orRGtBbmR2OVo3TFNZSlZGWGVOakhx?= =?utf-8?B?SGc9PQ==?= X-OriginatorOrg: prevas.dk X-MS-Exchange-CrossTenant-Network-Message-Id: badc7c4f-27bf-449f-1e4c-08db042eebc5 X-MS-Exchange-CrossTenant-AuthSource: DU0PR10MB5266.EURPRD10.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Feb 2023 08:32:57.5346 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: d350cf71-778d-4780-88f5-071a4cb1ed61 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: J0aICGYhTWWNSS3D5BQa3tKv4Vtph7EjZNB+VlePbDRNpcvvDx8UP/9403UgP8nErMgXH26nXjyfv4vGHIBaiNbg9bWLUArDefUYK43yyWM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3PR10MB3852 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 On 31/01/2023 16.07, Tom Rini wrote: > On Tue, Jan 31, 2023 at 02:03:10PM +0200, Ilias Apalodimas wrote: >> Hi all, >> >> 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 boot >>>>> services watchdog timer is disabled". We already disable the software >>>>> 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_boottime.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_services(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_services(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 != 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. >>> >> >> 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". > Indeed. But I think one reasonable thing to do would be to say "ok, the payload is now ready to assume responsibility, so on the U-Boot side we stop _petting_ the watchdog(s)" (i.e. nowadays that would mean deregistering them from the cyclic framework), even if the payload still performs calls into U-Boot where we would otherwise use the opportunity to feed the watchdog. And of course it's reasonable in that case to do one last ping. Because it's also a recipe for disaster if, say, both the payload and U-Boot toggles the same gpio or frobs the same SOC registers. Unrelated, but does anybody know who "the UEFI specification people" are and how to reach out? Rasmus