From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=217.140.101.70; helo=foss.arm.com; envelope-from=jagadeesh.ujja@arm.com; receiver=edk2-devel@lists.01.org Received: from foss.arm.com (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by ml01.01.org (Postfix) with ESMTP id 4C38B2117FD47 for ; Wed, 31 Oct 2018 04:10:11 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id F2E7F80D for ; Wed, 31 Oct 2018 04:10:10 -0700 (PDT) Received: from usa.arm.com (a75556-lin.blr.arm.com [10.162.2.34]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 339943F71D for ; Wed, 31 Oct 2018 04:10:09 -0700 (PDT) From: Jagadeesh Ujja To: edk2-devel@lists.01.org Date: Wed, 31 Oct 2018 16:39:42 +0530 Message-Id: <20181031110947.6305-5-jagadeesh.ujja@arm.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181031110947.6305-1-jagadeesh.ujja@arm.com> References: <20181031110947.6305-1-jagadeesh.ujja@arm.com> MIME-Version: 1.0 Subject: [RFC PATCH 4/9] MdeModulePkg/Variable/RuntimeDxe: adapt for usability with MM Standalone 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: Wed, 31 Oct 2018 11:10:11 -0000 X-List-Received-Date: Wed, 31 Oct 2018 11:10:11 -0000 X-List-Received-Date: Wed, 31 Oct 2018 11:10:11 -0000 X-List-Received-Date: Wed, 31 Oct 2018 11:10:11 -0000 X-List-Received-Date: Wed, 31 Oct 2018 11:10:11 -0000 X-List-Received-Date: Wed, 31 Oct 2018 11:10:11 -0000 X-List-Received-Date: Wed, 31 Oct 2018 11:10:11 -0000 X-List-Received-Date: Wed, 31 Oct 2018 11:10:11 -0000 X-List-Received-Date: Wed, 31 Oct 2018 11:10:11 -0000 X-List-Received-Date: Wed, 31 Oct 2018 11:10:11 -0000 X-List-Received-Date: Wed, 31 Oct 2018 11:10:11 -0000 X-List-Received-Date: Wed, 31 Oct 2018 11:10:11 -0000 X-List-Received-Date: Wed, 31 Oct 2018 11:10:11 -0000 X-List-Received-Date: Wed, 31 Oct 2018 11:10:11 -0000 X-List-Received-Date: Wed, 31 Oct 2018 11:10:11 -0000 X-List-Received-Date: Wed, 31 Oct 2018 11:10:11 -0000 X-List-Received-Date: Wed, 31 Oct 2018 11:10:11 -0000 X-List-Received-Date: Wed, 31 Oct 2018 11:10:11 -0000 X-List-Received-Date: Wed, 31 Oct 2018 11:10:11 -0000 X-List-Received-Date: Wed, 31 Oct 2018 11:10:11 -0000 X-List-Received-Date: Wed, 31 Oct 2018 11:10:11 -0000 X-List-Received-Date: Wed, 31 Oct 2018 11:10:11 -0000 X-List-Received-Date: Wed, 31 Oct 2018 11:10:11 -0000 X-List-Received-Date: Wed, 31 Oct 2018 11:10:11 -0000 X-List-Received-Date: Wed, 31 Oct 2018 11:10:11 -0000 X-List-Received-Date: Wed, 31 Oct 2018 11:10:11 -0000 X-List-Received-Date: Wed, 31 Oct 2018 11:10:11 -0000 X-List-Received-Date: Wed, 31 Oct 2018 11:10:11 -0000 X-List-Received-Date: Wed, 31 Oct 2018 11:10:11 -0000 X-List-Received-Date: Wed, 31 Oct 2018 11:10:11 -0000 X-List-Received-Date: Wed, 31 Oct 2018 11:10:11 -0000 X-List-Received-Date: Wed, 31 Oct 2018 11:10:11 -0000 X-List-Received-Date: Wed, 31 Oct 2018 11:10:11 -0000 X-List-Received-Date: Wed, 31 Oct 2018 11:10:11 -0000 X-List-Received-Date: Wed, 31 Oct 2018 11:10:11 -0000 X-List-Received-Date: Wed, 31 Oct 2018 11:10:11 -0000 X-List-Received-Date: Wed, 31 Oct 2018 11:10:11 -0000 Content-Transfer-Encoding: 8bit Adapt the VariableSmmRuntimeDxe driver to communicate with a VariableSmm driver that is implemented as a MM Standalone driver. Change-Id: I3975d021ac848f13206bc2c577a4f5fb0e29b941 Signed-off-by: Jagadeesh Ujja --- .../Variable/RuntimeDxe/VariableSmmRuntimeDxe.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c index 85d655d..63b9157 100644 --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c @@ -14,6 +14,8 @@ InitCommunicateBuffer() is really function to check the variable data size. Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved.
+Copyright (c) 2018, ARM Limited. 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 @@ -51,7 +53,13 @@ EFI_SMM_VARIABLE_PROTOCOL *mSmmVariable = NULL; EFI_EVENT mVirtualAddressChangeEvent = NULL; EFI_SMM_COMMUNICATION_PROTOCOL *mSmmCommunication = NULL; UINT8 *mVariableBuffer = NULL; +#ifndef MM_RUNTIME + + // + // mVariableBufferPhysical is not required as post UEFI boot the address will be of virtual address + // UINT8 *mVariableBufferPhysical = NULL; +#endif UINTN mVariableBufferSize; UINTN mVariableBufferPayloadSize; EFI_LOCK mVariableServicesLock; @@ -179,7 +187,11 @@ SendCommunicateBuffer ( SMM_VARIABLE_COMMUNICATE_HEADER *SmmVariableFunctionHeader; CommSize = DataSize + SMM_COMMUNICATE_HEADER_SIZE + SMM_VARIABLE_COMMUNICATE_HEADER_SIZE; +#ifdef MM_RUNTIME + Status = mSmmCommunication->Communicate (mSmmCommunication, mVariableBuffer, &CommSize); +#else Status = mSmmCommunication->Communicate (mSmmCommunication, mVariableBufferPhysical, &CommSize); +#endif ASSERT_EFI_ERROR (Status); SmmCommunicateHeader = (EFI_SMM_COMMUNICATE_HEADER *) mVariableBuffer; @@ -991,10 +1003,12 @@ SmmVariableReady ( { EFI_STATUS Status; +#ifndef MM_RUNTIME Status = gBS->LocateProtocol (&gEfiSmmVariableProtocolGuid, NULL, (VOID **)&mSmmVariable); if (EFI_ERROR (Status)) { return; } +#endif Status = gBS->LocateProtocol (&gEfiSmmCommunicationProtocolGuid, NULL, (VOID **) &mSmmCommunication); ASSERT_EFI_ERROR (Status); @@ -1007,12 +1021,12 @@ SmmVariableReady ( mVariableBufferSize = SMM_COMMUNICATE_HEADER_SIZE + SMM_VARIABLE_COMMUNICATE_HEADER_SIZE + mVariableBufferPayloadSize; mVariableBuffer = AllocateRuntimePool (mVariableBufferSize); ASSERT (mVariableBuffer != NULL); - +#ifndef MM_RUNTIME // // Save the buffer physical address used for SMM conmunication. // mVariableBufferPhysical = mVariableBuffer; - +#endif gRT->GetVariable = RuntimeServiceGetVariable; gRT->GetNextVariableName = RuntimeServiceGetNextVariableName; gRT->SetVariable = RuntimeServiceSetVariable; @@ -1068,6 +1082,7 @@ SmmVariableWriteReady ( ) { EFI_STATUS Status; +#ifndef MM_RUNTIME VOID *ProtocolOps; // @@ -1077,6 +1092,7 @@ SmmVariableWriteReady ( if (EFI_ERROR (Status)) { return; } +#endif // // Some Secure Boot Policy Var (SecureBoot, etc) updates following other -- 1.9.1