From patchwork Fri Jun 24 09:49:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1647789 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LTspP1yNwz9s1l for ; Fri, 24 Jun 2022 19:51:39 +1000 (AEST) Received: from localhost ([::1]:60380 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o4fyT-0002uc-GH for incoming@patchwork.ozlabs.org; Fri, 24 Jun 2022 05:51:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55756) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o4fwj-0002sK-6f for qemu-devel@nongnu.org; Fri, 24 Jun 2022 05:49:49 -0400 Received: from mout.kundenserver.de ([212.227.126.134]:45089) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o4fwh-0001aY-D4 for qemu-devel@nongnu.org; Fri, 24 Jun 2022 05:49:48 -0400 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue009 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MpDRv-1nJZ8o1UDf-00qj3I; Fri, 24 Jun 2022 11:49:45 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Laurent Vivier , Richard Henderson Subject: [PULL 1/3] linux-user/x86_64: Fix ELF_PLATFORM Date: Fri, 24 Jun 2022 11:49:41 +0200 Message-Id: <20220624094943.729568-2-laurent@vivier.eu> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220624094943.729568-1-laurent@vivier.eu> References: <20220624094943.729568-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:63cLd7fB7I05pE/4tri8CTPOT+5c0XjCFHZMAzuxrdOjzAemtCd 4SRwTfyMLMW5m4HvQaGu+Qx1WhLyM68gI9ajbruE/6Fnrtx7LhpwsSd+Gl+W4uKL8f54AVN 53GuaHwbyPeP5428wrY+ODMvkdXxYqR2J/tE3vmz0nrOGlsV1pn3OJ91BlPQe6evHOFybPC bGSaDyM0T86s18xtSKhMw== X-UI-Out-Filterresults: notjunk:1;V03:K0:NnZZ7VNUex8=:0XvGZEQuaKL3KiSKtKPffM sLoLxBL1BFYarO9n2axHWT9B7AiJ3gzuBZB2PFWkQgKapbrFzOjQuBzehBp0Fwu2TKBszj38l ld5SUfYumJ9s2b8aCtoJp3n1Nga9s/s4HxaNB+mbAV+ZgQMt/qW9Wi/rd8MEIhzh1MY4KOc+Y fJ+wai5HZmnD6B1xlvHwINUaGNQMSrvlYo/SDyDouzjXEUDNtxwEVm8O1QKssSKr8KKmwxgxQ OYX9Ta3dJettcAeHjY6HeF6fFBauzBtuXbr6QNwRAPYghXsPUpTzP1uSsHembx+zNf8RfHxeA xSbbiikRysMhS6LNm563vurs0xcD1psvmhyqUumy66mquYudSycxjrnD36qxgwvRfKVyK5OE+ R23gcctVtAeiNIJpPl96P2VS1q3qAWDtWZ63bqlI1HfANX6f0gee2tFAozVtUVhq2NH4IHqgP 5VqX8njP3Fx/jARwn/1009QOZm4qwEbJ6gXvgb+ARb3xIeBOJuP83uDD9ZGSDSIdO83ZwAHxW nZZokUB83cmC0pRib5JKiB/mXSaTmOKK/AkVjZvUsKrrq0CdzuRqVw3TvBOlSg51P6In3aU1X Z6aWj+1JNAr2A9JJu7KvtYW9OEq1pmJAKQok9cZf3xM35+8Oq3qaiWidWmCsFcG0wFQ0ne6a9 /ZV+EDiRpcKisnWlrzJuILpQtsNgm1r6mt15fuwjtN2bX7kfEsq44XXAtHM/vwj2jXM2M02g2 d4aH9wF6xVMzpHfPwN75sNWpIvZHqYEJjs/mlg== Received-SPF: none client-ip=212.227.126.134; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson We had been using the i686 platform string for x86_64. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1041 Signed-off-by: Richard Henderson Reviewed-by: Laurent Vivier Message-Id: <20220603213801.64738-1-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/elfload.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index f7eae357f4ae..163fc8a1eeab 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -130,19 +130,6 @@ typedef abi_int target_pid_t; #ifdef TARGET_I386 -#define ELF_PLATFORM get_elf_platform() - -static const char *get_elf_platform(void) -{ - static char elf_platform[] = "i386"; - int family = object_property_get_int(OBJECT(thread_cpu), "family", NULL); - if (family > 6) - family = 6; - if (family >= 3) - elf_platform[1] = '0' + family; - return elf_platform; -} - #define ELF_HWCAP get_elf_hwcap() static uint32_t get_elf_hwcap(void) @@ -158,6 +145,8 @@ static uint32_t get_elf_hwcap(void) #define ELF_CLASS ELFCLASS64 #define ELF_ARCH EM_X86_64 +#define ELF_PLATFORM "x86_64" + static inline void init_thread(struct target_pt_regs *regs, struct image_info *infop) { regs->rax = 0; @@ -221,6 +210,21 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUX86State *en #define ELF_CLASS ELFCLASS32 #define ELF_ARCH EM_386 +#define ELF_PLATFORM get_elf_platform() + +static const char *get_elf_platform(void) +{ + static char elf_platform[] = "i386"; + int family = object_property_get_int(OBJECT(thread_cpu), "family", NULL); + if (family > 6) { + family = 6; + } + if (family >= 3) { + elf_platform[1] = '0' + family; + } + return elf_platform; +} + static inline void init_thread(struct target_pt_regs *regs, struct image_info *infop) { From patchwork Fri Jun 24 09:49:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1647795 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LTswz2DbTz9s1l for ; Fri, 24 Jun 2022 19:57:21 +1000 (AEST) Received: from localhost ([::1]:44748 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o4g3y-0003JA-PS for incoming@patchwork.ozlabs.org; Fri, 24 Jun 2022 05:57:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55778) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o4fwn-0002wH-Pq for qemu-devel@nongnu.org; Fri, 24 Jun 2022 05:49:57 -0400 Received: from mout.kundenserver.de ([212.227.126.187]:36559) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o4fwk-0001aw-On for qemu-devel@nongnu.org; Fri, 24 Jun 2022 05:49:53 -0400 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue009 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MoNy4-1nKNov3W5Q-00onNX; Fri, 24 Jun 2022 11:49:46 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Laurent Vivier , Ilya Leoshkevich Subject: [PULL 2/3] linux-user: Add partial support for MADV_DONTNEED Date: Fri, 24 Jun 2022 11:49:42 +0200 Message-Id: <20220624094943.729568-3-laurent@vivier.eu> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220624094943.729568-1-laurent@vivier.eu> References: <20220624094943.729568-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:4HgF63GJ+EfhK442y+27a+Vgd80zRqW6kDXoCeWB9KSyoqmfDqc 0FvDo8Ojdxu61+/4bOkKVkMotwHsmrjT4ykZusKP3FOZ8UCL7domflScB1fb9GFoERHvA3u EITOiVWmSaKF9+ChmP3d1ziAdiCtrolJjrmeWP5S+MOuVpPWgfyjt5MZelpHWq3QVFrn5GZ 6rFF0z+AU7TE+aNZip0UA== X-UI-Out-Filterresults: notjunk:1;V03:K0:/okCK9ar2RM=:xxD7NYbUOz/KBVgKzZ29QN Q5cR9amlmLpNbUubPhE6+hchMt1fPsAXpetVsk+rlQ+Qhj1WVo+Pysc+maQe7ON/QK/Q7flFt jYeZWCSjbC61UP4llZR7Ky5YgcYaaIRPVcHKZaZNf3RDdAqJXmriFpXjZ7Byxr4rVnCxqKQAp /8ZqfQnZ8yejoFjnY78qD7k9PIYBeyWWL3Pi0ngFF6YBjKP7M+MfUlsRt6PDNSCG5vtZiRg8A jw4Sme5gSNknHUYwK6rWG4M19H3bcEhBgVAkjEFRYSqAXEBvqBXT4bxAvYWxNXaMylQblT3su jTB6t1ocs34UqjczNzjFZV1lZY1Bt4svYv4kK3lBKSYyLdUX276ivvB8Zslmuft9JgzM7f1gh aDjXbV216kbsnpUP1gDFj1ZkoBp4YL+CJftVMLJgM787ovj5aQvWIRdnrCFZidhPsVPo+31o8 QX/9D8f5FtH3E4kawjUUMMJzRx+noAc2nnEYUOMdI45SZ8/Hq6Z037GV/+K0ZbeThuJjzGaUn 1ewLw6DGp1yUVAJI+WY7Ywdqp20K7v/qHQazYJn1KlE42ZnEPS4i+PxdQ93RX1bjQvQObDOQ3 kaumqd86Y7TlwxEbbPdq4aMaUSrlVDXZl9KJvUJgzNTNzmOgVvDTRvDvocfsuRHdkkJpJdoDv F/wkQfesIXHitt6LxKfuxn31lmFTJVpZ3QRN7C4s68jrVqAeoD3zP+NMvud0EOur8SavdmxWq Xgh95S7h+XeyaiQUlXNFN42hnjYd7dA90C9K+w== Received-SPF: none client-ip=212.227.126.187; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Ilya Leoshkevich Currently QEMU ignores madvise(MADV_DONTNEED), which break apps that rely on this for zeroing out memory [1]. Improve the situation by doing a passthrough when the range in question is a host-page-aligned anonymous mapping. This is based on the patches from Simon Hausmann [2] and Chris Fallin [3]. The structure is taken from Simon's patch. The PAGE_MAP_ANONYMOUS bits are superseded by commit 26bab757d41b ("linux-user: Introduce PAGE_ANON"). In the end the patch acts like the one from Chris: we either pass-through the entire syscall, or do nothing, since doing this only partially would not help the affected applications much. Finally, add some extra checks to match the behavior of the Linux kernel [4]. [1] https://gitlab.com/qemu-project/qemu/-/issues/326 [2] https://patchew.org/QEMU/20180827084037.25316-1-simon.hausmann@qt.io/ [3] https://github.com/bytecodealliance/wasmtime/blob/v0.37.0/ci/qemu-madvise.patch [4] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/mm/madvise.c?h=v5.19-rc3#n1368 Signed-off-by: Ilya Leoshkevich Reviewed-by: Laurent Vivier Message-Id: <20220621144205.158452-1-iii@linux.ibm.com> Signed-off-by: Laurent Vivier --- linux-user/mmap.c | 64 +++++++++++++++++++++++++++++++++++++ linux-user/syscall.c | 8 ++--- linux-user/user-internals.h | 1 + linux-user/user-mmap.h | 1 + 4 files changed, 68 insertions(+), 6 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 48e13737962a..4e7a6be6ee19 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -835,3 +835,67 @@ abi_long target_mremap(abi_ulong old_addr, abi_ulong old_size, mmap_unlock(); return new_addr; } + +static bool can_passthrough_madv_dontneed(abi_ulong start, abi_ulong end) +{ + ulong addr; + + if ((start | end) & ~qemu_host_page_mask) { + return false; + } + + for (addr = start; addr < end; addr += TARGET_PAGE_SIZE) { + if (!(page_get_flags(addr) & PAGE_ANON)) { + return false; + } + } + + return true; +} + +abi_long target_madvise(abi_ulong start, abi_ulong len_in, int advice) +{ + abi_ulong len, end; + int ret = 0; + + if (start & ~TARGET_PAGE_MASK) { + return -TARGET_EINVAL; + } + len = TARGET_PAGE_ALIGN(len_in); + + if (len_in && !len) { + return -TARGET_EINVAL; + } + + end = start + len; + if (end < start) { + return -TARGET_EINVAL; + } + + if (end == start) { + return 0; + } + + if (!guest_range_valid_untagged(start, len)) { + return -TARGET_EINVAL; + } + + /* + * A straight passthrough may not be safe because qemu sometimes turns + * private file-backed mappings into anonymous mappings. + * + * This is a hint, so ignoring and returning success is ok. + * + * This breaks MADV_DONTNEED, completely implementing which is quite + * complicated. However, there is one low-hanging fruit: host-page-aligned + * anonymous mappings. In this case passthrough is safe, so do it. + */ + mmap_lock(); + if ((advice & MADV_DONTNEED) && + can_passthrough_madv_dontneed(start, end)) { + ret = get_errno(madvise(g2h_untagged(start), len, MADV_DONTNEED)); + } + mmap_unlock(); + + return ret; +} diff --git a/linux-user/syscall.c b/linux-user/syscall.c index f55cdebee5ab..8f68f255c0d9 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -538,7 +538,7 @@ static inline int target_to_host_errno(int target_errno) } } -static inline abi_long get_errno(abi_long ret) +abi_long get_errno(abi_long ret) { if (ret == -1) return -host_to_target_errno(errno); @@ -11807,11 +11807,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1, #ifdef TARGET_NR_madvise case TARGET_NR_madvise: - /* A straight passthrough may not be safe because qemu sometimes - turns private file-backed mappings into anonymous mappings. - This will break MADV_DONTNEED. - This is a hint, so ignoring and returning success is ok. */ - return 0; + return target_madvise(arg1, arg2, arg3); #endif #ifdef TARGET_NR_fcntl64 case TARGET_NR_fcntl64: diff --git a/linux-user/user-internals.h b/linux-user/user-internals.h index 6175ce53dbd6..0280e76addda 100644 --- a/linux-user/user-internals.h +++ b/linux-user/user-internals.h @@ -65,6 +65,7 @@ abi_long do_syscall(CPUArchState *cpu_env, int num, abi_long arg1, abi_long arg8); extern __thread CPUState *thread_cpu; G_NORETURN void cpu_loop(CPUArchState *env); +abi_long get_errno(abi_long ret); const char *target_strerror(int err); int get_osversion(void); void init_qemu_uname_release(void); diff --git a/linux-user/user-mmap.h b/linux-user/user-mmap.h index d1dec99c0249..480ce1c11487 100644 --- a/linux-user/user-mmap.h +++ b/linux-user/user-mmap.h @@ -25,6 +25,7 @@ int target_munmap(abi_ulong start, abi_ulong len); abi_long target_mremap(abi_ulong old_addr, abi_ulong old_size, abi_ulong new_size, unsigned long flags, abi_ulong new_addr); +abi_long target_madvise(abi_ulong start, abi_ulong len_in, int advice); extern unsigned long last_brk; extern abi_ulong mmap_next_start; abi_ulong mmap_find_vma(abi_ulong, abi_ulong, abi_ulong); From patchwork Fri Jun 24 09:49:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1647792 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LTstY0GFYz9s1l for ; Fri, 24 Jun 2022 19:55:17 +1000 (AEST) Received: from localhost ([::1]:40618 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o4g1w-0000OK-SA for incoming@patchwork.ozlabs.org; Fri, 24 Jun 2022 05:55:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55764) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o4fwk-0002sw-7z for qemu-devel@nongnu.org; Fri, 24 Jun 2022 05:49:50 -0400 Received: from mout.kundenserver.de ([212.227.126.187]:44729) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o4fwi-0001af-Ke for qemu-devel@nongnu.org; Fri, 24 Jun 2022 05:49:49 -0400 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue009 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MfYHQ-1nT9GM1Yfg-00fxfr; Fri, 24 Jun 2022 11:49:46 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Laurent Vivier , Helge Deller , Richard Henderson Subject: [PULL 3/3] linux-user: Adjust child_tidptr on set_tid_address() syscall Date: Fri, 24 Jun 2022 11:49:43 +0200 Message-Id: <20220624094943.729568-4-laurent@vivier.eu> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220624094943.729568-1-laurent@vivier.eu> References: <20220624094943.729568-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:Jdy6tD60Ahty6TTV1vrldTjxdWN0gFC2Vs6320oKES/XUHpaXkc sfFYy4sTt0lux+94tmlo+qbuldx+vEEe1zzb7+VRf4cD16uz5LSPSq1oSKyZ32d7iplInWv 6uTLE2NlE0vTzaQ5il/LtqMq0FRUV0olFcDXtIGWz6oA9hIoDKc1Meq1L+yCJ6fM+CzmMpi UZnE7Wyn4rNGk4Z315VYw== X-UI-Out-Filterresults: notjunk:1;V03:K0:WlsqVm8ndWY=:XQAKj8MWmWSMHWd/KlGMoN Z+TOgBxWZLP8e7vR5fLGh3Wdal4/U2rHu0GgNEPDLiWYjRyJGFiMTdCL9OrSQB5mq7rN3x4bt trwfSmoJkPX/5CXSZbMXe7Ks6an6OHTozFVqdl6Ria81zR2gCb0lAV3aPxJ2zS/78Mz2bQANN 0014zM2v1fyejTdCYwVtl5U77DeRKQYyfKYJTEk/5xHRUte0LtixRAIycsvcIke7HPVBG2OL5 xmJIUIbDxXta2PQkdrDDx0U0jMu9S/+glQPJq4pllEEJ1w2otaM+DHHjDq2BTb8/eDsDBhvZP bCI4tjBLm2U/5kwmSGnn9hI3FtZusDizALcjHver882z6RhU7fOeI7weLXt6SR5jC1pCiwcb6 A945fUYg/gztPoJYgNlwtsC1EsyfeJNP9k+XjKvgnDP6VHACTTzEBVobiArM4hqyFxqcYg6Qc hhMWcqIf9AuRoGel3/1P+QbGk6UmOmJ12Ys+R0/tfKXAWpNuBU9kX/3ArnwLbrDeLCqwjNb0C fRpp77Qz4Qz/uGqb70GE/LMiIYyBo5dqO16Q2MDX/cEVqExjhXkebIe7yKp1es2gISdh57ktV WvUUGm7rUw/KlRC8RD1uxhOqVsv5Ee9SR6Hkfc7RpC0HAZTAls6Pc/yYMRnp1zEoenIOTxHkB FWEczD0H60zQXXzvSs6iCeC7YxR0l/NgM3tw9VXS9SoTsUKJuPAhJNJ/hV+g3nNNZ4FJrPUp6 XX8PQeBSeeLB0QFOYDTIFlEiOneaXAh4wh5d3Q== Received-SPF: none client-ip=212.227.126.187; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Helge Deller Keep track of the new child tidptr given by a set_tid_address() syscall. Do not call the host set_tid_address() syscall because we are emulating the behaviour of writing to child_tidptr in the exit() path. Signed-off-by: Helge Deller Reviewed-by: Richard Henderson Reviewed-by: Laurent Vivier Message-Id: Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 8f68f255c0d9..669add74c11a 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -320,9 +320,6 @@ _syscall3(int,sys_syslog,int,type,char*,bufp,int,len) #ifdef __NR_exit_group _syscall1(int,exit_group,int,error_code) #endif -#if defined(TARGET_NR_set_tid_address) && defined(__NR_set_tid_address) -_syscall1(int,set_tid_address,int *,tidptr) -#endif #if defined(__NR_futex) _syscall6(int,sys_futex,int *,uaddr,int,op,int,val, const struct timespec *,timeout,int *,uaddr2,int,val3) @@ -12196,9 +12193,14 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1, } #endif -#if defined(TARGET_NR_set_tid_address) && defined(__NR_set_tid_address) +#if defined(TARGET_NR_set_tid_address) case TARGET_NR_set_tid_address: - return get_errno(set_tid_address((int *)g2h(cpu, arg1))); + { + TaskState *ts = cpu->opaque; + ts->child_tidptr = arg1; + /* do not call host set_tid_address() syscall, instead return tid() */ + return get_errno(sys_gettid()); + } #endif case TARGET_NR_tkill: