Commits on May 30, 2023

  1. gitlab-ci: crash-test-debian: make it verbose (remove -q)

    Michael Tokarev committed May 30, 2023
    Copy the full SHA
    26df00f View commit details
    Browse the repository at this point in the history
  2. vnc: avoid underflow when accessing user-provided address

    If hostlen is zero, there is a possibility that addrstr[hostlen - 1]
    underflows and, if a closing bracked is there, hostlen - 2 is passed
    to g_strndup() on the next line.  If websocket==false then
    addrstr[0] would be a colon, but if websocket==true this could in
    principle happen.
    
    Fix it by checking hostlen.
    
    Reported by Coverity.
    
    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
    (cherry picked from commit 3f9c41c)
    Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
    bonzini authored and Michael Tokarev committed May 30, 2023
    Copy the full SHA
    814eda6 View commit details
    Browse the repository at this point in the history
  3. target/i386: Change wrong XFRM value in SGX CPUID leaf

    The previous patch wrongly replaced FEAT_XSAVE_XCR0_{LO|HI} with
    FEAT_XSAVE_XSS_{LO|HI} in CPUID(EAX=12,ECX=1):{ECX,EDX}.  As a result,
    SGX enclaves only supported SSE and x87 feature (xfrm=0x3).
    
    Fixes: 301e906 ("target/i386: Enable support for XSAVES based features")
    Signed-off-by: Yang Zhong <yang.zhong@linux.intel.com>
    Reviewed-by: Yang Weijiang <weijiang.yang@intel.com>
    Reviewed-by: Kai Huang <kai.huang@intel.com>
    Message-Id: <20230406064041.420039-1-yang.zhong@linux.intel.com>
    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
    (cherry picked from commit 72497cf)
    Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
    Yang Zhong authored and Michael Tokarev committed May 30, 2023
    Copy the full SHA
    464aaf8 View commit details
    Browse the repository at this point in the history
  4. hw/timer/imx_epit: don't shadow variable

    Fix issue reported by Coverity.
    
    Signed-off-by: Axel Heider <axel.heider@hensoldt.net>
    Message-id: 168070611775.20412.2883242077302841473-1@git.sr.ht
    Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
    Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
    (cherry picked from commit 542fd43)
    Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
    Axel Heider authored and Michael Tokarev committed May 30, 2023
    Copy the full SHA
    14a40a9 View commit details
    Browse the repository at this point in the history
  5. hw/timer/imx_epit: fix limit check

    Fix the limit check. If the limit is less than the compare value,
    the timer can never reach this value, thus it will never fire.
    
    Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1491
    Signed-off-by: Axel Heider <axel.heider@hensoldt.net>
    Message-id: 168070611775.20412.2883242077302841473-2@git.sr.ht
    Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
    Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
    (cherry picked from commit 25d7581)
    Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
    Axel Heider authored and Michael Tokarev committed May 30, 2023
    Copy the full SHA
    5810375 View commit details
    Browse the repository at this point in the history
  6. acpi: pcihp: allow repeating hot-unplug requests

    with Q35 using ACPI PCI hotplug by default, user's request to unplug
    device is ignored when it's issued before guest OS has been booted.
    And any additional attempt to request device hot-unplug afterwards
    results in following error:
    
      "Device XYZ is already in the process of unplug"
    
    arguably it can be considered as a regression introduced by [2],
    before which it was possible to issue unplug request multiple
    times.
    
    Accept new uplug requests after timeout (1ms). This brings ACPI PCI
    hotplug on par with native PCIe unplug behavior [1] and allows user
    to repeat unplug requests at propper times.
    Set expire timeout to arbitrary 1msec so user won't be able to
    flood guest with SCI interrupts by calling device_del in tight loop.
    
    PS:
    ACPI spec doesn't mandate what OSPM can do with GPEx.status
    bits set before it's booted => it's impl. depended.
    Status bits may be retained (I tested with one Windows version)
    or cleared (Linux since 2.6 kernel times) during guest's ACPI
    subsystem initialization.
    Clearing status bits (though not wrong per se) hides the unplug
    event from guest, and it's upto user to repeat device_del later
    when guest is able to handle unplug requests.
    
    1) 18416c6 ("pcie: expire pending delete")
    2)
    Fixes: cce8944 ("qdev-monitor: Forbid repeated device_del")
    Signed-off-by: Igor Mammedov <imammedo@redhat.com>
    Acked-by: Gerd Hoffmann <kraxel@redhat.com>
    CC: mst@redhat.com
    CC: anisinha@redhat.com
    CC: jusual@redhat.com
    CC: kraxel@redhat.com
    Message-Id: <20230418090449.2155757-1-imammedo@redhat.com>
    Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
    Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
    Reviewed-by: Ani Sinha <anisinha@redhat.com>
    (cherry picked from commit 0f689cf)
    Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
    Igor Mammedov authored and Michael Tokarev committed May 30, 2023
    Copy the full SHA
    e8df2d6 View commit details
    Browse the repository at this point in the history
  7. block/monitor: Fix crash when executing HMP commit

    hmp_commit() calls blk_is_available() from a non-coroutine context (and
    in the main loop). blk_is_available() is a co_wrapper_mixed_bdrv_rdlock
    function, and in the non-coroutine context it calls AIO_WAIT_WHILE(),
    which crashes if the aio_context lock is not taken before.
    
    Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1615
    Signed-off-by: Wang Liang <wangliangzz@inspur.com>
    Message-Id: <20230424103902.45265-1-wangliangzz@126.com>
    Reviewed-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
    Reviewed-by: Kevin Wolf <kwolf@redhat.com>
    Signed-off-by: Kevin Wolf <kwolf@redhat.com>
    (cherry picked from commit 8c1e8fb)
    Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
    Wang Liang authored and Michael Tokarev committed May 30, 2023
    Copy the full SHA
    4520611 View commit details
    Browse the repository at this point in the history
  8. qemu-options: finesse the recommendations around -blockdev

    We are a bit premature in recommending -blockdev/-device as the best
    way to configure block devices. It seems there are times the more
    human friendly -drive still makes sense especially when -snapshot is
    involved.
    
    Improve the language to hopefully make things clearer.
    
    Suggested-by: Michael Tokarev <mjt@tls.msk.ru>
    Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
    Reviewed-by: Thomas Huth <thuth@redhat.com>
    Cc: Markus Armbruster <armbru@redhat.com>
    Cc: Kevin Wolf <kwolf@redhat.com>
    Message-Id: <20230424092249.58552-7-alex.bennee@linaro.org>
    (cherry picked from commit c1654c3)
    Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
    stsquad authored and Michael Tokarev committed May 30, 2023
    Copy the full SHA
    ae7daf9 View commit details
    Browse the repository at this point in the history
  9. docs/about/deprecated.rst: Add "since 7.1" tag to dtb-kaslr-seed depr…

    …ecation
    
    In commit 5242876 we deprecated the dtb-kaslr-seed property of
    the virt board, but forgot the "since n.n" tag in the documentation
    of this in deprecated.rst.
    
    This deprecation note first appeared in the 7.1 release, so
    retrospectively add the correct "since 7.1" annotation to it.
    
    Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
    Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
    Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
    Message-id: 20230420122256.1023709-1-peter.maydell@linaro.org
    (cherry picked from commit ac64ebb)
    Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
    pm215 authored and Michael Tokarev committed May 30, 2023
    Copy the full SHA
    2a999aa View commit details
    Browse the repository at this point in the history
  10. target/arm: Initialize debug capabilities only once

    kvm_arm_init_debug() used to be called several times on a SMP system as
    kvm_arch_init_vcpu() calls it. Move the call to kvm_arch_init() to make
    sure it will be called only once; otherwise it will overwrite pointers
    to memory allocated with the previous call and leak it.
    
    Fixes: e4482ab ("target-arm: kvm - add support for HW assisted debug")
    Suggested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
    Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
    Message-id: 20230405153644.25300-1-akihiko.odaki@daynix.com
    Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
    Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
    (cherry picked from commit ad5c6dd)
    Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
    akihikodaki authored and Michael Tokarev committed May 30, 2023
    Copy the full SHA
    f298d34 View commit details
    Browse the repository at this point in the history
  11. hw/net/msf2-emac: Don't modify descriptor in-place in emac_store_desc()

    The msf2-emac ethernet controller has functions emac_load_desc() and
    emac_store_desc() which read and write the in-memory descriptor
    blocks and handle conversion between guest and host endianness.
    
    As currently written, emac_store_desc() does the endianness
    conversion in-place; this means that it effectively consumes the
    input EmacDesc struct, because on a big-endian host the fields will
    be overwritten with the little-endian versions of their values.
    Unfortunately, in all the callsites the code continues to access
    fields in the EmacDesc struct after it has called emac_store_desc()
    -- specifically, it looks at the d.next field.
    
    The effect of this is that on a big-endian host networking doesn't
    work because the address of the next descriptor is corrupted.
    
    We could fix this by making the callsite avoid using the struct; but
    it's more robust to have emac_store_desc() leave its input alone.
    
    (emac_load_desc() also does an in-place conversion, but here this is
    fine, because the function is supposed to be initializing the
    struct.)
    
    Cc: qemu-stable@nongnu.org
    Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
    Reviewed-by: Thomas Huth <thuth@redhat.com>
    Message-id: 20230424151919.1333299-1-peter.maydell@linaro.org
    (cherry picked from commit d565f58)
    Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
    pm215 authored and Michael Tokarev committed May 30, 2023
    Copy the full SHA
    42a21b2 View commit details
    Browse the repository at this point in the history
  12. hw/arm/boot: Make write_bootloader() public as arm_write_bootloader()

    The arm boot.c code includes a utility function write_bootloader()
    which assists in writing a boot-code fragment into guest memory,
    including handling endianness and fixing it up with entry point
    addresses and similar things.  This is useful not just for the boot.c
    code but also in board model code, so rename it to
    arm_write_bootloader() and make it globally visible.
    
    Since we are making it public, make its API a little neater: move the
    AddressSpace* argument to be next to the hwaddr argument, and allow
    the fixupcontext array to be const, since we never modify it in this
    function.
    
    Cc: qemu-stable@nongnu.org
    Signed-off-by: Cédric Le Goater <clg@kaod.org>
    Tested-by: Cédric Le Goater <clg@kaod.org>
    Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
    Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
    Message-id: 20230424152717.1333930-2-peter.maydell@linaro.org
    [PMM: Split out from another patch by Cédric, added doc comment]
    Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
    (cherry picked from commit 0fe43f0)
    Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
    legoater authored and Michael Tokarev committed May 30, 2023
    Copy the full SHA
    a3c3caf View commit details
    Browse the repository at this point in the history
  13. hw/arm/aspeed: Use arm_write_bootloader() to write the bootloader

    When writing the secondary-CPU stub boot loader code to the guest,
    use arm_write_bootloader() instead of directly calling
    rom_add_blob_fixed().  This fixes a bug on big-endian hosts, because
    arm_write_bootloader() will correctly byte-swap the host-byte-order
    array values into the guest-byte-order to write into the guest
    memory.
    
    Cc: qemu-stable@nongnu.org
    Signed-off-by: Cédric Le Goater <clg@kaod.org>
    Tested-by: Cédric Le Goater <clg@kaod.org>
    Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
    Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
    Message-id: 20230424152717.1333930-3-peter.maydell@linaro.org
    [PMM: Moved the "make arm_write_bootloader() function public" part
     to its own patch; updated commit message to note that this fixes
     an actual bug; adjust to the API changes noted in previous commit]
    Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
    (cherry picked from commit 902bba5)
    Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
    legoater authored and Michael Tokarev committed May 30, 2023
    Copy the full SHA
    f3690e0 View commit details
    Browse the repository at this point in the history
  14. hw/arm/raspi: Use arm_write_bootloader() to write boot code

    When writing the secondary-CPU stub boot loader code to the guest,
    use arm_write_bootloader() instead of directly calling
    rom_add_blob_fixed().  This fixes a bug on big-endian hosts, because
    arm_write_bootloader() will correctly byte-swap the host-byte-order
    array values into the guest-byte-order to write into the guest
    memory.
    
    Cc: qemu-stable@nongnu.org
    Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
    Tested-by: Cédric Le Goater <clg@kaod.org>
    Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
    Message-id: 20230424152717.1333930-4-peter.maydell@linaro.org
    (cherry picked from commit 0acbdb4)
    Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
    pm215 authored and Michael Tokarev committed May 30, 2023
    Copy the full SHA
    0bf7376 View commit details
    Browse the repository at this point in the history
  15. hw/intc/allwinner-a10-pic: Don't use set_bit()/clear_bit()

    The Allwinner PIC model uses set_bit() and clear_bit() to update the
    values in its irq_pending[] array when an interrupt arrives.  However
    it is using these functions wrongly: they work on an array of type
    'long', and it is passing an array of type 'uint32_t'.  Because the
    code manually figures out the right array element, this works on
    little-endian hosts and on 32-bit big-endian hosts, where bits 0..31
    in a 'long' are in the same place as they are in a 'uint32_t'.
    However it breaks on 64-bit big-endian hosts.
    
    Remove the use of set_bit() and clear_bit() in favour of using
    deposit32() on the array element.  This fixes a bug where on
    big-endian 64-bit hosts the guest kernel would hang early on in
    bootup.
    
    Cc: qemu-stable@nongnu.org
    Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
    Reviewed-by: Thomas Huth <thuth@redhat.com>
    Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
    Message-id: 20230424152833.1334136-1-peter.maydell@linaro.org
    (cherry picked from commit 2c5fa07)
    Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
    pm215 authored and Michael Tokarev committed May 30, 2023
    Copy the full SHA
    6c9a80b View commit details
    Browse the repository at this point in the history
  16. target/arm: Define and use new load_cpu_field_low32()

    In several places in the 32-bit Arm translate.c, we try to use
    load_cpu_field() to load from a CPUARMState field into a TCGv_i32
    where the field is actually 64-bit. This works on little-endian
    hosts, but gives the wrong half of the register on big-endian.
    
    Add a new load_cpu_field_low32() which loads the low 32 bits
    of a 64-bit field into a TCGv_i32. The new macro includes a
    compile-time check against accidentally using it on a field
    of the wrong size. Use it to fix the two places in the code
    where we were using load_cpu_field() on a 64-bit field.
    
    This fixes a bug where on big-endian hosts the guest would
    crash after executing an ERET instruction, and a more corner
    case one where some UNDEFs for attempted accesses to MSR
    banked registers from Secure EL1 might go to the wrong EL.
    
    Cc: qemu-stable@nongnu.org
    Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
    Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
    Message-id: 20230424153909.1419369-2-peter.maydell@linaro.org
    (cherry picked from commit 7f3a3d3)
    Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
    pm215 authored and Michael Tokarev committed May 30, 2023
    Copy the full SHA
    fbcb93b View commit details
    Browse the repository at this point in the history
  17. hw/sd/allwinner-sdhost: Correctly byteswap descriptor fields

    In allwinner_sdhost_process_desc() we just read directly from
    guest memory into a host TransferDescriptor struct and back.
    This only works on little-endian hosts. Abstract the reading
    and writing of descriptors into functions that handle the
    byte-swapping so that TransferDescriptor structs as seen by
    the rest of the code are always in host-order.
    
    This fixes a failure of one of the avocado tests on s390.
    
    Cc: qemu-stable@nongnu.org
    Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
    Reviewed-by: Thomas Huth <thuth@redhat.com>
    Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
    Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
    Message-id: 20230424165053.1428857-2-peter.maydell@linaro.org
    (cherry picked from commit 3e20d90)
    Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
    pm215 authored and Michael Tokarev committed May 30, 2023
    Copy the full SHA
    64c5abe View commit details
    Browse the repository at this point in the history
  18. hw/net/allwinner-sun8i-emac: Correctly byteswap descriptor fields

    In allwinner-sun8i-emac we just read directly from guest memory into
    a host FrameDescriptor struct and back.  This only works on
    little-endian hosts.  Reading and writing of descriptors is already
    abstracted into functions; make those functions also handle the
    byte-swapping so that TransferDescriptor structs as seen by the rest
    of the code are always in host-order, and fix two places that were
    doing ad-hoc descriptor reading without using the functions.
    
    Cc: qemu-stable@nongnu.org
    Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
    Reviewed-by: Thomas Huth <thuth@redhat.com>
    Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
    Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
    Message-id: 20230424165053.1428857-3-peter.maydell@linaro.org
    (cherry picked from commit a4ae17e)
    Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
    pm215 authored and Michael Tokarev committed May 30, 2023
    Copy the full SHA
    6a3b880 View commit details
    Browse the repository at this point in the history
  19. block/export: call blk_set_dev_ops(blk, NULL, NULL)

    Most export types install BlockDeviceOps pointers. It is easy to forget
    to remove them because that happens automatically via the "drive" qdev
    property in hw/ but not block/export/.
    
    Put blk_set_dev_ops(blk, NULL, NULL) calls in the core export.c code so
    the export types don't need to remember.
    
    This fixes the nbd and vhost-user-blk export types.
    
    Fixes: fd6afc5 ("nbd/server: Use drained block ops to quiesce the server")
    Fixes: ca858a5 ("vhost-user-blk-server: notify client about disk resize")
    Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
    Reviewed-by: Eric Blake <eblake@redhat.com>
    Message-Id: <20230502211119.720647-1-stefanha@redhat.com>
    Signed-off-by: Eric Blake <eblake@redhat.com>
    (cherry picked from commit de79b52)
    Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
    stefanhaRH authored and Michael Tokarev committed May 30, 2023
    Copy the full SHA
    58e2d19 View commit details
    Browse the repository at this point in the history
  20. softfloat: Fix the incorrect computation in float32_exp2

    The float32_exp2 function is computing wrong exponent of 2.
    
    For example, with the following set of values {0.1, 2.0, 2.0, -1.0},
    the expected output would be {1.071773, 4.000000, 4.000000, 0.500000}.
    Instead, the function is computing {1.119102, 3.382044, 3.382044, -0.191022}
    
    Looking at the code, the float32_exp2() attempts to do this
    
                      2     3     4     5           n
      x        x     x     x     x     x           x
     e  = 1 + --- + --- + --- + --- + --- + ... + --- + ...
               1!    2!    3!    4!    5!          n!
    
    But because of the typo it ends up doing
    
      x        x     x     x     x     x           x
     e  = 1 + --- + --- + --- + --- + --- + ... + --- + ...
               1!    2!    3!    4!    5!          n!
    
    This is because instead of the xnp which holds the numerator, parts_muladd
    is using the xp which is just 'x'.  Commit '572c4d862ff2' refactored this
    function, and mistakenly used xp instead of xnp.
    
    Cc: qemu-stable@nongnu.org
    Fixes: 572c4d8 "softfloat: Convert float32_exp2 to FloatParts"
    Partially-Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1623
    Reported-By: Luca Barbato (https://gitlab.com/lu-zero)
    Signed-off-by: Shivaprasad G Bhat <sbhat@linux.ibm.com>
    Signed-off-by: Vaibhav Jain <vaibhav@linux.ibm.com>
    Message-Id: <168304110865.537992.13059030916325018670.stgit@localhost.localdomain>
    Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
    Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
    (cherry picked from commit 1098cc3)
    Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
    ShivaprasadGBhat authored and Michael Tokarev committed May 30, 2023
    Copy the full SHA
    2651923 View commit details
    Browse the repository at this point in the history
  21. meson: leave unnecessary modules out of the build

    meson.build files choose whether to build modules based on foo.found()
    expressions.  If a feature is enabled (e.g. --enable-gtk), these expressions
    are true even if the code is not used by any emulator, and this results
    in an unexpected difference between modular and non-modular builds.
    
    For non-modular builds, the files are not included in any binary, and
    therefore the source files are never processed.  For modular builds,
    however, all .so files are unconditionally built by default, and therefore
    a normal "make" tries to build them.  However, the corresponding trace-*.h
    files are absent due to this conditional:
    
    if have_system
      trace_events_subdirs += [
        ...
        'ui',
        ...
      ]
    endif
    
    which was added to avoid wasting time running tracetool on unused trace-events
    files.  This causes a compilation failure; fix it by skipping module builds
    entirely if (depending on the module directory) have_block or have_system
    are false.
    
    Reported-by: Michael Tokarev <mjt@tls.msk.ru>
    Cc: qemu-stable@nongnu.org
    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
    (cherry picked from commit ef70986)
    Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
    bonzini authored and Michael Tokarev committed May 30, 2023
    Copy the full SHA
    8c3fab5 View commit details
    Browse the repository at this point in the history
  22. block: Fix use after free in blockdev_mark_auto_del()

    job_cancel_locked() drops the job list lock temporarily and it may call
    aio_poll(). We must assume that the list has changed after this call.
    Also, with unlucky timing, it can end up freeing the job during
    job_completed_txn_abort_locked(), making the job pointer invalid, too.
    
    For both reasons, we can't just continue at block_job_next_locked(job).
    Instead, start at the head of the list again after job_cancel_locked()
    and skip those jobs that we already cancelled (or that are completing
    anyway).
    
    Cc: qemu-stable@nongnu.org
    Signed-off-by: Kevin Wolf <kwolf@redhat.com>
    Message-Id: <20230503140142.474404-1-kwolf@redhat.com>
    Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
    Signed-off-by: Kevin Wolf <kwolf@redhat.com>
    (cherry picked from commit e262687)
    Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
    Kevin Wolf authored and Michael Tokarev committed May 30, 2023
    Copy the full SHA
    83f6cbc View commit details
    Browse the repository at this point in the history
  23. block: Consistently call bdrv_activate() outside coroutine

    Migration code can call bdrv_activate() in coroutine context, whereas
    other callers call it outside of coroutines. As it calls other code that
    is not supposed to run in coroutines, standardise on running outside of
    coroutines.
    
    This adds a no_co_wrapper to switch to the main loop before calling
    bdrv_activate().
    
    Cc: qemu-stable@nongnu.org
    Signed-off-by: Kevin Wolf <kwolf@redhat.com>
    Reviewed-by: Eric Blake <eblake@redhat.com>
    Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
    Message-Id: <20230504115750.54437-3-kwolf@redhat.com>
    Signed-off-by: Kevin Wolf <kwolf@redhat.com>
    (cherry picked from commit da4afaf)
    Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
    Kevin Wolf authored and Michael Tokarev committed May 30, 2023
    Copy the full SHA
    ded28d8 View commit details
    Browse the repository at this point in the history
  24. block: bdrv/blk_co_unref() for calls in coroutine context

    These functions must not be called in coroutine context, because they
    need write access to the graph.
    
    Cc: qemu-stable@nongnu.org
    Signed-off-by: Kevin Wolf <kwolf@redhat.com>
    Reviewed-by: Eric Blake <eblake@redhat.com>
    Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
    Message-Id: <20230504115750.54437-4-kwolf@redhat.com>
    Signed-off-by: Kevin Wolf <kwolf@redhat.com>
    (cherry picked from commit b2ab5f5)
    Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
    Kevin Wolf authored and Michael Tokarev committed May 30, 2023
    Copy the full SHA
    5b0c365 View commit details
    Browse the repository at this point in the history
  25. block: Don't call no_coroutine_fns in qmp_block_resize()

    This QMP handler runs in a coroutine, so it must use the corresponding
    no_co_wrappers instead.
    
    Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2185688
    Cc: qemu-stable@nongnu.org
    Signed-off-by: Kevin Wolf <kwolf@redhat.com>
    Reviewed-by: Eric Blake <eblake@redhat.com>
    Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
    Message-Id: <20230504115750.54437-5-kwolf@redhat.com>
    Signed-off-by: Kevin Wolf <kwolf@redhat.com>
    (cherry picked from commit 0c7d204)
    Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
    Kevin Wolf authored and Michael Tokarev committed May 30, 2023
    Copy the full SHA
    d24558b View commit details
    Browse the repository at this point in the history
  26. target/riscv: Fix itrigger when icount is used

    When I boot a ubuntu image, QEMU output a "Bad icount read" message and exit.
    The reason is that when execute helper_mret or helper_sret, it will
    cause a call to icount_get_raw_locked (), which needs set can_do_io flag
    on cpustate.
    
    Thus we setting this flag when execute these two instructions.
    
    Signed-off-by: LIU Zhiwei <zhiwei_liu@linux.alibaba.com>
    Reviewed-by: Weiwei Li <liweiwei@iscas.ac.cn>
    Acked-by: Alistair Francis <alistair.francis@wdc.com>
    Message-Id: <20230324064011.976-1-zhiwei_liu@linux.alibaba.com>
    Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
    (cherry picked from commit df3ac6d)
    Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
    romanheros authored and Michael Tokarev committed May 30, 2023
    Copy the full SHA
    37cc3ad View commit details
    Browse the repository at this point in the history
  27. target/riscv: Restore the predicate() NULL check behavior

    When reading a non-existent CSR QEMU should raise illegal instruction
    exception, but currently it just exits due to the g_assert() check.
    
    This actually reverts commit 0ee3422.
    Some comments are also added to indicate that predicate() must be
    provided for an implemented CSR.
    
    Reported-by: Fei Wu <fei2.wu@intel.com>
    Signed-off-by: Bin Meng <bmeng@tinylab.org>
    Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
    Reviewed-by: Weiwei Li <liweiwei@iscas.ac.cn>
    Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
    Reviewed-by: LIU Zhiwei <zhiwei_liu@linux.alibaba.com>
    Message-Id: <20230417043054.3125614-1-bmeng@tinylab.org>
    Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
    (cherry picked from commit eae04c4)
    (mjt: context edit after ce3af0b "target/riscv: add support for Zcmt extension")
    Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
    lbmeng authored and Michael Tokarev committed May 30, 2023
    Copy the full SHA
    8c2fe85 View commit details
    Browse the repository at this point in the history
  28. hw/pci-bridge: pci_expander_bridge fix type in pxb_cxl_dev_reset()

    Reproduce issue with
    
    configure --enable-qom-cast-debug ...
    
    qemu-system-x86_64 -display none -machine q35,cxl=on -device pxb-cxl,bus=pcie.0
    
      hw/pci-bridge/pci_expander_bridge.c:54:PXB_DEV: Object 0x5570e0b1ada0 is not an instance of type pxb
      Aborted
    
    The type conversion results in the right state structure, but PXB_DEV is
    not a parent of PXB_CXL_DEV hence the error. Rather than directly
    cleaning up the inheritance, this is the minimal fix which will be
    followed by the cleanup.
    
    Fixes: 154070e ("hw/pxb-cxl: Support passthrough HDM Decoders unless overridden")
    Reported-by: Peter Maydell <peter.maydell@linaro.org>
    Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
    Message-Id: <20230420142750.6950-2-Jonathan.Cameron@huawei.com>
    Reviewed-by: Thomas Huth <thuth@redhat.com>
    Cc: qemu-stable@nongnu.org
    Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
    Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
    (cherry picked from commit 9136f66)
    Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
    jic23 authored and Michael Tokarev committed May 30, 2023
    Copy the full SHA
    99812af View commit details
    Browse the repository at this point in the history
  29. accel/tcg: Fix atomic_mmu_lookup for reads

    A copy-paste bug had us looking at the victim cache for writes.
    
    Cc: qemu-stable@nongnu.org
    Reported-by: Peter Maydell <peter.maydell@linaro.org>
    Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
    Fixes: 08dff43 ("tcg: Probe the proper permissions for atomic ops")
    Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
    Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
    Message-Id: <20230505204049.352469-1-richard.henderson@linaro.org>
    (cherry picked from commit 8c31325)
    Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
    rth7680 authored and Michael Tokarev committed May 30, 2023
    Copy the full SHA
    1d75921 View commit details
    Browse the repository at this point in the history
  30. target/arm: Fix handling of SW and NSW bits for stage 2 walks

    We currently don't correctly handle the VSTCR_EL2.SW and VTCR_EL2.NSW
    configuration bits.  These allow configuration of whether the stage 2
    page table walks for Secure IPA and NonSecure IPA should do their
    descriptor reads from Secure or NonSecure physical addresses. (This
    is separate from how the translation table base address and other
    parameters are set: an NS IPA always uses VTTBR_EL2 and VTCR_EL2
    for its base address and walk parameters, regardless of the NSW bit,
    and similarly for Secure.)
    
    Provide a new function ptw_idx_for_stage_2() which returns the
    MMU index to use for descriptor reads, and use it to set up
    the .in_ptw_idx wherever we call get_phys_addr_lpae().
    
    For a stage 2 walk, wherever we call get_phys_addr_lpae():
     * .in_ptw_idx should be ptw_idx_for_stage_2() of the .in_mmu_idx
     * .in_secure should be true if .in_mmu_idx is Stage2_S
    
    This allows us to correct S1_ptw_translate() so that it consistently
    always sets its (out_secure, out_phys) to the result it gets from the
    S2 walk (either by calling get_phys_addr_lpae() or by TLB lookup).
    This makes better conceptual sense because the S2 walk should return
    us an (address space, address) tuple, not an address that we then
    randomly assign to S or NS.
    
    Our previous handling of SW and NSW was broken, so guest code
    trying to use these bits to put the s2 page tables in the "other"
    address space wouldn't work correctly.
    
    Cc: qemu-stable@nongnu.org
    Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1600
    Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
    Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
    Message-id: 20230504135425.2748672-3-peter.maydell@linaro.org
    (cherry picked from commit fcc0b04)
    Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
    pm215 authored and Michael Tokarev committed May 30, 2023
    Copy the full SHA
    1335d26 View commit details
    Browse the repository at this point in the history
  31. ui: Fix pixel colour channel order for PNG screenshots

    When we take a PNG screenshot the ordering of the colour channels in
    the data is not correct, resulting in the image having weird
    colouring compared to the actual display.  (Specifically, on a
    little-endian host the blue and red channels are swapped; on
    big-endian everything is wrong.)
    
    This happens because the pixman idea of the pixel data and the libpng
    idea differ.  PIXMAN_a8r8g8b8 defines that pixels are 32-bit values,
    with A in bits 24-31, R in bits 16-23, G in bits 8-15 and B in bits
    0-7.  This means that on little-endian systems the bytes in memory
    are
       B G R A
    and on big-endian systems they are
       A R G B
    
    libpng, on the other hand, thinks of pixels as being a series of
    values for each channel, so its format PNG_COLOR_TYPE_RGB_ALPHA
    always wants bytes in the order
       R G B A
    
    This isn't the same as the pixman order for either big or little
    endian hosts.
    
    The alpha channel is also unnecessary bulk in the output PNG file,
    because there is no alpha information in a screenshot.
    
    To handle the endianness issue, we already define in ui/qemu-pixman.h
    various PIXMAN_BE_* and PIXMAN_LE_* values that give consistent
    byte-order pixel channel formats.  So we can use PIXMAN_BE_r8g8b8 and
    PNG_COLOR_TYPE_RGB, which both have an in-memory byte order of
        R G B
    and 3 bytes per pixel.
    
    (PPM format screenshots get this right; they already use the
    PIXMAN_BE_r8g8b8 format.)
    
    Cc: qemu-stable@nongnu.org
    Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1622
    Fixes: 9a0a119 ("Added parameter to take screenshot with screendump as PNG")
    Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
    Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
    Message-id: 20230502135548.2451309-1-peter.maydell@linaro.org
    (cherry picked from commit cd22a0f)
    Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
    pm215 authored and Michael Tokarev committed May 30, 2023
    Copy the full SHA
    9acb3d7 View commit details
    Browse the repository at this point in the history
  32. target/arm: Correct AArch64.S2MinTxSZ 32-bit EL1 input size check

    In check_s2_mmu_setup() we have a check that is attempting to
    implement the part of AArch64.S2MinTxSZ that is specific to when EL1
    is AArch32:
    
        if !s1aarch64 then
            // EL1 is AArch32
            min_txsz = Min(min_txsz, 24);
    
    Unfortunately we got this wrong in two ways:
    
    (1) The minimum txsz corresponds to a maximum inputsize, but we got
    the sense of the comparison wrong and were faulting for all
    inputsizes less than 40 bits
    
    (2) We try to implement this as an extra check that happens after
    we've done the same txsz checks we would do for an AArch64 EL1, but
    in fact the pseudocode is *loosening* the requirements, so that txsz
    values that would fault for an AArch64 EL1 do not fault for AArch32
    EL1, because it does Min(old_min, 24), not Max(old_min, 24).
    
    You can see this also in the text of the Arm ARM in table D8-8, which
    shows that where the implemented PA size is less than 40 bits an
    AArch32 EL1 is still OK with a configured stage2 T0SZ for a 40 bit
    IPA, whereas if EL1 is AArch64 then the T0SZ must be big enough to
    constrain the IPA to the implemented PA size.
    
    Because of part (2), we can't do this as a separate check, but
    have to integrate it into aa64_va_parameters(). Add a new argument
    to that function to indicate that EL1 is 32-bit. All the existing
    callsites except the one in get_phys_addr_lpae() can pass 'false',
    because they are either doing a lookup for a stage 1 regime or
    else they don't care about the tsz/tsz_oob fields.
    
    Cc: qemu-stable@nongnu.org
    Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1627
    Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
    Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
    Message-id: 20230509092059.3176487-1-peter.maydell@linaro.org
    (cherry picked from commit 478dccb)
    Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
    pm215 authored and Michael Tokarev committed May 30, 2023
    Copy the full SHA
    b249153 View commit details
    Browse the repository at this point in the history
  33. async: Suppress GCC13 false positive in aio_bh_poll()

    GCC13 reports an error :
    
    ../util/async.c: In function ‘aio_bh_poll’:
    include/qemu/queue.h:303:22: error: storing the address of local variable ‘slice’ in ‘*ctx.bh_slice_list.sqh_last’ [-Werror=dangling-pointer=]
      303 |     (head)->sqh_last = &(elm)->field.sqe_next;                          \
          |     ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
    ../util/async.c:169:5: note: in expansion of macro ‘QSIMPLEQ_INSERT_TAIL’
      169 |     QSIMPLEQ_INSERT_TAIL(&ctx->bh_slice_list, &slice, next);
          |     ^~~~~~~~~~~~~~~~~~~~
    ../util/async.c:161:17: note: ‘slice’ declared here
      161 |     BHListSlice slice;
          |                 ^~~~~
    ../util/async.c:161:17: note: ‘ctx’ declared here
    
    But the local variable 'slice' is removed from the global context list
    in following loop of the same routine. Add a pragma to silent GCC.
    
    Cc: Stefan Hajnoczi <stefanha@redhat.com>
    Cc: Paolo Bonzini <pbonzini@redhat.com>
    Cc: Daniel P. Berrangé <berrange@redhat.com>
    Signed-off-by: Cédric Le Goater <clg@redhat.com>
    Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
    Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
    Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
    Reviewed-by: Thomas Huth <thuth@redhat.com>
    Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>
    Message-Id: <20230420202939.1982044-1-clg@kaod.org>
    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
    (cherry picked from commit d66ba6d)
    Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
    (Mjt: cherry-picked to stable-8.0 to eliminate CI failures on win*)
    legoater authored and Michael Tokarev committed May 30, 2023
    Copy the full SHA
    7d807dc View commit details
    Browse the repository at this point in the history
  34. tcg: ppc64: Fix mask generation for vextractdm

    In function do_extractm() the mask is calculated as
    dup_const(1 << (element_width - 1)). '1' being signed int
    works fine for MO_8,16,32. For MO_64, on PPC64 host
    this ends up becoming 0 on compilation. The vextractdm
    uses MO_64, and it ends up having mask as 0.
    
    Explicitly use 1ULL instead of signed int 1 like its
    used everywhere else.
    
    Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1536
    Signed-off-by: Shivaprasad G Bhat <sbhat@linux.ibm.com>
    Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
    Reviewed-by: Lucas Mateus Castro <lucas.araujo@eldorado.org.br>
    Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
    Reviewed-by: Cédric Le Goater <clg@redhat.com>
    Message-Id: <168319292809.1159309.5817546227121323288.stgit@ltc-boston1.aus.stglabs.ibm.com>
    Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
    (cherry picked from commit 6a5d81b)
    Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
    ShivaprasadGBhat authored and Michael Tokarev committed May 30, 2023
    Copy the full SHA
    8e96424 View commit details
    Browse the repository at this point in the history
  35. target/s390x: Fix EXECUTE of relative branches

    Fix a problem similar to the one fixed by commit 703d03a
    ("target/s390x: Fix EXECUTE of relative long instructions"), but now
    for relative branches.
    
    Reported-by: Nina Schoetterl-Glausch <nsg@linux.ibm.com>
    Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
    Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
    Message-Id: <20230426235813.198183-2-iii@linux.ibm.com>
    Signed-off-by: Thomas Huth <thuth@redhat.com>
    (cherry picked from commit e8ecdfe)
    Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
    iii-i authored and Michael Tokarev committed May 30, 2023
    Copy the full SHA
    be76977 View commit details
    Browse the repository at this point in the history
  36. s390x/tcg: Fix LDER instruction format

    It's RRE, not RXE.
    
    Found by running valgrind's none/tests/s390x/bfp-2.
    
    Fixes: 86b5962 ("s390x/tcg: Implement LOAD LENGTHENED short HFP to long HFP")
    Reviewed-by: David Hildenbrand <david@redhat.com>
    Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
    Message-Id: <20230511134726.469651-1-iii@linux.ibm.com>
    Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
    Signed-off-by: Thomas Huth <thuth@redhat.com>
    (cherry picked from commit 970641d)
    Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
    iii-i authored and Michael Tokarev committed May 30, 2023
    Copy the full SHA
    6b765cb View commit details
    Browse the repository at this point in the history
  37. 9pfs/xen: Fix segfault on shutdown

    xen_9pfs_free can't use gnttabdev since it is already closed and NULL-ed
    out when free is called.  Do the teardown in _disconnect().  This
    matches the setup done in _connect().
    
    trace-events are also added for the XenDevOps functions.
    
    Signed-off-by: Jason Andryuk <jandryuk@gmail.com>
    Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
    Message-Id: <20230502143722.15613-1-jandryuk@gmail.com>
    [C.S.: - Remove redundant return in xen_9pfs_free().
           - Add comment to trace-events. ]
    Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
    (cherry picked from commit 92e667f)
    Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
    jandryuk authored and Michael Tokarev committed May 30, 2023
    Copy the full SHA
    dbdbd71 View commit details
    Browse the repository at this point in the history
  38. tcg/i386: Set P_REXW in tcg_out_addi_ptr

    The REXW bit must be set to produce a 64-bit pointer result; the
    bit is disabled in 32-bit mode, so we can do this unconditionally.
    
    Fixes: 7d9e1ee ("tcg/i386: Adjust assert in tcg_out_addi_ptr")
    Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1592
    Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1642
    Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
    (cherry picked from commit 9889985)
    Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
    rth7680 authored and Michael Tokarev committed May 30, 2023
    Copy the full SHA
    b2bdfb7 View commit details
    Browse the repository at this point in the history
  39. s390x/pv: Fix spurious warning with asynchronous teardown

    Kernel commit 292a7d6fca33 ("KVM: s390: pv: fix asynchronous teardown
    for small VMs") causes the KVM_PV_ASYNC_CLEANUP_PREPARE ioctl to fail
    if the VM is not larger than 2GiB. QEMU would attempt it and fail,
    print an error message, and then proceed with a normal teardown.
    
    Avoid attempting to use asynchronous teardown altogether when the VM is
    not larger than 2 GiB. This will avoid triggering the error message and
    also avoid pointless overhead; normal teardown is fast enough for small
    VMs.
    
    Reported-by: Marc Hartmayer <mhartmay@linux.ibm.com>
    Fixes: c3a073c ("s390x/pv: Add support for asynchronous teardown for reboot")
    Link: https://lore.kernel.org/all/20230421085036.52511-2-imbrenda@linux.ibm.com/
    Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
    Message-Id: <20230510105531.30623-2-imbrenda@linux.ibm.com>
    Reviewed-by: Thomas Huth <thuth@redhat.com>
    [thuth: Fix inline function parameter in pv.h]
    Signed-off-by: Thomas Huth <thuth@redhat.com>
    (cherry picked from commit 88693ab)
    Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
    Claudio Imbrenda authored and Michael Tokarev committed May 30, 2023
    Copy the full SHA
    524606c View commit details
    Browse the repository at this point in the history
  40. util/async-teardown: wire up query-command-line-options

    Add new -run-with option with an async-teardown=on|off parameter. It is
    visible in the output of query-command-line-options QMP command, so it
    can be discovered and used by libvirt.
    
    The option -async-teardown is now redundant, deprecate it.
    
    Reported-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
    Fixes: c891c24 ("os-posix: asynchronous teardown for shutdown on Linux")
    Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
    Message-Id: <20230505120051.36605-2-imbrenda@linux.ibm.com>
    [thuth: Add curly braces to fix error with GCC 8.5, fix bug in deprecated.rst]
    Signed-off-by: Thomas Huth <thuth@redhat.com>
    (cherry picked from commit 80bd81c)
    Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
    (Mjt: context tweak in docs/about/deprecated.rst)
    Claudio Imbrenda authored and Michael Tokarev committed May 30, 2023
    Copy the full SHA
    19a6649 View commit details
    Browse the repository at this point in the history
  41. docs/about/emulation: fix typo

    Duplicated word "are".
    
    Signed-off-by: Lizhi Yang <sledgeh4w@gmail.com>
    Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
    Message-Id: <20230511080119.99018-1-sledgeh4w@gmail.com>
    Signed-off-by: Thomas Huth <thuth@redhat.com>
    (cherry picked from commit c70bb9a)
    Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
    sledgeh4w authored and Michael Tokarev committed May 30, 2023
    Copy the full SHA
    a2b3181 View commit details
    Browse the repository at this point in the history
  42. tests/docker: bump the xtensa base to debian:11-slim

    Stretch is going out of support so things like security updates will
    fail. As the toolchain itself is binary it hopefully won't mind the
    underlying OS being updated.
    
    Message-Id: <20230503091244.1450613-3-alex.bennee@linaro.org>
    Reviewed-by: Thomas Huth <thuth@redhat.com>
    Reviewed-by: Juan Quintela <quintela@redhat.com>
    Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
    Reported-by: Richard Henderson <richard.henderson@linaro.org>
    (cherry picked from commit 3217b84)
    Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
    stsquad authored and Michael Tokarev committed May 30, 2023
    Copy the full SHA
    587148b View commit details
    Browse the repository at this point in the history
  43. linux-user: Fix mips fp64 executables loading

    If a program requires fr1, we should set the FR bit of CP0 control status
    register and add F64 hardware flag. The corresponding `else if` branch
    statement is copied from the linux kernel sources (see `arch_check_elf` function
    in linux/arch/mips/kernel/elf.c).
    
    Signed-off-by: Daniil Kovalev <dkovalev@compiler-toolchain-for.me>
    Reviewed-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
    Message-Id: <20230404052153.16617-1-dkovalev@compiler-toolchain-for.me>
    Signed-off-by: Laurent Vivier <laurent@vivier.eu>
    (cherry picked from commit a0f8d27)
    Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
    Daniil Kovalev authored and Michael Tokarev committed May 30, 2023
    Copy the full SHA
    bd8c5ad View commit details
    Browse the repository at this point in the history
  44. linux-user: fix getgroups/setgroups allocations

    linux-user getgroups(), setgroups(), getgroups32() and setgroups32()
    used alloca() to allocate grouplist arrays, with unchecked gidsetsize
    coming from the "guest".  With NGROUPS_MAX being 65536 (linux, and it
    is common for an application to allocate NGROUPS_MAX for getgroups()),
    this means a typical allocation is half the megabyte on the stack.
    Which just overflows stack, which leads to immediate SIGSEGV in actual
    system getgroups() implementation.
    
    An example of such issue is aptitude, eg
    https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=811087#72
    
    Cap gidsetsize to NGROUPS_MAX (return EINVAL if it is larger than that),
    and use heap allocation for grouplist instead of alloca().  While at it,
    fix coding style and make all 4 implementations identical.
    
    Try to not impose random limits - for example, allow gidsetsize to be
    negative for getgroups() - just do not allocate negative-sized grouplist
    in this case but still do actual getgroups() call.  But do not allow
    negative gidsetsize for setgroups() since its argument is unsigned.
    
    Capping by NGROUPS_MAX seems a bit arbitrary, - we can do more, it is
    not an error if set size will be NGROUPS_MAX+1. But we should not allow
    integer overflow for the array being allocated. Maybe it is enough to
    just call g_try_new() and return ENOMEM if it fails.
    
    Maybe there's also no need to convert setgroups() since this one is
    usually smaller and known beforehand (KERN_NGROUPS_MAX is actually 63, -
    this is apparently a kernel-imposed limit for runtime group set).
    
    The patch fixes aptitude segfault mentioned above.
    
    Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
    Message-Id: <20230409105327.1273372-1-mjt@msgid.tls.msk.ru>
    Signed-off-by: Laurent Vivier <laurent@vivier.eu>
    (cherry picked from commit 1e35d32)
    Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
    Michael Tokarev committed May 30, 2023
    Copy the full SHA
    9180293 View commit details
    Browse the repository at this point in the history
  45. migration: Handle block device inactivation failures better

    Consider what happens when performing a migration between two host
    machines connected to an NFS server serving multiple block devices to
    the guest, when the NFS server becomes unavailable.  The migration
    attempts to inactivate all block devices on the source (a necessary
    step before the destination can take over); but if the NFS server is
    non-responsive, the attempt to inactivate can itself fail.  When that
    happens, the destination fails to get the migrated guest (good,
    because the source wasn't able to flush everything properly):
    
      (qemu) qemu-kvm: load of migration failed: Input/output error
    
    at which point, our only hope for the guest is for the source to take
    back control.  With the current code base, the host outputs a message, but then appears to resume:
    
      (qemu) qemu-kvm: qemu_savevm_state_complete_precopy_non_iterable: bdrv_inactivate_all() failed (-1)
    
      (src qemu)info status
       VM status: running
    
    but a second migration attempt now asserts:
    
      (src qemu) qemu-kvm: ../block.c:6738: int bdrv_inactivate_recurse(BlockDriverState *): Assertion `!(bs->open_flags & BDRV_O_INACTIVE)' failed.
    
    Whether the guest is recoverable on the source after the first failure
    is debatable, but what we do not want is to have qemu itself fail due
    to an assertion.  It looks like the problem is as follows:
    
    In migration.c:migration_completion(), the source sets 'inactivate' to
    true (since COLO is not enabled), then tries
    savevm.c:qemu_savevm_state_complete_precopy() with a request to
    inactivate block devices.  In turn, this calls
    block.c:bdrv_inactivate_all(), which fails when flushing runs up
    against the non-responsive NFS server.  With savevm failing, we are
    now left in a state where some, but not all, of the block devices have
    been inactivated; but migration_completion() then jumps to 'fail'
    rather than 'fail_invalidate' and skips an attempt to reclaim those
    those disks by calling bdrv_activate_all().  Even if we do attempt to
    reclaim disks, we aren't taking note of failure there, either.
    
    Thus, we have reached a state where the migration engine has forgotten
    all state about whether a block device is inactive, because we did not
    set s->block_inactive in enough places; so migration allows the source
    to reach vm_start() and resume execution, violating the block layer
    invariant that the guest CPUs should not be restarted while a device
    is inactive.  Note that the code in migration.c:migrate_fd_cancel()
    will also try to reactivate all block devices if s->block_inactive was
    set, but because we failed to set that flag after the first failure,
    the source assumes it has reclaimed all devices, even though it still
    has remaining inactivated devices and does not try again.  Normally,
    qmp_cont() will also try to reactivate all disks (or correctly fail if
    the disks are not reclaimable because NFS is not yet back up), but the
    auto-resumption of the source after a migration failure does not go
    through qmp_cont().  And because we have left the block layer in an
    inconsistent state with devices still inactivated, the later migration
    attempt is hitting the assertion failure.
    
    Since it is important to not resume the source with inactive disks,
    this patch marks s->block_inactive before attempting inactivation,
    rather than after succeeding, in order to prevent any vm_start() until
    it has successfully reactivated all devices.
    
    See also https://bugzilla.redhat.com/show_bug.cgi?id=2058982
    
    Signed-off-by: Eric Blake <eblake@redhat.com>
    Reviewed-by: Juan Quintela <quintela@redhat.com>
    Acked-by: Lukas Straub <lukasstraub2@web.de>
    Tested-by: Lukas Straub <lukasstraub2@web.de>
    Signed-off-by: Juan Quintela <quintela@redhat.com>
    (cherry picked from commit 403d18a)
    Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
    ebblake authored and Michael Tokarev committed May 30, 2023
    Copy the full SHA
    67ab8e3 View commit details
    Browse the repository at this point in the history
  46. migration: Minor control flow simplification

    No need to declare a temporary variable.
    
    Suggested-by: Juan Quintela <quintela@redhat.com>
    Fixes: 1df36e8c6289 ("migration: Handle block device inactivation failures better")
    Signed-off-by: Eric Blake <eblake@redhat.com>
    Reviewed-by: Juan Quintela <quintela@redhat.com>
    Signed-off-by: Juan Quintela <quintela@redhat.com>
    (cherry picked from commit 5d39f44)
    Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
    ebblake authored and Michael Tokarev committed May 30, 2023
    Copy the full SHA
    41f345b View commit details
    Browse the repository at this point in the history
  47. migration: Attempt disk reactivation in more failure scenarios

    Commit fe904ea added a fail_inactivate label, which tries to
    reactivate disks on the source after a failure while s->state ==
    MIGRATION_STATUS_ACTIVE, but didn't actually use the label if
    qemu_savevm_state_complete_precopy() failed.  This failure to
    reactivate is also present in commit 6039dd5 (also covering the new
    s->state == MIGRATION_STATUS_DEVICE state) and 403d18a (ensuring
    s->block_inactive is set more reliably).
    
    Consolidate the two labels back into one - no matter HOW migration is
    failed, if there is any chance we can reach vm_start() after having
    attempted inactivation, it is essential that we have tried to restart
    disks before then.  This also makes the cleanup more like
    migrate_fd_cancel().
    
    Suggested-by: Kevin Wolf <kwolf@redhat.com>
    Signed-off-by: Eric Blake <eblake@redhat.com>
    Message-Id: <20230502205212.134680-1-eblake@redhat.com>
    Acked-by: Peter Xu <peterx@redhat.com>
    Reviewed-by: Juan Quintela <quintela@redhat.com>
    Reviewed-by: Kevin Wolf <kwolf@redhat.com>
    Signed-off-by: Kevin Wolf <kwolf@redhat.com>
    (cherry picked from commit 6dab4c9)
    Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
    (Mjt: minor context tweak near added comment in migration/migration.c)
    ebblake authored and Michael Tokarev committed May 30, 2023
    Copy the full SHA
    77b43d2 View commit details
    Browse the repository at this point in the history
  48. target/arm: Fix vd == vm overlap in sve_ldff1_z

    If vd == vm, copy vm to scratch, so that we can pre-zero
    the output and still access the gather indicies.
    
    Cc: qemu-stable@nongnu.org
    Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1612
    Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
    Message-id: 20230504104232.1877774-1-richard.henderson@linaro.org
    Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
    Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
    (cherry picked from commit a6771f2)
    Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
    rth7680 authored and Michael Tokarev committed May 30, 2023
    Copy the full SHA
    be25969 View commit details
    Browse the repository at this point in the history
  49. scsi-generic: fix buffer overflow on block limits inquiry

    Using linux 6.x guest, at boot time, an inquiry on a scsi-generic
    device makes qemu crash.  This is caused by a buffer overflow when
    scsi-generic patches the block limits VPD page.
    
    Do the operations on a temporary on-stack buffer that is guaranteed
    to be large enough.
    
    Reported-by: Théo Maillart <tmaillart@freebox.fr>
    Analyzed-by: Théo Maillart <tmaillart@freebox.fr>
    Cc: qemu-stable@nongnu.org
    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
    (cherry picked from commit 9bd634b)
    Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
    bonzini authored and Michael Tokarev committed May 30, 2023
    Copy the full SHA
    aa4ee71 View commit details
    Browse the repository at this point in the history
  50. target/i386: fix operand size for VCOMI/VUCOMI instructions

    Compared to other SSE instructions, VUCOMISx and VCOMISx are different:
    the single and double precision versions are distinguished through a
    prefix, however they use no-prefix and 0x66 for SS and SD respectively.
    Scalar values usually are associated with 0xF2 and 0xF3.
    
    Because of these, they incorrectly perform a 128-bit memory load instead
    of a 32- or 64-bit load.  Fix this by writing a custom decoding function.
    
    I tested that the reproducer is fixed and the test-avx output does not
    change.
    
    Reported-by: Gabriele Svelto <gsvelto@mozilla.com>
    Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1637
    Fixes: f8d19ee ("target/i386: reimplement 0x0f 0x28-0x2f, add AVX", 2022-10-18)
    Cc: qemu-stable@nongnu.org
    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
    (cherry picked from commit 2b55e47)
    Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
    bonzini authored and Michael Tokarev committed May 30, 2023
    Copy the full SHA
    eef6354 View commit details
    Browse the repository at this point in the history