From nobody Wed Dec 25 14:35:58 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 Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1510323844437139.6921666777913; Fri, 10 Nov 2017 06:24:04 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 9D2C72035D11E; Fri, 10 Nov 2017 06:18:56 -0800 (PST) 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 C262A2035521F for ; Fri, 10 Nov 2017 06:18:55 -0800 (PST) Received: by mail-wr0-x242.google.com with SMTP id u40so8734492wrf.10 for ; Fri, 10 Nov 2017 06:22:58 -0800 (PST) Received: from localhost.localdomain ([160.167.170.128]) by smtp.gmail.com with ESMTPSA id e131sm1036477wmg.15.2017.11.10.06.22.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Nov 2017 06:22:56 -0800 (PST) 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::242; helo=mail-wr0-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=hXUK7Wt8oFn9cCETSDa4FUJWSJBLAiRuW2w82ob6f0U=; b=J360xsYi2Fd2eBGOBqPfaSSS2/IKBxDAAj5EIOVZEZi2Q0HGXR1GcBC+H1Wj68otQB 66ZPs6nsjqycCyCvTYy9109t9oDa1xI7zBcyI7maWM2E/20iCNJy+4S/AfwDxMoMaqbS acy2QyIBVbcKf7FO0Gq/EcdWnxNGuFaDIoLZk= 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=hXUK7Wt8oFn9cCETSDa4FUJWSJBLAiRuW2w82ob6f0U=; b=Pz5w5A5Cny4LgyTN4lK5ge8IBVFperbzcqDejhaSeI7sZXfOM6D3J0wfChMouY0bYm h3HLFiO1f0rlcVb9hvZrmKB8h674ecVkHC4a+twBRJSlKduA9/O8V23QwszHOA7ypV9N wUfCdGH72NJ1ww/f3VMBacJK3r+yWdAfKN0twveYAO9C/yl0WSH9poNlOGQjLiy6tgNf W4wflG+gcfIX7zln8Iyx498PWV5wjEC1pze0Avl0N1vWuR7kECWVkpZ2LwjVMSn0OpTi QFjp7SFWuZZfijQ7xk6CK2StNZBVolWtvasm6YXC3x2IG242/quvduQDJ6eEAM8LwPeP RT4A== X-Gm-Message-State: AJaThX6r07bwfEMXupyouRKHn8RbNF+0bhk+/fRC02Oju2Ty3OJ+ZGQO OYdO2eF4k1Ix7sTGLzF0GYnHaT5jjZA= X-Google-Smtp-Source: AGs4zMZuBawNXqUjvB3ZP+vFIt/zHZ9cMd5p+uBZr1vFwoOFwwuBlAemKWN+LCuubTAeqOZjwPpRMQ== X-Received: by 10.223.182.73 with SMTP id i9mr484010wre.113.1510323777118; Fri, 10 Nov 2017 06:22:57 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org, leif.lindholm@linaro.org, daniel.thompson@linaro.org Date: Fri, 10 Nov 2017 14:21:20 +0000 Message-Id: <20171110142127.12018-28-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171110142127.12018-1-ard.biesheuvel@linaro.org> References: <20171110142127.12018-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH edk2-platforms v4 27/34] Silicon/SynQuacerMemoryInitPeiLib: ignore capsules when clearing NVRAM X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: masahisa.kojima@linaro.org, masami.hiramatsu@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" In preparation of adding support for setting a DIP switch to clear the EFI variable store, update the early capsule handling logic to take the boot mode into account. This is necessary for two reasons: - we override the boot mode when a capsule is detected, - the capsule detection itself involves reading a EFI variable, which we shouldn't be doing if the varstore may be in a bad state. So factor out the initial capsule check (to keep the code understandable) and only perform it if we are not booting in 'clear NVRAM' mode. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMem= oryInitPeiLib.c | 68 +++++++++++++------- 1 file changed, 45 insertions(+), 23 deletions(-) diff --git a/Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/= SynQuacerMemoryInitPeiLib.c b/Silicon/Socionext/SynQuacer/Library/SynQuacer= MemoryInitPeiLib/SynQuacerMemoryInitPeiLib.c index b44c58d61062..63c441872da7 100644 --- a/Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuac= erMemoryInitPeiLib.c +++ b/Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuac= erMemoryInitPeiLib.c @@ -170,6 +170,44 @@ DeclareDram ( return EFI_SUCCESS; } =20 +STATIC +BOOLEAN +CheckCapsule ( + IN EFI_PEI_SERVICES **PeiServices, + IN PEI_CAPSULE_PPI *Capsule, + IN EFI_PHYSICAL_ADDRESS UefiMemoryBase, + OUT VOID **CapsuleBuffer, + OUT UINTN *CapsuleBufferLength + ) +{ + EFI_STATUS Status; + + Status =3D Capsule->CheckCapsuleUpdate (PeiServices); + if (!EFI_ERROR (Status)) { + + // + // Coalesce the capsule into unused memory. CreateState() below will c= opy + // it to a properly allocated buffer. + // + *CapsuleBuffer =3D (VOID *)PcdGet64 (PcdSystemMemoryBase); + *CapsuleBufferLength =3D UefiMemoryBase - PcdGet64 (PcdSystemMemoryBas= e); + + PeiServicesSetBootMode (BOOT_ON_FLASH_UPDATE); + + Status =3D Capsule->Coalesce (PeiServices, CapsuleBuffer, + CapsuleBufferLength); + if (!EFI_ERROR (Status)) { + DEBUG ((DEBUG_INFO, "%a: Coalesced capsule @ %p (0x%lx)\n", + __FUNCTION__, *CapsuleBuffer, *CapsuleBufferLength)); + return TRUE; + } else { + DEBUG ((DEBUG_WARN, "%a: failed to coalesce() capsule (Status =3D=3D= %r)\n", + __FUNCTION__, Status)); + } + } + return FALSE; +} + EFI_STATUS EFIAPI MemoryPeim ( @@ -184,6 +222,7 @@ MemoryPeim ( VOID *CapsuleBuffer; UINTN CapsuleBufferLength; BOOLEAN HaveCapsule; + EFI_BOOT_MODE BootMode; =20 Status =3D DeclareDram (&VirtualMemoryTable); ASSERT_EFI_ERROR (Status); @@ -199,31 +238,14 @@ MemoryPeim ( ASSERT_EFI_ERROR (Status); =20 // - // Check for persistent capsules + // Check for persistent capsules, unless we are booting with default + // settings. // HaveCapsule =3D FALSE; - Status =3D Capsule->CheckCapsuleUpdate (PeiServices); - if (!EFI_ERROR (Status)) { - - // - // Coalesce the capsule into unused memory. CreateState() below will c= opy - // it to a properly allocated buffer. - // - CapsuleBuffer =3D (VOID *)PcdGet64 (PcdSystemMemoryBase); - CapsuleBufferLength =3D UefiMemoryBase - PcdGet64 (PcdSystemMemoryBase= ); - - PeiServicesSetBootMode (BOOT_ON_FLASH_UPDATE); - - Status =3D Capsule->Coalesce (PeiServices, &CapsuleBuffer, - &CapsuleBufferLength); - if (!EFI_ERROR (Status)) { - DEBUG ((DEBUG_INFO, "%a: Coalesced capsule @ %p (0x%lx)\n", - __FUNCTION__, CapsuleBuffer, CapsuleBufferLength)); - HaveCapsule =3D TRUE; - } else { - DEBUG ((DEBUG_WARN, "%a: failed to coalesce() capsule (Status =3D=3D= %r)\n", - __FUNCTION__, Status)); - } + Status =3D PeiServicesGetBootMode (&BootMode); + if (!EFI_ERROR (Status) && BootMode !=3D BOOT_WITH_DEFAULT_SETTINGS) { + HaveCapsule =3D CheckCapsule (PeiServices, Capsule, UefiMemoryBase, + &CapsuleBuffer, &CapsuleBufferLength); } =20 Status =3D ArmConfigureMmu (VirtualMemoryTable, NULL, NULL); --=20 2.11.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel