From 82918d8df95dae11907161123726522efd6b9c64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Cerqueira?= Date: Mon, 3 Jul 2023 18:41:12 +0100 Subject: [PATCH 1/2] qemu: update to 8.0.2. --- srcpkgs/qemu/patches/CVE-2023-2861.patch | 177 ++++++++++++++++++ .../qemu/patches/fix-linux-user-ppc32.patch | 117 ------------ .../patches/fix-softfloat-fesetround.patch | 39 ---- srcpkgs/qemu/patches/gcc12.patch | 72 ------- srcpkgs/qemu/patches/keymap.patch | 47 +++++ srcpkgs/qemu/patches/mmap-mremap-efault.patch | 42 ----- .../qemu/patches/musl-initialize-msghdr.patch | 6 +- srcpkgs/qemu/patches/musl-ppc.patch | 25 --- srcpkgs/qemu/patches/musl-rlimit-rttime.patch | 13 -- srcpkgs/qemu/patches/xxx-ppcle.patch | 113 ----------- srcpkgs/qemu/template | 41 +--- 11 files changed, 235 insertions(+), 457 deletions(-) create mode 100644 srcpkgs/qemu/patches/CVE-2023-2861.patch delete mode 100644 srcpkgs/qemu/patches/fix-linux-user-ppc32.patch delete mode 100644 srcpkgs/qemu/patches/fix-softfloat-fesetround.patch delete mode 100644 srcpkgs/qemu/patches/gcc12.patch create mode 100644 srcpkgs/qemu/patches/keymap.patch delete mode 100644 srcpkgs/qemu/patches/mmap-mremap-efault.patch delete mode 100644 srcpkgs/qemu/patches/musl-ppc.patch delete mode 100644 srcpkgs/qemu/patches/musl-rlimit-rttime.patch delete mode 100644 srcpkgs/qemu/patches/xxx-ppcle.patch diff --git a/srcpkgs/qemu/patches/CVE-2023-2861.patch b/srcpkgs/qemu/patches/CVE-2023-2861.patch new file mode 100644 index 000000000000..dca869f1d77f --- /dev/null +++ b/srcpkgs/qemu/patches/CVE-2023-2861.patch @@ -0,0 +1,177 @@ +Patch-Source: https://gitlab.com/qemu-project/qemu/-/commit/b9d2887be4e616cdaeedd0b7456bfaa71ee798af +-- +From b9d2887be4e616cdaeedd0b7456bfaa71ee798af Mon Sep 17 00:00:00 2001 +From: Christian Schoenebeck +Date: Wed, 7 Jun 2023 18:29:33 +0200 +Subject: [PATCH] 9pfs: prevent opening special files (CVE-2023-2861) + +The 9p protocol does not specifically define how server shall behave when +client tries to open a special file, however from security POV it does +make sense for 9p server to prohibit opening any special file on host side +in general. A sane Linux 9p client for instance would never attempt to +open a special file on host side, it would always handle those exclusively +on its guest side. A malicious client however could potentially escape +from the exported 9p tree by creating and opening a device file on host +side. + +With QEMU this could only be exploited in the following unsafe setups: + + - Running QEMU binary as root AND 9p 'local' fs driver AND 'passthrough' + security model. + +or + + - Using 9p 'proxy' fs driver (which is running its helper daemon as + root). + +These setups were already discouraged for safety reasons before, +however for obvious reasons we are now tightening behaviour on this. + +Fixes: CVE-2023-2861 +Reported-by: Yanwu Shen +Reported-by: Jietao Xiao +Reported-by: Jinku Li +Reported-by: Wenbo Shen +Signed-off-by: Christian Schoenebeck +Reviewed-by: Greg Kurz +Reviewed-by: Michael Tokarev +Message-Id: +(cherry picked from commit f6b0de53fb87ddefed348a39284c8e2f28dc4eda) +Signed-off-by: Michael Tokarev +--- + fsdev/virtfs-proxy-helper.c | 27 +++++++++++++++++++++++-- + hw/9pfs/9p-util.h | 39 +++++++++++++++++++++++++++++++++++++ + 2 files changed, 64 insertions(+), 2 deletions(-) + +diff --git a/fsdev/virtfs-proxy-helper.c b/fsdev/virtfs-proxy-helper.c +index 5cafcd77031..d9511f429c9 100644 +--- a/fsdev/virtfs-proxy-helper.c ++++ b/fsdev/virtfs-proxy-helper.c +@@ -26,6 +26,7 @@ + #include "qemu/xattr.h" + #include "9p-iov-marshal.h" + #include "hw/9pfs/9p-proxy.h" ++#include "hw/9pfs/9p-util.h" + #include "fsdev/9p-iov-marshal.h" + + #define PROGNAME "virtfs-proxy-helper" +@@ -338,6 +339,28 @@ static void resetugid(int suid, int sgid) + } + } + ++/* ++ * Open regular file or directory. Attempts to open any special file are ++ * rejected. ++ * ++ * returns file descriptor or -1 on error ++ */ ++static int open_regular(const char *pathname, int flags, mode_t mode) ++{ ++ int fd; ++ ++ fd = open(pathname, flags, mode); ++ if (fd < 0) { ++ return fd; ++ } ++ ++ if (close_if_special_file(fd) < 0) { ++ return -1; ++ } ++ ++ return fd; ++} ++ + /* + * send response in two parts + * 1) ProxyHeader +@@ -682,7 +705,7 @@ static int do_create(struct iovec *iovec) + if (ret < 0) { + goto unmarshal_err_out; + } +- ret = open(path.data, flags, mode); ++ ret = open_regular(path.data, flags, mode); + if (ret < 0) { + ret = -errno; + } +@@ -707,7 +730,7 @@ static int do_open(struct iovec *iovec) + if (ret < 0) { + goto err_out; + } +- ret = open(path.data, flags); ++ ret = open_regular(path.data, flags, 0); + if (ret < 0) { + ret = -errno; + } +diff --git a/hw/9pfs/9p-util.h b/hw/9pfs/9p-util.h +index c314cf381d4..df1b583a5e4 100644 +--- a/hw/9pfs/9p-util.h ++++ b/hw/9pfs/9p-util.h +@@ -13,6 +13,8 @@ + #ifndef QEMU_9P_UTIL_H + #define QEMU_9P_UTIL_H + ++#include "qemu/error-report.h" ++ + #ifdef O_PATH + #define O_PATH_9P_UTIL O_PATH + #else +@@ -95,6 +97,7 @@ static inline int errno_to_dotl(int err) { + #endif + + #define qemu_openat openat ++#define qemu_fstat fstat + #define qemu_fstatat fstatat + #define qemu_mkdirat mkdirat + #define qemu_renameat renameat +@@ -108,6 +111,38 @@ static inline void close_preserve_errno(int fd) + errno = serrno; + } + ++/** ++ * close_if_special_file() - Close @fd if neither regular file nor directory. ++ * ++ * @fd: file descriptor of open file ++ * Return: 0 on regular file or directory, -1 otherwise ++ * ++ * CVE-2023-2861: Prohibit opening any special file directly on host ++ * (especially device files), as a compromised client could potentially gain ++ * access outside exported tree under certain, unsafe setups. We expect ++ * client to handle I/O on special files exclusively on guest side. ++ */ ++static inline int close_if_special_file(int fd) ++{ ++ struct stat stbuf; ++ ++ if (qemu_fstat(fd, &stbuf) < 0) { ++ close_preserve_errno(fd); ++ return -1; ++ } ++ if (!S_ISREG(stbuf.st_mode) && !S_ISDIR(stbuf.st_mode)) { ++ error_report_once( ++ "9p: broken or compromised client detected; attempt to open " ++ "special file (i.e. neither regular file, nor directory)" ++ ); ++ close(fd); ++ errno = ENXIO; ++ return -1; ++ } ++ ++ return 0; ++} ++ + static inline int openat_dir(int dirfd, const char *name) + { + return qemu_openat(dirfd, name, +@@ -142,6 +177,10 @@ again: + return -1; + } + ++ if (close_if_special_file(fd) < 0) { ++ return -1; ++ } ++ + serrno = errno; + /* O_NONBLOCK was only needed to open the file. Let's drop it. We don't + * do that with O_PATH since fcntl(F_SETFL) isn't supported, and openat() +-- +GitLab diff --git a/srcpkgs/qemu/patches/fix-linux-user-ppc32.patch b/srcpkgs/qemu/patches/fix-linux-user-ppc32.patch deleted file mode 100644 index cd47435d5aa9..000000000000 --- a/srcpkgs/qemu/patches/fix-linux-user-ppc32.patch +++ /dev/null @@ -1,117 +0,0 @@ -commit 37814f62c2cc7aba2eea073014d6c53dcd5bf42c -Author: q66 -Date: Fri Jul 1 16:53:55 2022 +0200 - - fix linux-user build on 32-bit ppc - - Partial revert https://gitlab.com/qemu-project/qemu/-/commit/9d1401b79463e74adbfac69d836789d4e103fb61 - and https://gitlab.com/qemu-project/qemu/-/commit/0a7e01904d407baa73c1baddbdfc9ccf2ace8356 - -diff --git a/common-user/host/ppc/safe-syscall.inc.S b/common-user/host/ppc/safe-syscall.inc.S -new file mode 100644 -index 0000000..e69de29 -diff --git a/common-user/safe-syscall-error.c b/common-user/safe-syscall-error.c -index cf74b50..a36132c 100644 ---- a/common-user/safe-syscall-error.c -+++ b/common-user/safe-syscall-error.c -@@ -12,6 +12,7 @@ - #include "qemu/osdep.h" - #include "user/safe-syscall.h" - -+#if !defined(__powerpc__) || defined(__powerpc64__) - /* - * This is intended to be invoked via tail-call on the error path - * from the assembly in host/arch/safe-syscall.inc.S. This takes -@@ -23,3 +24,4 @@ long safe_syscall_set_errno_tail(int value) - errno = value; - return -1; - } -+#endif -diff --git a/include/user/safe-syscall.h b/include/user/safe-syscall.h -index 61a04e2..793fe84 100644 ---- a/include/user/safe-syscall.h -+++ b/include/user/safe-syscall.h -@@ -125,6 +125,8 @@ - * kinds of restartability. - */ - -+#if !defined(__powerpc__) || defined(__powerpc64__) -+ - /* The core part of this function is implemented in assembly */ - extern long safe_syscall_base(int *pending, long number, ...); - extern long safe_syscall_set_errno_tail(int value); -@@ -137,4 +139,10 @@ extern char safe_syscall_end[]; - safe_syscall_base(&((TaskState *)thread_cpu->opaque)->signal_pending, \ - __VA_ARGS__) - -+#else -+ -+#define safe_syscall syscall -+ -+#endif -+ - #endif -diff --git a/linux-user/include/host/ppc/host-signal.h b/linux-user/include/host/ppc/host-signal.h -new file mode 100644 -index 0000000..b80384d ---- /dev/null -+++ b/linux-user/include/host/ppc/host-signal.h -@@ -0,0 +1,38 @@ -+/* -+ * host-signal.h: signal info dependent on the host architecture -+ * -+ * Copyright (c) 2003-2005 Fabrice Bellard -+ * Copyright (c) 2021 Linaro Limited -+ * -+ * This work is licensed under the terms of the GNU LGPL, version 2.1 or later. -+ * See the COPYING file in the top-level directory. -+ */ -+ -+#ifndef PPC_HOST_SIGNAL_H -+#define PPC_HOST_SIGNAL_H -+ -+/* The third argument to a SA_SIGINFO handler is ucontext_t. */ -+typedef ucontext_t host_sigcontext; -+ -+static inline uintptr_t host_signal_pc(host_sigcontext *uc) -+{ -+ return uc->uc_mcontext.regs->nip; -+} -+ -+static inline void host_signal_set_pc(host_sigcontext *uc, uintptr_t pc) -+{ -+ uc->uc_mcontext.regs->nip = pc; -+} -+ -+static inline void *host_signal_mask(host_sigcontext *uc) -+{ -+ return &uc->uc_sigmask; -+} -+ -+static inline bool host_signal_write(siginfo_t *info, host_sigcontext *uc) -+{ -+ return uc->uc_mcontext.regs->trap != 0x400 -+ && (uc->uc_mcontext.regs->dsisr & 0x02000000); -+} -+ -+#endif -diff --git a/linux-user/signal.c b/linux-user/signal.c -index 092e70b..b8dfa8a 100644 ---- a/linux-user/signal.c -+++ b/linux-user/signal.c -@@ -800,6 +800,7 @@ void queue_signal(CPUArchState *env, int sig, int si_type, - /* Adjust the signal context to rewind out of safe-syscall if we're in it */ - static inline void rewind_if_in_safe_syscall(void *puc) - { -+#if !defined(__powerpc__) || defined(__powerpc64__) - host_sigcontext *uc = (host_sigcontext *)puc; - uintptr_t pcreg = host_signal_pc(uc); - -@@ -807,6 +808,7 @@ static inline void rewind_if_in_safe_syscall(void *puc) - && pcreg < (uintptr_t)safe_syscall_end) { - host_signal_set_pc(uc, (uintptr_t)safe_syscall_start); - } -+#endif - } - - static void host_signal_handler(int host_sig, siginfo_t *info, void *puc) diff --git a/srcpkgs/qemu/patches/fix-softfloat-fesetround.patch b/srcpkgs/qemu/patches/fix-softfloat-fesetround.patch deleted file mode 100644 index ecdd049f7921..000000000000 --- a/srcpkgs/qemu/patches/fix-softfloat-fesetround.patch +++ /dev/null @@ -1,39 +0,0 @@ -Source: @pullmoll -Upstream: no -Reason: Target architectures with soft float do not define these constants. - ---- a/tests/fp/fp-bench.c 2020-12-08 17:59:44.000000000 +0100 -+++ b/tests/fp/fp-bench.c 2020-12-12 20:38:40.702235420 +0100 -@@ -485,16 +485,32 @@ - - switch (rounding) { - case ROUND_EVEN: -+#if defined(FE_TONEAREST) - rhost = FE_TONEAREST; -+#else -+ return; -+#endif - break; - case ROUND_ZERO: -+#if defined(FE_TOWARDZERO) - rhost = FE_TOWARDZERO; -+#else -+ return; -+#endif - break; - case ROUND_DOWN: -+#if defined(FE_DOWNWARD) - rhost = FE_DOWNWARD; -+#else -+ return; -+#endif - break; - case ROUND_UP: -+#if defined(FE_UPWARD) - rhost = FE_UPWARD; -+#else -+ return; -+#endif - break; - case ROUND_TIEAWAY: - die_host_rounding(rounding); diff --git a/srcpkgs/qemu/patches/gcc12.patch b/srcpkgs/qemu/patches/gcc12.patch deleted file mode 100644 index 2a4b2bd03609..000000000000 --- a/srcpkgs/qemu/patches/gcc12.patch +++ /dev/null @@ -1,72 +0,0 @@ -From 5cb993ff131fca2abef3ce074a20258fd6fce557 Mon Sep 17 00:00:00 2001 -From: Bernhard Beschow -Date: Sat, 18 Mar 2023 19:59:31 +0100 -Subject: [PATCH] qemu/osdep: Switch position of "extern" and "G_NORETURN" - -Fixes the Windows build under msys2 using GCC 12 which fails with the following -error: - - [184/579] Compiling C++ object qga/vss-win32/qga-vss.dll.p/install.cpp.obj - FAILED: qga/vss-win32/qga-vss.dll.p/install.cpp.obj - "c++" "-m64" "-mcx16" "-Iqga/vss-win32/qga-vss.dll.p" "-Iqga/vss-win32" "-I../src/qga/vss-win32" "-I." "-Iqapi" "-Itrace" "-Iui" "-Iui/shader" "-IC:/msys64/mingw64/include/glib-2.0" "-IC:/msys64/mingw64/lib/glib-2.0/include" "-fdiagnostics-color=auto" "-Wall" "-Winvalid-pch" "-Wnon-virtual-dtor" "-Werror" "-std=gnu++11" "-g" "-iquote" "." "-iquote" "C:/msys64/home/shentey/Projects/qemu/src" "-iquote" "C:/msys64/home/shentey/Projects/qemu/src/include" "-iquote" "C:/msys64/home/shentey/Projects/qemu/src/tcg/i386" "-D__STDC_LIMIT_MACROS" "-D__STDC_CONSTANT_MACROS" "-D__STDC_FORMAT_MACROS" "-fno-pie" "-no-pie" "-D_GNU_SOURCE" "-D_FILE_OFFSET_BITS=64" "-D_LARGEFILE_SOURCE" "-fno-strict-aliasing" "-fno-common" "-fwrapv" "-Wundef" "-Wwrite-strings" "-Wtype-limits" "-Wformat-security" "-Wformat-y2k" "-Winit-self" "-Wignored-qualifiers" "-Wempty-body" "-Wendif-labels" "-Wexpansion-to-defined" "-Wimplicit-fallthrough=2" "-Wmissing-format-attribute" "-Wno-missing-include-dirs" "-Wno-shift-negative-value" "-Wno-psabi" "-fstack-protector-strong" "-Wno-unknown-pragmas" "-Wno-delete-non-virtual-dtor" "-Wno-non-virtual-dtor" -MD -MQ qga/vss-win32/qga-vss.dll.p/install.cpp.obj -MF "qga/vss-win32/qga-vss.dll.p/install.cpp.obj.d" -o qga/vss-win32/qga-vss.dll.p/install.cpp.obj "-c" ../src/qga/vss-win32/install.cpp - In file included from C:/msys64/mingw64/lib/glib-2.0/include/glibconfig.h:9, - from C:/msys64/mingw64/include/glib-2.0/glib/gtypes.h:34, - from C:/msys64/mingw64/include/glib-2.0/glib/galloca.h:34, - from C:/msys64/mingw64/include/glib-2.0/glib.h:32, - from C:/msys64/home/shentey/Projects/qemu/src/include/glib-compat.h:32, - from C:/msys64/home/shentey/Projects/qemu/src/include/qemu/osdep.h:144, - from ../src/qga/vss-win32/install.cpp:13: - C:/msys64/mingw64/include/glib-2.0/glib/gmacros.h:1075:21: error: standard attributes in middle of decl-specifiers - 1075 | # define G_NORETURN [[noreturn]] - | ^ - C:/msys64/home/shentey/Projects/qemu/src/include/qemu/osdep.h:240:8: note: in expansion of macro 'G_NORETURN' - 240 | extern G_NORETURN - | ^~~~~~~~~~ - C:/msys64/mingw64/include/glib-2.0/glib/gmacros.h:1075:21: note: standard attributes must precede the decl-specifiers to apply to the declaration, or follow them to apply to the type - 1075 | # define G_NORETURN [[noreturn]] - | ^ - C:/msys64/home/shentey/Projects/qemu/src/include/qemu/osdep.h:240:8: note: in expansion of macro 'G_NORETURN' - 240 | extern G_NORETURN - | ^~~~~~~~~~ - C:/msys64/mingw64/include/glib-2.0/glib/gmacros.h:1075:21: error: attribute ignored [-Werror=attributes] - 1075 | # define G_NORETURN [[noreturn]] - | ^ - C:/msys64/home/shentey/Projects/qemu/src/include/qemu/osdep.h:240:8: note: in expansion of macro 'G_NORETURN' - 240 | extern G_NORETURN - | ^~~~~~~~~~ - C:/msys64/mingw64/include/glib-2.0/glib/gmacros.h:1075:21: note: an attribute that appertains to a type-specifier is ignored - 1075 | # define G_NORETURN [[noreturn]] - | ^ - C:/msys64/home/shentey/Projects/qemu/src/include/qemu/osdep.h:240:8: note: in expansion of macro 'G_NORETURN' - 240 | extern G_NORETURN - | ^~~~~~~~~~ - cc1plus.exe: all warnings being treated as errors - -Apparently it also fixes the compilation with Clang 15 (see -https://gitlab.com/qemu-project/qemu/-/issues/1541 ). - -Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1541 -Signed-off-by: Bernhard Beschow -Message-Id: <20230318185931.181659-1-shentey@gmail.com> -Reviewed-by: Peter Maydell -Signed-off-by: Thomas Huth ---- - include/qemu/osdep.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h -index f68b5d8708c..9eff0be95bd 100644 ---- a/include/qemu/osdep.h -+++ b/include/qemu/osdep.h -@@ -237,7 +237,7 @@ extern "C" { - * supports QEMU_ERROR, this will be reported at compile time; otherwise - * this will be reported at link time due to the missing symbol. - */ --extern G_NORETURN -+G_NORETURN extern - void QEMU_ERROR("code path is reachable") - qemu_build_not_reached_always(void); - #if defined(__OPTIMIZE__) && !defined(__NO_INLINE__) --- -GitLab - diff --git a/srcpkgs/qemu/patches/keymap.patch b/srcpkgs/qemu/patches/keymap.patch new file mode 100644 index 000000000000..c4d9963cd636 --- /dev/null +++ b/srcpkgs/qemu/patches/keymap.patch @@ -0,0 +1,47 @@ +The xkb official name for the Arabic keyboard layout is 'ara'. +However xkb has for at least the past 15 years also permitted it to +be named via the legacy synonym 'ar'. In xkeyboard-config 2.39 this +synoynm was removed, which breaks compilation of QEMU: + +FAILED: pc-bios/keymaps/ar +/home/fred/qemu-git/src/qemu/build-full/qemu-keymap -f pc-bios/keymaps/ar -l ar +xkbcommon: ERROR: Couldn't find file "symbols/ar" in include paths +xkbcommon: ERROR: 1 include paths searched: +xkbcommon: ERROR: /usr/share/X11/xkb +xkbcommon: ERROR: 3 include paths could not be added: +xkbcommon: ERROR: /home/fred/.config/xkb +xkbcommon: ERROR: /home/fred/.xkb +xkbcommon: ERROR: /etc/xkb +xkbcommon: ERROR: Abandoning symbols file "(unnamed)" +xkbcommon: ERROR: Failed to compile xkb_symbols +xkbcommon: ERROR: Failed to compile keymap + +The upstream xkeyboard-config change removing the compat +mapping is: +https://gitlab.freedesktop.org/xkeyboard-config/xkeyboard-config/-/commit/470ad2cd8fea84d7210377161d86b31999bb5ea6 + +Make QEMU always ask for the 'ara' xkb layout, which should work on +both older and newer xkeyboard-config. We leave the QEMU name for +this keyboard layout as 'ar'; it is not the only one where our name +for it deviates from the xkb standard name. + +Cc: qemu-stable@nongnu.org +Signed-off-by: Peter Maydell +Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1709 +--- + pc-bios/keymaps/meson.build | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/pc-bios/keymaps/meson.build b/pc-bios/keymaps/meson.build +index bff30833137..0bd8ce00775 100644 +--- a/pc-bios/keymaps/meson.build ++++ b/pc-bios/keymaps/meson.build +@@ -1,5 +1,5 @@ + keymaps = { +- 'ar': '-l ar', ++ 'ar': '-l ara', + 'bepo': '-l fr -v dvorak', + 'cz': '-l cz', + 'da': '-l dk', +-- +2.34.1 diff --git a/srcpkgs/qemu/patches/mmap-mremap-efault.patch b/srcpkgs/qemu/patches/mmap-mremap-efault.patch deleted file mode 100644 index 5a70e9658b30..000000000000 --- a/srcpkgs/qemu/patches/mmap-mremap-efault.patch +++ /dev/null @@ -1,42 +0,0 @@ -Source: @pullmoll -Upstream: no -Reason: errno=EFAULT when the address passed to mremap(2) is not valid - -See Rich Felker's comment at https://www.openwall.com/lists/musl/2017/06/21/2 for -why we need to return errno as described in man mremap(2) from qemu-user-static. -Also speed up the loop when checking for increasing the mappings size to go -in steps of TARGET_PAGE_SIZE and OR-in a check for the very last byte of the range. -diff --git linux-user/mmap.c linux-user/mmap.c -index 7e3b245..1e8d0f1 100644 ---- a/linux-user/mmap.c -+++ b/linux-user/mmap.c -@@ -738,7 +738,7 @@ abi_long target_mremap(abi_ulong old_addr, abi_ulong old_size, - !guest_range_valid_untagged(new_addr, new_size)) || - ((flags & MREMAP_MAYMOVE) == 0 && - !guest_range_valid_untagged(old_addr, new_size))) { -- errno = ENOMEM; -+ errno = EFAULT; - return -1; - } - -@@ -775,9 +775,10 @@ abi_long target_mremap(abi_ulong old_addr, abi_ulong old_size, - abi_ulong addr; - for (addr = old_addr + old_size; - addr < old_addr + new_size; -- addr++) { -+ addr += TARGET_PAGE_SIZE) { - prot |= page_get_flags(addr); - } -+ prot |= page_get_flags(old_addr + new_size - 1); - } - if (prot == 0) { - host_addr = mremap(g2h_untagged(old_addr), -@@ -796,7 +797,7 @@ abi_long target_mremap(abi_ulong old_addr, abi_ulong old_size, - } - } - } else { -- errno = ENOMEM; -+ errno = EFAULT; - host_addr = MAP_FAILED; - } - } diff --git a/srcpkgs/qemu/patches/musl-initialize-msghdr.patch b/srcpkgs/qemu/patches/musl-initialize-msghdr.patch index 6d96b3511daf..a88547354c1e 100644 --- a/srcpkgs/qemu/patches/musl-initialize-msghdr.patch +++ b/srcpkgs/qemu/patches/musl-initialize-msghdr.patch @@ -1,10 +1,10 @@ Source: https://github.com/void-linux/void-packages/issues/23557 -diff --git linux-user/syscall.c linux-user/syscall.c -index 945fc25..8d8b68a 100644 +diff --git a/linux-user/syscall.c b/linux-user/syscall.c +index 14fdebd..de280af 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c -@@ -3071,7 +3071,7 @@ static abi_long do_sendrecvmsg_locked(int fd, struct target_msghdr *msgp, +@@ -3229,7 +3229,7 @@ static abi_long do_sendrecvmsg_locked(int fd, struct target_msghdr *msgp, int flags, int send) { abi_long ret, len; diff --git a/srcpkgs/qemu/patches/musl-ppc.patch b/srcpkgs/qemu/patches/musl-ppc.patch deleted file mode 100644 index 0b77aa8fc63d..000000000000 --- a/srcpkgs/qemu/patches/musl-ppc.patch +++ /dev/null @@ -1,25 +0,0 @@ ---- a/linux-user/signal.c -+++ b/linux-user/signal.c -@@ -21,5 +21,9 @@ - #include "exec/gdbstub.h" - #include "hw/core/tcg-cpu-ops.h" - -+#if defined(_ARCH_PPC64) && !defined(__GLIBC__) /* musl */ -+#include -+#endif -+ - #include - #include ---- a/util/mmap-alloc.c -+++ b/util/mmap-alloc.c -@@ -25,6 +25,10 @@ - - #ifdef CONFIG_LINUX - #include -+/* musl undefs this on ppc and mips */ -+#ifndef MAP_SYNC -+#define MAP_SYNC 0x80000 -+#endif - #endif - - size_t qemu_fd_getpagesize(int fd) diff --git a/srcpkgs/qemu/patches/musl-rlimit-rttime.patch b/srcpkgs/qemu/patches/musl-rlimit-rttime.patch deleted file mode 100644 index 0cbf9be36a8f..000000000000 --- a/srcpkgs/qemu/patches/musl-rlimit-rttime.patch +++ /dev/null @@ -1,13 +0,0 @@ ---- a/linux-user/syscall.c -+++ b/linux-user/syscall.c -@@ -141,6 +141,10 @@ - #include "fd-trans.h" - #include "tcg/tcg.h" - -+#ifndef RLIMIT_RTTIME -+#define RLIMIT_RTTIME 15 -+#endif -+ - #ifndef CLONE_IO - #define CLONE_IO 0x80000000 /* Clone io context */ - #endif diff --git a/srcpkgs/qemu/patches/xxx-ppcle.patch b/srcpkgs/qemu/patches/xxx-ppcle.patch deleted file mode 100644 index 90b32b5e07cd..000000000000 --- a/srcpkgs/qemu/patches/xxx-ppcle.patch +++ /dev/null @@ -1,113 +0,0 @@ -From 7ece08d7902d5a8c007deeb0b75cb533a41dd882 Mon Sep 17 00:00:00 2001 -From: Daniel Kolesa -Date: Sun, 7 Mar 2021 01:47:42 +0100 -Subject: [PATCH] support ppcle architecture - ---- - configure | 14 ++++++++++++-- - configs/targets/ppcle-linux-user.mak | 4 ++++ - linux-user/ppc/target_syscall.h | 4 ++++ - scripts/qemu-binfmt-conf.sh | 6 +++++- - tests/tcg/configure.sh | 2 ++ - 5 files changed, 27 insertions(+), 3 deletions(-) - create mode 100644 configs/targets/ppcle-linux-user.mak - -diff --git a/configure b/configure -index 18c26e0..03d3e18 100755 ---- a/configure -+++ b/configure -@@ -653,7 +653,11 @@ elif check_define _ARCH_PPC ; then - cpu="ppc64" - fi - else -- cpu="ppc" -+ if check_define _LITTLE_ENDIAN ; then -+ cpu="ppcle" -+ else -+ cpu="ppc" -+ fi - fi - elif check_define __mips__ ; then - cpu="mips" -@@ -638,6 +642,9 @@ - - ppc) - CPU_CFLAGS="-m32" ;; -+ ppcle) -+ cpu="ppc" -+ CPU_CFLAGS="-m32 -mlittle-endian" ;; - ppc64) - CPU_CFLAGS="-m64 -mbig-endian" ;; - ppc64le) -diff --git a/configs/targets/ppcle-linux-user.mak b/configs/targets/ppcle-linux-user.mak -new file mode 100644 -index 0000000..2259243 ---- /dev/null -+++ b/configs/targets/ppcle-linux-user.mak -@@ -0,0 +1,4 @@ -+TARGET_ARCH=ppc -+TARGET_SYSTBL_ABI=common,nospu,32 -+TARGET_SYSTBL=syscall.tbl -+TARGET_XML_FILES= gdb-xml/power-core.xml gdb-xml/power-fpu.xml gdb-xml/power-altivec.xml gdb-xml/power-spe.xml -diff --git a/linux-user/ppc/target_syscall.h b/linux-user/ppc/target_syscall.h -index b9c4b81..cf26497 100644 ---- a/linux-user/ppc/target_syscall.h -+++ b/linux-user/ppc/target_syscall.h -@@ -65,7 +65,11 @@ struct target_revectored_struct { - #define UNAME_MACHINE "ppc64le" - #endif - #else -+#if TARGET_BIG_ENDIAN - #define UNAME_MACHINE "ppc" -+#else -+#define UNAME_MACHINE "ppcle" -+#endif - #endif - #define UNAME_MINIMUM_RELEASE "2.6.32" - -diff --git a/scripts/qemu-binfmt-conf.sh b/scripts/qemu-binfmt-conf.sh -index 9f1580a..393943f 100755 ---- a/scripts/qemu-binfmt-conf.sh -+++ b/scripts/qemu-binfmt-conf.sh -@@ -46,6 +46,10 @@ ppc_magic='\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x - ppc_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff' - ppc_family=ppc - -+ppcle_magic='\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x14\x00' -+ppcle_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\x00' -+ppc_family=ppcle -+ - ppc64_magic='\x7fELF\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x15' - ppc64_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff' - ppc64_family=ppc -@@ -148,7 +152,7 @@ qemu_get_family() { - "Power Macintosh"|ppc64|powerpc|ppc) - echo "ppc" - ;; -- ppc64el|ppc64le) -+ ppc64el|ppc64le|ppcel|ppcle) - echo "ppcle" - ;; - arm|armel|armhf|arm64|armv[4-9]*l|aarch64) -diff --git a/configure b/configure -index 72ab03f11a..0691929d76 100755 ---- a/configure -+++ b/configure -@@ -1866,6 +1866,7 @@ fi - : ${cross_prefix_mips="mips-linux-gnu-"} - : ${cross_prefix_nios2="nios2-linux-gnu-"} - : ${cross_prefix_ppc="powerpc-linux-gnu-"} -+: ${cross_prefix_ppcle="powerpcle-linux-gnu-"} - : ${cross_prefix_ppc64="powerpc64-linux-gnu-"} - : ${cross_prefix_ppc64le="$cross_prefix_ppc64"} - : ${cross_prefix_riscv64="riscv64-linux-gnu-"} -@@ -1883,6 +1884,7 @@ fi - : ${cross_cc_cflags_hexagon="-mv67 -O2 -static"} - : ${cross_cc_cflags_i386="-m32"} - : ${cross_cc_cflags_ppc="-m32 -mbig-endian"} -+: ${cross_cc_cflags_ppcle="-m32"} - : ${cross_cc_cflags_ppc64="-m64 -mbig-endian"} - : ${cross_cc_ppc64le="$cross_cc_ppc64"} - : ${cross_cc_cflags_ppc64le="-m64 -mlittle-endian"} -2.30.1 - diff --git a/srcpkgs/qemu/template b/srcpkgs/qemu/template index 48ab199e5686..1ab53eeef726 100644 --- a/srcpkgs/qemu/template +++ b/srcpkgs/qemu/template @@ -1,8 +1,8 @@ # Template file for 'qemu' # This package should be updated together with qemu-user-static pkgname=qemu -version=7.1.0 -revision=2 +version=8.0.2 +revision=1 build_style=configure configure_args="--prefix=/usr --sysconfdir=/etc --libexecdir=/usr/libexec --localstatedir=/var --disable-glusterfs --disable-xen --enable-docs --enable-kvm --enable-libusb --enable-pie @@ -10,10 +10,10 @@ configure_args="--prefix=/usr --sysconfdir=/etc --libexecdir=/usr/libexec --loca --audio-drv-list=alsa$(vopt_if sdl2 ,sdl)$(vopt_if jack ,jack)$(vopt_if pulseaudio ,pa) $(vopt_enable opengl) $(vopt_enable pulseaudio pa) $(vopt_enable sdl2 sdl) $(vopt_enable smartcard) $(vopt_enable spice) $(vopt_enable virgl virglrenderer) $(vopt_if gtk3 '--enable-gtk')" -hostmakedepends="gettext pkg-config perl python3 python3-Sphinx python3-sphinx_rtd_theme ninja" +hostmakedepends="flex gettext glib-devel pkg-config perl python3 python3-Sphinx python3-sphinx_rtd_theme ninja" makedepends="capstone-devel dtc-devel libpng-devel libjpeg-turbo-devel pixman-devel - snappy-devel libuuid-devel libX11-devel alsa-lib-devel libaio-devel gnutls-devel - libsasl-devel libglib-devel ncurses-devel libseccomp-devel nss-devel + snappy-devel libuuid-devel libX11-devel alsa-lib-devel libaio-devel + gnutls-devel libsasl-devel ncurses-devel libseccomp-devel nss-devel libcurl-devel xfsprogs-devel libcap-ng-devel vde2-devel usbredir-devel libbluetooth-devel libssh2-devel libusb-devel libnfs-devel libslirp-devel libxkbcommon-devel libzstd-devel $(vopt_if sdl2 'SDL2-devel SDL2_image-devel') @@ -25,10 +25,10 @@ makedepends="capstone-devel dtc-devel libpng-devel libjpeg-turbo-devel pixman-de $(vopt_if jack 'jack-devel') $(vopt_if pulseaudio 'pulseaudio-devel')" short_desc="Open Source Processor Emulator" maintainer="Orphaned " -license="GPL-2.0-or-later, LGPL-2.1-or-later" +license="GPL-2.0-only, LGPL-2.1-only" homepage="https://www.qemu.org" distfiles="https://wiki.qemu.org/download/qemu-${version}.tar.bz2" -checksum=f7ac2b85b3f1831e6810b140306e30af91556e15784864b209f3942858947fd0 +checksum=b59281923d60d358a7d7d3bde46ba43c0810d34d26608fcdaf6bf4c42492b694 ignore_elf_dirs="/usr/share/qemu" nostrip_files="hppa-firmware.img openbios-ppc openbios-sparc32 openbios-sparc64 palcode-clipper s390-ccw.img s390-netboot.img u-boot.e500 opensbi-riscv32-generic-fw_dynamic.elf @@ -43,37 +43,12 @@ desc_option_smartcard="Enable smartcard support" desc_option_numa="Enable support for host NUMA" desc_option_iscsi="Enable support for iSCSI" -case "$XBPS_TARGET_MACHINE" in - aarch64-musl) CFLAGS="-D_LINUX_SYSINFO_H";; -esac - -if [ "$XBPS_TARGET_ENDIAN" = "le" ]; then - build_options_default+=" spice" -fi - if [ "$CROSS_BUILD" ]; then - configure_args+=" --cross-prefix=${XBPS_CROSS_TRIPLET}-" + configure_args+=" --cross-prefix=${XBPS_CROSS_TRIPLET}" else build_options_default+=" smartcard" fi -if [ "$XBPS_CHECK_PKGS" != full ]; then - make_check_target=check-unit -fi - -post_extract() { - if [ "$XBPS_TARGET_LIBC" = "musl" ]; then - grep -rl 'Input/output error' tests/qemu-iotests | - xargs -n1 sed -i -e 's;Input/output error;I/O error;g' - grep -rl 'Operation not supported' tests/qemu-iotests | - xargs -n1 sed -i -e 's;Operation not supported;Not supported;g' - fi -} - -pre_configure() { - unset CPP -} - post_install() { vdoc "${FILESDIR}/README.voidlinux" From e6d627dd47e49835a072695253cc8ecae513f02c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Cerqueira?= Date: Mon, 3 Jul 2023 18:41:30 +0100 Subject: [PATCH 2/2] qemu-user-static: update to 8.0.2. --- srcpkgs/qemu-user-static/template | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/srcpkgs/qemu-user-static/template b/srcpkgs/qemu-user-static/template index 2a8da9b53f2d..509688be23f3 100644 --- a/srcpkgs/qemu-user-static/template +++ b/srcpkgs/qemu-user-static/template @@ -1,20 +1,20 @@ # Template file for 'qemu-user-static' # This package should be updated together with qemu pkgname=qemu-user-static -version=7.1.0 -revision=3 +version=8.0.2 +revision=1 build_style=configure configure_args="--prefix=/usr --sysconfdir=/etc --libexecdir=/usr/libexec --disable-kvm --disable-png --disable-virtfs --disable-fdt --disable-seccomp --enable-linux-user --disable-system --static --disable-pie" -hostmakedepends="pkg-config perl python3 ninja" +hostmakedepends="flex glib-devel pkg-config perl python3 ninja" makedepends="dtc-devel libglib-devel pixman-devel libuuid-devel" short_desc="QEMU User-mode emulators (statically compiled)" maintainer="Orphaned " -license="GPL-2.0-or-later, LGPL-2.1-or-later" +license="GPL-2.0-only, LGPL-2.1-only" homepage="https://www.qemu.org" distfiles="https://wiki.qemu.org/download/qemu-${version}.tar.bz2" -checksum=f7ac2b85b3f1831e6810b140306e30af91556e15784864b209f3942858947fd0 +checksum=b59281923d60d358a7d7d3bde46ba43c0810d34d26608fcdaf6bf4c42492b694 _fmts="aarch64 aarch64_be alpha arm armeb cris hppa i386 m68k microblaze microblazeel mips mipsel mips64 mips64el mipsn32 mipsn32el or1k @@ -111,10 +111,6 @@ done binfmts="${binfmts%?}" -pre_configure() { - unset CPP -} - post_install() { # Remove unneeded stuff. rm -rf ${DESTDIR}/etc ${DESTDIR}/usr/share ${DESTDIR}/usr/libexec