qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH v3 3/3] hw/vfio: let read-only flag take effect for mmap'd re


From: Philippe Mathieu-Daudé
Subject: Re: [PATCH v3 3/3] hw/vfio: let read-only flag take effect for mmap'd regions
Date: Tue, 14 Apr 2020 11:37:58 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0

On 4/13/20 8:37 AM, Yan Zhao wrote:
along side setting host page table to be read-only, the memory regions
are also required to be read-only, so that when guest writes to the
read-only & mmap'd regions, vmexits would happen and region write handlers
are called.

Signed-off-by: Yan Zhao <address@hidden>
Signed-off-by: Xin Zeng <address@hidden>
---
  hw/vfio/common.c | 4 ++++
  1 file changed, 4 insertions(+)

diff --git a/hw/vfio/common.c b/hw/vfio/common.c
index fd6ee1fe3e..fc7618e041 100644
--- a/hw/vfio/common.c
+++ b/hw/vfio/common.c
@@ -977,6 +977,10 @@ int vfio_region_mmap(VFIORegion *region)
                                            name, region->mmaps[i].size,
                                            region->mmaps[i].mmap);
          g_free(name);
+
+        if (!(region->flags & VFIO_REGION_INFO_FLAG_WRITE)) {
+            memory_region_set_readonly(&region->mmaps[i].mem, true);
+        }
          memory_region_add_subregion(region->mem, region->mmaps[i].offset,
                                      &region->mmaps[i].mem);

Reviewed-by: Philippe Mathieu-Daudé <address@hidden>




reply via email to

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