Skip to content
Snippets Groups Projects
  1. May 27, 2021
  2. May 26, 2021
    • Peter Maydell's avatar
      Merge remote-tracking branch 'remotes/bonzini-gitlab/tags/for-upstream' into staging · 8385235b
      Peter Maydell authored
      
      * submodule cleanups (Philippe, myself)
      * tiny step towards a usable preconfig mode (myself)
      * Kconfig and LOCK_GUARD cleanups (philippe)
      * new x86 CPUID feature (Yang Zhong)
      * "-object qtest" support (myself)
      * Dirty ring support for KVM (Peter)
      * Fixes for 6.0 command line parsing breakage (myself)
      * Fix for macOS 11.3 SDK (Katsuhiro)
      
      # gpg: Signature made Wed 26 May 2021 13:50:12 BST
      # gpg:                using RSA key F13338574B662389866C7682BFFBD25F78C7AE83
      # gpg:                issuer "pbonzini@redhat.com"
      # gpg: Good signature from "Paolo Bonzini <bonzini@gnu.org>" [full]
      # gpg:                 aka "Paolo Bonzini <pbonzini@redhat.com>" [full]
      # Primary key fingerprint: 46F5 9FBD 57D6 12E7 BFD4  E2F7 7E15 100C CD36 69B1
      #      Subkey fingerprint: F133 3857 4B66 2389 866C  7682 BFFB D25F 78C7 AE83
      
      * remotes/bonzini-gitlab/tags/for-upstream: (28 commits)
        gitlab-ci: use --meson=git for CFI jobs
        hw/scsi: Fix sector translation bug in scsi_unmap_complete_noio
        configure: Avoid error messages about missing *-config-*.h files
        doc: Add notes about -mon option mode=control argument.
        qemu-config: load modules when instantiating option groups
        vl: allow not specifying size in -m when using -M memory-backend
        replication: move include out of root directory
        remove qemu-options* from root directory
        meson: Set implicit_include_directories to false
        tests/qtest/fuzz: Fix build failure
        KVM: Dirty ring support
        KVM: Disable manual dirty log when dirty ring enabled
        KVM: Add dirty-ring-size property
        KVM: Cache kvm slot dirty bitmap size
        KVM: Simplify dirty log sync in kvm_set_phys_mem
        KVM: Provide helper to sync dirty bitmap from slot to ramblock
        KVM: Provide helper to get kvm dirty log
        KVM: Create the KVMSlot dirty bitmap on flag changes
        KVM: Use a big lock to replace per-kml slots_lock
        memory: Introduce log_sync_global() to memory listener
        ...
      
      Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
      8385235b
    • Peter Maydell's avatar
      Merge remote-tracking branch 'remotes/kraxel/tags/input-20210526-pull-request' into staging · 2ab2dad0
      Peter Maydell authored
      
      input: a bunch of ps2 fixes.
      
      # gpg: Signature made Wed 26 May 2021 15:06:12 BST
      # gpg:                using RSA key A0328CFFB93A17A79901FE7D4CB6D8EED3E87138
      # 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/input-20210526-pull-request:
        hw/input/ps2: Use ps2_raise_irq() instead of open coding it
        pckbd: clear outport_present in outer pre_load()
        pckbd: remove duplicated keyboard and mouse defines
        pckbd: correctly disable PS/2 communication
        pckbd: add function kbd_pending()
        pckbd: add controller response queue
        pckbd: add state variable for interrupt source
        pckbd: PS/2 keyboard throttle
        pckbd: don't update OBF flags if KBD_STAT_OBF is set
        pckbd: split out interrupt line changing code
        ps2: don't deassert irq twice if queue is empty
        ps2: don't raise an interrupt if queue is full
        ps2: fix mouse stream corruption
        hw/input: expand trace info reported for ps2 device
      
      Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
      2ab2dad0
    • Paolo Bonzini's avatar
      gitlab-ci: use --meson=git for CFI jobs · 7cf333a3
      Paolo Bonzini authored
      
      Ensure that the meson submodule is checked out by the check targets,
      as they will need it to run "meson test".
      
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      7cf333a3
    • Kit Westneat's avatar
      hw/scsi: Fix sector translation bug in scsi_unmap_complete_noio · b802d14d
      Kit Westneat authored
      check_lba_range expects sectors to be expressed in original qdev blocksize, but
      scsi_unmap_complete_noio was translating them to 512 block sizes, which was
      causing sense errors in the larger LBAs in devices using a 4k block size.
      
      Resolves: https://gitlab.com/qemu-project/qemu/-/issues/345
      
      
      Signed-off-by: default avatarKit Westneat <kit.westneat@gmail.com>
      Message-Id: <20210521142829.326217-1-kit.westneat@gmail.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      b802d14d
    • Thomas Huth's avatar
      configure: Avoid error messages about missing *-config-*.h files · 54b0306e
      Thomas Huth authored
      
      When compiling with --disable-system there is a harmless yet still
      annoying error message at the end of the "configure" step:
      
       sed: can't read *-config-devices.h: No such file or directory
      
      When only building the tools or docs, without any emulator at all,
      there is even an additional message about missing *-config-target.h
      files.
      
      Fix it by checking whether any of these files are available before
      using them.
      
      Fixes: e0447a83 ("configure: Poison all current target-specific #defines")
      Reported-by: default avatarPhilippe Mathieu-Daudé <f4bug@amsat.org>
      Signed-off-by: default avatarThomas Huth <thuth@redhat.com>
      Reviewed-by: default avatarPhilippe Mathieu-Daudé <philmd@redhat.com>
      Message-Id: <20210519113840.298174-1-thuth@redhat.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      54b0306e
    • Ali Shirvani's avatar
      doc: Add notes about -mon option mode=control argument. · 16b3f3bb
      Ali Shirvani authored
      
      The mode=control argument configures a QMP monitor.
      
      Signed-off-by: default avatarAli Shirvani <alishir@routerhosting.com>
      Reviewed-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      Message-Id: <0799f0de89ad2482672b5d61d0de61e6eba782da.1621407918.git.alishir@routerhosting.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      16b3f3bb
    • Paolo Bonzini's avatar
      qemu-config: load modules when instantiating option groups · 632a8873
      Paolo Bonzini authored
      Right now the SPICE module is special cased to be loaded when processing
      of the -spice command line option.  However, the spice option group
      can also be brought in via -readconfig, in which case the module is
      not loaded.
      
      Add a generic hook to load modules that provide a QemuOpts group,
      and use it for the "spice" and "iscsi" groups.
      
      Fixes: #194
      Fixes: https://bugs.launchpad.net/qemu/+bug/1910696
      
      
      Cc: qemu-stable@nongnu.org
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      632a8873
    • Paolo Bonzini's avatar
      vl: allow not specifying size in -m when using -M memory-backend · d349f92f
      Paolo Bonzini authored
      
      Starting in QEMU 6.0's commit f5c9fcb8 ("vl: separate
      qemu_create_machine", 2020-12-10), a function have_custom_ram_size()
      replaced the return value of set_memory_options().
      
      The purpose of the return value was to record the presence of
      "-m size", and if it was not there, change the default RAM
      size to the size of the memory backend passed with "-M
      memory-backend".
      
      With that commit, however, have_custom_ram_size() is now queried only
      after set_memory_options has stored the fixed-up RAM size in QemuOpts for
      "future use".  This was actually the only future use of the fixed-up RAM
      size, so remove that code and fix the bug.
      
      Cc: qemu-stable@nongnu.org
      Fixes: f5c9fcb8 ("vl: separate qemu_create_machine", 2020-12-10)
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      d349f92f
    • Paolo Bonzini's avatar
      replication: move include out of root directory · b0262955
      Paolo Bonzini authored
      
      The replication.h file is included from migration/colo.c and tests/unit/test-replication.c,
      so it should be in include/.
      
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      b0262955
    • Paolo Bonzini's avatar
      remove qemu-options* from root directory · fd5fc4b1
      Paolo Bonzini authored
      
      These headers are also included from softmmu/vl.c, so they should be
      in include/.  Remove qemu-options-wrapper.h, since elsewhere
      we include "template" headers directly and #define the parameters in
      the including file; move qemu-options.h to include/.
      
      Reviewed-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      fd5fc4b1
    • Katsuhiro Ueno's avatar
      meson: Set implicit_include_directories to false · 75eebe0b
      Katsuhiro Ueno authored
      
      Without this, libvixl cannot be compiled with macOS 11.3 SDK due to
      include file name conflict (usr/include/c++/v1/version conflicts with
      VERSION).
      
      Signed-off-by: default avatarKatsuhiro Ueno <uenobk@gmail.com>
      Message-Id: <CA+pCdY09+OQfXq3YmRNuQE59ACOq7Py2q4hqOwgq4PnepCXhTA@mail.gmail.com>
      Tested-by: default avatarAlexander Graf <agraf@csgraf.de>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      75eebe0b
    • Philippe Mathieu-Daudé's avatar
      tests/qtest/fuzz: Fix build failure · aaad0264
      Philippe Mathieu-Daudé authored
      
      On Fedora 32, using clang (version 10.0.1-3.fc32) we get:
      
        tests/qtest/fuzz/fuzz.c:237:5: error: implicit declaration of function 'qemu_init' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
            qemu_init(result.we_wordc, result.we_wordv, NULL);
            ^
      
      qemu_init() is declared in "sysemu/sysemu.h", include this
      header to fix.
      
      Signed-off-by: default avatarPhilippe Mathieu-Daudé <philmd@redhat.com>
      Message-Id: <20210513162008.3922223-1-philmd@redhat.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      aaad0264
    • Peter Xu's avatar
      KVM: Dirty ring support · b4420f19
      Peter Xu authored
      
      KVM dirty ring is a new interface to pass over dirty bits from kernel to the
      userspace.  Instead of using a bitmap for each memory region, the dirty ring
      contains an array of dirtied GPAs to fetch (in the form of offset in slots).
      For each vcpu there will be one dirty ring that binds to it.
      
      kvm_dirty_ring_reap() is the major function to collect dirty rings.  It can be
      called either by a standalone reaper thread that runs in the background,
      collecting dirty pages for the whole VM.  It can also be called directly by any
      thread that has BQL taken.
      
      Signed-off-by: default avatarPeter Xu <peterx@redhat.com>
      Message-Id: <20210506160549.130416-11-peterx@redhat.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      b4420f19
    • Peter Xu's avatar
      KVM: Disable manual dirty log when dirty ring enabled · a81a5926
      Peter Xu authored
      
      KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2 is for KVM_CLEAR_DIRTY_LOG, which is only
      useful for KVM_GET_DIRTY_LOG.  Skip enabling it for kvm dirty ring.
      
      More importantly, KVM_DIRTY_LOG_INITIALLY_SET will not wr-protect all the pages
      initially, which is against how kvm dirty ring is used - there's no way for kvm
      dirty ring to re-protect a page before it's notified as being written first
      with a GFN entry in the ring!  So when KVM_DIRTY_LOG_INITIALLY_SET is enabled
      with dirty ring, we'll see silent data loss after migration.
      
      Signed-off-by: default avatarPeter Xu <peterx@redhat.com>
      Message-Id: <20210506160549.130416-10-peterx@redhat.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      a81a5926
    • Peter Xu's avatar
      KVM: Add dirty-ring-size property · 2ea5cb0a
      Peter Xu authored
      
      Add a parameter for dirty gfn count for dirty rings.  If zero, dirty ring is
      disabled.  Otherwise dirty ring will be enabled with the per-vcpu gfn count as
      specified.  If dirty ring cannot be enabled due to unsupported kernel or
      illegal parameter, it'll fallback to dirty logging.
      
      By default, dirty ring is not enabled (dirty-gfn-count default to 0).
      
      Signed-off-by: default avatarPeter Xu <peterx@redhat.com>
      Message-Id: <20210506160549.130416-9-peterx@redhat.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      2ea5cb0a
    • Peter Xu's avatar
      KVM: Cache kvm slot dirty bitmap size · 563d32ba
      Peter Xu authored
      
      Cache it too because we'll reference it more frequently in the future.
      
      Reviewed-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      Signed-off-by: default avatarPeter Xu <peterx@redhat.com>
      Message-Id: <20210506160549.130416-8-peterx@redhat.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      563d32ba
    • Peter Xu's avatar
      KVM: Simplify dirty log sync in kvm_set_phys_mem · 29b7e8be
      Peter Xu authored
      
      kvm_physical_sync_dirty_bitmap() on the whole section is inaccurate, because
      the section can be a superset of the memslot that we're working on.  The result
      is that if the section covers multiple kvm memslots, we could be doing the
      synchronization for multiple times for each kvmslot in the section.
      
      With the two helpers that we just introduced, it's very easy to do it right now
      by calling the helpers.
      
      Signed-off-by: default avatarPeter Xu <peterx@redhat.com>
      Message-Id: <20210506160549.130416-7-peterx@redhat.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      29b7e8be
    • Peter Xu's avatar
      KVM: Provide helper to sync dirty bitmap from slot to ramblock · 2c20b27e
      Peter Xu authored
      
      kvm_physical_sync_dirty_bitmap() calculates the ramblock offset in an
      awkward way from the MemoryRegionSection that passed in from the
      caller.  The truth is for each KVMSlot the ramblock offset never
      change for the lifecycle.  Cache the ramblock offset for each KVMSlot
      into the structure when the KVMSlot is created.
      
      With that, we can further simplify kvm_physical_sync_dirty_bitmap()
      with a helper to sync KVMSlot dirty bitmap to the ramblock dirty
      bitmap of a specific KVMSlot.
      
      Reviewed-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      Signed-off-by: default avatarPeter Xu <peterx@redhat.com>
      Message-Id: <20210506160549.130416-6-peterx@redhat.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      2c20b27e
    • Peter Xu's avatar
      KVM: Provide helper to get kvm dirty log · e65e5f50
      Peter Xu authored
      
      Provide a helper kvm_slot_get_dirty_log() to make the function
      kvm_physical_sync_dirty_bitmap() clearer.  We can even cache the as_id
      into KVMSlot when it is created, so that we don't even need to pass it
      down every time.
      
      Since at it, remove return value of kvm_physical_sync_dirty_bitmap()
      because it should never fail.
      
      Signed-off-by: default avatarPeter Xu <peterx@redhat.com>
      Message-Id: <20210506160549.130416-5-peterx@redhat.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      e65e5f50
    • Peter Xu's avatar
      KVM: Create the KVMSlot dirty bitmap on flag changes · ea776d15
      Peter Xu authored
      
      Previously we have two places that will create the per KVMSlot dirty
      bitmap:
      
        1. When a newly created KVMSlot has dirty logging enabled,
        2. When the first log_sync() happens for a memory slot.
      
      The 2nd case is lazy-init, while the 1st case is not (which is a fix
      of what the 2nd case missed).
      
      To do explicit initialization of dirty bitmaps, what we're missing is
      to create the dirty bitmap when the slot changed from not-dirty-track
      to dirty-track.  Do that in kvm_slot_update_flags().
      
      With that, we can safely remove the 2nd lazy-init.
      
      This change will be needed for kvm dirty ring because kvm dirty ring
      does not use the log_sync() interface at all.
      
      Also move all the pre-checks into kvm_slot_init_dirty_bitmap().
      
      Reviewed-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      Signed-off-by: default avatarPeter Xu <peterx@redhat.com>
      Message-Id: <20210506160549.130416-4-peterx@redhat.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      ea776d15
    • Peter Xu's avatar
      KVM: Use a big lock to replace per-kml slots_lock · a2f77862
      Peter Xu authored
      
      Per-kml slots_lock will bring some trouble if we want to take all slots_lock of
      all the KMLs, especially when we're in a context that we could have taken some
      of the KML slots_lock, then we even need to figure out what we've taken and
      what we need to take.
      
      Make this simple by merging all KML slots_lock into a single slots lock.
      
      Per-kml slots_lock isn't anything that helpful anyway - so far only x86 has two
      address spaces (so, two slots_locks).  All the rest archs will be having one
      address space always, which means there's actually one slots_lock so it will be
      the same as before.
      
      Signed-off-by: default avatarPeter Xu <peterx@redhat.com>
      Message-Id: <20210506160549.130416-3-peterx@redhat.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      a2f77862
    • Peter Xu's avatar
      memory: Introduce log_sync_global() to memory listener · b87eaa9b
      Peter Xu authored
      
      Some of the memory listener may want to do log synchronization without
      being able to specify a range of memory to sync but always globally.
      Such a memory listener should provide this new method instead of the
      log_sync() method.
      
      Obviously we can also achieve similar thing when we put the global
      sync logic into a log_sync() handler. However that's not efficient
      enough because otherwise memory_global_dirty_log_sync() may do the
      global sync N times, where N is the number of flat ranges in the
      address space.
      
      Make this new method be exclusive to log_sync().
      
      Reviewed-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      Signed-off-by: default avatarPeter Xu <peterx@redhat.com>
      Message-Id: <20210506160549.130416-2-peterx@redhat.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      b87eaa9b
    • Paolo Bonzini's avatar
      KVM: do not allow setting properties at runtime · 70cbae42
      Paolo Bonzini authored
      
      Only allow accelerator properties to be set when the
      accelerator is being created.
      
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      70cbae42
    • Paolo Bonzini's avatar
      qtest: add a QOM object for qtest · 6ba7ada3
      Paolo Bonzini authored
      
      The qtest server right now can only be created using the -qtest
      and -qtest-log options.  Allow an alternative way to create it
      using "-object qtest,chardev=...,log=...".
      
      This is part of the long term plan to make more (or all) of
      QEMU configurable through QMP and preconfig mode.
      
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      6ba7ada3
    • Paolo Bonzini's avatar
      object: add more commands to preconfig mode · 9e33013b
      Paolo Bonzini authored
      
      Creating and destroying QOM objects does not require a fully constructed
      machine.  Allow running object-add and object-del before machine
      initialization has concluded.
      
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      9e33013b
    • Yang Zhong's avatar
      i386/cpu: Expose AVX_VNNI instruction to guest · c1826ea6
      Yang Zhong authored
      Expose AVX (VEX-encoded) versions of the Vector Neural Network
      Instructions to guest.
      
      The bit definition:
      CPUID.(EAX=7,ECX=1):EAX[bit 4] AVX_VNNI
      
      The following instructions are available when this feature is
      present in the guest.
        1. VPDPBUS: Multiply and Add Unsigned and Signed Bytes
        2. VPDPBUSDS: Multiply and Add Unsigned and Signed Bytes with Saturation
        3. VPDPWSSD: Multiply and Add Signed Word Integers
        4. VPDPWSSDS: Multiply and Add Signed Integers with Saturation
      
      As for the kvm related code, please reference Linux commit id 1085a6b585d7.
      
      The release document ref below link:
      https://software.intel.com/content/www/us/en/develop/download/\
      
      
      intel-architecture-instruction-set-extensions-programming-reference.html
      
      Signed-off-by: default avatarYang Zhong <yang.zhong@intel.com>
      Message-Id: <20210407015609.22936-1-yang.zhong@intel.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      c1826ea6
    • Philippe Mathieu-Daudé's avatar
      hw/mem/nvdimm: Use Kconfig 'imply' instead of 'depends on' · cfa1f4bc
      Philippe Mathieu-Daudé authored
      
      Per the kconfig.rst:
      
        A device should be listed [...] ``imply`` if (depending on
        the QEMU command line) the board may or  may not be started
        without it.
      
      This is the case with the NVDIMM device, so use the 'imply'
      weak reverse dependency to select the symbol.
      
      Signed-off-by: default avatarPhilippe Mathieu-Daudé <philmd@redhat.com>
      Message-Id: <20210511155354.3069141-2-philmd@redhat.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      cfa1f4bc
    • Paolo Bonzini's avatar
      configure: simplify assignment to GIT_SUBMODULES · 2d652f24
      Paolo Bonzini authored
      
      Do not guard each assignment with a check for --with-git-submodules=ignore.
      To avoid a confusing "GIT" line from the Makefile, guard the git-submodule-update
      recipe so that it is empty when --with-git-submodules=ignore.
      
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      2d652f24
    • Paolo Bonzini's avatar
      configure: check for submodules if --with-git-submodules=ignore · b80fd281
      Paolo Bonzini authored
      
      Right now --with-git-submodules=ignore has a subtle difference from
      just running without a .git directory, in that it does not check
      that submodule sources actually exist.  Move the check for
      ui/keycodemapdb/README so that it happens even if the user
      specified --with-git-submodules=ignore, with a customized
      error message that is more suitable for this situation.
      
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      b80fd281
    • Philippe Mathieu-Daudé's avatar
      configure: Only clone softfloat-3 repositories if TCG is enabled · 56267b62
      Philippe Mathieu-Daudé authored
      
      Signed-off-by: default avatarPhilippe Mathieu-Daudé <philmd@redhat.com>
      Message-Id: <20210512045821.3257963-1-philmd@redhat.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      56267b62
    • Philippe Mathieu-Daudé's avatar
      hw/input/ps2: Use ps2_raise_irq() instead of open coding it · 96376ab1
      Philippe Mathieu-Daudé authored
      
      Inspired-by: default avatarVolker Rümelin <vr_qemu@t-online.de>
      Signed-off-by: default avatarPhilippe Mathieu-Daudé <f4bug@amsat.org>
      Reviewed-by: default avatarVolker Rümelin <vr_qemu@t-online.de>
      Reviewed-by: default avatarBin Meng <bmeng.cn@gmail.com>
      Message-Id: <20210513171244.3940519-1-f4bug@amsat.org>
      Signed-off-by: default avatarGerd Hoffmann <kraxel@redhat.com>
      96376ab1
    • Volker Rümelin's avatar
      pckbd: clear outport_present in outer pre_load() · 9d74e6c3
      Volker Rümelin authored
      
      The variable outport_present is a flag to show if the outport
      subsection was loaded. Clear the outport_present flag in the
      outer pre_load() function. This method is recommended in the QEMU
      manual for developers in the chapter "Migration, Subsections".
      
      Signed-off-by: default avatarVolker Rümelin <vr_qemu@t-online.de>
      Message-Id: <20210525181441.27768-12-vr_qemu@t-online.de>
      Signed-off-by: default avatarGerd Hoffmann <kraxel@redhat.com>
      9d74e6c3
    • Volker Rümelin's avatar
      pckbd: remove duplicated keyboard and mouse defines · 314f9064
      Volker Rümelin authored
      
      In 2005 the author of commit daa57963 "PS2 mouse and keyboard
      separation (Paul Brook)" and 0e43e99c "PS2 mouse and keyboard
      separation (Paul Brook)" separated the PS/2 controller code and
      the PS/2 keyboard and mouse code. It seems he forgot to remove
      a few defines. Remove them now.
      
      Signed-off-by: default avatarVolker Rümelin <vr_qemu@t-online.de>
      Message-Id: <20210525181441.27768-11-vr_qemu@t-online.de>
      Signed-off-by: default avatarGerd Hoffmann <kraxel@redhat.com>
      314f9064
    • Volker Rümelin's avatar
      pckbd: correctly disable PS/2 communication · f6f57a82
      Volker Rümelin authored
      
      Currently the PS/2 controller command KBD_CCMD_MOUSE_DISABLE
      doesn't disable the PS/2 mouse communication at all, and the
      PS/2 controller commands KBD_CCMD_KBD_DISABLE and
      KBD_CCMD_KBD_ENABLE only disable and enable the keyboard
      interrupt, which is very different from what a real PS/2
      controller does. A guest may notice the difference.
      
      Mask out pending data on disabled queues to correctly disable
      the PS/2 controller communication.
      
      Signed-off-by: default avatarVolker Rümelin <vr_qemu@t-online.de>
      Message-Id: <20210525181441.27768-10-vr_qemu@t-online.de>
      Signed-off-by: default avatarGerd Hoffmann <kraxel@redhat.com>
      f6f57a82
    • Volker Rümelin's avatar
      pckbd: add function kbd_pending() · e4697fab
      Volker Rümelin authored
      
      Replace reads of the variable s->pending with a call to a new
      function kbd_pending() to ease the review of the next patch.
      There is no functional change.
      
      Reviewed-by: default avatarPhilippe Mathieu-Daudé <philmd@redhat.com>
      Signed-off-by: default avatarVolker Rümelin <vr_qemu@t-online.de>
      Message-Id: <20210525181441.27768-9-vr_qemu@t-online.de>
      Signed-off-by: default avatarGerd Hoffmann <kraxel@redhat.com>
      e4697fab
    • Volker Rümelin's avatar
      pckbd: add controller response queue · aa67a42f
      Volker Rümelin authored
      
      Add a separate queue for PS/2 controller responses. The
      responses no longer get queued in the keyboard or mouse queues.
      The advantage of this can be seen after the next two patches,
      where the guest can disable the PS/2 communication with keyboard
      and mouse and still talk to the PS/2 controller.
      
      Signed-off-by: default avatarVolker Rümelin <vr_qemu@t-online.de>
      Message-Id: <20210525181441.27768-8-vr_qemu@t-online.de>
      Signed-off-by: default avatarGerd Hoffmann <kraxel@redhat.com>
      aa67a42f
    • Volker Rümelin's avatar
      pckbd: add state variable for interrupt source · ac9192bd
      Volker Rümelin authored
      
      Currently there is only one flag to distinguish between two
      interrupt sources and there are no available flags for more
      sources. Add an internal state variable to store the interrupt
      source. The next patch will introduce an additional interrupt
      source. There is no functional change.
      
      Signed-off-by: default avatarVolker Rümelin <vr_qemu@t-online.de>
      Message-Id: <20210525181441.27768-7-vr_qemu@t-online.de>
      Signed-off-by: default avatarGerd Hoffmann <kraxel@redhat.com>
      ac9192bd
    • Volker Rümelin's avatar
      pckbd: PS/2 keyboard throttle · d1e45668
      Volker Rümelin authored
      Limit the keyboard data rate to the serial link speed. Some old
      DOS software relies on being able to read an incoming scan-code
      more than once. After reading keyboard data from the i8042
      controller, the guest software has 1ms to read the same data
      again.
      
      Use -global i8042.kbd-throttle=on to enable this feature.
      
      To see how this patch works, start a FreeDOS 1.2 guest with the
      qemu option -global i8042.kbd-throttle=on and open a text file
      with the vim 7.3 32 bit for DOS executable. Then use the cursor
      keys (not the cursor keys on the numeric keypad) to move through
      the text. Without the kbd-throttle option enabled each keystroke
      will move the cursor two positions.
      
      Buglink: https://bugs.launchpad.net/bugs/1895363
      Buglink: https://bugs.launchpad.net/bugs/1897568
      
      
      Signed-off-by: default avatarVolker Rümelin <vr_qemu@t-online.de>
      Message-Id: <20210525181441.27768-6-vr_qemu@t-online.de>
      Signed-off-by: default avatarGerd Hoffmann <kraxel@redhat.com>
      d1e45668
    • Volker Rümelin's avatar
      pckbd: don't update OBF flags if KBD_STAT_OBF is set · ff6e1624
      Volker Rümelin authored
      
      Don't update the OBF flags in the status register and the cor-
      responding IRQ lines if KBD_STAT_OBF is set. Otherwise this
      may change the PS/2 event type. If the guest ISR was already
      scheduled, the changed event type will be rather surprising for
      the guest.
      
      This fixes a mouse event stream corruption. To reproduce the
      problem start a FreeDOS 1.2 guest with -machine pc,accel=kvm
      and -display gtk. The KVM in-kernel irqchip has to be enabled.
      Now open a text file with edit.exe in the guest and hold down
      the cursor right key and at the same time move the mouse around.
      You will quickly notice erratic mouse movements and unexpected
      mouse clicks.
      
      A trace file shows the mouse event stream corruption. Guest
      rip 0xce93 (f000:ce93) is the in al,0x60 instruction in the
      seabios mouse ISR, guest rip 0xceca (f000:ceca) is the
      in al,0x60 instruction in the seabios keyboard ISR.
      
      qemu-system-x86-5659  [007] ....   280.971116:
       tracing_mark_write: pckbd_kbd_update_irq kbd=0 aux=1
       # gtk queues a mouse event
      
      qemu-system-x86-5665  [000] ....   280.971121:
       kvm_exit: reason EXTERNAL_INTERRUPT rip 0x22da info 0 800000fd
      qemu-system-x86-5665  [000] d..1   280.971122:
       kvm_entry: vcpu 0, rip 0x22da
      qemu-system-x86-5665  [000] ....   280.971123:
       kvm_exit: reason EXTERNAL_INTERRUPT rip 0x22da info 0 800000fd
      qemu-system-x86-5665  [000] d..1   280.971124:
       kvm_entry: vcpu 0, rip 0x22da
      qemu-system-x86-5665  [000] ....   280.971126:
       kvm_exit: reason IO_INSTRUCTION rip 0x110c8c info 640008 0
      qemu-system-x86-5665  [000] ....   280.971176:
       tracing_mark_write: pckbd_kbd_read_status 0x3d
       # KBD_STAT_OBF and KBD_STAT_MOUSE_OBF set, the mouse ISR will
       # read data from the PS/2 controller.
      
      qemu-system-x86-5665  [000] d..1   280.971180:
       kvm_entry: vcpu 0, rip 0x110c8d
      qemu-system-x86-5665  [000] ....   280.971191:
       kvm_exit: reason EXTERNAL_INTERRUPT rip 0x110c8d info 0 800000f6
      qemu-system-x86-5665  [000] d..1   280.971191:
       kvm_entry: vcpu 0, rip 0x110c8d
      qemu-system-x86-5665  [000] ....   280.971193:
       kvm_exit: reason IO_INSTRUCTION rip 0xce93 info 600048 0
       # the mouse ISR wants to read data from the PS/2 controller
      
      qemu-system-x86-5659  [007] ....   280.971231:
       tracing_mark_write: pckbd_kbd_update_irq kbd=1 aux=0
      qemu-system-x86-5659  [007] ....   280.971238:
       tracing_mark_write: pckbd_kbd_update_irq kbd=1 aux=0
       # gtk queues a keyboard event 0xe0 0x4d (key right)
      
      qemu-system-x86-5665  [000] ....   280.971257:
       tracing_mark_write: pckbd_kbd_update_irq kbd=0 aux=1
      qemu-system-x86-5665  [000] ....   280.971262:
       tracing_mark_write: pckbd_kbd_update_irq kbd=1 aux=0
       # ps2_read_data() deasserts and reasserts the keyboard IRQ
      
      qemu-system-x86-5665  [000] ....   280.971266:
       tracing_mark_write: pckbd_kbd_read_data 0xe0 kbd
       # -> the mouse ISR receives keyboard data
      
      qemu-system-x86-5665  [000] d..1   280.971268:
       kvm_entry: vcpu 0, rip 0xce95
      qemu-system-x86-5665  [000] ....   280.971269:
       kvm_exit: reason IO_INSTRUCTION rip 0xe828 info a00040 0
      qemu-system-x86-5665  [000] ....   280.971270:
       kvm_ack_irq: irqchip PIC slave pin 12
      qemu-system-x86-5665  [000] d..1   280.971270:
       kvm_entry: vcpu 0, rip 0xe82a
      qemu-system-x86-5665  [000] ....   280.971271:
       kvm_exit: reason IO_INSTRUCTION rip 0xe82a info 200040 0
      qemu-system-x86-5665  [000] ....   280.971271:
       kvm_ack_irq: irqchip PIC master pin 2
      qemu-system-x86-5665  [000] d..1   280.971271:
       kvm_entry: vcpu 0, rip 0xe82c
      qemu-system-x86-5665  [000] ....   280.971272:
       kvm_exit: reason PENDING_INTERRUPT rip 0x22da info 0 0
      qemu-system-x86-5665  [000] d..1   280.971273:
       kvm_entry: vcpu 0, rip 0x22da
      qemu-system-x86-5665  [000] ....   280.971274:
       kvm_exit: reason IO_INSTRUCTION rip 0x110c8c info 640008 0
      qemu-system-x86-5665  [000] ....   280.971275:
       tracing_mark_write: pckbd_kbd_read_status 0x1d
      qemu-system-x86-5665  [000] d..1   280.971276:
       kvm_entry: vcpu 0, rip 0x110c8d
      qemu-system-x86-5665  [000] ....   280.971277:
       kvm_exit: reason IO_INSTRUCTION rip 0xceca info 600048 0
       # the keyboard ISR wants to read data from the PS/2 controller
      
      qemu-system-x86-5665  [000] ....   280.971279:
       tracing_mark_write: pckbd_kbd_update_irq kbd=0 aux=1
      qemu-system-x86-5665  [000] ....   280.971282:
       tracing_mark_write: pckbd_kbd_read_data 0x4d kbd
       # the keyboard ISR receives the second byte of the keyboard event
      
      Signed-off-by: default avatarVolker Rümelin <vr_qemu@t-online.de>
      Message-Id: <20210525181441.27768-5-vr_qemu@t-online.de>
      
      [ kraxel: add missing include ]
      
      Signed-off-by: default avatarGerd Hoffmann <kraxel@redhat.com>
      ff6e1624
Loading