From patchwork Mon Mar 11 15:36:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 160042 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp12060454jad; Mon, 11 Mar 2019 08:37:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqzVmB72OtPcQNgDngK7xHyrkRKQSRwrRDcFzxvdhqnVa337B0Jqk+ShThlmKtKzyU+v2PGq X-Received: by 2002:a17:902:28e6:: with SMTP id f93mr35057014plb.264.1552318638514; Mon, 11 Mar 2019 08:37:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552318638; cv=none; d=google.com; s=arc-20160816; b=kkZIZfdrV8gbI4kSAZJVpf56sDTj4LRes1tKlVqfmgRtVx5HjZGGhQXYEUBsPjZu8a EC/eLAITDbx93361WhbHRJYL68enZDueptMDmDQ9P5MDp9TOu3PbFdobtLFtVpOdcP9L 8oyFOW085z+iKIumpahYH6s4svzkYHyZ41rQ3Z/yZ7WF5yDHWgXAVnPWgDA0n8w9MKNy iDsW4EQfCoC3tMl+/twscLTvUs6iMoHV1agNnkt4G4+PwHDWxHsbHGQ9hb9OPRJR8TgH 7H32DnHfWOgk2n3ZfOFukoSovUDhizJ5gHD/IocIZRkHsyUp0xOoxoYXwiANX0Jrta+F psBg== 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:message-id:date:to:from :dkim-signature:delivered-to; bh=+r05GCtOLLbeI5kkVi+q7m9nw7v7rfUAewHbD7sqE0Q=; b=iC1hPlL2Ze/vSsj/V9vCMk00/RBX+wSdx6aL0oJVPriQsUfC0oTyJuHrQcDSn3rZV7 iFEm8xzQrQExrMW1ie+CCq6SsdaAVcWUKPStoi+JkJqmYdYDK7t4MxAFuDgI50QAGHvm jOGs2dJxQNvbsQlxsCGV/RJXHIET+40E2lbTb3JVqrrcs6+eFldpbRVSTG+pyuvS5BhS /rY0Wj0Yyp291rNPV09ZwsseZlGlu6Tfh7wcYXQw2LF4hLD4M9mFTXuIEw6PVdnBp9fu vREBMbDCrvr3JJkjfs3eRuBvXJBZ9WLnKnTKdH8PSxrPKej/RwXPY00O9vd30f82iSY5 7eEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Arh5O6yX; 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 z78si5379751pfi.51.2019.03.11.08.37.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Mar 2019 08:37:18 -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=Arh5O6yX; 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 078F9211D675B; Mon, 11 Mar 2019 08:37:17 -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.68; helo=mail-wm1-f68.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm1-f68.google.com (mail-wm1-f68.google.com [209.85.128.68]) (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 6C63A2194EB7C for ; Mon, 11 Mar 2019 08:37:16 -0700 (PDT) Received: by mail-wm1-f68.google.com with SMTP id g20so4707851wmh.5 for ; Mon, 11 Mar 2019 08:37:16 -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:mime-version :content-transfer-encoding; bh=Ztzeub83R61kQ4A7iE4XGMaxNOo1KkAXHdYedQrt7Z8=; b=Arh5O6yXFJFjxAgucO9iYvbqOEaryOjyw7ickmNGYyjYkbidDVIU6MGsIaA49Xx8fr xdVc8/eEJoCdDcMRpODfUT8aGVROSRaOXboj14EHlt+UL8C7UNbiUbd9DL77Et6V8/1V i+rW20Y9H2pO++KbB2Mq51tFEFjxVKYQXpXI4GD5Q3u1bYctb8PZWX9kx3cLA01alrNr vdrIwgl2BcnpuMMgvadBY2yrx45xb4cAhg0d3IPy2IyIod6njWUSxR3rV8pEHLPC/W+y SkWwoMjJdStXhSopmRWavt6gzYGUVKr0rb+e4rEuu1HOx2n8nPIJJznJ9wbTAYIf+WkN 6SWw== 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:mime-version :content-transfer-encoding; bh=Ztzeub83R61kQ4A7iE4XGMaxNOo1KkAXHdYedQrt7Z8=; b=cbcIZieBI9NYvDftgmRDEgCooL8zmjzKkNKQg2T4oTppENrCS4uU22c8Z0feF/8lGy T4joUZJ/phulrXMUVrvaJ1A5M5ziNuaNW7VJpQIRitdBBQc3orcIM5yjCEvJxZchgMNs KVQhzZ+mY1qT+1hvj6rfn7swLuvyGS1ZZI5j0PvWv3fG1QWrySLgz/F6CRjfAqY8A+CY ewjmwWHenxk5JXb6K1+F54CvOYeSm9kkFNeSTEttmNcu5trsomX7Optfgb07rlTqU/d0 hk0Vy3bmuxbu5OaJtkJv/tXI89eeHpKrzPGB2ideGNP83GzoRkC9gW1uDgMxJjWxQnMz Bgvg== X-Gm-Message-State: APjAAAVzJbAFX2KwaQc4AdcMezlqRjvbFKOu1j01CrhcwhCiPKaL5M+z zbgsBURH/CwOszOW8x2euh0GG98sHrE= X-Received: by 2002:a1c:3d84:: with SMTP id k126mr214976wma.60.1552318574480; Mon, 11 Mar 2019 08:36:14 -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.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Mar 2019 08:36:13 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Mon, 11 Mar 2019 16:36:04 +0100 Message-Id: <20190311153608.3251-1-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Subject: [edk2] [PATCH 0/4] MdeModulePkg, StandaloneMmPkg: work around VA vs PA ambiguity 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" This series proposes one possible approach to work around the issue that the traditional MM and standalone MM implement versions of the communicate protocol that are fundamentally incompatible from the point of view of the caller. In traditional MM, the MM communicate protocol takes a physical pointer for the buffer, so that the SMM execution context can access the memory directly without having to translate it according to the translation regime of the caller. In standalone MM, the buffer that is shared with the MM context is preallocated, and so it is up to the implementation of the MM communicate protocol to copy the data from the caller allocated buffer into the preallocated shared buffer. In order to be able to do so, the DXE driver needs to copy the contents, and for this it needs to know the virtual address not the physical address. So this means we have two incompatible versions of the same protocol, and given that we have even re-used the EFI_SMM_COMMUNICATE_PROTOCOL GUID for the new EFI_MM_COMMUNICATE_PROTOCOL, we cannot distinguish programmatically between a MM context that takes physical addresses vs one that takes virtual ones. Since this is known at build time, one way to deal with this is to have two different implementations of a library that defines an abstract MmCommunicate() function, allowing the correct implementation to be selected at integration time. Cc: Jian J Wang Cc: Hao Wu Cc: Star Zeng Cc: Michael D Kinney Cc: Liming Gao Cc: Achin Gupta Cc: Jiewen Yao Cc: Supreeth Venkatesh Cc: Jagadeesh Ujja Ard Biesheuvel (4): MdeModulePkg: introduce MmCommunicationLib library class MdeModulePkg: add implementation of MmCommunicateLib StandaloneMmPkg: add implementation of MmCommunicateLib MdeModulePkg/VariableSmmRuntimeDxe: switch to MmCommunicateLib library MdeModulePkg/MdeModulePkg.dec | 4 + MdeModulePkg/MdeModulePkg.dsc | 2 + MdeModulePkg/Library/RuntimeDxeMmCommunicateLib/RuntimeDxeMmCommunicateLib.inf | 51 +++++++++ MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.inf | 4 +- StandaloneMmPkg/Library/RuntimeDxeMmCommunicateLib/RuntimeDxeMmCommunicateLib.inf | 51 +++++++++ MdeModulePkg/Include/Library/MmCommunicateLib.h | 50 +++++++++ MdeModulePkg/Library/RuntimeDxeMmCommunicateLib/RuntimeDxeMmCommunicateLib.c | 114 ++++++++++++++++++++ MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c | 10 +- StandaloneMmPkg/Library/RuntimeDxeMmCommunicateLib/RuntimeDxeMmCommunicateLib.c | 113 +++++++++++++++++++ MdeModulePkg/Library/RuntimeDxeMmCommunicateLib/RuntimeDxeMmCommunicateLib.uni | 19 ++++ StandaloneMmPkg/Library/RuntimeDxeMmCommunicateLib/RuntimeDxeMmCommunicateLib.uni | 19 ++++ 11 files changed, 428 insertions(+), 9 deletions(-) create mode 100644 MdeModulePkg/Library/RuntimeDxeMmCommunicateLib/RuntimeDxeMmCommunicateLib.inf create mode 100644 StandaloneMmPkg/Library/RuntimeDxeMmCommunicateLib/RuntimeDxeMmCommunicateLib.inf create mode 100644 MdeModulePkg/Include/Library/MmCommunicateLib.h create mode 100644 MdeModulePkg/Library/RuntimeDxeMmCommunicateLib/RuntimeDxeMmCommunicateLib.c create mode 100644 StandaloneMmPkg/Library/RuntimeDxeMmCommunicateLib/RuntimeDxeMmCommunicateLib.c create mode 100644 MdeModulePkg/Library/RuntimeDxeMmCommunicateLib/RuntimeDxeMmCommunicateLib.uni create mode 100644 StandaloneMmPkg/Library/RuntimeDxeMmCommunicateLib/RuntimeDxeMmCommunicateLib.uni -- 2.20.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel