Skip to content

Commit

Permalink
Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging
Browse files Browse the repository at this point in the history
* Optional use of Meson wrap for slirp
* Coverity fixes
* Avoid -Werror=maybe-uninitialized
* Mark coroutine QMP command functions as coroutine_fn
* Mark functions that suspend as coroutine_mixed_fn
* target/i386: Fix SGX CPUID leaf
* First batch of qatomic_mb_read() removal
* Small atomic.rst improvement
* NBD cleanup
* Update libvirt-ci submodule

# -----BEGIN PGP SIGNATURE-----
#
# iQFIBAABCAAyFiEE8TM4V0tmI4mGbHaCv/vSX3jHroMFAmRBAzwUHHBib256aW5p
# QHJlZGhhdC5jb20ACgkQv/vSX3jHroP64gf+NzLW95tylCfhKuuLq/TjuOTQqHCD
# KVLlA1I3pwJfk4SUuigrnaJtwfa/tBiWxfaivUdPAzPzeXyxcVSOps0neohrmFBh
# 2e3ylBWWz22K0gkLtrFwJT99TVy6w6Xhj9SX8HPRfxl4k8yMPrUJNW78hh6APAwq
# /etZY6+ieHC7cwG4xluhxsHnxnBYBYD+18hUd+b5LchD/yvCSCNNiursutpa0Ar/
# r/HtDwNFKlaApO3sU4R3yYgdS1Fvcas4tDZaumADsQlSG5z+UeJldc98LiRlFrAA
# gnskBSaaly/NgWqY3hVCYaBGyjD4lWPkX/FEChi0XX6Fl1P0umQAv/7z3w==
# =XSAs
# -----END PGP SIGNATURE-----
# gpg: Signature made Thu 20 Apr 2023 10:17:48 AM BST
# gpg:                using RSA key F13338574B662389866C7682BFFBD25F78C7AE83
# gpg:                issuer "pbonzini@redhat.com"
# gpg: Good signature from "Paolo Bonzini <bonzini@gnu.org>" [undefined]
# gpg:                 aka "Paolo Bonzini <pbonzini@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: 46F5 9FBD 57D6 12E7 BFD4  E2F7 7E15 100C CD36 69B1
#      Subkey fingerprint: F133 3857 4B66 2389 866C  7682 BFFB D25F 78C7 AE83

* tag 'for-upstream' of https://gitlab.com/bonzini/qemu: (25 commits)
  tests: lcitool: Switch to OpenSUSE Leap 15.4
  tests: libvirt-ci: Update to commit '2fa24dce8bc'
  configure: Honour cross-prefix when finding ObjC compiler
  coverity: unify Fedora dockerfiles
  nbd: a BlockExport always has a BlockBackend
  docs: explain effect of smp_read_barrier_depends() on modern architectures
  qemu-coroutine: remove qatomic_mb_read()
  postcopy-ram: do not use qatomic_mb_read
  block-backend: remove qatomic_mb_read()
  target/i386: Change wrong XFRM value in SGX CPUID leaf
  monitor: mark mixed functions that can suspend
  migration: mark mixed functions that can suspend
  io: mark mixed functions that can suspend
  qapi-gen: mark coroutine QMP command functions as coroutine_fn
  target/mips: tcg: detect out-of-bounds accesses to cpu_gpr and cpu_gpr_hi
  coverity: update COMPONENTS.md
  lasi: fix RTC migration
  target/i386: Avoid unreachable variable declaration in mmu_translate()
  configure: Avoid -Werror=maybe-uninitialized
  tests: bios-tables-test: replace memset with initializer
  ...

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
  • Loading branch information
rth7680 committed Apr 22, 2023
2 parents 4560865 + 5f9efbb commit 1cc6e1a
Show file tree
Hide file tree
Showing 45 changed files with 425 additions and 396 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ GTAGS
*.swp
*.patch
*.gcov

/subprojects/slirp
4 changes: 2 additions & 2 deletions block/block-backend.c
Original file line number Diff line number Diff line change
Expand Up @@ -1845,7 +1845,7 @@ void blk_drain(BlockBackend *blk)

/* We may have -ENOMEDIUM completions in flight */
AIO_WAIT_WHILE(blk_get_aio_context(blk),
qatomic_mb_read(&blk->in_flight) > 0);
qatomic_read(&blk->in_flight) > 0);

