From patchwork Fri Jun 8 06:58:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 137922 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp511814lji; Thu, 7 Jun 2018 23:58:23 -0700 (PDT) X-Google-Smtp-Source: ADUXVKL9GeOo4I080WlalOA7JqxaHVjXZLRR5Pd3EkU9MIbOeTXpvuVGCLv4w7a6rW0vxmaSDT74 X-Received: by 2002:a65:5686:: with SMTP id v6-v6mr4243618pgs.141.1528441103294; Thu, 07 Jun 2018 23:58:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528441103; cv=none; d=google.com; s=arc-20160816; b=QZjp54V+iuY2AU3Bjymo/mIGdUJ3UUdNeAmEqvxmvubC4HcqVtzCpgFfxVbW2pBZ1S 55KrNRTO9eGNvMaCVoimQcXEdONz1479xLYgmkVxUQPrrQLF2bfLumAGWRsTLn29GEtY UFmMklLmZ1HuRvHpHk9iEbgbrr9w5jNUb5m9y4mgCA3Zkif2EOV0JLaBGKViSavqoHnq YSCQKMr0kfYdwJXIhwc4qCPpKnvdBVLg76PUK7RmJxub7hxBdMeW5RmbeIhaBHtQCn/f j4yUg6zLqt4RLny+IQgqVdi5+e7za/q6RwsFBxX0iDtnMthye8vPN48tdUvkg6dknFJp 2RMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to:arc-authentication-results; bh=c1MfLzAwPu9ZXt8vXsUUhsWuSJz7S37BmfYGkP44tGc=; b=YvdS8s9WNi208NfSXUQhPaVQVPP2HmZyyRIW0lhSLQJy++fbeANodhGORXGbSi3sN4 PxpXJBAyZWher5Z41Mhlr25XPOambB/x474Z74Xk1c2qu8Bt89jlZBXXT6+HKGDxQ9Hc OAsixhuJ9/76RMTFiyCp7Fn0bIj+0hCJ0KbXlYBZOJqBAExpR64JRwBVYnVpuvHAdjIa Y2iUW6cKzBWIBcESmcygPDFC+LLorEEEjVUrioqG3dO8wdgxCc7Vetmj5xq28F8DCbsO y4oEmlCO3aWVYtArRWAsW4E026ClfkXN8upQDvPiCHMdE8jhAcKHtUt+8WVaH5vSSEXQ 40cw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=ESVMBgjG; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [198.145.21.10]) by mx.google.com with ESMTPS id o128-v6si8876752pfg.5.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) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) client-ip=198.145.21.10; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=ESVMBgjG; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.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 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) 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-Received: by 2002:a1c:e846:: with SMTP id f67-v6mr605786wmh.63.1528441099247; Thu, 07 Jun 2018 23:58:19 -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) 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 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" 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(-) -- 2.17.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/MdeModulePkg/Universal/CapsulePei/CapsulePei.inf b/MdeModulePkg/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] [LibraryClasses] BaseLib + CacheMaintenanceLib HobLib BaseMemoryLib PeiServicesLib diff --git a/MdeModulePkg/Universal/CapsulePei/Common/CapsuleCoalesce.c b/MdeModulePkg/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 #include +#include #include #include #include @@ -253,6 +254,7 @@ ValidateCapsuleByMemoryResource ( ) { UINTN Index; + BOOLEAN Valid; // // Sanity Check @@ -270,25 +272,39 @@ ValidateCapsuleByMemoryResource ( return FALSE; } + Valid = FALSE; if (MemoryResource == NULL) { // // No memory resource descriptor reported in HOB list before capsule Coalesce. // - return TRUE; + Valid = TRUE; + } else { + for (Index = 0; MemoryResource[Index].ResourceLength != 0; Index++) { + if ((Address >= MemoryResource[Index].PhysicalStart) && + ((Address + Size) <= (MemoryResource[Index].PhysicalStart + MemoryResource[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, MemoryResource[Index].ResourceLength)); + Valid = TRUE; + break; + } + } + if (!Valid) { + DEBUG ((EFI_D_ERROR, "ERROR: Address(0x%lx) Size(0x%lx) not in any MemoryResource\n", Address, Size)); + } } - for (Index = 0; MemoryResource[Index].ResourceLength != 0; Index++) { - if ((Address >= MemoryResource[Index].PhysicalStart) && - ((Address + Size) <= (MemoryResource[Index].PhysicalStart + MemoryResource[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, MemoryResource[Index].ResourceLength)); - return TRUE; - } + if (Valid) { + // + // At this point, we may still be running with the MMU and caches disabled, + // and on architectures such as ARM or AARCH64, capsule [meta]data loaded + // into memory with the caches on is only guaranteed to be visible to the + // CPU running with the caches off after performing an explicit writeback. + // + WriteBackDataCacheRange ((VOID *)(UINTN)Address, (UINTN)Size); } - DEBUG ((EFI_D_ERROR, "ERROR: Address(0x%lx) Size(0x%lx) not in any MemoryResource\n", Address, Size)); - return FALSE; + return Valid; } /** From patchwork Fri Jun 8 06:58:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 137923 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp511840lji; Thu, 7 Jun 2018 23:58:26 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJm/5vB6gDfqABT4hhN7hahyFWjD4BjBweF7nm3Ik9GzCvWa9a6Wf1zU/KlOy8m3PqLB/g6 X-Received: by 2002:a62:cf44:: with SMTP id b65-v6mr4757282pfg.80.1528441106051; Thu, 07 Jun 2018 23:58:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528441106; cv=none; d=google.com; s=arc-20160816; b=jwwrS4I32BSlYlesFgWt+cmpQeOaMEjQvR8cP6gSY2/TsfTKTp4juu4cDtasq5ezHA riGb8VEC14QZDU1rY9MIFSlN6P4Yhw6IJq8b8a6k5/Hm4/mSDC7xRd0ZI6620qfibuD2 +f9Q8Xam6rmYdwgeDi52UTklenHkkRGpN8EglBjR6QaV4Kw4yhwC535P3dURcyn8jAmY hby48GSw+Jnh5Q0RNH3MQ4jHKdh9+BekiBAg6yFoSwSeQ2/jo1KC5kk/1v/aIt1tvTFr PnAnvnPgurSdcQHeDcRyrEVMPoQqXRlzNUIPGm/2N0lKJkh2+akDJFIumBwqGgD1HZbo AISQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to:arc-authentication-results; bh=DRLsit8+k2cX0C2Uu1D0rxYE/mUzrzsyd1SV1SrYPD8=; b=mpUN0wd1jCsPAc0pyJ7sjkV4nraHErFfW1+uwl/Wh+11FlPdiOyn8vdOBpVQhnyLT+ 04hGU8aN2f9NeQrEWm0i7AtjxQ9Xw1EDbiVCwt/VVOfabbj4PPcuKaL06cyq3S/KzKf2 TLzjPNqthxyJR6EBOaFN+TTMlW9dmodc/Vwgc/UBe6DDXGG+r9WDULqopJFTbuwe3R6z 4zMEabQ8f597hxtEb31LvzoZBTsR2sXOsgOtpHQnD8e2zsyqqpuJtThQRvaPXZLb8u97 IK6PoPgWyavJhSfNhkfwONTVn4UvglEXLPQL6GfCOODkMuGJM84ero9ciZKF56WSiyUB OmAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=XiFno4oG; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [198.145.21.10]) by mx.google.com with ESMTPS id s193-v6si9660570pgc.372.2018.06.07.23.58.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Jun 2018 23:58:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) client-ip=198.145.21.10; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=XiFno4oG; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.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 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) 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-Received: by 2002:a1c:d482:: with SMTP id l124-v6mr578066wmg.22.1528441100527; 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.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); 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: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 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" 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(-) -- 2.17.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel 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 ( extern BOOLEAN mDxeCapsuleLibEndOfDxe; BOOLEAN mNeedReset; +BOOLEAN mFirstRound = TRUE; VOID **mCapsulePtr; EFI_STATUS *mCapsuleStatusArray; @@ -364,8 +365,11 @@ PopulateCapsuleInConfigurationTable ( Each individual capsule result is recorded in capsule record variable. - @param[in] FirstRound TRUE: First round. Need skip the FMP capsules 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 EmbeddedDriverCount. + TRUE: Process rest FMP capsules. @retval EFI_SUCCESS There is no error when processing capsules. @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; } - if ((!FirstRound) || (EmbeddedDriverCount == 0)) { + if (LastRound || (EmbeddedDriverCount == 0)) { DEBUG((DEBUG_INFO, "ProcessCapsuleImage - 0x%x\n", CapsuleHeader)); Status = ProcessCapsuleImage (CapsuleHeader); mCapsuleStatusArray [Index] = Status; @@ -546,7 +551,7 @@ ProcessCapsules ( EFI_STATUS Status; if (!mDxeCapsuleLibEndOfDxe) { - Status = ProcessTheseCapsules(TRUE); + Status = ProcessTheseCapsules(TRUE, FALSE); // // Reboot System if and only if all capsule processed. @@ -555,8 +560,9 @@ ProcessCapsules ( if (mNeedReset && AreAllImagesProcessed()) { DoResetSystem(); } + mFirstRound = FALSE; } else { - Status = ProcessTheseCapsules(FALSE); + Status = ProcessTheseCapsules(mFirstRound, TRUE); // // Reboot System if required after all capsule processed // From patchwork Fri Jun 8 06:58:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 137924 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp511884lji; Thu, 7 Jun 2018 23:58:29 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJGpBsCIjYh24J611QbT0ifs2/eI/0vsLYK236ed6y9tGq4XiTaVXY+oANSq5SRW50ZwsVv X-Received: by 2002:a63:6e44:: with SMTP id j65-v6mr4283431pgc.14.1528441109078; Thu, 07 Jun 2018 23:58:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528441109; cv=none; d=google.com; s=arc-20160816; b=GlP7mnFpXVwcqfjUY/npLzZuRfl2z1fhclCC4fhGkea1i5MTJTlkDiPw4jWYbbKReD kHFJmzMCiDb2J6hm+Van/pBPCaUPESIWY5GHlggkgIzPGTTURcFYcCqidhkGMAv7/iZa Vqf1HQnisxROfGNbFBSW510xmGP1MfC8DUbem4u8X+CTwqhWKYg2+PaTzoclHheVTCe3 NVdpnWJjwvaTd+T6cXUyX6LJSq4KoFZCjpv7WeXWKX9gJCJRMK/cmUMzXFO4Bs+vAWXa 4OhkYR2GELMHCJAeLHzk/LPeIq8fVLJ5jp6o2ShkdtfhoQCtVnw0pu86euEeLSglWXLI kqJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to:arc-authentication-results; bh=JcgbqxOz9B2WRrz0M8ygdzgcrGBoQ/rSO1K1Oo873Jg=; b=MFCctYC6w/mIGhGMcgCU37QB68Vo+Do40b+LdFaqXgBjBDQzwJSqdyUN3zh/p1nUP3 3hFBicvG2yqCK7HW8FLQb68Wbyxn68SDTJL7dRkdY4aKU1coidXWFH3fRQ7LHVvVPy+z gSTHok6hty/iNxx81m64Jr6SiiN3WR+w+TsPZsD0rEzqnBVyPUG8lsuph0eAnOQbUhDR VMrFQewElrqWBxiGR/vkeiBJ2RPmt/+NgKtON+tNBJG1or2rwJRt0dUB3BbbGwrs9Qwn xYw0XR+CaQWEPosOvw8lNGgTW6RA1Qxtko0nTQcf9ahzyzJDgFfUNTGoiijCUpBql3qe LoXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=ix0FBXn7; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id g63-v6si44541425pgc.40.2018.06.07.23.58.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Jun 2018 23:58:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=ix0FBXn7; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.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 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) 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-Received: by 2002:a1c:d884:: with SMTP id p126-v6mr578818wmg.110.1528441101751; Thu, 07 Jun 2018 23:58:21 -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) 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 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" 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(-) -- 2.17.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c b/MdeModulePkg/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; Status = gBS->HandleProtocol( Handle, @@ -892,7 +893,11 @@ SetFmpImageData ( // // Before calling SetImage(), reset the progress bar to 0% // - UpdateImageProgress (0); + ProgressCallback = UpdateImageProgress; + Status = UpdateImageProgress (0); + if (EFI_ERROR (Status)) { + ProgressCallback = NULL; + } Status = 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 != NULL) { + UpdateImageProgress (100); + } DEBUG((DEBUG_INFO, "Fmp->SetImage - %r\n", Status)); if (AbortReason != NULL) { From patchwork Fri Jun 8 06:58:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 137925 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp511942lji; Thu, 7 Jun 2018 23:58:32 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKOTTORYlRNXIrcSiJ/zPLc6u+gaUtVRJkTG02NC/ZqtQLefyceAjFJpzx4dtkwawrCfkKM X-Received: by 2002:a62:3ad8:: with SMTP id v85-v6mr4792864pfj.184.1528441112016; Thu, 07 Jun 2018 23:58:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528441112; cv=none; d=google.com; s=arc-20160816; b=tRo0dgTxbgbs6a/K4t47KwlV1mjKdeuQE19FvHpWMfdLv9JSKFGQIPqvROqFudcto0 xf1ncrQExE+wMFT06EtNeY8HN07aqn9pU9JM8qgL6tZAUSzkITiQ3Vt2qAydjERJkXbB QNtIDCxfyGZyX+/0y9PKQNnstJPH1gfF/ckd0dI0B6LNBbQQJ3BM05QEayxebZyoFH6Y MTLIAKUZJL8/x2cZ5HZNAygwmOoVObxbQpLmSJNDhqb1txhAnUixLQBF9FxInHywnNH8 +yuVGwa7wMi0KmcROG8F49VP+echyeIbfXQ55oWyBXXfJWuVTFgzmpZTbyvRS5WptxOi WZsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to:arc-authentication-results; bh=k9jJk5y9cNErwadDlB5kVO0+5XkuW1kHWLHyZ84rnGk=; b=jwERPnH7MYBpktoOdhfQaKFNKsGFQhwGhX2NuVt3EGKuywB7aYHcC3q1Bkz1qQB3N7 RIAHQyO58IbKJy0JV8R+1YYXslgFvi2jq557XhuXsLJdxwL2CvSzmhWfH5/fMJYd6MHx G6EOwGQAFj6UAnOxIwUwaAVj3ubufgRtdAcIHPAfJE1ZD0EI0FoHTE5w1b4c9vmmiOhG BuUOun35v5uXdqHE1X0lkLZqxfnuryxOJwaAs65P+JFcNYzr7WQtHM4jQHt4+JWo8GP6 rdbs7655DbJONzb4tfEG4/tmcBk3fnqX6QzXfA+n18y/vNKHyKp05RpmAHLkbjeO9TNL rTGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=NYWdR172; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id i189-v6si29664112pgd.111.2018.06.07.23.58.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Jun 2018 23:58:32 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=NYWdR172; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.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 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) 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-Received: by 2002:a1c:8a07:: with SMTP id m7-v6mr669150wmd.27.1528441103143; 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.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Jun 2018 23:58:22 -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 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" 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(-) -- 2.17.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c b/ArmPkg/Library/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() == BOOT_ON_FLASH_UPDATE) { - DEBUG ((DEBUG_INFO, "ProcessCapsules Before EndOfDxe ......\n")); - Status = ProcessCapsules (); - DEBUG ((DEBUG_INFO, "ProcessCapsules returned %r\n", Status)); - } else { - Status = gBS->LocateProtocol (&gEsrtManagementProtocolGuid, NULL, - (VOID **)&EsrtManagement); - if (!EFI_ERROR (Status)) { - EsrtManagement->SyncEsrtFmp (); - } - } - // // Signal EndOfDxe PI Event // From patchwork Fri Jun 8 06:58:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 137926 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp511989lji; Thu, 7 Jun 2018 23:58:35 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJXB5k6XAVp7I2ferIBzCWmmLRJken8Uq24H5/H4WjRvS5vyDDW8aH0nUKSiWLD9jAdKaIx X-Received: by 2002:a62:5c06:: with SMTP id q6-v6mr4775487pfb.118.1528441115548; Thu, 07 Jun 2018 23:58:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528441115; cv=none; d=google.com; s=arc-20160816; b=RMJ7h3eGmVJGmS06+kZasDp0rOCoFECZUegqQgl8+sTZR/LLhP02YqvCIh6utrFLTa toar2aai7vNNPTCYB4J7g7+T6hTv4YiFSNcVZYpWLztRL28MIyDpYxHcJwKQqkCG0OR6 oYSBLmZi84keAR29KmUirEivuaYxl7PjIuzLZIai59dZCmY61ZKsSzIlr3qs7A5DBnUS zMrkSiU+srQasINDj4I3J3Bw5R3eTzQyOfkgUp3935O1NTFOUfQxkDGwYM0tg3JBnRTH +Mt/rlbRTyjUlqDWFa72kclX62TZrmLaeqmVH6Oo5naGcK31/UMm7AfXTlzTJjaUJotw 35EQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to:arc-authentication-results; bh=duknZj9gpAMi8jmkaBqURsGCRFwJXlnRjdk5jx3hetE=; b=B2BdonCyHyXWEM6cH+5+/KfIDYD5HG9dIaWFpJQmXB/gQx3RzS23uG9pgFvSQc65Kt GLNj4ECMx5G5r7OdvPgwmxM/2Qu/V1sV/XdyHn+h2fUc8uiP2/nle5cHBt62JzHfRwMh OtLaBC8DvHTjD4dE3TC497HCJBAAQC2ENumbMasvwpk7/Ypli8F/nHn3jjgovfeyk6zV /KMN5uERv6PM2t/sf5j8dzFnQkSyJSIf22oL8SKUZm+Acxj3Zolp+yOhU9U8XpEsASdL 0j7IguGlxvHYrWEdujtlYgzhV8EmBAuoDyxW95hGaFvMuBcO5PncH+QxYH09/dlszJ5v 2gjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Bk/JhMzZ; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [198.145.21.10]) by mx.google.com with ESMTPS id d10-v6si16277016pgo.630.2018.06.07.23.58.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Jun 2018 23:58:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) client-ip=198.145.21.10; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Bk/JhMzZ; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.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 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) 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-Received: by 2002:adf:d204:: with SMTP id g4-v6mr3955569wri.229.1528441104542; 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.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); 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: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 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" 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(-) -- 2.17.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel 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 + # 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|0x0000001F + [PcdsFeatureFlag.ARM] # Whether to map normal memory as non-shareable. FALSE is the safe choice, but # TRUE may be appropriate to fix performance problems if you don't care about diff --git a/ArmPkg/Library/ArmSmcPsciResetSystemLib/ArmSmcPsciResetSystemLib.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 @@ #include +#include +#include #include #include #include -#include +#include +#include #include @@ -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 MMU + // and interrupts, and jumping to the PEI entry point. + // + Reset = (VOID (*)(VOID))(UINTN)FixedPcdGet64 (PcdFvBaseAddress); + + gBS->RaiseTPL (TPL_HIGH_LEVEL); + ArmDisableMmu (); + Reset (); + } } /** diff --git a/ArmPkg/Library/ArmSmcPsciResetSystemLib/ArmSmcPsciResetSystemLib.inf b/ArmPkg/Library/ArmSmcPsciResetSystemLib/ArmSmcPsciResetSystemLib.inf index 5a1ee976e5bc..19021cd1e8b6 100644 --- a/ArmPkg/Library/ArmSmcPsciResetSystemLib/ArmSmcPsciResetSystemLib.inf +++ b/ArmPkg/Library/ArmSmcPsciResetSystemLib/ArmSmcPsciResetSystemLib.inf @@ -30,6 +30,15 @@ [Packages] MdePkg/MdePkg.dec [LibraryClasses] + ArmMmuLib ArmSmcLib BaseLib DebugLib + UefiBootServicesTableLib + UefiRuntimeLib + +[FeaturePcd] + gArmTokenSpaceGuid.PcdArmReenterPeiForCapsuleWarmReboot + +[FixedPcd] + gArmTokenSpaceGuid.PcdFvBaseAddress