All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 0/2] Introduce wrapper functions to access phys_ram_dirty, and replace existing direct accesses to it.
@ 2010-03-23  7:39 Yoshiaki Tamura
  2010-03-23  7:39 ` [Qemu-devel] [PATCH 1/2] Introduce wrapper functions to access phys_ram_dirty Yoshiaki Tamura
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Yoshiaki Tamura @ 2010-03-23  7:39 UTC (permalink / raw)
  To: qemu-devel; +Cc: ohmura.kei, mtosatti, avi


Before replacing byte-based dirty bitmap with bit-based dirty bitmap,
clearing direct accesses to the bitmap first seems to be good point to
start with.

This patch set is based on the following discussion.

http://www.mail-archive.com/kvm@vger.kernel.org/msg30724.html

Also rebased to qemu.git aa28b9bf9ba0904766b15e7ab8d62a76cb3225da.

Thanks,

Yoshi

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

* [Qemu-devel] [PATCH 1/2] Introduce wrapper functions to access phys_ram_dirty.
  2010-03-23  7:39 [Qemu-devel] [PATCH 0/2] Introduce wrapper functions to access phys_ram_dirty, and replace existing direct accesses to it Yoshiaki Tamura
@ 2010-03-23  7:39 ` Yoshiaki Tamura
  2010-03-23  7:39 ` [Qemu-devel] [PATCH 2/2] Replace direct phys_ram_dirty access with wrapper functions Yoshiaki Tamura
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Yoshiaki Tamura @ 2010-03-23  7:39 UTC (permalink / raw)
  To: qemu-devel; +Cc: ohmura.kei, mtosatti, avi, Yoshiaki Tamura

Adds wrapper functions to prevent direct access to the phys_ram_dirty bitmap.

Signed-off-by: Yoshiaki Tamura <tamura.yoshiaki@lab.ntt.co.jp>
Signed-off-by: OHMURA Kei <ohmura.kei@lab.ntt.co.jp>
---
 cpu-all.h |   25 +++++++++++++++++++++++++
 1 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/cpu-all.h b/cpu-all.h
index 897cd44..54d8449 100644
--- a/cpu-all.h
+++ b/cpu-all.h
@@ -893,6 +893,11 @@ static inline int cpu_physical_memory_is_dirty(ram_addr_t addr)
     return phys_ram_dirty[addr >> TARGET_PAGE_BITS] == 0xff;
 }
 
+static inline int cpu_physical_memory_get_dirty_flags(ram_addr_t addr)
+{
+    return phys_ram_dirty[addr >> TARGET_PAGE_BITS];
+}
+
 static inline int cpu_physical_memory_get_dirty(ram_addr_t addr,
                                                 int dirty_flags)
 {
@@ -904,6 +909,26 @@ static inline void cpu_physical_memory_set_dirty(ram_addr_t addr)
     phys_ram_dirty[addr >> TARGET_PAGE_BITS] = 0xff;
 }
 
+static inline int cpu_physical_memory_set_dirty_flags(ram_addr_t addr,
+                                                      int dirty_flags)
+{
+    return phys_ram_dirty[addr >> TARGET_PAGE_BITS] |= dirty_flags;
+}
+
+static inline void cpu_physical_memory_mask_dirty_range(ram_addr_t start,
+                                                        int length,
+                                                        int dirty_flags)
+{
+    int i, mask, len;
+    uint8_t *p;
+
+    len = length >> TARGET_PAGE_BITS;
+    mask = ~dirty_flags;
+    p = phys_ram_dirty + (start >> TARGET_PAGE_BITS);
+    for (i = 0; i < len; i++)
+        p[i] &= mask;
+}
+
 void cpu_physical_memory_reset_dirty(ram_addr_t start, ram_addr_t end,
                                      int dirty_flags);
 void cpu_tlb_update_dirty(CPUState *env);
-- 
1.7.0.31.g1df487

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

* [Qemu-devel] [PATCH 2/2] Replace direct phys_ram_dirty access with wrapper functions.
  2010-03-23  7:39 [Qemu-devel] [PATCH 0/2] Introduce wrapper functions to access phys_ram_dirty, and replace existing direct accesses to it Yoshiaki Tamura
  2010-03-23  7:39 ` [Qemu-devel] [PATCH 1/2] Introduce wrapper functions to access phys_ram_dirty Yoshiaki Tamura
