]> git.proxmox.com Git - mirror_qemu.git/log
mirror_qemu.git
3 years agotarget/ppc/kvm: Cache timebase frequency
Greg Kurz [Wed, 17 Mar 2021 17:57:07 +0000 (18:57 +0100)]
target/ppc/kvm: Cache timebase frequency

Each vCPU core exposes its timebase frequency in the DT. When running
under KVM, this means parsing /proc/cpuinfo in order to get the timebase
frequency of the host CPU.

The parsing appears to slow down the boot quite a bit with higher number
of cores:

# of cores     seconds spent in spapr_dt_cpus()
      8                  0.550122
     16                  1.342375
     32                  2.850316
     64                  5.922505
     96                  9.109224
    128                 12.245504
    256                 24.957236
    384                 37.389113

The timebase frequency of the host CPU is identical for all
cores and it is an invariant for the VM lifetime. Cache it
instead of doing the same expensive parsing again and again.

Rename kvmppc_get_tbfreq() to kvmppc_get_tbfreq_procfs() and
rename the 'retval' variable to make it clear it is used as
fallback only. Come up with a new version of kvmppc_get_tbfreq()
that calls kvmppc_get_tbfreq_procfs() only once and keep the
value in a static.

Zero is certainly not a valid value for the timebase frequency.
Treat atoi() returning zero as another parsing error and return
the fallback value instead. This allows kvmppc_get_tbfreq() to
use zero as an indicator that kvmppc_get_tbfreq_procfs() hasn't
been called yet.

With this patch applied:

    384                 0.518382

Signed-off-by: Greg Kurz <groug@kaod.org>
Message-Id: <161600382766.1780699.6787739229984093959.stgit@bahia.lan>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
3 years agohw/ppc: e500: Add missing #address-cells and #size-cells in the eTSEC node
Bin Meng [Thu, 11 Mar 2021 08:16:08 +0000 (16:16 +0800)]
hw/ppc: e500: Add missing #address-cells and #size-cells in the eTSEC node

Per devicetree spec v0.3 [1] chapter 2.3.5:

The #address-cells and #size-cells properties are not inherited
from ancestors in the devicetree. They shall be explicitly defined.
If missing, a client program should assume a default value of 2
for #address-cells, and a value of 1 for #size-cells.

These properties are currently missing, causing the <reg> property
of the queue-group subnode to be incorrectly parsed using default
values.

[1] https://github.com/devicetree-org/devicetree-specification/releases/download/v0.3/devicetree-specification-v0.3.pdf

Fixes: fdfb7f2cdb2d ("e500: Add support for eTSEC in device tree")
Signed-off-by: Bin Meng <bin.meng@windriver.com>
Message-Id: <20210311081608.66891-1-bmeng.cn@gmail.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
3 years agoUpdate version for v6.0.0-rc1 release
Peter Maydell [Tue, 30 Mar 2021 17:19:07 +0000 (18:19 +0100)]
Update version for v6.0.0-rc1 release

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
3 years agoMerge remote-tracking branch 'remotes/pmaydell/tags/pull-target-arm-20210330' into...
Peter Maydell [Tue, 30 Mar 2021 15:37:15 +0000 (16:37 +0100)]
Merge remote-tracking branch 'remotes/pmaydell/tags/pull-target-arm-20210330' into staging

 * net/npcm7xx_emc.c: Fix handling of receiving packets when RSDR not set
 * hw/display/xlnx_dp: Free FIFOs adding xlnx_dp_finalize()
 * hw/arm/smmuv3: Drop unused CDM_VALID() and is_cd_valid()
 * target/arm: Make number of counters in PMCR follow the CPU
 * hw/timer/renesas_tmr: Add default-case asserts in read_tcnt()

# gpg: Signature made Tue 30 Mar 2021 14:23:33 BST
# gpg:                using RSA key E1A5C593CD419DE28E8315CF3C2525ED14360CDE
# gpg:                issuer "peter.maydell@linaro.org"
# gpg: Good signature from "Peter Maydell <peter.maydell@linaro.org>" [ultimate]
# gpg:                 aka "Peter Maydell <pmaydell@gmail.com>" [ultimate]
# gpg:                 aka "Peter Maydell <pmaydell@chiark.greenend.org.uk>" [ultimate]
# Primary key fingerprint: E1A5 C593 CD41 9DE2 8E83  15CF 3C25 25ED 1436 0CDE

* remotes/pmaydell/tags/pull-target-arm-20210330:
  hw/timer/renesas_tmr: Add default-case asserts in read_tcnt()
  target/arm: Make number of counters in PMCR follow the CPU
  hw/arm/smmuv3: Drop unused CDM_VALID() and is_cd_valid()
  hw/display/xlnx_dp: Free FIFOs adding xlnx_dp_finalize()
  net/npcm7xx_emc.c: Fix handling of receiving packets when RSDR not set

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
3 years agoMerge remote-tracking branch 'remotes/maxreitz/tags/pull-block-2021-03-30' into staging
Peter Maydell [Tue, 30 Mar 2021 13:06:54 +0000 (14:06 +0100)]
Merge remote-tracking branch 'remotes/maxreitz/tags/pull-block-2021-03-30' into staging

Block patches for 6.0-rc1:
- Mark the qcow2 cache clean timer as external to fix record/replay
- Fix the mirror filter node's permissions so that an external process
  cannot grab an image while it is used as the mirror source
- Add documentation about FUSE exports to the storage daemon
- When creating a qcow2 image with the data-file-raw option, all
  metadata structures should be preallocated
- iotest fixes

# gpg: Signature made Tue 30 Mar 2021 13:38:40 BST
# gpg:                using RSA key 91BEB60A30DB3E8857D11829F407DB0061D5CF40
# gpg:                issuer "mreitz@redhat.com"
# gpg: Good signature from "Max Reitz <mreitz@redhat.com>" [full]
# Primary key fingerprint: 91BE B60A 30DB 3E88 57D1  1829 F407 DB00 61D5 CF40

* remotes/maxreitz/tags/pull-block-2021-03-30:
  iotests/244: Test preallocation for data-file-raw
  qcow2: Force preallocation with data-file-raw
  qsd: Document FUSE exports
  block/mirror: Fix mirror_top's permissions
  iotests/046: Filter request length
  qcow2: use external virtual timers
  iotests/116: Fix reference output
  iotests: fix 051.out expected output after error text touchups
  iotests: Fix typo in iotest 051

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
3 years agohw/timer/renesas_tmr: Add default-case asserts in read_tcnt()
Peter Maydell [Tue, 30 Mar 2021 13:05:34 +0000 (14:05 +0100)]
hw/timer/renesas_tmr: Add default-case asserts in read_tcnt()

In commit 81b3ddaf8772ec we fixed a use of uninitialized data
in read_tcnt(). However this change wasn't enough to placate
Coverity, which is not smart enough to see that if we read a
2 bit field and then handle cases 0, 1, 2 and 3 then there cannot
be a flow of execution through the switch default. Add explicit
default cases which assert that they can't be reached, which
should help silence Coverity.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-id: 20210319162458.13760-1-peter.maydell@linaro.org

3 years agotarget/arm: Make number of counters in PMCR follow the CPU
Peter Maydell [Tue, 30 Mar 2021 13:05:33 +0000 (14:05 +0100)]
target/arm: Make number of counters in PMCR follow the CPU

Currently we give all the v7-and-up CPUs a PMU with 4 counters.  This
means that we don't provide the 6 counters that are required by the
Arm BSA (Base System Architecture) specification if the CPU supports
the Virtualization extensions.

Instead of having a single PMCR_NUM_COUNTERS, make each CPU type
specify the PMCR reset value (obtained from the appropriate TRM), and
use the 'N' field of that value to define the number of counters
provided.

This means that we now supply 6 counters for Cortex-A53, A57, A72,
A15 and A9 as well as '-cpu max'; Cortex-A7 and A8 stay at 4; and
Cortex-R5 goes down to 3.

Note that because we now use the PMCR reset value of the specific
implementation, we no longer set the LC bit out of reset.  This has
an UNKNOWN value out of reset for all cores with any AArch32 support,
so guest software should be setting it anyway if it wants it.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Tested-by: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org>
Message-id: 20210311165947.27470-1-peter.maydell@linaro.org
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
3 years agohw/arm/smmuv3: Drop unused CDM_VALID() and is_cd_valid()
Zenghui Yu [Tue, 30 Mar 2021 13:05:33 +0000 (14:05 +0100)]
hw/arm/smmuv3: Drop unused CDM_VALID() and is_cd_valid()

