qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 1/3] memory: drop guest writes to read-only ram device regions
@ 2020-04-17  7:44 Yan Zhao
  2020-04-17  8:48 ` Philippe Mathieu-Daudé
  2020-04-25 10:55 ` Paolo Bonzini
  0 siblings, 2 replies; 7+ messages in thread
From: Yan Zhao @ 2020-04-17  7:44 UTC (permalink / raw)
  To: pbonzini, alex.williamson; +Cc: Yan Zhao, xin.zeng, philmd, qemu-devel

for ram device regions, drop guest writes if the regions is read-only.

Cc: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Yan Zhao <yan.y.zhao@intel.com>
Signed-off-by: Xin Zeng <xin.zeng@intel.com>
---
 memory.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/memory.c b/memory.c
index 601b749906..9576dd6807 100644
--- a/memory.c
+++ b/memory.c
@@ -34,6 +34,7 @@
 #include "sysemu/accel.h"
 #include "hw/boards.h"
 #include "migration/vmstate.h"
+#include "qemu/log.h"
 
 //#define DEBUG_UNASSIGNED
 
@@ -1313,6 +1314,12 @@ static void memory_region_ram_device_write(void *opaque, hwaddr addr,
     MemoryRegion *mr = opaque;
 
     trace_memory_region_ram_device_write(get_cpu_index(), mr, addr, data, size);
+    if (mr->readonly) {
+        qemu_log_mask(LOG_GUEST_ERROR,
+                      "Invalid write to read only ram device region 0x%"
+                       HWADDR_PRIx" size %u\n", addr, size);
+        return;
+    }
 
     switch (size) {
     case 1:
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-04-27 10:21 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-04-17  7:44 [PATCH v4 1/3] memory: drop guest writes to read-only ram device regions Yan Zhao
2020-04-17  8:48 ` Philippe Mathieu-Daudé
2020-04-25 10:55 ` Paolo Bonzini
2020-04-26  1:04   ` Yan Zhao
2020-04-27  9:15     ` Yan Zhao
2020-04-27  9:31       ` Philippe Mathieu-Daudé
2020-04-27 10:09         ` Yan Zhao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).