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.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-Google-Smtp-Source: APXvYqzC4hsF9HrwRFaima6X/XLh/budu1PN8dNzb4btkFt7x/cbrduFOLkPcnawEB1uhGarQwnCyA== 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 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:04 +0100 Message-Id: <20190311153608.3251-1-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Subject: [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: , X-List-Received-Date: Mon, 11 Mar 2019 15:37:16 -0000 Content-Transfer-Encoding: 8bit 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