From e7c2d7436e85ae6d1d72b7479c1137faa86f4f58 Mon Sep 17 00:00:00 2001 From: Yonggang Luo Date: Wed, 23 Mar 2022 16:07:55 +0800 Subject: [PATCH 1/6] misc: Fixes MAINTAINERS's path .github/workflows/lockdown.yml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Yonggang Luo Message-Id: <20220323080755.156-4-luoyonggang@gmail.com> Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Thomas Huth --- MAINTAINERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MAINTAINERS b/MAINTAINERS index cc364afef7..d8b2601981 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -3615,7 +3615,7 @@ M: Thomas Huth R: Wainer dos Santos Moschetta R: Beraldo Leal S: Maintained -F: .github/lockdown.yml +F: .github/workflows/lockdown.yml F: .gitlab-ci.yml F: .gitlab-ci.d/ F: .travis.yml From 5a2e67a691501bc4dd81c46c81b8f1881c8bd5df Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Wed, 23 Mar 2022 17:26:20 +0100 Subject: [PATCH 2/6] target/s390x: Fix determination of overflow condition code after addition This program currently prints different results when run with TCG instead of running on real s390x hardware: #include int overflow_32 (int x, int y) { int sum; return ! __builtin_add_overflow (x, y, &sum); } int overflow_64 (long long x, long long y) { long sum; return ! __builtin_add_overflow (x, y, &sum); } int a1 = -2147483648; int b1 = -2147483648; long long a2 = -9223372036854775808L; long long b2 = -9223372036854775808L; int main () { { int a = a1; int b = b1; printf ("a = 0x%x, b = 0x%x\n", a, b); printf ("no_overflow = %d\n", overflow_32 (a, b)); } { long long a = a2; long long b = b2; printf ("a = 0x%llx, b = 0x%llx\n", a, b); printf ("no_overflow = %d\n", overflow_64 (a, b)); } } Signed-off-by: Bruno Haible Resolves: https://gitlab.com/qemu-project/qemu/-/issues/616 Message-Id: <20220323162621.139313-2-thuth@redhat.com> Signed-off-by: Thomas Huth --- target/s390x/tcg/cc_helper.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/s390x/tcg/cc_helper.c b/target/s390x/tcg/cc_helper.c index 8d04097f78..e11cdb745d 100644 --- a/target/s390x/tcg/cc_helper.c +++ b/target/s390x/tcg/cc_helper.c @@ -136,7 +136,7 @@ static uint32_t cc_calc_subu(uint64_t borrow_out, uint64_t result) static uint32_t cc_calc_add_64(int64_t a1, int64_t a2, int64_t ar) { - if ((a1 > 0 && a2 > 0 && ar < 0) || (a1 < 0 && a2 < 0 && ar > 0)) { + if ((a1 > 0 && a2 > 0 && ar < 0) || (a1 < 0 && a2 < 0 && ar >= 0)) { return 3; /* overflow */ } else { if (ar < 0) { @@ -196,7 +196,7 @@ static uint32_t cc_calc_comp_64(int64_t dst) static uint32_t cc_calc_add_32(int32_t a1, int32_t a2, int32_t ar) { - if ((a1 > 0 && a2 > 0 && ar < 0) || (a1 < 0 && a2 < 0 && ar > 0)) { + if ((a1 > 0 && a2 > 0 && ar < 0) || (a1 < 0 && a2 < 0 && ar >= 0)) { return 3; /* overflow */ } else { if (ar < 0) { From fc6e0d0f2db5126592bb4066d484fcdfc14ccf36 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Wed, 23 Mar 2022 17:26:21 +0100 Subject: [PATCH 3/6] target/s390x: Fix determination of overflow condition code after subtraction Reported by Paul Eggert in https://lists.gnu.org/archive/html/bug-gnulib/2021-09/msg00050.html This program currently prints different results when run with TCG instead of running on real s390x hardware: #include int overflow_32 (int x, int y) { int sum; return __builtin_sub_overflow (x, y, &sum); } int overflow_64 (long long x, long long y) { long sum; return __builtin_sub_overflow (x, y, &sum); } int a1 = 0; int b1 = -2147483648; long long a2 = 0L; long long b2 = -9223372036854775808L; int main () { { int a = a1; int b = b1; printf ("a = 0x%x, b = 0x%x\n", a, b); printf ("no_overflow = %d\n", ! overflow_32 (a, b)); } { long long a = a2; long long b = b2; printf ("a = 0x%llx, b = 0x%llx\n", a, b); printf ("no_overflow = %d\n", ! overflow_64 (a, b)); } } Signed-off-by: Bruno Haible Resolves: https://gitlab.com/qemu-project/qemu/-/issues/618 Message-Id: <20220323162621.139313-3-thuth@redhat.com> Signed-off-by: Thomas Huth --- target/s390x/tcg/cc_helper.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/s390x/tcg/cc_helper.c b/target/s390x/tcg/cc_helper.c index e11cdb745d..b2e8d3d9f5 100644 --- a/target/s390x/tcg/cc_helper.c +++ b/target/s390x/tcg/cc_helper.c @@ -151,7 +151,7 @@ static uint32_t cc_calc_add_64(int64_t a1, int64_t a2, int64_t ar) static uint32_t cc_calc_sub_64(int64_t a1, int64_t a2, int64_t ar) { - if ((a1 > 0 && a2 < 0 && ar < 0) || (a1 < 0 && a2 > 0 && ar > 0)) { + if ((a1 >= 0 && a2 < 0 && ar < 0) || (a1 < 0 && a2 > 0 && ar > 0)) { return 3; /* overflow */ } else { if (ar < 0) { @@ -211,7 +211,7 @@ static uint32_t cc_calc_add_32(int32_t a1, int32_t a2, int32_t ar) static uint32_t cc_calc_sub_32(int32_t a1, int32_t a2, int32_t ar) { - if ((a1 > 0 && a2 < 0 && ar < 0) || (a1 < 0 && a2 > 0 && ar > 0)) { + if ((a1 >= 0 && a2 < 0 && ar < 0) || (a1 < 0 && a2 > 0 && ar > 0)) { return 3; /* overflow */ } else { if (ar < 0) { From 54c9b19421895eddac19444c1de705ef0ddbfe95 Mon Sep 17 00:00:00 2001 From: Thomas Huth Date: Wed, 30 Mar 2022 13:48:08 +0200 Subject: [PATCH 4/6] meson.build: Fix dependency of page-vary-common.c to config-poison.h Before compiling page-vary-common.c, we have to make sure that config-poison.h has been generated (which is in the "genh" list). Signed-off-by: Thomas Huth Reviewed-by: Richard Henderson Resolves: https://gitlab.com/qemu-project/qemu/-/issues/948 Message-Id: <20220330114808.942933-1-thuth@redhat.com> Signed-off-by: Thomas Huth --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index aef724ad3c..04ce33fef1 100644 --- a/meson.build +++ b/meson.build @@ -2881,7 +2881,7 @@ if get_option('b_lto') if get_option('cfi') pagevary_flags += '-fno-sanitize=cfi-icall' endif - pagevary = static_library('page-vary-common', sources: pagevary, + pagevary = static_library('page-vary-common', sources: pagevary + genh, c_args: pagevary_flags) pagevary = declare_dependency(link_with: pagevary) endif From a136d17590a03ad4cf4fabeffe49d246b9130103 Mon Sep 17 00:00:00 2001 From: Will Cohen Date: Thu, 31 Mar 2022 14:26:51 -0400 Subject: [PATCH 5/6] 9p: move P9_XATTR_SIZE_MAX from 9p.h to 9p.c The patch set adding 9p functionality to darwin introduced an issue where limits.h, which defines XATTR_SIZE_MAX, is included in 9p.c, though the referenced constant is needed in 9p.h. This commit fixes that issue by moving the definition of P9_XATTR_SIZE_MAX, which uses XATTR_SIZE_MAX, to also be in 9p.c. Additionally, this commit moves the location of the system headers include in 9p.c to occur before the project headers (except osdep.h). Resolves: https://gitlab.com/qemu-project/qemu/-/issues/950 Fixes: 38d7fd68b0 ("9p: darwin: Move XATTR_SIZE_MAX->P9_XATTR_SIZE_MAX") Signed-off-by: Will Cohen Message-Id: <20220331182651.887-1-wwcohen@gmail.com> [thuth: Adjusted placement of osdep.h] Signed-off-by: Thomas Huth --- hw/9pfs/9p.c | 28 +++++++++++++++++++++++----- hw/9pfs/9p.h | 18 ------------------ 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index dcaa602d4c..225f31fc31 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -17,6 +17,11 @@ */ #include "qemu/osdep.h" +#ifdef CONFIG_LINUX +#include +#else +#include +#endif #include #include "hw/virtio/virtio.h" #include "qapi/error.h" @@ -33,11 +38,6 @@ #include "migration/blocker.h" #include "qemu/xxhash.h" #include -#ifdef CONFIG_LINUX -#include -#else -#include -#endif int open_fd_hw; int total_open_fd; @@ -3925,6 +3925,24 @@ out_nofid: v9fs_string_free(&name); } +#if defined(CONFIG_LINUX) +/* Currently, only Linux has XATTR_SIZE_MAX */ +#define P9_XATTR_SIZE_MAX XATTR_SIZE_MAX +#elif defined(CONFIG_DARWIN) +/* + * Darwin doesn't seem to define a maximum xattr size in its user + * space header, so manually configure it across platforms as 64k. + * + * Having no limit at all can lead to QEMU crashing during large g_malloc() + * calls. Because QEMU does not currently support macOS guests, the below + * preliminary solution only works due to its being a reflection of the limit of + * Linux guests. + */ +#define P9_XATTR_SIZE_MAX 65536 +#else +#error Missing definition for P9_XATTR_SIZE_MAX for this host system +#endif + static void coroutine_fn v9fs_xattrcreate(void *opaque) { int flags, rflags = 0; diff --git a/hw/9pfs/9p.h b/hw/9pfs/9p.h index af2635fae9..994f952600 100644 --- a/hw/9pfs/9p.h +++ b/hw/9pfs/9p.h @@ -479,22 +479,4 @@ struct V9fsTransport { void (*push_and_notify)(V9fsPDU *pdu); }; -#if defined(XATTR_SIZE_MAX) -/* Linux */ -#define P9_XATTR_SIZE_MAX XATTR_SIZE_MAX -#elif defined(CONFIG_DARWIN) -/* - * Darwin doesn't seem to define a maximum xattr size in its user - * space header, so manually configure it across platforms as 64k. - * - * Having no limit at all can lead to QEMU crashing during large g_malloc() - * calls. Because QEMU does not currently support macOS guests, the below - * preliminary solution only works due to its being a reflection of the limit of - * Linux guests. - */ -#define P9_XATTR_SIZE_MAX 65536 -#else -#error Missing definition for P9_XATTR_SIZE_MAX for this host system -#endif - #endif From e32aaa5a19e24233180042f84a0235a209de71cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Mon, 28 Mar 2022 12:47:13 +0400 Subject: [PATCH 6/6] trace: fix compilation with lttng-ust >= 2.13 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On Fedora 36, with lttng-ust 2.13.1, compilation fails with: In file included from trace/trace-ust-all.h:49085, from trace/trace-ust-all.c:13: /usr/include/lttng/tracepoint-event.h:67:10: error: #include expects "FILENAME" or 67 | #include LTTNG_UST_TRACEPOINT_INCLUDE | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ In lttng-ust commit 41858e2b6e8 ("Fix: don't do macro expansion in tracepoint file name") from 2012, starting from lttng-ust 2.1, the API was changed to expect TRACEPOINT_INCLUDE to be defined as a string. In lttng-ust commit d2966b4b0b2 ("Remove TRACEPOINT_INCLUDE_FILE macro"), in 2021, the compatibility macro was removed. Use the "new" API from 2012, and bump the version requirement to 2.1 to fix compilation with >= 2.13. According to repology, all distributions we support have >= 2.1 (centos 8 has oldest with 2.8.1 afaict) Signed-off-by: Marc-André Lureau Reviewed-by: Stefan Hajnoczi Message-Id: <20220328084717.367993-2-marcandre.lureau@redhat.com> Signed-off-by: Thomas Huth --- meson.build | 4 ++-- scripts/tracetool/format/ust_events_h.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/meson.build b/meson.build index 04ce33fef1..861de93c4f 100644 --- a/meson.build +++ b/meson.build @@ -455,8 +455,8 @@ if 'CONFIG_GIO' in config_host endif lttng = not_found if 'ust' in get_option('trace_backends') - lttng = dependency('lttng-ust', required: true, method: 'pkg-config', - kwargs: static_kwargs) + lttng = dependency('lttng-ust', required: true, version: '>= 2.1', + method: 'pkg-config', kwargs: static_kwargs) endif pixman = not_found if have_system or have_tools diff --git a/scripts/tracetool/format/ust_events_h.py b/scripts/tracetool/format/ust_events_h.py index 6ce559f6cc..b99fe6896b 100644 --- a/scripts/tracetool/format/ust_events_h.py +++ b/scripts/tracetool/format/ust_events_h.py @@ -29,8 +29,8 @@ def generate(events, backend, group): '#undef TRACEPOINT_PROVIDER', '#define TRACEPOINT_PROVIDER qemu', '', - '#undef TRACEPOINT_INCLUDE_FILE', - '#define TRACEPOINT_INCLUDE_FILE ./%s' % include, + '#undef TRACEPOINT_INCLUDE', + '#define TRACEPOINT_INCLUDE "./%s"' % include, '', '#if !defined (TRACE_%s_GENERATED_UST_H) || \\' % group.upper(), ' defined(TRACEPOINT_HEADER_MULTI_READ)',