@ 2010-03-23  7:39 ` Yoshiaki Tamura
  2010-03-23  9:00 ` [Qemu-devel] Re: [PATCH 0/2] Introduce wrapper functions to access phys_ram_dirty, and replace existing direct accesses to it Avi Kivity
  2010-04-08  9:59 ` [Qemu-devel] " Aurelien Jarno
  3 siblings, 0 replies; 6+ messages in thread
From: Yoshiaki Tamura @ 2010-03-23  7:39 UTC (permalink / raw)
  To: qemu-devel; +Cc: ohmura.kei, mtosatti, avi, Yoshiaki Tamura

Replaces direct phys_ram_dirty access with wrapper functions to prevent
direct access to the phys_ram_dirty bitmap.

Signed-off-by: Yoshiaki Tamura <tamura.yoshiaki@lab.ntt.co.jp>
Signed-off-by: OHMURA Kei <ohmura.kei@lab.ntt.co.jp>
---
 exec.c |   45 ++++++++++++++++++++-------------------------
 1 files changed, 20 insertions(+), 25 deletions(-)

diff --git a/exec.c b/exec.c
index 14767b7..a70df31 100644
--- a/exec.c
+++ b/exec.c
@@ -1979,7 +1979,7 @@ static void tlb_protect_code(ram_addr_t ram_addr)
 static void tlb_unprotect_code_phys(CPUState *env, ram_addr_t ram_addr,
                                     target_ulong vaddr)
 {
-    phys_ram_dirty[ram_addr >> TARGET_PAGE_BITS] |= CODE_DIRTY_FLAG;
+    cpu_physical_memory_set_dirty_flags(ram_addr, CODE_DIRTY_FLAG);
 }
 
 static inline void tlb_reset_dirty_range(CPUTLBEntry *tlb_entry,
@@ -2000,8 +2000,7 @@ void cpu_physical_memory_reset_dirty(ram_addr_t start, ram_addr_t end,
 {
     CPUState *env;
     unsigned long length, start1;
-    int i, mask, len;
-    uint8_t *p;
+    int i;
 
     start &= TARGET_PAGE_MASK;
     end = TARGET_PAGE_ALIGN(end);
@@ -2009,11 +2008,7 @@ void cpu_physical_memory_reset_dirty(ram_addr_t start, ram_addr_t end,
     length = end - start;
     if (length == 0)
         return;
-    len = length >> TARGET_PAGE_BITS;
-    mask = ~dirty_flags;
-    p = phys_ram_dirty + (start >> TARGET_PAGE_BITS);
-    for(i = 0; i < len; i++)
-        p[i] &= mask;
+    cpu_physical_memory_mask_dirty_range(start, length, dirty_flags);    
 
     /* we modify the TLB cache so that the dirty bit will be set again
        when accessing the range */
@@ -2936,16 +2931,16 @@ static void notdirty_mem_writeb(void *opaque, target_phys_addr_t ram_addr,
                                 uint32_t val)
 {
     int dirty_flags;
-    dirty_flags = phys_ram_dirty[ram_addr >> TARGET_PAGE_BITS];
+    dirty_flags = cpu_physical_memory_get_dirty_flags(ram_addr);
     if (!(dirty_flags & CODE_DIRTY_FLAG)) {
 #if !defined(CONFIG_USER_ONLY)
         tb_invalidate_phys_page_fast(ram_addr, 1);
-        dirty_flags = phys_ram_dirty[ram_addr >> TARGET_PAGE_BITS];
+        dirty_flags = cpu_physical_memory_get_dirty_flags(ram_addr);
 #endif
     }
     stb_p(qemu_get_ram_ptr(ram_addr), val);
     dirty_flags |= (0xff & ~CODE_DIRTY_FLAG);
-    phys_ram_dirty[ram_addr >> TARGET_PAGE_BITS] = dirty_flags;
+    cpu_physical_memory_set_dirty_flags(ram_addr, dirty_flags);
     /* we remove the notdirty callback only if the code has been
        flushed */
     if (dirty_flags == 0xff)
@@ -2956,16 +2951,16 @@ static void notdirty_mem_writew(void *opaque, target_phys_addr_t ram_addr,
                                 uint32_t val)
 {
     int dirty_flags;
-    dirty_flags = phys_ram_dirty[ram_addr >> TARGET_PAGE_BITS];
+    dirty_flags = cpu_physical_memory_get_dirty_flags(ram_addr);
     if (!(dirty_flags & CODE_DIRTY_FLAG)) {
 #if !defined(CONFIG_USER_ONLY)
         tb_invalidate_phys_page_fast(ram_addr, 2);
-        dirty_flags = phys_ram_dirty[ram_addr >> TARGET_PAGE_BITS];
+        dirty_flags = cpu_physical_memory_get_dirty_flags(ram_addr);
 #endif
     }
     stw_p(qemu_get_ram_ptr(ram_addr), val);
     dirty_flags |= (0xff & ~CODE_DIRTY_FLAG);
-    phys_ram_dirty[ram_addr >> TARGET_PAGE_BITS] = dirty_flags;
+    cpu_physical_memory_set_dirty_flags(ram_addr, dirty_flags);
     /* we remove the notdirty callback only if the code has been
        flushed */
     if (dirty_flags == 0xff)
@@ -2976,16 +2971,16 @@ static void notdirty_mem_writel(void *opaque, target_phys_addr_t ram_addr,
                                 uint32_t val)
 {
     int dirty_flags;
-    dirty_flags = phys_ram_dirty[ram_addr >> TARGET_PAGE_BITS];
+    dirty_flags = cpu_physical_memory_get_dirty_flags(ram_addr);
     if (!(dirty_flags & CODE_DIRTY_FLAG)) {
 #if !defined(CONFIG_USER_ONLY)
         tb_invalidate_phys_page_fast(ram_addr, 4);
-        dirty_flags = phys_ram_dirty[ram_addr >> TARGET_PAGE_BITS];
+        dirty_flags = cpu_physical_memory_get_dirty_flags(ram_addr);
 #endif
     }
     stl_p(qemu_get_ram_ptr(ram_addr), val);
     dirty_flags |= (0xff & ~CODE_DIRTY_FLAG);
-    phys_ram_dirty[ram_addr >> TARGET_PAGE_BITS] = dirty_flags;
+    cpu_physical_memory_set_dirty_flags(ram_addr, dirty_flags);
     /* we remove the notdirty callback only if the code has been
        flushed */
     if (dirty_flags == 0xff)
@@ -3436,8 +3431,8 @@ void cpu_physical_memory_rw(target_phys_addr_t addr, uint8_t *buf,
                     /* invalidate code */
                     tb_invalidate_phys_page_range(addr1, addr1 + l, 0);
                     /* set dirty bit */
-                    phys_ram_dirty[addr1 >> TARGET_PAGE_BITS] |=
-                        (0xff & ~CODE_DIRTY_FLAG);
+                    cpu_physical_memory_set_dirty_flags(
+                        addr1, (0xff & ~CODE_DIRTY_FLAG));
                 }
             }
         } else {
@@ -3643,8 +3638,8 @@ void cpu_physical_memory_unmap(void *buffer, target_phys_addr_t len,
                     /* invalidate code */
                     tb_invalidate_phys_page_range(addr1, addr1 + l, 0);
                     /* set dirty bit */
-                    phys_ram_dirty[addr1 >> TARGET_PAGE_BITS] |=
-                        (0xff & ~CODE_DIRTY_FLAG);
+                    cpu_physical_memory_set_dirty_flags(
+                        addr1, (0xff & ~CODE_DIRTY_FLAG));
                 }
                 addr1 += l;
                 access_len -= l;
@@ -3778,8 +3773,8 @@ void stl_phys_notdirty(target_phys_addr_t addr, uint32_t val)
                 /* invalidate code */
                 tb_invalidate_phys_page_range(addr1, addr1 + 4, 0);
                 /* set dirty bit */
-                phys_ram_dirty[addr1 >> TARGET_PAGE_BITS] |=
-                    (0xff & ~CODE_DIRTY_FLAG);
+                cpu_physical_memory_set_dirty_flags(
+                    addr1, (0xff & ~CODE_DIRTY_FLAG));
             }
         }
     }
@@ -3847,8 +3842,8 @@ void stl_phys(target_phys_addr_t addr, uint32_t val)
             /* invalidate code */
             tb_invalidate_phys_page_range(addr1, addr1 + 4, 0);
             /* set dirty bit */
-            phys_ram_dirty[addr1 >> TARGET_PAGE_BITS] |=
-                (0xff & ~CODE_DIRTY_FLAG);
+            cpu_physical_memory_set_dirty_flags(addr1,
+                (0xff & ~CODE_DIRTY_FLAG));
         }
     }
 }
-- 
1.7.0.31.g1df487

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

* [Qemu-devel] Re: [PATCH 0/2] Introduce wrapper functions to access phys_ram_dirty, and replace existing direct accesses to it.
  2010-03-23  7:39 [Qemu-devel] [PATCH 0/2] Introduce wrapper functions to access phys_ram_dirty, and replace existing direct accesses to it Yoshiaki Tamura
  2010-03-23  7:39 ` [Qemu-devel] [PATCH 1/2] Introduce wrapper functions to access phys_ram_dirty Yoshiaki Tamura
  2010-03-23  7:39 ` [Qemu-devel] [PATCH 2/2] Replace direct phys_ram_dirty access with wrapper functions Yoshiaki Tamura
@ 2010-03-23  9:00 ` Avi Kivity
  2010-04-05 10:52   ` Yoshiaki Tamura
  2010-04-08  9:59 ` [Qemu-devel] " Aurelien Jarno
  3 siblings, 1 reply; 6+ messages in thread
From: Avi Kivity @ 2010-03-23  9:00 UTC (permalink / raw)
  To: Yoshiaki Tamura; +Cc: ohmura.kei, mtosatti, qemu-devel

On 03/23/2010 09:39 AM, Yoshiaki Tamura wrote:
> Before replacing byte-based dirty bitmap with bit-based dirty bitmap,
> clearing direct accesses to the bitmap first seems to be good point to
> start with.
>
>    

Reviewed-by: Avi Kivity <avi@redhat.com>

-- 
error compiling committee.c: too many arguments to function

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

* [Qemu-devel] Re: [PATCH 0/2] Introduce wrapper functions to access phys_ram_dirty, and replace existing direct accesses to it.
  2010-03-23  9:00 ` [Qemu-devel] Re: [PATCH 0/2] Introduce wrapper functions to access phys_ram_dirty, and replace existing direct accesses to it Avi Kivity
@ 2010-04-05 10:52   ` Yoshiaki Tamura
  0 siblings, 0 replies; 6+ messages in thread
From: Yoshiaki Tamura @ 2010-04-05 10:52 UTC (permalink / raw)
  To: qemu-devel, anthony, Anthony Liguori; +Cc: ohmura.kei, mtosatti, Avi Kivity

Hi.

Could someone pick this patch set?
I have another patch set which is based on this.
If there are any issues, I'm happy to fix them.