if (bs) {
bdrv_drained_end(bs);
Expand All @@ -1867,7 +1867,7 @@ void blk_drain_all(void)
aio_context_acquire(ctx);

/* We may have -ENOMEDIUM completions in flight */
AIO_WAIT_WHILE(ctx, qatomic_mb_read(&blk->in_flight) > 0);
AIO_WAIT_WHILE(ctx, qatomic_read(&blk->in_flight) > 0);

aio_context_release(ctx);
}
Expand Down
40 changes: 25 additions & 15 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,8 @@ for opt do
;;
--cxx=*) CXX="$optarg"
;;
--objcc=*) objcc="$optarg"
;;
--cpu=*) cpu="$optarg"
;;
--extra-cflags=*)
Expand Down Expand Up @@ -361,6 +363,21 @@ else
cxx="${CXX-${cross_prefix}g++}"
fi

# Preferred ObjC compiler:
# $objcc (if set, i.e. via --objcc option)
# ${cross_prefix}clang (if cross-prefix specified)
# clang (if available)
# $cc
if test -z "${objcc}${cross_prefix}"; then
if has clang; then
objcc=clang
else
objcc="$cc"
fi
else
objcc="${objcc-${cross_prefix}clang}"
fi

ar="${AR-${cross_prefix}ar}"
as="${AS-${cross_prefix}as}"
ccas="${CCAS-$cc}"
Expand Down Expand Up @@ -647,13 +664,6 @@ do
fi
done

# Default objcc to clang if available, otherwise use CC
if has clang; then
objcc=clang
else
objcc="$cc"
fi

