Skip to contentSkip to conversation

vga: dirty log cleanup, more linear mapping

PATCH Superseded Jan Kiszka 5 participants 28 messages Jun 14, 2011 – Jun 23, 2011

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Jan Kiszka

author
#0 lore raw

cover vga: dirty log cleanup, more linear mapping

A few optimizations and cleanups I came across when trying to speed up slow graphical grub unter non-cirrus vga. This series
- eliminates log_start/stop CPUPhysMemoryClient callbacks
- accelerates chain 4 vga mode under KVM
- fixes reset of vmware-vga
- cleans up vmware-vga a bit

At least patch 8 is a candiate for 0.15 and stable.

CC Andrzej Zaborowski <[email protected]>
CC Anthony PERARD <[email protected]>
CC Avi Kivity <[email protected]>
CC Gerd Hoffmann <[email protected]>
CC Michael S. Tsirkin <[email protected]>

Jan Kiszka (13):
spice: Use cpu_register_physical_memory_log for dirty log enabling
vga-pci: Use cpu_register_physical_memory_log for dirty log enabling
cirrus-vga: Drop redundant vga_dirty_log_start
vmware-vga: Disable verbose mode
vmware-vga: Remove dead DIRECT_VRAM mode
vmware-vga: Eliminate vga_dirty_log_restart
vmware_vga: Do not enable dirty logging when in SVGA mode
vmware-vga: Register reset service
vmware-vga: Use cpu_register_physical_memory_log for dirty log
enabling
Drop dirty log start/stop infrastructure
vga: Refactor lfb_vram_mapped to vga_mem_mapped
vga: Move vga_sync_dirty_bitmap
vga: Use linear mapping + dirty logging in chain 4 memory access mode

 cpu-all.h       |    6 --
 cpu-common.h    |    4 -
 exec.c          |   30 ---------
 hw/cirrus_vga.c |   15 ++---
 hw/qxl.c        |    9 +--
 hw/vga-pci.c    |    4 +-
 hw/vga.c        |  153 ++++++++++++++++++++++++-------------------
 hw/vga_int.h    |    8 +--
 hw/vhost.c      |    2 -
 hw/vmware_vga.c |  195 +++++++++++++-----------------------------------------
 kvm-all.c       |   47 -------------
 11 files changed, 147 insertions(+), 326 deletions(-)
author
#1 lore raw

PATCH 1/13 spice: Use cpu_register_physical_memory_log for dirty log enabling

Drop outdated dirty log disable/enable around PCI remapping and register the BAR for dirty logging via cpu_register_physical_memory_log. That allows to remove all vga_dirty_log_start/stop references from qxl.

Note: The addtional vga_dirty_log_start for the primary interface looked stray. qxl_write_config enabled logging for all interfaces anyway.

CC Gerd Hoffmann <[email protected]>
---
 hw/qxl.c |    9 +++------
 1 files changed, 3 insertions(+), 6 deletions(-)
hw/qxl.c +3 -6
index 1906e84..eba1ff9 100644
@@ -619,12 +619,10 @@ static void qxl_write_config(PCIDevice *d, uint32_t address,
     PCIQXLDevice *qxl = DO_UPCAST(PCIQXLDevice, pci, d);
     VGACommonState *vga = &qxl->vga;
 
-    vga_dirty_log_stop(vga);
     pci_default_write_config(d, address, val, len);
     if (vga->map_addr && qxl->pci.io_regions[0].addr == -1) {
         vga->map_addr = 0;
     }
-    vga_dirty_log_start(vga);
 }
 
 static void qxl_check_state(PCIQXLDevice *d)
@@ -1037,12 +1035,11 @@ static void qxl_map(PCIDevice *pci, int region_num,
         qxl->io_base = addr;
         break;
     case QXL_RAM_RANGE_INDEX:
-        cpu_register_physical_memory(addr, size, qxl->vga.vram_offset | IO_MEM_RAM);
+        cpu_register_physical_memory_log(addr, size,
+                                         qxl->vga.vram_offset | IO_MEM_RAM,
+                                         0, true);
         qxl->vga.map_addr = addr;
         qxl->vga.map_end = addr + size;
-        if (qxl->id == 0) {
-            vga_dirty_log_start(&qxl->vga);
-        }
         break;
     case QXL_ROM_RANGE_INDEX:
         cpu_register_physical_memory(addr, size, qxl->rom_offset | IO_MEM_ROM);
Signature · 1 line
1.7.1
#2 lore raw

Re: [Qemu-devel] [PATCH 01/13] spice: Use cpu_register_physical_memory_log for dirty log enabling

Hi,

Quoted 2 lines

Note: The addtional vga_dirty_log_start for the primary interface looked stray. qxl_write_config enabled logging for all interfaces anyway.

No. qxl_write_config is hooked for the primary only.

hw/qxl.c static void qxl_map(PCIDevice *pci, int region_num, · line 1040

Quoted 5 lines

case QXL_RAM_RANGE_INDEX:

hw/qxl.c +3 -1
-        cpu_register_physical_memory(addr, size, qxl->vga.vram_offset | IO_MEM_RAM);
+        cpu_register_physical_memory_log(addr, size,
+                                         qxl->vga.vram_offset | IO_MEM_RAM,
+                                         0, true);

if (qxl->id == 0) {
cpu_register_physical_memory_log(...)
} else {
cpu_register_physical_memory()
}

Only the primary is vga compatible and thus needs dirty logging.

cheers,
Gerd

author
#3 lore raw

PATCH v2 1/13 spice: Use cpu_register_physical_memory_log for dirty log enabling

Drop outdated dirty log disable/enable around PCI remapping and register the BAR for dirty logging via cpu_register_physical_memory_log. That allows to remove all vga_dirty_log_start/stop references from qxl.

CC Gerd Hoffmann <[email protected]>

---

Changes in v2:
- don't enable logging for secondary adapter

 hw/qxl.c |    9 +++------
 1 files changed, 3 insertions(+), 6 deletions(-)
hw/qxl.c +3 -6
index 1906e84..01149ae 100644
@@ -619,12 +619,10 @@ static void qxl_write_config(PCIDevice *d, uint32_t address,
     PCIQXLDevice *qxl = DO_UPCAST(PCIQXLDevice, pci, d);
     VGACommonState *vga = &qxl->vga;
 
-    vga_dirty_log_stop(vga);
     pci_default_write_config(d, address, val, len);
     if (vga->map_addr && qxl->pci.io_regions[0].addr == -1) {
         vga->map_addr = 0;
     }
-    vga_dirty_log_start(vga);
 }
 
 static void qxl_check_state(PCIQXLDevice *d)
@@ -1037,12 +1035,11 @@ static void qxl_map(PCIDevice *pci, int region_num,
         qxl->io_base = addr;
         break;
     case QXL_RAM_RANGE_INDEX:
-        cpu_register_physical_memory(addr, size, qxl->vga.vram_offset | IO_MEM_RAM);
+        cpu_register_physical_memory_log(addr, size,
+                                         qxl->vga.vram_offset | IO_MEM_RAM,
+                                         0, qxl->id == 0);
         qxl->vga.map_addr = addr;
         qxl->vga.map_end = addr + size;
-        if (qxl->id == 0) {
-            vga_dirty_log_start(&qxl->vga);
-        }
         break;
     case QXL_ROM_RANGE_INDEX:
         cpu_register_physical_memory(addr, size, qxl->rom_offset | IO_MEM_ROM);
Signature · 1 line
1.7.1
Acked-by on v2 1/13
#4 lore raw

Re: [Qemu-devel] [PATCH v2 01/13] spice: Use cpu_register_physical_memory_log for dirty log enabling

Quoted 3 lines · Jan Kiszka

Drop outdated dirty log disable/enable around PCI remapping and register the BAR for dirty logging via cpu_register_physical_memory_log. That allows to remove all vga_dirty_log_start/stop references from qxl.

cheers,
Gerd

author
#5 lore raw

PATCH 2/13 vga-pci: Use cpu_register_physical_memory_log for dirty log enabling

In reply to Jan Kiszka
---
 hw/vga-pci.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
hw/vga-pci.c +2 -2
index ce9ec45..d7d904a 100644
@@ -53,10 +53,10 @@ static void vga_map(PCIDevice *pci_dev, int region_num,
     PCIVGAState *d = (PCIVGAState *)pci_dev;
     VGACommonState *s = &d->vga;
 
-    cpu_register_physical_memory(addr, s->vram_size, s->vram_offset);
+    cpu_register_physical_memory_log(addr, s->vram_size, s->vram_offset, 0,
+                                     true);
     s->map_addr = addr;
     s->map_end = addr + s->vram_size;
-    vga_dirty_log_start(s);
 }
 
 static void pci_vga_write_config(PCIDevice *d,
Signature · 1 line
1.7.1
author
#6 lore raw

PATCH 3/13 cirrus-vga: Drop redundant vga_dirty_log_start

In reply to Jan Kiszka

map_linear_vram requests logging via cpu_register_physical_memory_log now, and cirrus_pci_lfb_map does not leave anything to log behind.

---
 hw/cirrus_vga.c |    4 ----
 1 files changed, 0 insertions(+), 4 deletions(-)
hw/cirrus_vga.c +0 -4
index 722cac7..98a9b8e 100644
@@ -2519,8 +2519,6 @@ static void map_linear_vram(CirrusVGAState *s)
         cpu_register_physical_memory(isa_mem_base + 0xa0000, 0x20000,
                                      s->vga.vga_io_memory);
     }
-
-    vga_dirty_log_start(&s->vga);
 }
 
 static void unmap_linear_vram(CirrusVGAState *s)
@@ -3077,8 +3075,6 @@ static void cirrus_pci_lfb_map(PCIDevice *d, int region_num,
     /* account for overflow */
     if (s->vga.lfb_end < addr + VGA_RAM_SIZE)
         s->vga.lfb_end = addr + VGA_RAM_SIZE;
-
-    vga_dirty_log_start(&s->vga);
 }
 
 static void pci_cirrus_write_config(PCIDevice *d,
Signature · 1 line
1.7.1
author
#7 lore raw

PATCH 4/13 vmware-vga: Disable verbose mode

In reply to Jan Kiszka

Elimiates 'vmsvga_value_write: guest runs Linux.' messages from the console.

CC Andrzej Zaborowski <[email protected]>
---
 hw/vmware_vga.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
hw/vmware_vga.c +1 -1
index 4656767..76fe015 100644
@@ -27,7 +27,7 @@
 #include "pci.h"
 #include "vmware_vga.h"
 
-#define VERBOSE
+#undef VERBOSE
 #undef DIRECT_VRAM
 #define HW_RECT_ACCEL
 #define HW_FILL_ACCEL
Signature · 1 line
1.7.1
author
#8 lore raw

PATCH 5/13 vmware-vga: Remove dead DIRECT_VRAM mode

In reply to Jan Kiszka

The code was disabled since day 1 of vmware-vga, and now it does not even build anymore. Time for a cleanup.

CC Andrzej Zaborowski <[email protected]>
---
 hw/vmware_vga.c |  168 ++++++++++--------------------------------------------
 1 files changed, 31 insertions(+), 137 deletions(-)
hw/vmware_vga.c +31 -137
index 76fe015..1dfa875 100644
@@ -28,7 +28,6 @@
 #include "vmware_vga.h"
 
 #undef VERBOSE
-#undef DIRECT_VRAM
 #define HW_RECT_ACCEL
 #define HW_FILL_ACCEL
 #define HW_MOUSE_ACCEL
@@ -294,7 +293,6 @@ enum {
 static inline void vmsvga_update_rect(struct vmsvga_state_s *s,
                 int x, int y, int w, int h)
 {
-#ifndef DIRECT_VRAM
     int line;
     int bypl;
     int width;
@@ -325,23 +323,17 @@ static inline void vmsvga_update_rect(struct vmsvga_state_s *s,
 
     for (; line > 0; line --, src += bypl, dst += bypl)
         memcpy(dst, src, width);
-#endif
 
     dpy_update(s->vga.ds, x, y, w, h);
 }
 
 static inline void vmsvga_update_screen(struct vmsvga_state_s *s)
 {
-#ifndef DIRECT_VRAM
-    memcpy(ds_get_data(s->vga.ds), s->vga.vram_ptr, s->bypp * s->width * s->height);
-#endif
-
+    memcpy(ds_get_data(s->vga.ds), s->vga.vram_ptr,
+           s->bypp * s->width * s->height);
     dpy_update(s->vga.ds, 0, 0, s->width, s->height);
 }
 
-#ifdef DIRECT_VRAM
-# define vmsvga_update_rect_delayed	vmsvga_update_rect
-#else
 static inline void vmsvga_update_rect_delayed(struct vmsvga_state_s *s,
                 int x, int y, int w, int h)
 {
@@ -352,7 +344,6 @@ static inline void vmsvga_update_rect_delayed(struct vmsvga_state_s *s,
     rect->w = w;
     rect->h = h;
 }
-#endif
 
 static inline void vmsvga_update_rect_flush(struct vmsvga_state_s *s)
 {
@@ -374,32 +365,23 @@ static inline void vmsvga_update_rect_flush(struct vmsvga_state_s *s)
 static inline void vmsvga_copy_rect(struct vmsvga_state_s *s,
                 int x0, int y0, int x1, int y1, int w, int h)
 {
-# ifdef DIRECT_VRAM
-    uint8_t *vram = ds_get_data(s->ds);
-# else
     uint8_t *vram = s->vga.vram_ptr;
-# endif
     int bypl = s->bypp * s->width;
     int width = s->bypp * w;
     int line = h;
     uint8_t *ptr[2];
 
-# ifdef DIRECT_VRAM
-    if (s->ds->dpy_copy)
-        qemu_console_copy(s->ds, x0, y0, x1, y1, w, h);
-    else
-# endif
-    {
-        if (y1 > y0) {
-            ptr[0] = vram + s->bypp * x0 + bypl * (y0 + h - 1);
-            ptr[1] = vram + s->bypp * x1 + bypl * (y1 + h - 1);
-            for (; line > 0; line --, ptr[0] -= bypl, ptr[1] -= bypl)
-                memmove(ptr[1], ptr[0], width);
-        } else {
-            ptr[0] = vram + s->bypp * x0 + bypl * y0;
-            ptr[1] = vram + s->bypp * x1 + bypl * y1;
-            for (; line > 0; line --, ptr[0] += bypl, ptr[1] += bypl)
-                memmove(ptr[1], ptr[0], width);
+    if (y1 > y0) {
+        ptr[0] = vram + s->bypp * x0 + bypl * (y0 + h - 1);
+        ptr[1] = vram + s->bypp * x1 + bypl * (y1 + h - 1);
+        for (; line > 0; line --, ptr[0] -= bypl, ptr[1] -= bypl) {
+            memmove(ptr[1], ptr[0], width);
+        }
+    } else {
+        ptr[0] = vram + s->bypp * x0 + bypl * y0;
+        ptr[1] = vram + s->bypp * x1 + bypl * y1;
+        for (; line > 0; line --, ptr[0] += bypl, ptr[1] += bypl) {
+            memmove(ptr[1], ptr[0], width);
         }
     }
 
@@ -411,11 +393,7 @@ static inline void vmsvga_copy_rect(struct vmsvga_state_s *s,
 static inline void vmsvga_fill_rect(struct vmsvga_state_s *s,
                 uint32_t c, int x, int y, int w, int h)
 {
-# ifdef DIRECT_VRAM
-    uint8_t *vram = ds_get_data(s->ds);
-# else
     uint8_t *vram = s->vga.vram_ptr;
-# endif
     int bypp = s->bypp;
     int bypl = bypp * s->width;
     int width = bypp * w;
@@ -426,31 +404,25 @@ static inline void vmsvga_fill_rect(struct vmsvga_state_s *s,
     uint8_t *src;
     uint8_t col[4];
 
-# ifdef DIRECT_VRAM
-    if (s->ds->dpy_fill)
-        s->ds->dpy_fill(s->ds, x, y, w, h, c);
-    else
-# endif
-    {
-        col[0] = c;
-        col[1] = c >> 8;
-        col[2] = c >> 16;
-        col[3] = c >> 24;
-
-        if (line --) {
-            dst = fst;
-            src = col;
-            for (column = width; column > 0; column --) {
-                *(dst ++) = *(src ++);
-                if (src - col == bypp)
-                    src = col;
-            }
-            dst = fst;
-            for (; line > 0; line --) {
-                dst += bypl;
-                memcpy(dst, fst, width);
+    col[0] = c;
+    col[1] = c >> 8;
+    col[2] = c >> 16;
+    col[3] = c >> 24;
+
+    if (line--) {
+        dst = fst;
+        src = col;
+        for (column = width; column > 0; column--) {
+            *(dst++) = *(src++);
+            if (src - col == bypp) {
+                src = col;
             }
         }
+        dst = fst;
+        for (; line > 0; line--) {
+            dst += bypl;
+            memcpy(dst, fst, width);
+        }
     }
 
     vmsvga_update_rect_delayed(s, x, y, w, h);
@@ -1076,77 +1048,6 @@ static void vmsvga_text_update(void *opaque, console_ch_t *chardata)
         s->vga.text_update(&s->vga, chardata);
 }
 
-#ifdef DIRECT_VRAM
-static uint32_t vmsvga_vram_readb(void *opaque, target_phys_addr_t addr)
-{
-    struct vmsvga_state_s *s = opaque;
-    if (addr < s->fb_size)
-        return *(uint8_t *) (ds_get_data(s->ds) + addr);
-    else
-        return *(uint8_t *) (s->vram_ptr + addr);
-}
-
-static uint32_t vmsvga_vram_readw(void *opaque, target_phys_addr_t addr)
-{
-    struct vmsvga_state_s *s = opaque;
-    if (addr < s->fb_size)
-        return *(uint16_t *) (ds_get_data(s->ds) + addr);
-    else
-        return *(uint16_t *) (s->vram_ptr + addr);
-}
-
-static uint32_t vmsvga_vram_readl(void *opaque, target_phys_addr_t addr)
-{
-    struct vmsvga_state_s *s = opaque;
-    if (addr < s->fb_size)
-        return *(uint32_t *) (ds_get_data(s->ds) + addr);
-    else
-        return *(uint32_t *) (s->vram_ptr + addr);
-}
-
-static void vmsvga_vram_writeb(void *opaque, target_phys_addr_t addr,
-                uint32_t value)
-{
-    struct vmsvga_state_s *s = opaque;
-    if (addr < s->fb_size)
-        *(uint8_t *) (ds_get_data(s->ds) + addr) = value;
-    else
-        *(uint8_t *) (s->vram_ptr + addr) = value;
-}
-
-static void vmsvga_vram_writew(void *opaque, target_phys_addr_t addr,
-                uint32_t value)
-{
-    struct vmsvga_state_s *s = opaque;
-    if (addr < s->fb_size)
-        *(uint16_t *) (ds_get_data(s->ds) + addr) = value;
-    else
-        *(uint16_t *) (s->vram_ptr + addr) = value;
-}
-
-static void vmsvga_vram_writel(void *opaque, target_phys_addr_t addr,
-                uint32_t value)
-{
-    struct vmsvga_state_s *s = opaque;
-    if (addr < s->fb_size)
-        *(uint32_t *) (ds_get_data(s->ds) + addr) = value;
-    else
-        *(uint32_t *) (s->vram_ptr + addr) = value;
-}
-
-static CPUReadMemoryFunc * const vmsvga_vram_read[] = {
-    vmsvga_vram_readb,
-    vmsvga_vram_readw,
-    vmsvga_vram_readl,
-};
-
-static CPUWriteMemoryFunc * const vmsvga_vram_write[] = {
-    vmsvga_vram_writeb,
-    vmsvga_vram_writew,
-    vmsvga_vram_writel,
-};
-#endif
-
 static int vmsvga_post_load(void *opaque, int version_id)
 {
     struct vmsvga_state_s *s = opaque;
@@ -1245,17 +1146,10 @@ static void pci_vmsvga_map_mem(PCIDevice *pci_dev, int region_num,
 {
     struct pci_vmsvga_state_s *d = (struct pci_vmsvga_state_s *) pci_dev;
     struct vmsvga_state_s *s = &d->chip;
-    ram_addr_t iomemtype;
 
     s->vram_base = addr;
-#ifdef DIRECT_VRAM
-    iomemtype = cpu_register_io_memory(vmsvga_vram_read,
-                    vmsvga_vram_write, s, DEVICE_NATIVE_ENDIAN);
-#else
-    iomemtype = s->vga.vram_offset | IO_MEM_RAM;
-#endif
     cpu_register_physical_memory(s->vram_base, s->vga.vram_size,
-                    iomemtype);
+                                 s->vga.vram_offset | IO_MEM_RAM);
 
     s->vga.map_addr = addr;
     s->vga.map_end = addr + s->vga.vram_size;
Signature · 1 line
1.7.1
author
#9 lore raw

PATCH 6/13 vmware-vga: Eliminate vga_dirty_log_restart

In reply to Jan Kiszka

Convert the last user of vga_dirty_log_restart to cpu_register_physical_memory_log and drop the service.

CC Andrzej Zaborowski <[email protected]>
---
 hw/vga.c        |    6 ------
 hw/vga_int.h    |    1 -
 hw/vmware_vga.c |    5 ++---
 3 files changed, 2 insertions(+), 10 deletions(-)
hw/vga.c +0 -6
index 124295a..814d0d3 100644
@@ -1606,12 +1606,6 @@ void vga_dirty_log_stop(VGACommonState *s)
 #endif
 }
 
-void vga_dirty_log_restart(VGACommonState *s)
-{
-    vga_dirty_log_stop(s);
-    vga_dirty_log_start(s);
-}
-
 /*
  * graphic modes
  */
hw/vga_int.h +0 -1
index d2811bd..5cd9a6e 100644
@@ -196,7 +196,6 @@ void vga_common_reset(VGACommonState *s);
 
 void vga_dirty_log_start(VGACommonState *s);
 void vga_dirty_log_stop(VGACommonState *s);
-void vga_dirty_log_restart(VGACommonState *s);
 
 extern const VMStateDescription vmstate_vga_common;
 uint32_t vga_ioport_read(void *opaque, uint32_t addr);
hw/vmware_vga.c +2 -3
index 1dfa875..82e2a1c 100644
@@ -1148,12 +1148,11 @@ static void pci_vmsvga_map_mem(PCIDevice *pci_dev, int region_num,
     struct vmsvga_state_s *s = &d->chip;
 
     s->vram_base = addr;
-    cpu_register_physical_memory(s->vram_base, s->vga.vram_size,
-                                 s->vga.vram_offset | IO_MEM_RAM);
+    cpu_register_physical_memory_log(s->vram_base, s->vga.vram_size,
+                                     s->vga.vram_offset | IO_MEM_RAM, 0, true);
 
     s->vga.map_addr = addr;
     s->vga.map_end = addr + s->vga.vram_size;
-    vga_dirty_log_restart(&s->vga);
 }
 
 static void pci_vmsvga_map_fifo(PCIDevice *pci_dev, int region_num,
Signature · 1 line
1.7.1
Reviewed-by on v1 6/13
#10 lore raw

Re: [Qemu-devel] [PATCH 06/13] vmware-vga: Eliminate vga_dirty_log_restart

Quoted 5 lines · Jan Kiszka

Convert the last user of vga_dirty_log_restart to cpu_register_physical_memory_log and drop the service.

CC Andrzej Zaborowski <[email protected]>
Quoted 59 lines

---
 hw/vga.c        |    6 ------
 hw/vga_int.h    |    1 -
 hw/vmware_vga.c |    5 ++---

 3 files changed, 2 insertions(+), 10 deletions(-)
hw/vga.c +0 -6
index 124295a..814d0d3 100644
@@ -1606,12 +1606,6 @@ void vga_dirty_log_stop(VGACommonState *s)
  #endif
  }
 
-void vga_dirty_log_restart(VGACommonState *s)
-{
-    vga_dirty_log_stop(s);
-    vga_dirty_log_start(s);
-}
-
  /*
  * graphic modes
  */
hw/vga_int.h +0 -1
index d2811bd..5cd9a6e 100644
@@ -196,7 +196,6 @@ void vga_common_reset(VGACommonState *s);
 
  void vga_dirty_log_start(VGACommonState *s);
  void vga_dirty_log_stop(VGACommonState *s);
-void vga_dirty_log_restart(VGACommonState *s);
 
  extern const VMStateDescription vmstate_vga_common;
  uint32_t vga_ioport_read(void *opaque, uint32_t addr);
hw/vmware_vga.c +2 -4
index 1dfa875..82e2a1c 100644
@@ -1148,12 +1148,11 @@ static void pci_vmsvga_map_mem(PCIDevice *pci_dev, int region_num,
     struct vmsvga_state_s *s = &d->chip;
 
     s->vram_base = addr;
-    cpu_register_physical_memory(s->vram_base, s->vga.vram_size,
-                                 s->vga.vram_offset | IO_MEM_RAM);
+    cpu_register_physical_memory_log(s->vram_base, s->vga.vram_size,
+                                     s->vga.vram_offset | IO_MEM_RAM, 0, true);
 
     s->vga.map_addr = addr;
     s->vga.map_end = addr + s->vga.vram_size;
-    vga_dirty_log_restart(&s->vga);
  }
 
  static void pci_vmsvga_map_fifo(PCIDevice *pci_dev, int region_num,
--

1.7.1

author
#11 lore raw

PATCH 7/13 vmware_vga: Do not enable dirty logging when in SVGA mode

In reply to Jan Kiszka

Just like on SVGA_REG_ENABLE changes, keep dirty logging off on PCI BAR remappings when SVGA mode is on.

CC Andrzej Zaborowski <[email protected]>
---
 hw/vmware_vga.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
hw/vmware_vga.c +2 -1
index 82e2a1c..93b8811 100644
@@ -1149,7 +1149,8 @@ static void pci_vmsvga_map_mem(PCIDevice *pci_dev, int region_num,
 
     s->vram_base = addr;
     cpu_register_physical_memory_log(s->vram_base, s->vga.vram_size,
-                                     s->vga.vram_offset | IO_MEM_RAM, 0, true);
+                                     s->vga.vram_offset | IO_MEM_RAM, 0,
+                                     !s->enable);
 
     s->vga.map_addr = addr;
     s->vga.map_end = addr + s->vga.vram_size;
Signature · 1 line
1.7.1
Reviewed-by on v1 7/13
#12 lore raw

Re: [Qemu-devel] [PATCH 07/13] vmware_vga: Do not enable dirty logging when in SVGA mode

Quoted 5 lines · Jan Kiszka

Just like on SVGA_REG_ENABLE changes, keep dirty logging off on PCI BAR remappings when SVGA mode is on.

CC Andrzej Zaborowski <[email protected]>
Quoted 23 lines

---
 hw/vmware_vga.c |    3 ++-

 1 files changed, 2 insertions(+), 1 deletions(-)
hw/vmware_vga.c +2 -2
index 82e2a1c..93b8811 100644
@@ -1149,7 +1149,8 @@ static void pci_vmsvga_map_mem(PCIDevice *pci_dev, int region_num,
 
     s->vram_base = addr;
     cpu_register_physical_memory_log(s->vram_base, s->vga.vram_size,
-                                     s->vga.vram_offset | IO_MEM_RAM, 0, true);
+                                     s->vga.vram_offset | IO_MEM_RAM, 0,
+                                     !s->enable);
 
     s->vga.map_addr = addr;
     s->vga.map_end = addr + s->vga.vram_size;
--

1.7.1

author
#13 lore raw

PATCH 8/13 vmware-vga: Register reset service

In reply to Jan Kiszka

Fixes cold reset in vmware graphic modes.

CC Andrzej Zaborowski <[email protected]>
---
 hw/vmware_vga.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)
hw/vmware_vga.c +6 -3
index 93b8811..c20f154 100644
@@ -966,8 +966,12 @@ static void vmsvga_update_display(void *opaque)
     }
 }
 
-static void vmsvga_reset(struct vmsvga_state_s *s)
+static void vmsvga_reset(DeviceState *dev)
 {
+    struct pci_vmsvga_state_s *pci =
+        DO_UPCAST(struct pci_vmsvga_state_s, card.qdev, dev);
+    struct vmsvga_state_s *s = &pci->chip;
+
     s->index = 0;
     s->enable = 0;
     s->config = 0;
@@ -1117,8 +1121,6 @@ static void vmsvga_init(struct vmsvga_state_s *s, int vga_ram_size)
     vga_common_init(&s->vga, vga_ram_size);
     vga_init(&s->vga);
     vmstate_register(NULL, 0, &vmstate_vga_common, &s->vga);
-
-    vmsvga_reset(s);
 }
 
 static void pci_vmsvga_map_ioport(PCIDevice *pci_dev, int region_num,
@@ -1207,6 +1209,7 @@ static PCIDeviceInfo vmsvga_info = {
     .qdev.name    = "vmware-svga",
     .qdev.size    = sizeof(struct pci_vmsvga_state_s),
     .qdev.vmsd    = &vmstate_vmware_vga,
+    .qdev.reset   = vmsvga_reset,
     .no_hotplug   = 1,
     .init         = pci_vmsvga_initfn,
     .romfile      = "vgabios-vmware.bin",
Signature · 1 line
1.7.1
Reviewed-by on v1 8/13
#14 lore raw

Re: [Qemu-devel] [PATCH 08/13] vmware-vga: Register reset service

Quoted 4 lines · Jan Kiszka

Fixes cold reset in vmware graphic modes.

CC Andrzej Zaborowski <[email protected]>
Quoted 44 lines

---
 hw/vmware_vga.c |    9 ++++++---

 1 files changed, 6 insertions(+), 3 deletions(-)
hw/vmware_vga.c +6 -4
index 93b8811..c20f154 100644
@@ -966,8 +966,12 @@ static void vmsvga_update_display(void *opaque)
     }
  }
 
-static void vmsvga_reset(struct vmsvga_state_s *s)
+static void vmsvga_reset(DeviceState *dev)
  {
+    struct pci_vmsvga_state_s *pci =
+        DO_UPCAST(struct pci_vmsvga_state_s, card.qdev, dev);
+    struct vmsvga_state_s *s = &pci->chip;
+
     s->index = 0;
     s->enable = 0;
     s->config = 0;
@@ -1117,8 +1121,6 @@ static void vmsvga_init(struct vmsvga_state_s *s, int vga_ram_size)
     vga_common_init(&s->vga, vga_ram_size);
     vga_init(&s->vga);
     vmstate_register(NULL, 0, &vmstate_vga_common, &s->vga);
-
-    vmsvga_reset(s);
  }
 
  static void pci_vmsvga_map_ioport(PCIDevice *pci_dev, int region_num,
@@ -1207,6 +1209,7 @@ static PCIDeviceInfo vmsvga_info = {
     .qdev.name    = "vmware-svga",
     .qdev.size    = sizeof(struct pci_vmsvga_state_s),
     .qdev.vmsd    = &vmstate_vmware_vga,
+    .qdev.reset   = vmsvga_reset,
     .no_hotplug   = 1,
     .init         = pci_vmsvga_initfn,
     .romfile      = "vgabios-vmware.bin",
--

1.7.1

author
#15 lore raw

PATCH 9/13 vmware-vga: Use cpu_register_physical_memory_log for dirty log enabling

In reply to Jan Kiszka

This eliminates the last user of vga_dirty_log_start/start.

CC Andrzej Zaborowski <[email protected]>
---
 hw/vmware_vga.c |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)
hw/vmware_vga.c +7 -5
index c20f154..7cb0c28 100644
@@ -828,9 +828,13 @@ static void vmsvga_value_write(void *opaque, uint32_t address, uint32_t value)
         s->vga.invalidate(&s->vga);
         if (s->enable) {
             s->fb_size = ((s->depth + 7) >> 3) * s->new_width * s->new_height;
-            vga_dirty_log_stop(&s->vga);
-        } else {
-            vga_dirty_log_start(&s->vga);
+            cpu_register_physical_memory_log(s->vram_base, s->vga.vram_size,
+                                             s->vga.vram_offset | IO_MEM_RAM,
+                                             0, false);
+        } else if (s->vram_base) {
+            cpu_register_physical_memory_log(s->vram_base, s->vga.vram_size,
+                                             s->vga.vram_offset | IO_MEM_RAM,
+                                             0, true);
         }
         break;
 
@@ -1011,8 +1015,6 @@ static void vmsvga_reset(DeviceState *dev)
         break;
     }
     s->syncing = 0;
-
-    vga_dirty_log_start(&s->vga);
 }
 
 static void vmsvga_invalidate_display(void *opaque)
Signature · 1 line
1.7.1
Reviewed-by on v1 9/13
#16 lore raw

Re: [Qemu-devel] [PATCH 09/13] vmware-vga: Use cpu_register_physical_memory_log for dirty log enabling

Quoted 4 lines · Jan Kiszka

This eliminates the last user of vga_dirty_log_start/start.

CC Andrzej Zaborowski <[email protected]>
Quoted 39 lines

---
 hw/vmware_vga.c |   12 +++++++-----

 1 files changed, 7 insertions(+), 5 deletions(-)
hw/vmware_vga.c +7 -6
index c20f154..7cb0c28 100644
@@ -828,9 +828,13 @@ static void vmsvga_value_write(void *opaque, uint32_t address, uint32_t value)
         s->vga.invalidate(&s->vga);
         if (s->enable) {
             s->fb_size = ((s->depth + 7) >> 3) * s->new_width * s->new_height;
-            vga_dirty_log_stop(&s->vga);
-        } else {
-            vga_dirty_log_start(&s->vga);
+            cpu_register_physical_memory_log(s->vram_base, s->vga.vram_size,
+                                             s->vga.vram_offset | IO_MEM_RAM,
+                                             0, false);
+        } else if (s->vram_base) {
+            cpu_register_physical_memory_log(s->vram_base, s->vga.vram_size,
+                                             s->vga.vram_offset | IO_MEM_RAM,
+                                             0, true);
         }
         break;
 
@@ -1011,8 +1015,6 @@ static void vmsvga_reset(DeviceState *dev)
         break;
     }
     s->syncing = 0;
-
-    vga_dirty_log_start(&s->vga);
  }
 
  static void vmsvga_invalidate_display(void *opaque)
--

1.7.1

author
#17 lore raw

PATCH 10/13 Drop dirty log start/stop infrastructure

In reply to Jan Kiszka

No more users of vga_dirty_log_start/start, thus also no use anymore for the log_start/stop CPUPhysMemoryClient callbacks. Drop the whole infrastructure.

CC Anthony PERARD <[email protected]>
CC Michael S. Tsirkin <[email protected]>
CC Avi Kivity <[email protected]>

---

Avi, does this match your plans for a new memory API? Or would be end up reintroducing such callbacks after the refactoring?

---
 cpu-all.h    |    6 ------
 cpu-common.h |    4 ----
 exec.c       |   30 ------------------------------
 hw/vga.c     |   36 ------------------------------------
 hw/vga_int.h |    3 ---
 hw/vhost.c   |    2 --
 kvm-all.c    |   47 -----------------------------------------------
 7 files changed, 0 insertions(+), 128 deletions(-)
cpu-all.h +0 -6
index 880f570..ac81a07 100644
@@ -1015,12 +1015,6 @@ int cpu_physical_memory_get_dirty_tracking(void);
 int cpu_physical_sync_dirty_bitmap(target_phys_addr_t start_addr,
                                    target_phys_addr_t end_addr);
 
-int cpu_physical_log_start(target_phys_addr_t start_addr,
-                           ram_addr_t size);
-
-int cpu_physical_log_stop(target_phys_addr_t start_addr,
-                          ram_addr_t size);
-
 void dump_exec_info(FILE *f, fprintf_function cpu_fprintf);
 #endif /* !CONFIG_USER_ONLY */
 
cpu-common.h +0 -4
index 9f59172..c90c463 100644
@@ -111,10 +111,6 @@ struct CPUPhysMemoryClient {
                              target_phys_addr_t end_addr);
     int (*migration_log)(struct CPUPhysMemoryClient *client,
                          int enable);
-    int (*log_start)(struct CPUPhysMemoryClient *client,
-                     target_phys_addr_t phys_addr, ram_addr_t size);
-    int (*log_stop)(struct CPUPhysMemoryClient *client,
-                    target_phys_addr_t phys_addr, ram_addr_t size);
     QLIST_ENTRY(CPUPhysMemoryClient) list;
 };
 
exec.c +0 -30
index 09928a3..cd2c5b6 100644
@@ -2099,36 +2099,6 @@ int cpu_physical_sync_dirty_bitmap(target_phys_addr_t start_addr,
     return ret;
 }
 
-int cpu_physical_log_start(target_phys_addr_t start_addr,
-                           ram_addr_t size)
-{
-    CPUPhysMemoryClient *client;
-    QLIST_FOREACH(client, &memory_client_list, list) {
-        if (client->log_start) {
-            int r = client->log_start(client, start_addr, size);
-            if (r < 0) {
-                return r;
-            }
-        }
-    }
-    return 0;
-}
-
-int cpu_physical_log_stop(target_phys_addr_t start_addr,
-                          ram_addr_t size)
-{
-    CPUPhysMemoryClient *client;
-    QLIST_FOREACH(client, &memory_client_list, list) {
-        if (client->log_stop) {
-            int r = client->log_stop(client, start_addr, size);
-            if (r < 0) {
-                return r;
-            }
-        }
-    }
-    return 0;
-}
-
 static inline void tlb_update_dirty(CPUTLBEntry *tlb_entry)
 {
     ram_addr_t ram_addr;
hw/vga.c +0 -36
index 814d0d3..1290317 100644
@@ -1570,42 +1570,6 @@ static void vga_sync_dirty_bitmap(VGACommonState *s)
 
 }
 
-void vga_dirty_log_start(VGACommonState *s)
-{
-    if (s->map_addr) {
-        cpu_physical_log_start(s->map_addr, s->map_end - s->map_addr);
-    }
-
-    if (s->lfb_vram_mapped) {
-        cpu_physical_log_start(isa_mem_base + 0xa0000, 0x8000);
-        cpu_physical_log_start(isa_mem_base + 0xa8000, 0x8000);
-    }
-
-#ifdef CONFIG_BOCHS_VBE
-    if (s->vbe_mapped) {
-        cpu_physical_log_start(VBE_DISPI_LFB_PHYSICAL_ADDRESS, s->vram_size);
-    }
-#endif
-}
-
-void vga_dirty_log_stop(VGACommonState *s)
-{
-    if (s->map_addr) {
-        cpu_physical_log_stop(s->map_addr, s->map_end - s->map_addr);
-    }
-
-    if (s->lfb_vram_mapped) {
-        cpu_physical_log_stop(isa_mem_base + 0xa0000, 0x8000);
-        cpu_physical_log_stop(isa_mem_base + 0xa8000, 0x8000);
-    }
-
-#ifdef CONFIG_BOCHS_VBE
-    if (s->vbe_mapped) {
-        cpu_physical_log_stop(VBE_DISPI_LFB_PHYSICAL_ADDRESS, s->vram_size);
-    }
-#endif
-}
-
 /*
  * graphic modes
  */
hw/vga_int.h +0 -3
index 5cd9a6e..73328c2 100644
@@ -194,9 +194,6 @@ void vga_init(VGACommonState *s);
 int vga_init_io(VGACommonState *s);
 void vga_common_reset(VGACommonState *s);
 
-void vga_dirty_log_start(VGACommonState *s);
-void vga_dirty_log_stop(VGACommonState *s);
-
 extern const VMStateDescription vmstate_vga_common;
 uint32_t vga_ioport_read(void *opaque, uint32_t addr);
 void vga_ioport_write(void *opaque, uint32_t addr, uint32_t val);
hw/vhost.c +0 -2
index 80f771e..b7e6284 100644
@@ -668,8 +668,6 @@ int vhost_dev_init(struct vhost_dev *hdev, int devfd, bool force)
     hdev->client.set_memory = vhost_client_set_memory;
     hdev->client.sync_dirty_bitmap = vhost_client_sync_dirty_bitmap;
     hdev->client.migration_log = vhost_client_migration_log;
-    hdev->client.log_start = NULL;
-    hdev->client.log_stop = NULL;
     hdev->mem = qemu_mallocz(offsetof(struct vhost_memory, regions));
     hdev->log = NULL;
     hdev->log_size = 0;
kvm-all.c +0 -47

65 lines not on this page · raw message

Signature · 1 line
1.7.1
#18 lore raw

PATCH v2 10/13 Drop dirty log start/stop infrastructure

From: Jan Kiszka <[email protected]>

No more users of vga_dirty_log_start/start, thus also no use anymore for the log_start/stop CPUPhysMemoryClient callbacks. Drop the whole infrastructure.

CC Anthony PERARD <[email protected]>
CC Michael S. Tsirkin <[email protected]>
CC Avi Kivity <[email protected]>

---

Changes in v2:
- rebased over master, removing the freshly added Xen hooks

Avi, does this match your plans for a new memory API? Or would be end up reintroducing such callbacks after the refactoring?

---
 cpu-all.h    |    6 ------
 cpu-common.h |    4 ----
 exec.c       |   30 ------------------------------
 hw/vga.c     |   36 ------------------------------------
 hw/vga_int.h |    3 ---
 hw/vhost.c   |    2 --
 kvm-all.c    |   47 -----------------------------------------------
 xen-all.c    |   18 ------------------
 8 files changed, 0 insertions(+), 146 deletions(-)
cpu-all.h +0 -6
index 880f570..ac81a07 100644
@@ -1015,12 +1015,6 @@ int cpu_physical_memory_get_dirty_tracking(void);
 int cpu_physical_sync_dirty_bitmap(target_phys_addr_t start_addr,
                                    target_phys_addr_t end_addr);
 
-int cpu_physical_log_start(target_phys_addr_t start_addr,
-                           ram_addr_t size);
-
-int cpu_physical_log_stop(target_phys_addr_t start_addr,
-                          ram_addr_t size);
-
 void dump_exec_info(FILE *f, fprintf_function cpu_fprintf);
 #endif /* !CONFIG_USER_ONLY */
 
cpu-common.h +0 -4
index b027e43..07379c5 100644
@@ -112,10 +112,6 @@ struct CPUPhysMemoryClient {
                              target_phys_addr_t end_addr);
     int (*migration_log)(struct CPUPhysMemoryClient *client,
                          int enable);
-    int (*log_start)(struct CPUPhysMemoryClient *client,
-                     target_phys_addr_t phys_addr, ram_addr_t size);
-    int (*log_stop)(struct CPUPhysMemoryClient *client,
-                    target_phys_addr_t phys_addr, ram_addr_t size);
     QLIST_ENTRY(CPUPhysMemoryClient) list;
 };
 
exec.c +0 -30
index b03b5be..56b95ab 100644
@@ -2127,36 +2127,6 @@ int cpu_physical_sync_dirty_bitmap(target_phys_addr_t start_addr,
     return ret;
 }
 
-int cpu_physical_log_start(target_phys_addr_t start_addr,
-                           ram_addr_t size)
-{
-    CPUPhysMemoryClient *client;
-    QLIST_FOREACH(client, &memory_client_list, list) {
-        if (client->log_start) {
-            int r = client->log_start(client, start_addr, size);
-            if (r < 0) {
-                return r;
-            }
-        }
-    }
-    return 0;
-}
-
-int cpu_physical_log_stop(target_phys_addr_t start_addr,
-                          ram_addr_t size)
-{
-    CPUPhysMemoryClient *client;
-    QLIST_FOREACH(client, &memory_client_list, list) {
-        if (client->log_stop) {
-            int r = client->log_stop(client, start_addr, size);
-            if (r < 0) {
-                return r;
-            }
-        }
-    }
-    return 0;
-}
-
 static inline void tlb_update_dirty(CPUTLBEntry *tlb_entry)
 {
     ram_addr_t ram_addr;
hw/vga.c +0 -36
index fdfa3c4..a74f581 100644
@@ -1570,42 +1570,6 @@ static void vga_sync_dirty_bitmap(VGACommonState *s)
 
 }
 
-void vga_dirty_log_start(VGACommonState *s)
-{
-    if (s->map_addr) {
-        cpu_physical_log_start(s->map_addr, s->map_end - s->map_addr);
-    }
-
-    if (s->lfb_vram_mapped) {
-        cpu_physical_log_start(isa_mem_base + 0xa0000, 0x8000);
-        cpu_physical_log_start(isa_mem_base + 0xa8000, 0x8000);
-    }
-
-#ifdef CONFIG_BOCHS_VBE
-    if (s->vbe_mapped) {
-        cpu_physical_log_start(VBE_DISPI_LFB_PHYSICAL_ADDRESS, s->vram_size);
-    }
-#endif
-}
-
-void vga_dirty_log_stop(VGACommonState *s)
-{
-    if (s->map_addr) {
-        cpu_physical_log_stop(s->map_addr, s->map_end - s->map_addr);
-    }
-
-    if (s->lfb_vram_mapped) {
-        cpu_physical_log_stop(isa_mem_base + 0xa0000, 0x8000);
-        cpu_physical_log_stop(isa_mem_base + 0xa8000, 0x8000);
-    }
-
-#ifdef CONFIG_BOCHS_VBE
-    if (s->vbe_mapped) {
-        cpu_physical_log_stop(VBE_DISPI_LFB_PHYSICAL_ADDRESS, s->vram_size);
-    }
-#endif
-}
-
 /*
  * graphic modes
  */
hw/vga_int.h +0 -3
index 5cd9a6e..73328c2 100644
@@ -194,9 +194,6 @@ void vga_init(VGACommonState *s);
 int vga_init_io(VGACommonState *s);
 void vga_common_reset(VGACommonState *s);
 
-void vga_dirty_log_start(VGACommonState *s);
-void vga_dirty_log_stop(VGACommonState *s);
-
 extern const VMStateDescription vmstate_vga_common;
 uint32_t vga_ioport_read(void *opaque, uint32_t addr);
 void vga_ioport_write(void *opaque, uint32_t addr, uint32_t val);
hw/vhost.c +0 -2
index 80f771e..b7e6284 100644
@@ -668,8 +668,6 @@ int vhost_dev_init(struct vhost_dev *hdev, int devfd, bool force)
     hdev->client.set_memory = vhost_client_set_memory;
     hdev->client.sync_dirty_bitmap = vhost_client_sync_dirty_bitmap;
     hdev->client.migration_log = vhost_client_migration_log;
-    hdev->client.log_start = NULL;
-    hdev->client.log_stop = NULL;
     hdev->mem = qemu_mallocz(offsetof(struct vhost_memory, regions));
     hdev->log = NULL;
     hdev->log_size = 0;
kvm-all.c +0 -47

65 lines not on this page · raw message

xen-all.c +0 -18
index fcb106f..3c87b36 100644
@@ -416,22 +416,6 @@ static int xen_sync_dirty_bitmap(XenIOState *state,
     return 0;
 }
 
-static int xen_log_start(CPUPhysMemoryClient *client, target_phys_addr_t phys_addr, ram_addr_t size)
-{
-    XenIOState *state = container_of(client, XenIOState, client);
-
-    return xen_sync_dirty_bitmap(state, phys_addr, size);
-}
-
-static int xen_log_stop(CPUPhysMemoryClient *client, target_phys_addr_t phys_addr, ram_addr_t size)
-{
-    XenIOState *state = container_of(client, XenIOState, client);
-
-    state->log_for_dirtybit = NULL;
-    /* Disable dirty bit tracking */
-    return xc_hvm_track_dirty_vram(xen_xc, xen_domid, 0, 0, NULL);
-}
-
 static int xen_client_sync_dirty_bitmap(struct CPUPhysMemoryClient *client,
                                         target_phys_addr_t start_addr,
                                         target_phys_addr_t end_addr)
@@ -451,8 +435,6 @@ static CPUPhysMemoryClient xen_cpu_phys_memory_client = {
     .set_memory = xen_client_set_memory,
     .sync_dirty_bitmap = xen_client_sync_dirty_bitmap,
     .migration_log = xen_client_migration_log,
-    .log_start = xen_log_start,
-    .log_stop = xen_log_stop,
 };
 
 /* VCPU Operations, MMIO, IO ring ... */
#19 lore raw

Re: [Qemu-devel] [PATCH v2 10/13] Drop dirty log start/stop infrastructure

Quoted 10 lines · Jan Kiszka

From: Jan Kiszka<[email protected]>

No more users of vga_dirty_log_start/start, thus also no use anymore for the log_start/stop CPUPhysMemoryClient callbacks. Drop the whole infrastructure.

CC Anthony PERARD<[email protected]>
CC Michael S. Tsirkin<[email protected]>
CC Avi Kivity<[email protected]>
Quoted 7 lines

---

Changes in v2:
- rebased over master, removing the freshly added Xen hooks

Avi, does this match your plans for a new memory API? Or would be end up reintroducing such callbacks after the refactoring?

I think we should be fine.

Signature · 1 line
error compiling committee.c: too many arguments to function
author
#20 lore raw

PATCH 11/13 vga: Refactor lfb_vram_mapped to vga_mem_mapped

In reply to Jan Kiszka

Make it clearer that this flag indicates wether the legacy VGA memory region is mapped as RAM. And change its type to bool.

---
 hw/cirrus_vga.c |   10 ++++------
 hw/vga.c        |    4 ++--
 hw/vga_int.h    |    2 +-
 3 files changed, 7 insertions(+), 9 deletions(-)
hw/cirrus_vga.c +4 -6
index 98a9b8e..54a730d 100644
@@ -1179,7 +1179,7 @@ static void cirrus_update_bank_ptr(CirrusVGAState * s, unsigned bank_index)
     if (limit > 0) {
         /* Thinking about changing bank base? First, drop the dirty bitmap information
          * on the current location, otherwise we lose this pointer forever */
-        if (s->vga.lfb_vram_mapped) {
+        if (s->vga.vga_mem_mapped) {
             target_phys_addr_t base_addr = isa_mem_base + 0xa0000 + bank_index * 0x8000;
             cpu_physical_sync_dirty_bitmap(base_addr, base_addr + 0x8000);
         }
@@ -2497,8 +2497,6 @@ static void map_linear_vram(CirrusVGAState *s)
     if (!s->vga.map_addr)
         return;
 
-    s->vga.lfb_vram_mapped = 0;
-
     if (!(s->cirrus_srcptr != s->cirrus_srcptr_end)
         && !((s->vga.sr[0x07] & 0x01) == 0)
         && !((s->vga.gr[0x0B] & 0x14) == 0x14)
@@ -2513,11 +2511,11 @@ static void map_linear_vram(CirrusVGAState *s)
 					  s->cirrus_bank_base[1]) |
 					 IO_MEM_RAM, 0, true);
 
-        s->vga.lfb_vram_mapped = 1;
-    }
-    else {
+        s->vga.vga_mem_mapped = true;
+    } else {
         cpu_register_physical_memory(isa_mem_base + 0xa0000, 0x20000,
                                      s->vga.vga_io_memory);
+        s->vga.vga_mem_mapped = false;
     }
 }
 
hw/vga.c +2 -2
index 1290317..ee0c68e 100644
@@ -1556,7 +1556,7 @@ static void vga_sync_dirty_bitmap(VGACommonState *s)
     if (s->map_addr)
         cpu_physical_sync_dirty_bitmap(s->map_addr, s->map_end);
 
-    if (s->lfb_vram_mapped) {
+    if (s->vga_mem_mapped) {
         cpu_physical_sync_dirty_bitmap(isa_mem_base + 0xa0000, 0xa8000);
         cpu_physical_sync_dirty_bitmap(isa_mem_base + 0xa8000, 0xb0000);
     }
@@ -1868,7 +1868,7 @@ void vga_common_reset(VGACommonState *s)
     s->lfb_end = 0;
     s->map_addr = 0;
     s->map_end = 0;
-    s->lfb_vram_mapped = 0;
+    s->vga_mem_mapped = false;
     s->sr_index = 0;
     memset(s->sr, '\0', sizeof(s->sr));
     s->gr_index = 0;
hw/vga_int.h +1 -1
index 73328c2..a6ea93c 100644
@@ -111,7 +111,7 @@ typedef struct VGACommonState {
     uint32_t lfb_end;
     uint32_t map_addr;
     uint32_t map_end;
-    uint32_t lfb_vram_mapped; /* whether 0xa0000 is mapped as ram */
+    bool vga_mem_mapped; /* whether 0xa0000..0xbffff is mapped as RAM */
     uint32_t latch;
     uint8_t sr_index;
     uint8_t sr[256];
Signature · 1 line
1.7.1
author
#21 lore raw

PATCH 12/13 vga: Move vga_sync_dirty_bitmap

In reply to Jan Kiszka

We will need it earlier in the code.

---
 hw/vga.c |   37 ++++++++++++++++++-------------------
 1 files changed, 18 insertions(+), 19 deletions(-)
hw/vga.c +18 -19
index ee0c68e..4208151 100644
@@ -152,6 +152,24 @@ static void vga_screen_dump(void *opaque, const char *filename);
 static char *screen_dump_filename;
 static DisplayChangeListener *screen_dump_dcl;
 
+static void vga_sync_dirty_bitmap(VGACommonState *s)
+{
+    if (s->map_addr) {
+        cpu_physical_sync_dirty_bitmap(s->map_addr, s->map_end);
+    }
+    if (s->vga_mem_mapped) {
+        cpu_physical_sync_dirty_bitmap(isa_mem_base + 0xa0000, 0xa8000);
+        cpu_physical_sync_dirty_bitmap(isa_mem_base + 0xa8000, 0xb0000);
+    }
+#ifdef CONFIG_BOCHS_VBE
+    if (s->vbe_mapped) {
+        cpu_physical_sync_dirty_bitmap(VBE_DISPI_LFB_PHYSICAL_ADDRESS,
+                                       VBE_DISPI_LFB_PHYSICAL_ADDRESS +
+                                       s->vram_size);
+    }
+#endif
+}
+
 static void vga_dumb_update_retrace_info(VGACommonState *s)
 {
     (void) s;
@@ -1551,25 +1569,6 @@ void vga_invalidate_scanlines(VGACommonState *s, int y1, int y2)
     }
 }
 
-static void vga_sync_dirty_bitmap(VGACommonState *s)
-{
-    if (s->map_addr)
-        cpu_physical_sync_dirty_bitmap(s->map_addr, s->map_end);
-
-    if (s->vga_mem_mapped) {
-        cpu_physical_sync_dirty_bitmap(isa_mem_base + 0xa0000, 0xa8000);
-        cpu_physical_sync_dirty_bitmap(isa_mem_base + 0xa8000, 0xb0000);
-    }
-
-#ifdef CONFIG_BOCHS_VBE
-    if (s->vbe_mapped) {
-        cpu_physical_sync_dirty_bitmap(VBE_DISPI_LFB_PHYSICAL_ADDRESS,
-                                       VBE_DISPI_LFB_PHYSICAL_ADDRESS + s->vram_size);
-    }
-#endif
-
-}
-
 /*
  * graphic modes
  */
Signature · 1 line
1.7.1
author
#22 lore raw

PATCH 13/13 vga: Use linear mapping + dirty logging in chain 4 memory access mode

In reply to Jan Kiszka

Most VGA memory access modes require MMIO handling as they demand weird logic to get a byte from or into the video RAM. However, there is one
exception: chain 4 mode with all memory planes enabled for writing. This mode actually allows lineary mapping, which can then be combined with dirty logging to accelerate KVM.

This patch accelerates specifically VBE accesses like they are used by grub in graphical mode. Not only the standard VGA adapter benefits from this, also vmware and spice in VGA mode.

CC Gerd Hoffmann <[email protected]>
---
 hw/cirrus_vga.c |    1 +
 hw/vga.c        |   74 +++++++++++++++++++++++++++++++++++++++++++++++++++---
 hw/vga_int.h    |    2 +
 3 files changed, 72 insertions(+), 5 deletions(-)
hw/cirrus_vga.c +1 -0
index 54a730d..babb816 100644
@@ -2516,6 +2516,7 @@ static void map_linear_vram(CirrusVGAState *s)
         cpu_register_physical_memory(isa_mem_base + 0xa0000, 0x20000,
                                      s->vga.vga_io_memory);
         s->vga.vga_mem_mapped = false;
+        s->vga.vga_memory_map_mode = 1;
     }
 }
 
hw/vga.c +69 -5

127 lines not on this page · raw message

hw/vga_int.h +2 -0
index a6ea93c..dd8a283 100644
@@ -112,6 +112,8 @@ typedef struct VGACommonState {
     uint32_t map_addr;
     uint32_t map_end;
     bool vga_mem_mapped; /* whether 0xa0000..0xbffff is mapped as RAM */
+    int vga_memory_map_mode;
+    int32_t vga_bank_offs_mapped;
     uint32_t latch;
     uint8_t sr_index;
     uint8_t sr[256];
Signature · 1 line
1.7.1
#23 lore raw
In reply to Jan Kiszka
Quoted 8 lines · Jan Kiszka

A few optimizations and cleanups I came across when trying to speed up slow graphical grub unter non-cirrus vga. This series
- eliminates log_start/stop CPUPhysMemoryClient callbacks
- accelerates chain 4 vga mode under KVM
- fixes reset of vmware-vga
- cleans up vmware-vga a bit

At least patch 8 is a candiate for 0.15 and stable.

Yikes, most is all going away with the memory API (except the extra acceleration).

Signature · 1 line
error compiling committee.c: too many arguments to function
#24 lore raw
Quoted 8 lines · Avi Kivity
Quoted 7 lines · Jan Kiszka

A few optimizations and cleanups I came across when trying to speed up slow graphical grub unter non-cirrus vga. This series
- eliminates log_start/stop CPUPhysMemoryClient callbacks
- accelerates chain 4 vga mode under KVM
- fixes reset of vmware-vga
- cleans up vmware-vga a bit

Quoted 4 lines
Quoted 1 line

At least patch 8 is a candiate for 0.15 and stable.

Yikes, most is all going away with the memory API (except the extra acceleration).

Can't follow yet. What goes away?

Jan

#25 lore raw
Quoted 9 lines · Jan Kiszka
Quoted 8 lines · Avi Kivity
Quoted 7 lines · Jan Kiszka

A few optimizations and cleanups I came across when trying to speed up slow graphical grub unter non-cirrus vga. This series
- eliminates log_start/stop CPUPhysMemoryClient callbacks
- accelerates chain 4 vga mode under KVM
- fixes reset of vmware-vga
- cleans up vmware-vga a bit

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

At least patch 8 is a candiate for 0.15 and stable.

Yikes, most is all going away with the memory API (except the extra acceleration).

Can't follow yet. What goes away?

All the games with starting and stopping the log. Now you start the log on the vram memory region and all the aliases, maps/unmaps, and mode changes are handled automatically.

But I didn't get the patches yet, so no idea how much overlap.

Signature · 1 line
error compiling committee.c: too many arguments to function
#26 lore raw
Quoted 11 lines · Avi Kivity
Quoted 10 lines · Jan Kiszka
Quoted 2 lines · Avi Kivity
Quoted 1 line · Jan Kiszka

A few optimizations and cleanups I came across when trying to

speed up

Quoted 6 lines
Quoted 6 lines

slow graphical grub unter non-cirrus vga. This series
- eliminates log_start/stop CPUPhysMemoryClient callbacks
- accelerates chain 4 vga mode under KVM
- fixes reset of vmware-vga
- cleans up vmware-vga a bit

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 1 line

At least patch 8 is a candiate for 0.15 and stable.

Yikes, most is all going away with the memory API (except the extra acceleration).

Can't follow yet. What goes away?

All the games with starting and stopping the log.

That's what this series does as well (among other things).

That the new API will look different for the devices is clear, also that it may differ on the listener side. But if your API will not need any kind of explicit start/stop callbacks for memory clients, then we are moving in the right direction.

Quoted 5 lines

Now you start the log
on the vram memory region and all the aliases, maps/unmaps, and mode changes are handled automatically.

But I didn't get the patches yet, so no idea how much overlap.

The patches were already sent last week, see [1] for the full history.

Jan

[1] http://thread.gmane.org/gmane.comp.emulators.qemu/106150

#27 lore raw
Quoted 19 lines · Jan Kiszka
Quoted 18 lines · Avi Kivity
Quoted 16 lines · Jan Kiszka
Quoted 2 lines · Avi Kivity
Quoted 1 line · Jan Kiszka

A few optimizations and cleanups I came across when trying to

speed up

Quoted 10 lines
Quoted 7 lines

slow graphical grub unter non-cirrus vga. This series
- eliminates log_start/stop CPUPhysMemoryClient callbacks
- accelerates chain 4 vga mode under KVM
- fixes reset of vmware-vga
- cleans up vmware-vga a bit

At least patch 8 is a candiate for 0.15 and stable.

Yikes, most is all going away with the memory API (except the extra acceleration).

Can't follow yet. What goes away?

Quoted 8 lines
Quoted 1 line

All the games with starting and stopping the log.

That's what this series does as well (among other things).

That the new API will look different for the devices is clear, also that it may differ on the listener side. But if your API will not need any kind of explicit start/stop callbacks for memory clients, then we are moving in the right direction.

Yes, looking at them, they certainly match what I'm doing. Will be fun rebasing over them.

Quoted 4 lines
Quoted 4 lines

Now you start the log
on the vram memory region and all the aliases, maps/unmaps, and mode changes are handled automatically.

Quoted 8 lines
Quoted 1 line

But I didn't get the patches yet, so no idea how much overlap.

The patches were already sent last week, see [1] for the full history.

Jan

[1] http://thread.gmane.org/gmane.comp.emulators.qemu/106150

Yeah, I missed them, even though you copied me.

Signature · 1 line
error compiling committee.c: too many arguments to function