From nobody Fri Apr 4 05:02:30 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1741437002; cv=none; d=zohomail.com; s=zohoarc; b=NWe5m7TWOmuGst5IVep839xGKI5O0jo8wu6UB2Lht1JQjycwywyTxbu/cXv+MuhypvmMryEMQwd5gU4VpCx8aBopqkebnwhbSIdydS/n4jD0Dtj/Ia+jq6oMSCa7vW+3i67brVjy4tJICbU+lkM/IFwnwxyCTo1D+Lp794d2pW0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1741437002; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=lNWRd/3bpDqDY9go9fwbBzHVlSOjDlQlmHNSNyWLCFQ=; b=mi7yYdfTnJioCkqV7yunZeFEwoTUkTHI/rLqyBdBpvy43/c/RtFOwdqRbEp/rOXstJIGero/kLosrp8Qep80HwxbMx3C8FmdnkgB3sBQhW/FkAVFYkT4394JQhyKeJv1fK7xdjzbx9OQgyzVU85kOUiVz0l89kSzWAEgsLGBzS0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1741437002048209.43172227441698; Sat, 8 Mar 2025 04:30:02 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tqtIs-0006X9-5u; Sat, 08 Mar 2025 07:29:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tqtIi-0006UB-MN for qemu-devel@nongnu.org; Sat, 08 Mar 2025 07:29:14 -0500 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tqtIc-0002Bd-Qm for qemu-devel@nongnu.org; Sat, 08 Mar 2025 07:29:05 -0500 Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-39140bd6317so68502f8f.1 for ; Sat, 08 Mar 2025 04:29:02 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3912c1031fdsm8434950f8f.89.2025.03.08.04.28.59 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sat, 08 Mar 2025 04:28:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1741436941; x=1742041741; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lNWRd/3bpDqDY9go9fwbBzHVlSOjDlQlmHNSNyWLCFQ=; b=eh+zA946OZtKL44+9K4/NzexQYPy5C3xUiG998OVU2tr84hIWSxFDsEAoSHDanW7gC B2HTmUfhisTa8oVxxlGH12sDwdXnS4yfzF8H92IQqxMI4ai0zix8nvwNiwwnw0WvR/0I PSiqnwEl38+mTpJlshxvQvT75yFkrxhrOHeLuJgIf0OU1GqAXFiAsfBT8xfn5iH46xnO dgZo+oJrVsMHd4MotCUwME7G1m46h2DlrBqf0XwCXBMIlImrnmXu0fyjXEFW97Lx6J9u kHKFlDI+MkvVE4BOPoHlm/PbQ7xWjhlA8SvLpMRyAjP2WnTpbkfGLFvWYhOC3UVTiW5n C9sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741436941; x=1742041741; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lNWRd/3bpDqDY9go9fwbBzHVlSOjDlQlmHNSNyWLCFQ=; b=e3161xwGE50dGthjdCT98Lw2qTYTKKil8vJFprChUJcdqdMVhG3b68z0ocjFtf56PJ z5SIpOzIKKLBFb99ZCMIqmIA+WYW/0u5dHn1UgS4nnUDSAiZwWHuAR/1t3jzm3BaqVQA HwEb0yODgFrVF+9BIxri1yrLHKr6HICpf8uJzOfqbo1y1G0JxK0DL7KZsTVSTWFCzQ1g GAz6Y/0jCi+a8WS2BqbndujawrZoGEoTcw/b8UhureT8zO8I+FXFHTSFdj7hke09dadJ W+kPrAF/2npxqRpv1Z8OC5NNl7Mc4kMFmZYNhd8d/pag6psjiGMRSWKP2CzmuFENmGgb 0HPQ== X-Gm-Message-State: AOJu0YxmyVVlntw6EJXTW5Dec8BhuQPj+o2BajCc8+EdNZOaKcylS0xA qcsEHe3WS0yvy0RJcJyaZb1A3/RmvU/DeOMlfXhHN1sSbV5EnK356osmo3kecLAnbnU5gDHFQIt Ee2Q= X-Gm-Gg: ASbGncvM8wZ3l403xJ1BP6/wTECeo0o2dMeIjtYLff31GlfjvMgMcj+Xo6txg+EJONX u3Ywik21dRaLs1TMJ7pdibpeD4lolXBszck9xgns6tCM0Kz561EQ9pu0FfUgX45cLVrqyxybvA1 J9e7Za2nKRqnsFUKGBRnuTaPDB2vbXZGSVij8yc3HUtKHJUYmQfDmJv/oJxTiRof5MJF5ko7OUr I4FSovqTUX34wIGZovOSx4MRGfHE9VpQq8OpNfhOYn/gx+YyGG/R8OAXjgjuU1V0aCuccHH8wzp zrEVdSyva+tx6tHcmXvGG8sr29Iyz8yeIxGRfC35Fth6ORZ0HjKaUE29K/tpYOR5Pt0qGkXFmzZ f/nxMBVgSfZdk/I+t0bw= X-Google-Smtp-Source: AGHT+IGMluLQ6WjIStepyGF8R0zu2xurdD0n4VO2r4YxLPlaKmqC91urDhWP+6d2NapoTshUuT3Uzw== X-Received: by 2002:adf:a39c:0:b0:391:34ef:ae6f with SMTP id ffacd0b85a97d-39134efaf51mr2877368f8f.29.1741436940882; Sat, 08 Mar 2025 04:29:00 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Riku Voipio , Laurent Vivier , Kyle Evans , Warner Losh , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson Subject: [PATCH v4 3/3] user: Extract common MMAP API to 'user/mmap.h' Date: Sat, 8 Mar 2025 13:28:42 +0100 Message-ID: <20250308122842.76377-4-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250308122842.76377-1-philmd@linaro.org> References: <20250308122842.76377-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42a; envelope-from=philmd@linaro.org; helo=mail-wr1-x42a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1741437004254019100 Keep common MMAP-related declarations in a single place. Note, this disable ThreadSafetyAnalysis on Linux for: - mmap_fork_start() - mmap_fork_end(). Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Warner Losh Reviewed-by: Richard Henderson --- bsd-user/qemu.h | 12 +----------- include/user/mmap.h | 32 ++++++++++++++++++++++++++++++++ linux-user/user-mmap.h | 19 ++----------------- 3 files changed, 35 insertions(+), 28 deletions(-) create mode 100644 include/user/mmap.h diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h index 0b3bd65b180..c1c508281a8 100644 --- a/bsd-user/qemu.h +++ b/bsd-user/qemu.h @@ -32,6 +32,7 @@ extern char **environ; =20 #include "user/thunk.h" +#include "user/mmap.h" #include "target_arch.h" #include "syscall_defs.h" #include "target_syscall.h" @@ -233,19 +234,8 @@ void print_taken_signal(int target_signum, const targe= t_siginfo_t *tinfo); extern int do_strace; =20 /* mmap.c */ -int target_mprotect(abi_ulong start, abi_ulong len, int prot); -abi_long target_mmap(abi_ulong start, abi_ulong len, int prot, - int flags, int fd, off_t offset); -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); int target_msync(abi_ulong start, abi_ulong len, int flags); -extern abi_ulong mmap_next_start; -abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size, abi_ulong alignme= nt); void mmap_reserve(abi_ulong start, abi_ulong size); -void TSA_NO_TSA mmap_fork_start(void); -void TSA_NO_TSA mmap_fork_end(int child); =20 /* main.c */ extern char qemu_proc_pathname[]; diff --git a/include/user/mmap.h b/include/user/mmap.h new file mode 100644 index 00000000000..4d5e9aac70a --- /dev/null +++ b/include/user/mmap.h @@ -0,0 +1,32 @@ +/* + * MMAP declarations for QEMU user emulation + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ +#ifndef USER_MMAP_H +#define USER_MMAP_H + +#include "user/abitypes.h" + +/* + * mmap_next_start: The base address for the next mmap without hint, + * increased after each successful map, starting at task_unmapped_base. + * This is an optimization within QEMU and not part of ADDR_COMPAT_LAYOUT. + */ +extern abi_ulong mmap_next_start; + +int target_mprotect(abi_ulong start, abi_ulong len, int prot); + +abi_long target_mmap(abi_ulong start, abi_ulong len, int prot, + int flags, int fd, off_t offset); +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_ulong mmap_find_vma(abi_ulong start, abi_ulong size, abi_ulong alignme= nt); + +void TSA_NO_TSA mmap_fork_start(void); +void TSA_NO_TSA mmap_fork_end(int child); + +#endif diff --git a/linux-user/user-mmap.h b/linux-user/user-mmap.h index b94bcdcf83c..dfc4477a720 100644 --- a/linux-user/user-mmap.h +++ b/linux-user/user-mmap.h @@ -18,6 +18,8 @@ #ifndef LINUX_USER_USER_MMAP_H #define LINUX_USER_USER_MMAP_H =20 +#include "user/mmap.h" + /* * Guest parameters for the ADDR_COMPAT_LAYOUT personality * (at present this is the only layout supported by QEMU). @@ -39,24 +41,7 @@ extern abi_ulong task_unmapped_base; extern abi_ulong elf_et_dyn_base; =20 -/* - * mmap_next_start: The base address for the next mmap without hint, - * increased after each successful map, starting at task_unmapped_base. - * This is an optimization within QEMU and not part of ADDR_COMPAT_LAYOUT. - */ -extern abi_ulong mmap_next_start; - -int target_mprotect(abi_ulong start, abi_ulong len, int prot); -abi_long target_mmap(abi_ulong start, abi_ulong len, int prot, - int flags, int fd, off_t offset); -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); -abi_ulong mmap_find_vma(abi_ulong, abi_ulong, abi_ulong); -void mmap_fork_start(void); -void mmap_fork_end(int child); =20 abi_ulong target_shmat(CPUArchState *cpu_env, int shmid, abi_ulong shmaddr, int shmflg); --=20 2.47.1