if test "$mingw32" = "yes" ; then
EXESUF=".exe"
# MinGW needs -mthreads for TLS and macro _MT.
Expand Down Expand Up @@ -713,7 +723,7 @@ for opt do
;;
--cxx=*)
;;
--objcc=*) objcc="$optarg"
--objcc=*)
;;
--make=*) make="$optarg"
;;
Expand Down Expand Up @@ -1749,13 +1759,9 @@ if test "$sanitizers" = "yes" ; then
# detect the static linking issue of ubsan, see also:
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84285
cat > $TMPC << EOF
#include <stdlib.h>
int main(void) {
void *tmp = malloc(10);
if (tmp != NULL) {
return *(int *)(tmp + 2);
}
return 1;
int main(int argc, char **argv)
{
return argc + 1;
}
EOF
if compile_prog "$CPU_CFLAGS -Werror -fsanitize=undefined" ""; then
Expand Down Expand Up @@ -2615,6 +2621,10 @@ if test "$skip_meson" = no; then

rm -rf meson-private meson-info meson-logs

# Prevent meson from automatically downloading wrapped subprojects when missing.
# You can use 'meson subprojects download' before running configure.
meson_option_add "--wrap-mode=nodownload"

# Built-in options
test "$bindir" != "bin" && meson_option_add "-Dbindir=$bindir"
test "$default_feature" = no && meson_option_add -Dauto_features=disabled
Expand Down
11 changes: 7 additions & 4 deletions docs/devel/atomics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -220,17 +220,20 @@ They come in six kinds:
retrieves the address to which the second load will be directed),
the processor will guarantee that the first LOAD will appear to happen
before the second with respect to the other components of the system.
However, this is not always true---for example, it was not true on
Alpha processors. Whenever this kind of access happens to shared
memory (that is not protected by a lock), a read barrier is needed,
and ``smp_read_barrier_depends()`` can be used instead of ``smp_rmb()``.
Therefore, unlike ``smp_rmb()`` or ``qatomic_load_acquire()``,
``smp_read_barrier_depends()`` can be just a compiler barrier on
weakly-ordered architectures such as Arm or PPC[#]_.

Note that the first load really has to have a _data_ dependency and not
a control dependency. If the address for the second load is dependent
on the first load, but the dependency is through a conditional rather
than actually loading the address itself, then it's a _control_
dependency and a full read barrier or better is required.

.. [#] The DEC Alpha is an exception, because ``smp_read_barrier_depends()``
needs a processor barrier. On strongly-ordered architectures such
as x86 or s390, ``smp_rmb()`` and ``qatomic_load_acquire()`` can
also be compiler barriers only.
Memory barriers and ``qatomic_load_acquire``/``qatomic_store_release`` are
mostly used when a data structure has one thread that is always a writer
Expand Down
4 changes: 2 additions & 2 deletions hw/misc/lasi.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ static const MemoryRegionOps lasi_chip_ops = {

static const VMStateDescription vmstate_lasi = {
.name = "Lasi",
.version_id = 1,
.version_id = 2,
.minimum_version_id = 1,
.fields = (VMStateField[]) {
VMSTATE_UINT32(irr, LasiState),
Expand All @@ -204,6 +204,7 @@ static const VMStateDescription vmstate_lasi = {
VMSTATE_UINT32(iar, LasiState),
VMSTATE_UINT32(errlog, LasiState),
VMSTATE_UINT32(amr, LasiState),
VMSTATE_UINT32_V(rtc_ref, LasiState, 2),
VMSTATE_END_OF_LIST()
}
};
Expand Down Expand Up @@ -233,7 +234,6 @@ static void lasi_reset(DeviceState *dev)
s->iar = 0xFFFB0000 + 3; /* CPU_HPA + 3 */

/* Real time clock (RTC), it's only one 32-bit counter @9000 */
s->rtc = time(NULL);
s->rtc_ref = 0;
}

Expand Down
4 changes: 1 addition & 3 deletions hw/nvme/ctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -7158,9 +7158,7 @@ static int nvme_start_ctrl(NvmeCtrl *n)

if (pci_is_vf(PCI_DEVICE(n)) && !sctrl->scs) {
trace_pci_nvme_err_startfail_virt_state(le16_to_cpu(sctrl->nvi),
le16_to_cpu(sctrl->nvq),
sctrl->scs ? "ONLINE" :
"OFFLINE");
le16_to_cpu(sctrl->nvq));
return -1;
}
if (unlikely(n->cq[0])) {
Expand Down
2 changes: 1 addition & 1 deletion hw/nvme/trace-events
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ pci_nvme_err_startfail_asqent_sz_zero(void) "nvme_start_ctrl failed because the
pci_nvme_err_startfail_acqent_sz_zero(void) "nvme_start_ctrl failed because the admin completion queue size is zero"
pci_nvme_err_startfail_zasl_too_small(uint32_t zasl, uint32_t pagesz) "nvme_start_ctrl failed because zone append size limit %"PRIu32" is too small, needs to be >= %"PRIu32""
pci_nvme_err_startfail(void) "setting controller enable bit failed"
pci_nvme_err_startfail_virt_state(uint16_t vq, uint16_t vi, const char *state) "nvme_start_ctrl failed due to ctrl state: vi=%u vq=%u %s"
pci_nvme_err_startfail_virt_state(uint16_t vq, uint16_t vi) "nvme_start_ctrl failed due to ctrl state: vi=%u vq=%u"
pci_nvme_err_invalid_mgmt_action(uint8_t action) "action=0x%"PRIx8""
pci_nvme_err_ignored_mmio_vf_offline(uint64_t addr, unsigned size) "addr 0x%"PRIx64" size %d"

Expand Down
3 changes: 1 addition & 2 deletions include/hw/misc/lasi.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ struct LasiState {

uint32_t errlog;
uint32_t amr;
uint32_t rtc;
time_t rtc_ref;
uint32_t rtc_ref;

MemoryRegion this_mem;
};
Expand Down
78 changes: 39 additions & 39 deletions include/io/channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -301,10 +301,10 @@ ssize_t qio_channel_writev_full(QIOChannel *ioc,
* Returns: 1 if all bytes were read, 0 if end-of-file
* occurs without data, or -1 on error
*/
int qio_channel_readv_all_eof(QIOChannel *ioc,
const struct iovec *iov,
size_t niov,
Error **errp);
int coroutine_mixed_fn qio_channel_readv_all_eof(QIOChannel *ioc,
const struct iovec *iov,
size_t niov,
Error **errp);

/**
* qio_channel_readv_all:
Expand All @@ -328,10 +328,10 @@ int qio_channel_readv_all_eof(QIOChannel *ioc,
*
* Returns: 0 if all bytes were read, or -1 on error
*/
int qio_channel_readv_all(QIOChannel *ioc,
const struct iovec *iov,
size_t niov,
Error **errp);
int coroutine_mixed_fn qio_channel_readv_all(QIOChannel *ioc,
const struct iovec *iov,
size_t niov,
Error **errp);


/**
Expand All @@ -353,10 +353,10 @@ int qio_channel_readv_all(QIOChannel *ioc,
*
* Returns: 0 if all bytes were written, or -1 on error
*/
int qio_channel_writev_all(QIOChannel *ioc,
const struct iovec *iov,
size_t niov,
Error **errp);
int coroutine_mixed_fn qio_channel_writev_all(QIOChannel *ioc,
const struct iovec *iov,
size_t niov,
Error **errp);

/**
* qio_channel_readv:
Expand Down Expand Up @@ -437,10 +437,10 @@ ssize_t qio_channel_write(QIOChannel *ioc,
* Returns: 1 if all bytes were read, 0 if end-of-file occurs
* without data, or -1 on error
*/
int qio_channel_read_all_eof(QIOChannel *ioc,
char *buf,
size_t buflen,
Error **errp);
int coroutine_mixed_fn qio_channel_read_all_eof(QIOChannel *ioc,
char *buf,
size_t buflen,
Error **errp);

/**
* qio_channel_read_all:
Expand All @@ -457,10 +457,10 @@ int qio_channel_read_all_eof(QIOChannel *ioc,
*
* Returns: 0 if all bytes were read, or -1 on error
*/
int qio_channel_read_all(QIOChannel *ioc,
char *buf,
size_t buflen,
Error **errp);
int coroutine_mixed_fn qio_channel_read_all(QIOChannel *ioc,
char *buf,
size_t buflen,
Error **errp);

/**
* qio_channel_write_all:
Expand All @@ -476,10 +476,10 @@ int qio_channel_read_all(QIOChannel *ioc,
*
* Returns: 0 if all bytes were written, or -1 on error
*/
int qio_channel_write_all(QIOChannel *ioc,
const char *buf,
size_t buflen,
Error **errp);
int coroutine_mixed_fn qio_channel_write_all(QIOChannel *ioc,
const char *buf,
size_t buflen,
Error **errp);

/**
* qio_channel_set_blocking:
Expand Down Expand Up @@ -812,11 +812,11 @@ void qio_channel_set_aio_fd_handler(QIOChannel *ioc,
* occurs without data, or -1 on error
*/

int qio_channel_readv_full_all_eof(QIOChannel *ioc,
const struct iovec *iov,
size_t niov,
int **fds, size_t *nfds,
Error **errp);
int coroutine_mixed_fn qio_channel_readv_full_all_eof(QIOChannel *ioc,
const struct iovec *iov,
size_t niov,
int **fds, size_t *nfds,
Error **errp);

/**
* qio_channel_readv_full_all:
Expand All @@ -838,11 +838,11 @@ int qio_channel_readv_full_all_eof(QIOChannel *ioc,
* Returns: 0 if all bytes were read, or -1 on error
*/

int qio_channel_readv_full_all(QIOChannel *ioc,
const struct iovec *iov,
size_t niov,
int **fds, size_t *nfds,
Error **errp);
int coroutine_mixed_fn qio_channel_readv_full_all(QIOChannel *ioc,
const struct iovec *iov,
size_t niov,
int **fds, size_t *nfds,
Error **errp);

/**
* qio_channel_writev_full_all:
Expand Down Expand Up @@ -872,11 +872,11 @@ int qio_channel_readv_full_all(QIOChannel *ioc,
* Returns: 0 if all bytes were written, or -1 on error
*/

int qio_channel_writev_full_all(QIOChannel *ioc,
const struct iovec *iov,
size_t niov,
int *fds, size_t nfds,
int flags, Error **errp);
int coroutine_mixed_fn qio_channel_writev_full_all(QIOChannel *ioc,
const struct iovec *iov,
size_t niov,
int *fds, size_t nfds,
int flags, Error **errp);

/**
* qio_channel_flush:
Expand Down
4 changes: 2 additions & 2 deletions include/migration/qemu-file-types.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void qemu_put_byte(QEMUFile *f, int v);
void qemu_put_be16(QEMUFile *f, unsigned int v);
void qemu_put_be32(QEMUFile *f, unsigned int v);
void qemu_put_be64(QEMUFile *f, uint64_t v);
size_t qemu_get_buffer(QEMUFile *f, uint8_t *buf, size_t size);
size_t coroutine_mixed_fn qemu_get_buffer(QEMUFile *f, uint8_t *buf, size_t size);

int qemu_get_byte(QEMUFile *f);

Expand Down Expand Up @@ -161,7 +161,7 @@ static inline void qemu_get_sbe64s(QEMUFile *f, int64_t *pv)
qemu_get_be64s(f, (uint64_t *)pv);
}

size_t qemu_get_counted_string(QEMUFile *f, char buf[256]);
size_t coroutine_mixed_fn qemu_get_counted_string(QEMUFile *f, char buf[256]);

void qemu_put_counted_string(QEMUFile *f, const char *name);

Expand Down
4 changes: 2 additions & 2 deletions include/qapi/qmp/dispatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ bool qmp_command_available(const QmpCommand *cmd, Error **errp);
const char *qmp_command_name(const QmpCommand *cmd);
bool qmp_has_success_response(const QmpCommand *cmd);
QDict *qmp_error_response(Error *err);
QDict *qmp_dispatch(const QmpCommandList *cmds, QObject *request,
bool allow_oob, Monitor *cur_mon);
QDict *coroutine_mixed_fn qmp_dispatch(const QmpCommandList *cmds, QObject *request,
bool allow_oob, Monitor *cur_mon);
bool qmp_is_oob(const QDict *dict);

typedef void (*qmp_cmd_callback_fn)(const QmpCommand *cmd, void *opaque);
Expand Down

0 comments on commit 1cc6e1a

Please sign in to comment.