Skip to content
Snippets Groups Projects
  1. Mar 22, 2021
    • David Hildenbrand's avatar
      microvm: Don't open-code "etc/table-loader" · 2a3bdc5c
      David Hildenbrand authored
      
      Let's just reuse ACPI_BUILD_LOADER_FILE.
      
      Cc: Alistair Francis <alistair.francis@xilinx.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: "Michael S. Tsirkin" <mst@redhat.com>
      Cc: Igor Mammedov <imammedo@redhat.com>
      Cc: Peter Maydell <peter.maydell@linaro.org>
      Cc: Shannon Zhao <shannon.zhaosl@gmail.com>
      Cc: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Richard Henderson <richard.henderson@linaro.org>
      Cc: Laszlo Ersek <lersek@redhat.com>
      Signed-off-by: default avatarDavid Hildenbrand <david@redhat.com>
      Message-Id: <20210304105554.121674-3-david@redhat.com>
      Reviewed-by: default avatarLaszlo Ersek <lersek@redhat.com>
      Reviewed-by: default avatarIgor Mammedov <imammedo@redhat.com>
      Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      2a3bdc5c
    • David Hildenbrand's avatar
      acpi: Set proper maximum size for "etc/table-loader" blob · 6c2b24d1
      David Hildenbrand authored
      
      The resizeable memory region / RAMBlock that is created for the cmd blob
      has a maximum size of whole host pages (e.g., 4k), because RAMBlocks
      work on full host pages. In addition, in i386 ACPI code:
        acpi_align_size(tables->linker->cmd_blob, ACPI_BUILD_ALIGN_SIZE);
      makes sure to align to multiples of 4k, padding with 0.
      
      For example, if our cmd_blob is created with a size of 2k, the maximum
      size is 4k - we cannot grow beyond that. Growing might be required
      due to guest action when rebuilding the tables, but also on incoming
      migration.
      
      This automatic generation of the maximum size used to be sufficient,
      however, there are cases where we cross host pages now when growing at
      runtime: we exceed the maximum size of the RAMBlock and can crash QEMU when
      trying to resize the resizeable memory region / RAMBlock:
        $ build/qemu-system-x86_64 --enable-kvm \
            -machine q35,nvdimm=on \
            -smp 1 \
            -cpu host \
            -m size=2G,slots=8,maxmem=4G \
            -object memory-backend-file,id=mem0,mem-path=/tmp/nvdimm,size=256M \
            -device nvdimm,label-size=131072,memdev=mem0,id=nvdimm0,slot=1 \
            -nodefaults \
            -device vmgenid \
            -device intel-iommu
      
      Results in:
        Unexpected error in qemu_ram_resize() at ../softmmu/physmem.c:1850:
        qemu-system-x86_64: Size too large: /rom@etc/table-loader:
          0x2000 > 0x1000: Invalid argument
      
      In this configuration, we consume exactly 4k (32 entries, 128 bytes each)
      when creating the VM. However, once the guest boots up and maps the MCFG,
      we also create the MCFG table and end up consuming 2 additional entries
      (pointer + checksum) -- which is where we try resizing the memory region
      / RAMBlock, however, the maximum size does not allow for it.
      
      Currently, we get the following maximum sizes for our different
      mutable tables based on behavior of resizeable RAMBlock:
      
        hw       table                max_size
        -------  ---------------------------------------------------------
      
        virt     "etc/acpi/tables"    ACPI_BUILD_TABLE_MAX_SIZE (0x200000)
        virt     "etc/table-loader"   HOST_PAGE_ALIGN(initial_size)
        virt     "etc/acpi/rsdp"      HOST_PAGE_ALIGN(initial_size)
      
        i386     "etc/acpi/tables"    ACPI_BUILD_TABLE_MAX_SIZE (0x200000)
        i386     "etc/table-loader"   HOST_PAGE_ALIGN(initial_size)
        i386     "etc/acpi/rsdp"      HOST_PAGE_ALIGN(initial_size)
      
        microvm  "etc/acpi/tables"    ACPI_BUILD_TABLE_MAX_SIZE (0x200000)
        microvm  "etc/table-loader"   HOST_PAGE_ALIGN(initial_size)
        microvm  "etc/acpi/rsdp"      HOST_PAGE_ALIGN(initial_size)
      
      Let's set the maximum table size for "etc/table-loader" to 64k, so we
      can properly grow at runtime, which should be good enough for the future.
      
      Migration is not concerned with the maximum size of a RAMBlock, only
      with the used size - so existing setups are not affected. Of course, we
      cannot migrate a VM that would have crash when started on older QEMU from
      new QEMU to older QEMU without failing early on the destination when
      synchronizing the RAM state:
          qemu-system-x86_64: Size too large: /rom@etc/table-loader: 0x2000 > 0x1000: Invalid argument
          qemu-system-x86_64: error while loading state for instance 0x0 of device 'ram'
          qemu-system-x86_64: load of migration failed: Invalid argument
      
      We'll refactor the code next, to make sure we get rid of this implicit
      behavior for "etc/acpi/rsdp" as well and to make the code easier to
      grasp.
      
      Reviewed-by: default avatarIgor Mammedov <imammedo@redhat.com>
      Cc: Alistair Francis <alistair.francis@xilinx.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: "Michael S. Tsirkin" <mst@redhat.com>
      Cc: Igor Mammedov <imammedo@redhat.com>
      Cc: Peter Maydell <peter.maydell@linaro.org>
      Cc: Shannon Zhao <shannon.zhaosl@gmail.com>
      Cc: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Richard Henderson <richard.henderson@linaro.org>
      Cc: Laszlo Ersek <lersek@redhat.com>
      Signed-off-by: default avatarDavid Hildenbrand <david@redhat.com>
      Message-Id: <20210304105554.121674-2-david@redhat.com>
      Reviewed-by: default avatarLaszlo Ersek <lersek@redhat.com>
      Reviewed-by: default avatarIgor Mammedov <imammedo@redhat.com>
      Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      6c2b24d1
    • Igor Mammedov's avatar
      tests: acpi: update expected blobs · 835fde4a
      Igor Mammedov authored
      
      expected changes are:
       * larger BNMR operation region
       * new PIDX field and method to fetch acpi-index
       * PDSM method that implements PCI device _DSM +
         per device _DSM that calls PDSM
      
      @@ -221,10 +221,11 @@ DefinitionBlock ("", "DSDT", 1, "BOCHS ", "BXPC    ", 0x00000001)
                   B0EJ,   32
               }
      
      -        OperationRegion (BNMR, SystemIO, 0xAE10, 0x04)
      +        OperationRegion (BNMR, SystemIO, 0xAE10, 0x08)
               Field (BNMR, DWordAcc, NoLock, WriteAsZeros)
               {
      -            BNUM,   32
      +            BNUM,   32,
      +            PIDX,   32
               }
      
               Mutex (BLCK, 0x00)
      @@ -236,6 +237,52 @@ DefinitionBlock ("", "DSDT", 1, "BOCHS ", "BXPC    ", 0x00000001)
                   Release (BLCK)
                   Return (Zero)
               }
      +
      +        Method (AIDX, 2, NotSerialized)
      +        {
      +            Acquire (BLCK, 0xFFFF)
      +            BNUM = Arg0
      +            PIDX = (One << Arg1)
      +            Local0 = PIDX /* \_SB_.PCI0.PIDX */
      +            Release (BLCK)
      +            Return (Local0)
      +        }
      +
      +        Method (PDSM, 6, Serialized)
      +        {
      +            If ((Arg0 == ToUUID ("e5c937d0-3553-4d7a-9117-ea4d19c3434d") /* Device Labeling Interface */))
      +            {
      +                Local0 = AIDX (Arg4, Arg5)
      +                If ((Arg2 == Zero))
      +                {
      +                    If ((Arg1 == 0x02))
      +                    {
      +                        If (!((Local0 == Zero) | (Local0 == 0xFFFFFFFF)))
      +                        {
      +                            Return (Buffer (One)
      +                            {
      +                                 0x81                                             // .
      +                            })
      +                        }
      +                    }
      +
      +                    Return (Buffer (One)
      +                    {
      +                         0x00                                             // .
      +                    })
      +                }
      +                ElseIf ((Arg2 == 0x07))
      +                {
      +                    Local1 = Package (0x02)
      +                        {
      +                            Zero,
      +                            ""
      +                        }
      +                    Local1 [Zero] = Local0
      +                    Return (Local1)
      +                }
      +            }
      +        }
           }
      
           Scope (_SB)
      @@ -785,7 +832,7 @@ DefinitionBlock ("", "DSDT", 1, "BOCHS ", "BXPC    ", 0x00000001)
                           0xAE00,             // Range Minimum
                           0xAE00,             // Range Maximum
                           0x01,               // Alignment
      -                    0x14,               // Length
      +                    0x18,               // Length
                           )
                   })
               }
      @@ -842,11 +889,22 @@ DefinitionBlock ("", "DSDT", 1, "BOCHS ", "BXPC    ", 0x00000001)
                   Device (S00)
                   {
                       Name (_ADR, Zero)  // _ADR: Address
      +                Name (_SUN, Zero)  // _SUN: Slot User Number
      +                Method (_DSM, 4, Serialized)  // _DSM: Device-Specific Method
      +                {
      +                    Return (PDSM (Arg0, Arg1, Arg2, Arg3, BSEL, _SUN))
      +                }
                   }
      
                   Device (S10)
                   {
                       Name (_ADR, 0x00020000)  // _ADR: Address
      +                Name (_SUN, 0x02)  // _SUN: Slot User Number
      +                Method (_DSM, 4, Serialized)  // _DSM: Device-Specific Method
      +                {
      +                    Return (PDSM (Arg0, Arg1, Arg2, Arg3, BSEL, _SUN))
      +                }
      +
                       Method (_S1D, 0, NotSerialized)  // _S1D: S1 Device State
                       {
                           Return (Zero)
      [...]
      
      Signed-off-by: default avatarIgor Mammedov <imammedo@redhat.com>
      Message-Id: <20210315180102.3008391-7-imammedo@redhat.com>
      Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      835fde4a
    • Igor Mammedov's avatar
      pci: acpi: add _DSM method to PCI devices · b7f23f62
      Igor Mammedov authored
      
      Implement _DSM according to:
          PCI Firmware Specification 3.1
          4.6.7.  DSM for Naming a PCI or PCI Express Device Under
                  Operating Systems
      and wire it up to cold and hot-plugged PCI devices.
      Feature depends on ACPI hotplug being enabled (as that provides
      PCI devices descriptions in ACPI and MMIO registers that are
      reused to fetch acpi-index).
      
      acpi-index should work for
        - cold plugged NICs:
            $QEMU -device e1000,acpi-index=100
               => 'eno100'
        - hot-plugged
            (monitor) device_add e1000,acpi-index=200,id=remove_me
               => 'eno200'
        - re-plugged
            (monitor) device_del remove_me
            (monitor) device_add e1000,acpi-index=1
               => 'eno1'
      
      Windows also sees index under "PCI Label Id" field in properties
      dialog but otherwise it doesn't seem to have any effect.
      
      Signed-off-by: default avatarIgor Mammedov <imammedo@redhat.com>
      Message-Id: <20210315180102.3008391-6-imammedo@redhat.com>
      Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      b7f23f62
    • Igor Mammedov's avatar
      acpi: add aml_to_decimalstring() and aml_call6() helpers · 910e4069
      Igor Mammedov authored
      
      it will be used by follow up patches
      
      Signed-off-by: default avatarIgor Mammedov <imammedo@redhat.com>
      Message-Id: <20210315180102.3008391-5-imammedo@redhat.com>
      Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      910e4069
    • Igor Mammedov's avatar
      pci: acpi: ensure that acpi-index is unique · 4fd7da4c
      Igor Mammedov authored
      
      it helps to avoid device naming conflicts when guest OS is
      configured to use acpi-index for naming.
      Spec ialso says so:
      
      PCI Firmware Specification Revision 3.2
      4.6.7.  _DSM for Naming a PCI or PCI Express Device Under Operating Systems
      "
      Instance number must be unique under \_SB scope. This instance number does not have to
      be sequential in a given system configuration.
      "
      
      Signed-off-by: default avatarIgor Mammedov <imammedo@redhat.com>
      Message-Id: <20210315180102.3008391-4-imammedo@redhat.com>
      Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      4fd7da4c
    • Igor Mammedov's avatar
      pci: introduce acpi-index property for PCI device · b32bd763
      Igor Mammedov authored
      
      In x86/ACPI world, linux distros are using predictable
      network interface naming since systemd v197. Which on
      QEMU based VMs results into path based naming scheme,
      that names network interfaces based on PCI topology.
      
      With itm on has to plug NIC in exactly the same bus/slot,
      which was used when disk image was first provisioned/configured
      or one risks to loose network configuration due to NIC being
      renamed to actually used topology.
      That also restricts freedom to reshape PCI configuration of
      VM without need to reconfigure used guest image.
      
      systemd also offers "onboard" naming scheme which is
      preferred over PCI slot/topology one, provided that
      firmware implements:
          "
          PCI Firmware Specification 3.1
          4.6.7.  DSM for Naming a PCI or PCI Express Device Under
                  Operating Systems
          "
      that allows to assign user defined index to PCI device,
      which systemd will use to name NIC. For example, using
        -device e1000,acpi-index=100
      guest will rename NIC to 'eno100', where 'eno' is default
      prefix for "onboard" naming scheme. This doesn't require
      any advance configuration on guest side to com in effect
      at 'onboard' scheme takes priority over path based naming.
      
      Hope is that 'acpi-index' it will be easier to consume by
      management layer, compared to forcing specific PCI topology
      and/or having several disk image templates for different
      topologies and will help to simplify process of spawning
      VM from the same template without need to reconfigure
      guest NIC.
      
      This patch adds, 'acpi-index'* property and wires up
      a 32bit register on top of pci hotplug register block
      to pass index value to AML code at runtime.
      Following patch will add corresponding _DSM code and
      wire it up to PCI devices described in ACPI.
      
      *) name comes from linux kernel terminology
      
      Signed-off-by: default avatarIgor Mammedov <imammedo@redhat.com>
      Message-Id: <20210315180102.3008391-3-imammedo@redhat.com>
      Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      b32bd763
    • Igor Mammedov's avatar
      tests: acpi: temporary whitelist DSDT changes · 79a2aca2
      Igor Mammedov authored
      
      Signed-off-by: default avatarIgor Mammedov <imammedo@redhat.com>
      Message-Id: <20210315180102.3008391-2-imammedo@redhat.com>
      Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      79a2aca2
    • Wang Liang's avatar
      virtio-pmem: fix virtio_pmem_resp assign problem · d2adda34
      Wang Liang authored
      
      ret in virtio_pmem_resp is a uint32_t variable, which should be assigned
      using virtio_stl_p.
      
      The kernel side driver does not guarantee virtio_pmem_resp to be initialized
      to zero in advance, So sometimes the flush operation will fail.
      
      Signed-off-by: default avatarWang Liang <wangliangzz@inspur.com>
      Message-Id: <20210317024145.271212-1-wangliangzz@126.com>
      Reviewed-by: default avatarStefano Garzarella <sgarzare@redhat.com>
      Reviewed-by: default avatarDavid Hildenbrand <david@redhat.com>
      Reviewed-by: default avatarPankaj Gupta <pankaj.gupta@cloud.ionos.com>
      Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      d2adda34
    • Greg Kurz's avatar
      vhost-user: Monitor slave channel in vhost_user_read() · db8a3772
      Greg Kurz authored
      
      Now that everything is in place, have the nested event loop to monitor
      the slave channel. The source in the main event loop is destroyed and
      recreated to ensure any pending even for the slave channel that was
      previously detected is purged. This guarantees that the main loop
      wont invoke slave_read() based on an event that was already handled
      by the nested loop.
      
      Signed-off-by: default avatarGreg Kurz <groug@kaod.org>
      Message-Id: <20210312092212.782255-7-groug@kaod.org>
      Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Reviewed-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      db8a3772
    • Greg Kurz's avatar
      vhost-user: Introduce nested event loop in vhost_user_read() · a7f523c7
      Greg Kurz authored
      A deadlock condition potentially exists if a vhost-user process needs
      to request something to QEMU on the slave channel while processing a
      vhost-user message.
      
      This doesn't seem to affect any vhost-user implementation so far, but
      this is currently biting the upcoming enablement of DAX with virtio-fs.
      The issue is being observed when the guest does an emergency reboot while
      a mapping still exits in the DAX window, which is very easy to get with
      a busy enough workload (e.g. as simulated by blogbench [1]) :
      
      - QEMU sends VHOST_USER_GET_VRING_BASE to virtiofsd.
      
      - In order to complete the request, virtiofsd then asks QEMU to remove
        the mapping on the slave channel.
      
      All these dialogs are synchronous, hence the deadlock.
      
      As pointed out by Stefan Hajnoczi:
      
      When QEMU's vhost-user master implementation sends a vhost-user protocol
      message, vhost_user_read() does a "blocking" read during which slave_fd
      is not monitored by QEMU.
      
      The natural solution for this issue is an event loop. The main event
      loop cannot be nested though since we have no guarantees that its
      fd handlers are prepared for re-entrancy.
      
      Introduce a new event loop that only monitors the chardev I/O for now
      in vhost_user_read() and push the actual reading to a one-shot handler.
      A subsequent patch will teach the loop to monitor and process messages
      from the slave channel as well.
      
      [1] https://github.com/jedisct1/Blogbench
      
      
      
      Suggested-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      Signed-off-by: default avatarGreg Kurz <groug@kaod.org>
      Message-Id: <20210312092212.782255-6-groug@kaod.org>
      Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Reviewed-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      a7f523c7
    • Greg Kurz's avatar
      vhost-user: Convert slave channel to QIOChannelSocket · 57dc0217
      Greg Kurz authored
      
      The slave channel is implemented with socketpair() : QEMU creates
      the pair, passes one of the socket to virtiofsd and monitors the
      other one with the main event loop using qemu_set_fd_handler().
      
      In order to fix a potential deadlock between QEMU and a vhost-user
      external process (e.g. virtiofsd with DAX), we want to be able to
      monitor and service the slave channel while handling vhost-user
      requests.
      
      Prepare ground for this by converting the slave channel to be a
      QIOChannelSocket. This will make monitoring of the slave channel
      as simple as calling qio_channel_add_watch_source(). Since the
      connection is already established between the two sockets, only
      incoming I/O (G_IO_IN) and disconnect (G_IO_HUP) need to be
      serviced.
      
      This also allows to get rid of the ancillary data parsing since
      QIOChannelSocket can do this for us. Note that the MSG_CTRUNC
      check is dropped on the way because QIOChannelSocket ignores this
      case. This isn't a problem since slave_read() provisions space for
      8 file descriptors, but affected vhost-user slave protocol messages
      generally only convey one. If for some reason a buggy implementation
      passes more file descriptors, no need to break the connection, just
      like we don't break it if some other type of ancillary data is
      received : this isn't explicitely violating the protocol per-se so
      it seems better to ignore it.
      
      The current code errors out on short reads and writes. Use the
      qio_channel_*_all() variants to address this on the way.
      
      Signed-off-by: default avatarGreg Kurz <groug@kaod.org>
      Message-Id: <20210312092212.782255-5-groug@kaod.org>
      Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Reviewed-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      57dc0217
    • Greg Kurz's avatar
      vhost-user: Factor out duplicated slave_fd teardown code · de62e494
      Greg Kurz authored
      
      Signed-off-by: default avatarGreg Kurz <groug@kaod.org>
      Message-Id: <20210312092212.782255-4-groug@kaod.org>
      Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Reviewed-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      de62e494
    • Greg Kurz's avatar
      vhost-user: Fix double-close on slave_read() error path · 9e06080b
      Greg Kurz authored
      
      Some message types, e.g. VHOST_USER_SLAVE_VRING_HOST_NOTIFIER_MSG,
      can convey file descriptors. These must be closed before returning
      from slave_read() to avoid being leaked. This can currently be done
      in two different places:
      
      [1] just after the request has been processed
      
      [2] on the error path, under the goto label err:
      
      These path are supposed to be mutually exclusive but they are not
      actually. If the VHOST_USER_NEED_REPLY_MASK flag was passed and the
      sending of the reply fails, both [1] and [2] are performed with the
      same descriptor values. This can potentially cause subtle bugs if one
      of the descriptor was recycled by some other thread in the meantime.
      
      This code duplication complicates rollback for no real good benefit.
      Do the closing in a unique place, under a new fdcleanup: goto label
      at the end of the function.
      
      Signed-off-by: default avatarGreg Kurz <groug@kaod.org>
      Message-Id: <20210312092212.782255-3-groug@kaod.org>
      Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Reviewed-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      9e06080b
    • Greg Kurz's avatar
      vhost-user: Drop misleading EAGAIN checks in slave_read() · a890557d
      Greg Kurz authored
      
      slave_read() checks EAGAIN when reading or writing to the socket
      fails. This gives the impression that the slave channel is in
      non-blocking mode, which is certainly not the case with the current
      code base. And the rest of the code isn't actually ready to cope
      with non-blocking I/O.
      
      Just drop the checks everywhere in this function for the sake of
      clarity.
      
      Signed-off-by: default avatarGreg Kurz <groug@kaod.org>
      Message-Id: <20210312092212.782255-2-groug@kaod.org>
      Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Reviewed-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      a890557d
    • Laurent Vivier's avatar
      virtio: Fix virtio_mmio_read()/virtio_mmio_write() · 0ab8c021
      Laurent Vivier authored
      
      Both functions don't check the personality of the interface (legacy or
      modern) before accessing the configuration memory and always use
      virtio_config_readX()/virtio_config_writeX().
      
      With this patch, they now check the personality and in legacy mode
      call virtio_config_readX()/virtio_config_writeX(), otherwise call
      virtio_config_modern_readX()/virtio_config_modern_writeX().
      
      This change has been tested with virtio-mmio guests (virt stretch/armhf and
      virt sid/m68k) and virtio-pci guests (pseries RHEL-7.3/ppc64 and /ppc64le).
      
      Signed-off-by: default avatarLaurent Vivier <laurent@vivier.eu>
      Message-Id: <20210314200300.3259170-1-laurent@vivier.eu>
      Reviewed-by: default avatarStefano Garzarella <sgarzare@redhat.com>
      Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      0ab8c021
    • Peter Maydell's avatar
      Merge remote-tracking branch 'remotes/thuth-gitlab/tags/pull-request-2021-03-21' into staging · f0f20022
      Peter Maydell authored
      
      * Small fixes for the unit tests
      * Compilation fixes for Illumos et al.
      * Update the FreeBSD VM to 12.2
      
      # gpg: Signature made Sun 21 Mar 2021 16:51:42 GMT
      # gpg:                using RSA key 27B88847EEE0250118F3EAB92ED9D774FE702DB5
      # gpg:                issuer "thuth@redhat.com"
      # gpg: Good signature from "Thomas Huth <th.huth@gmx.de>" [full]
      # gpg:                 aka "Thomas Huth <thuth@redhat.com>" [full]
      # gpg:                 aka "Thomas Huth <huth@tuxfamily.org>" [full]
      # gpg:                 aka "Thomas Huth <th.huth@posteo.de>" [unknown]
      # Primary key fingerprint: 27B8 8847 EEE0 2501 18F3  EAB9 2ED9 D774 FE70 2DB5
      
      * remotes/thuth-gitlab/tags/pull-request-2021-03-21:
        FreeBSD: Upgrade to 12.2 release
        contrib: ivshmem client and server build fix for SunOS.
        configure: fix for SunOS based systems
        tests/unit/test-block-iothread: fix maybe-uninitialized error on GCC 11
        docs/devel/testing.rst: Fix references to unit tests
      
      Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
      f0f20022
  2. Mar 20, 2021
  3. Mar 19, 2021
    • Peter Maydell's avatar
      Merge remote-tracking branch 'remotes/bonzini-gitlab/tags/for-upstream' into staging · bdee969c
      Peter Maydell authored
      
      * fixes for i386 TCG paging
      * fixes for Hyper-V enlightenments
      * avoid uninitialized variable warning
      
      # gpg: Signature made Fri 19 Mar 2021 14:38:12 GMT
      # gpg:                using RSA key F13338574B662389866C7682BFFBD25F78C7AE83
      # gpg:                issuer "pbonzini@redhat.com"
      # gpg: Good signature from "Paolo Bonzini <bonzini@gnu.org>" [full]
      # gpg:                 aka "Paolo Bonzini <pbonzini@redhat.com>" [full]
      # Primary key fingerprint: 46F5 9FBD 57D6 12E7 BFD4  E2F7 7E15 100C CD36 69B1
      #      Subkey fingerprint: F133 3857 4B66 2389 866C  7682 BFFB D25F 78C7 AE83
      
      * remotes/bonzini-gitlab/tags/for-upstream:
        tests/qtest: cleanup the testcase for bug 1878642
        hw/intc/i8259: Refactor pic_read_irq() to avoid uninitialized variable
        i386: Make migration fail when Hyper-V reenlightenment was enabled but 'user_tsc_khz' is unset
        i386: Fix 'hypercall_hypercall' typo
        target/i386: svm: do not discard high 32 bits of EXITINFO1
        target/i386: fail if toggling LA57 in 64-bit mode
        target/i386: allow modifying TCG phys-addr-bits
        qom: use qemu_printf to print help for user-creatable objects
      
      Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
      bdee969c
    • Peter Maydell's avatar
      Merge remote-tracking branch 'remotes/armbru/tags/pull-qapi-2021-03-16-v4' into staging · 2e1293cb
      Peter Maydell authored
      
      QAPI patches patches for 2021-03-16
      
      # gpg: Signature made Fri 19 Mar 2021 15:06:52 GMT
      # gpg:                using RSA key 354BC8B3D7EB2A6B68674E5F3870B400EB918653
      # gpg:                issuer "armbru@redhat.com"
      # gpg: Good signature from "Markus Armbruster <armbru@redhat.com>" [full]
      # gpg:                 aka "Markus Armbruster <armbru@pond.sub.org>" [full]
      # Primary key fingerprint: 354B C8B3 D7EB 2A6B 6867  4E5F 3870 B400 EB91 8653
      
      * remotes/armbru/tags/pull-qapi-2021-03-16-v4:
        qapi: New -compat deprecated-input=crash
        qapi: Implement deprecated-input=reject for QMP command arguments
        qapi: Implement deprecated-input=reject for QMP commands
        test-util-sockets: Add stub for monitor_set_cur()
        qapi: Implement deprecated-output=hide for QMP introspection
        monitor: Drop query-qmp-schema 'gen': false hack
        qapi: Implement deprecated-output=hide for QMP event data
        qapi: Implement deprecated-output=hide for QMP events
        qapi: Implement deprecated-output=hide for QMP command results
        qemu-options: New -compat to set policy for deprecated interfaces
        qemuutil: remove qemu_set_fd_handler duplicate symbol
      
      Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
      2e1293cb
    • Peter Maydell's avatar
      Merge remote-tracking branch 'remotes/armbru/tags/pull-qom-fdc-2021-03-16-v5' into staging · 8631a430
      Peter Maydell authored
      
      QOM and fdc patches patches for 2021-03-16
      
      # gpg: Signature made Fri 19 Mar 2021 14:18:47 GMT
      # gpg:                using RSA key 354BC8B3D7EB2A6B68674E5F3870B400EB918653
      # gpg:                issuer "armbru@redhat.com"
      # gpg: Good signature from "Markus Armbruster <armbru@redhat.com>" [full]
      # gpg:                 aka "Markus Armbruster <armbru@pond.sub.org>" [full]
      # Primary key fingerprint: 354B C8B3 D7EB 2A6B 6867  4E5F 3870 B400 EB91 8653
      
      * remotes/armbru/tags/pull-qom-fdc-2021-03-16-v5:
        memory: Drop "qemu:" prefix from QOM memory region type names
        hw: Replace anti-social QOM type names
        blockdev: Drop deprecated bogus -drive interface type
        fdc: Inline fdctrl_connect_drives() into fdctrl_realize_common()
        fdc: Drop deprecated floppy configuration
        docs/system/deprecated: Fix note on fdc drive properties
        fuzz: Avoid deprecated misuse of -drive if=sd
      
      Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
      8631a430
    • Markus Armbruster's avatar
      qapi: New -compat deprecated-input=crash · dbb675c1
      Markus Armbruster authored
      
      Policy "crash" calls abort() when deprecated input is received.
      
      Bugs in integration tests may mask the error from policy "reject".
      Provide a larger hammer: crash outright.  Masking that seems unlikely.
      
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: default avatarEric Blake <eblake@redhat.com>
      Message-Id: <20210318155519.1224118-12-armbru@redhat.com>
      dbb675c1
    • Markus Armbruster's avatar
      qapi: Implement deprecated-input=reject for QMP command arguments · db291641
      Markus Armbruster authored
      
      This policy rejects deprecated input, and thus permits "testing the
      future".  Implement it for QMP command arguments: reject commands with
      deprecated ones.  Example: when QEMU is run with -compat
      deprecated-input=reject, then
      
          {"execute": "eject", "arguments": {"device": "cd"}}
      
      fails like this
      
          {"error": {"class": "GenericError", "desc": "Deprecated parameter 'device' disabled by policy"}}
      
      When the deprecated parameter is removed, the error will change to
      
          {"error": {"class": "GenericError", "desc": "Parameter 'device' is unexpected"}}
      
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: default avatarEric Blake <eblake@redhat.com>
      Message-Id: <20210318155519.1224118-11-armbru@redhat.com>
      db291641
    • Markus Armbruster's avatar
      qapi: Implement deprecated-input=reject for QMP commands · d2032598
      Markus Armbruster authored
      
      This policy rejects deprecated input, and thus permits "testing the
      future".  Implement it for QMP commands: make deprecated ones fail.
      Example: when QEMU is run with -compat deprecated-input=reject, then
      
          {"execute": "query-cpus"}
      
      fails like this
      
          {"error": {"class": "CommandNotFound", "desc": "Deprecated command query-cpus disabled by policy"}}
      
      When the deprecated command is removed, the error will change to
      
          {"error": {"class": "CommandNotFound", "desc": "The command query-cpus has not been found"}}
      
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: default avatarEric Blake <eblake@redhat.com>
      Message-Id: <20210318155519.1224118-10-armbru@redhat.com>
      d2032598
    • Markus Armbruster's avatar
      test-util-sockets: Add stub for monitor_set_cur() · 130d4824
      Markus Armbruster authored
      
      Without this stub, the next commit fails to link.  I suspect the real
      cause is 947e4744 "monitor: Use getter/setter functions for
      cur_mon".
      
      Cc: Kevin Wolf <kwolf@redhat.com>
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: default avatarEric Blake <eblake@redhat.com>
      Message-Id: <20210318155519.1224118-9-armbru@redhat.com>
      130d4824
    • Markus Armbruster's avatar
      qapi: Implement deprecated-output=hide for QMP introspection · 2df68d77
      Markus Armbruster authored
      
      This policy suppresses deprecated bits in output, and thus permits
      "testing the future".  Implement it for QMP command query-qmp-schema:
      suppress information on deprecated commands, events and object type
      members, i.e. anything that has the special feature flag "deprecated".
      
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: default avatarEric Blake <eblake@redhat.com>
      Message-Id: <20210318155519.1224118-8-armbru@redhat.com>
      2df68d77
    • Markus Armbruster's avatar
      monitor: Drop query-qmp-schema 'gen': false hack · 624fa80c
      Markus Armbruster authored
      
      QMP commands return their response as a generated QAPI type, which the
      monitor core converts to JSON via QObject.
      
      query-qmp-schema's response is the generated introspection data.  This
      is a QLitObject since commit 7d0f982b "qapi: generate a literal
      qobject for introspection", v2.12).  Before, it was a string.  Instead
      of converting QLitObject / string -> QObject -> QAPI type
      SchemaInfoList -> QObject -> JSON, we take a shortcut: the command is
      'gen': false, so it can return the QObject instead of the QAPI type.
      Slightly simpler and more efficient.
      
      The next commit will filter the response for output policy, and this
      is easier in the SchemaInfoList representation.  Drop the shortcut.
      
      This replaces the manual command registration by a generated one.  The
      manual registration makes the command available before the machine is
      built by passing flag QCO_ALLOW_PRECONFIG.  To keep it available
      there, we need need to add 'allow-preconfig': true to its definition
      in the schema.
      
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: default avatarEric Blake <eblake@redhat.com>
      Message-Id: <20210318155519.1224118-7-armbru@redhat.com>
      624fa80c
    • Markus Armbruster's avatar
      qapi: Implement deprecated-output=hide for QMP event data · a291a38f
      Markus Armbruster authored
      
      This policy suppresses deprecated bits in output, and thus permits
      "testing the future".  Implement it for QMP event data: suppress
      deprecated members.
      
      No QMP event data is deprecated right now.
      
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: default avatarEric Blake <eblake@redhat.com>
      Message-Id: <20210318155519.1224118-6-armbru@redhat.com>
      a291a38f
    • Markus Armbruster's avatar
      qapi: Implement deprecated-output=hide for QMP events · 278fc2f7
      Markus Armbruster authored
      
      This policy suppresses deprecated bits in output, and thus permits
      "testing the future".  Implement it for QMP events: suppress
      deprecated ones.
      
      No QMP event is deprecated right now.
      
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: default avatarEric Blake <eblake@redhat.com>
      Message-Id: <20210318155519.1224118-5-armbru@redhat.com>
      278fc2f7
    • Markus Armbruster's avatar
      qapi: Implement deprecated-output=hide for QMP command results · 91fa93e5
      Markus Armbruster authored
      
      This policy suppresses deprecated bits in output, and thus permits
      "testing the future".  Implement it for QMP command results.  Example:
      when QEMU is run with -compat deprecated-output=hide, then
      
          {"execute": "query-cpus-fast"}
      
      yields
      
          {"return": [{"thread-id": 9805, "props": {"core-id": 0, "thread-id": 0, "socket-id": 0}, "qom-path": "/machine/unattached/device[0]", "cpu-index": 0, "target": "x86_64"}]}
      
      instead of
      
          {"return": [{"arch": "x86", "thread-id": 22436, "props": {"core-id": 0, "thread-id": 0, "socket-id": 0}, "qom-path": "/machine/unattached/device[0]", "cpu-index": 0, "target": "x86_64"}]}
      
      Note the suppression of deprecated member "arch".
      
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: default avatarEric Blake <eblake@redhat.com>
      Message-Id: <20210318155519.1224118-4-armbru@redhat.com>
      91fa93e5
    • Markus Armbruster's avatar
      qemu-options: New -compat to set policy for deprecated interfaces · 6dd75472
      Markus Armbruster authored
      
      New option -compat lets you configure what to do when deprecated
      interfaces get used.  This is intended for testing users of the
      management interfaces.  It is experimental.
      
      -compat deprecated-input=<input-policy> configures what to do when
      deprecated input is received.  Input policy can be "accept" (accept
      silently), or "reject" (reject the request with an error).
      
      -compat deprecated-output=<out-policy> configures what to do when
      deprecated output is sent.  Output policy can be "accept" (pass on
      unchanged), or "hide" (filter out the deprecated parts).
      
      Default is "accept".  Policies other than "accept" are implemented
      later in this series.
      
      For now, -compat covers only syntactic aspects of QMP, i.e. stuff
      tagged with feature 'deprecated'.  We may want to extend it to cover
      semantic aspects, CLI, and experimental features.
      
      Note that there is no good way for management application to detect
      presence of -compat: it's not visible output of query-qmp-schema or
      query-command-line-options.  Tolerable, because it's meant for
      testing.  If running with -compat fails, skip the test.
      
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: default avatarEric Blake <eblake@redhat.com>
      Message-Id: <20210318155519.1224118-3-armbru@redhat.com>
      6dd75472
    • Paolo Bonzini's avatar
      qemuutil: remove qemu_set_fd_handler duplicate symbol · b1eee9bb
      Paolo Bonzini authored
      
      libqemuutil has two definitions of qemu_set_fd_handler.  This
      is not needed since the only users of the function are
      qemu-io.c and the emulators, both of which already include
      util/main-loop.c.
      
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Message-Id: <d0c5aa88-029e-4328-7a53-482a3010c5f8@redhat.com>
      Tested-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20210318155519.1224118-2-armbru@redhat.com>
      b1eee9bb
    • Paolo Bonzini's avatar
      tests/qtest: cleanup the testcase for bug 1878642 · af05ffff
      Paolo Bonzini authored
      
      Clean up the writes to the configuration space and the PM region, and
      rename the test to lpc-ich9-test.
      
      Reviewed-by: default avatarPhilippe Mathieu-Daudé <philmd@redhat.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      af05ffff
    • Markus Armbruster's avatar
      memory: Drop "qemu:" prefix from QOM memory region type names · bb3c92ed
      Markus Armbruster authored
      
      Almost all QOM type names consist only of letters, digits, '-', '_',
      and '.'.  Just two contain ':': "qemu:memory-region" and
      "qemu:iommu-memory-region".  Neither can be plugged with -object.
      Rename them to "memory-region" and "iommu-memory-region".
      
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20210304140229.575481-3-armbru@redhat.com>
      Reviewed-by: default avatarAlistair Francis <alistair.francis@wdc.com>
      Reviewed-by: default avatarPhilippe Mathieu-Daudé <philmd@redhat.com>
      Acked-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      bb3c92ed
    • Markus Armbruster's avatar
      hw: Replace anti-social QOM type names · e178113f
      Markus Armbruster authored
      
      Several QOM type names contain ',':
      
          ARM,bitband-memory
          etraxfs,pic
          etraxfs,serial
          etraxfs,timer
          fsl,imx25
          fsl,imx31
          fsl,imx6
          fsl,imx6ul
          fsl,imx7
          grlib,ahbpnp
          grlib,apbpnp
          grlib,apbuart
          grlib,gptimer
          grlib,irqmp
          qemu,register
          SUNW,bpp
          SUNW,CS4231
          SUNW,DBRI
          SUNW,DBRI.prom
          SUNW,fdtwo
          SUNW,sx
          SUNW,tcx
          xilinx,zynq_slcr
          xlnx,zynqmp
          xlnx,zynqmp-pmu-soc
          xlnx,zynq-xadc
      
      These are all device types.  They can't be plugged with -device /
      device_add, except for xlnx,zynqmp-pmu-soc, and I doubt that one
      actually works.
      
      They *can* be used with -device / device_add to request help.
      Usability is poor, though: you have to double the comma, like this:
      
          $ qemu-system-x86_64 -device SUNW,,fdtwo,help
      
      Trap for the unwary.  The fact that this was broken in
      device-introspect-test for more than six years until commit e27bd498
      fixed it demonstrates that "the unwary" includes seasoned developers.
      
      One QOM type name contains ' ': "ICH9 SMB".  Because having to
      remember just one way to quote would be too easy.
      
      Rename the "SUNW,FOO types to "sun-FOO".  Summarily replace ',' and '
      ' by '-' in the other type names.
      
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20210304140229.575481-2-armbru@redhat.com>
      Reviewed-by: default avatarMark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
      Acked-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      e178113f
    • Markus Armbruster's avatar
      blockdev: Drop deprecated bogus -drive interface type · fe9f70a1
      Markus Armbruster authored
      
      Drop the crap deprecated in commit a1b40bda "blockdev: Deprecate
      -drive with bogus interface type" (v5.1.0).
      
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: default avatarDaniel P. Berrangé <berrange@redhat.com>
      Reviewed-by: default avatarJohn Snow <jsnow@redhat.com>
      Message-id: 20210309161214.1402527-5-armbru@redhat.com
      Signed-off-by: default avatarJohn Snow <jsnow@redhat.com>
      fe9f70a1
Loading