From patchwork Mon Mar 11 15:36:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 160043 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp12060471jad; Mon, 11 Mar 2019 08:37:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqy1SYa+lOyH4muWBVG89o1Pr6BEWljb6aeFy+HvhZbD1nGDiMsb92r58DpsPv9WpLwNF0ON X-Received: by 2002:a63:1c02:: with SMTP id c2mr30861729pgc.351.1552318639860; Mon, 11 Mar 2019 08:37:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552318639; cv=none; d=google.com; s=arc-20160816; b=xFrqwdQm2aghYvHxbKPK5AnvdPh9kKpH7scEluAiHN3tTY2KvHV96sPsOJG0GWi30k EYYKkneYFmhLBiob4MDe5FPTHKzY56tMnVIJTv8Vpy5IVl1Ok1E5KMN0XmkgZuXOBeND sHGDy5jC7eyaKIezenoB65I/lrOx4MfwTzEqHK07l/gDipvaEHVZ2gvWHMOhe2uzhsBv U4yT4Tlm2uCRnaNwngrMRHBkVovxf9A1YLF3QBw9h8A+AIiIsYW8umqaTBiMoOnZuE/Q Y9ul9ixWYYuFzKc8CCQtih9sGktoPlMoL8NlC3FN4lS8OYqz7iorJe/0TYXfznpUbKo6 6UTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=58L/H12Ghz/bjoL7mxrAkNqFyMSxr9vHIUSQCy7n4hc=; b=y7HjvdRRkmKFEU68lSGGyFWc+myc4nhjbbfn7hjytk1TphSK5eUAJp5G1xKeaS0qNi ZRaMcR2+he7HQ+RUSozA8t4JzIKcYmhbSrF9ECjMSoS8fmDUhbl9ysIk9NtmZWOHGbgh 0KayF/PyiS9NswYxpm3HAYm+X5HCK7lp9qmq44swCTpfPAF83xkTbeFH5VNKRUTkK5zV u0BPQcnnqXXJdUgZuybHjZAJHS8weHPZ5uFMFlJp79x5bSu6CFX3TSZlcPZ0x+SHV+F8 zsvG5Z5oD3+4hki9m7ZhW26TfEsqSc3y+ml87VehW9F2FevNfpIWsZMixgUO+O/5eUzI +lQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=rKpn4SBP; 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 q188si5859796pfc.159.2019.03.11.08.37.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Mar 2019 08:37:19 -0700 (PDT) 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=rKpn4SBP; 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 3B174211DB417; Mon, 11 Mar 2019 08:37:19 -0700 (PDT) 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=209.85.128.67; helo=mail-wm1-f67.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) (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 9A4DC211D07B2 for ; Mon, 11 Mar 2019 08:37:17 -0700 (PDT) Received: by mail-wm1-f67.google.com with SMTP id a188so4715536wmf.3 for ; Mon, 11 Mar 2019 08:37:17 -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=Y1ktGFqEb5Ow2e7B6qjBnx7JE3Qj89ugIXwznhY5gF0=; b=rKpn4SBPOCE0qMzUOLzjIvuXfC+9nU+bdJzpaqhJGY5416VIitr/Z9veoqbFbi8vAP wHy6ZeBiG5+F22mbp1aGAOSD2Gn/CNtB2HOuFcLUftK10KkjS2ikz1PqMhXP909BfFof 8ds1/ai92+mPqEUKh8E8Eb7zNcEIijZieQ5b/badHgdzl+rsP84KgRk7sTpatgsyUMFx ADM11RIa+TqLbJYZyU6A1BySiL7UPRjsCDs+xBdrs2srxF89ALeDLnjfgAzqnr2X9Xn+ RiSFE3BIUIl1To0afLZ9gLpcQD2QMjIsLfkBwO3CT7bhw4GBcnqeYLTB/jxLGTce6Bq3 8amg== 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=Y1ktGFqEb5Ow2e7B6qjBnx7JE3Qj89ugIXwznhY5gF0=; b=ZIYmQAAJjIk/xixSCvaK+1XiWgKSSCQKPQX0rKum4/GkFSAYm+vH+JrzdSS5VPNQnm HDYSz8LgPvtS2MWtv6ug/gh/tfGxrNgjGHaoorqWEjdD0/V7n/e9btAdDv1wBwz//Pbj GtbuXqB+RQcv/WM2UJG8UiEZhYABZxw914+elRwmql5sIr0RNGUinzFQQvTFKQfBkHoz j0T30fI5DZjvsKcow2TrHof3VlWGLEtNn0ilGexcKvJMsB5utSWQX+4IJiWPp/0Ihs+N ERr91OqzqKtOIiOX9Z9OvjRkBjiGY0VKwb/52a1LKWZoGW6xgxhenA0Vipgjcev+IvC9 hOtw== X-Gm-Message-State: APjAAAUQ0zxrJMsJ2uPfkRnwUNV2m4Sx6biNh8Sz0GUsHnugpcj2I1uK nLQwbfSRdFfnqlhWLe6VqfHObu0M47U= X-Received: by 2002:a1c:b709:: with SMTP id h9mr224999wmf.114.1552318575816; Mon, 11 Mar 2019 08:36:15 -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.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Mar 2019 08:36:14 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Mon, 11 Mar 2019 16:36:05 +0100 Message-Id: <20190311153608.3251-2-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: [edk2] [PATCH 1/4] MdeModulePkg: introduce MmCommunicationLib library class 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 , Jiewen Yao , Michael D Kinney , Star Zeng Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" In order to abstract away the difference between traditional and standalone MM implementations of the MM communicate protocol, which have different requirements when it comes to the way the address of the communication buffer is passed, introduce a library class that can encapsulate calls to the MM communicate protocols, and which takes both the physical and virtual adresses of the buffer. This way, it is left up to the library implementation to decide which address is passed. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- MdeModulePkg/MdeModulePkg.dec | 4 ++ MdeModulePkg/Include/Library/MmCommunicateLib.h | 50 ++++++++++++++++++++ 2 files changed, 54 insertions(+) -- 2.20.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec index a2130bc43991..0778bf01edca 100644 --- a/MdeModulePkg/MdeModulePkg.dec +++ b/MdeModulePkg/MdeModulePkg.dec @@ -182,6 +182,10 @@ [LibraryClasses] # DisplayUpdateProgressLib|Include/Library/DisplayUpdateProgressLib.h + ## @libraryclass Provides an abstraction for invoking the MM communicate protocol + # + MmCommunicateLib|Include/Library/MmCommunicateLib.h + [Guids] ## MdeModule package token space guid # Include/Guid/MdeModulePkgTokenSpace.h diff --git a/MdeModulePkg/Include/Library/MmCommunicateLib.h b/MdeModulePkg/Include/Library/MmCommunicateLib.h new file mode 100644 index 000000000000..b302e47f6f8f --- /dev/null +++ b/MdeModulePkg/Include/Library/MmCommunicateLib.h @@ -0,0 +1,50 @@ +/** @file + Abstraction library for calls to EFI_MM_COMMUNICATE_PROTOCOL::Communicate + + Copyright (c) 2019, 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. + +**/ + +#ifndef MM_COMMUNICATE_LIB_H__ +#define MM_COMMUNICATE_LIB_H__ + +/** + Invoke the MM communication protocol + + @param[in] PhysicalCommBuffer Physical address of the communication buffer. + @param[in] VirtualCommBuffer Virtual address of the 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(s) or CommSize + parameter, if not omitted, are in address range + that cannot be accessed by the MM environment. + +**/ +EFI_STATUS +EFIAPI +MmCommunicate ( + IN OUT VOID *PhysicalCommBuffer, + IN OUT VOID *VirtualCommBuffer, + IN OUT UINTN *CommSize OPTIONAL + ); + +#endif From patchwork Mon Mar 11 15:36:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 160044 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp12060994jad; Mon, 11 Mar 2019 08:37:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqwuLu/ew1NB9jcMHYklzz5bU+uh3hnT7puKk2FZQ0Ta1Ug1l8xyZjkhnwrb77HhQB8hXEMh X-Received: by 2002:a17:902:523:: with SMTP id 32mr6823231plf.249.1552318667981; Mon, 11 Mar 2019 08:37:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552318667; cv=none; d=google.com; s=arc-20160816; b=uKtD/qVwFcgFv7BnPhhnMTQJ1aKLqWQS7beJch2Mp5dtojgz525A70Mx9l09qau1p2 XrIN7OxtgPpql6hvAbB4uA4pxbxZKw75joTzii2OO45Af+TrQNWBx/M0RUJhD7yKyCg7 hQo56DI+09z4z1BArAeHQfTcEftB5f4dAYp0+4W0/DwfX1pHpHdjQQoQfA9gWzq/voCg JLuBC+ycsaGzJ16HWh1DVlDzesiW5Rq+NhgmrwyT9mYiz7jbaa5xl4RnUFlfsclUEqCv rHGy443pev9R3BcRXlimpBcSonVMv4OBIyW1YemSu6WKPbjlne5DqwUnpfPGiSP1rwN4 QUpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=wXjy+ph0K/txQYpDFDEINI0WA1ebFtEBK2Godbne0Xw=; b=kAGc3Yl4EzX7LdylA1dibkwgMOB5MwwnvPjBeHaHGqZmpuBPftm8l1Ul2x73yEgMv4 XA0Kf+S2wz897GxQfZw0Kfhfw5lmFzyaYsDYRadW6iSwi0XfhyhoVL4c4GZGW9LsnEss GSN/sVFGMEUHq9XPk+PUVMj2NU1tS1kVjOwsVwaX5g7A48k/ZaqSthwGZdTqGIuBPFn2 Dl+ln5s5pJ0lIlP6Dk1MVVrirtDbAhLcIjFN/xUtFP3hbTz3nkdBX5W8R5s6QVsEvewT 56e6eGmsqBgqPHBLN0KBYVFagag60xaeStuTlPjrWgHvtWxVXsqKWEMfp3+XFVxJp2tP XMGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=DZ9Sjbee; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 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. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id i13si1892795pgr.58.2019.03.11.08.37.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Mar 2019 08:37:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=DZ9Sjbee; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 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 67D35211DB41C; Mon, 11 Mar 2019 08:37:20 -0700 (PDT) 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=209.85.128.42; helo=mail-wm1-f42.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) (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 004F62194EB7C for ; Mon, 11 Mar 2019 08:37:18 -0700 (PDT) Received: by mail-wm1-f42.google.com with SMTP id g20so4708011wmh.5 for ; Mon, 11 Mar 2019 08:37:18 -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=U+fzMeF7VZjuRI2vh8g7zZNSKxP3oNphcE7jajRjzns=; b=DZ9SjbeeNGYFtO6Mj1NLxky5BSkOQDa++rDFqMN88QG90Y0Wwl4v4tIGNM1u0hFhqb R4x4+AwobqaKtpiVRCjZhsnnipUJO+yqQ/xZv0k8dSToMb7KP9fld+2T2RCVYbc7MgpL qYvZ/lsR4ICoOMlarivUCI3bkKOf11zy3RLCx0omvciFwmHnQmYhEw8raz3oDj97bW8B ba60ppAS+uayunDd+dWz2fx10lxx3/U02wk2b0d0tZ9JcTksJCGwSGEy2Y6kmK9EIn5J 6pPTCHyPYgb3KN+RcgjID1MO9DmJzxUqtXTA9OQuXnrrxU5nPwQlS0egvcYArZVAasxp 3pgA== 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=U+fzMeF7VZjuRI2vh8g7zZNSKxP3oNphcE7jajRjzns=; b=ZckhLSbUkO+sogzKx8eao4cUczfx95RBXTbND2U2odN7CiGNlezXb7ZrLRX6Dh7w+b qo4vLqIDIwCMBktMBVKHLCHqP0mRRlAyP/wgqKt6jbSMj4fddW9kscb2fekIFzOJ/BjO M/FHMduaztosqpVGk2j2p/QJjWndWoLpefVotU5FXVSni4nRljkfVl/GWo0uXRwMMHvv hUWM+3Wwp0AsvMDXYIbL9tfQFWoDM/gOpzomTuSda082sTqz3zoKo4nR3bJ6EkMPSnpH IRgF279QMpZZlGPuSt/tbkRXRX6RHlSjwvWMT8FK4saJq3iubIaNNQvILTkpwNhjcjvu v5/w== X-Gm-Message-State: APjAAAWxHIKits851w6rsTmUlE3vqhYt3z8Q8vQAGZBPaOvc8AnzX914 G9Xoiw7BnpvXi440vlxeavs3PD80ry8= X-Received: by 2002:a1c:20d3:: with SMTP id g202mr224782wmg.74.1552318577074; Mon, 11 Mar 2019 08:36:17 -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.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Mar 2019 08:36:16 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Mon, 11 Mar 2019 16:36:06 +0100 Message-Id: <20190311153608.3251-3-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: [edk2] [PATCH 2/4] MdeModulePkg: add implementation of MmCommunicateLib 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 , Jiewen Yao , Michael D Kinney , Star Zeng Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" Add an implementation of MmCommunicateLib based on traditional SMM. This version passes the physical address of the communication buffer into the MM communicate protocol method. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- MdeModulePkg/MdeModulePkg.dsc | 1 + MdeModulePkg/Library/RuntimeDxeMmCommunicateLib/RuntimeDxeMmCommunicateLib.inf | 51 +++++++++ MdeModulePkg/Library/RuntimeDxeMmCommunicateLib/RuntimeDxeMmCommunicateLib.c | 114 ++++++++++++++++++++ MdeModulePkg/Library/RuntimeDxeMmCommunicateLib/RuntimeDxeMmCommunicateLib.uni | 19 ++++ 4 files changed, 185 insertions(+) -- 2.20.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/MdeModulePkg/MdeModulePkg.dsc b/MdeModulePkg/MdeModulePkg.dsc index 6cd1727a0d61..84c2629d5adc 100644 --- a/MdeModulePkg/MdeModulePkg.dsc +++ b/MdeModulePkg/MdeModulePkg.dsc @@ -317,6 +317,7 @@ [Components] MdeModulePkg/Library/BaseBmpSupportLib/BaseBmpSupportLib.inf MdeModulePkg/Library/DisplayUpdateProgressLibGraphics/DisplayUpdateProgressLibGraphics.inf MdeModulePkg/Library/DisplayUpdateProgressLibText/DisplayUpdateProgressLibText.inf + MdeModulePkg/Library/RuntimeDxeMmCommunicateLib/RuntimeDxeMmCommunicateLib.inf MdeModulePkg/Universal/BdsDxe/BdsDxe.inf MdeModulePkg/Application/BootManagerMenuApp/BootManagerMenuApp.inf diff --git a/MdeModulePkg/Library/RuntimeDxeMmCommunicateLib/RuntimeDxeMmCommunicateLib.inf b/MdeModulePkg/Library/RuntimeDxeMmCommunicateLib/RuntimeDxeMmCommunicateLib.inf new file mode 100644 index 000000000000..93b924d5eefb --- /dev/null +++ b/MdeModulePkg/Library/RuntimeDxeMmCommunicateLib/RuntimeDxeMmCommunicateLib.inf @@ -0,0 +1,51 @@ +## @file +# Abstraction library for calls to EFI_MM_COMMUNICATE_PROTOCOL::Communicate +# +# Copyright (c) 2019, 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. +# +# +## + +[Defines] + INF_VERSION = 0x0001001B + BASE_NAME = RuntimeDxeMmCommunicateLib + MODULE_UNI_FILE = RuntimeDxeMmCommunicateLib.uni + FILE_GUID = cb3ee7d3-ea6f-494c-ac57-c5f4dc0ab3b9 + MODULE_TYPE = DXE_RUNTIME_DRIVER + VERSION_STRING = 1.0 + LIBRARY_CLASS = MmCommunicateLib|DXE_RUNTIME_DRIVER + CONSTRUCTOR = RuntimeDxeMmCommunicateLibConstructor + +# +# The following information is for reference only and not required by the build tools. +# +# VALID_ARCHITECTURES = ARM AARCH64 IA32 X64 EBC +# + +[Sources] + RuntimeDxeMmCommunicateLib.c + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + +[LibraryClasses] + DebugLib + UefiBootServicesTableLib + UefiRuntimeLib + +[Guids] + gEfiEventVirtualAddressChangeGuid ## CONSUMES ## Event + +[Protocols] + gEfiMmCommunicationProtocolGuid ## CONSUMES + +[Depex] + gEfiMmCommunicationProtocolGuid diff --git a/MdeModulePkg/Library/RuntimeDxeMmCommunicateLib/RuntimeDxeMmCommunicateLib.c b/MdeModulePkg/Library/RuntimeDxeMmCommunicateLib/RuntimeDxeMmCommunicateLib.c new file mode 100644 index 000000000000..b4ae5dd1fd9a --- /dev/null +++ b/MdeModulePkg/Library/RuntimeDxeMmCommunicateLib/RuntimeDxeMmCommunicateLib.c @@ -0,0 +1,114 @@ +/** @file + Abstraction library for calls to EFI_MM_COMMUNICATE_PROTOCOL::Communicate + + Copyright (c) 2019, 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 +#include + +#include + +STATIC EFI_MM_COMMUNICATION_PROTOCOL *mMmCommunication; +STATIC EFI_EVENT mVirtualAddressChangeEvent; + +/** + Invoke the MM communication protocol + + @param[in] PhysicalCommBuffer Physical address of the communication buffer. + @param[in] VirtualCommBuffer Virtual address of the 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(s) or CommSize + parameter, if not omitted, are in address range + that cannot be accessed by the MM environment. + +**/ +EFI_STATUS +EFIAPI +MmCommunicate ( + IN OUT VOID *PhysicalCommBuffer, + IN OUT VOID *VirtualCommBuffer, + IN OUT UINTN *CommSize OPTIONAL + ) +{ + ASSERT (EfiAtRuntime () || (PhysicalCommBuffer == VirtualCommBuffer)); + + return mMmCommunication->Communicate (mMmCommunication, PhysicalCommBuffer, + CommSize); +} + +/** + Notification function of EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE. + + @param[in] Event Event whose notification function is being invoked. + @param[in] Context Pointer to the notification function's context. + +**/ +STATIC +VOID +EFIAPI +VariableAddressChangeEvent ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + EfiConvertPointer (0x0, (VOID **)&mMmCommunication); +} + +/** + Library entry point + + @param[in] ImageHandle The firmware allocated handle for the EFI image. + @param[in] SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS Library successfully initialized. + +**/ +EFI_STATUS +EFIAPI +RuntimeDxeMmCommunicateLibConstructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + Status = gBS->LocateProtocol (&gEfiMmCommunicationProtocolGuid, NULL, + (VOID **)&mMmCommunication); + ASSERT_EFI_ERROR (Status); + + // + // Register the event to convert the pointer for runtime. + // + Status = gBS->CreateEventEx (EVT_NOTIFY_SIGNAL, TPL_NOTIFY, + VariableAddressChangeEvent, NULL, + &gEfiEventVirtualAddressChangeGuid, + &mVirtualAddressChangeEvent); + ASSERT_EFI_ERROR (Status); + + return EFI_SUCCESS; +} diff --git a/MdeModulePkg/Library/RuntimeDxeMmCommunicateLib/RuntimeDxeMmCommunicateLib.uni b/MdeModulePkg/Library/RuntimeDxeMmCommunicateLib/RuntimeDxeMmCommunicateLib.uni new file mode 100644 index 000000000000..1e3332a649b0 --- /dev/null +++ b/MdeModulePkg/Library/RuntimeDxeMmCommunicateLib/RuntimeDxeMmCommunicateLib.uni @@ -0,0 +1,19 @@ +///** @file +// Abstraction library for calls to EFI_MM_COMMUNICATE_PROTOCOL::Communicate +// +// Copyright (c) 2019, 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. +// +//**/ + + +#string STR_MODULE_ABSTRACT #language en-US "Abstraction library for calls to EFI_MM_COMMUNICATE_PROTOCOL::Communicate" + +#string STR_MODULE_DESCRIPTION #language en-US "Abstraction library for calls to EFI_MM_COMMUNICATE_PROTOCOL::Communicate." + From patchwork Mon Mar 11 15:36:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 160045 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp12061600jad; Mon, 11 Mar 2019 08:38:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqyrZiERp1uzPCskA3u5y0nW7UwsUI/gK2X845sCCAuLxsKTQGUrrLN0i64G7CX4ZxbSIyCe X-Received: by 2002:a63:720f:: with SMTP id n15mr29761310pgc.216.1552318701665; Mon, 11 Mar 2019 08:38:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552318701; cv=none; d=google.com; s=arc-20160816; b=bhnMpw/w02ei8Lyli1nui8nWsqGD1gpTig63raAvuacwuTxbQJ2cKyztObb8Nq1irI KIMG+b4NvyodYv+s3MehqELWxUH9oC1zPgBGkFumn3jEd8Mv5jzXu4RcsvOql92n9+qr c7IkEYjNWi/o+o2OjgiqT+w5dIXOoTkMhCohZgTClTFfwoOMoa55gi6ih0R87TIqfeHy IG9BcfXZihGeFg2zIJKyXl2CREoRK/sGmvpp53NY17Khe4n16Cu+lCwzL9deF01R6i7v vVZDUDIDaifXigOGIQ3RXQhmpEinNB6Br0fN1eUKawy+1myUsIkwjD7F9fIf+vY19MId TptA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=V4IqFXYBD6QrIF3PtLASFN+AExkCTDJCJMmRwBcACqQ=; b=RKnQyqsqPirShPg6gDPkiKK9S4XIQb3R4/IhcvprtjT6StYOgv4rQ7+IPCxIntpa9q Uju+wOMmBWHLeKK8fBIr0d7dRtSJv38vutH811du0kW2jPZCDzCE8ISCCQPlgyPtces+ ejYBG3kfxnIXVho3hL5MwLk6Y4L1JWgM5H/nJySxuPeXUPUk1CbZWKURt9Mxyz+kkOa/ YsV2EPgvXN59oM4QHtoBPHK0jhWZDrIJmMY9yb/ewoyHMQA/njLAt/6kLo3fzVHTG5j6 4ikdzmJl2NVyV73Sbxjybtr7y4dJv2qHav9ydIR4Yvhih5lGUubLPT9L9lIdE4zZEgy5 PFDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=b2xe9ViP; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 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. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id a2si5177342pga.476.2019.03.11.08.38.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Mar 2019 08:38:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=b2xe9ViP; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 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 9886A211DB41F; Mon, 11 Mar 2019 08:37:21 -0700 (PDT) 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=209.85.128.54; helo=mail-wm1-f54.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) (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 5E3FB211DB41A for ; Mon, 11 Mar 2019 08:37:20 -0700 (PDT) Received: by mail-wm1-f54.google.com with SMTP id f65so5011933wma.2 for ; Mon, 11 Mar 2019 08:37:20 -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=GBdWU2SPMEvlK802syGTeSqu+DDV8HRducYlzcGsKFo=; b=b2xe9ViPjF45Z+G5UCic3ukunNuRgnU0O324htzu7O43KWLnGY+vI9oFmi+r5If43I Dhy6tTerDmEJ4Pe/wu6uu1rI5aTELdPlOGMqREoCji9zdlSZ57y781mYbwA5VavEJVqW mXfIromYOABRFn3UPLIx1tQQpr7cveuMDa8AuNNBXHMfZxNqi2aQwDkls+YvDOikyGlj 5mT65L9QG6L2OuPG6U0fyso1JLKd+kDlYu6s9EdMFIur0AoFWr9EpMGloF5jbzLADLMf 4ehhhlaCZVay2ottZDHQPSR5e6lvdKoG4CnYy19leSW3oPginrhP1AzFY53+5cMIT0/J 132w== 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=GBdWU2SPMEvlK802syGTeSqu+DDV8HRducYlzcGsKFo=; b=maD2bJcMjf8shRndaMp3zRPqPXWmCS+xjBelWciypC+ivOPwePZUImo+M6eGBjcPOA ao+7ajcpVqmcZV/EYXDxnzTCvyYUFi6OnIcUFbRxIYEYpClfdH72eKUmVhtpZw6UiEy3 4cp2fC7Hh6ioP3gkSFl3urWtRC0eN9C28XRrL5LNwADJE90hcDOswc8Zj+AMrAC3P4Eu tB9606QyNpbtbxFsgdRp7/Fb7M34I/El9Tiy0dZJlxk+kAs7j8VvGjToX8eCGpBDCxkL liiC88Q9X/tFwnd9MPhajom25dI3B2rZB2uzgo5DSofsVZnrOwZ++/2VEaE9+GUfBPzR QDFQ== X-Gm-Message-State: APjAAAUbdo856nw+0FWUyduQMQVNwAr5fYLyu/mGEz/mvJkXqQasZzme rtq0Z+PW+aJrGUmDAyZt/tUfIzTA8Y0= X-Received: by 2002:a1c:230e:: with SMTP id j14mr210910wmj.9.1552318578407; Mon, 11 Mar 2019 08:36:18 -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.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Mar 2019 08:36:17 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Mon, 11 Mar 2019 16:36:07 +0100 Message-Id: <20190311153608.3251-4-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: [edk2] [PATCH 3/4] StandaloneMmPkg: add implementation of MmCommunicateLib 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 , Jiewen Yao , Michael D Kinney , Star Zeng Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" Add an implementation of MmCommunicateLib based on standalone MM. This version passes the virtual address of the communication buffer into the MM communicate protocol method. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- StandaloneMmPkg/Library/RuntimeDxeMmCommunicateLib/RuntimeDxeMmCommunicateLib.inf | 51 +++++++++ StandaloneMmPkg/Library/RuntimeDxeMmCommunicateLib/RuntimeDxeMmCommunicateLib.c | 113 ++++++++++++++++++++ StandaloneMmPkg/Library/RuntimeDxeMmCommunicateLib/RuntimeDxeMmCommunicateLib.uni | 19 ++++ 3 files changed, 183 insertions(+) -- 2.20.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/StandaloneMmPkg/Library/RuntimeDxeMmCommunicateLib/RuntimeDxeMmCommunicateLib.inf b/StandaloneMmPkg/Library/RuntimeDxeMmCommunicateLib/RuntimeDxeMmCommunicateLib.inf new file mode 100644 index 000000000000..c29a8618b3c2 --- /dev/null +++ b/StandaloneMmPkg/Library/RuntimeDxeMmCommunicateLib/RuntimeDxeMmCommunicateLib.inf @@ -0,0 +1,51 @@ +## @file +# Abstraction library for calls to EFI_MM_COMMUNICATE_PROTOCOL::Communicate +# +# Copyright (c) 2019, 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. +# +# +## + +[Defines] + INF_VERSION = 0x0001001B + BASE_NAME = RuntimeDxeMmCommunicateLib + MODULE_UNI_FILE = RuntimeDxeMmCommunicateLib.uni + FILE_GUID = 15cd7ca8-ca1a-43a2-8f9c-eabbd3e7e5b5 + MODULE_TYPE = DXE_RUNTIME_DRIVER + VERSION_STRING = 1.0 + LIBRARY_CLASS = MmCommunicateLib|DXE_RUNTIME_DRIVER + CONSTRUCTOR = RuntimeDxeMmCommunicateLibConstructor + +# +# The following information is for reference only and not required by the build tools. +# +# VALID_ARCHITECTURES = ARM AARCH64 IA32 X64 +# + +[Sources] + RuntimeDxeMmCommunicateLib.c + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + +[LibraryClasses] + DebugLib + UefiBootServicesTableLib + UefiRuntimeLib + +[Guids] + gEfiEventVirtualAddressChangeGuid ## CONSUMES ## Event + +[Protocols] + gEfiMmCommunicationProtocolGuid ## CONSUMES + +[Depex] + gEfiMmCommunicationProtocolGuid diff --git a/StandaloneMmPkg/Library/RuntimeDxeMmCommunicateLib/RuntimeDxeMmCommunicateLib.c b/StandaloneMmPkg/Library/RuntimeDxeMmCommunicateLib/RuntimeDxeMmCommunicateLib.c new file mode 100644 index 000000000000..b5a203865360 --- /dev/null +++ b/StandaloneMmPkg/Library/RuntimeDxeMmCommunicateLib/RuntimeDxeMmCommunicateLib.c @@ -0,0 +1,113 @@ +/** @file + Abstraction library for calls to EFI_MM_COMMUNICATE_PROTOCOL::Communicate + + Copyright (c) 2019, 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 +#include + +#include + +STATIC EFI_MM_COMMUNICATION_PROTOCOL *mMmCommunication; +STATIC EFI_EVENT mVirtualAddressChangeEvent; + +/** + Invoke the MM communication protocol + + @param[in] CommBuffer A pointer to the buffer to convey into MMRAM. + @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(s) or CommSize + parameter, if not omitted, are in address range + that cannot be accessed by the MM environment. + +**/ +EFI_STATUS +EFIAPI +MmCommunicate ( + IN OUT VOID *PhysicalCommBuffer, + IN OUT VOID *VirtualCommBuffer, + IN OUT UINTN *CommSize OPTIONAL + ) +{ + ASSERT (EfiAtRuntime () || (PhysicalCommBuffer == VirtualCommBuffer)); + + return mMmCommunication->Communicate (mMmCommunication, VirtualCommBuffer, + CommSize); +} + +/** + Notification function of EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE. + + @param[in] Event Event whose notification function is being invoked. + @param[in] Context Pointer to the notification function's context. + +**/ +STATIC +VOID +EFIAPI +VariableAddressChangeEvent ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + EfiConvertPointer (0x0, (VOID **)&mMmCommunication); +} + +/** + Library entry point + + @param[in] ImageHandle The firmware allocated handle for the EFI image. + @param[in] SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS Library successfully initialized. + +**/ +EFI_STATUS +EFIAPI +RuntimeDxeMmCommunicateLibConstructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + Status = gBS->LocateProtocol (&gEfiMmCommunicationProtocolGuid, NULL, + (VOID **)&mMmCommunication); + ASSERT_EFI_ERROR (Status); + + // + // Register the event to convert the pointer for runtime. + // + Status = gBS->CreateEventEx (EVT_NOTIFY_SIGNAL, TPL_NOTIFY, + VariableAddressChangeEvent, NULL, + &gEfiEventVirtualAddressChangeGuid, + &mVirtualAddressChangeEvent); + ASSERT_EFI_ERROR (Status); + + return EFI_SUCCESS; +} diff --git a/StandaloneMmPkg/Library/RuntimeDxeMmCommunicateLib/RuntimeDxeMmCommunicateLib.uni b/StandaloneMmPkg/Library/RuntimeDxeMmCommunicateLib/RuntimeDxeMmCommunicateLib.uni new file mode 100644 index 000000000000..1e3332a649b0 --- /dev/null +++ b/StandaloneMmPkg/Library/RuntimeDxeMmCommunicateLib/RuntimeDxeMmCommunicateLib.uni @@ -0,0 +1,19 @@ +///** @file +// Abstraction library for calls to EFI_MM_COMMUNICATE_PROTOCOL::Communicate +// +// Copyright (c) 2019, 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. +// +//**/ + + +#string STR_MODULE_ABSTRACT #language en-US "Abstraction library for calls to EFI_MM_COMMUNICATE_PROTOCOL::Communicate" + +#string STR_MODULE_DESCRIPTION #language en-US "Abstraction library for calls to EFI_MM_COMMUNICATE_PROTOCOL::Communicate." + From patchwork Mon Mar 11 15:36:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 160046 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp12062286jad; Mon, 11 Mar 2019 08:39:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqwop0eiIFaqAWIEMTrVb63NB3YpsHUxgqNVNIcqz/iHK7KbTowV7TJ/NRfXPu9sR1tepYbx X-Received: by 2002:a63:eb0f:: with SMTP id t15mr31034739pgh.252.1552318742982; Mon, 11 Mar 2019 08:39:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552318742; cv=none; d=google.com; s=arc-20160816; b=M2fLRWOF5qUAbw85qDdwhHhPuDiJmPNSo4huNeuWTszp4xKOUkctALdtGrI6IEBei5 N61eslrg5QTdDriFBBgtgGuQAQMDt968RaHHVr6eYgJTdX3UkjQf7tbaeSlxv62HWhwv aC68tCkinz+bHRvbP0iUaQGPeRm4fbuOD3iQkqSf5ardnyYM4NavQnN6vjSqezAq7vuq sWA9rR/F+OSxhR0Xa7rBL+CbBJB9lv55v3oWTYvIETffOgA0JNBWBB4YVRZmD12KpIOp IFAvzgg+4QgP/rzfMJxprEVxA4rTGKgLS6rbn2PBLymTpoZufthSy9H4l/BBXut/Y6eq QVdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=C71py2t7+a0PuC3gOMb4NnSUhvBVudhF6Mx0G37Ts1U=; b=qVpGC3cWrAAv/PmvMwprwB9oRTqTU7k6IlPBN/t4/AoDYv9lERvmN4FEgGoww10/3r 8pGMxjY/83rWsooPyqqqJA3IuU4Sfr+u2Dhr0b3wwOqfs1sRPnggQU1MLJ5LbHq1tPcR 2J7D9LolA6acEvaiSgaTONhtod26oYE0kdexhwhmu+OAx4TLMzQZjr8YAVcmi86EdAfD PiAryroDEzC6HzG45MZumo6YTpnFwvwSdNRmpGYyPFRjUi5G5qwuOqHbER+1Bo1URbxP rx9/HZy295fX7qjMdfjVgDDxhyocUbcglrRp6w2PXNujMtw1oCFWrMi94YhT5rg6SC1h 5CVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=SwycuW9X; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 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. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id o24si5447286pfa.34.2019.03.11.08.39.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Mar 2019 08:39:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=SwycuW9X; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 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 C75F1211DB416; Mon, 11 Mar 2019 08:37:22 -0700 (PDT) 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=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-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 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: [edk2] [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: , Cc: Hao Wu , Liming Gao , Jiewen Yao , Michael D Kinney , Star Zeng Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" 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(-) -- 2.20.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel 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. //