Thanks,

Yoshi

Avi Kivity wrote:
> On 03/23/2010 09:39 AM, Yoshiaki Tamura wrote:
>> Before replacing byte-based dirty bitmap with bit-based dirty bitmap,
>> clearing direct accesses to the bitmap first seems to be good point to
>> start with.
>>
>
> Reviewed-by: Avi Kivity <avi@redhat.com>
>

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

* Re: [Qemu-devel] [PATCH 0/2] Introduce wrapper functions to access phys_ram_dirty, and replace existing direct accesses to it.
  2010-03-23  7:39 [Qemu-devel] [PATCH 0/2] Introduce wrapper functions to access phys_ram_dirty, and replace existing direct accesses to it Yoshiaki Tamura
                   ` (2 preceding siblings ...)
  2010-03-23  9:00 ` [Qemu-devel] Re: [PATCH 0/2] Introduce wrapper functions to access phys_ram_dirty, and replace existing direct accesses to it Avi Kivity
@ 2010-04-08  9:59 ` Aurelien Jarno
  3 siblings, 0 replies; 6+ messages in thread
From: Aurelien Jarno @ 2010-04-08  9:59 UTC (permalink / raw)
  To: Yoshiaki Tamura; +Cc: ohmura.kei, mtosatti, qemu-devel, avi

On Tue, Mar 23, 2010 at 04:39:51PM +0900, Yoshiaki Tamura wrote:
> 
> Before replacing byte-based dirty bitmap with bit-based dirty bitmap,
> clearing direct accesses to the bitmap first seems to be good point to
> start with.
> 
> This patch set is based on the following discussion.
> 
> http://www.mail-archive.com/kvm@vger.kernel.org/msg30724.html
> 
> Also rebased to qemu.git aa28b9bf9ba0904766b15e7ab8d62a76cb3225da.
> 

Thanks, applied.

-- 
Aurelien Jarno                          GPG: 1024D/F1BCDB73
aurelien@aurel32.net                 http://www.aurel32.net

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

end of thread, other threads:[~2010-04-08 11:16 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-23  7:39 [Qemu-devel] [PATCH 0/2] Introduce wrapper functions to access phys_ram_dirty, and replace existing direct accesses to it Yoshiaki Tamura
2010-03-23  7:39 ` [Qemu-devel] [PATCH 1/2] Introduce wrapper functions to access phys_ram_dirty Yoshiaki Tamura
2010-03-23  7:39 ` [Qemu-devel] [PATCH 2/2] Replace direct phys_ram_dirty access with wrapper functions Yoshiaki Tamura
2010-03-23  9:00 ` [Qemu-devel] Re: [PATCH 0/2] Introduce wrapper functions to access phys_ram_dirty, and replace existing direct accesses to it Avi Kivity
2010-04-05 10:52   ` Yoshiaki Tamura
2010-04-08  9:59 ` [Qemu-devel] " Aurelien Jarno

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.