qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: Yan Zhao <yan.y.zhao@intel.com>, qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, alex.williamson@redhat.com,
	Xin Zeng <xin.zeng@intel.com>,
	stefanha@redhat.com
Subject: Re: [PATCH v3 1/3] memory: drop guest writes to read-only ram device regions
Date: Tue, 14 Apr 2020 11:35:22 +0200	[thread overview]
Message-ID: <36cbf8f3-65e6-936f-6278-ab45dc470b02@redhat.com> (raw)
In-Reply-To: <20200413063713.84659-1-yan.y.zhao@intel.com>

On 4/13/20 8:37 AM, Yan Zhao wrote:
> 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) {

            qemu_log_mask(LOG_GUEST_ERROR, ...)?

> +        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)"
> 



  reply	other threads:[~2020-04-14  9:36 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 ` [PATCH v3 1/3] memory: drop guest writes to read-only ram device regions Yan Zhao
2020-04-14  9:35   ` Philippe Mathieu-Daudé [this message]
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=36cbf8f3-65e6-936f-6278-ab45dc470b02@redhat.com \
    --to=philmd@redhat.com \
    --cc=alex.williamson@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    --cc=xin.zeng@intel.com \
    --cc=yan.y.zhao@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).