They were introduced in commit 9bde7f0674fe ("hw/arm/smmuv3: Implement
translate callback") but never actually used. Drop them.

Signed-off-by: Zenghui Yu <yuzenghui@huawei.com>
Acked-by: Eric Auger <eric.auger@redhat.com>
Message-id: 20210325142702.790-1-yuzenghui@huawei.com
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
3 years agohw/display/xlnx_dp: Free FIFOs adding xlnx_dp_finalize()
Philippe Mathieu-Daudé [Tue, 30 Mar 2021 13:05:33 +0000 (14:05 +0100)]
hw/display/xlnx_dp: Free FIFOs adding xlnx_dp_finalize()

When building with --enable-sanitizers we get:

  Direct leak of 16 byte(s) in 1 object(s) allocated from:
      #0 0x5618479ec7cf in malloc (qemu-system-aarch64+0x233b7cf)
      #1 0x7f675745f958 in g_malloc (/lib64/libglib-2.0.so.0+0x58958)
      #2 0x561847c2dcc9 in xlnx_dp_init hw/display/xlnx_dp.c:1259:5
      #3 0x56184a5bdab8 in object_init_with_type qom/object.c:375:9
      #4 0x56184a5a2bda in object_initialize_with_type qom/object.c:517:5
      #5 0x56184a5a24d5 in object_initialize qom/object.c:536:5
      #6 0x56184a5a2f6c in object_initialize_child_with_propsv qom/object.c:566:5
      #7 0x56184a5a2e60 in object_initialize_child_with_props qom/object.c:549:10
      #8 0x56184a5a3a1e in object_initialize_child_internal qom/object.c:603:5
      #9 0x5618495aa431 in xlnx_zynqmp_init hw/arm/xlnx-zynqmp.c:273:5

The RX/TX FIFOs are created in xlnx_dp_init(), add xlnx_dp_finalize()
to destroy them.

Fixes: 58ac482a66d ("introduce xlnx-dp")
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Message-id: 20210323182958.277654-1-f4bug@amsat.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
3 years agonet/npcm7xx_emc.c: Fix handling of receiving packets when RSDR not set
Doug Evans [Tue, 30 Mar 2021 13:05:33 +0000 (14:05 +0100)]
net/npcm7xx_emc.c: Fix handling of receiving packets when RSDR not set

Turning REG_MCMDR_RXON is enough to start receiving packets.

Signed-off-by: Doug Evans <dje@google.com>
Message-id: 20210319195044.741821-1-dje@google.com
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
3 years agoiotests/244: Test preallocation for data-file-raw
Max Reitz [Fri, 26 Mar 2021 14:55:09 +0000 (15:55 +0100)]
iotests/244: Test preallocation for data-file-raw

Three test cases:
(1) Adding a qcow2 (metadata) file to an existing data file, see whether
    we can read the existing data through the qcow2 image.
(2) Append data to the data file, grow the qcow2 image accordingly, see
    whether we can read the new data through the qcow2 image.
(3) At runtime, add a backing image to a freshly created qcow2 image
    with an external data file (with data-file-raw).  Reading data from
    the qcow2 image must return the same result as reading data from the
    data file, so everything in the backing image must be ignored.
    (This did not use to be the case, because without the L2 tables
    preallocated, all clusters would appear as unallocated, and so the
    qcow2 driver would fall through to the backing file.)

Signed-off-by: Max Reitz <mreitz@redhat.com>
Message-Id: <20210326145509.163455-3-mreitz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
3 years agoqcow2: Force preallocation with data-file-raw
Max Reitz [Fri, 26 Mar 2021 14:55:08 +0000 (15:55 +0100)]
qcow2: Force preallocation with data-file-raw

Setting the qcow2 data-file-raw bit means that you can ignore the
qcow2 metadata when reading from the external data file.  It does not
mean that you have to ignore it, though.  Therefore, the data read must
be the same regardless of whether you interpret the metadata or whether
you ignore it, and thus the L1/L2 tables must all be present and give a
1:1 mapping.

This patch changes 244's output: First, the qcow2 file is larger right
after creation, because of metadata preallocation.  Second, the qemu-img
map output changes: Everything that was not explicitly discarded or
zeroed is now a data area.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Message-Id: <20210326145509.163455-2-mreitz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
3 years agoMerge remote-tracking branch 'remotes/nvme/tags/nvme-fixes-for-6.0-pull-request'...
Peter Maydell [Mon, 29 Mar 2021 17:45:12 +0000 (18:45 +0100)]
Merge remote-tracking branch 'remotes/nvme/tags/nvme-fixes-for-6.0-pull-request' into staging

emulated nvme fixes

# gpg: Signature made Mon 29 Mar 2021 18:03:30 BST
# gpg:                using RSA key 522833AA75E2DCE6A24766C04DE1AF316D4F0DE9
# gpg: Good signature from "Klaus Jensen <its@irrelevant.dk>" [unknown]
# gpg:                 aka "Klaus Jensen <k.jensen@samsung.com>" [unknown]
# gpg: WARNING: This key is not certified with a trusted signature!
# gpg:          There is no indication that the signature belongs to the owner.
# Primary key fingerprint: DDCA 4D9C 9EF9 31CC 3468  4272 63D5 6FC5 E55D A838
#      Subkey fingerprint: 5228 33AA 75E2 DCE6 A247  66C0 4DE1 AF31 6D4F 0DE9

* remotes/nvme/tags/nvme-fixes-for-6.0-pull-request:
  hw/block/nvme: fix ref counting in nvme_format_ns
  hw/block/nvme: fix resource leak in nvme_dif_rw

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
3 years agohw/block/nvme: fix ref counting in nvme_format_ns
Klaus Jensen [Mon, 22 Mar 2021 06:10:24 +0000 (07:10 +0100)]
hw/block/nvme: fix ref counting in nvme_format_ns

Max noticed that since blk_aio_pwrite_zeroes() may invoke the callback
before returning, the callbacks will never see *count == 0 and thus
never free the count variable or decrement num_formats causing a CQE to
never be posted.

Coverity (CID 1451082) also picked up on the fact that count would not
be free'ed if the namespace was of zero size.

Fix both of these issues by explicitly checking *count and finalize for
the given namespace if --(*count) is zero. Enqueing a CQE if there are
no AIOs outstanding after this case is already handled by nvme_format()
by inspecting *num_formats.

Reported-by: Max Reitz <mreitz@redhat.com>
Reported-by: Coverity (CID 1451082)
Fixes: dc04d25e2f3f ("hw/block/nvme: add support for the format nvm command")
Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
Reviewed-by: Gollu Appalanaidu <anaidu.gollu@samsung.com>
3 years agohw/block/nvme: fix resource leak in nvme_dif_rw
Klaus Jensen [Mon, 22 Mar 2021 05:58:38 +0000 (06:58 +0100)]
hw/block/nvme: fix resource leak in nvme_dif_rw

If nvme_map_dptr() fails, nvme_dif_rw() will leak the bounce context.
Fix this by using the same error handling as everywhere else in the
function.

Reported-by: Coverity (CID 1451080)
Fixes: 146f720c5563 ("hw/block/nvme: end-to-end data protection")
Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
Reviewed-by: Gollu Appalanaidu <anaidu.gollu@samsung.com>
3 years agoqsd: Document FUSE exports
Max Reitz [Wed, 17 Feb 2021 11:58:44 +0000 (12:58 +0100)]
qsd: Document FUSE exports

Implementing FUSE exports required no changes to the storage daemon, so
we forgot to document them there.  Considering that both NBD and
vhost-user-blk exports are documented in its man page (and NBD exports
in its --help text), we should probably do the same for FUSE.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Message-Id: <20210217115844.62661-1-mreitz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
3 years agoblock/mirror: Fix mirror_top's permissions
Max Reitz [Thu, 11 Feb 2021 17:22:41 +0000 (18:22 +0100)]
block/mirror: Fix mirror_top's permissions

mirror_top currently shares all permissions, and takes only the WRITE
permission (if some parent has taken that permission, too).

That is wrong, though; mirror_top is a filter, so it should take
permissions like any other filter does.  For example, if the parent
needs CONSISTENT_READ, we need to take that, too, and if it cannot share
the WRITE permission, we cannot share it either.

The exception is when mirror_top is used for active commit, where we
cannot take CONSISTENT_READ (because it is deliberately unshared above
the base node) and where we must share WRITE (so that it is shared for
all images in the backing chain, so the mirror job can take it for the
target BB).

Signed-off-by: Max Reitz <mreitz@redhat.com>
Message-Id: <20210211172242.146671-2-mreitz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
3 years agoiotests/046: Filter request length
Max Reitz [Fri, 18 Sep 2020 15:33:23 +0000 (17:33 +0200)]
iotests/046: Filter request length

For its concurrent requests, 046 has always filtered the offset,
probably because concurrent requests may settle in any order.  However,
it did not filter the request length, and so if requests with different
lengths settle in an unexpected order (notably the longer request before
the shorter request), the test fails (for no good reason).

Filter the length, too.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Message-Id: <20200918153323.108932-1-mreitz@redhat.com>

3 years agoqcow2: use external virtual timers
Pavel Dovgalyuk [Mon, 29 Mar 2021 08:06:03 +0000 (11:06 +0300)]
qcow2: use external virtual timers

Regular virtual timers are used to emulate timings
related to vCPU and peripheral states. QCOW2 uses timers
to clean the cache. These timers should have external
flag. In the opposite case they affect the execution
and it can't be recorded and replayed.
This patch adds external flag to the timer for qcow2
cache clean.

Signed-off-by: Pavel Dovgalyuk <Pavel.Dovgalyuk@ispras.ru>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <161700516327.1141158.8366564693714562536.stgit@pasha-ThinkPad-X280>
Signed-off-by: Max Reitz <mreitz@redhat.com>
3 years agoiotests/116: Fix reference output
Max Reitz [Fri, 26 Mar 2021 14:14:19 +0000 (15:14 +0100)]
iotests/116: Fix reference output

15ce94a68ca ("block/qed: bdrv_qed_do_open: deal with errp") has improved
the qed driver's error reporting, though sadly did not add a test for
it.
The good news are: There already is such a test, namely 116.
The bad news are: Its reference output was not adjusted, and so now it
fails.

Let's fix the reference output, which has the nice side effect of
demonstrating 15ce94a68ca's improvements.

Fixes: 15ce94a68ca6730466c565c3d29971aab3087bf1
       ("block/qed: bdrv_qed_do_open: deal with errp")
Signed-off-by: Max Reitz <mreitz@redhat.com>
Message-Id: <20210326141419.156831-1-mreitz@redhat.com>

3 years agoiotests: fix 051.out expected output after error text touchups
Connor Kuehl [Thu, 18 Mar 2021 20:09:49 +0000 (15:09 -0500)]
iotests: fix 051.out expected output after error text touchups

A patch was recently applied that touched up some error messages that
pertained to key names like 'node-name'. The trouble is it only updated
tests/qemu-iotests/051.pc.out and not tests/qemu-iotests/051.out as
well.

Do that now.

Fixes: 785ec4b1b9 ("block: Clarify error messages pertaining to
'node-name'")
Signed-off-by: Connor Kuehl <ckuehl@redhat.com>
Message-Id: <20210318200949.1387703-2-ckuehl@redhat.com>
Tested-by: Christian Borntraeger <borntraeger@de.ibm.com>
Reviewed-by: John Snow <jsnow@redhat.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
3 years agoiotests: Fix typo in iotest 051
Tao Xu [Wed, 24 Mar 2021 08:43:21 +0000 (16:43 +0800)]
iotests: Fix typo in iotest 051

There is an typo in iotest 051, correct it.

Signed-off-by: Tao Xu <tao3.xu@intel.com>
Message-Id: <20210324084321.90952-1-tao3.xu@intel.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
3 years agoMerge remote-tracking branch 'remotes/vivier2/tags/linux-user-for-6.0-pull-request...
Peter Maydell [Sun, 28 Mar 2021 18:49:57 +0000 (19:49 +0100)]
Merge remote-tracking branch 'remotes/vivier2/tags/linux-user-for-6.0-pull-request' into staging

linux-user pull request 20210328

- Fix recvfrom with NULL msg
- Fix sigreturn address on s390x

# gpg: Signature made Sun 28 Mar 2021 17:05:45 BST
# gpg:                using RSA key CD2F75DDC8E3A4DC2E4F5173F30C38BD3F2FBE3C
# gpg:                issuer "laurent@vivier.eu"
# gpg: Good signature from "Laurent Vivier <lvivier@redhat.com>" [full]
# gpg:                 aka "Laurent Vivier <laurent@vivier.eu>" [full]
# gpg:                 aka "Laurent Vivier (Red Hat) <lvivier@redhat.com>" [full]
# Primary key fingerprint: CD2F 75DD C8E3 A4DC 2E4F  5173 F30C 38BD 3F2F BE3C

* remotes/vivier2/tags/linux-user-for-6.0-pull-request:
  linux-user: allow NULL msg in recvfrom
  linux-user/s390x: Use the guest pointer for the sigreturn stub

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
3 years agolinux-user: allow NULL msg in recvfrom
Zach Reizner [Sat, 27 Mar 2021 02:11:16 +0000 (22:11 -0400)]
linux-user: allow NULL msg in recvfrom

The kernel allows a NULL msg in recvfrom so that he size of the next
message may be queried before allocating a correctly sized buffer. This
change allows the syscall translator to pass along the NULL msg pointer
instead of returning early with EFAULT.

Signed-off-by: Zach Reizner <zachr@google.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <CAFNex=DvFCq=AQf+=19fTfw-T8eZZT=3NnFFm2JMFvVr5QgQyA@mail.gmail.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
3 years agoMerge remote-tracking branch 'remotes/kraxel/tags/fixes-20210326-pull-request' into...
Peter Maydell [Fri, 26 Mar 2021 12:58:58 +0000 (12:58 +0000)]
Merge remote-tracking branch 'remotes/kraxel/tags/fixes-20210326-pull-request' into staging

fixes for usb, virtio-gpu and vhost-gpu

# gpg: Signature made Fri 26 Mar 2021 12:49:14 GMT
# 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/fixes-20210326-pull-request:
  hw/usb/hcd-ehci: Fix crash when showing help of EHCI devices
  s390x: modularize virtio-gpu-ccw
  s390x: add have_virtio_ccw
  s390x: move S390_ADAPTER_SUPPRESSIBLE
  hw/usb/hcd-ehci-sysbus: Free USBPacket on instance finalize()
  vhost-user-gpu: fix cursor move/update
  vhost-user-gpu: fix vugbm_device_init fallback
  vhost-user-gpu: glFlush before notifying clients
  usb: Remove "-usbdevice ccid"

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
3 years agohw/usb/hcd-ehci: Fix crash when showing help of EHCI devices
Thomas Huth [Fri, 26 Mar 2021 09:51:55 +0000 (10:51 +0100)]
hw/usb/hcd-ehci: Fix crash when showing help of EHCI devices

QEMU crashes with certain targets when trying to show the help
output of EHCI devices:

$ ./qemu-system-aarch64 -device ich9-usb-ehci1,help
qemu-system-aarch64: ../../devel/qemu/softmmu/physmem.c:1154: phys_section_add:
 Assertion `map->sections_nb < TARGET_PAGE_SIZE' failed.
Aborted (core dumped)

This happens because the device is doing things at "instance_init" time
that should be done at "realize" time instead. So move the related code
to the realize() function instead. (NB: This now also matches the
memory_region_del_subregion() calls which are done in usb_ehci_unrealize(),
and not during finalize()).

Suggested-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Thomas Huth <thuth@redhat.com>
Message-Id: <20210326095155.1994604-1-thuth@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
3 years agos390x: modularize virtio-gpu-ccw
Gerd Hoffmann [Wed, 17 Mar 2021 09:56:22 +0000 (10:56 +0100)]
s390x: modularize virtio-gpu-ccw

Since the virtio-gpu-ccw device depends on the hw-display-virtio-gpu
module, which provides the type virtio-gpu-device, packaging the
hw-display-virtio-gpu module as a separate package that may or may not
be installed along with the qemu package leads to problems. Namely if
the hw-display-virtio-gpu is absent, qemu continues to advertise
virtio-gpu-ccw, but it aborts not only when one attempts using
virtio-gpu-ccw, but also when libvirtd's capability probing tries
to instantiate the type to introspect it.

Let us thus introduce a module named hw-s390x-virtio-gpu-ccw that
is going to provide the virtio-gpu-ccw device. The hw-s390x prefix
was chosen because it is not a portable device.

With virtio-gpu-ccw built as a module, the correct way to package a
modularized qemu is to require that hw-display-virtio-gpu must be
installed whenever the module hw-s390x-virtio-gpu-ccw.

Signed-off-by: Halil Pasic <pasic@linux.ibm.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Halil Pasic <pasic@linux.ibm.com>
Tested-by: Halil Pasic <pasic@linux.ibm.com>
Message-Id: <20210317095622.2839895-4-kraxel@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
3 years agos390x: add have_virtio_ccw
Gerd Hoffmann [Wed, 17 Mar 2021 09:56:21 +0000 (10:56 +0100)]
s390x: add have_virtio_ccw

Introduce a symbol which can be used to prevent ccw modules
being loaded into system emulators without ccw support.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Halil Pasic <pasic@linux.ibm.com>
Tested-by: Halil Pasic <pasic@linux.ibm.com>
Message-Id: <20210317095622.2839895-3-kraxel@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
3 years agos390x: move S390_ADAPTER_SUPPRESSIBLE
Gerd Hoffmann [Wed, 17 Mar 2021 09:56:20 +0000 (10:56 +0100)]
s390x: move S390_ADAPTER_SUPPRESSIBLE

The definition S390_ADAPTER_SUPPRESSIBLE was moved to "cpu.h", per
suggestion of Thomas Huth. From interface design perspective, IMHO, not
a good thing as it belongs to the public interface of
css_register_io_adapters(). We did this because CONFIG_KVM requeires
NEED_CPU_H and Thomas, and other commenters did not like the
consequences of that.

Moving the interrupt related declarations to s390_flic.h was suggested
by Cornelia Huck.

Signed-off-by: Halil Pasic <pasic@linux.ibm.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Halil Pasic <pasic@linux.ibm.com>
Tested-by: Halil Pasic <pasic@linux.ibm.com>
Message-Id: <20210317095622.2839895-2-kraxel@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
3 years agohw/usb/hcd-ehci-sysbus: Free USBPacket on instance finalize()
Philippe Mathieu-Daudé [Tue, 23 Mar 2021 18:37:01 +0000 (19:37 +0100)]
hw/usb/hcd-ehci-sysbus: Free USBPacket on instance finalize()

When building with --enable-sanitizers we get:

  Direct leak of 32 byte(s) in 2 object(s) allocated from:
      #0 0x5618479ec7cf in malloc (qemu-system-aarch64+0x233b7cf)
      #1 0x7f675745f958 in g_malloc (/lib64/libglib-2.0.so.0+0x58958)
      #2 0x561847f02ca2 in usb_packet_init hw/usb/core.c:531:5
      #3 0x561848df4df4 in usb_ehci_init hw/usb/hcd-ehci.c:2575:5
      #4 0x561847c119ac in ehci_sysbus_init hw/usb/hcd-ehci-sysbus.c:73:5
      #5 0x56184a5bdab8 in object_init_with_type qom/object.c:375:9
      #6 0x56184a5bd955 in object_init_with_type qom/object.c:371:9
      #7 0x56184a5a2bda in object_initialize_with_type qom/object.c:517:5
      #8 0x56184a5a24d5 in object_initialize qom/object.c:536:5
      #9 0x56184a5a2f6c in object_initialize_child_with_propsv qom/object.c:566:5
      #10 0x56184a5a2e60 in object_initialize_child_with_props qom/object.c:549:10
      #11 0x56184a5a3a1e in object_initialize_child_internal qom/object.c:603:5
      #12 0x561849542d18 in npcm7xx_init hw/arm/npcm7xx.c:427:5

Similarly to commit d710e1e7bd3 ("usb: ehci: fix memory leak in
ehci"), fix by calling usb_ehci_finalize() to free the USBPacket.

Fixes: 7341ea075c0
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Message-Id: <20210323183701.281152-1-f4bug@amsat.org>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
3 years agovhost-user-gpu: fix cursor move/update
Marc-André Lureau [Fri, 12 Mar 2021 10:00:45 +0000 (14:00 +0400)]
vhost-user-gpu: fix cursor move/update

"move" is incorrectly initialized.

Fix it by using a switch statement and also treating unknown commands
with a fallback.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20210312100108.2706195-5-marcandre.lureau@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
3 years agovhost-user-gpu: fix vugbm_device_init fallback
Marc-André Lureau [Fri, 12 Mar 2021 10:00:44 +0000 (14:00 +0400)]
vhost-user-gpu: fix vugbm_device_init fallback

vugbm implements GBM device wrapping, udmabuf and memory fallback.
However, the fallback/detection logic is flawed, as if "/dev/udmabuf"
failed to be opened, it will not initialize vugbm and crash later.

Rework the vugbm_device_init() logic to initialize correctly in all
cases.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20210312100108.2706195-4-marcandre.lureau@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
3 years agovhost-user-gpu: glFlush before notifying clients
Marc-André Lureau [Fri, 12 Mar 2021 10:00:43 +0000 (14:00 +0400)]
vhost-user-gpu: glFlush before notifying clients

For similar reasons as commit 3af1671852 ("spice: flush on GL update
before notifying client"), vhost-user-gpu must ensure the GL state is
flushed before sharing its rendering result.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20210312100108.2706195-3-marcandre.lureau@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
3 years agousb: Remove "-usbdevice ccid"
Thomas Huth [Thu, 11 Mar 2021 09:28:29 +0000 (10:28 +0100)]
usb: Remove "-usbdevice ccid"

"-usbdevice ccid" was not documented and -usbdevice itself was marked
as deprecated before QEMU v6.0. And searching for "-usbdevice ccid"
in the internet does not show any useful results, so likely nobody
was using the ccid device via the -usbdevice option. Remove it now.

Signed-off-by: Thomas Huth <thuth@redhat.com>
Message-Id: <20210311092829.1479051-1-thuth@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
3 years agolinux-user/s390x: Use the guest pointer for the sigreturn stub
Andreas Krebbel [Wed, 24 Mar 2021 18:51:28 +0000 (19:51 +0100)]
linux-user/s390x: Use the guest pointer for the sigreturn stub

When setting up the pointer for the sigreturn stub in the return
address register (r14) we currently use the host frame address instead
of the guest frame address.

Note: This only caused problems if Qemu has been built with
--disable-pie (as it is in distros nowadays). Otherwise guest_base
defaults to 0 hiding the actual problem.

Signed-off-by: Andreas Krebbel <krebbel@linux.ibm.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20210324185128.63971-1-krebbel@linux.ibm.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
3 years agoMerge remote-tracking branch 'remotes/stefanha-gitlab/tags/block-pull-request' into...
Peter Maydell [Thu, 25 Mar 2021 16:34:10 +0000 (16:34 +0000)]
Merge remote-tracking branch 'remotes/stefanha-gitlab/tags/block-pull-request' into staging

Pull request

This dirty bitmap fix solves a crash that can be triggered in the destination
QEMU process during live migration.

# gpg: Signature made Wed 24 Mar 2021 14:51:31 GMT
# gpg:                using RSA key 8695A8BFD3F97CDAAC35775A9CA4ABB381AB73C8
# gpg: Good signature from "Stefan Hajnoczi <stefanha@redhat.com>" [full]
# gpg:                 aka "Stefan Hajnoczi <stefanha@gmail.com>" [full]
# Primary key fingerprint: 8695 A8BF D3F9 7CDA AC35  775A 9CA4 ABB3 81AB 73C8

* remotes/stefanha-gitlab/tags/block-pull-request:
  migrate-bitmaps-postcopy-test: check that we can't remove in-flight bitmaps
  migration/block-dirty-bitmap: make incoming disabled bitmaps busy

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
3 years agoUpdate version for v6.0.0-rc0 release
Peter Maydell [Wed, 24 Mar 2021 19:50:49 +0000 (19:50 +0000)]
Update version for v6.0.0-rc0 release

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
3 years agoMerge remote-tracking branch 'remotes/stsquad/tags/pull-6.0-rc0-fixed-240321-1' into...
Peter Maydell [Wed, 24 Mar 2021 14:33:33 +0000 (14:33 +0000)]
Merge remote-tracking branch 'remotes/stsquad/tags/pull-6.0-rc0-fixed-240321-1' into staging

Various fixes for 6.0:

  - include kernel-doc API reference for plugins
  - fix semihosting SYS_HEAPINFO
  - various tweaks to improve CI runtime
  - more stroz fixes
  - fix iotest CI regressions

# gpg: Signature made Wed 24 Mar 2021 14:28:24 GMT
# gpg:                using RSA key 6685AE99E75167BCAFC8DF35FBD0DB095A9E2A44
# gpg: Good signature from "Alex Bennée (Master Work Key) <alex.bennee@linaro.org>" [full]
# Primary key fingerprint: 6685 AE99 E751 67BC AFC8  DF35 FBD0 DB09 5A9E 2A44

* remotes/stsquad/tags/pull-6.0-rc0-fixed-240321-1: (22 commits)
  gitlab: default to not building the documentation
  iotests: iothreads need ioeventfd
  iotests: test m68k with the virt machine
  iotests: Revert "iotests: use -ccw on s390x for 040, 139, and 182"
  blockdev: with -drive if=virtio, use generic virtio-blk
  m68k: add the virtio devices aliases
  qdev: define list of archs with virtio-pci or virtio-ccw
  gitlab: extend timeouts for CFI builds
  utils: Work around mingw strto*l bug with 0x
  utils: Tighter tests for qemu_strtosz
  cirrus.yml: Update the FreeBSD task to version 12.2
  configure: Don't use the __atomic_*_16 functions for testing 128-bit support
  gitlab-ci.yml: Merge the trace-backend testing into other jobs
  tests/tcg: add HeapInfo checking to semihosting test
  linux-user/riscv: initialise the TaskState heap/stack info
  semihosting/arm-compat-semi: don't use SET_ARG to report SYS_HEAPINFO
  semihosting/arm-compat-semi: unify GET/SET_ARG helpers
  semihosting: move semihosting tests to multiarch
  tools/virtiofsd: include --socket-group in help
  docs/devel: expand style section of memory management
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
3 years agogitlab: default to not building the documentation
Alex Bennée [Tue, 23 Mar 2021 16:53:08 +0000 (16:53 +0000)]
gitlab: default to not building the documentation

In d0f26e68a0 ("gitlab: force enable docs build in Fedora, Ubuntu,
Debian") we made sure we can build the documents on more than one
system. However we don't want to build documents all the time as it's
a waste of cycles (and energy). So lets reduce the total amount of
documentation we build while still keeping coverage of at least one
build on each supported target.

Fixes: a8a3abe0b3 ("gitlab: move docs and tools build across from Travis")
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Willian Rampazzo <willianr@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Message-Id: <20210323165308.15244-23-alex.bennee@linaro.org>

3 years agoiotests: iothreads need ioeventfd
Laurent Vivier [Tue, 23 Mar 2021 16:53:07 +0000 (16:53 +0000)]
iotests: iothreads need ioeventfd

And ioeventfd are only available with virtio-scsi-pci or virtio-scsi-ccw,
use the alias but add a rule to require virtio-scsi-pci or virtio-scsi-ccw
for the tests that use iothreads.

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Message-Id: <20210319202335.2397060-7-laurent@vivier.eu>
Message-Id: <20210323165308.15244-22-alex.bennee@linaro.org>

3 years agoiotests: test m68k with the virt machine
Laurent Vivier [Tue, 23 Mar 2021 16:53:06 +0000 (16:53 +0000)]
iotests: test m68k with the virt machine

This allows to cover the virtio tests with a 32bit big-endian
virtio-mmio machine.

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Message-Id: <20210319202335.2397060-6-laurent@vivier.eu>
Message-Id: <20210323165308.15244-21-alex.bennee@linaro.org>

3 years agoiotests: Revert "iotests: use -ccw on s390x for 040, 139, and 182"
Laurent Vivier [Tue, 23 Mar 2021 16:53:05 +0000 (16:53 +0000)]
iotests: Revert "iotests: use -ccw on s390x for 040, 139, and 182"

Commit f1d5516ab583 introduces a test in some iotests to check if
the machine is a s390-ccw-virtio and to select virtio-*-ccw rather
than virtio-*-pci.

We don't need that because QEMU already provides aliases to use the correct
virtio interface according to the machine type.

This patch removes all virtio-*-pci and virtio-*-ccw to use virtio-*
instead and remove get_virtio_scsi_device().
This also enables virtio-mmio devices (virtio-*-device)

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Message-Id: <20210319202335.2397060-5-laurent@vivier.eu>
Message-Id: <20210323165308.15244-20-alex.bennee@linaro.org>

3 years agoblockdev: with -drive if=virtio, use generic virtio-blk
Laurent Vivier [Tue, 23 Mar 2021 16:53:04 +0000 (16:53 +0000)]
blockdev: with -drive if=virtio, use generic virtio-blk

Rather than checking if the machine is an s390x to use virtio-blk-ccw
instead of virtio-blk-pci, use the alias virtio-blk that is set to
the expected target.

This also enables the use of virtio-blk-device for targets without
PCI or CCW.

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Acked-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20210319202335.2397060-4-laurent@vivier.eu>
Message-Id: <20210323165308.15244-19-alex.bennee@linaro.org>

3 years agom68k: add the virtio devices aliases
Laurent Vivier [Tue, 23 Mar 2021 16:53:03 +0000 (16:53 +0000)]
m68k: add the virtio devices aliases

Similarly to 5f629d943cb0 ("s390x: fix s390 virtio aliases"),
define the virtio aliases.

This allows to start machines with virtio devices without
knowledge of the implementation type.

For instance, we can use "-device virtio-scsi" on
m68k, s390x or PC, and the device will be respectively
"virtio-scsi-device", "virtio-scsi-ccw" or "virtio-scsi-pci".

This already exists for s390x and -ccw interfaces, add them
for m68k and MMIO (-device) interfaces.

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Message-Id: <20210319202335.2397060-3-laurent@vivier.eu>
Message-Id: <20210323165308.15244-18-alex.bennee@linaro.org>

3 years agoqdev: define list of archs with virtio-pci or virtio-ccw
Laurent Vivier [Tue, 23 Mar 2021 16:53:02 +0000 (16:53 +0000)]
qdev: define list of archs with virtio-pci or virtio-ccw

This is used to define virtio-*-pci and virtio-*-ccw aliases
rather than substracting the CCW architecture from all the others.

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Message-Id: <20210319202335.2397060-2-laurent@vivier.eu>
Message-Id: <20210323165308.15244-17-alex.bennee@linaro.org>

3 years agogitlab: extend timeouts for CFI builds
Alex Bennée [Tue, 23 Mar 2021 16:53:01 +0000 (16:53 +0000)]
gitlab: extend timeouts for CFI builds

These builds are running very close to the default build limit and as
they are already pared down the only other option is to extend the
timeout a little to give some breathing room.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Willian Rampazzo <willianr@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-Id: <20210323165308.15244-16-alex.bennee@linaro.org>

3 years agoutils: Work around mingw strto*l bug with 0x
Eric Blake [Tue, 23 Mar 2021 16:53:00 +0000 (16:53 +0000)]
utils: Work around mingw strto*l bug with 0x

Mingw recognizes that "0x" has value 0 without setting errno, but
fails to advance endptr to the trailing garbage 'x'.  This in turn
showed up in our recent testsuite additions for qemu_strtosz (commit
1657ba44b4 utils: Enhance testsuite for do_strtosz()); adjust our
remaining tests to show that we now work around this windows bug.

This patch intentionally fails check-syntax for use of strtol.

Signed-off-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Message-Id: <20210317143325.2165821-3-eblake@redhat.com>
Message-Id: <20210323165308.15244-15-alex.bennee@linaro.org>

3 years agoutils: Tighter tests for qemu_strtosz
Eric Blake [Tue, 23 Mar 2021 16:52:59 +0000 (16:52 +0000)]
utils: Tighter tests for qemu_strtosz

Our tests were not validating the return value in all cases, nor was
it guaranteeing our documented claim that 'res' is unchanged on error.
For that matter, it wasn't as thorough as the existing tests for
qemu_strtoi() and friends for proving that endptr and res are sanely
set.  Enhancing the test found one case where we violated our
documentation: namely, when failing with EINVAL when endptr is NULL,
we shouldn't modify res.

Signed-off-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Message-Id: <20210317143325.2165821-2-eblake@redhat.com>
Message-Id: <20210323165308.15244-14-alex.bennee@linaro.org>

3 years agocirrus.yml: Update the FreeBSD task to version 12.2
Thomas Huth [Tue, 23 Mar 2021 16:52:58 +0000 (16:52 +0000)]
cirrus.yml: Update the FreeBSD task to version 12.2

FreeBSD version 12.1 is out of service now, and the task in the
Cirrus-CI is failing. Update to 12.2 to get it working again.
Unfortunately, there is a bug in libtasn1 that triggers with the
new version of Clang that is used there (see this thread for details:
https://lists.gnu.org/archive/html/qemu-devel/2021-02/msg00739.html ),
so we have to disable gnutls for now to make it work again. We can
enable it later again once libtasn1 has been fixed in FreeBSD.

Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20210319101402.48871-1-thuth@redhat.com>
Message-Id: <20210323165308.15244-13-alex.bennee@linaro.org>

3 years agoconfigure: Don't use the __atomic_*_16 functions for testing 128-bit support
Thomas Huth [Tue, 23 Mar 2021 16:52:57 +0000 (16:52 +0000)]
configure: Don't use the __atomic_*_16 functions for testing 128-bit support

The test for 128-bit atomics is causing trouble with FreeBSD 12.2 and
--enable-werror:

 cc -Werror -fPIE -DPIE -std=gnu99 -Wall -m64 -mcx16 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wundef -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -fno-common -fwrapv -Wold-style-definition -Wtype-limits -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wempty-body -Wnested-externs -Wendif-labels -Wexpansion-to-defined -Wno-initializer-overrides -Wno-missing-include-dirs -Wno-shift-negative-value -Wno-string-plus-int -Wno-typedef-redefinition -Wno-tautological-type-limit-compare -fstack-protector-strong -o config-temp/qemu-conf.exe config-temp/qemu-conf.c -pie -Wl,-z,relro -Wl,-z,now -m64 -fstack-protector-strong
 config-temp/qemu-conf.c:4:7: error: implicit declaration of function '__atomic_load_16' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
   y = __atomic_load_16(&x, 0);
       ^
 config-temp/qemu-conf.c:5:3: error: implicit declaration of function '__atomic_store_16' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
   __atomic_store_16(&x, y, 0);
   ^
 config-temp/qemu-conf.c:5:3: note: did you mean '__atomic_load_16'?
 config-temp/qemu-conf.c:4:7: note: '__atomic_load_16' declared here
   y = __atomic_load_16(&x, 0);
       ^
 config-temp/qemu-conf.c:6:3: error: implicit declaration of function '__atomic_compare_exchange_16' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
   __atomic_compare_exchange_16(&x, &y, x, 0, 0, 0);
   ^
 3 errors generated.

Looking for they way we are using atomic functions in QEMU, we are not
using these functions with the _16 suffix anyway. Switch to the same
functions that we use in the include/qemu/atomic.h header.

Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20210317110512.583747-2-thuth@redhat.com>
Message-Id: <20210323165308.15244-12-alex.bennee@linaro.org>

3 years agogitlab-ci.yml: Merge the trace-backend testing into other jobs
Thomas Huth [Tue, 23 Mar 2021 16:52:56 +0000 (16:52 +0000)]
gitlab-ci.yml: Merge the trace-backend testing into other jobs

Our gitlab-ci got quite slow in the past weeks, due to the immense amount
of jobs that we have, so we should try to reduce the number of jobs.
There is no real good reason for having separate jobs just to test the
trace backends, we can do this just fine in other jobs, too.

Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Wainer dos Santos Moschetta <wainersm@redhat.com>
Reviewed-by: Willian Rampazzo <willianr@redhat.com>
Message-Id: <20210319095726.45965-1-thuth@redhat.com>
Message-Id: <20210323165308.15244-11-alex.bennee@linaro.org>

3 years agotests/tcg: add HeapInfo checking to semihosting test
Alex Bennée [Tue, 23 Mar 2021 16:52:55 +0000 (16:52 +0000)]
tests/tcg: add HeapInfo checking to semihosting test

Query the SYS_HEAPINFO semicall and do some basic verification of the
information via libc calls.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Message-Id: <20210323165308.15244-10-alex.bennee@linaro.org>

3 years agolinux-user/riscv: initialise the TaskState heap/stack info
Alex Bennée [Tue, 23 Mar 2021 16:52:54 +0000 (16:52 +0000)]
linux-user/riscv: initialise the TaskState heap/stack info

Arguably the target_cpu_copy_regs function for each architecture is
misnamed as a number of the architectures also take the opportunity to
fill out the TaskState structure. This could arguably be factored out
into common code but that would require a wider audit of the
architectures. For now just replicate for riscv so we can correctly
report semihosting information for SYS_HEAPINFO.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Acked-by: Alistair Francis <alistair.francis@wdc.com>
Message-Id: <20210323165308.15244-9-alex.bennee@linaro.org>

3 years agosemihosting/arm-compat-semi: don't use SET_ARG to report SYS_HEAPINFO
Alex Bennée [Tue, 23 Mar 2021 16:52:53 +0000 (16:52 +0000)]
semihosting/arm-compat-semi: don't use SET_ARG to report SYS_HEAPINFO

As per the spec:

  the PARAMETER REGISTER contains the address of a pointer to a
  four-field data block.

So we need to follow arg0 and place the results of SYS_HEAPINFO there.

Fixes: 3c37cfe0b1 ("semihosting: Change internal common-semi interfaces to use CPUState *")
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Cc: Bug 1915925 <1915925@bugs.launchpad.net>
Cc: Keith Packard <keithp@keithp.com>
Bug: https://bugs.launchpad.net/bugs/1915925
Message-Id: <20210323165308.15244-8-alex.bennee@linaro.org>

3 years agosemihosting/arm-compat-semi: unify GET/SET_ARG helpers
Alex Bennée [Tue, 23 Mar 2021 16:52:52 +0000 (16:52 +0000)]
semihosting/arm-compat-semi: unify GET/SET_ARG helpers

>>>From the semihosting point of view what we want to know is the current
mode of the processor. Unify this into a single helper and allow us to
use the same GET/SET_ARG helpers for the rest of the code. Having the
helper will also be useful later.

Note: we aren't currently testing riscv32 due to missing toolchain for
check-tcg tests.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Keith Packard <keithp@keithp.com>
Message-Id: <20210323165308.15244-7-alex.bennee@linaro.org>

3 years agosemihosting: move semihosting tests to multiarch
Alex Bennée [Tue, 23 Mar 2021 16:52:51 +0000 (16:52 +0000)]
semihosting: move semihosting tests to multiarch

It may be arm-compat-semihosting but more than one architecture uses
it so lets move the tests into the multiarch area. We gate it on the
feature and split the semicall.h header between the arches.

Also clean-up a bit of the Makefile messing about to one common set of
runners.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20210323165308.15244-6-alex.bennee@linaro.org>

3 years agotools/virtiofsd: include --socket-group in help
Alex Bennée [Tue, 23 Mar 2021 16:52:50 +0000 (16:52 +0000)]
tools/virtiofsd: include --socket-group in help

I confused myself wandering if this had been merged by looking at the
help output. It seems fuse_opt doesn't automagically add to help
output so lets do it now.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Connor Kuehl <ckuehl@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Updates: f6698f2b03 ("tools/virtiofsd: add support for --socket-group")
Message-Id: <20210323165308.15244-5-alex.bennee@linaro.org>

3 years agodocs/devel: expand style section of memory management
Alex Bennée [Tue, 23 Mar 2021 16:52:49 +0000 (16:52 +0000)]
docs/devel: expand style section of memory management

This aims to provide a bit more guidance for those who take on one of
our "clean up memory allocation" bite-sized tasks.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20210323165308.15244-4-alex.bennee@linaro.org>

3 years agodocs/devel: include the plugin API information from the headers
Alex Bennée [Tue, 23 Mar 2021 16:52:48 +0000 (16:52 +0000)]
docs/devel: include the plugin API information from the headers

We have kerneldoc tags for the headers so we might as well extract
them into our developer documentation whilst we are at it.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Aaron Lindsay <aaron@os.amperecomputing.com>
Message-Id: <20210323165308.15244-3-alex.bennee@linaro.org>

3 years agoscripts/kernel-doc: strip QEMU_ from function definitions
Alex Bennée [Tue, 23 Mar 2021 16:52:47 +0000 (16:52 +0000)]
scripts/kernel-doc: strip QEMU_ from function definitions

Some packaged versions of Sphinx (fedora33/alpine so far) have issues
with the annotated C code that kernel-doc spits out. Without knowing
about things like QEMU_PLUGIN_EXPORT it chokes trying to understand
the code. Evidently this is a problem for the kernel as well as the
long stream of regex substitutions we add to in this patch can attest.

Fortunately we have a fairly common format for all our compiler
shenanigans as applied to functions so lets just filter them all out.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20210323165308.15244-2-alex.bennee@linaro.org>

3 years agomigrate-bitmaps-postcopy-test: check that we can't remove in-flight bitmaps
Vladimir Sementsov-Ogievskiy [Mon, 22 Mar 2021 09:49:06 +0000 (12:49 +0300)]
migrate-bitmaps-postcopy-test: check that we can't remove in-flight bitmaps

Check that we can't remove bitmaps being migrated on destination vm.
The new check proves that previous commit helps.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-Id: <20210322094906.5079-3-vsementsov@virtuozzo.com>

3 years agomigration/block-dirty-bitmap: make incoming disabled bitmaps busy
Vladimir Sementsov-Ogievskiy [Mon, 22 Mar 2021 09:49:05 +0000 (12:49 +0300)]
migration/block-dirty-bitmap: make incoming disabled bitmaps busy

Incoming enabled bitmaps are busy, because we do
bdrv_dirty_bitmap_create_successor() for them. But disabled bitmaps
being migrated are not marked busy, and user can remove them during the
incoming migration. Then we may crash in cancel_incoming_locked() when
try to remove the bitmap that was already removed by user, like this:

 #0  qemu_mutex_lock_impl (mutex=0x5593d88c50d1, file=0x559680554b20
   "../block/dirty-bitmap.c", line=64) at ../util/qemu-thread-posix.c:77
 #1  bdrv_dirty_bitmaps_lock (bs=0x5593d88c0ee9)
   at ../block/dirty-bitmap.c:64
 #2  bdrv_release_dirty_bitmap (bitmap=0x5596810e9570)
   at ../block/dirty-bitmap.c:362
 #3  cancel_incoming_locked (s=0x559680be8208 <dbm_state+40>)
   at ../migration/block-dirty-bitmap.c:918
 #4  dirty_bitmap_load (f=0x559681d02b10, opaque=0x559680be81e0
   <dbm_state>, version_id=1) at ../migration/block-dirty-bitmap.c:1194
 #5  vmstate_load (f=0x559681d02b10, se=0x559680fb5810)
   at ../migration/savevm.c:908
 #6  qemu_loadvm_section_part_end (f=0x559681d02b10,
   mis=0x559680fb4a30) at ../migration/savevm.c:2473
 #7  qemu_loadvm_state_main (f=0x559681d02b10, mis=0x559680fb4a30)
   at ../migration/savevm.c:2626
 #8  postcopy_ram_listen_thread (opaque=0x0)
   at ../migration/savevm.c:1871
 #9  qemu_thread_start (args=0x5596817ccd10)
   at ../util/qemu-thread-posix.c:521
 #10 start_thread () at /lib64/libpthread.so.0
 #11 clone () at /lib64/libc.so.6

Note bs pointer taken from bitmap: it's definitely bad aligned. That's
because we are in use after free, bitmap is already freed.

So, let's make disabled bitmaps (being migrated) busy during incoming
migration.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-Id: <20210322094906.5079-2-vsementsov@virtuozzo.com>

3 years agoMerge remote-tracking branch 'remotes/rth/tags/pull-tcg-20210323' into staging
Peter Maydell [Wed, 24 Mar 2021 11:22:08 +0000 (11:22 +0000)]
Merge remote-tracking branch 'remotes/rth/tags/pull-tcg-20210323' into staging

Workaround for macos mprotect
Workaround for target_page vs -flto

# gpg: Signature made Wed 24 Mar 2021 01:40:12 GMT
# gpg:                using RSA key 7A481E78868B4DB6A85A05C064DF38E8AF7E215F
# gpg:                issuer "richard.henderson@linaro.org"
# gpg: Good signature from "Richard Henderson <richard.henderson@linaro.org>" [full]
# Primary key fingerprint: 7A48 1E78 868B 4DB6 A85A  05C0 64DF 38E8 AF7E 215F

* remotes/rth/tags/pull-tcg-20210323:
  exec: Build page-vary-common.c with -fno-lto
  exec: Extract 'page-vary.h' header
  exec: Rename exec-vary.c as page-vary.c
  tcg: Workaround macOS 11.2 mprotect bug
  tcg: Do not set guard pages on the rx portion of code_gen_buffer

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
3 years agoexec: Build page-vary-common.c with -fno-lto
Richard Henderson [Mon, 22 Mar 2021 11:24:26 +0000 (12:24 +0100)]
exec: Build page-vary-common.c with -fno-lto

In bbc17caf81f, we used an alias attribute to allow target_page
to be declared const, and yet be initialized late.

This fails when using LTO with several versions of gcc.
The compiler looks through the alias and decides that the const
variable is statically initialized to zero, then propagates that
zero to many uses of the variable.

This can be avoided by compiling one object file with -fno-lto.
In this way, any initializer cannot be seen, and the constant
propagation does not occur.

Since we are certain to have this separate compilation unit, we
can drop the alias attribute as well.  We simply have differing
declarations for target_page in different compilation units.
Drop the use of init_target_page, and drop the configure detection
for CONFIG_ATTRIBUTE_ALIAS.

In order to change the compilation flags for a file with meson,
we must use a static_library.  This runs into specific_ss, where
we would need to create many static_library instances.

Fix this by splitting page-vary.c: the page-vary-common.c part is
compiled once as a static_library, while the page-vary.c part is
left in specific_ss in order to handle the target-specific value
of TARGET_PAGE_BITS_MIN.

Reported-by: Gavin Shan <gshan@redhat.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20210321211534.2101231-1-richard.henderson@linaro.org>
[PMD: Fix typo in subject, split original patch in 3]
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Tested-by: Gavin Shan <gshan@redhat.com>
Message-Id: <20210322112427.4045204-4-f4bug@amsat.org>
[rth: Update MAINTAINERS]
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
3 years agoexec: Extract 'page-vary.h' header
Richard Henderson [Mon, 22 Mar 2021 11:24:25 +0000 (12:24 +0100)]
exec: Extract 'page-vary.h' header

In the next commit we will extract the generic code out of
page-vary.c, only keeping the target specific code. Both
files will use the same TargetPageBits structure, so make
its declaration in a shared header.

As the common header can not use target specific types,
use a uint64_t to hold the page mask value, and add a
cast back to target_long in the TARGET_PAGE_MASK definitions.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-Id: <20210322112427.4045204-3-f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
3 years agoexec: Rename exec-vary.c as page-vary.c
Richard Henderson [Mon, 22 Mar 2021 11:24:24 +0000 (12:24 +0100)]
exec: Rename exec-vary.c as page-vary.c

exec-vary.c is about variable page size handling,
rename it page-vary.c. Currently this file is target
specific (built once for each target), comment this.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-Id: <20210322112427.4045204-2-f4bug@amsat.org>
[rth: Update MAINTAINERS]
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
3 years agotcg: Workaround macOS 11.2 mprotect bug
Richard Henderson [Sat, 20 Mar 2021 16:57:20 +0000 (10:57 -0600)]
tcg: Workaround macOS 11.2 mprotect bug

There's a change in mprotect() behaviour [1] in the latest macOS
on M1 and it's not yet clear if it's going to be fixed by Apple.

As a short-term fix, ignore failures setting up the guard pages.

[1] https://gist.github.com/hikalium/75ae822466ee4da13cbbe486498a191f

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Tested-by: Roman Bolshakov <r.bolshakov@yadro.com>
Reviewed-by: Roman Bolshakov <r.bolshakov@yadro.com>
Buglink: https://bugs.launchpad.net/qemu/+bug/1914849
Message-Id: <20210320165720.1813545-3-richard.henderson@linaro.org>

3 years agotcg: Do not set guard pages on the rx portion of code_gen_buffer
Richard Henderson [Sat, 20 Mar 2021 16:57:19 +0000 (10:57 -0600)]
tcg: Do not set guard pages on the rx portion of code_gen_buffer

The rw portion of the buffer is the only one in which overruns
can be generated.  Allow the rx portion to be more completely
covered by huge pages.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Tested-by: Roman Bolshakov <r.bolshakov@yadro.com>
Reviewed-by: Roman Bolshakov <r.bolshakov@yadro.com>
Message-Id: <20210320165720.1813545-2-richard.henderson@linaro.org>

3 years agoMerge remote-tracking branch 'remotes/kraxel/tags/ui-20210323-pull-request' into...
Peter Maydell [Tue, 23 Mar 2021 23:47:30 +0000 (23:47 +0000)]
Merge remote-tracking branch 'remotes/kraxel/tags/ui-20210323-pull-request' into staging

fixes for 6.0

# gpg: Signature made Tue 23 Mar 2021 15:36:06 GMT
# 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/ui-20210323-pull-request:
  edid: prefer standard timings
  include/ui/console.h: Delete is_surface_bgr()
  qmp: add new qmp display-reload
  vnc: support reload x509 certificates for vnc
  crypto: add reload for QCryptoTLSCredsClass

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
3 years agoMerge remote-tracking branch 'remotes/armbru/tags/pull-qapi-2021-03-23' into staging
Peter Maydell [Tue, 23 Mar 2021 22:28:58 +0000 (22:28 +0000)]
Merge remote-tracking branch 'remotes/armbru/tags/pull-qapi-2021-03-23' into staging

QAPI patches patches for 2021-03-23

# gpg: Signature made Tue 23 Mar 2021 21:37:53 GMT
# gpg:                using RSA key 354BC8B3D7EB2A6B68674E5F3870B400EB918653
# gpg:                issuer "armbru@redhat.com"
# gpg: Good signature from "Markus Armbruster <armbru@redhat.com>" [full]
# gpg:                 aka "Markus Armbruster <armbru@pond.sub.org>" [full]
# Primary key fingerprint: 354B C8B3 D7EB 2A6B 6867  4E5F 3870 B400 EB91 8653

* remotes/armbru/tags/pull-qapi-2021-03-23: (29 commits)
  block: Remove monitor command block_passwd
  qapi: Enforce union and alternate branch naming rules
  qapi: Enforce enum member naming rules
  qapi: Enforce struct member naming rules
  tests/qapi-schema: Switch member name clash test to struct
  qapi: Enforce command naming rules
  qapi: Enforce feature naming rules
  qapi: Prepare for rejecting underscore in command and member names
  tests-qmp-cmds: Drop unused and incorrect qmp_TestIfCmd()
  qapi/pragma: Streamline comments on member-name-exceptions
  qapi: Rename pragma *-whitelist to *-exceptions
  tests/qapi-schema: Rename returns-whitelist to returns-bad-type
  tests/qapi-schema: Rename pragma-*-crap to pragma-value-not-*
  qapi: Factor out QAPISchemaParser._check_pragma_list_of_str()
  tests/qapi-schema: Rename redefined-builtin to redefined-predefined
  qapi: Enforce type naming rules
  qapi: Enforce event naming rules
  qapi: Consistently permit any case in downstream prefixes
  qapi: Move uppercase rejection to check_name_lower()
  qapi: Rework name checking in preparation of stricter checking
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
3 years agoblock: Remove monitor command block_passwd
Markus Armbruster [Tue, 23 Mar 2021 10:19:51 +0000 (11:19 +0100)]
block: Remove monitor command block_passwd

Command block_passwd always fails since

Commit c01c214b69 "block: remove all encryption handling APIs"
(v2.10.0) turned block_passwd into a stub that always fails, and
hardcoded encryption_key_missing to false in query-named-block-nodes
and query-block.

Commit ad1324e044 "block: remove 'encryption_key_missing' flag from
QAPI" just landed.  Complete the cleanup job: remove block_passwd.

Cc: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20210323101951.3686029-1-armbru@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agoqapi: Enforce union and alternate branch naming rules
Markus Armbruster [Tue, 23 Mar 2021 09:40:25 +0000 (10:40 +0100)]
qapi: Enforce union and alternate branch naming rules

Union branch names should use '-', not '_'.  Enforce this.  The only
offenders are in tests/.  Fix them.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20210323094025.3569441-29-armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
[Commit message typo fixed]

3 years agoqapi: Enforce enum member naming rules
Markus Armbruster [Tue, 23 Mar 2021 09:40:24 +0000 (10:40 +0100)]
qapi: Enforce enum member naming rules

Enum members should use '-', not '_'.  Enforce this.  Fix the fixable
offenders (all in tests/), and add the remainder to pragma
member-name-exceptions.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20210323094025.3569441-28-armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
3 years agoqapi: Enforce struct member naming rules
Markus Armbruster [Tue, 23 Mar 2021 09:40:23 +0000 (10:40 +0100)]
qapi: Enforce struct member naming rules

Struct members, including command arguments, event data, and union
inline base members, should use '-', not '_'.  Enforce this.  Fix the
fixable offenders (all in tests/), and add the remainder to pragma
member-name-exceptions.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20210323094025.3569441-27-armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
3 years agotests/qapi-schema: Switch member name clash test to struct
Markus Armbruster [Tue, 23 Mar 2021 09:40:22 +0000 (10:40 +0100)]
tests/qapi-schema: Switch member name clash test to struct

Test args-name-clash covers command parameter name clash.  This
effectively covers struct member name clash as well.  The next commit
will make parameter name clash impossible.  Convert args-name-clash
from testing command to testing a struct, and rename it to
struct-member-name-clash.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20210323094025.3569441-26-armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
[Commit message typo fixed]

3 years agoqapi: Enforce command naming rules
Markus Armbruster [Tue, 23 Mar 2021 09:40:21 +0000 (10:40 +0100)]
qapi: Enforce command naming rules

Command names should be lower-case.  Enforce this.  Fix the fixable
offenders (all in tests/), and add the remainder to pragma
command-name-exceptions.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20210323094025.3569441-25-armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
3 years agoqapi: Enforce feature naming rules
Markus Armbruster [Tue, 23 Mar 2021 09:40:20 +0000 (10:40 +0100)]
qapi: Enforce feature naming rules

Feature names should use '-', not '_'.  Enforce this.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20210323094025.3569441-24-armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
3 years agoqapi: Prepare for rejecting underscore in command and member names
Markus Armbruster [Tue, 23 Mar 2021 09:40:19 +0000 (10:40 +0100)]
qapi: Prepare for rejecting underscore in command and member names

Command names and member names within a type should be all lower case
with words separated by a hyphen.  We also accept underscore.  Rework
check_name_lower() to optionally reject underscores, but don't use
that option, yet.

Update expected test output for the changed error message.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20210323094025.3569441-23-armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
3 years agotests-qmp-cmds: Drop unused and incorrect qmp_TestIfCmd()
Markus Armbruster [Tue, 23 Mar 2021 09:40:18 +0000 (10:40 +0100)]
tests-qmp-cmds: Drop unused and incorrect qmp_TestIfCmd()

Commit 967c885108 "qapi: add 'if' to top-level expressions" added
command TestIfCmd with an 'if' condition.  It also added the
qmp_TestIfCmd() to go with it, guarded by the corresponding #if.
Commit ccadd6bcba "qapi: Add 'if' to implicit struct members" changed
the command, but not the function.  Compiles only because we don't
satisfy the #if.  Instead of fixing the function, simply drop it.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20210323094025.3569441-22-armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
3 years agoqapi/pragma: Streamline comments on member-name-exceptions
Markus Armbruster [Tue, 23 Mar 2021 09:40:17 +0000 (10:40 +0100)]
qapi/pragma: Streamline comments on member-name-exceptions

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20210323094025.3569441-21-armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
3 years agoqapi: Rename pragma *-whitelist to *-exceptions
Markus Armbruster [Tue, 23 Mar 2021 09:40:16 +0000 (10:40 +0100)]
qapi: Rename pragma *-whitelist to *-exceptions

Rename pragma returns-whitelist to command-returns-exceptions, and
name-case-whitelist to member-name-case-exceptions.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20210323094025.3569441-20-armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
3 years agotests/qapi-schema: Rename returns-whitelist to returns-bad-type
Markus Armbruster [Tue, 23 Mar 2021 09:40:15 +0000 (10:40 +0100)]
tests/qapi-schema: Rename returns-whitelist to returns-bad-type

This test covers returning "bad" types.  Pragma returns-whitelist is
just one aspect.  Naming it returns-whitelist is suboptimal.  Rename
to returns-bad-type.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20210323094025.3569441-19-armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
3 years agotests/qapi-schema: Rename pragma-*-crap to pragma-value-not-*
Markus Armbruster [Tue, 23 Mar 2021 09:40:14 +0000 (10:40 +0100)]
tests/qapi-schema: Rename pragma-*-crap to pragma-value-not-*

Rename pragma-doc-required-crap to pragma-not-bool,
pragma-returns-whitelist-crap to pragma-value-not-list, and
pragma-name-case-whitelist-crap to pragma-value-not-list-of-str.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20210323094025.3569441-18-armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
3 years agoqapi: Factor out QAPISchemaParser._check_pragma_list_of_str()
Markus Armbruster [Tue, 23 Mar 2021 09:40:13 +0000 (10:40 +0100)]
qapi: Factor out QAPISchemaParser._check_pragma_list_of_str()

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20210323094025.3569441-17-armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
3 years agotests/qapi-schema: Rename redefined-builtin to redefined-predefined
Markus Armbruster [Tue, 23 Mar 2021 09:40:12 +0000 (10:40 +0100)]
tests/qapi-schema: Rename redefined-builtin to redefined-predefined

The previous commit changed this test to clash with a predefined enum
type, not a built-in type.  Adjust its name.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20210323094025.3569441-16-armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
3 years agoqapi: Enforce type naming rules
Markus Armbruster [Tue, 23 Mar 2021 09:40:11 +0000 (10:40 +0100)]
qapi: Enforce type naming rules

Type names should be CamelCase.  Enforce this.  The only offenders are
in tests/.  Fix them.  Add test type-case to cover the new error.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20210323094025.3569441-15-armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
[Regexp simplified, new test made more robust]

3 years agoqapi: Enforce event naming rules
Markus Armbruster [Tue, 23 Mar 2021 09:40:10 +0000 (10:40 +0100)]
qapi: Enforce event naming rules

Event names should be ALL_CAPS with words separated by underscore.
Enforce this.  The only offenders are in tests/.  Fix them.  Existing
test event-case covers the new error.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20210323094025.3569441-14-armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
3 years agoqapi: Consistently permit any case in downstream prefixes
Markus Armbruster [Tue, 23 Mar 2021 09:40:09 +0000 (10:40 +0100)]
qapi: Consistently permit any case in downstream prefixes

We require lowercase __RFQDN_ downstream prefixes only where we
require the prefixed name to be lowercase.  Don't; permit any case in
__RFQDN_ prefixes anywhere.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20210323094025.3569441-13-armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
3 years agoqapi: Move uppercase rejection to check_name_lower()
Markus Armbruster [Tue, 23 Mar 2021 09:40:08 +0000 (10:40 +0100)]
qapi: Move uppercase rejection to check_name_lower()

check_name_lower() is the only user of check_name_str() using
permit_upper=False.  Move the associated code from check_name_str() to
check_name_lower(), and drop the parameter.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20210323094025.3569441-12-armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
3 years agoqapi: Rework name checking in preparation of stricter checking
Markus Armbruster [Tue, 23 Mar 2021 09:40:07 +0000 (10:40 +0100)]
qapi: Rework name checking in preparation of stricter checking

Naming rules differ for the various kinds of names.  To prepare
enforcing them, define functions to check them: check_name_upper(),
check_name_lower(), and check_name_camel().  For now, these merely
wrap around check_name_str(), but that will change shortly.  Replace
the other uses of check_name_str() by appropriate uses of the
wrappers.  No change in behavior just yet.

check_name_str() now returns the name without downstream and x-
prefix, for use by the wrappers in later patches.  Requires tweaking
regexp @valid_name.  It accepts the same strings as before.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20210323094025.3569441-11-armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
[Commit message improved]

3 years agoqapi: Lift enum-specific code out of check_name_str()
Markus Armbruster [Tue, 23 Mar 2021 09:40:06 +0000 (10:40 +0100)]
qapi: Lift enum-specific code out of check_name_str()

check_name_str() masks leading digits when passed enum_member=True.
Only check_enum() does.  Lift the masking into check_enum().

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20210323094025.3569441-10-armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
3 years agoqapi: Permit flat union members for any tag value
Markus Armbruster [Tue, 23 Mar 2021 09:40:05 +0000 (10:40 +0100)]
qapi: Permit flat union members for any tag value

Flat union branch names match the tag enum's member names.  Omitted
branches default to "no members for this tag value".

Branch names starting with a digit get rejected like "'data' member
'0' has an invalid name".  However, omitting the branch works.

This is because flat union tag values get checked twice: as enum
member name, and as union branch name.  The former accepts leading
digits, the latter doesn't.

Branches whose names start with a digit therefore cannot have members.
Feels wrong.  Get rid of the restriction by skipping the latter check.

This can expose c_name() to input it can't handle: a name starting
with a digit.  Improve it to return a valid C identifier for any
input.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20210323094025.3569441-9-armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
[Commit message rewritten]

3 years agoqapi: Fix to reject optional members with reserved names
Markus Armbruster [Tue, 23 Mar 2021 09:40:04 +0000 (10:40 +0100)]
qapi: Fix to reject optional members with reserved names

check_type() fails to reject optional members with reserved names,
because it neglects to strip off the leading '*'.  Fix that.

The stripping in check_name_str() is now useless.  Drop.

Also drop the "no leading '*'" assertion, because valid_name.match()
ensures it can't fail.

Fixes: 9fb081e0b98409556d023c7193eeb68947cd1211
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20210323094025.3569441-8-armbru@redhat.com>
Reviewed-by: John Snow <jsnow@redhat.com>
3 years agotests/qapi-schema: Tweak to demonstrate buggy member name check
Markus Armbruster [Tue, 23 Mar 2021 09:40:03 +0000 (10:40 +0100)]
tests/qapi-schema: Tweak to demonstrate buggy member name check

Member name 'u' and names starting with 'has-' or 'has_' are reserved
for the generator.  check_type() enforces this, covered by tests
reserved-member-u and reserved-member-has.

These tests neglect to cover optional members, where the name starts
with '*'.  Tweak reserved-member-u to fix that.  Test
reserved-member-has still covers non-optional members.

This demonstrates the reserved member name check is broken for
optional members.  The next commit will fix it.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20210323094025.3569441-7-armbru@redhat.com>
Reviewed-by: John Snow <jsnow@redhat.com>
[Commit message improved slightly]

3 years agoMerge remote-tracking branch 'remotes/pmaydell/tags/pull-target-arm-20210323' into...
Peter Maydell [Tue, 23 Mar 2021 21:15:16 +0000 (21:15 +0000)]
Merge remote-tracking branch 'remotes/pmaydell/tags/pull-target-arm-20210323' into staging

target-arm queue:
 * hw/arm/virt: Disable pl011 clock migration if needed
 * target/arm: Make M-profile VTOR loads on reset handle memory aliasing
 * target/arm: Set ARMMMUFaultInfo.level in user-only arm_cpu_tlb_fill

# gpg: Signature made Tue 23 Mar 2021 14:26:09 GMT
# gpg:                using RSA key E1A5C593CD419DE28E8315CF3C2525ED14360CDE
# gpg:                issuer "peter.maydell@linaro.org"
# gpg: Good signature from "Peter Maydell <peter.maydell@linaro.org>" [ultimate]
# gpg:                 aka "Peter Maydell <pmaydell@gmail.com>" [ultimate]
# gpg:                 aka "Peter Maydell <pmaydell@chiark.greenend.org.uk>" [ultimate]
# Primary key fingerprint: E1A5 C593 CD41 9DE2 8E83  15CF 3C25 25ED 1436 0CDE

* remotes/pmaydell/tags/pull-target-arm-20210323:
  target/arm: Set ARMMMUFaultInfo.level in user-only arm_cpu_tlb_fill
  target/arm: Make M-profile VTOR loads on reset handle memory aliasing
  hw/core/loader: Add new function rom_ptr_for_as()
  memory: Add offset_in_region to flatview_cb arguments
  memory: Document flatview_for_each_range()
  memory: Make flatview_cb return bool, not int
  hw/arm/virt: Disable pl011 clock migration if needed

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
3 years agotests/qapi-schema: Drop TODO comment on simple unions
Markus Armbruster [Tue, 23 Mar 2021 09:40:02 +0000 (10:40 +0100)]
tests/qapi-schema: Drop TODO comment on simple unions

Simple unions don't need more features, they need to die.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20210323094025.3569441-6-armbru@redhat.com>
Reviewed-by: John Snow <jsnow@redhat.com>
3 years agotests/qapi-schema: Belatedly update comment on alternate clash
Markus Armbruster [Tue, 23 Mar 2021 09:40:01 +0000 (10:40 +0100)]
tests/qapi-schema: Belatedly update comment on alternate clash

Commit 0426d53c65 "qapi: Simplify visiting of alternate types"
eliminated the implicit alternate enum, but neglected to update a
comment about it in a test.  Do that now.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20210323094025.3569441-5-armbru@redhat.com>
Reviewed-by: John Snow <jsnow@redhat.com>
3 years agotests/qapi-schema: Rework comments on longhand member definitions
Markus Armbruster [Tue, 23 Mar 2021 09:40:00 +0000 (10:40 +0100)]
tests/qapi-schema: Rework comments on longhand member definitions

A few old comments talk about "desired future use of defaults" and
"anonymous inline branch types".  Kind of misleading since commit
87adbbffd4 "qapi: add a dictionary form for TYPE" added longhand
member definitions.  Talk about that instead.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20210323094025.3569441-4-armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: John Snow <jsnow@redhat.com>
3 years agotests/qapi-schema: Drop redundant flat-union-inline test
Markus Armbruster [Tue, 23 Mar 2021 09:39:59 +0000 (10:39 +0100)]
tests/qapi-schema: Drop redundant flat-union-inline test

flat-union-inline.json covers longhand branch definition with an
invalid type value.  It's redundant: longhand branch definition is
covered by flat-union-inline-invalid-dict.json, and invalid type value
is covered by nested-struct-data.json.  Drop the test.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20210323094025.3569441-3-armbru@redhat.com>
Reviewed-by: John Snow <jsnow@redhat.com>
3 years agoqapi/pragma: Tidy up after removal of deprecated commands
Markus Armbruster [Tue, 23 Mar 2021 09:39:58 +0000 (10:39 +0100)]
qapi/pragma: Tidy up after removal of deprecated commands

Commit cbde7be900 "migrate: remove QMP/HMP commands for speed,
downtime and cache size" neglected to remove query-migrate-cache-size
from pragma returns-whitelist.

Commit 8af54b9172 "machine: remove 'query-cpus' QMP command" neglected
to remove CpuInfo & friends from pragma name-case-exceptions.

Remove these now.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20210323094025.3569441-2-armbru@redhat.com>
Reviewed-by: John Snow <jsnow@redhat.com>