1. 15 7月, 2020 2 次提交
    • P
      Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging · d2628b1e
      Peter Maydell 提交于
      Block layer patches:
      
      - file-posix: Mitigate file fragmentation with extent size hints
      - Tighten qemu-img rules on missing backing format
      - qemu-img map: Don't limit block status request size
      - Fix crash with virtio-scsi and iothreads
      
      # gpg: Signature made Tue 14 Jul 2020 14:24:19 BST
      # gpg:                using RSA key DC3DEB159A9AF95D3D7456FE7F09B272C88F2FD6
      # gpg:                issuer "kwolf@redhat.com"
      # gpg: Good signature from "Kevin Wolf <kwolf@redhat.com>" [full]
      # Primary key fingerprint: DC3D EB15 9A9A F95D 3D74  56FE 7F09 B272 C88F 2FD6
      
      * remotes/kevin/tags/for-upstream:
        block: Avoid stale pointer dereference in blk_get_aio_context()
        qemu-img: Deprecate use of -b without -F
        block: Add support to warn on backing file change without format
        iotests: Specify explicit backing format where sensible
        qcow2: Deprecate use of qemu-img amend to change backing file
        block: Error if backing file fails during creation without -u
        qcow: Tolerate backing_fmt=
        vmdk: Add trivial backing_fmt support
        sheepdog: Add trivial backing_fmt support
        block: Finish deprecation of 'qemu-img convert -n -o'
        qemu-img: Flush stdout before before potential stderr messages
        file-posix: Mitigate file fragmentation with extent size hints
        iotests/059: Filter out disk size with more standard filter
        qemu-img map: Don't limit block status request size
        iotests: Simplify _filter_img_create() a bit
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      d2628b1e
    • P
      Merge remote-tracking branch 'remotes/alistair/tags/pull-riscv-to-apply-20200713' into staging · aeb07b5f
      Peter Maydell 提交于
      This is a colection of bug fixes and small imrprovements for RISC-V.
      
      This includes some vector extensions fixes, a PMP bug fix, OpenTitan
      UART bug fix and support for OpenSBI dynamic firmware.
      
      # gpg: Signature made Tue 14 Jul 2020 01:29:44 BST
      # gpg:                using RSA key F6C4AC46D4934868D3B8CE8F21E10D29DF977054
      # gpg: Good signature from "Alistair Francis <alistair@alistair23.me>" [full]
      # Primary key fingerprint: F6C4 AC46 D493 4868 D3B8  CE8F 21E1 0D29 DF97 7054
      
      * remotes/alistair/tags/pull-riscv-to-apply-20200713:
        target/riscv: Fix pmp NA4 implementation
        tcg/riscv: Remove superfluous breaks
        hw/char: Convert the Ibex UART to use the registerfields API
        hw/char: Convert the Ibex UART to use the qdev Clock model
        target/riscv: fix vill bit index in vtype register
        target/riscv: fix return value of do_opivx_widen()
        target/riscv: correct the gvec IR called in gen_vec_rsub16_i64()
        target/riscv: fix rsub gvec tcg_assert_listed_vecop assertion
        hw/riscv: Modify MROM size to end at 0x10000
        RISC-V: Support 64 bit start address
        riscv: Add opensbi firmware dynamic support
        RISC-V: Copy the fdt in dram instead of ROM
        riscv: Unify Qemu's reset vector code path
        hw/riscv: virt: Sort the SoC memmap table entries
        MAINTAINERS: Add an entry for OpenSBI firmware
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      aeb07b5f
  2. 14 7月, 2020 35 次提交
    • P
      Merge remote-tracking branch 'remotes/juanquintela/tags/migration-pull-request' into staging · beff47a2
      Peter Maydell 提交于
      Migration Pull request
      
      It includes several fixes:
      
      - fix qemu_fclose(denis)
      - remove superfluous breaks (liao)
      - fix memory leak (zheng)
      
      Please apply
      
      [v1 & v2]
      
      There was one error on the huawei address of the 1st patch and mail
      was bouncing.  Fixed.
      
      # gpg: Signature made Mon 13 Jul 2020 18:51:34 BST
      # gpg:                using RSA key 1899FF8EDEBF58CCEE034B82F487EF185872D723
      # gpg: Good signature from "Juan Quintela <quintela@redhat.com>" [full]
      # gpg:                 aka "Juan Quintela <quintela@trasno.org>" [full]
      # Primary key fingerprint: 1899 FF8E DEBF 58CC EE03  4B82 F487 EF18 5872 D723
      
      * remotes/juanquintela/tags/migration-pull-request:
        migration/migration.c: Remove superfluous breaks
        migration/savevm: respect qemu_fclose() error code in save_snapshot()
        migration: fix memory leak in qmp_migrate_set_parameters
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      beff47a2
    • G
      block: Avoid stale pointer dereference in blk_get_aio_context() · e6cada92
      Greg Kurz 提交于
      It is possible for blk_remove_bs() to race with blk_drain_all(), causing
      the latter to dereference a stale blk->root pointer:
      
        blk_remove_bs(blk)
         bdrv_root_unref_child(blk->root)
          child_bs = blk->root->bs
          bdrv_detach_child(blk->root)
           ...
           g_free(blk->root) <============== blk->root becomes stale
          bdrv_unref(child_bs) <============ yield at some point
      
      A blk_drain_all() can be triggered by some guest action in the
      meantime, eg. on POWER, SLOF might disable bus mastering on
      a virtio-scsi-pci device:
      
        virtio_write_config()
         virtio_pci_stop_ioeventfd()
          virtio_bus_stop_ioeventfd()
           virtio_scsi_dataplane_stop()
            blk_drain_all()
             blk_get_aio_context()
             bs = blk->root ? blk->root->bs : NULL
                  ^^^^^^^^^
                    stale
      
      Then, depending on one's luck, QEMU either crashes with SEGV or
      hits the assertion in blk_get_aio_context().
      
      blk->root is set by blk_insert_bs() which calls bdrv_root_attach_child()
      first. The blk_remove_bs() function should rollback the changes made
      by blk_insert_bs() in the opposite order (or it should be documented
      somewhere why this isn't the case). Clear blk->root before calling
      bdrv_root_unref_child() in blk_remove_bs().
      Signed-off-by: NGreg Kurz <groug@kaod.org>
      Message-Id: <159430264541.389456.11925072456012783045.stgit@bahia.lan>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      e6cada92
    • E
      qemu-img: Deprecate use of -b without -F · d9f059aa
      Eric Blake 提交于
      Creating an image that requires format probing of the backing image is
      potentially unsafe (we've had several CVEs over the years based on
      probes leaking information to the guest on a subsequent boot, although
      these days tools like libvirt are aware of the issue enough to prevent
      the worst effects).  For example, if our probing algorithm ever
      changes, or if other tools like libvirt determine a different probe
      result than we do, then subsequent use of that backing file under a
      different format will present corrupted data to the guest.
      Fortunately, the worst effects occur only when the backing image is
      originally raw, and we at least prevent commit into a probed raw
      backing file that would change its probed type.
      
      Still, it is worth starting a deprecation clock so that future
      qemu-img can refuse to create backing chains that would rely on
      probing, to encourage clients to avoid unsafe practices.  Most
      warnings are intentionally emitted from bdrv_img_create() in the block
      layer, but qemu-img convert uses bdrv_create() which cannot emit its
      own warning without causing spurious warnings on other code paths.  In
      the end, all command-line image creation or backing file rewriting now
      performs a check.
      
      Furthermore, if we probe a backing file as non-raw, then it is safe to
      explicitly record that result (rather than relying on future probes);
      only where we probe a raw image do we care about further warnings to
      the user when using such an image (for example, commits into a
      probed-raw backing file are prevented), to help them improve their
      tooling.  But whether or not we make the probe results explicit, we
      still warn the user to remind them to upgrade their workflow to supply
      -F always.
      
      iotest 114 specifically wants to create an unsafe image for later
      amendment rather than defaulting to our new default of recording a
      probed format, so it needs an update.  While touching it, expand it to
      cover all of the various warnings enabled by this patch.  iotest 301
      also shows a change to qcow messages.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <20200706203954.341758-11-eblake@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      d9f059aa
    • E
      block: Add support to warn on backing file change without format · e54ee1b3
      Eric Blake 提交于
      For now, this is a mechanical addition; all callers pass false. But
      the next patch will use it to improve 'qemu-img rebase -u' when
      selecting a backing file with no format.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NPeter Krempa <pkrempa@redhat.com>
      Reviewed-by: NJán Tomko <jtomko@redhat.com>
      Message-Id: <20200706203954.341758-10-eblake@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      e54ee1b3
    • E
      iotests: Specify explicit backing format where sensible · b66ff2c2
      Eric Blake 提交于
      There are many existing qcow2 images that specify a backing file but
      no format.  This has been the source of CVEs in the past, but has
      become more prominent of a problem now that libvirt has switched to
      -blockdev.  With older -drive, at least the probing was always done by
      qemu (so the only risk of a changed format between successive boots of
      a guest was if qemu was upgraded and probed differently).  But with
      newer -blockdev, libvirt must specify a format; if libvirt guesses raw
      where the image was formatted, this results in data corruption visible
      to the guest; conversely, if libvirt guesses qcow2 where qemu was
      using raw, this can result in potential security holes, so modern
      libvirt instead refuses to use images without explicit backing format.
      
      The change in libvirt to reject images without explicit backing format
      has pointed out that a number of tools have been far too reliant on
      probing in the past.  It's time to set a better example in our own
      iotests of properly setting this parameter.
      
      iotest calls to create, rebase, and convert are all impacted to some
      degree.  It's a bit annoying that we are inconsistent on command line
      - while all of those accept -o backing_file=...,backing_fmt=..., the
      shortcuts are different: create and rebase have -b and -F, while
      convert has -B but no -F.  (amend has no shortcuts, but the previous
      patch just deprecated the use of amend to change backing chains).
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <20200706203954.341758-9-eblake@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      b66ff2c2
    • E
      qcow2: Deprecate use of qemu-img amend to change backing file · bc5ee6da
      Eric Blake 提交于
      The use of 'qemu-img amend' to change qcow2 backing files is not
      tested very well.  In particular, our implementation has a bug where
      if a new backing file is provided without a format, then the prior
      format is blindly reused, even if this results in data corruption, but
      this is not caught by iotests.
      
      There are also situations where amending other options needs access to
      the original backing file (for example, on a downgrade to a v2 image,
      knowing whether a v3 zero cluster must be allocated or may be left
      unallocated depends on knowing whether the backing file already reads
      as zero), but the command line does not have a nice way to tell us
      both the backing file to use for opening the image as well as the
      backing file to install after the operation is complete.
      
      Even if we do allow changing the backing file, it is redundant with
      the existing ability to change backing files via 'qemu-img rebase -u'.
      It is time to deprecate this support (leaving the existing behavior
      intact, even if it is buggy), and at a point in the future, require
      the use of only 'qemu-img rebase' for adjusting backing chain
      relations, saving 'qemu-img amend' for changes unrelated to the
      backing chain.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <20200706203954.341758-8-eblake@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      bc5ee6da
    • E
      block: Error if backing file fails during creation without -u · add8200d
      Eric Blake 提交于
      Back in commit 6e6e55f5 (Jul 2017, v2.10), we tweaked the code to warn
      if the backing file could not be opened but the user gave a size,
      unless the user also passes the -u option to bypass the open of the
      backing file.  As one common reason for failure to open the backing
      file is when there is mismatch in the requested backing format in
      relation to what the backing file actually contains, we actually want
      to open the backing file and ensure that it has the right format in as
      many cases as possible.  iotest 301 for qcow demonstrates how
      detecting explicit format mismatch is useful to prevent the creation
      of an image that would probe differently than the user requested.  Now
      is the time to finally turn the warning an error, as promised.
      
      Note that the original warning was added prior to our documentation of
      an official deprecation policy (eb22aeca, also Jul 2017), and because
      the warning didn't mention the word "deprecated", we never actually
      remembered to document it as such.  But the warning has been around
      long enough that I don't see prolonging it another two releases.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <20200706203954.341758-7-eblake@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      add8200d
    • E
      qcow: Tolerate backing_fmt= · 344acbd6
      Eric Blake 提交于
      qcow has no space in the metadata to store a backing format, and there
      are existing qcow images backed both by raw or by other formats
      (usually qcow) images, reliant on probing to tell the difference.  On
      the bright side, because we probe every time, raw files are marked as
      probed and we thus forbid a commit action into the backing file where
      guest-controlled contents could change the result of the probe next
      time around (the iotest added here proves that).
      
      Still, allowing the user to specify the backing format during
      creation, even if we can't record it, is a good thing.  This patch
      blindly allows any value that resolves to a known driver, even if the
      user's request is a mismatch from what probing finds; then the next
      patch will further enhance things to verify that the user's request
      matches what we actually probe.  With this and the next patch in
      place, we will finally be ready to deprecate the creation of images
      where a backing format was not explicitly specified by the user.
      
      Note that this is only for QemuOpts usage; there is no change to the
      QAPI to allow a format through -blockdev.
      
      Add a new iotest 301 just for qcow, to demonstrate the latest
      behavior, and to make it easier to show the improvements made in the
      next patch.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <20200706203954.341758-6-eblake@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      344acbd6
    • E
      vmdk: Add trivial backing_fmt support · d51a814c
      Eric Blake 提交于
      vmdk already requires that if backing_file is present, that it be
      another vmdk image (see vmdk_co_do_create).  Meanwhile, we want to
      move towards always being explicit about the backing format for other
      drivers where it matters.  So for convenience, make qemu-img create -F
      vmdk work, while rejecting all other explicit formats (note that this
      is only for QemuOpts usage; there is no change to the QAPI to allow a
      format through -blockdev).
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <20200706203954.341758-5-eblake@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      d51a814c
    • E
      sheepdog: Add trivial backing_fmt support · 80fa43e7
      Eric Blake 提交于
      Sheepdog already requires that if backing_file is present, that it be
      another sheepdog image (see sd_co_create).  Meanwhile, we want to move
      towards always being explicit about the backing format for other
      drivers where it matters.  So for convenience, make qemu-img create -F
      sheepdog work, while rejecting all other explicit formats (note that
      this is only for QemuOpts usage; there is no change to the QAPI to
      allow a format through -blockdev).
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <20200706203954.341758-4-eblake@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      80fa43e7
    • E
      block: Finish deprecation of 'qemu-img convert -n -o' · 25956af3
      Eric Blake 提交于
      It's been two releases since we started warning; time to make the
      combination an error as promised.  There was no iotest coverage, so
      add some.
      
      While touching the documentation, tweak another section heading for
      consistent style.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <20200706203954.341758-3-eblake@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      25956af3
    • E
      qemu-img: Flush stdout before before potential stderr messages · 4e2f4418
      Eric Blake 提交于
      During 'qemu-img create ... 2>&1', if --quiet is not in force, we can
      end up with buffered I/O in stdout that was produced before failure,
      but which appears in output after failure.  This is confusing; the fix
      is to flush stdout prior to attempting anything that might produce an
      error message.  Several iotests demonstrate the resulting ordering
      change now that the merged outputs now reflect chronology.  (An even
      better fix would be to avoid printf from within block.c altogether,
      but that's much more invasive...)
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <20200706203954.341758-2-eblake@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      4e2f4418
    • K
      file-posix: Mitigate file fragmentation with extent size hints · ffa244c8
      Kevin Wolf 提交于
      Especially when O_DIRECT is used with image files so that the page cache
      indirection can't cause a merge of allocating requests, the file will
      fragment on the file system layer, with a potentially very small
      fragment size (this depends on the requests the guest sent).
      
      On Linux, fragmentation can be reduced by setting an extent size hint
      when creating the file (at least on XFS, it can't be set any more after
      the first extent has been allocated), basically giving raw files a
      "cluster size" for allocation.
      
      This adds a create option to set the extent size hint, and changes the
      default from not setting a hint to setting it to 1 MB. The main reason
      why qcow2 defaults to smaller cluster sizes is that COW becomes more
      expensive, which is not an issue with raw files, so we can choose a
      larger size. The tradeoff here is only potentially wasted disk space.
      
      For qcow2 (or other image formats) over file-posix, the advantage should
      even be greater because they grow sequentially without leaving holes, so
      there won't be wasted space. Setting even larger extent size hints for
      such images may make sense. This can be done with the new option, but
      let's keep the default conservative for now.
      
      The effect is very visible with a test that intentionally creates a
      badly fragmented file with qemu-img bench (the time difference while
      creating the file is already remarkable) and then looks at the number of
      extents and the time a simple "qemu-img map" takes.
      
      Without an extent size hint:
      
          $ ./qemu-img create -f raw -o extent_size_hint=0 ~/tmp/test.raw 10G
          Formatting '/home/kwolf/tmp/test.raw', fmt=raw size=10737418240 extent_size_hint=0
          $ ./qemu-img bench -f raw -t none -n -w ~/tmp/test.raw -c 1000000 -S 8192 -o 0
          Sending 1000000 write requests, 4096 bytes each, 64 in parallel (starting at offset 0, step size 8192)
          Run completed in 25.848 seconds.
          $ ./qemu-img bench -f raw -t none -n -w ~/tmp/test.raw -c 1000000 -S 8192 -o 4096
          Sending 1000000 write requests, 4096 bytes each, 64 in parallel (starting at offset 4096, step size 8192)
          Run completed in 19.616 seconds.
          $ filefrag ~/tmp/test.raw
          /home/kwolf/tmp/test.raw: 2000000 extents found
          $ time ./qemu-img map ~/tmp/test.raw
          Offset          Length          Mapped to       File
          0               0x1e8480000     0               /home/kwolf/tmp/test.raw
      
          real    0m1,279s
          user    0m0,043s
          sys     0m1,226s
      
      With the new default extent size hint of 1 MB:
      
          $ ./qemu-img create -f raw -o extent_size_hint=1M ~/tmp/test.raw 10G
          Formatting '/home/kwolf/tmp/test.raw', fmt=raw size=10737418240 extent_size_hint=1048576
          $ ./qemu-img bench -f raw -t none -n -w ~/tmp/test.raw -c 1000000 -S 8192 -o 0
          Sending 1000000 write requests, 4096 bytes each, 64 in parallel (starting at offset 0, step size 8192)
          Run completed in 11.833 seconds.
          $ ./qemu-img bench -f raw -t none -n -w ~/tmp/test.raw -c 1000000 -S 8192 -o 4096
          Sending 1000000 write requests, 4096 bytes each, 64 in parallel (starting at offset 4096, step size 8192)
          Run completed in 10.155 seconds.
          $ filefrag ~/tmp/test.raw
          /home/kwolf/tmp/test.raw: 178 extents found
          $ time ./qemu-img map ~/tmp/test.raw
          Offset          Length          Mapped to       File
          0               0x1e8480000     0               /home/kwolf/tmp/test.raw
      
          real    0m0,061s
          user    0m0,040s
          sys     0m0,014s
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      Message-Id: <20200707142329.48303-1-kwolf@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      ffa244c8
    • K
      iotests/059: Filter out disk size with more standard filter · 046e07ca
      Kevin Wolf 提交于
      The actual disk space used by an image can vary between filesystems and
      depending on other settings like an extent size hint. Replace the one
      call of "$QEMU_IMG info" and the associated one-off sed filter with the
      more standard "_img_info" and the standard filter from common.filter.
      
      Apart from turning "vmdk" into "IMGFMT" and changing the placeholder for
      cid fields, this only removes the "disk size" line.
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      046e07ca
    • K
      qemu-img map: Don't limit block status request size · d0ceea88
      Kevin Wolf 提交于
      Limiting each loop iteration of qemu-img map to 1 GB was arbitrary from
      the beginning, though it only cut the maximum in half then because the
      interface was a signed 32 bit byte count. These days, bdrv_block_status
      supports a 64 bit byte count, so the arbitrary limit is even worse.
      
      On file-posix, bdrv_block_status() eventually maps to SEEK_HOLE and
      SEEK_DATA, which don't support a limit, but always do all of the work
      necessary to find the start of the next hole/data. Much of this work may
      be repeated if we don't use this information fully, but query with an
      only slightly larger offset in the next loop iteration. Therefore, if
      bdrv_block_status() is called in a loop, it should always pass the
      full number of bytes that the whole loop is interested in.
      
      This removes the arbitrary limit and speeds up 'qemu-img map'
      significantly on heavily fragmented images.
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      Message-Id: <20200707144629.51235-1-kwolf@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      d0ceea88
    • M
      iotests: Simplify _filter_img_create() a bit · 4b196cd1
      Max Reitz 提交于
      Not only is it a bit stupid to try to filter multi-line "Formatting"
      output (because we only need it for a single test, which can easily be
      amended to no longer need it), it is also problematic when there can be
      output after a "Formatting" line that we do not want to filter as if it
      were part of it.
      
      So rename _filter_img_create to _do_filter_img_create, let it filter
      only a single line, and let _filter_img_create loop over all input
      lines, calling _do_filter_img_create only on those that match
      /^Formatting/ (basically, what _filter_img_create_in_qmp did already).
      (And fix 020 to work with that.)
      Reported-by: NKevin Wolf <kwolf@redhat.com>
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      Message-Id: <20200709110205.310942-1-mreitz@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      4b196cd1
    • P
      Merge remote-tracking branch 'remotes/ericb/tags/pull-nbd-2020-07-13' into staging · 1a53dfee
      Peter Maydell 提交于
      NBD patches for 2020-07-13
      
      - fix off-by-one truncation in corner-case name display
      - use fcntl correctly
      - iotest cleanups that enable testing an upcoming fix for NBD close
      
      # gpg: Signature made Mon 13 Jul 2020 15:11:35 BST
      # gpg:                using RSA key 71C2CC22B1C4602927D2F3AAA7A16B4A2527436A
      # gpg: Good signature from "Eric Blake <eblake@redhat.com>" [full]
      # gpg:                 aka "Eric Blake (Free Software Programmer) <ebb9@byu.net>" [full]
      # gpg:                 aka "[jpeg image of size 6874]" [full]
      # Primary key fingerprint: 71C2 CC22 B1C4 6029 27D2  F3AA A7A1 6B4A 2527 436A
      
      * remotes/ericb/tags/pull-nbd-2020-07-13:
        iotests.py: filter_testfiles(): filter SOCK_DIR too
        iotests.py: QemuIoInteractive: print output on failure
        iotests: QemuIoInteractive: use qemu_io_args_no_fmt
        hax: Fix setting of FD_CLOEXEC
        nbd: Avoid off-by-one in long export name truncation
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      1a53dfee
    • A
      target/riscv: Fix pmp NA4 implementation · cfad709b
      Alexandre Mergnat 提交于
      The end address calculation for NA4 mode is wrong because the address
      used isn't shifted.
      
      It doesn't watch 4 bytes but a huge range because the end address
      calculation is wrong.
      
      The solution is to use the shifted address calculated for start address
      variable.
      
      Modifications are tested on Zephyr OS userspace test suite which works
      for other RISC-V boards (E31 and E34 core).
      Signed-off-by: NAlexandre Mergnat <amergnat@baylibre.com>
      Reviewed-by: NAlistair Francis <alistair.francis@wdc.com>
      Message-id: 20200706084550.24117-1-amergnat@baylibre.com
      Message-Id: <20200706084550.24117-1-amergnat@baylibre.com>
      [ Changes by AF:
       - Improve the commit title and message
      ]
      Signed-off-by: NAlistair Francis <alistair.francis@wdc.com>
      cfad709b
    • L
      tcg/riscv: Remove superfluous breaks · 895bfa84
      Liao Pingfang 提交于
      Remove superfluous breaks, as there is a "return" before them.
      Signed-off-by: NLiao Pingfang <liao.pingfang@zte.com.cn>
      Signed-off-by: NYi Wang <wang.yi59@zte.com.cn>
      Reviewed-by: NPhilippe Mathieu-Daudé <f4bug@amsat.org>
      Reviewed-by: NThomas Huth <thuth@redhat.com>
      Reviewed-by: NAlistair Francis <alistair.francis@wdc.com>
      Message-Id: <1594600421-22942-1-git-send-email-wang.yi59@zte.com.cn>
      Signed-off-by: NAlistair Francis <alistair.francis@wdc.com>
      895bfa84
    • A
      hw/char: Convert the Ibex UART to use the registerfields API · 59093cc4
      Alistair Francis 提交于
      Signed-off-by: NAlistair Francis <alistair.francis@wdc.com>
      Message-id: 06372c9cdeec715077899e71c858d9f0a2a3395b.1594332223.git.alistair.francis@wdc.com
      Message-Id: <06372c9cdeec715077899e71c858d9f0a2a3395b.1594332223.git.alistair.francis@wdc.com>
      59093cc4
    • A
      hw/char: Convert the Ibex UART to use the qdev Clock model · 940aabb9
      Alistair Francis 提交于
      Conver the Ibex UART to use the recently added qdev-clock functions.
      Signed-off-by: NAlistair Francis <alistair.francis@wdc.com>
      Reviewed-by: NPhilippe Mathieu-Daudé <f4bug@amsat.org>
      Message-id: b0136fad870a29049959ec161c1217b967d7e19d.1594332223.git.alistair.francis@wdc.com
      Message-Id: <b0136fad870a29049959ec161c1217b967d7e19d.1594332223.git.alistair.francis@wdc.com>
      940aabb9
    • F
      target/riscv: fix vill bit index in vtype register · fbcbafa2
      Frank Chang 提交于
      vill bit is at vtype[XLEN-1].
      Signed-off-by: NFrank Chang <frank.chang@sifive.com>
      Reviewed-by: NRichard Henderson <richard.henderson@linaro.org>
      Message-Id: <20200710104920.13550-5-frank.chang@sifive.com>
      Signed-off-by: NAlistair Francis <alistair.francis@wdc.com>
      fbcbafa2
    • F
      target/riscv: fix return value of do_opivx_widen() · a69f97c1
      Frank Chang 提交于
      do_opivx_widen() should return false if check function returns false.
      Signed-off-by: NFrank Chang <frank.chang@sifive.com>
      Reviewed-by: NRichard Henderson <richard.henderson@linaro.org>
      Message-Id: <20200710104920.13550-4-frank.chang@sifive.com>
      Signed-off-by: NAlistair Francis <alistair.francis@wdc.com>
      a69f97c1
    • F
      target/riscv: correct the gvec IR called in gen_vec_rsub16_i64() · 1989205c
      Frank Chang 提交于
      Signed-off-by: NFrank Chang <frank.chang@sifive.com>
      Reviewed-by: NRichard Henderson <richard.henderson@linaro.org>
      Message-Id: <20200710104920.13550-3-frank.chang@sifive.com>
      Signed-off-by: NAlistair Francis <alistair.francis@wdc.com>
      1989205c
    • F
      target/riscv: fix rsub gvec tcg_assert_listed_vecop assertion · 7acafcfa
      Frank Chang 提交于
      gvec should provide vecop_list to avoid:
      "tcg_tcg_assert_listed_vecop: code should not be reached bug" assertion.
      Signed-off-by: NFrank Chang <frank.chang@sifive.com>
      Reviewed-by: NRichard Henderson <richard.henderson@linaro.org>
      Message-Id: <20200710104920.13550-2-frank.chang@sifive.com>
      Signed-off-by: NAlistair Francis <alistair.francis@wdc.com>
      7acafcfa
    • B
      hw/riscv: Modify MROM size to end at 0x10000 · 9eb8b14a
      Bin Meng 提交于
      At present the size of Mask ROM for sifive_u / spike / virt machines
      is set to 0x11000, which ends at an unusual address. This changes the
      size to 0xf000 so that it ends at 0x10000.
      Signed-off-by: NBin Meng <bin.meng@windriver.com>
      Reviewed-by: NPhilippe Mathieu-Daudé <f4bug@amsat.org>
      Message-Id: <1594289144-24723-1-git-send-email-bmeng.cn@gmail.com>
      Signed-off-by: NAlistair Francis <alistair.francis@wdc.com>
      9eb8b14a
    • A
      RISC-V: Support 64 bit start address · 8590f536
      Atish Patra 提交于
      Even though the start address in ROM code is declared as a 64 bit address
      for RV64, it can't be used as upper bits are set to zero in ROM code.
      
      Update the ROM code correctly to reflect the 64bit value.
      Signed-off-by: NAtish Patra <atish.patra@wdc.com>
      Reviewed-by: NBin Meng <bin.meng@windriver.com>
      Tested-by: NBin Meng <bin.meng@windriver.com>
      Message-Id: <20200701183949.398134-5-atish.patra@wdc.com>
      Signed-off-by: NAlistair Francis <alistair.francis@wdc.com>
      8590f536
    • A
      riscv: Add opensbi firmware dynamic support · dc144fe1
      Atish Patra 提交于
      OpenSBI is the default firmware in Qemu and has various firmware loading
      options. Currently, qemu loader uses fw_jump which has a compile time
      pre-defined address where fdt & kernel image must reside. This puts a
      constraint on image size of the Linux kernel depending on the fdt location
      and available memory. However, fw_dynamic allows the loader to specify
      the next stage location (i.e. Linux kernel/U-Boot) in memory and other
      configurable boot options available in OpenSBI.
      
      Add support for OpenSBI dynamic firmware loading support. This doesn't
      break existing setup and fw_jump will continue to work as it is. Any
      other firmware will continue to work without any issues as long as it
      doesn't expect anything specific from loader in "a2" register.
      Signed-off-by: NAtish Patra <atish.patra@wdc.com>
      Reviewed-by: NAlistair Francis <alistair.francis@wdc.com>
      Reviewed-by: NBin Meng <bin.meng@windriver.com>
      Tested-by: NBin Meng <bin.meng@windriver.com>
      Message-Id: <20200701183949.398134-4-atish.patra@wdc.com>
      Signed-off-by: NAlistair Francis <alistair.francis@wdc.com>
      dc144fe1
    • A
      RISC-V: Copy the fdt in dram instead of ROM · 66b1205b
      Atish Patra 提交于
      Currently, the fdt is copied to the ROM after the reset vector. The firmware
      has to copy it to DRAM. Instead of this, directly copy the device tree to a
      pre-computed dram address. The device tree load address should be as far as
      possible from kernel and initrd images. That's why it is kept at the end of
      the DRAM or 4GB whichever is lesser.
      Signed-off-by: NAtish Patra <atish.patra@wdc.com>
      Reviewed-by: NAlistair Francis <alistair.francis@wdc.com>
      Reviewed-by: NBin Meng <bin.meng@windriver.com>
      Tested-by: NBin Meng <bin.meng@windriver.com>
      Message-Id: <20200701183949.398134-3-atish.patra@wdc.com>
      Signed-off-by: NAlistair Francis <alistair.francis@wdc.com>
      66b1205b
    • A
      riscv: Unify Qemu's reset vector code path · 43cf723a
      Atish Patra 提交于
      Currently, all riscv machines except sifive_u have identical reset vector
      code implementations with memory addresses being different for all machines.
      They can be easily combined into a single function in common code.
      
      Move it to common function and let all the machines use the common function.
      Signed-off-by: NAtish Patra <atish.patra@wdc.com>
      Reviewed-by: NAlistair Francis <alistair.francis@wdc.com>
      Reviewed-by: NBin Meng <bin.meng@windriver.com>
      Tested-by: NBin Meng <bin.meng@windriver.com>
      Message-Id: <20200701183949.398134-2-atish.patra@wdc.com>
      Signed-off-by: NAlistair Francis <alistair.francis@wdc.com>
      43cf723a
    • B
      hw/riscv: virt: Sort the SoC memmap table entries · 2c44bbf3
      Bin Meng 提交于
      Adjust the PCIe memory maps to follow the order.
      Signed-off-by: NBin Meng <bin.meng@windriver.com>
      Reviewed-by: NAlistair Francis <alistair.francis@wdc.com>
      Message-Id: <1593746511-19517-1-git-send-email-bmeng.cn@gmail.com>
      Signed-off-by: NAlistair Francis <alistair.francis@wdc.com>
      2c44bbf3
    • B
      MAINTAINERS: Add an entry for OpenSBI firmware · e92fb016
      Bin Meng 提交于
      List me as the maintainer for OpenSBI firmware related files.
      Signed-off-by: NBin Meng <bmeng.cn@gmail.com>
      Reviewed-by: NPhilippe Mathieu-Daudé <philmd@redhat.com>
      Message-Id: <1593177220-28143-1-git-send-email-bmeng.cn@gmail.com>
      Signed-off-by: NAlistair Francis <alistair.francis@wdc.com>
      e92fb016
    • L
      migration/migration.c: Remove superfluous breaks · eb9bd46f
      Liao Pingfang 提交于
      Remove superfluous breaks, as there is a "return" before them.
      Signed-off-by: NLiao Pingfang <liao.pingfang@zte.com.cn>
      Signed-off-by: NYi Wang <wang.yi59@zte.com.cn>
      Reviewed-by: NPhilippe Mathieu-Daudé <f4bug@amsat.org>
      Reviewed-by: NJuan Quintela <quintela@redhat.com>
      Reviewed-by: NThomas Huth <thuth@redhat.com>
      Signed-off-by: NJuan Quintela <quintela@redhat.com>
      eb9bd46f
    • D
      migration/savevm: respect qemu_fclose() error code in save_snapshot() · 66270a47
      Denis V. Lunev 提交于
      qemu_fclose() could return error, f.e. if bdrv_co_flush() will return
      the error.
      
      This validation will become more important once we will start waiting of
      asynchronous IO operations, started from bdrv_write_vmstate(), which are
      coming soon.
      Signed-off-by: NDenis V. Lunev <den@openvz.org>
      Reviewed-by: N"Dr. David Alan Gilbert" <dgilbert@redhat.com>
      Reviewed-by: NVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
      Reviewed-by: NJuan Quintela <quintela@redhat.com>
      CC: Kevin Wolf <kwolf@redhat.com>
      CC: Max Reitz <mreitz@redhat.com>
      CC: Stefan Hajnoczi <stefanha@redhat.com>
      CC: Fam Zheng <fam@euphon.net>
      CC: Juan Quintela <quintela@redhat.com>
      CC: Denis Plotnikov <dplotnikov@virtuozzo.com>
      Signed-off-by: NJuan Quintela <quintela@redhat.com>
      66270a47
    • Z
      migration: fix memory leak in qmp_migrate_set_parameters · 9728ebfb
      Zheng Chuan 提交于
      "tmp.tls_hostname" and "tmp.tls_creds" allocated by migrate_params_test_apply()
      is forgot to free at the end of qmp_migrate_set_parameters(). Fix that.
      
      The leak stack:
      Direct leak of 2 byte(s) in 2 object(s) allocated from:
         #0 0xffffb597c20b in __interceptor_malloc (/usr/lib64/libasan.so.4+0xd320b)
         #1 0xffffb52dcb1b in g_malloc (/usr/lib64/libglib-2.0.so.0+0x58b1b)
         #2 0xffffb52f8143 in g_strdup (/usr/lib64/libglib-2.0.so.0+0x74143)
         #3 0xaaaac52447fb in migrate_params_test_apply (/usr/src/debug/qemu-4.1.0/migration/migration.c:1377)
         #4 0xaaaac52fdca7 in qmp_migrate_set_parameters (/usr/src/debug/qemu-4.1.0/qapi/qapi-commands-migration.c:192)
         #5 0xaaaac551d543 in qmp_dispatch (/usr/src/debug/qemu-4.1.0/qapi/qmp-dispatch.c:165)
         #6 0xaaaac52a0a8f in qmp_dispatch (/usr/src/debug/qemu-4.1.0/monitor/qmp.c:125)
         #7 0xaaaac52a1c7f in monitor_qmp_dispatch (/usr/src/debug/qemu-4.1.0/monitor/qmp.c:214)
         #8 0xaaaac55cb0cf in aio_bh_call (/usr/src/debug/qemu-4.1.0/util/async.c:117)
         #9 0xaaaac55d4543 in aio_bh_poll (/usr/src/debug/qemu-4.1.0/util/aio-posix.c:459)
         #10 0xaaaac55cae0f in aio_dispatch (/usr/src/debug/qemu-4.1.0/util/async.c:268)
         #11 0xffffb52d6a7b in g_main_context_dispatch (/usr/lib64/libglib-2.0.so.0+0x52a7b)
         #12 0xaaaac55d1e3b(/usr/bin/qemu-kvm-4.1.0+0x1622e3b)
         #13 0xaaaac4e314bb(/usr/bin/qemu-kvm-4.1.0+0xe824bb)
         #14 0xaaaac47f45ef(/usr/bin/qemu-kvm-4.1.0+0x8455ef)
         #15 0xffffb4bfef3f in __libc_start_main (/usr/lib64/libc.so.6+0x23f3f)
         #16 0xaaaac47ffacb(/usr/bin/qemu-kvm-4.1.0+0x850acb)
      
      Direct leak of 2 byte(s) in 2 object(s) allocated from:
         #0 0xffffb597c20b in __interceptor_malloc (/usr/lib64/libasan.so.4+0xd320b)
         #1 0xffffb52dcb1b in g_malloc (/usr/lib64/libglib-2.0.so.0+0x58b1b)
         #2 0xffffb52f8143 in g_strdup (/usr/lib64/libglib-2.0.so.0+0x74143)
         #3 0xaaaac5244893 in migrate_params_test_apply (/usr/src/debug/qemu-4.1.0/migration/migration.c:1382)
         #4 0xaaaac52fdca7 in qmp_migrate_set_parameters (/usr/src/debug/qemu-4.1.0/qapi/qapi-commands-migration.c:192)
         #5 0xaaaac551d543 in qmp_dispatch (/usr/src/debug/qemu-4.1.0/qapi/qmp-dispatch.c)
         #6 0xaaaac52a0a8f in qmp_dispatch (/usr/src/debug/qemu-4.1.0/monitor/qmp.c:125)
         #7 0xaaaac52a1c7f in monitor_qmp_dispatch (/usr/src/debug/qemu-4.1.0/monitor/qmp.c:214)
         #8 0xaaaac55cb0cf in aio_bh_call (/usr/src/debug/qemu-4.1.0/util/async.c:117)
         #9 0xaaaac55d4543 in aio_bh_poll (/usr/src/debug/qemu-4.1.0/util/aio-posix.c:459)
         #10 0xaaaac55cae0f in in aio_dispatch (/usr/src/debug/qemu-4.1.0/util/async.c:268)
         #11 0xffffb52d6a7b in g_main_context_dispatch (/usr/lib64/libglib-2.0.so.0+0x52a7b)
         #12 0xaaaac55d1e3b(/usr/bin/qemu-kvm-4.1.0+0x1622e3b)
         #13 0xaaaac4e314bb(/usr/bin/qemu-kvm-4.1.0+0xe824bb)
         #14 0xaaaac47f45ef (/usr/bin/qemu-kvm-4.1.0+0x8455ef)
         #15 0xffffb4bfef3f in __libc_start_main (/usr/lib64/libc.so.6+0x23f3f)
         #16 0xaaaac47ffacb(/usr/bin/qemu-kvm-4.1.0+0x850acb)
      Signed-off-by: NChuan Zheng <zhengchuan@huawei.com>
      Reviewed-by: NKeQian Zhu <zhukeqian1@huawei.com>
      Reviewed-by: NHaiLiang <zhang.zhanghailiang@huawei.com>
      Reviewed-by: NJuan Quintela <quintela@redhat.com>
      Signed-off-by: NJuan Quintela <quintela@redhat.com>
      9728ebfb
  3. 13 7月, 2020 3 次提交
    • P
      Merge remote-tracking branch 'remotes/kraxel/tags/fixes-20200713-pull-request' into staging · 20c1df54
      Peter Maydell 提交于
      bugfixes for audio, usb, ui and docs.
      
      # gpg: Signature made Mon 13 Jul 2020 15:10:35 BST
      # gpg:                using RSA key 4CB6D8EED3E87138
      # gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>" [full]
      # gpg:                 aka "Gerd Hoffmann <gerd@kraxel.org>" [full]
      # gpg:                 aka "Gerd Hoffmann (private) <kraxel@gmail.com>" [full]
      # Primary key fingerprint: A032 8CFF B93A 17A7 9901  FE7D 4CB6 D8EE D3E8 7138
      
      * remotes/kraxel/tags/fixes-20200713-pull-request:
        usb: fix usb-host build on windows.
        ui: fix vc_chr_write call in text_console_do_init
        docs/qdev-device-use: Clean up the sentences related to -usbdevice
        ossaudio: fix out of bounds write
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      20c1df54
    • P
      Merge remote-tracking branch 'remotes/pmaydell/tags/pull-target-arm-20200713' into staging · 5c65b1f1
      Peter Maydell 提交于
      target-arm queue:
       * hw/arm/bcm2836: Remove unused 'cpu_type' field
       * target/arm: Fix mtedesc for do_mem_zpz
       * Add the ability to change the FEC PHY MDIO device number on i.MX25/i.MX6/i.MX7
       * target/arm: Don't do raw writes for PMINTENCLR
       * virtio-iommu: Fix coverity issue in virtio_iommu_handle_command()
       * build: Fix various issues with building on Haiku
       * target/nios2: fix wrctl behaviour when using icount
       * hw/arm/tosa: Encapsulate misc GPIO handling in a device
       * hw/arm/palm.c: Encapsulate misc GPIO handling in a device
       * hw/arm/aspeed: Do not create and attach empty SD cards by default
      
      # gpg: Signature made Mon 13 Jul 2020 15:08:16 BST
      # gpg:                using RSA key E1A5C593CD419DE28E8315CF3C2525ED14360CDE
      # gpg:                issuer "peter.maydell@linaro.org"
      # gpg: Good signature from "Peter Maydell <peter.maydell@linaro.org>" [ultimate]
      # gpg:                 aka "Peter Maydell <pmaydell@gmail.com>" [ultimate]
      # gpg:                 aka "Peter Maydell <pmaydell@chiark.greenend.org.uk>" [ultimate]
      # Primary key fingerprint: E1A5 C593 CD41 9DE2 8E83  15CF 3C25 25ED 1436 0CDE
      
      * remotes/pmaydell/tags/pull-target-arm-20200713: (25 commits)
        hw/arm/aspeed: Do not create and attach empty SD cards by default
        hw/arm/palm.c: Encapsulate misc GPIO handling in a device
        hw/arm/palm.c: Detabify
        hw/arm/tosa: Encapsulate misc GPIO handling in a device
        hw/arm/tosa.c: Detabify
        hw/nios2: exit to main CPU loop only when unmasking interrupts
        target/nios2: Use gen_io_start around wrctl instruction
        target/nios2: in line the semantics of DISAS_UPDATE with other targets
        target/nios2: add DISAS_NORETURN case for nothing more to generate
        util/drm: make portable by avoiding struct dirent d_type
        util/oslib-posix.c: Implement qemu_init_exec_dir() for Haiku
        util/compatfd.c: Only include <sys/syscall.h> if CONFIG_SIGNALFD
        bswap.h: Include <endian.h> on Haiku for bswap operations
        osdep.h: For Haiku, define SIGIO as equivalent to SIGPOLL
        osdep.h: Always include <sys/signal.h> if it exists
        build: Check that mlockall() exists
        util/qemu-openpty.c: Don't assume pty.h is glibc-only
        build: Enable BSD symbols for Haiku
        virtio-iommu: Fix coverity issue in virtio_iommu_handle_command()
        target/arm: Don't do raw writes for PMINTENCLR
        ...
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      5c65b1f1
    • V
      iotests.py: filter_testfiles(): filter SOCK_DIR too · df0e032b
      Vladimir Sementsov-Ogievskiy 提交于
      Signed-off-by: NVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
      Message-Id: <20200701105331.121670-5-vsementsov@virtuozzo.com>
      Signed-off-by: NEric Blake <eblake@redhat.com>
      df0e032b