qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH] nvdimm: ensure that dsm memory is read in nvdimm_ds


From: Artemis Tosini
Subject: [Qemu-devel] [PATCH] nvdimm: ensure that dsm memory is read in nvdimm_dsm_write
Date: Tue, 20 Mar 2018 07:35:18 -0400

This patch ensures that the client OS does not cause the host to read invalid 
memory from the NVDIMM DSM. It is not tested, since the Linux NVDIMM driver 
will not cause an invalid memory read.

This patch is for my outreachy assignment, and is my first open source patch.

>From bcb717b761ac62adeda145e895f92e4bde1003af Mon Sep 17 00:00:00 2001
From: Artemis Tosini <address@hidden>
Date: Sat, 10 Mar 2018 20:38:07 +0000
Subject: [PATCH] nvdimm: ensure that dsm memory is read in nvdimm_dsm_write

Signed-off-by: Artemis Tosini <address@hidden>
---
 hw/acpi/nvdimm.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/hw/acpi/nvdimm.c b/hw/acpi/nvdimm.c
index 59d6e4254c..67dda723a7 100644
--- a/hw/acpi/nvdimm.c
+++ b/hw/acpi/nvdimm.c
@@ -838,7 +838,12 @@ nvdimm_dsm_write(void *opaque, hwaddr addr, uint64_t val, 
unsigned size)
      * this by copying DSM memory to QEMU local memory.
      */
     in = g_new(NvdimmDsmIn, 1);
-    cpu_physical_memory_read(dsm_mem_addr, in, sizeof(*in));
+    if (address_space_read(&address_space_memory, dsm_mem_addr,
+                          MEMTXATTRS_UNSPECIFIED, in,
+                          sizeof(*in)) != MEMTX_OK) {
+                            nvdimm_debug("Failed to read DSM memory");
+                            goto exit;
+                          }
 
     le32_to_cpus(&in->revision);
     le32_to_cpus(&in->function);
-- 
2.16.2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]