summaryrefslogtreecommitdiffstats
path: root/OvmfPkg/Library/QemuFwCfgLib
diff options
context:
space:
mode:
authorLaszlo Ersek <lersek@redhat.com>2017-08-28 11:48:00 +0200
committerLaszlo Ersek <lersek@redhat.com>2017-08-29 22:44:33 +0200
commitd431d8339e8b0e8cff634ae2567960706c028522 (patch)
tree774a50889d95cb4b3948949f9dcdf6b6d064b9aa /OvmfPkg/Library/QemuFwCfgLib
parentc1d799b915096b79b5c5d035b134ffbccc6d1469 (diff)
downloadedk2-d431d8339e8b0e8cff634ae2567960706c028522.tar.gz
edk2-d431d8339e8b0e8cff634ae2567960706c028522.tar.bz2
edk2-d431d8339e8b0e8cff634ae2567960706c028522.zip
OvmfPkg/QemuFwCfgDxeLib: SEV: zero FW_CFG_DMA_ACCESS before decrypting it
There's a small window between - AllocFwCfgDmaAccessBuffer() mapping the new FW_CFG_DMA_ACCESS object for common buffer operation (i.e., decrypting it), and - InternalQemuFwCfgDmaBytes() setting the fields of the object. In this window, earlier garbage in the object is "leaked" to the hypervisor. So zero the object before we decrypt it. (This commit message references AMD SEV directly, because QemuFwCfgDxeLib is not *generally* enabled for IOMMU operation just yet, unlike our goal for the virtio infrastructure. Instead, QemuFwCfgDxeLib uses MemEncryptSevLib explicitly to detect SEV, and then relies on IOMMU protocol behavior that is specific to SEV. At this point, this is by design.) Cc: Brijesh Singh <brijesh.singh@amd.com> Cc: Jordan Justen <jordan.l.justen@intel.com> Cc: Tom Lendacky <thomas.lendacky@amd.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Jordan Justen <jordan.l.justen@intel.com> Reviewed-by: Brijesh Singh <brijesh.singh@amd.com>
Diffstat (limited to 'OvmfPkg/Library/QemuFwCfgLib')
-rw-r--r--OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgDxe.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgDxe.c b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgDxe.c
index 8b98208591..22077851a4 100644
--- a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgDxe.c
+++ b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgDxe.c
@@ -20,6 +20,7 @@
#include <Protocol/IoMmu.h>
#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
#include <Library/IoLib.h>
#include <Library/DebugLib.h>
#include <Library/QemuFwCfgLib.h>
@@ -189,6 +190,12 @@ AllocFwCfgDmaAccessBuffer (
}
//
+ // Avoid exposing stale data even temporarily: zero the area before mapping
+ // it.
+ //
+ ZeroMem (HostAddress, Size);
+
+ //
// Map the host buffer with BusMasterCommonBuffer64
//
Status = mIoMmuProtocol->Map (