Commit graph

101004 commits

Author SHA1 Message Date
Laszlo Ersek 6a3aa014c5 acpi: cpuhp: fix guest-visible maximum access size to the legacy reg block
The modern ACPI CPU hotplug interface was introduced in the following
series (aa1dd39ca307..679dd1a957df), released in v2.7.0:

  1  abd49bc2ed docs: update ACPI CPU hotplug spec with new protocol
  2  16bcab97eb pc: piix4/ich9: add 'cpu-hotplug-legacy' property
  3  5e1b5d9388 acpi: cpuhp: add CPU devices AML with _STA method
  4  ac35f13ba8 pc: acpi: introduce AcpiDeviceIfClass.madt_cpu hook
  5  d2238cb678 acpi: cpuhp: implement hot-add parts of CPU hotplug
                  interface
  6  8872c25a26 acpi: cpuhp: implement hot-remove parts of CPU hotplug
                  interface
  7  76623d00ae acpi: cpuhp: add cpu._OST handling
  8  679dd1a957 pc: use new CPU hotplug interface since 2.7 machine type

Before patch#1, "docs/specs/acpi_cpu_hotplug.txt" only specified 1-byte
accesses for the hotplug register block.  Patch#1 preserved the same
restriction for the legacy register block, but:

- it specified DWORD accesses for some of the modern registers,

- in particular, the switch from the legacy block to the modern block
  would require a DWORD write to the *legacy* block.

The latter functionality was then implemented in cpu_status_write()
[hw/acpi/cpu_hotplug.c], in patch#8.

