mirror of https://github.com/xemu-project/xemu.git
esp: don't overflow cmdfifo if TC is larger than the cmdfifo size
If a guest transfers the message out/command phase data using DMA with a TC that is larger than the cmdfifo size then the cmdfifo overflows triggering an assert. Limit the size of the transfer to the free space available in cmdfifo. Buglink: https://bugs.launchpad.net/qemu/+bug/1919036 Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Tested-by: Alexander Bulekov <alxndr@bu.edu> Message-Id: <20210407195801.685-10-mark.cave-ayland@ilande.co.uk>
This commit is contained in:
parent
fbc6510e33
commit
0ebb5fd805
|
@ -578,6 +578,7 @@ static void esp_do_dma(ESPState *s)
|
||||||
cmdlen = fifo8_num_used(&s->cmdfifo);
|
cmdlen = fifo8_num_used(&s->cmdfifo);
|
||||||
trace_esp_do_dma(cmdlen, len);
|
trace_esp_do_dma(cmdlen, len);
|
||||||
if (s->dma_memory_read) {
|
if (s->dma_memory_read) {
|
||||||
|
len = MIN(len, fifo8_num_free(&s->cmdfifo));
|
||||||
s->dma_memory_read(s->dma_opaque, buf, len);
|
s->dma_memory_read(s->dma_opaque, buf, len);
|
||||||
fifo8_push_all(&s->cmdfifo, buf, len);
|
fifo8_push_all(&s->cmdfifo, buf, len);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue