From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=209.85.128.51; helo=mail-wm1-f51.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (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 8A48B211D56B2 for ; Mon, 11 Mar 2019 08:37:21 -0700 (PDT) Received: by mail-wm1-f51.google.com with SMTP id x7so5017297wmj.0 for ; Mon, 11 Mar 2019 08:37: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 :mime-version:content-transfer-encoding; bh=hTTtggkQdTqeHpniDTz+4U37bmlhYJ6rY9dd/4ox9TM=; b=SwycuW9XP12QlnGrHb/GaSN0RHGVoATmkQx7et+kijRo0BbmJrdqiUVEB/kGCC5KnO 6jWjYkkCuHmKotjLmak6FzE0HGGelRH2kUL67tJq/7XJm8ZTpMa++8SummdCN76LNVeM QQfV7NND+OHfwU+IEtVIpK4Mf/ySAKE1K6fbJ/ToKTfP+b8TETwfRR7sw7SD+4c92bQN udExjO0aH7j2pmbw6yE66P+l6fkJG36IcXga2wgrd+jk9Qt+4EVxY76eIUHh4SFwuOFx nsKC6iG0tjt9wuhKhPk+5XRdI+fLjz+5nY2ZDlC1n5PtMadn1y3j5LL9waYbXz/nMCmY 1gMw== 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:mime-version:content-transfer-encoding; bh=hTTtggkQdTqeHpniDTz+4U37bmlhYJ6rY9dd/4ox9TM=; b=N8hq0+VgHU5SFO0unPirsXMZoHZwAgkGwQO92k2xCBxm29RcNVfT/K9V7eeAx5ZsyD 4R4tOxkkIhiEoSjW1gqnGycL6+VUZpW6Rp+rCV1vh9JyK7/u5XQYTCORGgrK25qJ5vz3 iPpiCbyk79QbL/3V1rrjWxJsiO1QbcQ4bb1tRVnkwggPeSZwsq+W0e4lLn6sim4yGUKN QHuYgYEIgx8NvrlS5qqsM6v/KqVnVEg+dxUvtEg1c74aKfvOheMhHZ51ypZA00b7Xaud tFCXF0ul/0NiID0Ll3M3+dNllPuD8PViURK0O6gahP7YwbPPLdqgIuK71YPfUp2Y+TxF jQvw== X-Gm-Message-State: APjAAAU+we1dxpUHsY7PrB3/t6UumqJlIFSLOjWseUjwGQ3fMrF/o/yY yuxwNNmH5lfrwnpYJyET2sPoUHg716Y= X-Google-Smtp-Source: APXvYqy8P6sh0tLs5/cIACkDlrTbx2mPfZYU9qOl8h6ZoIAr8RAyYk6sxJznpk6zoIkfhA0pA5ipBA== X-Received: by 2002:a1c:4e19:: with SMTP id g25mr222288wmh.106.1552318579649; Mon, 11 Mar 2019 08:36:19 -0700 (PDT) Received: from localhost.localdomain (laubervilliers-657-1-83-120.w92-154.abo.wanadoo.fr. [92.154.90.120]) by smtp.gmail.com with ESMTPSA id u13sm34938965wmf.3.2019.03.11.08.36.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Mar 2019 08:36:18 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org Cc: Ard Biesheuvel , Jian J Wang , Hao Wu , Star Zeng , Michael D Kinney , Liming Gao , Achin Gupta , Jiewen Yao , Supreeth Venkatesh , Jagadeesh Ujja Date: Mon, 11 Mar 2019 16:36:08 +0100 Message-Id: <20190311153608.3251-5-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190311153608.3251-1-ard.biesheuvel@linaro.org> References: <20190311153608.3251-1-ard.biesheuvel@linaro.org> MIME-Version: 1.0 Subject: [PATCH 4/4] MdeModulePkg/VariableSmmRuntimeDxe: switch to MmCommunicateLib library 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: Mon, 11 Mar 2019 15:37:21 -0000 Content-Transfer-Encoding: 8bit Replace direct calls to the EFI_SMM_COMMUNICATE protocol with calls to the MmCommunicateLib library, which abstracts differences between traditional MM and standalone MM. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- MdeModulePkg/MdeModulePkg.dsc | 1 + MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.inf | 4 ++-- MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c | 10 +++------- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/MdeModulePkg/MdeModulePkg.dsc b/MdeModulePkg/MdeModulePkg.dsc index 84c2629d5adc..e8bafaf5007b 100644 --- a/MdeModulePkg/MdeModulePkg.dsc +++ b/MdeModulePkg/MdeModulePkg.dsc @@ -140,6 +140,7 @@ [LibraryClasses.common.DXE_RUNTIME_DRIVER] DebugLib|MdePkg/Library/UefiDebugLibConOut/UefiDebugLibConOut.inf LockBoxLib|MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxDxeLib.inf CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf + MmCommunicateLib|MdeModulePkg/Library/RuntimeDxeMmCommunicateLib/RuntimeDxeMmCommunicateLib.inf [LibraryClasses.common.SMM_CORE] HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.inf b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.inf index bd73f7ac29f2..53ab1baa7974 100644 --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.inf +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.inf @@ -56,13 +56,13 @@ [LibraryClasses] DebugLib UefiRuntimeLib DxeServicesTableLib + MmCommunicateLib UefiDriverEntryPoint TpmMeasurementLib [Protocols] gEfiVariableWriteArchProtocolGuid ## PRODUCES gEfiVariableArchProtocolGuid ## PRODUCES - gEfiSmmCommunicationProtocolGuid ## CONSUMES ## CONSUMES ## NOTIFY ## UNDEFINED # Used to do smm communication @@ -88,7 +88,7 @@ [Guids] gEfiImageSecurityDatabaseGuid [Depex] - gEfiSmmCommunicationProtocolGuid + TRUE [UserExtensions.TianoCore."ExtraFiles"] VariableSmmRuntimeDxeExtra.uni diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c index 85d655dc19ff..e52913a1eb6f 100644 --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c @@ -34,6 +34,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include #include +#include #include #include #include @@ -49,7 +50,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. EFI_HANDLE mHandle = NULL; EFI_SMM_VARIABLE_PROTOCOL *mSmmVariable = NULL; EFI_EVENT mVirtualAddressChangeEvent = NULL; -EFI_SMM_COMMUNICATION_PROTOCOL *mSmmCommunication = NULL; UINT8 *mVariableBuffer = NULL; UINT8 *mVariableBufferPhysical = NULL; UINTN mVariableBufferSize; @@ -179,7 +179,7 @@ SendCommunicateBuffer ( SMM_VARIABLE_COMMUNICATE_HEADER *SmmVariableFunctionHeader; CommSize = DataSize + SMM_COMMUNICATE_HEADER_SIZE + SMM_VARIABLE_COMMUNICATE_HEADER_SIZE; - Status = mSmmCommunication->Communicate (mSmmCommunication, mVariableBufferPhysical, &CommSize); + Status = MmCommunicate (mVariableBufferPhysical, mVariableBuffer, &CommSize); ASSERT_EFI_ERROR (Status); SmmCommunicateHeader = (EFI_SMM_COMMUNICATE_HEADER *) mVariableBuffer; @@ -898,7 +898,6 @@ VariableAddressChangeEvent ( ) { EfiConvertPointer (0x0, (VOID **) &mVariableBuffer); - EfiConvertPointer (0x0, (VOID **) &mSmmCommunication); } /** @@ -954,7 +953,7 @@ GetVariablePayloadSize ( // // Send data to SMM. // - Status = mSmmCommunication->Communicate (mSmmCommunication, CommBuffer, &CommSize); + Status = MmCommunicate (CommBuffer, CommBuffer, &CommSize); ASSERT_EFI_ERROR (Status); Status = SmmVariableFunctionHeader->ReturnStatus; @@ -996,9 +995,6 @@ SmmVariableReady ( return; } - Status = gBS->LocateProtocol (&gEfiSmmCommunicationProtocolGuid, NULL, (VOID **) &mSmmCommunication); - ASSERT_EFI_ERROR (Status); - // // Allocate memory for variable communicate buffer. // -- 2.20.1