Unfortunately, all DWORD accesses depended on a dormant bug: the one
introduced in earlier commit a014ed07bd ("memory: accept mismatching
sizes in memory_region_access_valid", 2013-05-29); first released in
v1.6.0.  Due to commit a014ed07bd, the DWORD accesses to the *legacy*
CPU hotplug register block would work in spite of the above series *not*
relaxing "valid.max_access_size = 1" in "hw/acpi/cpu_hotplug.c":

> static const MemoryRegionOps AcpiCpuHotplug_ops = {
>     .read = cpu_status_read,
>     .write = cpu_status_write,
>     .endianness = DEVICE_LITTLE_ENDIAN,
>     .valid = {
>         .min_access_size = 1,
>         .max_access_size = 1,
>     },
> };

Later, in commits e6d0c3ce68 ("acpi: cpuhp: introduce 'Command data 2'
field", 2020-01-22) and ae340aa3d2 ("acpi: cpuhp: spec: add typical
usecases", 2020-01-22), first released in v5.0.0, the modern CPU hotplug
interface (including the documentation) was extended with another DWORD
*read* access, namely to the "Command data 2" register, which would be
important for the guest to confirm whether it managed to switch the
register block from legacy to modern.

This functionality too silently depended on the bug from commit
a014ed07bd.

In commit 5d971f9e67 ('memory: Revert "memory: accept mismatching sizes
in memory_region_access_valid"', 2020-06-26), first released in v5.1.0,
the bug from commit a014ed07bd was fixed (the commit was reverted).
That swiftly exposed the bug in "AcpiCpuHotplug_ops", still present from
the v2.7.0 series quoted at the top -- namely the fact that
"valid.max_access_size = 1" didn't match what the guest was supposed to
do, according to the spec ("docs/specs/acpi_cpu_hotplug.txt").

The symptom is that the "modern interface negotiation protocol"
described in commit ae340aa3d256:

> +      Use following steps to detect and enable modern CPU hotplug interface:
> +        1. Store 0x0 to the 'CPU selector' register,
> +           attempting to switch to modern mode
> +        2. Store 0x0 to the 'CPU selector' register,
> +           to ensure valid selector value
> +        3. Store 0x0 to the 'Command field' register,
> +        4. Read the 'Command data 2' register.
> +           If read value is 0x0, the modern interface is enabled.
> +           Otherwise legacy or no CPU hotplug interface available

falls apart for the guest: steps 1 and 2 are lost, because they are DWORD
writes; so no switching happens.  Step 3 (a single-byte write) is not
lost, but it has no effect; see the condition in cpu_status_write() in
patch#8.  And step 4 *misleads* the guest into thinking that the switch
worked: the DWORD read is lost again -- it returns zero to the guest
without ever reaching the device model, so the guest never learns the
switch didn't work.

This means that guest behavior centered on the "Command data 2" register
worked *only* in the v5.0.0 release; it got effectively regressed in
v5.1.0.

To make things *even more* complicated, the breakage was (and remains, as
of today) visible with TCG acceleration only.  Commit 5d971f9e67 makes
no difference with KVM acceleration -- the DWORD accesses still work,
despite "valid.max_access_size = 1".

As commit 5d971f9e67 suggests, fix the problem by raising
"valid.max_access_size" to 4 -- the spec now clearly instructs the guest
to perform DWORD accesses to the legacy register block too, for enabling
(and verifying!) the modern block.  In order to keep compatibility for the
device model implementation though, set "impl.max_access_size = 1", so
that wide accesses be split before they reach the legacy read/write
handlers, like they always have been on KVM, and like they were on TCG
before 5d971f9e67 (v5.1.0).

Tested with:

- OVMF IA32 + qemu-system-i386, CPU hotplug/hot-unplug with SMM,
  intermixed with ACPI S3 suspend/resume, using KVM accel
  (regression-test);

- OVMF IA32X64 + qemu-system-x86_64, CPU hotplug/hot-unplug with SMM,
  intermixed with ACPI S3 suspend/resume, using KVM accel
  (regression-test);

- OVMF IA32 + qemu-system-i386, SMM enabled, using TCG accel; verified the
  register block switch and the present/possible CPU counting through the
  modern hotplug interface, during OVMF boot (bugfix test);

- I do not have any testcase (guest payload) for regression-testing CPU
  hotplug through the *legacy* CPU hotplug register block.

Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Ani Sinha <ani@anisinha.ca>
Cc: Ard Biesheuvel <ardb@kernel.org>
Cc: Igor Mammedov <imammedo@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Peter Maydell <peter.maydell@linaro.org>
Cc: Philippe Mathieu-Daudé <philmd@linaro.org>
Cc: qemu-stable@nongnu.org
Ref: "IO port write width clamping differs between TCG and KVM"
Link: http://mid.mail-archive.com/aaedee84-d3ed-a4f9-21e7-d221a28d1683@redhat.com
Link: https://lists.gnu.org/archive/html/qemu-devel/2023-01/msg00199.html
Reported-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Tested-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Tested-by: Igor Mammedov <imammedo@redhat.com>
Message-Id: <20230105161804.82486-1-lersek@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit dab30fbef3896bb652a09d46c37d3f55657cbcbb)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2023-03-29 10:20:04 +03:00
Richard Henderson e05827b632 target/riscv: Set pc_succ_insn for !rvc illegal insn
Failure to set pc_succ_insn may result in a TB covering zero bytes,
which triggers an assert within the code generator.

Cc: qemu-stable@nongnu.org
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1224
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-Id: <20221203175744.151365-1-richard.henderson@linaro.org>
[ Changes by AF:
 - Add missing run-plugin-test-noc-% line
]
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
(cherry picked from commit ec2918b467228e7634f1dd5f35033ad3021b6ef7)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2023-03-29 10:20:04 +03:00
Paolo Bonzini 6647b6edea meson: accept relative symlinks in "meson introspect --installed" data
When installing shared libraries, as is the case for libvfio-user.so,
Meson will include relative symbolic links in the output of
"meson introspect --installed":

  {
    "libvfio-user.so": "/usr/local/lib64/libvfio-user.so",
    ...
  }

In the case of scripts/symlink-install-tree.py, this will
be a symbolic link to a symbolic link but, in any case, there is
no issue in creating it.

Cc: qemu-stable@nongnu.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
(cherry picked from commit f32eb0021a85efaca97f69b0e9201737562a8e4f)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2023-03-29 10:20:04 +03:00
Alex Bennée 305c0f8c54 target/arm: fix handling of HLT semihosting in system mode
The check semihosting_enabled() wants to know if the guest is
currently in user mode. Unlike the other cases the test was inverted
causing us to block semihosting calls in non-EL0 modes.

Cc: qemu-stable@nongnu.org
Fixes: 19b26317e9 (target/arm: Honour -semihosting-config userspace=on)
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
(cherry picked from commit 9788d4c007cbde7cda1b7a577b8b836335eb2b73)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2023-03-29 10:20:04 +03:00
Chenyi Qiang a2093dd6fe virtio-mem: Fix the iterator variable in a vmem->rdl_list loop
It should be the variable rdl2 to revert the already-notified listeners.

Fixes: 2044969f0b ("virtio-mem: Implement RamDiscardManager interface")
Signed-off-by: Chenyi Qiang <chenyi.qiang@intel.com>
Message-Id: <20221228090312.17276-1-chenyi.qiang@intel.com>
Cc: qemu-stable@nongnu.org
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: David Hildenbrand <david@redhat.com>
(cherry picked from commit 29f1b328e3b767cba2661920a8470738469b9e36)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2023-03-29 10:20:04 +03:00
Chenyi Qiang 5f43c7786e virtio-mem: Fix the bitmap index of the section offset
vmem->bitmap indexes the memory region of the virtio-mem backend at a
granularity of block_size. To calculate the index of target section offset,
the block_size should be divided instead of the bitmap_size.

Fixes: 2044969f0b ("virtio-mem: Implement RamDiscardManager interface")
Signed-off-by: Chenyi Qiang <chenyi.qiang@intel.com>
Message-Id: <20221216062231.11181-1-chenyi.qiang@intel.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Cc: qemu-stable@nongnu.org
Signed-off-by: David Hildenbrand <david@redhat.com>
(cherry picked from commit b11cf32e07a2f7ff0d171b89497381a04c9d07e0)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2023-03-29 10:20:04 +03:00
Jason Wang f16011abc1 vhost: fix vq dirty bitmap syncing when vIOMMU is enabled
When vIOMMU is enabled, the vq->used_phys is actually the IOVA not
GPA. So we need to translate it to GPA before the syncing otherwise we
may hit the following crash since IOVA could be out of the scope of
the GPA log size. This could be noted when using virtio-IOMMU with
vhost using 1G memory.

Fixes: c471ad0e9b ("vhost_net: device IOTLB support")
Cc: qemu-stable@nongnu.org
Tested-by: Lei Yang <leiyang@redhat.com>
Reported-by: Yalan Zhang <yalzhang@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
Message-Id: <20221216033552.77087-1-jasowang@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit 345cc1cbcbce2bab00abc2b88338d7d89c702d6b)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2023-03-29 10:20:04 +03:00
Guenter Roeck e34f86a2f9 target/sh4: Mask restore of env->flags from tb->flags
The values in env->flags are a subset of tb->flags.
Restore only the bits that belong.

Cc: qemu-stable@nongnu.org
Fixes: ab419fd8a0 ("target/sh4: Fix TB_FLAG_UNALIGN")
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Message-ID: <20221212011345.GA2235238@roeck-us.net>
[rth: Reduce to only the the superh_cpu_synchronize_from_tb change]
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
(cherry picked from commit bc2331635ce18ff068d2bb1e493bc546e1f786e1)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2023-03-29 10:20:04 +03:00
Antonio Abbatangelo 4a99fd0f18 ui: Add clear button to file picker 2023-03-26 22:20:11 -07:00
wutno 065c74a00f nv2a: Don't manually set NV_PFB_CFG0 reg 2023-03-06 14:02:41 -07:00
Dustin Holden d8fa50e524 smc: Implement read/write of SMC error code storage 2023-02-14 17:10:40 -07:00
Matt Borgerson 7cbe9d337a util/osdep.c: Fix qemu_mkdir missing return value 2023-01-23 12:47:25 -07:00
Matt Borgerson 3c836586be ci: Update xemu-win64-toolchain image tag 2023-01-23 12:39:36 -07:00
Matt Borgerson d0d3e7b4fa xemu-win64-toolchain/sdl2.mk: Specify PKG_FILE 2023-01-23 10:37:06 -07:00
Matt Borgerson c08183c54d xemu-win64-toolchain: Add libslirp v4.7.0 2023-01-23 10:37:06 -07:00
Matt Borgerson d14e3360d3 scripts/download-macos-libs.py: Add libslirp 2023-01-23 02:17:32 -07:00
Matt Borgerson e1cd23213f configure, meson: Use legacy gl/epoxy detection for now 2023-01-23 02:17:32 -07:00
Matt Borgerson 577c469ae1 scripts/gen-license.py: Update libslirp 2023-01-23 02:06:46 -07:00
Matt Borgerson 9c3e05ded4 configure: Add back fortify source option 2023-01-23 00:30:40 -07:00
Matt Borgerson 03ba4ecad2 ci: Drop QEMU GH mirror's lockdown.yml workflow 2023-01-23 00:30:40 -07:00
Matt Borgerson 861492d62a meson: Use optimization level 3 2023-01-23 00:30:40 -07:00
Matt Borgerson 3afd8456d5 xbox.c: Fix null string warning 2023-01-23 00:30:40 -07:00
Matt Borgerson 38f294c58a softmmu/runstate.c: Fix unused variable warning 2023-01-23 00:30:40 -07:00
Matt Borgerson 637a37dd02 target/i386: Fix unused function warning 2023-01-23 00:30:40 -07:00
Matt Borgerson b53b53b04b configure: Cleanup straggling newline 2023-01-23 00:30:40 -07:00
Matt Borgerson b6dc0cdca2 accel/tcg: Don't attempt to revert code_gen_ptr on a recycled TB 2023-01-23 00:30:40 -07:00
Matt Borgerson c5a32ec200 meson: Update meson-buildoptions.sh 2023-01-23 00:30:40 -07:00
Matt Borgerson 2872f38f4f meson: Reflow a few sections 2023-01-23 00:30:40 -07:00
Matt Borgerson 25ced4f4c1 configure, meson: Migrate gl check to meson 2023-01-23 00:30:40 -07:00
Matt Borgerson ec7d5ce8db configure, meson: Migrate libsamplerate check to meson 2023-01-23 00:30:40 -07:00
Matt Borgerson ef44344d06 configure, meson: Migrate libpcap check to meson 2023-01-23 00:30:40 -07:00
Matt Borgerson ed042c141f configure, meson: Migrate openssl check to meson 2023-01-23 00:30:40 -07:00
Matt Borgerson 6cc30513ac configure, meson: Eliminate redundant gtk check 2023-01-23 00:30:40 -07:00
Matt Borgerson c3e9fb14a5 i386/tcg: Migrate gen_jmp_im to gen_update_eip_next 2023-01-23 00:30:40 -07:00
Matt Borgerson 93b2a408fb main: Cleanup 2023-01-23 00:30:40 -07:00
Matt Borgerson d981ca9409 accel/tcg: Migrate from tb->pc 2023-01-23 00:30:40 -07:00
Matt Borgerson d73d134bcf target/i386: Fix gen_enter_mmx calls 2023-01-23 00:30:40 -07:00
Matt Borgerson 2cca7e1b8f tlb: Update TCGMemOpIdx to MemOpIdx 2023-01-23 00:30:40 -07:00
Matt Borgerson 99e719a674 tlb: Update callback to use CPUTLBEntryFull 2023-01-23 00:30:40 -07:00
Matt Borgerson 4dd5e12807 xemu-xbe.c: Add memtxattrs 2023-01-23 00:30:40 -07:00
Matt Borgerson 2e201db096 xemu-hud.h: Add gl.h 2023-01-23 00:30:40 -07:00
Matt Borgerson 426805f0b3 ui/xemu: Specify new force param to qmp_blockdev_change_medium 2023-01-23 00:30:40 -07:00
Matt Borgerson b3fe79bc8a ui/xemu: Drop old display change listener ops 2023-01-23 00:30:40 -07:00
Matt Borgerson bf85019e32 ui/xemu: Specify delay arg to dpy_set_ui_info 2023-01-23 00:30:40 -07:00
Matt Borgerson 8625656510 ui/xemu: Define {ctrl,alt}_grab 2023-01-23 00:30:40 -07:00
Matt Borgerson 88fd14d26a meson: Enable slirp 2023-01-23 00:30:40 -07:00
Matt Borgerson c30a2a8f23 meson: Enable opengl 2023-01-23 00:30:40 -07:00
Matt Borgerson 28fb1e44c6 meson: Ignore EGL requirement 2023-01-23 00:30:40 -07:00
Matt Borgerson 8e3a1b2b2c xbox: Drop old pcms->pit_enabled setting 2023-01-23 00:30:40 -07:00
Matt Borgerson b1a59ba2e9 nv2a: Add missing vga headers 2023-01-23 00:30:40 -07:00