]> git.proxmox.com Git - mirror_qemu.git/log
mirror_qemu.git
23 months agoaspeed: Remove usage of sysbus_mmio_map
Peter Delevoryas [Thu, 30 Jun 2022 07:21:13 +0000 (09:21 +0200)]
aspeed: Remove usage of sysbus_mmio_map

sysbus_mmio_map maps devices into "get_system_memory()".

With the new SoC memory attribute, we want to make sure that each device is
mapped into the SoC memory.

In single SoC machines, the SoC memory is the same as "get_system_memory()",
but in multi SoC machines it will be different.

Signed-off-by: Peter Delevoryas <pdel@fb.com>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Message-Id: <20220624003701.1363500-4-pdel@fb.com>
Signed-off-by: Cédric Le Goater <clg@kaod.org>
23 months agoaspeed: Add memory property to Aspeed SoC
Peter Delevoryas [Thu, 30 Jun 2022 07:21:13 +0000 (09:21 +0200)]
aspeed: Add memory property to Aspeed SoC

Multi-SoC machines can use this property to specify a memory container
for each SoC. Single SoC machines will just specify get_system_memory().

Signed-off-by: Peter Delevoryas <pdel@fb.com>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Message-Id: <20220624003701.1363500-3-pdel@fb.com>
Signed-off-by: Cédric Le Goater <clg@kaod.org>
23 months agoaspeed: Set CPU memory property explicitly
Peter Delevoryas [Thu, 30 Jun 2022 07:21:13 +0000 (09:21 +0200)]
aspeed: Set CPU memory property explicitly

Signed-off-by: Peter Delevoryas <pdel@fb.com>
Message-Id: <20220624003701.1363500-2-pdel@fb.com>
Signed-off-by: Cédric Le Goater <clg@kaod.org>
23 months agoaspeed/smc: Fix potential overflow
Cédric Le Goater [Thu, 30 Jun 2022 07:21:13 +0000 (09:21 +0200)]
aspeed/smc: Fix potential overflow

Coverity warns that "ssi_transfer(s->spi, 0U) << 8 * i" might overflow
because the expression is evaluated using 32-bit arithmetic and then
used in a context expecting a uint64_t.

Fixes: Coverity CID 1487244
Message-Id: <20220628165512.1133590-1-clg@kaod.org>
Signed-off-by: Cédric Le Goater <clg@kaod.org>
23 months agoaspeed/hace: Accumulative mode supported
Joel Stanley [Thu, 30 Jun 2022 07:21:13 +0000 (09:21 +0200)]
aspeed/hace: Accumulative mode supported

While the HMAC mode is not modelled, the accumulative mode is.

Accumulative mode is enabled by setting one of the bits in the HMAC
engine command mode part of the register, so fix the unimplemented check
to only look at the upper of the two bits.

Fixes: 5cd7d8564a8b ("aspeed/hace: Support AST2600 HACE")
Signed-off-by: Joel Stanley <joel@jms.id.au>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Message-Id: <20220627100816.125956-1-joel@jms.id.au>
Signed-off-by: Cédric Le Goater <clg@kaod.org>
23 months agoaspeed/i2c: Change trace event for NORMAL_STOP states
Cédric Le Goater [Thu, 30 Jun 2022 07:21:13 +0000 (09:21 +0200)]
aspeed/i2c: Change trace event for NORMAL_STOP states

Using a 'stop' string seems more appropriate than 'normal'.

Reviewed-by: Peter Delevoryas <pdel@fb.com>
Message-Id: <20220628154740.1117349-3-clg@kaod.org>
Signed-off-by: Cédric Le Goater <clg@kaod.org>
23 months agoaspeed/scu: Add trace events for read ops
Cédric Le Goater [Thu, 30 Jun 2022 07:21:13 +0000 (09:21 +0200)]
aspeed/scu: Add trace events for read ops

Reviewed-by: Peter Delevoryas <pdel@fb.com>
Message-Id: <20220628154740.1117349-2-clg@kaod.org>
Signed-off-by: Cédric Le Goater <clg@kaod.org>
23 months agoaspeed: Set the dram container at the SoC level
Cédric Le Goater [Thu, 30 Jun 2022 07:21:13 +0000 (09:21 +0200)]
aspeed: Set the dram container at the SoC level

Currently, the Aspeed machines allocate a ram container region in
which the machine ram region is mapped. See commit ad1a9782186d
("aspeed: add a RAM memory region container"). An extra region is
mapped after ram in the ram container to catch invalid access done by
FW. That's how FW determines the size of ram. See commit ebe31c0a8ef7
("aspeed: add a max_ram_size property to the memory controller").

Let's move all the logic under the SoC where it should be. It will
also ease the work on multi SoC support.

