Skip to content
Snippets Groups Projects
  1. May 25, 2022
  2. May 19, 2022
    • Richard Henderson's avatar
      target/arm: Use FIELD definitions for CPACR, CPTR_ELx · fab8ad39
      Richard Henderson authored
      
      We had a few CPTR_* bits defined, but missed quite a few.
      Complete all of the fields up to ARMv9.2.
      Use FIELD_EX64 instead of manual extract32.
      
      Reviewed-by: default avatarPeter Maydell <peter.maydell@linaro.org>
      Signed-off-by: default avatarRichard Henderson <richard.henderson@linaro.org>
      Message-id: 20220517054850.177016-3-richard.henderson@linaro.org
      Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
      fab8ad39
    • Peter Maydell's avatar
      ptimer: Rename PTIMER_POLICY_DEFAULT to PTIMER_POLICY_LEGACY · 9598c1bb
      Peter Maydell authored
      
      The traditional ptimer behaviour includes a collection of weird edge
      case behaviours.  In 2016 we improved the ptimer implementation to
      fix these and generally make the behaviour more flexible, with
      ptimers opting in to the new behaviour by passing an appropriate set
      of policy flags to ptimer_init().  For backwards-compatibility, we
      defined PTIMER_POLICY_DEFAULT (which sets no flags) to give the old
      weird behaviour.
      
      This turns out to be a poor choice of name, because people writing
      new devices which use ptimers are misled into thinking that the
      default is probably a sensible choice of flags, when in fact it is
      almost always not what you want.  Rename PTIMER_POLICY_DEFAULT to
      PTIMER_POLICY_LEGACY and beef up the comment to more clearly say that
      new devices should not be using it.
      
      The code-change part of this commit was produced by
        sed -i -e 's/PTIMER_POLICY_DEFAULT/PTIMER_POLICY_LEGACY/g' $(git grep -l PTIMER_POLICY_DEFAULT)
      with the exception of a test name string change in
      tests/unit/ptimer-test.c which was added manually.
      
      Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
      Reviewed-by: default avatarFrancisco Iglesias <francisco.iglesias@amd.com>
      Reviewed-by: default avatarRichard Henderson <richard.henderson@linaro.org>
      Message-id: 20220516103058.162280-1-peter.maydell@linaro.org
      9598c1bb
    • Peter Maydell's avatar
      hw/arm/virt: Drop #size-cells and #address-cells from gpio-keys dtb node · afdcbddc
      Peter Maydell authored
      
      The virt board generates a gpio-keys node in the dtb, but it
      incorrectly gives this node #size-cells and #address-cells
      properties. If you dump the dtb with 'machine dumpdtb=file.dtb'
      and run it through dtc, dtc will warn about this:
      
      Warning (avoid_unnecessary_addr_size): /gpio-keys: unnecessary #address-cells/#size-cells without "ranges" or child "reg" property
      
      Remove the bogus properties.
      
      Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
      Reviewed-by: default avatarRichard Henderson <richard.henderson@linaro.org>
      Message-id: 20220513131316.4081539-3-peter.maydell@linaro.org
      afdcbddc
    • Peter Maydell's avatar
      hw/arm/virt: Fix incorrect non-secure flash dtb node name · e8ca920f
      Peter Maydell authored
      
      In the virt board with secure=on we put two nodes in the dtb
      for flash devices: one for the secure-only flash, and one
      for the non-secure flash. We get the reg properties for these
      correct, but in the DT node name, which by convention includes
      the base address of devices, we used the wrong address. Fix it.
      
      Spotted by dtc, which will complain
      Warning (unique_unit_address): /flash@0: duplicate unit-address (also used in node /secflash@0)
      if you dump the dtb from QEMU with -machine dumpdtb=file.dtb
      and then decompile it with dtc.
      
      Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
      Reviewed-by: default avatarRichard Henderson <richard.henderson@linaro.org>
      Message-id: 20220513131316.4081539-2-peter.maydell@linaro.org
      e8ca920f
    • Philippe Mathieu-Daudé's avatar
      hw/adc/zynq-xadc: Use qemu_irq typedef · 6e76d35f
      Philippe Mathieu-Daudé authored
      
      Except hw/core/irq.c which implements the forward-declared opaque
      qemu_irq structure, hw/adc/zynq-xadc.{c,h} are the only files not
      using the typedef. Fix this single exception.
      
      Signed-off-by: default avatarPhilippe Mathieu-Daudé <f4bug@amsat.org>
      Reviewed-by: default avatarBernhard Beschow <shentey@gmail.com>
      Message-id: 20220509202035.50335-1-philippe.mathieu.daude@gmail.com
      Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
      6e76d35f
    • Peter Maydell's avatar
      hw/intc/arm_gicv3: Provide ich_num_aprs() · 5d55f827
      Peter Maydell authored
      
      We previously open-coded the expression for the number of virtual APR
      registers and the assertion that it was not going to cause us to
      overflow the cs->ich_apr[] array.  Factor this out into a new
      ich_num_aprs() function, for consistency with the icc_num_aprs()
      function we just added for the physical APR handling.
      
      Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
      Reviewed-by: default avatarRichard Henderson <richard.henderson@linaro.org>
      Message-id: 20220512151457.3899052-7-peter.maydell@linaro.org
      Message-id: 20220506162129.2896966-6-peter.maydell@linaro.org
      5d55f827
    • Peter Maydell's avatar
      hw/intc/arm_gicv3: Use correct number of priority bits for the CPU · 39f29e59
      Peter Maydell authored
      
      Make the GICv3 set its number of bits of physical priority from the
      implementation-specific value provided in the CPU state struct, in
      the same way we already do for virtual priority bits.  Because this
      would be a migration compatibility break, we provide a property
      force-8-bit-prio which is enabled for 7.0 and earlier versioned board
      models to retain the legacy "always use 8 bits" behaviour.
      
      Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
      Reviewed-by: default avatarRichard Henderson <richard.henderson@linaro.org>
      Message-id: 20220512151457.3899052-6-peter.maydell@linaro.org
      Message-id: 20220506162129.2896966-5-peter.maydell@linaro.org
      39f29e59
    • Peter Maydell's avatar
      hw/intc/arm_gicv3: Support configurable number of physical priority bits · 84597ff3
      Peter Maydell authored
      
      The GICv3 code has always supported a configurable number of virtual
      priority and preemption bits, but our implementation currently
      hardcodes the number of physical priority bits at 8.  This is not
      what most hardware implementations provide; for instance the
      Cortex-A53 provides only 5 bits of physical priority.
      
      Make the number of physical priority/preemption bits driven by fields
      in the GICv3CPUState, the way that we already do for virtual
      priority/preemption bits.  We set cs->pribits to 8, so there is no
      behavioural change in this commit.  A following commit will add the
      machinery for CPUs to set this to the correct value for their
      implementation.
      
      Note that changing the number of priority bits would be a migration
      compatibility break, because the semantics of the icc_apr[][] array
      changes.
      
      Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
      Reviewed-by: default avatarRichard Henderson <richard.henderson@linaro.org>
      Message-id: 20220512151457.3899052-5-peter.maydell@linaro.org
      Message-id: 20220506162129.2896966-4-peter.maydell@linaro.org
      84597ff3
    • Peter Maydell's avatar
      hw/intc/arm_gicv3_kvm.c: Stop using GIC_MIN_BPR constant · 9774c0f7
      Peter Maydell authored
      
      The GIC_MIN_BPR constant defines the minimum BPR value that the TCG
      emulated GICv3 supports.  We're currently using this also as the
      value we reset the KVM GICv3 ICC_BPR registers to, but this is only
      right by accident.
      
      We want to make the emulated GICv3 use a configurable number of
      priority bits, which means that GIC_MIN_BPR will no longer be a
      constant.  Replace the uses in the KVM reset code with literal 0,
      plus a constant explaining why this is reasonable.
      
      Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
      Reviewed-by: default avatarRichard Henderson <richard.henderson@linaro.org>
      Message-id: 20220512151457.3899052-4-peter.maydell@linaro.org
      Message-id: 20220506162129.2896966-3-peter.maydell@linaro.org
      9774c0f7
    • Peter Maydell's avatar
      hw/intc/arm_gicv3: report correct PRIbits field in ICV_CTLR_EL1 · 9c6f933e
      Peter Maydell authored
      
      As noted in the comment, the PRIbits field in ICV_CTLR_EL1 is
      supposed to match the ICH_VTR_EL2 PRIbits setting; that is, it is the
      virtual priority bit setting, not the physical priority bit setting.
      (For QEMU currently we always implement 8 bits of physical priority,
      so the PRIbits field was previously 7, since it is defined to be
      "priority bits - 1".)
      
      Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
      Reviewed-by: default avatarRichard Henderson <richard.henderson@linaro.org>
      Message-id: 20220512151457.3899052-3-peter.maydell@linaro.org
      Message-id: 20220506162129.2896966-2-peter.maydell@linaro.org
      9c6f933e
    • Peter Maydell's avatar
      hw/intc/arm_gicv3_cpuif: Handle CPUs that don't specify GICv3 parameters · 272f75e8
      Peter Maydell authored
      
      We allow a GICv3 to be connected to any CPU, but we don't do anything
      to handle the case where the CPU type doesn't in hardware have a
      GICv3 CPU interface and so the various GIC configuration fields
      (gic_num_lrs, vprebits, vpribits) are not specified.
      
      The current behaviour is that we will add the EL1 CPU interface
      registers, but will not put in the EL2 CPU interface registers, even
      if the CPU has EL2, which will leave the GIC in a broken state and
      probably result in the guest crashing as it tries to set it up.  This
      only affects the virt board when using the cortex-a15 or cortex-a7
      CPU types (both 32-bit) with -machine gic-version=3 (or 'max')
      and -machine virtualization=on.
      
      Instead of failing to set up the EL2 registers, if the CPU doesn't
      define the GIC configuration set it to a reasonable default, matching
      the standard configuration for most Arm CPUs.
      
      Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
      Reviewed-by: default avatarRichard Henderson <richard.henderson@linaro.org>
      Message-id: 20220512151457.3899052-2-peter.maydell@linaro.org
      272f75e8
  3. May 17, 2022
    • Helge Deller's avatar
      tulip: Assign default MAC address if not specified · 052c2579
      Helge Deller authored
      
      The MAC of the tulip card is stored in the EEPROM and at startup
      tulip_fill_eeprom() is called to initialize the EEPROM with the MAC
      address given on the command line, e.g.:
          -device tulip,mac=00:11:22:33:44:55
      
      In case the mac address was not given on the command line,
      tulip_fill_eeprom() initializes the MAC in EEPROM with 00:00:00:00:00:00
      which breaks e.g. a HP-UX guest.
      
      Fix this problem by moving qemu_macaddr_default_if_unset() a few lines
      up, so that a default mac address is assigned before tulip_fill_eeprom()
      initializes the EEPROM.
      
      Signed-off-by: default avatarHelge Deller <deller@gmx.de>
      Reviewed-by: default avatarPhilippe Mathieu-Daudé <f4bug@amsat.org>
      Signed-off-by: default avatarJason Wang <jasowang@redhat.com>
      052c2579
  4. May 16, 2022
    • Si-Wei Liu's avatar
      virtio-net: don't handle mq request in userspace handler for vhost-vdpa · 2a7888cc
      Si-Wei Liu authored
      
      virtio_queue_host_notifier_read() tends to read pending event
      left behind on ioeventfd in the vhost_net_stop() path, and
      attempts to handle outstanding kicks from userspace vq handler.
      However, in the ctrl_vq handler, virtio_net_handle_mq() has a
      recursive call into virtio_net_set_status(), which may lead to
      segmentation fault as shown in below stack trace:
      
      0  0x000055f800df1780 in qdev_get_parent_bus (dev=0x0) at ../hw/core/qdev.c:376
      1  0x000055f800c68ad8 in virtio_bus_device_iommu_enabled (vdev=vdev@entry=0x0) at ../hw/virtio/virtio-bus.c:331
      2  0x000055f800d70d7f in vhost_memory_unmap (dev=<optimized out>) at ../hw/virtio/vhost.c:318
      3  0x000055f800d70d7f in vhost_memory_unmap (dev=<optimized out>, buffer=0x7fc19bec5240, len=2052, is_write=1, access_len=2052) at ../hw/virtio/vhost.c:336
      4  0x000055f800d71867 in vhost_virtqueue_stop (dev=dev@entry=0x55f8037ccc30, vdev=vdev@entry=0x55f8044ec590, vq=0x55f8037cceb0, idx=0) at ../hw/virtio/vhost.c:1241
      5  0x000055f800d7406c in vhost_dev_stop (hdev=hdev@entry=0x55f8037ccc30, vdev=vdev@entry=0x55f8044ec590) at ../hw/virtio/vhost.c:1839
      6  0x000055f800bf00a7 in vhost_net_stop_one (net=0x55f8037ccc30, dev=0x55f8044ec590) at ../hw/net/vhost_net.c:315
      7  0x000055f800bf0678 in vhost_net_stop (dev=dev@entry=0x55f8044ec590, ncs=0x55f80452bae0, data_queue_pairs=data_queue_pairs@entry=7, cvq=cvq@entry=1)
         at ../hw/net/vhost_net.c:423
      8  0x000055f800d4e628 in virtio_net_set_status (status=<optimized out>, n=0x55f8044ec590) at ../hw/net/virtio-net.c:296
      9  0x000055f800d4e628 in virtio_net_set_status (vdev=vdev@entry=0x55f8044ec590, status=15 '\017') at ../hw/net/virtio-net.c:370
      10 0x000055f800d534d8 in virtio_net_handle_ctrl (iov_cnt=<optimized out>, iov=<optimized out>, cmd=0 '\000', n=0x55f8044ec590) at ../hw/net/virtio-net.c:1408
      11 0x000055f800d534d8 in virtio_net_handle_ctrl (vdev=0x55f8044ec590, vq=0x7fc1a7e888d0) at ../hw/net/virtio-net.c:1452
      12 0x000055f800d69f37 in virtio_queue_host_notifier_read (vq=0x7fc1a7e888d0) at ../hw/virtio/virtio.c:2331
      13 0x000055f800d69f37 in virtio_queue_host_notifier_read (n=n@entry=0x7fc1a7e8894c) at ../hw/virtio/virtio.c:3575
      14 0x000055f800c688e6 in virtio_bus_cleanup_host_notifier (bus=<optimized out>, n=n@entry=14) at ../hw/virtio/virtio-bus.c:312
      15 0x000055f800d73106 in vhost_dev_disable_notifiers (hdev=hdev@entry=0x55f8035b51b0, vdev=vdev@entry=0x55f8044ec590)
         at ../../../include/hw/virtio/virtio-bus.h:35
      16 0x000055f800bf00b2 in vhost_net_stop_one (net=0x55f8035b51b0, dev=0x55f8044ec590) at ../hw/net/vhost_net.c:316
      17 0x000055f800bf0678 in vhost_net_stop (dev=dev@entry=0x55f8044ec590, ncs=0x55f80452bae0, data_queue_pairs=data_queue_pairs@entry=7, cvq=cvq@entry=1)
         at ../hw/net/vhost_net.c:423
      18 0x000055f800d4e628 in virtio_net_set_status (status=<optimized out>, n=0x55f8044ec590) at ../hw/net/virtio-net.c:296
      19 0x000055f800d4e628 in virtio_net_set_status (vdev=0x55f8044ec590, status=15 '\017') at ../hw/net/virtio-net.c:370
      20 0x000055f800d6c4b2 in virtio_set_status (vdev=0x55f8044ec590, val=<optimized out>) at ../hw/virtio/virtio.c:1945
      21 0x000055f800d11d9d in vm_state_notify (running=running@entry=false, state=state@entry=RUN_STATE_SHUTDOWN) at ../softmmu/runstate.c:333
      22 0x000055f800d04e7a in do_vm_stop (state=state@entry=RUN_STATE_SHUTDOWN, send_stop=send_stop@entry=false) at ../softmmu/cpus.c:262
      23 0x000055f800d04e99 in vm_shutdown () at ../softmmu/cpus.c:280
      24 0x000055f800d126af in qemu_cleanup () at ../softmmu/runstate.c:812
      25 0x000055f800ad5b13 in main (argc=<optimized out>, argv=<optimized out>, envp=<optimized out>) at ../softmmu/main.c:51
      
      For now, temporarily disable handling MQ request from the ctrl_vq
      userspace hanlder to avoid the recursive virtio_net_set_status()
      call. Some rework is needed to allow changing the number of
      queues without going through a full virtio_net_set_status cycle,
      particularly for vhost-vdpa backend.
      
      This patch will need to be reverted as soon as future patches of
      having the change of #queues handled in userspace is merged.
      
      Fixes: 40237840 ("vhost-vdpa: multiqueue support")
      Signed-off-by: default avatarSi-Wei Liu <si-wei.liu@oracle.com>
      Acked-by: default avatarJason Wang <jasowang@redhat.com>
      Message-Id: <1651890498-24478-8-git-send-email-si-wei.liu@oracle.com>
      Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      2a7888cc
    • Si-Wei Liu's avatar
      vhost-vdpa: change name and polarity for vhost_vdpa_one_time_request() · d71b0609
      Si-Wei Liu authored
      
      The name vhost_vdpa_one_time_request() was confusing. No
      matter whatever it returns, its typical occurrence had
      always been at requests that only need to be applied once.
      And the name didn't suggest what it actually checks for.
      Change it to vhost_vdpa_first_dev() with polarity flipped
      for better readibility of code. That way it is able to
      reflect what the check is really about.
      
      This call is applicable to request which performs operation
      only once, before queues are set up, and usually at the beginning
      of the caller function. Document the requirement for it in place.
      
      Signed-off-by: default avatarSi-Wei Liu <si-wei.liu@oracle.com>
      Message-Id: <1651890498-24478-7-git-send-email-si-wei.liu@oracle.com>
      Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Reviewed-by: default avatarStefano Garzarella <sgarzare@redhat.com>
      Acked-by: default avatarJason Wang <jasowang@redhat.com>
      d71b0609
    • Si-Wei Liu's avatar
      vhost-vdpa: backend feature should set only once · 6aee7e42
      Si-Wei Liu authored
      
      The vhost_vdpa_one_time_request() branch in
      vhost_vdpa_set_backend_cap() incorrectly sends down
      ioctls on vhost_dev with non-zero index. This may
      end up with multiple VHOST_SET_BACKEND_FEATURES
      ioctl calls sent down on the vhost-vdpa fd that is
      shared between all these vhost_dev's.
      
      To fix it, send down ioctl only once via the first
      vhost_dev with index 0. Toggle the polarity of the
      vhost_vdpa_one_time_request() test should do the
      trick.
      
      Fixes: 4d191cfd ("vhost-vdpa: classify one time request")
      Signed-off-by: default avatarSi-Wei Liu <si-wei.liu@oracle.com>
      Reviewed-by: default avatarStefano Garzarella <sgarzare@redhat.com>
      Acked-by: default avatarJason Wang <jasowang@redhat.com>
      Acked-by: default avatarEugenio Pérez <eperezma@redhat.com>
      Message-Id: <1651890498-24478-6-git-send-email-si-wei.liu@oracle.com>
      Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      6aee7e42
    • Si-Wei Liu's avatar
      vhost-net: fix improper cleanup in vhost_net_start · 6f3910b5
      Si-Wei Liu authored
      
      vhost_net_start() missed a corresponding stop_one() upon error from
      vhost_set_vring_enable(). While at it, make the error handling for
      err_start more robust. No real issue was found due to this though.
      
      Signed-off-by: default avatarSi-Wei Liu <si-wei.liu@oracle.com>
      Acked-by: default avatarJason Wang <jasowang@redhat.com>
      Message-Id: <1651890498-24478-5-git-send-email-si-wei.liu@oracle.com>
      Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      6f3910b5
    • Si-Wei Liu's avatar
      virtio-net: align ctrl_vq index for non-mq guest for vhost_vdpa · 68b0a639
      Si-Wei Liu authored
      
      With MQ enabled vdpa device and non-MQ supporting guest e.g.
      booting vdpa with mq=on over OVMF of single vqp, below assert
      failure is seen:
      
      ../hw/virtio/vhost-vdpa.c:560: vhost_vdpa_get_vq_index: Assertion `idx >= dev->vq_index && idx < dev->vq_index + dev->nvqs' failed.
      
      0  0x00007f8ce3ff3387 in raise () at /lib64/libc.so.6
      1  0x00007f8ce3ff4a78 in abort () at /lib64/libc.so.6
      2  0x00007f8ce3fec1a6 in __assert_fail_base () at /lib64/libc.so.6
      3  0x00007f8ce3fec252 in  () at /lib64/libc.so.6
      4  0x0000558f52d79421 in vhost_vdpa_get_vq_index (dev=<optimized out>, idx=<optimized out>) at ../hw/virtio/vhost-vdpa.c:563
      5  0x0000558f52d79421 in vhost_vdpa_get_vq_index (dev=<optimized out>, idx=<optimized out>) at ../hw/virtio/vhost-vdpa.c:558
      6  0x0000558f52d7329a in vhost_virtqueue_mask (hdev=0x558f55c01800, vdev=0x558f568f91f0, n=2, mask=<optimized out>) at ../hw/virtio/vhost.c:1557
      7  0x0000558f52c6b89a in virtio_pci_set_guest_notifier (d=d@entry=0x558f568f0f60, n=n@entry=2, assign=assign@entry=true, with_irqfd=with_irqfd@entry=false)
         at ../hw/virtio/virtio-pci.c:974
      8  0x0000558f52c6c0d8 in virtio_pci_set_guest_notifiers (d=0x558f568f0f60, nvqs=3, assign=true) at ../hw/virtio/virtio-pci.c:1019
      9  0x0000558f52bf091d in vhost_net_start (dev=dev@entry=0x558f568f91f0, ncs=0x558f56937cd0, data_queue_pairs=data_queue_pairs@entry=1, cvq=cvq@entry=1)
         at ../hw/net/vhost_net.c:361
      10 0x0000558f52d4e5e7 in virtio_net_set_status (status=<optimized out>, n=0x558f568f91f0) at ../hw/net/virtio-net.c:289
      11 0x0000558f52d4e5e7 in virtio_net_set_status (vdev=0x558f568f91f0, status=15 '\017') at ../hw/net/virtio-net.c:370
      12 0x0000558f52d6c4b2 in virtio_set_status (vdev=vdev@entry=0x558f568f91f0, val=val@entry=15 '\017') at ../hw/virtio/virtio.c:1945
      13 0x0000558f52c69eff in virtio_pci_common_write (opaque=0x558f568f0f60, addr=<optimized out>, val=<optimized out>, size=<optimized out>) at ../hw/virtio/virtio-pci.c:1292
      14 0x0000558f52d15d6e in memory_region_write_accessor (mr=0x558f568f19d0, addr=20, value=<optimized out>, size=1, shift=<optimized out>, mask=<optimized out>, attrs=...)
         at ../softmmu/memory.c:492
      15 0x0000558f52d127de in access_with_adjusted_size (addr=addr@entry=20, value=value@entry=0x7f8cdbffe748, size=size@entry=1, access_size_min=<optimized out>, access_size_max=<optimized out>, access_fn=0x558f52d15cf0 <memory_region_write_accessor>, mr=0x558f568f19d0, attrs=...) at ../softmmu/memory.c:554
      16 0x0000558f52d157ef in memory_region_dispatch_write (mr=mr@entry=0x558f568f19d0, addr=20, data=<optimized out>, op=<optimized out>, attrs=attrs@entry=...)
         at ../softmmu/memory.c:1504
      17 0x0000558f52d078e7 in flatview_write_continue (fv=fv@entry=0x7f8accbc3b90, addr=addr@entry=103079215124, attrs=..., ptr=ptr@entry=0x7f8ce6300028, len=len@entry=1, addr1=<optimized out>, l=<optimized out>, mr=0x558f568f19d0) at /home/opc/qemu-upstream/include/qemu/host-utils.h:165
      18 0x0000558f52d07b06 in flatview_write (fv=0x7f8accbc3b90, addr=103079215124, attrs=..., buf=0x7f8ce6300028, len=1) at ../softmmu/physmem.c:2822
      19 0x0000558f52d0b36b in address_space_write (as=<optimized out>, addr=<optimized out>, attrs=..., buf=buf@entry=0x7f8ce6300028, len=<optimized out>)
         at ../softmmu/physmem.c:2914
      20 0x0000558f52d0b3da in address_space_rw (as=<optimized out>, addr=<optimized out>, attrs=...,
         attrs@entry=..., buf=buf@entry=0x7f8ce6300028, len=<optimized out>, is_write=<optimized out>) at ../softmmu/physmem.c:2924
      21 0x0000558f52dced09 in kvm_cpu_exec (cpu=cpu@entry=0x558f55c2da60) at ../accel/kvm/kvm-all.c:2903
      22 0x0000558f52dcfabd in kvm_vcpu_thread_fn (arg=arg@entry=0x558f55c2da60) at ../accel/kvm/kvm-accel-ops.c:49
      23 0x0000558f52f9f04a in qemu_thread_start (args=<optimized out>) at ../util/qemu-thread-posix.c:556
      24 0x00007f8ce4392ea5 in start_thread () at /lib64/libpthread.so.0
      25 0x00007f8ce40bb9fd in clone () at /lib64/libc.so.6
      
      The cause for the assert failure is due to that the vhost_dev index
      for the ctrl vq was not aligned with actual one in use by the guest.
      Upon multiqueue feature negotiation in virtio_net_set_multiqueue(),
      if guest doesn't support multiqueue, the guest vq layout would shrink
      to a single queue pair, consisting of 3 vqs in total (rx, tx and ctrl).
      This results in ctrl_vq taking a different vhost_dev group index than
      the default. We can map vq to the correct vhost_dev group by checking
      if MQ is supported by guest and successfully negotiated. Since the
      MQ feature is only present along with CTRL_VQ, we ensure the index
      2 is only meant for the control vq while MQ is not supported by guest.
      
      Fixes: 22288fe5 ("virtio-net: vhost control virtqueue support")
      Suggested-by: default avatarJason Wang <jasowang@redhat.com>
      Signed-off-by: default avatarSi-Wei Liu <si-wei.liu@oracle.com>
      Acked-by: default avatarJason Wang <jasowang@redhat.com>
      Message-Id: <1651890498-24478-3-git-send-email-si-wei.liu@oracle.com>
      Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      68b0a639
    • Si-Wei Liu's avatar
      virtio-net: setup vhost_dev and notifiers for cvq only when feature is negotiated · aa858194
      Si-Wei Liu authored
      
      When the control virtqueue feature is absent or not negotiated,
      vhost_net_start() still tries to set up vhost_dev and install
      vhost notifiers for the control virtqueue, which results in
      erroneous ioctl calls with incorrect queue index sending down
      to driver. Do that only when needed.
      
      Fixes: 22288fe5 ("virtio-net: vhost control virtqueue support")
      Signed-off-by: default avatarSi-Wei Liu <si-wei.liu@oracle.com>
      Acked-by: default avatarJason Wang <jasowang@redhat.com>
      Message-Id: <1651890498-24478-2-git-send-email-si-wei.liu@oracle.com>
      Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      aa858194
    • Wei Huang's avatar
      hw/i386/amd_iommu: Fix IOMMU event log encoding errors · 18aa91cd
      Wei Huang authored
      
      Coverity issues several UNINIT warnings against amd_iommu.c [1]. This
      patch fixes them by clearing evt before encoding. On top of it, this
      patch changes the event log size to 16 bytes per IOMMU specification,
      and fixes the event log entry format in amdvi_encode_event().
      
      [1] CID 1487116/1487200/1487190/1487232/1487115/1487258
      
      Reported-by: default avatarPeter Maydell <peter.maydell@linaro.org>
      Signed-off-by: default avatarWei Huang <wei.huang2@amd.com>
      Message-Id: <20220422055146.3312226-1-wei.huang2@amd.com>
      Reviewed-by: default avatarPeter Maydell <peter.maydell@linaro.org>
      Acked-by: default avatarJason Wang <jasowang@redhat.com>
      Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      18aa91cd
    • Xiaoyao Li's avatar
      hw/i386: Make pic a property of common x86 base machine type · c300bbe8
      Xiaoyao Li authored
      
      Legacy PIC (8259) cannot be supported for TDX guests since TDX module
      doesn't allow directly interrupt injection.  Using posted interrupts
      for the PIC is not a viable option as the guest BIOS/kernel will not
      do EOI for PIC IRQs, i.e. will leave the vIRR bit set.
      
      Make PIC the property of common x86 machine type. Hence all x86
      machines, including microvm, can disable it.
      
      Signed-off-by: default avatarXiaoyao Li <xiaoyao.li@intel.com>
      Reviewed-by: default avatarSergio Lopez <slp@redhat.com>
      Message-Id: <20220310122811.807794-3-xiaoyao.li@intel.com>
      Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      c300bbe8
    • Xiaoyao Li's avatar
      hw/i386: Make pit a property of common x86 base machine type · 9dee7e51
      Xiaoyao Li authored
      
      Both pc and microvm have pit property individually. Let's just make it
      the property of common x86 base machine type.
      
      Signed-off-by: default avatarXiaoyao Li <xiaoyao.li@intel.com>
      Reviewed-by: default avatarSergio Lopez <slp@redhat.com>
      Message-Id: <20220310122811.807794-2-xiaoyao.li@intel.com>
      Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      9dee7e51
    • Helge Deller's avatar
      artist: Fix X cursor position calculation in X11 · 9ef2c6b4
      Helge Deller authored
      
      The X cursor postion can be calculated based on the backporch and
      interleave values.  In the emulation we ignore the HP-UX settings for
      backporch and use instead twice the size of the emulated cursor.  With
      those changes the X-position of the graphics cursor is now finally
      working correctly on HP-UX 10 and HP-UX 11.
      
      Based on coding in Xorg X11R6.6
      
      Signed-off-by: default avatarHelge Deller <deller@gmx.de>
      9ef2c6b4
    • Helge Deller's avatar
      artist: Emulate screen blanking · caca6e61
      Helge Deller authored
      
      The misc_video and misc_ctrl registers control the visibility of the
      screen. Start with the screen turned on, and hide or show the screen
      based on the control registers.
      
      Signed-off-by: default avatarHelge Deller <deller@gmx.de>
      Acked-by: default avatarMark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
      caca6e61
    • Helge Deller's avatar
      artist: Allow to turn cursor on or off · a377b574
      Helge Deller authored
      
      Bit 0x80 in the cursor_cntrl register specifies if the cursor
      should be visible. Prevent rendering the cursor if it's invisible.
      
      Signed-off-by: default avatarHelge Deller <deller@gmx.de>
      Acked-by: default avatarMark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
      a377b574
    • Helge Deller's avatar
      artist: Fix vertical X11 cursor position in HP-UX · 482afe02
      Helge Deller authored
      
      Drop the hard-coded value of 1146 lines which seems to work with HP-UX
      11, but not with HP-UX 10. Instead encode the screen height in byte 0 of
      active_lines_low and byte 3 of misc_video as it's expected by the Xorg
      X11 graphics driver.
      
      This potentially allows for higher vertical screen resolutions than
      1280x1024 with X11.
      
      Signed-off-by: default avatarHelge Deller <deller@gmx.de>
      Acked-by: default avatarMark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
      482afe02
    • Helge Deller's avatar
      artist: Use human-readable variable names instead of reg_xxx · e9683fbc
      Helge Deller authored
      
      Convert the variable names of some registers to human-readable and
      understandable names.
      
      Signed-off-by: default avatarHelge Deller <deller@gmx.de>
      Acked-by: default avatarMark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
      e9683fbc
    • Helge Deller's avatar
      artist: Introduce constant for max cursor size · 7e50730c
      Helge Deller authored
      
      Add the constant NGLE_MAX_SPRITE_SIZE which defines the currently
      maximum supported cursor size.
      
      Signed-off-by: default avatarHelge Deller <deller@gmx.de>
      Acked-by: default avatarMark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
      7e50730c
    • Leonardo Bras's avatar
      QIOChannel: Add flags on io_writev and introduce io_flush callback · b88651cb
      Leonardo Bras authored
      
      Add flags to io_writev and introduce io_flush as optional callback to
      QIOChannelClass, allowing the implementation of zero copy writes by
      subclasses.
      
      How to use them:
      - Write data using qio_channel_writev*(...,QIO_CHANNEL_WRITE_FLAG_ZERO_COPY),
      - Wait write completion with qio_channel_flush().
      
      Notes:
      As some zero copy write implementations work asynchronously, it's
      recommended to keep the write buffer untouched until the return of
      qio_channel_flush(), to avoid the risk of sending an updated buffer
      instead of the buffer state during write.
      
      As io_flush callback is optional, if a subclass does not implement it, then:
      - io_flush will return 0 without changing anything.
      
      Also, some functions like qio_channel_writev_full_all() were adapted to
      receive a flag parameter. That allows shared code between zero copy and
      non-zero copy writev, and also an easier implementation on new flags.
      
      Signed-off-by: default avatarLeonardo Bras <leobras@redhat.com>
      Reviewed-by: default avatarDaniel P. Berrangé <berrange@redhat.com>
      Reviewed-by: default avatarPeter Xu <peterx@redhat.com>
      Reviewed-by: default avatarJuan Quintela <quintela@redhat.com>
      Message-Id: <20220513062836.965425-3-leobras@redhat.com>
      Signed-off-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      b88651cb
    • Jonah Palmer's avatar
      virtio: add vhost support for virtio devices · c255488d
      Jonah Palmer authored
      
      This patch adds a get_vhost() callback function for VirtIODevices that
      returns the device's corresponding vhost_dev structure, if the vhost
      device is running. This patch also adds a vhost_started flag for
      VirtIODevices.
      
      Previously, a VirtIODevice wouldn't be able to tell if its corresponding
      vhost device was active or not.
      
      Signed-off-by: default avatarJonah Palmer <jonah.palmer@oracle.com>
      Message-Id: <1648819405-25696-3-git-send-email-jonah.palmer@oracle.com>
      Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      c255488d
    • Jonah Palmer's avatar
      virtio: drop name parameter for virtio_init() · 3857cd5c
      Jonah Palmer authored
      
      This patch drops the name parameter for the virtio_init function.
      
      The pair between the numeric device ID and the string device ID
      (name) of a virtio device already exists, but not in a way that
      lets us map between them.
      
      This patch lets us do this and removes the need for the name
      parameter in the virtio_init function.
      
      Signed-off-by: default avatarJonah Palmer <jonah.palmer@oracle.com>
      Message-Id: <1648819405-25696-2-git-send-email-jonah.palmer@oracle.com>
      Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      3857cd5c
    • Alex Bennée's avatar
      virtio/vhost-user: dynamically assign VhostUserHostNotifiers · 503e3554
      Alex Bennée authored
      
      At a couple of hundred bytes per notifier allocating one for every
      potential queue is very wasteful as most devices only have a few
      queues. Instead of having this handled statically dynamically assign
      them and track in a GPtrArray.
      
      [AJB: it's hard to trigger the vhost notifiers code, I assume as it
      requires a KVM guest with appropriate backend]
      
      Signed-off-by: default avatarAlex Bennée <alex.bennee@linaro.org>
      Message-Id: <20220321153037.3622127-14-alex.bennee@linaro.org>
      Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      503e3554
    • Alex Bennée's avatar
      hw/virtio/vhost-user: don't suppress F_CONFIG when supported · 56534930
      Alex Bennée authored
      
      Previously we would silently suppress VHOST_USER_PROTOCOL_F_CONFIG
      during the protocol negotiation if the QEMU stub hadn't implemented
      the vhost_dev_config_notifier. However this isn't the only way we can
      handle config messages, the existing vdc->get/set_config can do this
      as well.
      
      Lightly re-factor the code to check for both potential methods and
      instead of silently squashing the feature error out. It is unlikely
      that a vhost-user backend expecting to handle CONFIG messages will
      behave correctly if they never get sent.
      
      Fixes: 1c3e5a26 ("vhost-user: back SET/GET_CONFIG requests with a protocol feature")
      Cc: Maxime Coquelin <maxime.coquelin@redhat.com>
      Cc: Michael S. Tsirkin <mst@redhat.com>
      Cc: Stefan Hajnoczi <stefanha@redhat.com>
      Signed-off-by: default avatarAlex Bennée <alex.bennee@linaro.org>
      
      Message-Id: <20220321153037.3622127-13-alex.bennee@linaro.org>
      Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      56534930
    • Alex Bennée's avatar
      hw/virtio: add vhost_user_[read|write] trace points · 6ca6d8ee
      Alex Bennée authored
      
      These are useful when trying to debug the initial vhost-user
      negotiation, especially when it hard to get logging from the low level
      library on the other side.
      
      Signed-off-by: default avatarAlex Bennée <alex.bennee@linaro.org>
      
      Message-Id: <20220321153037.3622127-4-alex.bennee@linaro.org>
      Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Reviewed-by: default avatarPhilippe Mathieu-Daudé <f4bug@amsat.org>
      6ca6d8ee
    • Alex Bennée's avatar
      virtio-pci: add notification trace points · 31cc62bb
      Alex Bennée authored
      
      Signed-off-by: default avatarAlex Bennée <alex.bennee@linaro.org>
      Reviewed-by: default avatarPhilippe Mathieu-Daudé <philmd@redhat.com>
      Message-Id: <20200925125147.26943-6-alex.bennee@linaro.org>
      Signed-off-by: default avatarAlex Bennée <alex.bennee@linaro.org>
      Message-Id: <20220321153037.3622127-3-alex.bennee@linaro.org>
      Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      31cc62bb
    • Alex Bennée's avatar
      hw/virtio: move virtio-pci.h into shared include space · e1b1f534
      Alex Bennée authored
      
      This allows other device classes that will be exposed via PCI to be
      able to do so in the appropriate hw/ directory. I resisted the
      temptation to re-order headers to be more aesthetically pleasing.
      
      Signed-off-by: default avatarAlex Bennée <alex.bennee@linaro.org>
      Message-Id: <20200925125147.26943-4-alex.bennee@linaro.org>
      
      Message-Id: <20220321153037.3622127-2-alex.bennee@linaro.org>
      Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      e1b1f534
    • Ilya Maximets's avatar
      vhost_net: Print feature masks in hex · 1eed051c
      Ilya Maximets authored
      
      "0x200000000" is much more readable than "8589934592".
      The change saves one step (conversion) while debugging.
      
      Signed-off-by: default avatarIlya Maximets <i.maximets@ovn.org>
      Message-Id: <20220318140440.596019-1-i.maximets@ovn.org>
      Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Reviewed-by: default avatarPhilippe Mathieu-Daudé <f4bug@amsat.org>
      1eed051c
    • Jason Wang's avatar
      intel-iommu: update iq_dw during post load · 147a372e
      Jason Wang authored
      
      We need to update iq_dw according to the DMA_IRQ_REG during post
      load. Otherwise we may get wrong IOTLB invalidation descriptor after
      migration.
      
      Fixes: fb43cf73 ("intel_iommu: scalable mode emulation")
      Signed-off-by: default avatarJason Wang <jasowang@redhat.com>
      Message-Id: <20220317080522.14621-2-jasowang@redhat.com>
      Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Reviewed-by: default avatarPeter Xu <peterx@redhat.com>
      147a372e
    • Jason Wang's avatar
      intel-iommu: update root_scalable before switching as during post_load · ceb05895
      Jason Wang authored
      
      We need check whether passthrough is enabled during
      vtd_switch_address_space() by checking the context entries. This
      requires the root_scalable to be set correctly otherwise we may try to
      check legacy rsvd bits instead of scalable ones.
      
      Fixing this by updating root_scalable before switching the address
      spaces during post_load.
      
      Fixes: fb43cf73 ("intel_iommu: scalable mode emulation")
      Signed-off-by: default avatarJason Wang <jasowang@redhat.com>
      Message-Id: <20220317080522.14621-1-jasowang@redhat.com>
      Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Reviewed-by: default avatarPeter Xu <peterx@redhat.com>
      ceb05895
    • Jason Wang's avatar
      intel-iommu: block output address in interrupt address range · ea97a1bd
      Jason Wang authored
      
      According to vtd spec v3.3 3.14:
      
      """
      Software must not program paging-structure entries to remap any
      address to the interrupt address range. Untranslated requests and
      translation requests that result in an address in the interrupt range
      will be blocked with condition code LGN.4 or SGN.8.
      """
      
      This patch blocks the request that result in interrupt address range.
      
      Signed-off-by: default avatarJason Wang <jasowang@redhat.com>
      Message-Id: <20220210092815.45174-2-jasowang@redhat.com>
      Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Reviewed-by: default avatarPeter Xu <peterx@redhat.com>
      ea97a1bd
Loading