From: Yan Zhao <yan.y.zhao@intel.com>
To: qemu-devel@nongnu.org
Cc: Yan Zhao <yan.y.zhao@intel.com>, Xin Zeng <xin.zeng@intel.com>,
alex.williamson@redhat.com, stefanha@redhat.com,
pbonzini@redhat.com, philmd@redhat.com
Subject: [PATCH v3 1/3] memory: drop guest writes to read-only ram device regions
Date: Mon, 13 Apr 2020 06:37:13 +0000 [thread overview]
Message-ID: <20200413063713.84659-1-yan.y.zhao@intel.com> (raw)
In-Reply-To: <20200413063627.84608-1-yan.y.zhao@intel.com>
for ram device regions, drop guest writes if the regions is read-only.
Signed-off-by: Yan Zhao <yan.y.zhao@intel.com>
Signed-off-by: Xin Zeng <xin.zeng@intel.com>
---
memory.c | 6 +++++-
trace-events | 2 +-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/memory.c b/memory.c
index 601b749906..a380b59980 100644
--- a/memory.c
+++ b/memory.c
@@ -1312,7 +1312,11 @@ 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);
+ trace_memory_region_ram_device_write(get_cpu_index(), mr, addr, data,
+ size, mr->readonly);
+ if (mr->readonly) {
+ return;
+ }
switch (size) {
case 1:
diff --git a/trace-events b/trace-events
index 42107ebc69..e1de662973 100644
--- a/trace-events
+++ b/trace-events
@@ -61,7 +61,7 @@ memory_region_ops_write(int cpu_index, void *mr, uint64_t addr, uint64_t value,
memory_region_subpage_read(int cpu_index, void *mr, uint64_t offset, uint64_t value, unsigned size) "cpu %d mr %p offset 0x%"PRIx64" value 0x%"PRIx64" size %u"
memory_region_subpage_write(int cpu_index, void *mr, uint64_t offset, uint64_t value, unsigned size) "cpu %d mr %p offset 0x%"PRIx64" value 0x%"PRIx64" size %u"
memory_region_ram_device_read(int cpu_index, void *mr, uint64_t addr, uint64_t value, unsigned size) "cpu %d mr %p addr 0x%"PRIx64" value 0x%"PRIx64" size %u"
-memory_region_ram_device_write(int cpu_index, void *mr, uint64_t addr, uint64_t value, unsigned size) "cpu %d mr %p addr 0x%"PRIx64" value 0x%"PRIx64" size %u"
+memory_region_ram_device_write(int cpu_index, void *mr, uint64_t addr, uint64_t value, unsigned size, bool readonly) "cpu %d mr %p addr 0x%"PRIx64" value 0x%"PRIx64" size %u" " is_readonly_region=%d"
flatview_new(void *view, void *root) "%p (root %p)"
flatview_destroy(void *view, void *root) "%p (root %p)"
flatview_destroy_rcu(void *view, void *root) "%p (root %p)"
--
2.17.1
next prev parent reply other threads:[~2020-04-13 6:39 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-13 6:36 [PATCH v3 0/3] drop writes to read-only ram device & vfio regions Yan Zhao
2020-04-13 6:37 ` Yan Zhao [this message]
2020-04-14 9:35 ` [PATCH v3 1/3] memory: drop guest writes to read-only ram device regions Philippe Mathieu-Daudé
2020-04-15 8:19 ` Yan Zhao
2020-04-13 6:37 ` [PATCH v3 2/3] hw/vfio: drop guest writes to ro regions Yan Zhao
2020-04-14 9:34 ` Philippe Mathieu-Daudé
2020-04-15 8:19 ` Yan Zhao
2020-04-13 6:37 ` [PATCH v3 3/3] hw/vfio: let read-only flag take effect for mmap'd regions Yan Zhao
2020-04-14 9:37 ` Philippe Mathieu-Daudé
2020-04-15 8:19 ` Yan Zhao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200413063713.84659-1-yan.y.zhao@intel.com \
--to=yan.y.zhao@intel.com \
--cc=alex.williamson@redhat.com \
--cc=pbonzini@redhat.com \
--cc=philmd@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
--cc=xin.zeng@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).