1 From 4aa79a8818711d475bd79b906cd7d060d4e8a441 Mon Sep 17 00:00:00 2001
2 From: Gerd Hoffmann <kraxel@redhat.com>
3 Date: Mon, 30 May 2016 09:09:18 +0200
4 Subject: [PATCH 4/9] vmsvga: move fifo sanity checks to vmsvga_fifo_length
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
9 Sanity checks are applied when the fifo is enabled by the guest
10 (SVGA_REG_CONFIG_DONE write). Which doesn't help much if the guest
11 changes the fifo registers afterwards. Move the checks to
12 vmsvga_fifo_length so they are done each time qemu is about to read
16 Cc: P J P <ppandit@redhat.com>
17 Reported-by: 李强 <liqiang6-s@360.cn>
18 Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
20 hw/display/vmware_vga.c | 28 +++++++++++++++-------------
21 1 file changed, 15 insertions(+), 13 deletions(-)
23 diff --git a/hw/display/vmware_vga.c b/hw/display/vmware_vga.c
24 index 9354037..3ce1717 100644
25 --- a/hw/display/vmware_vga.c
26 +++ b/hw/display/vmware_vga.c
27 @@ -553,6 +553,21 @@ static inline int vmsvga_fifo_length(struct vmsvga_state_s *s)
28 if (!s->config || !s->enable) {
32 + /* Check range and alignment. */
33 + if ((CMD(min) | CMD(max) | CMD(next_cmd) | CMD(stop)) & 3) {
36 + if (CMD(min) < (uint8_t *) s->cmd->fifo - (uint8_t *) s->fifo) {
39 + if (CMD(max) > SVGA_FIFO_SIZE) {
42 + if (CMD(max) < CMD(min) + 10 * 1024) {
46 num = CMD(next_cmd) - CMD(stop);
48 num += CMD(max) - CMD(min);
49 @@ -1003,19 +1018,6 @@ static void vmsvga_value_write(void *opaque, uint32_t address, uint32_t value)
50 case SVGA_REG_CONFIG_DONE:
52 s->fifo = (uint32_t *) s->fifo_ptr;
53 - /* Check range and alignment. */
54 - if ((CMD(min) | CMD(max) | CMD(next_cmd) | CMD(stop)) & 3) {
57 - if (CMD(min) < (uint8_t *) s->cmd->fifo - (uint8_t *) s->fifo) {
60 - if (CMD(max) > SVGA_FIFO_SIZE) {
63 - if (CMD(max) < CMD(min) + 10 * 1024) {
66 vga_dirty_log_stop(&s->vga);