From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) by mx.groups.io with SMTP id smtpd.web12.5695.1575648086733783657 for ; Fri, 06 Dec 2019 08:01:27 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@linaro.org header.s=google header.b=GXSrRo0L; spf=pass (domain: linaro.org, ip: 209.85.128.67, mailfrom: ard.biesheuvel@linaro.org) Received: by mail-wm1-f67.google.com with SMTP id f129so7868204wmf.2 for ; Fri, 06 Dec 2019 08:01:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Esa9LRAuHhcwt9n1LGCLOpHXSeX0jKP7rYnW41aJqLM=; b=GXSrRo0Ll1nTM6UPzduPohp+UlFB94L+ZecOHyk10f/Rsx6STOS2WlgBsgmxBu6JSn eXkYdyFBXjJcJK+sLmlRmFvvZs/v9/nt0yCVM3srOw8QoKc1cbOrI8D5HP/WGmzRnqIh 8DZQkbcnTZ1FOHg8qxZoydxE9udIgtEbAihxiRSaGcFOqkoQ6fhkJGokZvcnCpX8YlOh pvpcdrSsllTcQRT5D6Had6UV5OSDwKFTHuRsF0dSI6uV20DBUSRebJ5wBYobAhRnlNvB 3hRCpfZgO4DAg/tdo5+0INSa6VLckAwMYmN5vhL6q3DlsmOYcmYPPa7l5dehflVzAm3S Zpvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Esa9LRAuHhcwt9n1LGCLOpHXSeX0jKP7rYnW41aJqLM=; b=ocEI0aFXQN8XUaJU87t6qiVLXgJn3MQcfvv4Ic9bT2v2rIkGcW2SSM6m508quXTEQj cT8SU9HL9g7M/P1yPRs3r+d6rtz8B1jFWxNj2ghHZWrxD06yblvByYF8VoSVOX9BKmD/ qmbXnjCc7h3+G5YIXFg5ma2zjnLVHtwlF2qLuYn6RVORGIWHF7o0w1PBTq7/KWz6deQk X1vCMozu2kp9pcO/lfehtwa8T6VpzlTQNV6glwoHDAuwboBoFI84gBPT1eWxCF8nbcUx m2WeDweYxfItG2pW0iufIHwYHXAT8I1jjRegOvFlZgvd9kJcpXn+S08D7U94aSvXHlkj s7xw== X-Gm-Message-State: APjAAAU3sAgQ2lMLKhGdc3d34XadCYeejWwFap2HCbZSCr5Z8pZ6NfFb MysDrjpdC2MkbWO9mBC0l2EC2rr/JKDL4ZAqHNCbWA== X-Google-Smtp-Source: APXvYqyz/1dZQd8X9EIv1EvpeFPu+ChBYHnYz3220gNfN50/VicxJcCrazr9DC0TaZ6kWS0JhyUC73Es1L6RP5Ba6u0= X-Received: by 2002:a1c:a591:: with SMTP id o139mr9186069wme.95.1575648085139; Fri, 06 Dec 2019 08:01:25 -0800 (PST) MIME-Version: 1.0 References: <20191206152946.624-1-ard.biesheuvel@arm.com> <20191206152946.624-3-ard.biesheuvel@arm.com> In-Reply-To: <20191206152946.624-3-ard.biesheuvel@arm.com> From: "Ard Biesheuvel" Date: Fri, 6 Dec 2019 16:01:21 +0000 Message-ID: Subject: Re: [PATCH 2/7] MdeModulePkg/SmmIpl: expose MM communicate 2 protocol To: Ard Biesheuvel Cc: edk2-devel-groups-io , Michael D Kinney , Leif Lindholm , Liming Gao , Hao A Wu , Eric Dong , Ray Ni , Achin Gupta , Jiewen Yao Content-Type: text/plain; charset="UTF-8" On Fri, 6 Dec 2019 at 15:29, Ard Biesheuvel wrote: > > From: Ard Biesheuvel > > The MM communicate 2 protocol was introduced to factor out the mismatch > between traditional MM, which requires the physical address of the MM > buffer to be passed, and standalone MM, which copies the MM communicate > buffer data into a separate buffer, requiring the virtual address. For > this reason, MM communicate 2 carries both addresses, allowing the > implementation to decide which address it needs. > > This hides this implementation detail from the callers of the protocol, > which simply passes both addresses without having to reason about what the > implementation of the protocol actually needs. > > Note that the old version of the protocol is retained, in order to support > existing implementations that don't require this flexibility. > > Signed-off-by: Ard Biesheuvel > --- > MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c | 79 ++++++++++++++++++++ > MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf | 1 + > 2 files changed, 80 insertions(+) > The following hunk needs to be added to this patch, but it got lost somehow. Apologies. --- a/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c +++ b/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c @@ -1837,6 +1837,7 @@ SmmIplEntry ( &mSmmIplHandle, &gEfiSmmBase2ProtocolGuid, &mSmmBase2, &gEfiSmmCommunicationProtocolGuid, &mSmmCommunication, + &gEfiMmCommunication2ProtocolGuid, &mMmCommunication2, NULL ); ASSERT_EFI_ERROR (Status); > diff --git a/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c b/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c > index 1cf8c93227a3..d86b8b4a6a29 100644 > --- a/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c > +++ b/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c > @@ -10,6 +10,7 @@ > > #include > #include > +#include > #include > #include > #include > @@ -118,6 +119,39 @@ SmmCommunicationCommunicate ( > IN OUT UINTN *CommSize OPTIONAL > ); > > +/** > + Communicates with a registered handler. > + > + This function provides a service to send and receive messages from a registered UEFI service. > + > + @param[in] This The EFI_MM_COMMUNICATION_PROTOCOL instance. > + @param[in] CommBufferPhysical Physical address of the MM communication buffer > + @param[in] CommBufferVirtual Virtual address of the MM communication buffer > + @param[in] CommSize The size of the data buffer being passed in. On exit, the size of data > + being returned. Zero if the handler does not wish to reply with any data. > + This parameter is optional and may be NULL. > + > + @retval EFI_SUCCESS The message was successfully posted. > + @retval EFI_INVALID_PARAMETER The CommBuffer was NULL. > + @retval EFI_BAD_BUFFER_SIZE The buffer is too large for the MM implementation. > + If this error is returned, the MessageLength field > + in the CommBuffer header or the integer pointed by > + CommSize, are updated to reflect the maximum payload > + size the implementation can accommodate. > + @retval EFI_ACCESS_DENIED The CommunicateBuffer parameter or CommSize parameter, > + if not omitted, are in address range that cannot be > + accessed by the MM environment. > + > +**/ > +EFI_STATUS > +EFIAPI > +SmmCommunicationMmCommunicate2 ( > + IN CONST EFI_MM_COMMUNICATION2_PROTOCOL *This, > + IN OUT VOID *CommBufferPhysical, > + IN OUT VOID *CommBufferVirtual, > + IN OUT UINTN *CommSize OPTIONAL > + ); > + > /** > Event notification that is fired every time a gEfiSmmConfigurationProtocol installs. > > @@ -240,6 +274,13 @@ EFI_SMM_COMMUNICATION_PROTOCOL mSmmCommunication = { > SmmCommunicationCommunicate > }; > > +// > +// PI 1.7 MM Communication Protocol 2 instance > +// > +EFI_MM_COMMUNICATION2_PROTOCOL mMmCommunication2 = { > + SmmCommunicationMmCommunicate2 > +}; > + > // > // SMM Core Private Data structure that contains the data shared between > // the SMM IPL and the SMM Core. > @@ -576,6 +617,44 @@ SmmCommunicationCommunicate ( > return (Status == EFI_SUCCESS) ? EFI_SUCCESS : EFI_NOT_FOUND; > } > > +/** > + Communicates with a registered handler. > + > + This function provides a service to send and receive messages from a registered UEFI service. > + > + @param[in] This The EFI_MM_COMMUNICATION_PROTOCOL instance. > + @param[in] CommBufferPhysical Physical address of the MM communication buffer > + @param[in] CommBufferVirtual Virtual address of the MM communication buffer > + @param[in] CommSize The size of the data buffer being passed in. On exit, the size of data > + being returned. Zero if the handler does not wish to reply with any data. > + This parameter is optional and may be NULL. > + > + @retval EFI_SUCCESS The message was successfully posted. > + @retval EFI_INVALID_PARAMETER The CommBuffer was NULL. > + @retval EFI_BAD_BUFFER_SIZE The buffer is too large for the MM implementation. > + If this error is returned, the MessageLength field > + in the CommBuffer header or the integer pointed by > + CommSize, are updated to reflect the maximum payload > + size the implementation can accommodate. > + @retval EFI_ACCESS_DENIED The CommunicateBuffer parameter or CommSize parameter, > + if not omitted, are in address range that cannot be > + accessed by the MM environment. > + > +**/ > +EFI_STATUS > +EFIAPI > +SmmCommunicationMmCommunicate2 ( > + IN CONST EFI_MM_COMMUNICATION2_PROTOCOL *This, > + IN OUT VOID *CommBufferPhysical, > + IN OUT VOID *CommBufferVirtual, > + IN OUT UINTN *CommSize OPTIONAL > + ) > +{ > + return SmmCommunicationCommunicate (&mSmmCommunication, > + CommBufferPhysical, > + CommSize); > +} > + > /** > Event notification that is fired when GUIDed Event Group is signaled. > > diff --git a/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf b/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf > index b6b1bbcdac51..0a05d593522e 100644 > --- a/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf > +++ b/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf > @@ -50,6 +50,7 @@ [LibraryClasses] > [Protocols] > gEfiSmmBase2ProtocolGuid ## PRODUCES > gEfiSmmCommunicationProtocolGuid ## PRODUCES > + gEfiMmCommunication2ProtocolGuid ## PRODUCES > gEfiSmmAccess2ProtocolGuid ## CONSUMES > ## NOTIFY > ## CONSUMES > -- > 2.17.1 >