1. 28 7月, 2020 2 次提交
  2. 27 7月, 2020 7 次提交
    • L
      virtio-pci: fix virtio_pci_queue_enabled() · 0c9753eb
      Laurent Vivier 提交于
      In legacy mode, virtio_pci_queue_enabled() falls back to
      virtio_queue_enabled() to know if the queue is enabled.
      
      But virtio_queue_enabled() calls again virtio_pci_queue_enabled()
      if k->queue_enabled is set. This ends in a crash after a stack
      overflow.
      
      The problem can be reproduced with
      "-device virtio-net-pci,disable-legacy=off,disable-modern=true
       -net tap,vhost=on"
      
      And a look to the backtrace is very explicit:
      
          ...
          #4  0x000000010029a438 in virtio_queue_enabled ()
          #5  0x0000000100497a9c in virtio_pci_queue_enabled ()
          ...
          #130902 0x000000010029a460 in virtio_queue_enabled ()
          #130903 0x0000000100497a9c in virtio_pci_queue_enabled ()
          #130904 0x000000010029a460 in virtio_queue_enabled ()
          #130905 0x0000000100454a20 in vhost_net_start ()
          ...
      
      This patch fixes the problem by introducing a new function
      for the legacy case and calls it from virtio_pci_queue_enabled().
      It also calls it from virtio_queue_enabled() to avoid code duplication.
      
      Fixes: f19bcdfe ("virtio-pci: implement queue_enabled method")
      Cc: Jason Wang <jasowang@redhat.com>
      Cc: Cindy Lu <lulu@redhat.com>
      CC: Michael S. Tsirkin <mst@redhat.com>
      Signed-off-by: NLaurent Vivier <lvivier@redhat.com>
      Message-Id: <20200727153319.43716-1-lvivier@redhat.com>
      Reviewed-by: NMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
      0c9753eb
    • C
      vhost-vdpa :Fix Coverity CID 1430270 / CID 1420267 · 386494f2
      Cindy Lu 提交于
      In the function vhost_vdpa_dma_map/unmap, The struct msg was not initialized all its fields.
      Signed-off-by: NCindy Lu <lulu@redhat.com>
      Message-Id: <20200710064642.24505-1-lulu@redhat.com>
      Reviewed-by: NPeter Maydell <peter.maydell@linaro.org>
      Acked-by: NJason Wang <jasowang@redhat.com>
      Reviewed-by: NLi Qiang <liq3ea@gmail.com>
      Cc: qemu-stable@nongnu.org
      Reviewed-by: NMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
      386494f2
    • R
      Fix vhost-user buffer over-read on ram hot-unplug · 4fdecf05
      Raphael Norwitz 提交于
      The VHOST_USER_PROTOCOL_F_CONFIGURE_MEM_SLOTS vhost-user protocol
      feature introduced a shadow-table, used by the backend to dynamically
      determine how a vdev's memory regions have changed since the last
      vhost_user_set_mem_table() call. On hot-remove, a memmove() operation
      is used to overwrite the removed shadow region descriptor(s). The size
      parameter of this memmove was off by 1 such that if a VM with a backend
      supporting the VHOST_USER_PROTOCOL_F_CONFIGURE_MEM_SLOTS filled it's
      shadow-table (by performing the maximum number of supported hot-add
      operatons) and attempted to remove the last region, Qemu would read an
      out of bounds value and potentially crash.
      
      This change fixes the memmove() bounds such that this erroneous read can
      never happen.
      Signed-off-by: NPeter Turschmid <peter.turschm@nutanix.com>
      Signed-off-by: NRaphael Norwitz <raphael.norwitz@nutanix.com>
      Message-Id: <1594799958-31356-1-git-send-email-raphael.norwitz@nutanix.com>
      Fixes: f1aeb14b ("Transmit vhost-user memory regions individually")
      Reviewed-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      Cc: qemu-stable@nongnu.org
      Reviewed-by: NMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
      4fdecf05
    • H
      hw/pci-host: save/restore pci host config register · 2ebc2121
      Hogan Wang 提交于
      The pci host config register is used to save PCI address for
      read/write config data. If guest writes a value to config register,
      and then QEMU pauses the vcpu to migrate, after the migration, the guest
      will continue to write pci config data, and the write data will be ignored
      because of new qemu process losing the config register state.
      
      To trigger the bug:
      1. guest is booting in seabios.
      2. guest enables the SMRAM in seabios:piix4_apmc_smm_setup, and then
         expects to disable the SMRAM by pci_config_writeb.
      3. after guest writes the pci host config register, QEMU pauses vcpu
         to finish migration.
      4. guest write of config data(0x0A) fails to disable the SMRAM because
         the config register state is lost.
      5. guest continues to boot and crashes in ipxe option ROM due to SMRAM
         in enabled state.
      
      Example Reproducer:
      
      step 1. Make modifications to seabios and qemu for increase reproduction
      efficiency, write 0xf0 to 0x402 port notify qemu to stop vcpu after
      0x0cf8 port wrote i440 configure register. qemu stop vcpu when catch
      0x402 port wrote 0xf0.
      
      seabios:/src/hw/pci.c
      @@ -52,6 +52,11 @@ void pci_config_writeb(u16 bdf, u32 addr, u8 val)
               writeb(mmconfig_addr(bdf, addr), val);
           } else {
               outl(ioconfig_cmd(bdf, addr), PORT_PCI_CMD);
      +       if (bdf == 0 && addr == 0x72 && val == 0xa) {
      +            dprintf(1, "stop vcpu\n");
      +            outb(0xf0, 0x402); // notify qemu to stop vcpu
      +            dprintf(1, "resume vcpu\n");
      +        }
               outb(val, PORT_PCI_DATA + (addr & 3));
           }
       }
      
      qemu:hw/char/debugcon.c
      @@ -60,6 +61,9 @@ static void debugcon_ioport_write(void *opaque, hwaddr addr, uint64_t val,
           printf(" [debugcon: write addr=0x%04" HWADDR_PRIx " val=0x%02" PRIx64 "]\n", addr, val);
       #endif
      
      +    if (ch == 0xf0) {
      +        vm_stop(RUN_STATE_PAUSED);
      +    }
           /* XXX this blocks entire thread. Rewrite to use
            * qemu_chr_fe_write and background I/O callbacks */
           qemu_chr_fe_write_all(&s->chr, &ch, 1);
      
      step 2. start vm1 by the following command line, and then vm stopped.
      $ qemu-system-x86_64 -machine pc-i440fx-5.0,accel=kvm\
       -netdev tap,ifname=tap-test,id=hostnet0,vhost=on,downscript=no,script=no\
       -device virtio-net-pci,netdev=hostnet0,id=net0,bus=pci.0,addr=0x13,bootindex=3\
       -device cirrus-vga,id=video0,vgamem_mb=16,bus=pci.0,addr=0x2\
       -chardev file,id=seabios,path=/var/log/test.seabios,append=on\
       -device isa-debugcon,iobase=0x402,chardev=seabios\
       -monitor stdio
      
      step 3. start vm2 to accept vm1 state.
      $ qemu-system-x86_64 -machine pc-i440fx-5.0,accel=kvm\
       -netdev tap,ifname=tap-test1,id=hostnet0,vhost=on,downscript=no,script=no\
       -device virtio-net-pci,netdev=hostnet0,id=net0,bus=pci.0,addr=0x13,bootindex=3\
       -device cirrus-vga,id=video0,vgamem_mb=16,bus=pci.0,addr=0x2\
       -chardev file,id=seabios,path=/var/log/test.seabios,append=on\
       -device isa-debugcon,iobase=0x402,chardev=seabios\
       -monitor stdio \
       -incoming tcp:127.0.0.1:8000
      
      step 4. execute the following qmp command in vm1 to migrate.
      (qemu) migrate tcp:127.0.0.1:8000
      
      step 5. execute the following qmp command in vm2 to resume vcpu.
      (qemu) cont
      Before this patch, we get KVM "emulation failure" error on vm2.
      This patch fixes it.
      
      Cc: qemu-stable@nongnu.org
      Signed-off-by: NHogan Wang <hogan.wang@huawei.com>
      Message-Id: <20200727084621.3279-1-hogan.wang@huawei.com>
      Reported-by: N"Dr. David Alan Gilbert" <dgilbert@redhat.com>
      Reviewed-by: NMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
      2ebc2121
    • D
      virtio-mem-pci: force virtio version 1 · c22aba19
      David Hildenbrand 提交于
      Trying to run simple virtio-mem-pci examples currently fails with
          qemu-system-x86_64: -device virtio-mem-pci,id=vm0,memdev=mem0,node=0,
          requested-size=300M: device is modern-only, use disable-legacy=on
      due to the added safety checks in 9b3a35ec ("virtio: verify that legacy
      support is not accidentally on").
      
      As noted by Conny, we have to force virtio version 1. While at it, use
      qdev_realize() to set the parent bus and realize - like most other
      virtio-*-pci implementations.
      
      Fixes: 0b9a2443 ("virtio-pci: Proxy for virtio-mem")
      Reviewed-by: NCornelia Huck <cohuck@redhat.com>
      Cc: Cornelia Huck <cohuck@redhat.com>
      Cc: "Michael S. Tsirkin" <mst@redhat.com>
      Signed-off-by: NDavid Hildenbrand <david@redhat.com>
      Message-Id: <20200727115905.129397-1-david@redhat.com>
      Cc: qemu-stable@nongnu.org
      Reviewed-by: NMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
      c22aba19
    • K
      semihosting: don't send the trailing '\0' · 7d2d6522
      KONRAD Frederic 提交于
      Don't send the trailing 0 from the string.
      Signed-off-by: NKONRAD Frederic <frederic.konrad@adacore.com>
      Signed-off-by: NAlex Bennée <alex.bennee@linaro.org>
      Reviewed-by: NPhilippe Mathieu-Daudé <philmd@redhat.com>
      Reviewed-by: NRichard Henderson <richard.henderson@linaro.org>
      Message-Id: <1592215252-26742-2-git-send-email-frederic.konrad@adacore.com>
      Message-Id: <20200724064509.331-4-alex.bennee@linaro.org>
      7d2d6522
    • L
      pseries: fix kvmppc_set_fwnmi() · aef92d87
      Laurent Vivier 提交于
      QEMU issues the ioctl(KVM_CAP_PPC_FWNMI) on the first vCPU.
      
      If the first vCPU is currently running, the vCPU mutex is held
      and the ioctl() cannot be done and waits until the mutex is released.
      This never happens and the VM is stuck.
      
      To avoid this deadlock, issue the ioctl on the same vCPU doing the
      RTAS call.
      
      The problem can be reproduced by booting a guest with several vCPUs
      (the probability to have the problem is (n - 1) / n,  n = # of CPUs),
      and then by triggering a kernel crash with "echo c >/proc/sysrq-trigger".
      
      On the reboot, the kernel hangs after:
      
      ...
      [    0.000000] -----------------------------------------------------
      [    0.000000] ppc64_pft_size    = 0x0
      [    0.000000] phys_mem_size     = 0x48000000
      [    0.000000] dcache_bsize      = 0x80
      [    0.000000] icache_bsize      = 0x80
      [    0.000000] cpu_features      = 0x0001c06f8f4f91a7
      [    0.000000]   possible        = 0x0003fbffcf5fb1a7
      [    0.000000]   always          = 0x00000003800081a1
      [    0.000000] cpu_user_features = 0xdc0065c2 0xaee00000
      [    0.000000] mmu_features      = 0x3c006041
      [    0.000000] firmware_features = 0x00000085455a445f
      [    0.000000] physical_start    = 0x8000000
      [    0.000000] -----------------------------------------------------
      [    0.000000] numa:   NODE_DATA [mem 0x47f33c80-0x47f3ffff]
      
      Fixes: ec010c00 ("ppc/spapr: KVM FWNMI should not be enabled until guest requests it")
      Cc: npiggin@gmail.com
      Signed-off-by: NLaurent Vivier <lvivier@redhat.com>
      Message-Id: <20200724083533.281700-1-lvivier@redhat.com>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      aef92d87
  3. 24 7月, 2020 6 次提交
  4. 23 7月, 2020 2 次提交
  5. 22 7月, 2020 9 次提交
  6. 21 7月, 2020 10 次提交
  7. 20 7月, 2020 4 次提交