From nobody Thu Mar 28 17:55:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1528441103923997.4582999143366; Thu, 7 Jun 2018 23:58:23 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id C247D21106FC4; Thu, 7 Jun 2018 23:58:21 -0700 (PDT) Received: from mail-wm0-x243.google.com (mail-wm0-x243.google.com [IPv6:2a00:1450:400c:c09::243]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 04AA1210F201E for ; Thu, 7 Jun 2018 23:58:20 -0700 (PDT) Received: by mail-wm0-x243.google.com with SMTP id o13-v6so1380747wmf.4 for ; Thu, 07 Jun 2018 23:58:20 -0700 (PDT) Received: from dogfood.home (LFbn-NIC-1-75-91.w2-15.abo.wanadoo.fr. [2.15.165.91]) by smtp.gmail.com with ESMTPSA id x130-v6sm892491wme.24.2018.06.07.23.58.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Jun 2018 23:58:18 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:400c:c09::243; helo=mail-wm0-x243.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org 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; bh=RWqKvEvKmAO2K2dbqQlsQ1VVnNu/xEo9tC2DsTsKjcM=; b=ESVMBgjGvc+U1o/p8VrHS5d/msXumrsITAI0zdkyUAPzTQIoI4ukl6eKn17fiJgjS6 obeR2N9wPi1vJmzFDFLAuoawaLzOs1zqSSRdvQMYDLQOW0ozfRyiwI+1MHszzok587vv UqVALigcCCHSuIVO8WiHuKJeTAHv8ILo7Di2Y= 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; bh=RWqKvEvKmAO2K2dbqQlsQ1VVnNu/xEo9tC2DsTsKjcM=; b=D+OHe5LHLHAq/yrP/MkGWcZP/ERDOj4c9qNgLXFA/wkBYpaLvHzNDw1gM0avSSfJiH +kkZm6hvA0ct46OomSK5RO2QmW5qRJPC0QZHw55RC+9ZvHiJyCU4UDah9xmQ/PiRAgM7 Fljckfg8FKefqKIXTdaA7NzyQZ9g7mz4wEa8A3hVr+N64eNefXZuNNjVZKtoiMj04fXx ZdIk1m6PjEtD9177oMBY3YZvsD1DaQ0erQzFumWavMe0b4ST1SPwl+tdEng2D/M4NAOa D8rg295nF9W+GmA6JSmNHWKZS/nM8knNyzOQtvNZTTevUR9uVPFddCoTL5j9y+rt+10y orBQ== X-Gm-Message-State: APt69E3i5zWIII/QxLWDh3ntq4byDQlNnbHIBB8ufZXzajFXHE9+NwDA UqgwdlK1NYCGdWyoJiJWpPzEfHVhrZs= X-Google-Smtp-Source: ADUXVKJROorbGVwCfqIFup0hFoc1wymXN8OnPWrUKfxxSHrOgCuBCl/9u6Sl/zqrSYPqxgWYhrHuhw== X-Received: by 2002:a1c:e846:: with SMTP id f67-v6mr605786wmh.63.1528441099247; Thu, 07 Jun 2018 23:58:19 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Fri, 8 Jun 2018 08:58:07 +0200 Message-Id: <20180608065811.2065-2-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180608065811.2065-1-ard.biesheuvel@linaro.org> References: <20180608065811.2065-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH v2 1/5] MdeModulePkg/CapsulePei: clean Dcache before consuming capsule data X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: michael.d.kinney@intel.com, jiewen.yao@intel.com, star.zeng@intel.com, leif.lindholm@linaro.org, Ard Biesheuvel MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" When capsule updates are staged for processing after a warm reboot, they are copied into memory with the MMU and caches enabled. When the capsule PEI gets around to coalescing the capsule, the MMU and caches may still be disabled, and so on architectures where uncached accesses are incoherent with the caches (such as ARM and AARCH64), we may read stale data if we don't clean the caches to memory first. Note that this cache maintenance cannot be done during the invocation of UpdateCapsule(), since the ScatterGatherList structures are only identified by physical address, and at runtime, the firmware doesn't know whether and where this memory is mapped, and cache maintenance requires a virtual address. Reviewed-by: Jiewen Yao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- MdeModulePkg/Universal/CapsulePei/CapsulePei.inf | 1 + MdeModulePkg/Universal/CapsulePei/Common/CapsuleCoalesce.c | 38 ++++++++++= ++++------ 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/MdeModulePkg/Universal/CapsulePei/CapsulePei.inf b/MdeModulePk= g/Universal/CapsulePei/CapsulePei.inf index c54bc21a95a8..594e110d1f8a 100644 --- a/MdeModulePkg/Universal/CapsulePei/CapsulePei.inf +++ b/MdeModulePkg/Universal/CapsulePei/CapsulePei.inf @@ -48,6 +48,7 @@ [Packages] =20 [LibraryClasses] BaseLib + CacheMaintenanceLib HobLib BaseMemoryLib PeiServicesLib diff --git a/MdeModulePkg/Universal/CapsulePei/Common/CapsuleCoalesce.c b/M= deModulePkg/Universal/CapsulePei/Common/CapsuleCoalesce.c index 3e7054cd38a9..52b80e30b479 100644 --- a/MdeModulePkg/Universal/CapsulePei/Common/CapsuleCoalesce.c +++ b/MdeModulePkg/Universal/CapsulePei/Common/CapsuleCoalesce.c @@ -27,6 +27,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER= EXPRESS OR IMPLIED. #include =20 #include +#include #include #include #include @@ -253,6 +254,7 @@ ValidateCapsuleByMemoryResource ( ) { UINTN Index; + BOOLEAN Valid; =20 // // Sanity Check @@ -270,25 +272,39 @@ ValidateCapsuleByMemoryResource ( return FALSE; } =20 + Valid =3D FALSE; if (MemoryResource =3D=3D NULL) { // // No memory resource descriptor reported in HOB list before capsule C= oalesce. // - return TRUE; + Valid =3D TRUE; + } else { + for (Index =3D 0; MemoryResource[Index].ResourceLength !=3D 0; Index++= ) { + if ((Address >=3D MemoryResource[Index].PhysicalStart) && + ((Address + Size) <=3D (MemoryResource[Index].PhysicalStart + Me= moryResource[Index].ResourceLength))) { + DEBUG ((EFI_D_INFO, "Address(0x%lx) Size(0x%lx) in MemoryResource[= 0x%x] - Start(0x%lx) Length(0x%lx)\n", + Address, Size, + Index, MemoryResource[Index].PhysicalStart, Me= moryResource[Index].ResourceLength)); + Valid =3D TRUE; + break; + } + } + if (!Valid) { + DEBUG ((EFI_D_ERROR, "ERROR: Address(0x%lx) Size(0x%lx) not in any M= emoryResource\n", Address, Size)); + } } =20 - for (Index =3D 0; MemoryResource[Index].ResourceLength !=3D 0; Index++) { - if ((Address >=3D MemoryResource[Index].PhysicalStart) && - ((Address + Size) <=3D (MemoryResource[Index].PhysicalStart + Memo= ryResource[Index].ResourceLength))) { - DEBUG ((EFI_D_INFO, "Address(0x%lx) Size(0x%lx) in MemoryResource[0x= %x] - Start(0x%lx) Length(0x%lx)\n", - Address, Size, - Index, MemoryResource[Index].PhysicalStart, Memo= ryResource[Index].ResourceLength)); - return TRUE; - } + if (Valid) { + // + // At this point, we may still be running with the MMU and caches disa= bled, + // and on architectures such as ARM or AARCH64, capsule [meta]data loa= ded + // into memory with the caches on is only guaranteed to be visible to = the + // CPU running with the caches off after performing an explicit writeb= ack. + // + WriteBackDataCacheRange ((VOID *)(UINTN)Address, (UINTN)Size); } =20 - DEBUG ((EFI_D_ERROR, "ERROR: Address(0x%lx) Size(0x%lx) not in any Memor= yResource\n", Address, Size)); - return FALSE; + return Valid; } =20 /** --=20 2.17.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Thu Mar 28 17:55:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1528441106517973.1549004631962; Thu, 7 Jun 2018 23:58:26 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id EE0BF21106FD6; Thu, 7 Jun 2018 23:58:23 -0700 (PDT) Received: from mail-wm0-x242.google.com (mail-wm0-x242.google.com [IPv6:2a00:1450:400c:c09::242]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 390DE21106FCB for ; Thu, 7 Jun 2018 23:58:22 -0700 (PDT) Received: by mail-wm0-x242.google.com with SMTP id v16-v6so1382752wmh.5 for ; Thu, 07 Jun 2018 23:58:22 -0700 (PDT) Received: from dogfood.home (LFbn-NIC-1-75-91.w2-15.abo.wanadoo.fr. [2.15.165.91]) by smtp.gmail.com with ESMTPSA id x130-v6sm892491wme.24.2018.06.07.23.58.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Jun 2018 23:58:19 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:400c:c09::242; helo=mail-wm0-x242.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org 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; bh=Q9G4PpnS3BIJu/0hNkN72JkwkzYhKcEVFra6o/+dWAc=; b=XiFno4oG6HnXXER7o665NDwpcrhS/D9UaEtm8XhIOvSBVNO77eKRpyFUsP5qceegYY 0zbMz7vWzHTNp74IfL2cc2lhiQDnslxHsA2+AG8o/Q7pqBJPLcnmApqdVO7tG7FVd+wc +pMWc9bJ0MIkz31fiKGtx9aJux13pN9rwsRV4= 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; bh=Q9G4PpnS3BIJu/0hNkN72JkwkzYhKcEVFra6o/+dWAc=; b=EoNeCeVqo/K46pN4bRXuPJ8OhhXURJxhbXKxU22Zo1mJBf3a8EF6uqfhPfGtlpxOyO EH1jGroEzvbxOT90CJZ1cf4iYcoRVBDH6XewHG26ljg9ouErvYJkaxxj4lqFAq9xXOHW ry4pvUG1AnJZgMnEC/FtRByuMgukS7hN+8I8OJdKzCqV/yjeC+73bLBd7MgCxmHQPq03 TlWmubTp6nzhYM+FqW85Nfr/eFKUAPo/MH1D998sllTUNaRyXNp3xJ3Tgft+j0pN2N/N VhVhWTGosCuBYneyl5cV1yZMdPYJ9OTqyPIX6agSf0kdNzfXhUAVtZm4WxNUOOirK9vL 97Mg== X-Gm-Message-State: APt69E1HsofaXumosZ0SP6EUwlNuTr/YsqQCjrpGUP4yNS/pcdI0v60d d82cciqsxUC9Cel36LH3wZE81mZ9s2w= X-Google-Smtp-Source: ADUXVKKVK2lSdeZCsVjNKC9gRzTlkpf/7RnIim51Kzou2en0E2BJO6eTPu1XV2R7r64MlNk45EKECw== X-Received: by 2002:a1c:d482:: with SMTP id l124-v6mr578066wmg.22.1528441100527; Thu, 07 Jun 2018 23:58:20 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Fri, 8 Jun 2018 08:58:08 +0200 Message-Id: <20180608065811.2065-3-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180608065811.2065-1-ard.biesheuvel@linaro.org> References: <20180608065811.2065-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH v2 2/5] MdeModulePkg/DxeCapsuleLibFmp: permit ProcessCapsules () to be called once X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: michael.d.kinney@intel.com, jiewen.yao@intel.com, star.zeng@intel.com, leif.lindholm@linaro.org, Ard Biesheuvel MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Permit ProcessCapsules () to be called only a single time, after EndOfDxe. This allows platforms that are able to update system firmware after EndOfDxe (e.g., because the flash ROM is not locked down) to do so at a time when a non-trusted console is up and running, and progress can be reported to the user. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleProcessLib.c | 18 ++++++++= ++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleProcessLib.c b= /MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleProcessLib.c index 26ca4e295f20..ad83660f1737 100644 --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleProcessLib.c +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleProcessLib.c @@ -100,6 +100,7 @@ IsValidCapsuleHeader ( =20 extern BOOLEAN mDxeCapsuleLibEndOfDxe; BOOLEAN mNeedReset; +BOOLEAN mFirstRound =3D TRUE; =20 VOID **mCapsulePtr; EFI_STATUS *mCapsuleStatusArray; @@ -364,8 +365,11 @@ PopulateCapsuleInConfigurationTable ( =20 Each individual capsule result is recorded in capsule record variable. =20 - @param[in] FirstRound TRUE: First round. Need skip the FMP cap= sules with non zero EmbeddedDriverCount. - FALSE: Process rest FMP capsules. + @param[in] FirstRound Whether this is the first invocation + @param[in] LastRound Whether this is the last invocation + FALSE: First of 2 rounds. Need skip the = FMP + capsules with non zero EmbeddedDr= iverCount. + TRUE: Process rest FMP capsules. =20 @retval EFI_SUCCESS There is no error when processing capsul= es. @retval EFI_OUT_OF_RESOURCES No enough resource to process capsules. @@ -373,7 +377,8 @@ PopulateCapsuleInConfigurationTable ( **/ EFI_STATUS ProcessTheseCapsules ( - IN BOOLEAN FirstRound + IN BOOLEAN FirstRound, + IN BOOLEAN LastRound ) { EFI_STATUS Status; @@ -453,7 +458,7 @@ ProcessTheseCapsules ( continue; } =20 - if ((!FirstRound) || (EmbeddedDriverCount =3D=3D 0)) { + if (LastRound || (EmbeddedDriverCount =3D=3D 0)) { DEBUG((DEBUG_INFO, "ProcessCapsuleImage - 0x%x\n", CapsuleHeader)); Status =3D ProcessCapsuleImage (CapsuleHeader); mCapsuleStatusArray [Index] =3D Status; @@ -546,7 +551,7 @@ ProcessCapsules ( EFI_STATUS Status; =20 if (!mDxeCapsuleLibEndOfDxe) { - Status =3D ProcessTheseCapsules(TRUE); + Status =3D ProcessTheseCapsules(TRUE, FALSE); =20 // // Reboot System if and only if all capsule processed. @@ -555,8 +560,9 @@ ProcessCapsules ( if (mNeedReset && AreAllImagesProcessed()) { DoResetSystem(); } + mFirstRound =3D FALSE; } else { - Status =3D ProcessTheseCapsules(FALSE); + Status =3D ProcessTheseCapsules(mFirstRound, TRUE); // // Reboot System if required after all capsule processed // --=20 2.17.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Thu Mar 28 17:55:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1528441109539501.36173744038297; Thu, 7 Jun 2018 23:58:29 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 2E7D421106FDC; Thu, 7 Jun 2018 23:58:26 -0700 (PDT) Received: from mail-wm0-x22e.google.com (mail-wm0-x22e.google.com [IPv6:2a00:1450:400c:c09::22e]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 7554E21106FCB for ; Thu, 7 Jun 2018 23:58:23 -0700 (PDT) Received: by mail-wm0-x22e.google.com with SMTP id p11-v6so1563118wmc.4 for ; Thu, 07 Jun 2018 23:58:23 -0700 (PDT) Received: from dogfood.home (LFbn-NIC-1-75-91.w2-15.abo.wanadoo.fr. [2.15.165.91]) by smtp.gmail.com with ESMTPSA id x130-v6sm892491wme.24.2018.06.07.23.58.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Jun 2018 23:58:21 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:400c:c09::22e; helo=mail-wm0-x22e.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org 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; bh=FspWq5+qPhF63i9or4drgtMsbF6v8QDNI43SSAS41n0=; b=ix0FBXn7k83oG4817oeXdvYTI6OBIErKILr15fppAmAfytGyFvqV0RWDcgtg0nLrQY R3Gmh1uxGtH07RkuglL1REAfvkngpfEf4O8M8QkoeiMZouueK8NXHGeEKvP9+iBBhRM8 w7F22RiO1Wv7ZOuuVg1ggFcMKAv9zhP6YInyM= 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; bh=FspWq5+qPhF63i9or4drgtMsbF6v8QDNI43SSAS41n0=; b=I1yHcHu/mzHxyAm6pE3BkwUD3TjvjHlqT/dPRpJnzmTNKR2MvOosweDOX8za7euMJ6 9JPOlJDsry5kxVX5knG8kJWbVWl0F0lpL2x7kOSD3qm8tutQ2wcgxF6q1brq548KycYY TJ8v13lXSpDfN4UgBoxeykwhbyG0Zq9Y3BY1aRFmtZHOp7+FPpXScTZnkoD3euqJ71cW uiGHaJK1Oq+rbhNglT7dSCpp97H+usObupqR8s8ADhkdU1q3/xUs3Sz1IPInBP5wEG7s KaHIpbUTDYNopLZNehJvBfQnxj13XWNZCdp/LRqBBGkW5Fjm8S4nRlvKEnZFOWrdPX79 nL2A== X-Gm-Message-State: APt69E36GF9DDGciA0kI0uIvfJ+D6VZ9Dr8Yp5/KJmvOVrl4crIXFzoo 5fyNdqlTLSyqJcCMG7mJjNDui8FI6Ro= X-Google-Smtp-Source: ADUXVKKQe4MgzrU+TsvkL1567ykzNHJ5jKPbkM3SXTPfeyBXjR5T6Qdj/jISvB2cWWCpGyedpQ9cMQ== X-Received: by 2002:a1c:d884:: with SMTP id p126-v6mr578818wmg.110.1528441101751; Thu, 07 Jun 2018 23:58:21 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Fri, 8 Jun 2018 08:58:09 +0200 Message-Id: <20180608065811.2065-4-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180608065811.2065-1-ard.biesheuvel@linaro.org> References: <20180608065811.2065-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH v2 3/5] MdeModulePkg/DxeCapsuleLibFmp: pass progress callback only if it works X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: michael.d.kinney@intel.com, jiewen.yao@intel.com, star.zeng@intel.com, leif.lindholm@linaro.org, Ard Biesheuvel MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" If the first call to UpdateImageProgress() fails, there is no point in passing a pointer to it to Fmp->SetImage(), since it is highly unlikely to succeed on any subsequent calls. This permits the FMP implementation to fall back to an alternate means of providing feedback to the user, e.g., via the console. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c b/MdeMod= ulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c index f0226eafa576..ab41df0eb0a4 100644 --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c @@ -841,6 +841,7 @@ SetFmpImageData ( UINT8 *Image; VOID *VendorCode; CHAR16 *AbortReason; + EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS ProgressCallback; =20 Status =3D gBS->HandleProtocol( Handle, @@ -892,7 +893,11 @@ SetFmpImageData ( // // Before calling SetImage(), reset the progress bar to 0% // - UpdateImageProgress (0); + ProgressCallback =3D UpdateImageProgress; + Status =3D UpdateImageProgress (0); + if (EFI_ERROR (Status)) { + ProgressCallback =3D NULL; + } =20 Status =3D Fmp->SetImage( Fmp, @@ -900,13 +905,15 @@ SetFmpImageData ( Image, // Image ImageHeader->UpdateImageSize, // ImageSize VendorCode, // VendorCode - UpdateImageProgress, // Progress + ProgressCallback, // Progress &AbortReason // AbortReason ); // // Set the progress bar to 100% after returning from SetImage() // - UpdateImageProgress (100); + if (ProgressCallback !=3D NULL) { + UpdateImageProgress (100); + } =20 DEBUG((DEBUG_INFO, "Fmp->SetImage - %r\n", Status)); if (AbortReason !=3D NULL) { --=20 2.17.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Thu Mar 28 17:55:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 152844111254464.29249705910627; Thu, 7 Jun 2018 23:58:32 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 671E921107162; Thu, 7 Jun 2018 23:58:26 -0700 (PDT) Received: from mail-wm0-x241.google.com (mail-wm0-x241.google.com [IPv6:2a00:1450:400c:c09::241]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id C13F621106FD4 for ; Thu, 7 Jun 2018 23:58:24 -0700 (PDT) Received: by mail-wm0-x241.google.com with SMTP id v131-v6so1586699wma.1 for ; Thu, 07 Jun 2018 23:58:24 -0700 (PDT) Received: from dogfood.home (LFbn-NIC-1-75-91.w2-15.abo.wanadoo.fr. [2.15.165.91]) by smtp.gmail.com with ESMTPSA id x130-v6sm892491wme.24.2018.06.07.23.58.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Jun 2018 23:58:22 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:400c:c09::241; helo=mail-wm0-x241.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org 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; bh=rWw+nw28PGMW03a0FZ8OjXh8iNt/MPfEtgEI9RcEVVQ=; b=NYWdR172cmzkoilIGfnweAGQHCMZfzfRoCCwR233e74ht75oNx9Dk53fQZAR27k+22 JUgjsXiXimlxsvfFq3+SD6FHYz/TgogC1aMyhZs1w86jya8NNo/wYMIhN2pyNPkKHBvm ewK+rpbA97B8HJIZyAo0IWYrKBxmiGOyxi7m4= 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; bh=rWw+nw28PGMW03a0FZ8OjXh8iNt/MPfEtgEI9RcEVVQ=; b=qi9CgMIY0vnMqpF87M7AZD/n5HRe5Qpei3yjV8N3zeJ3Y98oIYhiqljgSsFP1E9IHO 6t7R2o01GSwJrTgKXCL+rlS4+iCkxO/Q01SUupGG5jwGbKNnNSumRHhVXLtfvL2Imylw GneMwAwro3wj4BADFe/azO343+ltiAehjiGoleITWNOcr7PU0UAd/UhMrX6ejPQx1baV 1Ef3HPzFCKI+0T4kOZ495zNwvv4SZzKRnbjMOB3fZKIlsbbGBHGSpX83cg1/MVbVf8ID UlK70agKXQRPBrEz+HrCvjNgWxS0p3V3IeEzf5/DJz4A+hPPEp1Xs3TEXzsj/Ekzaz4D ohDA== X-Gm-Message-State: APt69E3rfDx5B12jGFoXiLVPjvapkEo+5b3F/0Xo1TBopTkkIEjp/AFj Ac504ZiDV6guGvaaSFLcIZk2wpIKFWw= X-Google-Smtp-Source: ADUXVKIIguUsCScZhzxkLzmmCkYtEnBJPTqLJ+tiWSSxkMqGoOdy3uL5yyqucgHnoI9Vo7pzAgj4rA== X-Received: by 2002:a1c:8a07:: with SMTP id m7-v6mr669150wmd.27.1528441103143; Thu, 07 Jun 2018 23:58:23 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Fri, 8 Jun 2018 08:58:10 +0200 Message-Id: <20180608065811.2065-5-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180608065811.2065-1-ard.biesheuvel@linaro.org> References: <20180608065811.2065-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH v2 4/5] ArmPkg/PlatformBootManagerLib: call ProcessCapsules() only once X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: michael.d.kinney@intel.com, jiewen.yao@intel.com, star.zeng@intel.com, leif.lindholm@linaro.org, Ard Biesheuvel MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" ARM platforms have no restriction on when a system firmware update capsule can be applied, and so it is not necessary to call ProcessCapsules() twice. So let's drop the first invocation that occurs before EndOfDxe, so that capsule updates will be applied when the console is up and able to provide progress feedback. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel Reviewed-by: Leif Lindholm --- ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c b/ArmPkg/Li= brary/PlatformBootManagerLib/PlatformBm.c index 3456a71fbb9c..8e1ecdc01564 100644 --- a/ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c +++ b/ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c @@ -553,21 +553,6 @@ PlatformBootManagerBeforeConsole ( VOID ) { - EFI_STATUS Status; - ESRT_MANAGEMENT_PROTOCOL *EsrtManagement; - - if (GetBootModeHob() =3D=3D BOOT_ON_FLASH_UPDATE) { - DEBUG ((DEBUG_INFO, "ProcessCapsules Before EndOfDxe ......\n")); - Status =3D ProcessCapsules (); - DEBUG ((DEBUG_INFO, "ProcessCapsules returned %r\n", Status)); - } else { - Status =3D gBS->LocateProtocol (&gEsrtManagementProtocolGuid, NULL, - (VOID **)&EsrtManagement); - if (!EFI_ERROR (Status)) { - EsrtManagement->SyncEsrtFmp (); - } - } - // // Signal EndOfDxe PI Event // --=20 2.17.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Thu Mar 28 17:55:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1528441116062185.97560727514485; Thu, 7 Jun 2018 23:58:36 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 9329B21107172; Thu, 7 Jun 2018 23:58:27 -0700 (PDT) Received: from mail-wr0-x22d.google.com (mail-wr0-x22d.google.com [IPv6:2a00:1450:400c:c0c::22d]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 561A521106FCB for ; Thu, 7 Jun 2018 23:58:26 -0700 (PDT) Received: by mail-wr0-x22d.google.com with SMTP id k16-v6so12203279wro.0 for ; Thu, 07 Jun 2018 23:58:26 -0700 (PDT) Received: from dogfood.home (LFbn-NIC-1-75-91.w2-15.abo.wanadoo.fr. [2.15.165.91]) by smtp.gmail.com with ESMTPSA id x130-v6sm892491wme.24.2018.06.07.23.58.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Jun 2018 23:58:23 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:400c:c0c::22d; helo=mail-wr0-x22d.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org 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; bh=IDGZTFa44cMq31H+VcVxKIAVLEOpjBlqf99JEjpN1rg=; b=Bk/JhMzZt6iKWXo17lo/y6Yzk3RUlCB2thxBg/pIKRUozLll6Q+0e7Ki8JUKN0EqN9 RtRXNPevpxn4rvfPATJ6tmMUt+ar/vfPf2rZ3o5CIXCegs4ka29ULyurlDsMTbc48znO zWmHGj2wj29hHt5dIpjTB7wXm0KO3GMxDVij8= 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; bh=IDGZTFa44cMq31H+VcVxKIAVLEOpjBlqf99JEjpN1rg=; b=Cqv9zrCt0bHEzScPoSkF09LXYVwr3GRStgWuvNYzwPBl2JMGsUDTQk6dn3v5BoVLxA Pqtj834b19T/T1TpOZKyHr64LQI9m3KhWO1ZZykQnP+nGUa9ReheOu2hQa8QmOLoghle d/UOGn3yKI+SPuinfE5zMxUbGN0w7jJOGQ3bdd1yAgKGxU+OqU5uFDxttyKnss82hWAO L6XqAMTAnduxy4EcI1eFUa301jNTPrH0dd1j2T0yXXMMU3uOhImWIt1QBTbyD0zhFjUv MHosgRNlngfiHnXPUgadH3mXhiMr9ZucIMWau+0m2Ze8q3+OyUFQQlzknZVrA57l7GrV 0S8Q== X-Gm-Message-State: APt69E0XzTaFqqnZG40aktVFl2lGmgRhFdjt0bgkIxhNOIhOyJZ4Acgu mvDF82O8LDXfj3GW0ww/ko45ODATxBw= X-Google-Smtp-Source: ADUXVKJmxRhwsMEGoGK9wxecbTXNeWfT+5uceZIvTmzNQLWxQJlZduzxWuVqkiUbuJlRcYOqtD+34Q== X-Received: by 2002:adf:d204:: with SMTP id g4-v6mr3955569wri.229.1528441104542; Thu, 07 Jun 2018 23:58:24 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Fri, 8 Jun 2018 08:58:11 +0200 Message-Id: <20180608065811.2065-6-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180608065811.2065-1-ard.biesheuvel@linaro.org> References: <20180608065811.2065-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH v2 5/5] ArmPkg/ArmSmcPsciResetSystemLib: implement fallback for warm reboot X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: michael.d.kinney@intel.com, jiewen.yao@intel.com, star.zeng@intel.com, leif.lindholm@linaro.org, Ard Biesheuvel MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Implement ResetSystemLib's EnterS3WithImmediateWake() routine using a jump back to the PEI entry point with interrupts and MMU+caches disabled. This is only possible at boot time, when we are sure that the current CPU is the only one up and running. Also, it depends on the platform whether the PEI code is preserved in memory (it may be copied to DRAM rather than execute in place), so also add a feature PCD to selectively enable this feature. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel Reviewed-by: Leif Lindholm --- ArmPkg/ArmPkg.dec | 4 = ++++ ArmPkg/Library/ArmSmcPsciResetSystemLib/ArmSmcPsciResetSystemLib.c | 21 = ++++++++++++++++++-- ArmPkg/Library/ArmSmcPsciResetSystemLib/ArmSmcPsciResetSystemLib.inf | 9 = +++++++++ 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/ArmPkg/ArmPkg.dec b/ArmPkg/ArmPkg.dec index debe066b6f7b..3aa229fe2ec9 100644 --- a/ArmPkg/ArmPkg.dec +++ b/ArmPkg/ArmPkg.dec @@ -85,6 +85,10 @@ [PcdsFeatureFlag.common] # Define if the GICv3 controller should use the GICv2 legacy gArmTokenSpaceGuid.PcdArmGicV3WithV2Legacy|FALSE|BOOLEAN|0x00000042 =20 + # Whether to implement warm reboot for capsule update using a jump back = to the + # PEI entry point with caches and interrupts disabled. + gArmTokenSpaceGuid.PcdArmReenterPeiForCapsuleWarmReboot|FALSE|BOOLEAN|0x= 0000001F + [PcdsFeatureFlag.ARM] # Whether to map normal memory as non-shareable. FALSE is the safe choic= e, but # TRUE may be appropriate to fix performance problems if you don't care = about diff --git a/ArmPkg/Library/ArmSmcPsciResetSystemLib/ArmSmcPsciResetSystemL= ib.c b/ArmPkg/Library/ArmSmcPsciResetSystemLib/ArmSmcPsciResetSystemLib.c index d6d26bce5009..10ceafd14d5d 100644 --- a/ArmPkg/Library/ArmSmcPsciResetSystemLib/ArmSmcPsciResetSystemLib.c +++ b/ArmPkg/Library/ArmSmcPsciResetSystemLib/ArmSmcPsciResetSystemLib.c @@ -15,10 +15,13 @@ =20 #include =20 +#include +#include #include #include #include -#include +#include +#include =20 #include =20 @@ -89,7 +92,21 @@ EnterS3WithImmediateWake ( VOID ) { - // Not implemented + VOID (*Reset)(VOID); + + if (FeaturePcdGet (PcdArmReenterPeiForCapsuleWarmReboot) && + !EfiAtRuntime ()) { + // + // At boot time, we are the only core running, so we can implement the + // immediate wake (which is used by capsule update) by disabling the M= MU + // and interrupts, and jumping to the PEI entry point. + // + Reset =3D (VOID (*)(VOID))(UINTN)FixedPcdGet64 (PcdFvBaseAddress); + + gBS->RaiseTPL (TPL_HIGH_LEVEL); + ArmDisableMmu (); + Reset (); + } } =20 /** diff --git a/ArmPkg/Library/ArmSmcPsciResetSystemLib/ArmSmcPsciResetSystemL= ib.inf b/ArmPkg/Library/ArmSmcPsciResetSystemLib/ArmSmcPsciResetSystemLib.i= nf index 5a1ee976e5bc..19021cd1e8b6 100644 --- a/ArmPkg/Library/ArmSmcPsciResetSystemLib/ArmSmcPsciResetSystemLib.inf +++ b/ArmPkg/Library/ArmSmcPsciResetSystemLib/ArmSmcPsciResetSystemLib.inf @@ -30,6 +30,15 @@ [Packages] MdePkg/MdePkg.dec =20 [LibraryClasses] + ArmMmuLib ArmSmcLib BaseLib DebugLib + UefiBootServicesTableLib + UefiRuntimeLib + +[FeaturePcd] + gArmTokenSpaceGuid.PcdArmReenterPeiForCapsuleWarmReboot + +[FixedPcd] + gArmTokenSpaceGuid.PcdFvBaseAddress --=20 2.17.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel