Fix display breakage when resizing the screen (v2)
PATCH 1/1 Fix display breakage when resizing the screen (v2)
When the vga resolution changes, a new display surface is not allocated immediately; instead that is deferred until the next update. However, if we're running without a display client attached, that won't happen and the next bitblt is likely to cause a segfault by overflowing the display surface.
Fix by reallocating the display immediately when the resolution changes.
Tested with (Windows|Linux) x (cirrus|std) x (curses|sdl).
Changes from v1:
- fix segfault when switching virtual consoles with curses
--- hw/cirrus_vga.c | 11 ++- hw/vga.c | 275 +++++++++++++++++++++++++++++++------------------------ hw/vga_int.h | 4 + 3 files changed, 170 insertions(+), 120 deletions(-)
hw/cirrus_vga.c +10 -1
@@ -1392,6 +1392,8 @@ cirrus_hook_write_sr(CirrusVGAState * s, unsigned reg_index, int reg_value)break ; } +vga_update_resolution ((VGAState *)s); +return CIRRUS_HOOK_HANDLED ; }
@@ -1419,6 +1421,7 @@ static void cirrus_write_hidden_dac(CirrusVGAState * s, int reg_value)#endif } s->cirrus_hidden_dac_lockindex =0 ; +vga_update_resolution ((VGAState *)s); }/***************************************
@@ -1705,6 +1708,8 @@ cirrus_hook_write_cr(CirrusVGAState * s, unsigned reg_index, int reg_value)break ; } +vga_update_resolution ((VGAState *)s); +return CIRRUS_HOOK_HANDLED ; }
@@ -2830,6 +2835,7 @@ static void vga_ioport_write(void *opaque, uint32_t addr, uint32_t val)if (s->ar_flip_flop ==0 ) { val &=0x3f ; s->ar_index = val; +vga_update_resolution ((VGAState *)s); }else { index = s->ar_index &0x1f ;switch (index) {
@@ -2923,6 +2929,7 @@ static void vga_ioport_write(void *opaque, uint32_t addr, uint32_t val)/* can always write bit 4 of CR7 */ if (s->cr_index ==7 ) s->cr[7 ] = (s->cr[7 ] & ~0x10 ) | (val &0x10 ); +vga_update_resolution ((VGAState *)s);return ; }switch (s->cr_index) {
@@ -2951,6 +2958,7 @@ static void vga_ioport_write(void *opaque, uint32_t addr, uint32_t val) s->update_retrace_info ((VGAState *) s);break ; } +vga_update_resolution ((VGAState *)s);break ;case 0x3ba :case 0x3da :
@@ -3157,7 +3165,8 @@ static int cirrus_vga_load(QEMUFile *f, void *opaque, int version_id)cirrus_update_memory_access (s);/* force refresh */ - s->graphic_mode =-1 ; +vga_update_resolution ((VGAState *)s); + s->want_full_update =1 ;cirrus_update_bank_ptr (s,0 );cirrus_update_bank_ptr (s,1 );return 0 ;
hw/vga.c +156 -119
496 lines not on this page · raw message
hw/vga_int.h +4 -0
@@ -147,8 +147,11 @@ typedef void (* vga_update_retrace_info_fn)(struct VGAState *s);DisplayState *ds; \uint32_t font_offsets[2 ]; \int graphic_mode; \ +int want_full_update; \uint8_t shift_control; \uint8_t double_scan; \ +uint8_t multi_run; \ +uint8_t multi_scan; \uint32_t line_offset; \uint32_t line_compare; \uint32_t start_addr; \
@@ -195,6 +198,7 @@ void vga_common_init(VGAState *s, uint8_t *vga_ram_base, ram_addr_t vga_ram_offset, int vga_ram_size);void vga_init (VGAState *s);void vga_reset (void *s); +void vga_update_resolution (VGAState *s);void vga_dirty_log_start (VGAState *s);void vga_dirty_log_stop (VGAState *s);
Signature · 1 line
1.6.1.1
Anthony Liguori
AppliedQuoted 6 lines · Avi Kivity
When the vga resolution changes, a new display surface is not allocated immediately; instead that is deferred until the next update. However, if we're running without a display client attached, that won't happen and the next bitblt is likely to cause a segfault by overflowing the display surface.
Quoted 9 lines
Fix by reallocating the display immediately when the resolution changes.
Tested with (Windows|Linux) x (cirrus|std) x (curses|sdl).
Changes from v1:
- fix segfault when switching virtual consoles with cursesSigned-off-by Avi Kivity <[email protected]>
Applied. Thanks.
Signature · 3 lines
Regards, Anthony Liguori