From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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-Google-Smtp-Source: AFSGD/VBCAg5Ue7qg0tsdL3QanBKTyUgrEvVBxRxfQEjcqMzAG48YHyez4De3IEfUusU/T142ObllQ== 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 Cc: Ard Biesheuvel , Laszlo Ersek , Leif Lindholm , Michael D Kinney , Liming Gao , Jian J Wang , Hao Wu , Jagadeesh Ujja , Achin Gupta , Thomas Panakamattam Abraham , Sami Mujawar 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: [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: , X-List-Received-Date: Thu, 03 Jan 2019 18:28:58 -0000 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(+) 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 + -- 2.17.1