Reviewed-by: Peter Delevoryas <pdel@fb.com>
Message-Id: <20220623202123.3972977-1-clg@kaod.org>
Signed-off-by: Cédric Le Goater <clg@kaod.org>
23 months agohw: m25p80: add tests for write protect (WP# and SRWD bit)
Iris Chen [Thu, 30 Jun 2022 07:21:13 +0000 (09:21 +0200)]
hw: m25p80: add tests for write protect (WP# and SRWD bit)

Signed-off-by: Iris Chen <irischenlj@fb.com>
Message-Id: <20220624183016.2125264-1-irischenlj@fb.com>
Signed-off-by: Cédric Le Goater <clg@kaod.org>
23 months agohw: m25p80: add WP# pin and SRWD bit for write protection
Iris Chen [Thu, 30 Jun 2022 07:21:13 +0000 (09:21 +0200)]
hw: m25p80: add WP# pin and SRWD bit for write protection

Signed-off-by: Iris Chen <irischenlj@gmail.com>
Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com>
Message-Id: <20220621202427.2680413-1-irischenlj@fb.com>
Signed-off-by: Cédric Le Goater <clg@kaod.org>
23 months agoMerge tag 'trivial-branch-for-7.1-pull-request' of https://gitlab.com/laurent_vivier...
Richard Henderson [Wed, 29 Jun 2022 23:19:40 +0000 (04:49 +0530)]
Merge tag 'trivial-branch-for-7.1-pull-request' of https://gitlab.com/laurent_vivier/qemu into staging

trivial patches pull request 20220629

# -----BEGIN PGP SIGNATURE-----
#
# iQJGBAABCAAwFiEEzS913cjjpNwuT1Fz8ww4vT8vvjwFAmK8FmsSHGxhdXJlbnRA
# dml2aWVyLmV1AAoJEPMMOL0/L7482EkP/19M/AAUkGqIdU9Dj7H46r+LEKtrT7Xu
# jNRDDrkhVQvx42mklSB+fO/ptMKUDgxvLs4mnuZFxM7SrTOb4h5jfZzyYjk73ENQ
# YZ/TLxRtxAfRCcGwso7NGyk85mwt+sBFKZXfW6qsfc9AjDphLUOblfSieeFegz69
# BUtzbMOPSMR7e54y6azJX3gCkxLytSXYgk4otSLTrL233sT7pnwPRdxKGzCTA5vs
# fRxKb4p/R05lWepcjrL2d2lB1TabsV0kqmNkHDvubVWlgyoK3Vt/1dzD1UP7CrvF
# WghlZWmxCHrmLlBb+VSDUa22kpfv5fi/feauuug+dya+s1Mlq8HZTL8VtjUJHwLL
# 92xRPeP/RfEJdoQDuMKXP9DWAAYM03HGgR37cE5NMDCyHG0XRKOJ+i2P7DQLVDjW
# QyWX6bX1WV6FovdwwMnZR9OclvKtsZnb1jlfj+G2DdKXpLliDH6DkFm8mPQTM1L7
# w53iMtK88erEc+NP6+fPbbZmySvDVUcLmcTiBceZK6Vjo4oTGNrAWP+VgjBTJaz+
# 71ulkJ6vo39ZnEQOUlWrL/yW+8sQNaeO1tO67HZZ8dgTvAnPwyvKq88jSMzGCNpz
# Wpcf4yVAEvU+fP3KkEaqQqmQeK/Vc+H6044O00tcLVICkpCdN/FwRjgfZanX9CIJ
# xQjxW5mkb1Z3
# =fgtJ
# -----END PGP SIGNATURE-----
# gpg: Signature made Wed 29 Jun 2022 02:37:55 PM +0530
# gpg:                using RSA key CD2F75DDC8E3A4DC2E4F5173F30C38BD3F2FBE3C
# gpg:                issuer "laurent@vivier.eu"
# gpg: Good signature from "Laurent Vivier <lvivier@redhat.com>" [undefined]
# gpg:                 aka "Laurent Vivier <laurent@vivier.eu>" [undefined]
# gpg:                 aka "Laurent Vivier (Red Hat) <lvivier@redhat.com>" [undefined]
# 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: CD2F 75DD C8E3 A4DC 2E4F  5173 F30C 38BD 3F2F BE3C

* tag 'trivial-branch-for-7.1-pull-request' of https://gitlab.com/laurent_vivier/qemu:
  hw/i386/xen/xen-hvm: Inline xen_piix_pci_write_config_client() and remove it
  hw/i386/xen/xen-hvm: Allow for stubbing xen_set_pci_link_route()
  hw/ide/atapi.c: Correct typos (CD-CDROM -> CD-ROM)
  common-user: Only compile the common user code if have_user is set
  hw/pci-host/i440fx: Remove unused parameter from i440fx_init()
  MAINTAINERS: Add softmmu/runstate.c to "Main loop"
  trivial typos: namesapce
  Trivial: 3 char repeat typos
  util: Return void on iova_tree_remove
  qom/object: Remove circular include dependency
  vga: avoid crash if no default vga card

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
23 months agoMerge tag 'pull-block-2022-06-14-v2' of https://gitlab.com/vsementsov/qemu into staging
Richard Henderson [Wed, 29 Jun 2022 16:05:27 +0000 (21:35 +0530)]
Merge tag 'pull-block-2022-06-14-v2' of https://gitlab.com/vsementsov/qemu into staging

Block jobs & NBD patches

v2: - add arguments to QEMUMachine constructor in test, to make it work
      on arm in gitlab pipeline
    - use bdrv_inc_in_flight() / bdrv_dec_in_flight() instead of direct
      manipulation with bs->in_flight

- add new options for copy-before-write filter
- new trace points for NBD
- prefer unsigned type for some 'in_flight' fields

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCgAdFiEEi5wmzbL9FHyIDoahVh8kwfGfefsFAmK8BqkACgkQVh8kwfGf
# efuiMw/+P9FFLfGFSjVP+LYeT0Ah6kN1ypCMQzIk3Qq/J6qgMZhtRqpQoZOfIFQL
# U9fGmEtQZ7gvEMD/nJToL6uOYlnQfPxDcA6GrRwWWE3rcFiPK4J0q2LlnPLn4QaU
# W/qag5l/QnZfLlj/iV6neWOEvqdnvY1L8IS+T8xV6N0iBYlwgMC/6FGshQwehzcV
# T5F1qPGB0vjFDjf92LFPEsvsFFHjHIVPwOyJMvF64QtSk57utikq/la9PI/yA9AH
# Ll4mNQuZKx6rSI5wE6b21jc8iOUvaoHdPSEDQZfNILSdgGdiKvFwE51y+baGnIAD
# TpjxfG59q0jyGxMjQVxMRSFaxAC4+Mqi82diSPv4xbiUdsE4byJH0oENn4z7+wAv
# EvjuU9yx4FfHHltoUNwfn2pv00o/ELdZIoBNmW36rPxSGZMvfVfRtuBL7XWNUFbW
# Fr4BwsjC4KfIxb16QTBGhXVv6grxdlwoU9N23npdi0YpW1ftZzXGDa85+gINQ807
# eK/gP/OtYPwIql0bgmLiuaRNzC9psmQOO6vQbdvd/e4BEVWkxiez37+e+zFMStmL
# OAL8rS6jckUoxVZjCYFEWg97XOobLUIhQxt9Fwh2omMDGKTwv861ghUAivxSWs93
# IRNxfwqNPxnpDDXjnK1ayZgU08IL98AUYVKcPN1y8JvEhB4Hr1k=
# =ndKk
# -----END PGP SIGNATURE-----
# gpg: Signature made Wed 29 Jun 2022 01:30:41 PM +0530
# gpg:                using RSA key 8B9C26CDB2FD147C880E86A1561F24C1F19F79FB
# gpg: Good signature from "Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>" [unknown]
# gpg:                 aka "Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.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: 8B9C 26CD B2FD 147C 880E  86A1 561F 24C1 F19F 79FB

* tag 'pull-block-2022-06-14-v2' of https://gitlab.com/vsementsov/qemu:
  block: use 'unsigned' for in_flight field on driver state
  nbd: trace long NBD operations
  iotests: copy-before-write: add cases for cbw-timeout option
  block/copy-before-write: implement cbw-timeout option
  block/block-copy: block_copy(): add timeout_ns parameter
  util: add qemu-co-timeout
  iotests: add copy-before-write: on-cbw-error tests
  block/copy-before-write: add on-cbw-error open parameter
  block/copy-before-write: refactor option parsing

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
23 months agoblock: use 'unsigned' for in_flight field on driver state
Denis V. Lunev [Mon, 30 May 2022 10:39:57 +0000 (12:39 +0200)]
block: use 'unsigned' for in_flight field on driver state

This patch makes in_flight field 'unsigned' for BDRVNBDState and
MirrorBlockJob. This matches the definition of this field on BDS
and is generically correct - we should never get negative value here.

Signed-off-by: Denis V. Lunev <den@openvz.org>
CC: John Snow <jsnow@redhat.com>
CC: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
CC: Kevin Wolf <kwolf@redhat.com>
CC: Hanna Reitz <hreitz@redhat.com>
CC: Eric Blake <eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
23 months agonbd: trace long NBD operations
Denis V. Lunev [Mon, 30 May 2022 10:39:29 +0000 (12:39 +0200)]
nbd: trace long NBD operations

At the moment there are 2 sources of lengthy operations if configured:
* open connection, which could retry inside and
* reconnect of already opened connection
These operations could be quite lengthy and cumbersome to catch thus
it would be quite natural to add trace points for them.

This patch is based on the original downstream work made by Vladimir.

Signed-off-by: Denis V. Lunev <den@openvz.org>
CC: Eric Blake <eblake@redhat.com>
CC: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
CC: Kevin Wolf <kwolf@redhat.com>
CC: Hanna Reitz <hreitz@redhat.com>
CC: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
23 months agoiotests: copy-before-write: add cases for cbw-timeout option
Vladimir Sementsov-Ogievskiy [Thu, 7 Apr 2022 13:27:26 +0000 (16:27 +0300)]
iotests: copy-before-write: add cases for cbw-timeout option

Add two simple test-cases: timeout failure with
break-snapshot-on-cbw-error behavior and similar with
break-guest-write-on-cbw-error behavior.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@openvz.org>
Reviewed-by: Hanna Reitz <hreitz@redhat.com>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
23 months agoblock/copy-before-write: implement cbw-timeout option
Vladimir Sementsov-Ogievskiy [Thu, 7 Apr 2022 13:27:25 +0000 (16:27 +0300)]
block/copy-before-write: implement cbw-timeout option

In some scenarios, when copy-before-write operations lasts too long
time, it's better to cancel it.

Most useful would be to use the new option together with
on-cbw-error=break-snapshot: this way if cbw operation takes too long
time we'll just cancel backup process but do not disturb the guest too
much.

Note the tricky point of realization: we keep additional point in
bs->in_flight during block_copy operation even if it's timed-out.
Background "cancelled" block_copy operations will finish at some point
and will want to access state. We should care to not free the state in
.bdrv_close() earlier.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@openvz.org>
Reviewed-by: Hanna Reitz <hreitz@redhat.com>
  [vsementsov: use bdrv_inc_in_flight()/bdrv_dec_in_flight() instead of
   direct manipulation on bs->in_flight]
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
23 months agoblock/block-copy: block_copy(): add timeout_ns parameter
Vladimir Sementsov-Ogievskiy [Thu, 7 Apr 2022 13:27:24 +0000 (16:27 +0300)]
block/block-copy: block_copy(): add timeout_ns parameter

Add possibility to limit block_copy() call in time. To be used in the
next commit.

As timed-out block_copy() call will continue in background anyway (we
can't immediately cancel IO operation), it's important also give user a
possibility to pass a callback, to do some additional actions on
block-copy call finish.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@openvz.org>
Reviewed-by: Hanna Reitz <hreitz@redhat.com>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
23 months agoutil: add qemu-co-timeout
Vladimir Sementsov-Ogievskiy [Thu, 7 Apr 2022 13:27:23 +0000 (16:27 +0300)]
util: add qemu-co-timeout

Add new API, to make a time limited call of the coroutine.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@openvz.org>
Reviewed-by: Hanna Reitz <hreitz@redhat.com>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
23 months agoiotests: add copy-before-write: on-cbw-error tests
Vladimir Sementsov-Ogievskiy [Thu, 7 Apr 2022 13:27:22 +0000 (16:27 +0300)]
iotests: add copy-before-write: on-cbw-error tests

Add tests for new option of copy-before-write filter: on-cbw-error.

Note that we use QEMUMachine instead of VM class, because in further
commit we'll want to use throttling which doesn't work with -accel
qtest used by VM.

We also touch pylintrc to not break iotest 297.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@openvz.org>
Reviewed-by: Hanna Reitz <hreitz@redhat.com>
  [vsementsov: add arguments to QEMUMachine constructor]
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
23 months agohw/i386/xen/xen-hvm: Inline xen_piix_pci_write_config_client() and remove it
Bernhard Beschow [Sun, 26 Jun 2022 09:46:56 +0000 (11:46 +0200)]
hw/i386/xen/xen-hvm: Inline xen_piix_pci_write_config_client() and remove it

xen_piix_pci_write_config_client() is implemented in the xen sub tree and
uses PIIX constants internally, thus creating a direct dependency on
PIIX. Now that xen_set_pci_link_route() is stubbable, the logic of
xen_piix_pci_write_config_client() can be moved to PIIX which resolves
the dependency.

Signed-off-by: Bernhard Beschow <shentey@gmail.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Paul Durrant <paul@xen.org>
Message-Id: <20220626094656.15673-3-shentey@gmail.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
23 months agohw/i386/xen/xen-hvm: Allow for stubbing xen_set_pci_link_route()
Bernhard Beschow [Sun, 26 Jun 2022 09:46:55 +0000 (11:46 +0200)]
hw/i386/xen/xen-hvm: Allow for stubbing xen_set_pci_link_route()

The only user of xen_set_pci_link_route() is
xen_piix_pci_write_config_client() which implements PIIX-specific logic in
the xen namespace. This makes xen-hvm depend on PIIX which could be
avoided if xen_piix_pci_write_config_client() was implemented in PIIX. In
order to do this, xen_set_pci_link_route() needs to be stubbable which
this patch addresses.

Signed-off-by: Bernhard Beschow <shentey@gmail.com>
Reviewed-by: Paul Durrant <paul@xen.org>
Message-Id: <20220626094656.15673-2-shentey@gmail.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
23 months agohw/ide/atapi.c: Correct typos (CD-CDROM -> CD-ROM)
Lev Kujawski [Sat, 28 May 2022 20:46:59 +0000 (20:46 +0000)]
hw/ide/atapi.c: Correct typos (CD-CDROM -> CD-ROM)

Signed-off-by: Lev Kujawski <lkujaw@member.fsf.org>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20220528204702.167912-1-lkujaw@member.fsf.org>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
23 months agocommon-user: Only compile the common user code if have_user is set
Thomas Huth [Wed, 22 Jun 2022 14:03:28 +0000 (16:03 +0200)]
common-user: Only compile the common user code if have_user is set

There is no need to waste cycles here if we only compile the system
binaries or tools. Additionally, this change is even a hard requirement
for building the tools on systems that do not have an entry in the
common-user/host/ folder (since common-user/meson.build is trying
to add such a path via the include_directories() command).

Reported-by: Michael Tokarev <mjt@tls.msk.ru>
Signed-off-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Zhang Chen <chen.zhang@intel.com>
Message-Id: <20220622140328.383961-1-thuth@redhat.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
23 months agohw/pci-host/i440fx: Remove unused parameter from i440fx_init()
Bernhard Beschow [Sun, 12 Jun 2022 19:28:00 +0000 (21:28 +0200)]
hw/pci-host/i440fx: Remove unused parameter from i440fx_init()

pi440fx_state is an out-parameter which is never read by the caller.

Signed-off-by: Bernhard Beschow <shentey@gmail.com>
Reviewed-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Message-Id: <20220612192800.40813-1-shentey@gmail.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
23 months agoMAINTAINERS: Add softmmu/runstate.c to "Main loop"
Markus Armbruster [Wed, 15 Jun 2022 12:23:38 +0000 (14:23 +0200)]
MAINTAINERS: Add softmmu/runstate.c to "Main loop"

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Acked-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20220615122338.340426-1-armbru@redhat.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
23 months agotrivial typos: namesapce
Dr. David Alan Gilbert [Tue, 14 Jun 2022 10:40:45 +0000 (11:40 +0100)]
trivial typos: namesapce

'namespace' is misspelled in a bunch of places.

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Klaus Jensen <k.jensen@samsung.com>
Message-Id: <20220614104045.85728-3-dgilbert@redhat.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
23 months agoTrivial: 3 char repeat typos
Dr. David Alan Gilbert [Tue, 14 Jun 2022 10:40:44 +0000 (11:40 +0100)]
Trivial: 3 char repeat typos

Inspired by Julia Lawall's fixing of Linux
kernel comments, I looked at qemu, although I did it manually.

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Klaus Jensen <k.jensen@samsung.com>
Message-Id: <20220614104045.85728-2-dgilbert@redhat.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
23 months agoutil: Return void on iova_tree_remove
Eugenio Pérez [Wed, 27 Apr 2022 15:49:31 +0000 (17:49 +0200)]
util: Return void on iova_tree_remove

It always returns IOVA_OK so nobody uses it.

Acked-by: Jason Wang <jasowang@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
Message-Id: <20220427154931.3166388-1-eperezma@redhat.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
23 months agoqom/object: Remove circular include dependency
Philippe Mathieu-Daudé [Mon, 9 May 2022 08:46:59 +0000 (10:46 +0200)]
qom/object: Remove circular include dependency

"qom/object.h" doesn't need to include itself.

Fixes: db1015e92e04 ("Move QOM typedefs and add missing includes")
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Damien Hedde <damien.hedde@greensocs.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20220509084659.52076-1-philippe.mathieu.daude@gmail.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
23 months agovga: avoid crash if no default vga card
Guo Zhi [Tue, 3 May 2022 09:17:24 +0000 (17:17 +0800)]
vga: avoid crash if no default vga card

QEMU in some arch will crash when executing -vga help command, because
there is no default vga model.  Add check to this case and avoid crash.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/978

Signed-off-by: Guo Zhi <qtxuning1999@sjtu.edu.cn>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Tested-by: Thomas Huth <thuth@redhat.com>
Message-Id: <20220503091724.970009-1-qtxuning1999@sjtu.edu.cn>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
23 months agoblock/copy-before-write: add on-cbw-error open parameter
Vladimir Sementsov-Ogievskiy [Thu, 7 Apr 2022 13:27:21 +0000 (16:27 +0300)]
block/copy-before-write: add on-cbw-error open parameter

Currently, behavior on copy-before-write operation failure is simple:
report error to the guest.

Let's implement alternative behavior: break the whole copy-before-write
process (and corresponding backup job or NBD client) but keep guest
working. It's needed if we consider guest stability as more important.

The realisation is simple: on copy-before-write failure we set
s->snapshot_ret and continue guest operations. s->snapshot_ret being
set will lead to all further snapshot API requests. Note that all
in-flight snapshot-API requests may still success: we do wait for them
on BREAK_SNAPSHOT-failure path in cbw_do_copy_before_write().

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@openvz.org>
Reviewed-by: Hanna Reitz <hreitz@redhat.com>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
23 months agoblock/copy-before-write: refactor option parsing
Vladimir Sementsov-Ogievskiy [Thu, 7 Apr 2022 13:27:20 +0000 (16:27 +0300)]
block/copy-before-write: refactor option parsing

We are going to add one more option of enum type. Let's refactor option
parsing so that we can simply work with BlockdevOptionsCbw object.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@openvz.org>
Reviewed-by: Hanna Reitz <hreitz@redhat.com>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
23 months agoMerge tag 'for_upstream' of git://git.kernel.org/pub/scm/virt/kvm/mst/qemu into staging
Richard Henderson [Tue, 28 Jun 2022 06:21:07 +0000 (11:51 +0530)]
Merge tag 'for_upstream' of git://git.kernel.org/pub/scm/virt/kvm/mst/qemu into staging

virtio: fixes

fixes all over the place

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
# -----BEGIN PGP SIGNATURE-----
#
# iQFDBAABCAAtFiEEXQn9CHHI+FuUyooNKB8NuNKNVGkFAmK6NQoPHG1zdEByZWRo
# YXQuY29tAAoJECgfDbjSjVRp/sQIAJGiYliUHElJapM/4KSsXKWCFtk9B8wJuUie
# yeMKOdD6QSk9tk/HkYSCnMB7G6Fe+MtoE+sPm/6l5nOFqvqVVJw9vOKteWHSpQ0E
# 9CgbR7s7K1MoLG9J613iB2OtAfhPrWEvSOJ6mvTAxGgxhCQw6UzC88cYfBHJ/efn
# GAhVlriSfSCRANmivjY+g4h4JFWWSMTH6m9u4wKBJF8GRkNgN+C50Z+bp8aE7wRT
# KiMoaaYUDOjxzD+8nGYggg/t+UIM7jG2t8M5BMbC0NMP+ovVZeesWK6ZOzoda2tI
# ZONV0dLikLCicyOvfMH6YDqzGtchCDmS0hpfuorhlzsntm42RBM=
# =T+gr
# -----END PGP SIGNATURE-----
# gpg: Signature made Tue 28 Jun 2022 04:24:02 AM +0530
# gpg:                using RSA key 5D09FD0871C8F85B94CA8A0D281F0DB8D28D5469
# gpg:                issuer "mst@redhat.com"
# gpg: Good signature from "Michael S. Tsirkin <mst@kernel.org>" [undefined]
# gpg:                 aka "Michael S. Tsirkin <mst@redhat.com>" [undefined]
# 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: 0270 606B 6F3C DF3D 0B17  0970 C350 3912 AFBE 8E67
#      Subkey fingerprint: 5D09 FD08 71C8 F85B 94CA  8A0D 281F 0DB8 D28D 5469

* tag 'for_upstream' of git://git.kernel.org/pub/scm/virt/kvm/mst/qemu:
  include/hw/virtio: document vhost_ack_features
  include/hw/virtio: document vhost_get_features
  contrib/vhost-user-blk: fix 32 bit build and enable
  MAINTAINERS: Collect memory device files in "Memory devices"
  libvhost-user: Fix VHOST_USER_ADD_MEM_REG reply
  libvhost-user: Fix VHOST_USER_GET_MAX_MEM_SLOTS reply
  docs/vhost-user: Fix mismerge
  virtio-iommu: Fix migration regression
  vhost: setup error eventfd and dump errors
  vhost: add method vhost_set_vring_err
  msi: fix MSI vector limit check in msi_set_mask()
  virtio-iommu: Fix the partial copy of probe request

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
23 months agoMerge tag 'pull-semi-20220628' of https://gitlab.com/rth7680/qemu into staging
Richard Henderson [Tue, 28 Jun 2022 04:54:30 +0000 (10:24 +0530)]
Merge tag 'pull-semi-20220628' of https://gitlab.com/rth7680/qemu into staging

Semihosting syscall reorg:
  * Split out semihosting/syscalls.c with common implementations.
  * Reorg arm-compat-semi.c to use syscalls.c.
  * Minor prep cleanups to m68k, mips, nios2.

# -----BEGIN PGP SIGNATURE-----
#
# iQFRBAABCgA7FiEEekgeeIaLTbaoWgXAZN846K9+IV8FAmK6iSodHHJpY2hhcmQu
# aGVuZGVyc29uQGxpbmFyby5vcmcACgkQZN846K9+IV8SEwgAmmowW2oeFA9uCrwz
# gUJo17AJ+RmRF/zXHyu5CPswylvfwH0zJXAm5BV7P/pVdyaL36b8YcgSEf+EWLsf
# rLFHxCshTYEnZSk6yFtWk5bn5azfevHm9/ObPeS9XGL4seQqGy7C/FReoTQ7/zI0
# W3zUDd3bWah3fXw8XYgSzh/RCrC5E2gFFc1G1g+6SIVZ7pbgkre2rRk5WMmylCLd
# jf9pmyswrheaKumCoBxU/S4XDgxVpaf3khiIqdbo8A20MDGnK/SZUWsBwJLK3QB8
# SKKv8o1ovbnl/HykABaszCIkO/LIu6SX3LoK7pF2CujkgSuwEN3WW0DOml6+b3fU
# J7YeZg==
# =sTbM
# -----END PGP SIGNATURE-----
# gpg: Signature made Tue 28 Jun 2022 10:22:58 AM +0530
# gpg:                using RSA key 7A481E78868B4DB6A85A05C064DF38E8AF7E215F
# gpg:                issuer "richard.henderson@linaro.org"
# gpg: Good signature from "Richard Henderson <richard.henderson@linaro.org>" [ultimate]

* tag 'pull-semi-20220628' of https://gitlab.com/rth7680/qemu: (60 commits)
  target/nios2: Move nios2-semi.c to nios2_softmmu_ss
  target/nios2: Eliminate nios2_semi_is_lseek
  target/mips: Drop pread and pwrite syscalls from semihosting
  target/mips: Add UHI errno values
  target/mips: Use an exception for semihosting
  target/m68k: Make semihosting system only
  target/m68k: Eliminate m68k_semi_is_fseek
  semihosting: Create semihost_sys_poll_one
  semihosting: Remove qemu_semihosting_console_outs
  semihosting: Use console_out_gf for SYS_WRITE0
  semihosting: Remove qemu_semihosting_console_outc
  semihosting: Use console_out_gf for SYS_WRITEC
  semihosting: Use console_in_gf for SYS_READC
  semihosting: Create qemu_semihosting_guestfd_init
  semihosting: Add GuestFDConsole
  semihosting: Create qemu_semihosting_console_write
  semihosting: Cleanup chardev init
  semihosting: Expand qemu_semihosting_console_inc to read
  semihosting: Pass CPUState to qemu_semihosting_console_inc
  semihosting: Fix docs comment for qemu_semihosting_console_inc
  ...

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
23 months agotarget/nios2: Move nios2-semi.c to nios2_softmmu_ss
Richard Henderson [Sat, 30 Apr 2022 02:50:02 +0000 (19:50 -0700)]
target/nios2: Move nios2-semi.c to nios2_softmmu_ss

Semihosting is not enabled for nios2-linux-user.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
23 months agotarget/nios2: Eliminate nios2_semi_is_lseek
Richard Henderson [Fri, 29 Apr 2022 23:49:20 +0000 (16:49 -0700)]
target/nios2: Eliminate nios2_semi_is_lseek

Reorg nios2_semi_return_* to gdb_syscall_complete_cb.
Use the 32-bit version normally, and the 64-bit version
for HOSTED_LSEEK.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
23 months agotarget/mips: Drop pread and pwrite syscalls from semihosting
Richard Henderson [Tue, 3 May 2022 05:52:19 +0000 (22:52 -0700)]
target/mips: Drop pread and pwrite syscalls from semihosting

We don't implement it with _WIN32 hosts, and the syscalls
are missing from the gdb remote file i/o interface.
Since we can't implement them universally, drop them.

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
23 months agotarget/mips: Add UHI errno values
Richard Henderson [Mon, 2 May 2022 03:03:01 +0000 (20:03 -0700)]
target/mips: Add UHI errno values

From the Unified Hosting Interface, MD01069 Reference Manual,
version 1.1.6, 06 July 2015.

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
23 months agotarget/mips: Use an exception for semihosting
Richard Henderson [Mon, 2 May 2022 07:11:25 +0000 (00:11 -0700)]
target/mips: Use an exception for semihosting

Within do_interrupt, we hold the iothread lock, which
is required for Chardev access for the console, and for
the round trip for use_gdb_syscalls().

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
23 months agotarget/m68k: Make semihosting system only
Richard Henderson [Sat, 30 Apr 2022 03:16:53 +0000 (20:16 -0700)]
target/m68k: Make semihosting system only

While we had a call to do_m68k_semihosting in linux-user, it
wasn't actually reachable.  We don't include DISAS_INSN(halt)
as an instruction unless system mode.

Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
23 months agotarget/m68k: Eliminate m68k_semi_is_fseek
Richard Henderson [Fri, 29 Apr 2022 23:44:44 +0000 (16:44 -0700)]
target/m68k: Eliminate m68k_semi_is_fseek

Reorg m68k_semi_return_* to gdb_syscall_complete_cb.
Use the 32-bit version normally, and the 64-bit version
for HOSTED_LSEEK.

Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
23 months agosemihosting: Create semihost_sys_poll_one
Richard Henderson [Mon, 2 May 2022 18:15:40 +0000 (11:15 -0700)]
semihosting: Create semihost_sys_poll_one

This will be used for implementing the xtensa select_one
system call.  Choose "poll" over "select" so that we can
reuse Glib's g_poll constants and to avoid struct timeval.

Reviewed-by: Luc Michel <lmichel@kalray.eu>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
23 months agosemihosting: Remove qemu_semihosting_console_outs
Richard Henderson [Mon, 2 May 2022 01:04:27 +0000 (18:04 -0700)]
semihosting: Remove qemu_semihosting_console_outs

This function has been replaced by *_write.

Reviewed-by: Luc Michel <lmichel@kalray.eu>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
23 months agosemihosting: Use console_out_gf for SYS_WRITE0
Richard Henderson [Mon, 2 May 2022 01:02:53 +0000 (18:02 -0700)]
semihosting: Use console_out_gf for SYS_WRITE0

Reviewed-by: Luc Michel <lmichel@kalray.eu>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
23 months agosemihosting: Remove qemu_semihosting_console_outc
Richard Henderson [Mon, 2 May 2022 00:57:22 +0000 (17:57 -0700)]
semihosting: Remove qemu_semihosting_console_outc

This function has been replaced by *_write.

Reviewed-by: Luc Michel <lmichel@kalray.eu>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
23 months agosemihosting: Use console_out_gf for SYS_WRITEC
Richard Henderson [Mon, 2 May 2022 00:55:20 +0000 (17:55 -0700)]
semihosting: Use console_out_gf for SYS_WRITEC

Reviewed-by: Luc Michel <lmichel@kalray.eu>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
23 months agosemihosting: Use console_in_gf for SYS_READC
Richard Henderson [Mon, 2 May 2022 00:42:43 +0000 (17:42 -0700)]
semihosting: Use console_in_gf for SYS_READC

Reviewed-by: Luc Michel <lmichel@kalray.eu>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
23 months agosemihosting: Create qemu_semihosting_guestfd_init
Richard Henderson [Mon, 2 May 2022 00:21:00 +0000 (17:21 -0700)]
semihosting: Create qemu_semihosting_guestfd_init

For arm-compat, initialize console_{in,out}_gf;
otherwise, initialize stdio file descriptors.

This will go some way to cleaning up arm-compat, and
will allow other semihosting to use normal stdio.

Reviewed-by: Luc Michel <lmichel@kalray.eu>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
23 months agosemihosting: Add GuestFDConsole
Richard Henderson [Sun, 1 May 2022 20:11:45 +0000 (13:11 -0700)]
semihosting: Add GuestFDConsole

Add a GuestFDType for connecting to the semihosting console.
Hook up to read, write, isatty, and fstat syscalls.

Note that the arm-specific syscall flen cannot be applied
to the console, because the console is not a descriptor
exposed to the guest.

Reviewed-by: Luc Michel <lmichel@kalray.eu>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
23 months agosemihosting: Create qemu_semihosting_console_write
Richard Henderson [Sun, 1 May 2022 19:42:37 +0000 (12:42 -0700)]
semihosting: Create qemu_semihosting_console_write

Will replace qemu_semihosting_console_{outs,outc},
but we need more plumbing first.

Reviewed-by: Luc Michel <lmichel@kalray.eu>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
23 months agosemihosting: Cleanup chardev init
Richard Henderson [Sun, 1 May 2022 23:59:06 +0000 (16:59 -0700)]
semihosting: Cleanup chardev init

Rename qemu_semihosting_connect_chardevs to
qemu_semihosting_chardev_init; pass the result
directly to qemu_semihosting_console_init.

Store the chardev in SemihostingConsole instead
of SemihostingConfig, which lets us drop
semihosting_get_chardev.

Reviewed-by: Luc Michel <lmichel@kalray.eu>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
23 months agosemihosting: Expand qemu_semihosting_console_inc to read
Richard Henderson [Sun, 1 May 2022 19:31:08 +0000 (12:31 -0700)]
semihosting: Expand qemu_semihosting_console_inc to read

Allow more than one character to be read at one time.
Will be used by m68k and nios2 semihosting for stdio.

Reviewed-by: Luc Michel <lmichel@kalray.eu>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
23 months agosemihosting: Pass CPUState to qemu_semihosting_console_inc
Richard Henderson [Sun, 1 May 2022 19:21:19 +0000 (12:21 -0700)]
semihosting: Pass CPUState to qemu_semihosting_console_inc

We don't need CPUArchState, and we do want the CPUState of the
thread performing the operation -- use this instead of current_cpu.

Reviewed-by: Luc Michel <lmichel@kalray.eu>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
23 months agosemihosting: Fix docs comment for qemu_semihosting_console_inc
Richard Henderson [Sun, 1 May 2022 18:58:58 +0000 (11:58 -0700)]
semihosting: Fix docs comment for qemu_semihosting_console_inc

The implementation of qemu_semihosting_console_inc does not
defer to gdbstub, but only reads from the fifo in console.c.

Reviewed-by: Luc Michel <lmichel@kalray.eu>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
23 months agogdbstub: Adjust gdb_syscall_complete_cb declaration
Richard Henderson [Fri, 29 Apr 2022 23:21:43 +0000 (16:21 -0700)]
gdbstub: Adjust gdb_syscall_complete_cb declaration

Change 'ret' to uint64_t.  This resolves a FIXME in the
m68k and nios2 semihosting that we've lost data.
Change 'err' to int.  There is nothing target-specific
about the width of the errno value.

Reviewed-by: Luc Michel <lmichel@kalray.eu>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
23 months agosemihosting: Create semihost_sys_gettimeofday
Richard Henderson [Fri, 29 Apr 2022 23:05:49 +0000 (16:05 -0700)]
semihosting: Create semihost_sys_gettimeofday

This syscall will be used by m68k and nios2 semihosting.

Reviewed-by: Luc Michel <lmichel@kalray.eu>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
23 months agosemihosting: Create semihost_sys_{stat,fstat}
Richard Henderson [Fri, 29 Apr 2022 22:45:25 +0000 (15:45 -0700)]
semihosting: Create semihost_sys_{stat,fstat}

These syscalls will be used by m68k and nios2 semihosting.

Reviewed-by: Luc Michel <lmichel@kalray.eu>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
23 months agosemihosting: Split out semihost_sys_system
Richard Henderson [Fri, 29 Apr 2022 20:57:19 +0000 (13:57 -0700)]
semihosting: Split out semihost_sys_system

Split out the non-ARM specific portions of SYS_SYSTEM to a
reusable function.

Reviewed-by: Luc Michel <lmichel@kalray.eu>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
23 months agosemihosting: Split out semihost_sys_rename
Richard Henderson [Fri, 29 Apr 2022 17:11:31 +0000 (10:11 -0700)]
semihosting: Split out semihost_sys_rename

Split out the non-ARM specific portions of SYS_RENAME to a
reusable function.

Reviewed-by: Luc Michel <lmichel@kalray.eu>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
23 months agosemihosting: Split out semihost_sys_remove
Richard Henderson [Fri, 29 Apr 2022 16:29:27 +0000 (09:29 -0700)]
semihosting: Split out semihost_sys_remove

Split out the non-ARM specific portions of SYS_REMOVE to a
reusable function.

Reviewed-by: Luc Michel <lmichel@kalray.eu>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
23 months agosemihosting: Split out semihost_sys_flen
Richard Henderson [Fri, 29 Apr 2022 16:05:36 +0000 (09:05 -0700)]
semihosting: Split out semihost_sys_flen

The ARM-specific SYS_FLEN isn't really something that can be
reused by other semihosting apis, but there are parts that can
reused for the implementation of semihost_sys_fstat.

Reviewed-by: Luc Michel <lmichel@kalray.eu>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
23 months agosemihosting: Split out semihost_sys_isatty
Richard Henderson [Thu, 28 Apr 2022 19:31:25 +0000 (12:31 -0700)]
semihosting: Split out semihost_sys_isatty

Split out the non-ARM specific portions of SYS_ISTTY to a
reusable function.  This handles all GuestFD.

Add a common_semi_istty_cb helper to translate the Posix
error return, 0+ENOTTY, to the Arm semihosting not-a-file
success result.

Reviewed-by: Luc Michel <lmichel@kalray.eu>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
23 months agosemihosting: Split out semihost_sys_lseek
Richard Henderson [Thu, 28 Apr 2022 19:04:44 +0000 (12:04 -0700)]
semihosting: Split out semihost_sys_lseek

Split out the non-ARM specific portions of SYS_SEEK to a
reusable function.  This handles all GuestFD.  Isolate the
curious ARM-specific return value processing to a new
callback, common_semi_seek_cb.

Expand the internal type of the offset to int64_t, and
provide the whence argument, which will be required by
m68k and nios2 semihosting.

Note that gdb_do_syscall %x reads target_ulong, not int.

Reviewed-by: Luc Michel <lmichel@kalray.eu>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
23 months agosemihosting: Bound length for semihost_sys_{read,write}
Richard Henderson [Fri, 29 Apr 2022 19:15:14 +0000 (12:15 -0700)]
semihosting: Bound length for semihost_sys_{read,write}

Fixes a minor bug in which a 64-bit guest on a 32-bit host could
truncate the length.  This would only ever cause a problem if
there were no bits set in the low 32, so that it truncates to 0.

Reviewed-by: Luc Michel <lmichel@kalray.eu>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
23 months agosemihosting: Split out semihost_sys_write
Richard Henderson [Thu, 28 Apr 2022 18:49:47 +0000 (11:49 -0700)]
semihosting: Split out semihost_sys_write

Split out the non-ARM specific portions of SYS_WRITE to a
reusable function.  This handles all GuestFD.  This removes
the last use of common_semi_syscall_len.

Note that gdb_do_syscall %x reads target_ulong, not int.

Reviewed-by: Luc Michel <lmichel@kalray.eu>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
23 months agosemihosting: Split out semihost_sys_read
Richard Henderson [Thu, 28 Apr 2022 18:40:41 +0000 (11:40 -0700)]
semihosting: Split out semihost_sys_read

Split out the non-ARM specific portions of SYS_READ to a
reusable function.  This handles all GuestFD.  Isolate the
curious ARM-specific return value processing to a new
callback, common_semi_rw_cb.

Note that gdb_do_syscall %x reads target_ulong, not int.

Reviewed-by: Luc Michel <lmichel@kalray.eu>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
23 months agosemihosting: Split out semihost_sys_close
Richard Henderson [Thu, 28 Apr 2022 16:22:18 +0000 (09:22 -0700)]
semihosting: Split out semihost_sys_close

Split out the non-ARM specific portions of SYS_CLOSE to a
reusable function.  This handles all GuestFD.

Note that gdb_do_syscall %x reads target_ulong, not int.

Reviewed-by: Luc Michel <lmichel@kalray.eu>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
23 months agosemihosting: Split out semihost_sys_open
Richard Henderson [Thu, 28 Apr 2022 08:44:28 +0000 (01:44 -0700)]
semihosting: Split out semihost_sys_open

Split out the non-ARM specific portions of SYS_OPEN to a
reusable function.  This handles gdb and host file i/o.

Add helpers to validate the length of the filename string.
Prepare for usage by other semihosting by allowing the
filename length parameter to be 0, and calling strlen.

Reviewed-by: Luc Michel <lmichel@kalray.eu>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
23 months agosemihosting: Move GET_ARG/SET_ARG earlier in the file
Richard Henderson [Thu, 28 Apr 2022 18:40:14 +0000 (11:40 -0700)]
semihosting: Move GET_ARG/SET_ARG earlier in the file

Moving this to be useful for another function
besides do_common_semihosting.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
23 months agosemihosting: Use env more often in do_common_semihosting
Richard Henderson [Fri, 29 Apr 2022 21:18:40 +0000 (14:18 -0700)]
semihosting: Use env more often in do_common_semihosting

We've already loaded cs->env_ptr into a local variable; use it.
Since env is unconditionally used, we don't need a dummy use.

Reviewed-by: Luc Michel <lmichel@kalray.eu>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
23 months agosemihosting: Split out common-semi-target.h
Richard Henderson [Tue, 7 Jun 2022 17:31:22 +0000 (10:31 -0700)]
semihosting: Split out common-semi-target.h

Move the ARM and RISCV specific helpers into
their own header file.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Luc Michel <lmichel@kalray.eu>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
23 months agosemihosting: Split out common_semi_has_synccache
Richard Henderson [Fri, 29 Apr 2022 21:16:01 +0000 (14:16 -0700)]
semihosting: Split out common_semi_has_synccache

We already have some larger ifdef blocks for ARM and RISCV;
split out a boolean test for SYS_SYNCCACHE.

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
23 months agosemihosting: Split common_semi_flen_buf per target
Richard Henderson [Fri, 29 Apr 2022 20:59:52 +0000 (13:59 -0700)]
semihosting: Split common_semi_flen_buf per target

We already have some larger ifdef blocks for ARM and RISCV;
split out common_semi_stack_bottom per target.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
23 months agosemihosting: Split is_64bit_semihosting per target
Richard Henderson [Thu, 28 Apr 2022 18:31:04 +0000 (11:31 -0700)]
semihosting: Split is_64bit_semihosting per target

We already have some larger ifdef blocks for ARM and RISCV;
split the function into multiple implementations per arch.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
23 months agosemihosting: Use struct gdb_stat in common_semi_flen_cb
Richard Henderson [Fri, 29 Apr 2022 21:55:21 +0000 (14:55 -0700)]
semihosting: Use struct gdb_stat in common_semi_flen_cb

Load the entire 64-bit size value.  While we're at it,
use offsetof instead of an integer constant.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
23 months agogdbstub: Convert GDB error numbers to host error numbers
Richard Henderson [Tue, 7 Jun 2022 19:38:26 +0000 (12:38 -0700)]
gdbstub: Convert GDB error numbers to host error numbers

Provide the callback with consistent state -- always use
host error numbers.  The individual callback can then
decide if the errno requires conversion for the guest.

Reviewed-by: Luc Michel <lmichel@kalray.eu>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
23 months agoinclude/exec: Define errno values in gdbstub.h
Richard Henderson [Mon, 2 May 2022 01:35:18 +0000 (18:35 -0700)]
include/exec: Define errno values in gdbstub.h

Define constants for the errno values defined by the
gdb remote fileio protocol.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
23 months agoinclude/exec: Move gdb_stat and gdb_timeval to gdbstub.h
Richard Henderson [Fri, 29 Apr 2022 21:41:37 +0000 (14:41 -0700)]
include/exec: Move gdb_stat and gdb_timeval to gdbstub.h

We have two copies of these structures, and require them
in semihosting/ going forward.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
23 months agoinclude/exec: Move gdb open flags to gdbstub.h
Richard Henderson [Thu, 28 Apr 2022 08:29:54 +0000 (01:29 -0700)]
include/exec: Move gdb open flags to gdbstub.h

There were 3 copies of these flags.  Place them in the
file with gdb_do_syscall, with which they belong.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
23 months agosemihosting: Remove GDB_O_BINARY
Richard Henderson [Tue, 7 Jun 2022 17:50:43 +0000 (10:50 -0700)]
semihosting: Remove GDB_O_BINARY

The value is zero, and gdb always opens files in binary mode.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
23 months agosemihosting: Move common-semi.h to include/semihosting/
Richard Henderson [Thu, 28 Apr 2022 08:14:02 +0000 (01:14 -0700)]
semihosting: Move common-semi.h to include/semihosting/

This header is not private to the top-level semihosting directory,
so place it in the public include directory.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
23 months agosemihosting: Return void from do_common_semihosting
Richard Henderson [Thu, 28 Apr 2022 08:10:55 +0000 (01:10 -0700)]
semihosting: Return void from do_common_semihosting

Perform the cleanup in the FIXME comment in common_semi_gdb_syscall.
Do not modify guest registers until the syscall is complete,
which in the gdbstub case is asynchronous.

In the synchronous non-gdbstub case, use common_semi_set_ret
to set the result.  Merge set_swi_errno into common_semi_cb.
Rely on the latter for combined return value / errno setting.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
23 months agosemihosting: Clean up common_semi_open_cb
Richard Henderson [Tue, 17 May 2022 02:37:14 +0000 (19:37 -0700)]
semihosting: Clean up common_semi_open_cb

Use common_semi_cb to return results instead of calling
set_swi_errno and common_semi_set_ret directly.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
23 months agosemihosting: Clean up common_semi_flen_cb
Richard Henderson [Tue, 17 May 2022 02:34:06 +0000 (19:34 -0700)]
semihosting: Clean up common_semi_flen_cb

Do not read from the gdb struct stat buffer if the callback is
reporting an error. Use common_semi_cb to finish returning results.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
23 months agosemihosting: Adjust error checking in common_semi_cb
Richard Henderson [Fri, 29 Apr 2022 19:32:24 +0000 (12:32 -0700)]
semihosting: Adjust error checking in common_semi_cb

The err parameter is non-zero if and only if an error occured.
Use this instead of ret == -1 for determining if we need to
update the saved errno.

This fixes the errno setting of SYS_ISTTY, which returns 0 on
error, not -1.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
23 months agosemihosting: Inline set_swi_errno into common_semi_cb
Richard Henderson [Tue, 17 May 2022 02:25:19 +0000 (19:25 -0700)]
semihosting: Inline set_swi_errno into common_semi_cb

Do not store 'err' into errno only to read it back immediately.
Use 'ret' for the return value, not 'reg0'.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
23 months agosemihosting: Split out guestfd.c
Richard Henderson [Thu, 28 Apr 2022 04:38:02 +0000 (21:38 -0700)]
semihosting: Split out guestfd.c

In arm-compat-semi.c, we have more advanced treatment of
guest file descriptors than we do in other implementations.
Split out GuestFD and related functions to a new file so
that they can be shared.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
23 months agosemihosting: Simplify softmmu_lock_user_string
Richard Henderson [Thu, 28 Apr 2022 04:06:58 +0000 (21:06 -0700)]
semihosting: Simplify softmmu_lock_user_string

We are not currently bounding the search to the 1024 bytes
that we allocated, possibly overrunning the buffer.
Use softmmu_strlen_user to find the length and allocate the
correct size from the beginning.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
23 months agosemihosting: Add target_strlen for softmmu-uaccess.h
Richard Henderson [Thu, 28 Apr 2022 04:03:12 +0000 (21:03 -0700)]
semihosting: Add target_strlen for softmmu-uaccess.h

Mirror the interface of the user-only function of the same name.
Use probe_access_flags for the common case of ram, and
cpu_memory_rw_debug for the uncommon case of mmio.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
v3: Use probe_access_flags (pmm)

23 months agoaccel/stubs: Add tcg stub for probe_access_flags
Richard Henderson [Sat, 21 May 2022 05:12:08 +0000 (22:12 -0700)]
accel/stubs: Add tcg stub for probe_access_flags

Reviewed-by: Luc Michel <lmichel@kalray.eu>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
23 months agosemihosting: Move softmmu-uaccess.h functions out of line
Richard Henderson [Thu, 28 Apr 2022 03:44:17 +0000 (20:44 -0700)]
semihosting: Move softmmu-uaccess.h functions out of line

Rather that static (and not even inline) functions within a
header, move the functions to semihosting/uaccess.c.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
23 months agosemihosting: Improve condition for config.c and console.c
Richard Henderson [Sat, 30 Apr 2022 01:32:35 +0000 (18:32 -0700)]
semihosting: Improve condition for config.c and console.c

While CONFIG_SEMIHOSTING is currently only set for softmmu,
this will not continue to be true.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
23 months agosemihosting: Return failure from softmmu-uaccess.h functions
Richard Henderson [Thu, 28 Apr 2022 03:01:24 +0000 (20:01 -0700)]
semihosting: Return failure from softmmu-uaccess.h functions

We were reporting unconditional success for these functions;
pass on any failure from cpu_memory_rw_debug.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
23 months agosemihosting: Move exec/softmmu-semi.h to semihosting/softmmu-uaccess.h
Richard Henderson [Thu, 28 Apr 2022 03:48:41 +0000 (20:48 -0700)]
semihosting: Move exec/softmmu-semi.h to semihosting/softmmu-uaccess.h

We have a subdirectory for semihosting; move this file out of exec.
Rename to emphasize the contents are a replacement for the functions
in linux-user/bsd-user uaccess.c.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
23 months agoinclude/hw/virtio: document vhost_ack_features
Alex Bennée [Tue, 24 May 2022 15:40:45 +0000 (16:40 +0100)]
include/hw/virtio: document vhost_ack_features

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20220524154056.2896913-5-alex.bennee@linaro.org>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
23 months agoinclude/hw/virtio: document vhost_get_features
Alex Bennée [Tue, 24 May 2022 15:40:44 +0000 (16:40 +0100)]
include/hw/virtio: document vhost_get_features

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20220524154056.2896913-4-alex.bennee@linaro.org>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
23 months agocontrib/vhost-user-blk: fix 32 bit build and enable
Alex Bennée [Tue, 24 May 2022 15:40:42 +0000 (16:40 +0100)]
contrib/vhost-user-blk: fix 32 bit build and enable

We were not building the vhost-user-blk server due to 32 bit
compilation problems. The problem was due to format string types so
fix that and then enable the build. Tweak the rule to follow the same
rules as other vhost-user daemons.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20220321153037.3622127-12-alex.bennee@linaro.org>
Message-Id: <20220524154056.2896913-2-alex.bennee@linaro.org>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Raphael Norwitz <raphael.norwitz@nutanix.com>
23 months agoMAINTAINERS: Collect memory device files in "Memory devices"
David Hildenbrand [Fri, 17 Jun 2022 12:31:51 +0000 (14:31 +0200)]
MAINTAINERS: Collect memory device files in "Memory devices"

Xiao Guangrong doesn't have enough time to actively review or contribute
to our NVDIMM implementation. Let's dissolve the "NVDIMM" section, moving
relevant ACPI parts to "ACPI/SMBIOS" and moving memory device stuff into a
new "Memory devices" section. Make that new section cover other memory
device stuff as well.

We can now drop the "hw/mem/*" rule from "ACPI/SMBIOS". Note that
hw/acpi/nvdimm.c is already covered by "ACPI/SMBIOS".

The following files in hw/mem don't fall into the TYPE_MEMPORY_DEVICE
category:
* hw/mem/cxl_type3.c is CXL specific and belongs to "Compute Express Link"
* hw/mem/sparse-mem.c is already covered by "Device Fuzzing"
* hw/mem/npcm7xx_mc.c is already covered by "Nuvoton NPCM7xx"

Thanks Xiao for your work on NVDIMM!

Cc: Ben Widawsky <ben.widawsky@intel.com>
Cc: Jonathan Cameron <jonathan.cameron@huawei.com>
Cc: Michael S. Tsirkin <mst@redhat.com>
Cc: Igor Mammedov <imammedo@redhat.com>
Cc: Ani Sinha <ani@anisinha.ca>
Cc: Xiao Guangrong <xiaoguangrong.eric@gmail.com>
Cc: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
Cc: Richard Henderson <richard.henderson@linaro.org>
Cc: Peter Maydell <peter.maydell@linaro.org>
Cc: Julia Suvorova <jusual@redhat.com>
Signed-off-by: David Hildenbrand <david@redhat.com>
Message-Id: <20220617123151.103033-1-david@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
23 months agolibvhost-user: Fix VHOST_USER_ADD_MEM_REG reply
Kevin Wolf [Mon, 27 Jun 2022 13:45:00 +0000 (15:45 +0200)]
libvhost-user: Fix VHOST_USER_ADD_MEM_REG reply

With REPLY_NEEDED, libvhost-user sends both the acutal result and an
additional ACK reply for VHOST_USER_ADD_MEM_REG. This is incorrect, the
spec mandates that it behave the same with and without REPLY_NEEDED
because it always sends a reply.

Fixes: ec94c8e621de96c50c2d381c8c9ec94f5beec7c1
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Message-Id: <20220627134500.94842-4-kwolf@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
23 months agolibvhost-user: Fix VHOST_USER_GET_MAX_MEM_SLOTS reply
Kevin Wolf [Mon, 27 Jun 2022 13:44:59 +0000 (15:44 +0200)]
libvhost-user: Fix VHOST_USER_GET_MAX_MEM_SLOTS reply

With REPLY_NEEDED, libvhost-user sends both the acutal result and an
additional ACK reply for VHOST_USER_GET_MAX_MEM_SLOTS. This is
incorrect, the spec mandates that it behave the same with and without
REPLY_NEEDED because it always sends a reply.

Fixes: 6fb2e173d20c9bbb5466183d33a3ad7dcd0375fa
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Message-Id: <20220627134500.94842-3-kwolf@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>