From patchwork Thu Jan 3 18:28:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 154740 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp950439ljp; Thu, 3 Jan 2019 10:29:07 -0800 (PST) X-Google-Smtp-Source: ALg8bN7cLvFog8lldk5vpneUQhSWsvX1ejYQUG0/xdB4+x93U9lMDtfT+nBavoWWAxO2HlSsfXHe X-Received: by 2002:a63:be4d:: with SMTP id g13mr18099325pgo.378.1546540147734; Thu, 03 Jan 2019 10:29:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546540147; cv=none; d=google.com; s=arc-20160816; b=x1XL363wj/099DCf6I65gKAcYcolw+PMQraJmLcc7gN9hUMcXxW+NkFnAs7ChczQ43 Dt8sq/H9jxU4+jWmip5NsverbsxteZQhJlX+U+pYPYULyIlsaYP7u/+9lib7YvLsUrO3 I95Rl9+uBDp+O7JhE/QjSPVlnDQQZq+nBhhrneDT3V1Ca3y9hGsGXFKRIK1CR1Rg+Gln 9z3Y7LesfbzjzHlg01IC03sS+1r1SB3FVg0tiCHwk8RGLl4rmZtSMJ4c5sSCp0tdsK3v CzEcZ+ojk+idL4JQN1NZrPX37aGWbeT4a3+ONqVrN7SJmcJSLNYgdvVKs52Qef04gHuH gMag== 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; bh=hwP71924TU+q8U/xBoglv7WPInunjmF0ahcgEfopstY=; b=Mx6AsATCEm6NaQnWYDECHHe6c8DOfhdeC8HndNOefzNf/gVINoX8HvTesf6j4zfpe1 92Sp2siOVPYnm5royUBPGsxtG2WQ4JVd4a+QHMnqp42mBrMFbx/0vAB5Z+LP0SydeUwn FNQqXBJwUcSKXYlVAPFYOB7Pye1bHdI5zO1kcyvJYzqIk4X6RJ8tR/3U58C4vweSuNTJ r8HbAQIgp25NA16cyqTOFinT1tjohlVNRn5SmCZOAvnb9rgxAK4c50oCWyiMmb/EZZER a8q9VTjnHfyF24eKEDWql0PpdXWcUHLTHXs+eK6lxmZO10Bn3iJNQnjlActCiIJ+ng4I AEIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=jxa8hk7c; 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 p3si33994210plk.424.2019.01.03.10.29.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 Jan 2019 10:29:07 -0800 (PST) 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=jxa8hk7c; 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 90445211ADA4D; Thu, 3 Jan 2019 10:28:59 -0800 (PST) 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:4864:20::541; helo=mail-ed1-x541.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-ed1-x541.google.com (mail-ed1-x541.google.com [IPv6:2a00:1450:4864:20::541]) (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 9A86D211ADA34 for ; Thu, 3 Jan 2019 10:28:57 -0800 (PST) Received: by mail-ed1-x541.google.com with SMTP id h50so29810626ede.5 for ; Thu, 03 Jan 2019 10:28:57 -0800 (PST) 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=shT3Q/Zocz0DJtBVOptUWODAts4+Q7AZH9hJtqDcNOI=; b=jxa8hk7coUs3O8Kndh/n67nrMvUBuLzEE85TL+ojeU0dihYdLo8vBCYM+iAx3nV4KO ywVLZP2WYyxFJglmFtkV6R8r2h5Z7h8wrH1mw4evtsbBa2tNlS3+zm5Ub5NFunESGAxU q6hVgx/A/hfrZW5I8sUg39NLthkuYoLcV/bJo= 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=shT3Q/Zocz0DJtBVOptUWODAts4+Q7AZH9hJtqDcNOI=; b=sv31LNsQEdgPAzUn9rwDHFY5fNq23i0qO8Rg/ch41bNxADzxsCq4Q9L98KxU/lhS6a 1TWZqioMjLjwGjmF1tXtfBIM6nDr14t1JH1WsL06nBTElAkVuq/G7RZ7ccwSbmMf0QZQ 31b2HAbdUO+lnyt5XEj3wcVVjPgeAg55YFhQGUdsKXiFOd0wLBcmrCZHQfdgnQCD/ruQ 5zbtB4GPNCXfxITxM6vT1xibg/uguUpzLzsgN7DaO0TdISYZDL6Sjl5NKBeSMECVxbMj zcM++OXWi+p7BRQeqLUpxffXAlDPeHj5pmWJRqbhf7geUPCQv4DryDKT/qpNInUZcSiK 6WSw== X-Gm-Message-State: AA+aEWY57beX3nniKogjkdQD/zfi9NlsHWBB1QEkzBcj9C6Ama3EnWc/ qzGhVzUqriwmoJlt7BpnERPt/1VeVPongw== X-Received: by 2002:a17:906:195b:: with SMTP id b27-v6mr36968543eje.220.1546540135652; Thu, 03 Jan 2019 10:28:55 -0800 (PST) Received: from dogfood.home ([2a01:cb1d:112:6f00:704e:c241:dc88:597d]) by smtp.gmail.com with ESMTPSA id a11sm25707206edc.28.2019.01.03.10.28.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 Jan 2019 10:28:54 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Thu, 3 Jan 2019 19:28:23 +0100 Message-Id: <20190103182825.32231-6-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190103182825.32231-1-ard.biesheuvel@linaro.org> References: <20190103182825.32231-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH 4/6] MdeModulePkg/FaultTolerantWriteDxe: implement standalone MM version X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Hao Wu , Liming Gao , Michael D Kinney , Laszlo Ersek MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" Implement a new version of the fault tolerant write driver that can be used in the context of a standalone MM implementation. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandaloneMm.c | 70 +++++++++++++++ MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandaloneMm.inf | 90 ++++++++++++++++++++ 2 files changed, 160 insertions(+) -- 2.17.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel Reviewed-by: Jian J Wang diff --git a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandaloneMm.c b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandaloneMm.c new file mode 100644 index 000000000000..b6fbf6c64f8a --- /dev/null +++ b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandaloneMm.c @@ -0,0 +1,70 @@ +/** @file + + Parts of the SMM/MM implementation that are specific to standalone MM + +Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.
+Copyright (c) 2018, Linaro, Ltd. All rights reserved.
+This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include +#include +#include "FaultTolerantWrite.h" +#include "FaultTolerantWriteSmmCommon.h" + +BOOLEAN +FtwSmmIsBufferOutsideSmmValid ( + IN EFI_PHYSICAL_ADDRESS Buffer, + IN UINT64 Length + ) +{ + return TRUE; +} + +/** + Internal implementation of CRC32. Depending on the execution context + (standalone SMM or DXE vs standalone MM), this function is implemented + via a call to the CalculateCrc32 () boot service, or via a library + call. + + If Buffer is NULL, then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). + + @param[in] Buffer A pointer to the buffer on which the 32-bit CRC is to be computed. + @param[in] Length The number of bytes in the buffer Data. + + @retval Crc32 The 32-bit CRC was computed for the data buffer. + +**/ +UINT32 +FtwCalculateCrc32 ( + IN VOID *Buffer, + IN UINTN Length + ) +{ + return CalculateCrc32 (Buffer, Length); +} + +VOID +FtwNotifySmmReady ( + VOID + ) +{ +} + +EFI_STATUS +EFIAPI +StandaloneMmFaultTolerantWriteInitialize ( + IN EFI_HANDLE ImageHandle, + IN EFI_MM_SYSTEM_TABLE *MmSystemTable + ) +{ + return MmFaultTolerantWriteInitialize (); +} diff --git a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandaloneMm.inf b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandaloneMm.inf new file mode 100644 index 000000000000..99bd62ad5ceb --- /dev/null +++ b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandaloneMm.inf @@ -0,0 +1,90 @@ + ## @file +# Fault Tolerant Write Smm Driver. +# +# This driver installs SMM Fault Tolerant Write (FTW) protocol, which provides fault +# tolerant write capability in SMM environment for block devices. Its implementation +# depends on the full functionality SMM FVB protocol that support read, write/erase +# flash access. +# +# Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.
+# +# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +## + +[Defines] + INF_VERSION = 0x0001001A + BASE_NAME = FaultTolerantWriteStandaloneMm + FILE_GUID = 3aade4ec-63cc-4a48-a928-5a374dd463eb + MODULE_TYPE = MM_STANDALONE + VERSION_STRING = 1.0 + PI_SPECIFICATION_VERSION = 0x00010032 + ENTRY_POINT = StandaloneMmFaultTolerantWriteInitialize + +# +# The following information is for reference only and not required by the build tools. +# +# VALID_ARCHITECTURES = AARCH64 +# + +[Sources] + FtwMisc.c + UpdateWorkingBlock.c + FaultTolerantWrite.c + FaultTolerantWriteStandaloneMm.c + FaultTolerantWriteSmm.c + FaultTolerantWrite.h + FaultTolerantWriteSmmCommon.h + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + StandaloneMmPkg/StandaloneMmPkg.dec + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + MemoryAllocationLib + MmServicesTableLib + PcdLib + ReportStatusCodeLib + StandaloneMmDriverEntryPoint + +[Guids] + # + # Signature in EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER + # + ## CONSUMES ## GUID + ## PRODUCES ## GUID + gEdkiiWorkingBlockSignatureGuid + +[Protocols] + gEfiSmmSwapAddressRangeProtocolGuid | gEfiMdeModulePkgTokenSpaceGuid.PcdFullFtwServiceEnable ## SOMETIMES_CONSUMES + ## NOTIFY + ## CONSUMES + gEfiSmmFirmwareVolumeBlockProtocolGuid + ## PRODUCES + ## UNDEFINED # SmiHandlerRegister + gEfiSmmFaultTolerantWriteProtocolGuid + gEfiMmEndOfDxeProtocolGuid ## CONSUMES + +[FeaturePcd] + gEfiMdeModulePkgTokenSpaceGuid.PcdFullFtwServiceEnable ## CONSUMES + +[Pcd] + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase ## SOMETIMES_CONSUMES + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase64 ## CONSUMES + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize ## CONSUMES + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase ## SOMETIMES_CONSUMES + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase64 ## CONSUMES + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize ## CONSUMES + +[Depex] + TRUE +