Fixes 20200407 patches
The following changes since commit 146aa0f104bb3bf88e43c4082a0bfc4bbda4fbd8:
Merge remote-tracking branch 'remotes/stefanha/tags/block-pull-request' into staging (2020-04-03 15:30:11 +0100)
are available in the Git repository at:
git://git.kraxel.org/qemu tags/fixes-20200407-pull-request
for you to fetch changes up to ac2071c3791b67fc7af78b8ceb320c01ca1b5df7:
ati-vga: Fix checks in ati_2d_blt() to avoid crash (2020-04-07 09:25:23 +0200)
----------------------------------------------------------------
fixes for 5.0:
- audio: windows (dsound) fixes.
- vga: ati blitter sanity check fixes.
----------------------------------------------------------------
BALATON Zoltan (1):
ati-vga: Fix checks in ati_2d_blt() to avoid crash
Volker Rümelin (3):
dsoundaudio: fix never-ending playback loop
dsoundaudio: fix "Could not lock capture buffer" warning
dsoundaudio: dsound_get_buffer_in should honor *size
audio/audio.c | 12 +++++------- audio/dsoundaudio.c | 9 +++++++-- hw/display/ati_2d.c | 37 ++++++++++++++++++++++++++----------- 3 files changed, 38 insertions(+), 20 deletions(-)
Signature · 1 line
2.18.2
[PULL 1/4] dsoundaudio: fix never-ending playback loop
From: Volker Rümelin <[email protected]>
Currently the DirectSound backend fails to stop audio playback in dsound_enable_out(). To detect a lost buffer condition dsound_get_status_out() incorrectly uses the error code DSERR_BUFFERLOST instead of flag DSBSTATUS_BUFFERLOST as a mask and returns with an error. As a result dsound_enable_out() returns early and doesn't stop playback.
To reproduce the bug start qemu on a Windows host with -soundhw pcspk -audiodev dsound,id=audio0. On the guest FreeDOS 1.2 command line enter beep. The image Day 1 - F-Bird from the QEMU Advent Calendar 2018 shows the bug as well.
Message-id: [email protected]
--- audio/dsoundaudio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
audio/dsoundaudio.c +1 -1
@@ -279,7 +279,7 @@ static int dsound_get_status_out (LPDIRECTSOUNDBUFFER dsb, DWORD *statusp,return -1 ; } -if (*statusp &DSERR_BUFFERLOST ) { +if (*statusp &DSBSTATUS_BUFFERLOST ) {dsound_restore_out (dsb, s);return -1 ; }
Signature · 1 line
2.18.2
[PULL 2/4] dsoundaudio: fix "Could not lock capture buffer" warning
In reply to Gerd HoffmannFrom: Volker Rümelin <[email protected]>
IDirectSoundCaptureBuffer_Lock() fails on Windows when called with len = 0. Return early from dsound_get_buffer_in() in this case.
To reproduce the warning start a linux guest. In the guest start Audacity and you will see a lot of "Could not lock capture buffer" warnings.
Message-id: [email protected]
--- audio/dsoundaudio.c | 5 +++++ 1 file changed, 5 insertions(+)
audio/dsoundaudio.c +5 -0
@@ -542,6 +542,11 @@ static void *dsound_get_buffer_in(HWVoiceIn *hw, size_t *size) req_size =audio_ring_dist (cpos, hw->pos_emul, hw->size_emul); req_size =MIN (req_size, hw->size_emul - hw->pos_emul); +if (req_size ==0 ) { + *size =0 ; +return NULL ; + } + err =dsound_lock_in (dscb, &hw->info, hw->pos_emul, req_size, &ret,NULL , &act_size,NULL , false, ds->s);if (err) {
Signature · 1 line
2.18.2
[PULL 4/4] ati-vga: Fix checks in ati_2d_blt() to avoid crash
In reply to Gerd HoffmannFrom: BALATON Zoltan <[email protected]>
In some corner cases (that never happen during normal operation but a malicious guest could program wrong values) pixman functions were called with parameters that result in a crash. Fix this and add more checks to disallow such cases.
Message-id: [email protected]
--- hw/display/ati_2d.c | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-)
hw/display/ati_2d.c +26 -11
@@ -53,12 +53,20 @@ void ati_2d_blt(ATIVGAState *s) s->vga.vbe_start_addr,surface_data (ds),surface_stride (ds),surface_bits_per_pixel (ds), (s->regs.dp_mix & GMC_ROP3_MASK) >> 16); -int dst_x = (s->regs.dp_cntl &DST_X_LEFT_TO_RIGHT ? - s->regs.dst_x : s->regs.dst_x +1 - s->regs.dst_width); -int dst_y = (s->regs.dp_cntl &DST_Y_TOP_TO_BOTTOM ? - s->regs.dst_y : s->regs.dst_y +1 - s->regs.dst_height); +unsigned dst_x = (s->regs.dp_cntl &DST_X_LEFT_TO_RIGHT ? + s->regs.dst_x : s->regs.dst_x +1 - s->regs.dst_width); +unsigned dst_y = (s->regs.dp_cntl &DST_Y_TOP_TO_BOTTOM ? + s->regs.dst_y : s->regs.dst_y +1 - s->regs.dst_height);int bpp =ati_bpp_from_datatype (s); +if (!bpp) { +qemu_log_mask (LOG_GUEST_ERROR ,"Invalid bpp\n" ); +return ; + }int dst_stride =DEFAULT_CNTL ? s->regs.dst_pitch : s->regs.default_pitch; +if (!dst_stride) { +qemu_log_mask (LOG_GUEST_ERROR ,"Zero dest pitch\n" ); +return ; + }uint8_t *dst_bits = s->vga.vram_ptr + (DEFAULT_CNTL ? s->regs.dst_offset : s->regs.default_offset);
@@ -82,12 +90,16 @@ void ati_2d_blt(ATIVGAState *s)switch (s->regs.dp_mix &GMC_ROP3_MASK ) {case ROP3_SRCCOPY : { -int src_x = (s->regs.dp_cntl &DST_X_LEFT_TO_RIGHT ? - s->regs.src_x : s->regs.src_x +1 - s->regs.dst_width); -int src_y = (s->regs.dp_cntl &DST_Y_TOP_TO_BOTTOM ? - s->regs.src_y : s->regs.src_y +1 - s->regs.dst_height); +unsigned src_x = (s->regs.dp_cntl &DST_X_LEFT_TO_RIGHT ? + s->regs.src_x : s->regs.src_x +1 - s->regs.dst_width); +unsigned src_y = (s->regs.dp_cntl &DST_Y_TOP_TO_BOTTOM ? + s->regs.src_y : s->regs.src_y +1 - s->regs.dst_height);int src_stride =DEFAULT_CNTL ? s->regs.src_pitch : s->regs.default_pitch; +if (!src_stride) { +qemu_log_mask (LOG_GUEST_ERROR ,"Zero source pitch\n" ); +return ; + }uint8_t *src_bits = s->vga.vram_ptr + (DEFAULT_CNTL ? s->regs.src_offset : s->regs.default_offset);
@@ -137,8 +149,10 @@ void ati_2d_blt(ATIVGAState *s) dst_y *surface_stride (ds), s->regs.dst_height * surface_stride(ds)); } - s->regs.dst_x += s->regs.dst_width; - s->regs.dst_y += s->regs.dst_height; + s->regs.dst_x = (s->regs.dp_cntl &DST_X_LEFT_TO_RIGHT ? + dst_x + s->regs.dst_width : dst_x); + s->regs.dst_y = (s->regs.dp_cntl &DST_Y_TOP_TO_BOTTOM ? + dst_y + s->regs.dst_height : dst_y);break ; }case ROP3_PATCOPY :
@@ -179,7 +193,8 @@ void ati_2d_blt(ATIVGAState *s) dst_y *surface_stride (ds), s->regs.dst_height * surface_stride(ds)); } - s->regs.dst_y += s->regs.dst_height; + s->regs.dst_y = (s->regs.dp_cntl &DST_Y_TOP_TO_BOTTOM ? + dst_y + s->regs.dst_height : dst_y);break ; }default :
Signature · 1 line
2.18.2
[PULL 3/4] dsoundaudio: dsound_get_buffer_in should honor *size
In reply to Gerd HoffmannFrom: Volker Rümelin <[email protected]>
This patch prevents an underflow of variable samples in function audio_pcm_hw_run_in(). See commit 599eac4e5a "audio:audio_generic_get_buffer_in should honor *size". This time the while loop in audio_pcm_hw_run_in() will terminate nevertheless, because it seems the recording stream in Windows is always rate limited.
Message-id: [email protected]
--- audio/audio.c | 12 +++++------- audio/dsoundaudio.c | 2 +- 2 files changed, 6 insertions(+), 8 deletions(-)
audio/audio.c +5 -7
@@ -1491,16 +1491,14 @@ size_t audio_generic_write(HWVoiceOut *hw, void *buf, size_t size)size_t audio_generic_read (HWVoiceIn *hw,void *buf,size_t size) { -size_t src_size, copy_size; -void *src = hw->pcm_ops->get_buffer_in (hw, &src_size); - copy_size =MIN (size, src_size); +void *src = hw->pcm_ops->get_buffer_in (hw, &size); -memcpy (buf, src, copy_size); - hw->pcm_ops->put_buffer_in (hw, src, copy_size); -return copy_size; +memcpy (buf, src, size); + hw->pcm_ops->put_buffer_in (hw, src, size); + +return size; } -static int audio_driver_init (AudioState *s,struct audio_driver *drv,bool msg,Audiodev *dev) {
audio/dsoundaudio.c +1 -1
@@ -540,7 +540,7 @@ static void *dsound_get_buffer_in(HWVoiceIn *hw, size_t *size) } req_size =audio_ring_dist (cpos, hw->pos_emul, hw->size_emul); - req_size =MIN (req_size, hw->size_emul - hw->pos_emul); + req_size =MIN (*size,MIN (req_size, hw->size_emul - hw->pos_emul));if (req_size ==0 ) { *size =0 ;
Signature · 1 line
2.18.2
Peter Maydell
AppliedQuoted 9 lines · Gerd Hoffmann
The following changes since commit
146aa0f104bb3bf88e43c4082a0bfc4bbda4fbd8:Merge remote-tracking branch 'remotes/stefanha/tags/block-pull-request' into staging (2020-04-03 15:30:11 +0100)
are available in the Git repository at:
git://git.kraxel.org/qemutags/fixes-20200407-pull-request
Quoted 8 lines
for you to fetch changes up to
ac2071c3791b67fc7af78b8ceb320c01ca1b5df7:ati-vga: Fix checks in
ati_2d_blt()to avoid crash (2020-04-07 09:25:23 +0200)----------------------------------------------------------------
fixes for 5.0:
- audio: windows (dsound) fixes.
- vga: ati blitter sanity check fixes.
Applied, thanks.
Please update the changelog at https://wiki.qemu.org/ChangeLog/5.0
for any user-visible changes.
-- PMM