From patchwork Thu Jun 7 11:08: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: 137875 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp1950568lji; Thu, 7 Jun 2018 04:08:22 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIrdhExgSXgqQpO3djkMNgONkb2J5oiB7gr8S3CRxsPjHAOkPsuRgoIoth+uIsXY/KaE5U9 X-Received: by 2002:a62:8d5:: with SMTP id 82-v6mr1395459pfi.154.1528369702060; Thu, 07 Jun 2018 04:08:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528369702; cv=none; d=google.com; s=arc-20160816; b=qlGkukkxq36l+YpwHdTapSgEUOgy/+cTDkGHzKsdAFDHsyx3BM+nsj+nnaY5pMLU6K CoTDUfKg5CVWFIvcpMG4WJPwt9033yisAUpMHJTbZm9YCsORhE3ED4JrIO3KhEJ92c2X o9BbJdAx4VUbWXe2B4mImEGUFviA4Ro9i0DB2ziLfA0eeJ2LwbBLCn8cxEFeRU6zcCQ4 4HxTHSFYuahYY0W54n8+X+c3rFfdEXjvR0sy1GHrHykPJ069CQGqtdd1AiDsOuyjRja7 H3P0IcTQypI9ZbiTNL3N/cf8zadXuzlz+h2PwNdWZbnUCwun/emOzbI/1SEiagQSswXA bLdw== 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=H5si6LLwgFMoBhYgp+yfgymiL62Gi28cNS88IVg2o+g=; b=trS4EsV0etXfRY1JarCDPFEWlc7q6FouvF/gUKCP0R4hpMYIqv9YKAkJUAsbTMx0Om 0G1SxqfyV5d9JMBuPR+oWLr0kNLLEGB7On996SdXGRhF2k46+O31CRzKrWU9nd3918Ew IcOt6J9IGXWtYR6riI7X9FzuYk8aLwCPCsmG7sJqvG5yO+jSVbLw8jMTQQNIVyIzXZSy iuXENAuZbluaECEUWv5Q488W9OAKkmhlEqrO3AnD2EgFiLpOnavbW0PCKr2GYc4VSG8b YKymSlSSGqtwn+wVap9KHn+/sZKkSQw5Pj9DVmo6dRInQ4ak55jLe+V7WawVKdMMhZnf wsSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=gFb0GlG+; 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 x2-v6si15464029pfn.315.2018.06.07.04.08.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Jun 2018 04:08:21 -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=gFb0GlG+; 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 48504211C3F6D; Thu, 7 Jun 2018 04:08:19 -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::244; helo=mail-wr0-x244.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wr0-x244.google.com (mail-wr0-x244.google.com [IPv6:2a00:1450:400c:c0c::244]) (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 16B35211B85FE for ; Thu, 7 Jun 2018 04:08:18 -0700 (PDT) Received: by mail-wr0-x244.google.com with SMTP id a12-v6so9647815wro.1 for ; Thu, 07 Jun 2018 04:08:17 -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=KEYJMTUEqBlBTHgwySNGwZgl7i4BEmO3mp/rs+IeSW8=; b=gFb0GlG+edBio7ur+qxkabmSeFM+nO0b20GEx9DhDutR2OVUDksvgxXNb4Z0wkOywl ISk80Z4gY1q/F+Q142gs1RpKAUY0uW0Y4S6sTHq+P9wTq9oproTeRYOQXEO28lVUfQJH NO161nIAWcAjd50G1Xq3kf0wcAOK050DqQ4H4= 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=KEYJMTUEqBlBTHgwySNGwZgl7i4BEmO3mp/rs+IeSW8=; b=NaNpnlMtYU1syyX90OYqroJ97feIdy6A0QS3/jAX2D0UHBbEhHWtqcNiBh+dNyf5G6 l8NjZ5fLdHcaxON81/2oleYjdxbB8LzSDBMfF5tXdqWTm7dN1klEYn9gtjO9xvt0Q8Mc nLUqXTLaRwasE1YSgUvkHcYchMu4rTA1UweumGUDLE4wLS3N8zcsHaOQgQiHiduRb+98 +Njvjn7eozSHmORfygahryk9rUGsCYt5LGixF3ubZ6yrDPQW7y0UudQeLqlo6A3585ZX IhsHZyCQ5AFB84p37xV5q8+2lniehfrxiCHdm4PG5ar865HJu4P2QU2JA8i4rIkFePXj XBLQ== X-Gm-Message-State: APt69E39wtNS8Nx9atkTgHLJSBu7ugisIaGbyfq/Hse0HEVpfqIUi4y2 5WHrZhR1l4YaG5SNfIpcUpSQjxGBVxM= X-Received: by 2002:adf:dc52:: with SMTP id m18-v6mr1405048wrj.84.1528369696418; Thu, 07 Jun 2018 04:08:16 -0700 (PDT) Received: from dogfood.home ([2a01:cb1d:112:6f00:88ff:8f90:37f1:db91]) by smtp.gmail.com with ESMTPSA id 72-v6sm54997900wrb.22.2018.06.07.04.08.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Jun 2018 04:08:15 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Thu, 7 Jun 2018 13:08:08 +0200 Message-Id: <20180607110812.26778-2-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180607110812.26778-1-ard.biesheuvel@linaro.org> References: <20180607110812.26778-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH 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 | 10 ++++++++++ 2 files changed, 11 insertions(+) -- 2.17.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel Reviewed-by: Jiewen Yao Signed-off-by: Ard Biesheuvel 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..fb59f338f100 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 @@ -274,6 +275,7 @@ ValidateCapsuleByMemoryResource ( // // No memory resource descriptor reported in HOB list before capsule Coalesce. // + WriteBackDataCacheRange ((VOID *)(UINTN)Address, (UINTN)Size); return TRUE; } @@ -283,6 +285,14 @@ ValidateCapsuleByMemoryResource ( 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)); + + // + // 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); return TRUE; } } From patchwork Thu Jun 7 11:08: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: 137876 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp1950596lji; Thu, 7 Jun 2018 04:08:23 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJ8Orbi0yccMb4w2WRqiBUpXAeiBQBqMd1O0pqAa5cPukQor/2jWAPKzWZtHmNkdqoIIP0Y X-Received: by 2002:a62:830e:: with SMTP id h14-v6mr1406115pfe.64.1528369703748; Thu, 07 Jun 2018 04:08:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528369703; cv=none; d=google.com; s=arc-20160816; b=VFTjzrPL3BDno11f3IGlPNSYnOsDhPKg42Et9PSEcqZMdphSH4LeAwJ/KH6TbNsyzg 9uW/VM0c5g+0m8Ji1Gry5uIB4HsioLJPOiFLvTgVt5CFsaq5YlVnr13GQNUvKr2w31Q8 IBCL0//TlzBC5LpsGOLOsTRYuC8DhG+jG4+KeNArBwxpL9zzTVWzsMMksFdBO1WYaeFD TPA6r1bwloXLiJuwEC2BlrMUPc2EaptZPRPq6GZhOwgpiNojctItTIR/HdE40cq4KxMf d64ya0U+AywRBBGFrPGtbujGWYthWZy/DY0b1JRbold4Zlk9oXLLpDO4eyk+3JywH6Ft 2HAQ== 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=7TUk1c3rUeFFk5MbRKov2sG2Jr4BmS8MGO9B9mkaqKQ=; b=eLI934h2bExVavPGPaP0LNdvggAknM+W6ksHVKui6x7el9IjAkXmLgcv6EZuxLlkbn F/lPyEWxJuyGFqcgIyr+mjv/pxn2DTBDE5eQTX4oDTLFI4rsxIcxjyb0I+lt42Y20Fjw jVSJmtI22d4yEftr1fWIrjOExqD2expOo6PaA5ShKiLtGIF2JL33MtKwkO6q7EWYulkv pYqjpxCmZBLAgEzQdvR/AZ7twbxS5YvbFyPgsCbjnfweDVVnkpZpMRlseUzzexh5/5Li DpxJ4VcAASmW/u7zkPFkTf/aIDuMDfIEB9hvnbbY7heHJIirJxe3hYNJoDh3sSILWYYo vibA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=WGp+2kQZ; 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 p8-v6si53021911plk.441.2018.06.07.04.08.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Jun 2018 04:08: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=WGp+2kQZ; 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 763ED211CFFC6; Thu, 7 Jun 2018 04:08: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:c0c::241; helo=mail-wr0-x241.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wr0-x241.google.com (mail-wr0-x241.google.com [IPv6:2a00:1450:400c:c0c::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 30A5D211C3F47 for ; Thu, 7 Jun 2018 04:08:19 -0700 (PDT) Received: by mail-wr0-x241.google.com with SMTP id x4-v6so1485913wro.11 for ; Thu, 07 Jun 2018 04:08:19 -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=ykjohDSxVLRy+E3pzXwoHmYP9tKZIFAMNmg1ZKUUmpk=; b=WGp+2kQZ8CSOD7nspSn5cpELZMNp6YwA7nE4MwBeHyNFw5OyJcn8s4oAsxX84fYjE+ XA89e6O4gSAuuFzgaByGongWTfMXaTjoL0Tasy2O+U+A6+19HtHPXeU+ITPxWomqKYMM TaWqo4oGmn+1BgF0zJnQCrGHEIcAcbj3v6NMM= 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=ykjohDSxVLRy+E3pzXwoHmYP9tKZIFAMNmg1ZKUUmpk=; b=C7Nlibj5gbtlrrjy7VICeyE9Dk4hLTILLAuMXxwrh8PixP24SpTICG3H6Utwa0D8sj QLc/Wsvc15KCGH3/x6BtMboCNTNiFOOEbYP28HuKY/x0FJAJac0E7ctLuUPSOLlvAmBI PYCUg3hkHbNOb3/eUnYKgORG8aDVGB6qI5oWCBESE2DrqDdumf4m3P9eTVGQsofO941F irwIGtKPjYo13e58V29GM0KIPrUag9UQwzQMYI7byHV7s+/GCzd57TQ0OM0tBHzhuOwS KDngscMa3fTTWyviGwbHmt4UbMPgC/9pJf+dqC2gRmRrmWZr0fHpyRLF10NSvzXkoDdk sGpw== X-Gm-Message-State: APt69E2Tuwk4hiB6mF9mq1zvDFBLJqyLUeOTXTmpUZmYSijWSPmT8Qlm hgnG+3Qz+xOz24D33ucGWcjP6MQfMVU= X-Received: by 2002:adf:98cf:: with SMTP id w73-v6mr1373017wrb.209.1528369697541; Thu, 07 Jun 2018 04:08:17 -0700 (PDT) Received: from dogfood.home ([2a01:cb1d:112:6f00:88ff:8f90:37f1:db91]) by smtp.gmail.com with ESMTPSA id 72-v6sm54997900wrb.22.2018.06.07.04.08.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Jun 2018 04:08:16 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Thu, 7 Jun 2018 13:08:09 +0200 Message-Id: <20180607110812.26778-3-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180607110812.26778-1-ard.biesheuvel@linaro.org> References: <20180607110812.26778-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH 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 | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) -- 2.17.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel Signed-off-by: Ard Biesheuvel diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleProcessLib.c b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleProcessLib.c index 26ca4e295f20..52691fa68be4 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,10 @@ 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] LastRound FALSE: First of multiple 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 +376,7 @@ PopulateCapsuleInConfigurationTable ( **/ EFI_STATUS ProcessTheseCapsules ( - IN BOOLEAN FirstRound + IN BOOLEAN LastRound ) { EFI_STATUS Status; @@ -384,8 +387,9 @@ ProcessTheseCapsules ( REPORT_STATUS_CODE(EFI_PROGRESS_CODE, (EFI_SOFTWARE | PcdGet32(PcdStatusCodeSubClassCapsule) | PcdGet32(PcdCapsuleStatusCodeProcessCapsulesBegin))); - if (FirstRound) { + if (mFirstRound) { InitCapsulePtr (); + mFirstRound = FALSE; } if (mCapsuleTotalNumber == 0) { @@ -404,7 +408,7 @@ ProcessTheseCapsules ( // Check the capsule flags,if contains CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE, install // capsuleTable to configure table with EFI_CAPSULE_GUID // - if (FirstRound) { + if (LastRound) { PopulateCapsuleInConfigurationTable (); } @@ -453,7 +457,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 +550,7 @@ ProcessCapsules ( EFI_STATUS Status; if (!mDxeCapsuleLibEndOfDxe) { - Status = ProcessTheseCapsules(TRUE); + Status = ProcessTheseCapsules(FALSE); // // Reboot System if and only if all capsule processed. @@ -556,7 +560,7 @@ ProcessCapsules ( DoResetSystem(); } } else { - Status = ProcessTheseCapsules(FALSE); + Status = ProcessTheseCapsules(TRUE); // // Reboot System if required after all capsule processed // From patchwork Thu Jun 7 11:08: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: 137877 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp1950664lji; Thu, 7 Jun 2018 04:08:27 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLN8vlJWaREc46x8YVoiKtk6S0Djw24MwlZQ3siUy3MyM2wBTaJGi57XgjXQQ85CMYSebm+ X-Received: by 2002:a17:902:28ab:: with SMTP id f40-v6mr1568683plb.208.1528369707353; Thu, 07 Jun 2018 04:08:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528369707; cv=none; d=google.com; s=arc-20160816; b=N0tnQI9T/UAgSAbvOWRTpK+/BYHnyGLmZ6XEcphbb8buFV6B6GLOe3YjvorJUE2iPg KQ5NhPvDsSZY4n2pSbzjH+PgsBS+SOqDvqdSpjOUb9ZmjaGFoPLW3IAlEeEaYTd5iDGn 247SwrGWhic4HhFZ645y+gLnV6bjynyUc0tKxOERUWgWdI5XvQ6vzBfGRveRSv8Q0GrD mytHlgRxKTr0oGk69lN4OGeoRuMViKh14Qvq9XQRKEJREXIMZY/OEGQnWbsenivygZ1K XTBBvYaBvCGXBazJpO3XSpJTGpsR2OL20OkvASOToRDZFIAkURUbsMm5WVf8orJUa5GA JRBw== 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=u2IDTaVm0EhJUqTVK8v5AyVEX3iefeoEI7MfSDadfyK4MeNoYixasksuIx/9jE2C4D 4bL1TiOqOyqb99FDoQ2JNNfOkDyqDAEX6+VfESUxFBiRU93VeTrvsyQ+CcvxswMCv4oQ YO53c8a09D65rugJm56exO3/6ucNN/VUU8AKx0tSRvgiRRac518RRTYtHCz2TvxP3CLN OgTsbj8/uG0OMnksRqIN2sJ3iCGx1KZDVEgypXTWCbB1kiTjw84P+E4rLVM8FGDcB5LH zTcWXDXLGvCG5MOXfRvkG9RkvPn8I5Vcbckd2oKiM2o3qEWylp5gUNk+liDHIrwi/R50 Zr/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=hEED2FIR; 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 a22-v6si9962183pfn.19.2018.06.07.04.08.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Jun 2018 04:08:27 -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=hEED2FIR; 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 9F8F6211D67FD; Thu, 7 Jun 2018 04:08: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:c0c::242; helo=mail-wr0-x242.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wr0-x242.google.com (mail-wr0-x242.google.com [IPv6:2a00:1450:400c:c0c::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 D1E61211C3F47 for ; Thu, 7 Jun 2018 04:08:20 -0700 (PDT) Received: by mail-wr0-x242.google.com with SMTP id l41-v6so9631580wre.7 for ; Thu, 07 Jun 2018 04:08: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=FspWq5+qPhF63i9or4drgtMsbF6v8QDNI43SSAS41n0=; b=hEED2FIRUBi/Kxcs1j5U+qmmmkUXoVA6jvC36nE2b3duY34VtulgI0s/6DJuDILVZQ JSjglTdbrgSjr0XHrfxChtL/vCB1azR1Tb7lXLv6WiAxnWrOHm8Ag+uHRd0tlHVRQQbj pZuFXWt5fhRgAEscCX6nTGfxnGdjV/pNf3zko= 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=dahC/ccGWpSAsdr047DGDxzb/ddG52e1cjAXM7hypkxsrqvcw5hVZQJiT/XxV/2i+f qxeakgUP+j8PdLScAAsPB7zACnOmYgCgoS3ckxEqUv3gg4amr5lhEP2NNsyYWGiHAHtD 9sGngSs+ehTbzEbgLwO/4LFYvI0IQFqtd7It8rN8FuPc9HdMhEr/1VxFgkMTHz+5KCmi FacIiVQPNvyqxYnoUyhBlTvbQEZTIikd7oLWIyuyJtkGOouvVWwFfA/ikfTfZSQ/XKGS p03VS+HHSNCxgKcUEEPE/fiFp5UkPYQJyVPGANblXTksLWE8UaLLT0HhDfBNjX77OezR xpbg== X-Gm-Message-State: APt69E3Y1RiWVbzK0RHY+UanjR0STIiNhLXuE+FpodAzMCaE726kM1/F F8h8SU+ZRhxwgOuPojvjkU9RxJ6tj38= X-Received: by 2002:adf:b60d:: with SMTP id f13-v6mr1276961wre.186.1528369698758; Thu, 07 Jun 2018 04:08:18 -0700 (PDT) Received: from dogfood.home ([2a01:cb1d:112:6f00:88ff:8f90:37f1:db91]) by smtp.gmail.com with ESMTPSA id 72-v6sm54997900wrb.22.2018.06.07.04.08.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Jun 2018 04:08:17 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Thu, 7 Jun 2018 13:08:10 +0200 Message-Id: <20180607110812.26778-4-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180607110812.26778-1-ard.biesheuvel@linaro.org> References: <20180607110812.26778-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH 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 Thu Jun 7 11:08: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: 137878 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp1950702lji; Thu, 7 Jun 2018 04:08:30 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJFFRQWAcxjBlybe8P2vOdl0lwyGD6Q7sARJlGIwwbcLC0Bh77xD1YUDAiiEG29ksZE8P6u X-Received: by 2002:a62:9d82:: with SMTP id a2-v6mr1358769pfk.223.1528369710548; Thu, 07 Jun 2018 04:08:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528369710; cv=none; d=google.com; s=arc-20160816; b=f/lGyrNuVl1MNNp1ur1qyAwWv9jtYBRlFRINdf3qWp7g7S5cqbvPC6rPlEDexXvdYi gbjijJFfmBaPH8VGnjHuDc96F/I1ROD9JmdrEFPYgbpRh4SEDTk8a7oOxGxE7zsvwnK8 sGq2DTYVgfPb9YsPLXUrJky2t1afzhqQ3DpIifi0xPf6LUuvFAFzgyxNCAH3WcG9S43q nA/uF6XtEq/sU4drAsLgplzDGqrsuLfLXrsUaW/5J2FGADR43dPdWOV33jWlwCdDYCDi t9S0nh7ljnYo7c/1E/XMnLVaRRfxPc5EalD7u1zldriUCGcvi7ysYNCzXLaSHkxuVCdn 3duw== 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=yXBkbTdsRRe42cjWiM2hplUlderIQVAjgfKtDASqrV0=; b=g8Ar4KvomPITbvjFf9fCcrq/kh+KB7EWXtA5ZDUhWDxkJpBI340ydTGGj+Y5Ats96i gUiThgxPwTsn+LhojuFFnnIoOxSeVxVhmyBiyHvgV4hGeDqCXWPAWmTNe4w2uSRqzyhI li7QMiaq27m+JB+rnJ5NfEZBPVpTjDAfq5fGGjWAt1DKjPAG0KRZTqqDuBIM3a4JWyyl xMsjw9VRFmQjF1LShMUM3T3a870mzKHqfVQfPn/hORwiH610q/QXDTY8ugyhRuNCOtOY 7IybKpxX4YBxrEeMV9U6kVV2NNqBLhjoOWcLGZboTQAUEPBiHqPLAtHqQdIBfiwFxuXM LM5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=ColBu0+H; 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 d5-v6si20147606plr.13.2018.06.07.04.08.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Jun 2018 04:08:30 -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=ColBu0+H; 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 CAF00211D67F6; Thu, 7 Jun 2018 04:08:22 -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::243; helo=mail-wr0-x243.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wr0-x243.google.com (mail-wr0-x243.google.com [IPv6:2a00:1450:400c:c0c::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 90A3B211D67EC for ; Thu, 7 Jun 2018 04:08:21 -0700 (PDT) Received: by mail-wr0-x243.google.com with SMTP id l41-v6so9631659wre.7 for ; Thu, 07 Jun 2018 04:08:21 -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=o+84anZdOaoGmnazOmTgpD/VqzbYO6uf3gsP1KNc2FY=; b=ColBu0+HDNoTSr5olLZaN9Kp4ld6aV0YGvb21uDIklAC3gisNXMknHACJwyaT6OGKW i4z4hlcOJpZ5FH38eXRe79TBKG0D3/MHuM+4S2YZouW+5FZLO5LMMkn5qNKWdQ+65d2z yq4vaT3bf6/tic43pSLoODmxWFHBVVgLoABLw= 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=o+84anZdOaoGmnazOmTgpD/VqzbYO6uf3gsP1KNc2FY=; b=cAE9f4uYWUA7IcqvFJBkuev1R1H6c45sbFcDM8zHRXdyottQOraVDum7ROSTH5v6st LxQMhOda2+7mcWFM2WjklZL/6z0kAzXl2shsBlePKhHUmcC8wCQ966VEws0xypmteila R1VZxApBW/NepXXqWEmY1orzdqxRctgVDKrnMMetGAuoNpLsBpPgSIkFontxE+SYS67K NYtRx7Fh9VmNloHaj60PD8fgj3oXLtFmXLBF3xFSLbF+EQXNbBD60T8ldgC0Mjf9m+G7 Cb8LeX0Jkbiv6OYHE70DDilA4WI02t9wIV9rhszFhBi51cFFo8DlwqRSYYJDrxtuzq09 NcAw== X-Gm-Message-State: APt69E0GggZIqKSBL+dnU4kgiXIbwfFBDCMD95GnGH6OJP8pRTi3QqJO nb9JnCKPzvDhtyV7SLRfApBKjIGImhM= X-Received: by 2002:adf:8854:: with SMTP id e20-v6mr1437745wre.30.1528369699950; Thu, 07 Jun 2018 04:08:19 -0700 (PDT) Received: from dogfood.home ([2a01:cb1d:112:6f00:88ff:8f90:37f1:db91]) by smtp.gmail.com with ESMTPSA id 72-v6sm54997900wrb.22.2018.06.07.04.08.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Jun 2018 04:08:19 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Thu, 7 Jun 2018 13:08:11 +0200 Message-Id: <20180607110812.26778-5-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180607110812.26778-1-ard.biesheuvel@linaro.org> References: <20180607110812.26778-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH 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 --- 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 Reviewed-by: Leif Lindholm 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 Thu Jun 7 11:08:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 137879 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp1950763lji; Thu, 7 Jun 2018 04:08:34 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJmb7hjl2sMiuBYGfKzaZoVOE/9vSLQMvxQNhJf0etRnTRQKXZz43a0Wq0tB3019EgrH9hv X-Received: by 2002:a63:7b4e:: with SMTP id k14-v6mr1191549pgn.261.1528369714270; Thu, 07 Jun 2018 04:08:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528369714; cv=none; d=google.com; s=arc-20160816; b=Ng4TifLyEYojG68wcmGSJX/YS8SGlaHRPg3U5qyqr98O+bHw0EbQtOAhcrFfEohEMH 5cfKJs9lsyV/n0ocuYz++4Tgpk2cO8CPzOt4MGKDjL0UJjWYigsRF/VHUpH2KCOEHAmU 9b6upx5BzvrJfTPLBhfSewN9u6UT4Ino9UJyPeN+vV6Jp73C547YHfycRr2/Pz9WkSj/ GpYyUPqkzLnq25a7G9T1EV/S8boa/KJlCIZUUwOeMmk/W/hNxyh4cyTPOow2lR1mudZz Y3j7qGxO7zaCeENpLeR6ERLGFS1jeURCIlphk+efd6JuaUrdwDQ0mlaF0BaE/xGvz6Rk jKFQ== 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=VFqH5FughndcmQp6EEe+BTicTpFsyDc4rabDZ1uUcPViSoDF6KHoHW+mOGbcijaaDD +5V1VBzN5prgth8Lp4JiOkhrYDl+ph+ZaYWNxHyqfMszYwqbDHTMpKSfWcT/3ltCXgF3 q/0eoix4Wr0IuEG+KBlq8VG0huPiwPsRE0UWY2++K/ZkfErRbgKc5UFCGL8Wxt+eEuot SjyMhClr4HllARP2cCAFlI+X+/9VJNu/U1S7ld3SvBsq3Y7aMC0Zn3nbC1AsIS+eCIYJ FurymQr9OOGvyBZZUizkOg3KkMvjaQY39yPD+rtbYhBQ2ggjKBlZTlkj7nSBw33Br+i+ /DnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=c5KeHvRw; 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 w16-v6si23873323pgc.232.2018.06.07.04.08.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Jun 2018 04:08:34 -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=c5KeHvRw; 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 01271211C3F47; Thu, 7 Jun 2018 04:08:24 -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::243; helo=mail-wr0-x243.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wr0-x243.google.com (mail-wr0-x243.google.com [IPv6:2a00:1450:400c:c0c::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 CFC3C211DDA00 for ; Thu, 7 Jun 2018 04:08:22 -0700 (PDT) Received: by mail-wr0-x243.google.com with SMTP id f16-v6so9647793wrm.3 for ; Thu, 07 Jun 2018 04:08: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=IDGZTFa44cMq31H+VcVxKIAVLEOpjBlqf99JEjpN1rg=; b=c5KeHvRwLMyCedDlQA5ES4N9PoLaT/+rLodZY+fdzg+WgFw0sJXUPexwZRA7qccS+/ lRfxYLZStaObVsX78LZw0Rz20C8/wy7ZHsKuWIOWOHheNCniQFs6ZJ1bI3Kp9WuE8Nzu wQrXVC0euA060gVLGNYn3S86SLsTyVr8zchWQ= 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=IA+t55BJ2dtMo8tUZSlFTbkE5cxriKkEGLk+95olIcLgfhyOiAYbo+ovOrAHOYTKFg +JTnkcv+NHCruL9O2gYJTn/w+QNoCmttZqSVIWzfy7TnAaaFB9rclTYnB83rd6WSPxzG jiDVQvN7flX6cGyM4OrGRrG7Fuu/TveJYR60WAIeVny/QVV4pfxlkl+jERydI5z5WW9C dBMZWgVYn971fAR1sSC1/F6VOCm8AgrubD6xafz54J7x0yovjcL7+1wtzON1EDOltZFq TILs1qVlDnHoILHR2OfU5E/0++tCWqsNXToHDbJJ0GuzYMwIBGsWs7l3/0yfWcnmkOlI vp5A== X-Gm-Message-State: APt69E18lE/gvytctczyrVzFLhb1pJzf+4RH8GsX76kQU7Fg3Ffk0flO hOhBVJaHVTNIViki3zNHMKQotqdiOsU= X-Received: by 2002:adf:91e5:: with SMTP id 92-v6mr1342871wri.124.1528369701227; Thu, 07 Jun 2018 04:08:21 -0700 (PDT) Received: from dogfood.home ([2a01:cb1d:112:6f00:88ff:8f90:37f1:db91]) by smtp.gmail.com with ESMTPSA id 72-v6sm54997900wrb.22.2018.06.07.04.08.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Jun 2018 04:08:20 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Thu, 7 Jun 2018 13:08:12 +0200 Message-Id: <20180607110812.26778-6-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180607110812.26778-1-ard.biesheuvel@linaro.org> References: <20180607110812.26778-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH 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