From nobody Sun May 19 09:42:24 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1696376408; cv=none; d=zohomail.com; s=zohoarc; b=Lc9fUeumK/9kmxgwCR/+8JjVgkLI9sAsgKdczW5Gwj+ljoFJ8RmrRmg6dNK2RrWJiWS5CqFmKP+GUZyWKIkdXrbdQYXE0SClRvO0+IU2xYI554c5RicdtxA/4PYJYPt6ern/6O+vbApCI/qIvUcsDqBWE+37kJKC9/74RjriwhA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696376408; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=IWdm+hDV/GXkOmrbOCDP//62BDkJTz7eQAUm8g6H/pk=; b=fHY7Hko5Iqm955pRcni28sWX12TrcIgyACmCpsxIWh95c5yUa0+srdkuV1/NQTVh8TPpDcw1MljoGqolirNFkmLpAmEyb4CANEWcBGI5ONgj6A+0gIF/TniqzNLpUN6Yp9D752KWOouXvhubrqPKZMk9Cl4NuheGL5l1LmIu3hY= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1696376408976481.9836706351192; Tue, 3 Oct 2023 16:40:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qnov6-0003vS-75; Tue, 03 Oct 2023 19:35:16 -0400 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 1qnov4-0003vA-7q for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:14 -0400 Received: from mail-io1-xd2d.google.com ([2607:f8b0:4864:20::d2d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qnov1-0006gW-71 for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:13 -0400 Received: by mail-io1-xd2d.google.com with SMTP id ca18e2360f4ac-79fc3d32a2fso60161939f.1 for ; Tue, 03 Oct 2023 16:35:08 -0700 (PDT) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id w25-20020a6b4a19000000b0079fa1a7cd36sm593596iob.30.2023.10.03.16.35.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 16:35:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1696376108; x=1696980908; 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=IWdm+hDV/GXkOmrbOCDP//62BDkJTz7eQAUm8g6H/pk=; b=pI+p2q0DCqHgkfw+ntQpEWRSlMCXp3LiSgpL72dGfABdwbZoUGDwH9gbFysEpYZU4u hCBrbO/IRW3Kl3XZwSstIKduUV/bQJy0uN+YRvxZ0qsi+AldKCP8AYrxcZALj1pi3BF0 8+Jc47fRnXijRVEwbJ6s1ozCYEpWTfAsoTxrFwZ7mY2fpg6Gj80n+q94hC4cdmYephuP nmia7bBPRzlVcRaNJoPqKS24ff6UHJJSbsAWkbI8UQ//VdNceyq4CTpOr9Yn/RhUao5b GQ+W/RduAPA58t7ZCsmGEj7hjrAx8FZid9oWw9JZIJ3jyVwq6NWTerGtn0kV+QEG7a+f zQmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696376108; x=1696980908; 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=IWdm+hDV/GXkOmrbOCDP//62BDkJTz7eQAUm8g6H/pk=; b=piGjBLWxo3Y1QoWVbFt5TPq8foJ7JN3Br8nQE3LRbcYYbUaDes8IPbWOfcaXJmacKg VCxkrFfW8nDMfbGa+jJNY3jHhGSzj9Q96hTe4AuD11Q15yDbnYbU7bUVAOFe+/ReQ1J8 v2f0IRYyGHNi3WZoLNnm5V2zydYqe7pW8mSOrUq0uxE+ld+6BrHkjYq72jlXpZLjp1Dl jNBX2TenjlUIbnqpfvc2n5koYtep1pJwpMWqvWjNaK6vN7pcuSh94UYVsDNWkc3Qw+kV 5DlWbwOXTIFPh/NDedi/rIMpm38ycGLU+P0+pYfuPN17hw/FtMmXNVKK3wB46wZ1jvyd UV1A== X-Gm-Message-State: AOJu0YwyRFD6eVFy5fGhUEKZTZ1e3HqQa5nqVZmaMibFpA4JVTnNBI15 wVHU3k5XBijF8RQu4cPw1h245hUhFiZ3Kubu6/r4gA== X-Google-Smtp-Source: AGHT+IE9dMWSyqEayfRJFF7JquFMLPPymh1C06GHHWp03sqM2FU/sMIM7lTCeGQw8g98Zud7MHZEhw== X-Received: by 2002:a6b:5b03:0:b0:787:1555:efca with SMTP id v3-20020a6b5b03000000b007871555efcamr977020ioh.5.1696376107841; Tue, 03 Oct 2023 16:35:07 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Thomas Huth , Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Wainer dos Santos Moschetta , Beraldo Leal , Warner Losh , Kyle Evans , Karim Taha , Kyle Evans , Richard Henderson Subject: [PULL 01/51] bsd-user: define TARGET_RFSPAWN for rfork to use vfork(2) semantics, and fix RLIM_INFINITY Date: Tue, 3 Oct 2023 17:31:25 -0600 Message-ID: <20231003233215.95557-2-imp@bsdimp.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231003233215.95557-1-imp@bsdimp.com> References: <20231003233215.95557-1-imp@bsdimp.com> MIME-Version: 1.0 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: none client-ip=2607:f8b0:4864:20::d2d; envelope-from=imp@bsdimp.com; helo=mail-io1-xd2d.google.com 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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 @bsdimp-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1696376409657100002 Content-Type: text/plain; charset="utf-8" From: Karim Taha RLIM_INFINITY on FreeBSD, OpenBSD and NetBSD has value of ~(1<<63), caculat= ed one way or another. Signed-off-by: Kyle Evans Signed-off-by: Karim Taha Reviewed-by: Richard Henderson Reviewed-by: Warner Losh Message-Id: <20230925182425.3163-2-kariem.taha2.7@gmail.com> --- bsd-user/syscall_defs.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bsd-user/syscall_defs.h b/bsd-user/syscall_defs.h index 9c90616baae..ddd38c13e08 100644 --- a/bsd-user/syscall_defs.h +++ b/bsd-user/syscall_defs.h @@ -130,11 +130,7 @@ struct target_freebsd_timeval { /* * sys/resource.h */ -#if defined(__FreeBSD__) #define TARGET_RLIM_INFINITY RLIM_INFINITY -#else -#define TARGET_RLIM_INFINITY ((abi_ulong)-1) -#endif =20 #define TARGET_RLIMIT_CPU 0 #define TARGET_RLIMIT_FSIZE 1 @@ -390,6 +386,10 @@ struct target_freebsd_flock { int32_t l_sysid; } QEMU_PACKED; =20 +/* sys/unistd.h */ +/* user: vfork(2) semantics, clear signals */ +#define TARGET_RFSPAWN (1U << 31) + #define safe_syscall0(type, name) \ type safe_##name(void) \ { \ --=20 2.41.0 From nobody Sun May 19 09:42:24 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1696376485; cv=none; d=zohomail.com; s=zohoarc; b=eefMs6N0sNlQvFYLPHn8Uhh7Q8rNx3kFzlCn1yjJBVI9bAx3xfG1SQNs8+xSgDKWUexIeBYnaNYaUEbi1S4vR6i0v4JrKHW2tZnN/5UUyvp1kz+jSjMtYmo3MBRZoq3iRA951oD7pXFe6Bk/kC9EZbMmRcQOHnqZIG/IYEZolw4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696376485; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=u5huf7WpcMpMUeKt9etdLQ59Hm45g8cQi4QWAhrlxD0=; b=dfpDF2volYFwLoZ+J9j+DmJbDVzNXpbT58IEXDRF26vxoIu0ONdtCVkAVavEFMPakI6h213tK8vs3G5SJDAwAgfvuQjfBUyoz2kWUszu7dlyA0ULu4U2aJEXsaVD0Jr1rml02IAQd3WpjJW1ggj9iKtfluFd46Oi4tHo5c7d08U= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1696376485150254.9368270095; Tue, 3 Oct 2023 16:41:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qnov7-0003wj-NQ; Tue, 03 Oct 2023 19:35:17 -0400 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 1qnov5-0003vL-JN for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:15 -0400 Received: from mail-io1-xd2d.google.com ([2607:f8b0:4864:20::d2d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qnov2-0006gd-4F for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:15 -0400 Received: by mail-io1-xd2d.google.com with SMTP id ca18e2360f4ac-79fa416b7ffso60867739f.2 for ; Tue, 03 Oct 2023 16:35:10 -0700 (PDT) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id w25-20020a6b4a19000000b0079fa1a7cd36sm593596iob.30.2023.10.03.16.35.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 16:35:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1696376109; x=1696980909; 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=u5huf7WpcMpMUeKt9etdLQ59Hm45g8cQi4QWAhrlxD0=; b=OzQdUBF4LXCL4QGdL4u2XDgWOQXOtMGJm7UOqTOJpVnUno1yFMXMYXIm5/2a3E4zYS 7xy4yr7WFMBsm7VDybiJenBPGeUjXqyJdci1vGqzMH902/e1zEyNTFYJ+WI74h+UTah9 8iNnve42P73nUllKDekReeR4IN5r448S6Kx523l43mEUoyocW/4Tg8oNAdM1WBe0qBqc ezpZS5a3ovjxUHypflSnDQH+empEgo0sz9yJvm5Oojs5rguThdRqmhJYLJxENmfbBBnc SsgN6kjNDkdWPfBauvvcgKCdH8pe7D/gvT31p+7/MjjpQDNbZ7KZEF5ZmNFXqY0YoWYB wqPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696376109; x=1696980909; 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=u5huf7WpcMpMUeKt9etdLQ59Hm45g8cQi4QWAhrlxD0=; b=uUe0sS2uIdEWQQ1QdltsNjro20//pFO2GROBCFJ+83BzfqPYr7titjf73t10UdLAh6 Dbm7xlLdrNd0aFMepozVHSLdV6tg+KO1C1yuxJaVh6+9hJwN7TQ/+3xLnkhGFVP8sJ0g atR17RRuY2pCgzEWgc4mW9nSN6YTChWlxsTr0RBkWuwKBEIAvPyEU8Ez9vrswBA2O78z F2MOmxBzgvdem0KxO+VmaXVqiWzzua96UOiKUmCdgkh5EhTsK3NIO/6KcWNKNtza1L9n q7hxSwy9eGkzH9fUCYeIJPN5BPIB3rfea+Nm+1mtYdagOTR5nFiB+31isprvrmfS0UEi twVg== X-Gm-Message-State: AOJu0Yy/zrpfL9u2/WnItgbf6jU8ypqpx9uL/H7reevCLIW6dEGbCzBt yQmJ2K/1RTOqi0TBvdyH6tO67p37MT96pPiRS65umA== X-Google-Smtp-Source: AGHT+IFUJ122Ie9NCheR/OEg3UPU2Ta3L2B6lAXRj7/VLZ6ONiYOkhGZdjY0WNruVgsDFLyYfsI94w== X-Received: by 2002:a5e:8c0c:0:b0:795:16b8:85fc with SMTP id n12-20020a5e8c0c000000b0079516b885fcmr1004957ioj.0.1696376108730; Tue, 03 Oct 2023 16:35:08 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Thomas Huth , Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Wainer dos Santos Moschetta , Beraldo Leal , Warner Losh , Kyle Evans , Stacey Son , Karim Taha , Richard Henderson Subject: [PULL 02/51] bsd-user: Define procctl(2) related structs Date: Tue, 3 Oct 2023 17:31:26 -0600 Message-ID: <20231003233215.95557-3-imp@bsdimp.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231003233215.95557-1-imp@bsdimp.com> References: <20231003233215.95557-1-imp@bsdimp.com> MIME-Version: 1.0 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: none client-ip=2607:f8b0:4864:20::d2d; envelope-from=imp@bsdimp.com; helo=mail-io1-xd2d.google.com 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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 @bsdimp-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1696376486954100003 Content-Type: text/plain; charset="utf-8" From: Stacey Son Implement procctl flags and related structs: struct target_procctl_reaper_status struct target_procctl_reaper_pidinfo struct target_procctl_reaper_pids struct target_procctl_reaper_kill Signed-off-by: Stacey Son Signed-off-by: Karim Taha Reviewed-by: Richard Henderson Reviewed-by: Warner Losh Message-Id: <20230925182425.3163-3-kariem.taha2.7@gmail.com> --- bsd-user/syscall_defs.h | 42 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/bsd-user/syscall_defs.h b/bsd-user/syscall_defs.h index ddd38c13e08..a3bc738ff89 100644 --- a/bsd-user/syscall_defs.h +++ b/bsd-user/syscall_defs.h @@ -390,6 +390,48 @@ struct target_freebsd_flock { /* user: vfork(2) semantics, clear signals */ #define TARGET_RFSPAWN (1U << 31) =20 +/* + * from sys/procctl.h + */ +#define TARGET_PROC_SPROTECT 1 +#define TARGET_PROC_REAP_ACQUIRE 2 +#define TARGET_PROC_REAP_RELEASE 3 +#define TARGET_PROC_REAP_STATUS 4 +#define TARGET_PROC_REAP_GETPIDS 5 +#define TARGET_PROC_REAP_KILL 6 + +struct target_procctl_reaper_status { + uint32_t rs_flags; + uint32_t rs_children; + uint32_t rs_descendants; + uint32_t rs_reaper; + uint32_t rs_pid; + uint32_t rs_pad0[15]; +}; + +struct target_procctl_reaper_pidinfo { + uint32_t pi_pid; + uint32_t pi_subtree; + uint32_t pi_flags; + uint32_t pi_pad0[15]; +}; + +struct target_procctl_reaper_pids { + uint32_t rp_count; + uint32_t rp_pad0[15]; + abi_ulong rp_pids; +}; + +struct target_procctl_reaper_kill { + int32_t rk_sig; + uint32_t rk_flags; + uint32_t rk_subtree; + uint32_t rk_killed; + uint32_t rk_fpid; + uint32_t rk_pad0[15]; +}; + + #define safe_syscall0(type, name) \ type safe_##name(void) \ { \ --=20 2.41.0 From nobody Sun May 19 09:42:24 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1696376236; cv=none; d=zohomail.com; s=zohoarc; b=hSrrvRVZfK5RwgQCtztrPB9AYOWWLC3iKUfeSDB4E52BnAVLUDPzwIVEofe5cZ2FhK1zTVji0mIv1ki8Lgi0w0JHiYY5GPiAG1FPHB191iUMWAfag9Q5rLGrvcYglQPdj6xDtmM1vt1ApXRrrp/Hh9V6bKCShcxe3Ba8D0fdQ6k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696376236; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=nRg9pwrrUdH7ek792cGQPFuJ+z7VOTPX+WRxVjZhFoc=; b=i2qKiMmGhvzURxXhzKnoV77RrWooEjk7Ns9HlSiVdLlu/n8l2GFSqRkrCxGYiEsQMUEbaQNKoiwSz+/zU+sxuw2uUvW8o7tdiSOwm68ksf2mcCOu4BL4FjyBof8yfUMflUFJcL+YbudbAwSfkSKC++guTeG4yPP+XCchiVIqk+E= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1696376236145563.8735110847415; Tue, 3 Oct 2023 16:37:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qnov7-0003w3-0O; Tue, 03 Oct 2023 19:35:17 -0400 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 1qnov5-0003vK-JC for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:15 -0400 Received: from mail-io1-xd2e.google.com ([2607:f8b0:4864:20::d2e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qnov2-0006gk-4X for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:15 -0400 Received: by mail-io1-xd2e.google.com with SMTP id ca18e2360f4ac-79faf4210b2so57687839f.2 for ; Tue, 03 Oct 2023 16:35:10 -0700 (PDT) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id w25-20020a6b4a19000000b0079fa1a7cd36sm593596iob.30.2023.10.03.16.35.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 16:35:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1696376110; x=1696980910; 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=nRg9pwrrUdH7ek792cGQPFuJ+z7VOTPX+WRxVjZhFoc=; b=BprEymcq4J/buBWwmvCYsFvX3z86nNBh93UcKSzGdtGOYvmgCMBTKhJevYtz4DQri9 6i/VVY0jd3/ZHnsAN6N5c5kOWKE/DFikzNSzMgAP50XE8IDPaRoa+iZdXnfRnNk+j4By 4ukGXmHi9yBZUQkwH2Le/y9+GHR9cd3vQ6j11eQhZm8klN/q5d6Kwj9Jk07cW2A6SFKz Fvw1/c2wiiK6kZsNFlVcb9CosiHfd+6u4g3tF8Yq2CRLSUcy07DkfpV0tGdO/ZlCYTVn BLkNtw+kYJgi1sy12CcQQED9G3OGIXYN8HLnPfetiv010ig++lk6dWdQWPpnILdlgOnS oiOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696376110; x=1696980910; 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=nRg9pwrrUdH7ek792cGQPFuJ+z7VOTPX+WRxVjZhFoc=; b=PCTDT2AiXvZY8/XDK5XJci97cVnheupsjOzG8flNH2hK9OQNdgRXSTTkTnjlrHMEkZ 7t7W/UTwRqo6Y6l0QB634JXg1TVlPV+Zd8/b+XyxyMw7CjN4SS9DXGzaapxAnvm8roVZ ETN8qsCvp3oTzcQ0feJpLCBEVq4pIWArzrHUH7AmIxeP7YUVxohTiPEAt+1M7VsBsRnN N7qD6DS0OBe9ahv6JV2Bm7tbZpekHA01rRDSQJN9rdO/bYrUtYDIGyJ1CkPv3FJR2EZJ ihX7iJs2nBcTg7uJjWJ7lrHPUfrRLrrwYxPeTP5rou8EAGw4XzANPuA2ZQ18jfo/ssBb laHQ== X-Gm-Message-State: AOJu0Yx6EhOPMW/o7xxElXkbENNYyNY3CUGBTh1EM5TIAGuzat97OjVy UwJpPj7f99j8xgPZEY+vFXRnT16flBPFqA5SPdlwtA== X-Google-Smtp-Source: AGHT+IFfBD717TINbasu/Asf5Ff90RhANH8U6G4QpdRPE6inx0tgqIKTOOiMk2Z2CnY0Ppoam7h/3A== X-Received: by 2002:a5e:c24d:0:b0:79f:e9ac:f60a with SMTP id w13-20020a5ec24d000000b0079fe9acf60amr861018iop.20.1696376109717; Tue, 03 Oct 2023 16:35:09 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Thomas Huth , Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Wainer dos Santos Moschetta , Beraldo Leal , Warner Losh , Kyle Evans , Stacey Son , Karim Taha , Richard Henderson Subject: [PULL 03/51] bsd-user: Implement host_to_target_siginfo. Date: Tue, 3 Oct 2023 17:31:27 -0600 Message-ID: <20231003233215.95557-4-imp@bsdimp.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231003233215.95557-1-imp@bsdimp.com> References: <20231003233215.95557-1-imp@bsdimp.com> MIME-Version: 1.0 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: none client-ip=2607:f8b0:4864:20::d2e; envelope-from=imp@bsdimp.com; helo=mail-io1-xd2e.google.com 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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 @bsdimp-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1696376236436100009 Content-Type: text/plain; charset="utf-8" From: Stacey Son Used in wait6 system call Signed-off-by: Stacey Son Signed-off-by: Karim Taha Reviewed-by: Richard Henderson Reviewed-by: Warner Losh Message-Id: <20230925182425.3163-4-kariem.taha2.7@gmail.com> --- bsd-user/signal-common.h | 1 + bsd-user/signal.c | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/bsd-user/signal-common.h b/bsd-user/signal-common.h index c044e811653..77d7c7a78b7 100644 --- a/bsd-user/signal-common.h +++ b/bsd-user/signal-common.h @@ -35,6 +35,7 @@ int do_sigaction(int sig, const struct target_sigaction *= act, abi_long do_sigaltstack(abi_ulong uss_addr, abi_ulong uoss_addr, abi_ulong= sp); long do_sigreturn(CPUArchState *env, abi_ulong addr); void force_sig_fault(int sig, int code, abi_ulong addr); +void host_to_target_siginfo(target_siginfo_t *tinfo, const siginfo_t *info= ); int host_to_target_signal(int sig); void host_to_target_sigset(target_sigset_t *d, const sigset_t *s); void process_pending_signals(CPUArchState *env); diff --git a/bsd-user/signal.c b/bsd-user/signal.c index b6beab659e1..ea82241b70b 100644 --- a/bsd-user/signal.c +++ b/bsd-user/signal.c @@ -311,6 +311,12 @@ static void tswap_siginfo(target_siginfo_t *tinfo, con= st target_siginfo_t *info) } } =20 +void host_to_target_siginfo(target_siginfo_t *tinfo, const siginfo_t *info) +{ + host_to_target_siginfo_noswap(tinfo, info); + tswap_siginfo(tinfo, tinfo); +} + int block_signals(void) { TaskState *ts =3D (TaskState *)thread_cpu->opaque; --=20 2.41.0 From nobody Sun May 19 09:42:24 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1696376397; cv=none; d=zohomail.com; s=zohoarc; b=GwlohemRdEwOg+ro5OLnIOwi+u3eFGrcggNlLPqW8mtuRnDbhJTkNfB8GKfXGK789rbzSVASk4hJB4ml/w6KmqQxO108vxHEMTv2vDfezza4guKlb9JSSf9CyJ7MBLV0KmqLfTBmuMiSzVFTR3tFE9ZRj2d7DeYhn7G3FW37ASM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696376397; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=jzja6mNX65PpCCE06Mbtlzy3xvt/FsjtzuhPRGjLIms=; b=GbAfXNCJvWhfJysEiblgp47dGFW2CPaIsVCnZtoT1WRADqEvZHGyVtJ7XKIFEbYdynVfmyzmQefusap6U/q0WqXb62DZkFMj6KUlvpdif9bOfSQ5PoKNm0uMkOWSaGylUNhJydqg1yE5ymYAT7H35Ma8caU7EsASRCoeznBvsJQ= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1696376397889633.1384169685085; Tue, 3 Oct 2023 16:39:57 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qnovH-00045g-BI; Tue, 03 Oct 2023 19:35:27 -0400 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 1qnovE-00042x-3r for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:24 -0400 Received: from mail-io1-xd2a.google.com ([2607:f8b0:4864:20::d2a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qnov2-0006go-Sz for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:23 -0400 Received: by mail-io1-xd2a.google.com with SMTP id ca18e2360f4ac-79fa7e33573so58980239f.0 for ; Tue, 03 Oct 2023 16:35:11 -0700 (PDT) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id w25-20020a6b4a19000000b0079fa1a7cd36sm593596iob.30.2023.10.03.16.35.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 16:35:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1696376110; x=1696980910; 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=jzja6mNX65PpCCE06Mbtlzy3xvt/FsjtzuhPRGjLIms=; b=EqytJkaDM8SWnvM3CJX1ie4CpcfiRL+xluIA+rTFLy0b8Qtr6NzlvRNLCotygRyhMk 8aEkrVX3nb+QGEJVrFCPJSm4U2WAhGJcZK82PdsVWjnsnh+c10PzbKkILTqE6Ko1siFB j4L/qpbg/BZDO1uCGZHiUf/LMdZA4AevsIPjZ7Bko3JArENFOqY1ckoUem4rIrzUF480 IDWcn34e2s9o2F1C7WZ6Dendm1gWeHCInGUn+UyftXH0+jqf5Jd6P7kLW/Ij8h5qZSko v2lGEMbgIRgPsx0WeS0+vE/sAq7dg30WIPbnpPt1rCNlU39B4s3h6IlnyQKWtqNBitvc pKrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696376110; x=1696980910; 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=jzja6mNX65PpCCE06Mbtlzy3xvt/FsjtzuhPRGjLIms=; b=MGrB1zAS+ynUp2uni3QU3tLH37shipc56RjiuShRqcWYOv57i5NLNhRgHJ3EJ8WsHO PEA+lKtsZB2Pg7q0axPBdiaH+lMUQgynGZTAN8s73Ox6VCEL/Tf+r2HIXBcD3IGDEtZv cpQa/BF/lQqk9brRwsDBAkLfGgm7ei9PeruKE+hykvQpWuDdxc8ddEK0fY4x4x8ldmK0 gb4Ifi57edxNoAUCYYaYuYR1DjOsA88/O7uqLBZF1N4NOPOwEWBNH620vcBEKgNCmGqI 9hKdrUnAY3sJGYCQm/KMv/z2bjb/IMPeQeO9oo/VvUAwXUY8xHLFXf6wgPGo77ekw3aD x8iA== X-Gm-Message-State: AOJu0YyAnB5fLovlLuSYmXDgnrtoUe4GTNUagEcIzokB6eq+yyXFN1iQ RAk5jtDaDnNrfe1uAC8ZZ3uSl7/s4dy472PRAsjvPg== X-Google-Smtp-Source: AGHT+IF/BCWCGZiB7eEc3AFzNcEWEKbSfeTt/NuYIOfecsuJkLwQ5ZIlvWL4WnLoEtwt1bddfPOkTA== X-Received: by 2002:a6b:6514:0:b0:783:550e:33c0 with SMTP id z20-20020a6b6514000000b00783550e33c0mr961383iob.7.1696376110631; Tue, 03 Oct 2023 16:35:10 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Thomas Huth , Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Wainer dos Santos Moschetta , Beraldo Leal , Warner Losh , Kyle Evans , Stacey Son , Karim Taha , Richard Henderson Subject: [PULL 04/51] bsd-user: Add freebsd_exec_common and do_freebsd_procctl to qemu.h. Date: Tue, 3 Oct 2023 17:31:28 -0600 Message-ID: <20231003233215.95557-5-imp@bsdimp.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231003233215.95557-1-imp@bsdimp.com> References: <20231003233215.95557-1-imp@bsdimp.com> MIME-Version: 1.0 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: none client-ip=2607:f8b0:4864:20::d2a; envelope-from=imp@bsdimp.com; helo=mail-io1-xd2a.google.com 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, SPF_HELO_NONE=0.001, SPF_NONE=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 @bsdimp-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1696376399213100005 Content-Type: text/plain; charset="utf-8" From: Stacey Son Signed-off-by: Stacey Son Signed-off-by: Karim Taha Reviewed-by: Richard Henderson Reviewed-by: Warner Losh Message-Id: <20230925182425.3163-5-kariem.taha2.7@gmail.com> --- bsd-user/qemu.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h index d9507137cca..41c7bd31d3c 100644 --- a/bsd-user/qemu.h +++ b/bsd-user/qemu.h @@ -249,6 +249,12 @@ abi_long get_errno(abi_long ret); bool is_error(abi_long ret); int host_to_target_errno(int err); =20 +/* os-proc.c */ +abi_long freebsd_exec_common(abi_ulong path_or_fd, abi_ulong guest_argp, + abi_ulong guest_envp, int do_fexec); +abi_long do_freebsd_procctl(void *cpu_env, int idtype, abi_ulong arg2, + abi_ulong arg3, abi_ulong arg4, abi_ulong arg5, abi_ulong arg6); + /* os-sys.c */ abi_long do_freebsd_sysctl(CPUArchState *env, abi_ulong namep, int32_t nam= elen, abi_ulong oldp, abi_ulong oldlenp, abi_ulong newp, abi_ulong newle= n); --=20 2.41.0 From nobody Sun May 19 09:42:24 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1696376156; cv=none; d=zohomail.com; s=zohoarc; b=hx10sZPsAQE5NPcYGQuETPbblo5kgk1dA67kqidGAG6+oCUGhJ8zVGKyck4yBn8bhQJGcqnfMq3G8P6fOtl72EHxkTh2mKDOtiDQ+sntbmcx8w+jNK+MbXvEXclMcWIR9ZWGyeSAhAAMrt6fkZYXuYHeMZNAMgyGueYa0dghASg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696376156; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=4s+TJxjVa/sdg7uCzCwkoZKCJLn5htyPFKNsiln+QBw=; b=WyI0SoJwuXxCvRCSatNiOyqsGXaYiqq2rH0RCPkremw6OqXr42DSsjfh0MOyNuNCuu0djTZSrS6BCmF5r2O2KOINV1xTpRemXj6W0xIkQnBPif/iEYqSB5EBD85FTNMWdzG/Lii4hECduihdVnTyStU6w4mh3YMgoasjbYvpnrU= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1696376156527486.6452431851545; Tue, 3 Oct 2023 16:35:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qnov6-0003vy-Sv; Tue, 03 Oct 2023 19:35:16 -0400 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 1qnov5-0003vJ-JI for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:15 -0400 Received: from mail-io1-xd41.google.com ([2607:f8b0:4864:20::d41]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qnov3-0006gt-Ax for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:15 -0400 Received: by mail-io1-xd41.google.com with SMTP id ca18e2360f4ac-79fa5d9f3a2so57643839f.3 for ; Tue, 03 Oct 2023 16:35:12 -0700 (PDT) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id w25-20020a6b4a19000000b0079fa1a7cd36sm593596iob.30.2023.10.03.16.35.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 16:35:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1696376111; x=1696980911; 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=4s+TJxjVa/sdg7uCzCwkoZKCJLn5htyPFKNsiln+QBw=; b=y4ZCvDNhdmWbtkn3yh9CtfmS+reM7iuB7S3IaNlPFex/TcZoh3tk5sTNdf/YqSeSFX nXSIcgLUa2TFdwPgRcuk4RD9I2GByQDdwIfMVpJprbED1Lai/q2fZDaxIxxO3GimFPj5 n8xapsKZZHNjZPU9dojjhgP1Cxlt/AJw80r6vB8yA/3DRqEGCDOxGPAX9etc4nq6GKoX jp/GlXHbGDZjYvKWZxloZpcqD2JmOKcga84V10R+iV8rR/iQxT0FU390tMfS3Prv8QLi y0TTjjEDGzu0CqEVHKnsaCv2q4cbMccoqB66MfoZLQ8hA10o6iVq+GoVXVFdOm+kB/uY XoAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696376111; x=1696980911; 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=4s+TJxjVa/sdg7uCzCwkoZKCJLn5htyPFKNsiln+QBw=; b=fVXoh4D12U2Z/jA54avjwUEh2ZTQqKIyCiEQzKs7P778u9/gYGD8VeHmikN/pX3G4i FDNe8qBIeCvokAdUI2UeexwdPX9+JakGxfHTzm5G6dfhX6VFRQVq28ydxEDzIibzRk+6 yoHf293CCRhOPXe4H3tEES8yvdrN+e8UBRgYvWZbA9Zz9gNfSQ1IDGse6QJOXMj7b8KQ vE4d2nbwJWaGZZ/ZFgb7MKSsuitlCj2M6n813mGvpjZBrkLi9OnKGbYrVfmdiYyFTzuq llPtl3UQnyj+3CXah7VNbBRVC1Wgj2OlFk5d8Hfjd4oGWDxrP3PdEA0u1T/9pmvegQxV WD8w== X-Gm-Message-State: AOJu0YykzHdTibyzVjtODSfa3ti1bzBi+xUjnPw339P9w62v+6MqrV05 vSQPYSGJokUu76FPhmmiXrFhky7Y6G7/qJWMyEbEGpqW X-Google-Smtp-Source: AGHT+IGHnT0CRyYakx1Jgv1pLjRzTb5shPJnnnPDviDb9N4EiawHfBGYiGFW2IcX0/2UzvuVuMc+kQ== X-Received: by 2002:a6b:7e05:0:b0:792:7f26:dc95 with SMTP id i5-20020a6b7e05000000b007927f26dc95mr863243iom.14.1696376111521; Tue, 03 Oct 2023 16:35:11 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Thomas Huth , Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Wainer dos Santos Moschetta , Beraldo Leal , Warner Losh , Kyle Evans , Stacey Son , Karim Taha , Richard Henderson Subject: [PULL 05/51] bsd-user: add extern declarations for bsd-proc.c conversion functions Date: Tue, 3 Oct 2023 17:31:29 -0600 Message-ID: <20231003233215.95557-6-imp@bsdimp.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231003233215.95557-1-imp@bsdimp.com> References: <20231003233215.95557-1-imp@bsdimp.com> MIME-Version: 1.0 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: none client-ip=2607:f8b0:4864:20::d41; envelope-from=imp@bsdimp.com; helo=mail-io1-xd41.google.com 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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 @bsdimp-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1696376158796100007 Content-Type: text/plain; charset="utf-8" From: Stacey Son Signed-off-by: Stacey Son Signed-off-by: Karim Taha Reviewed-by: Richard Henderson Reviewed-by: Warner Losh Message-Id: <20230925182425.3163-6-kariem.taha2.7@gmail.com> --- bsd-user/qemu-bsd.h | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 bsd-user/qemu-bsd.h diff --git a/bsd-user/qemu-bsd.h b/bsd-user/qemu-bsd.h new file mode 100644 index 00000000000..b93a0b7fd5b --- /dev/null +++ b/bsd-user/qemu-bsd.h @@ -0,0 +1,38 @@ +/* + * BSD conversion extern declarations + * + * Copyright (c) 2013 Stacey D. Son + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + */ + +#ifndef QEMU_BSD_H +#define QEMU_BSD_H + +#include +#include + +/* bsd-proc.c */ +int target_to_host_resource(int code); +rlim_t target_to_host_rlim(abi_llong target_rlim); +abi_llong host_to_target_rlim(rlim_t rlim); +abi_long host_to_target_rusage(abi_ulong target_addr, + const struct rusage *rusage); +abi_long host_to_target_wrusage(abi_ulong target_addr, + const struct __wrusage *wrusage); +int host_to_target_waitstatus(int status); +void h2g_rusage(const struct rusage *rusage, + struct target_freebsd_rusage *target_rusage); + +#endif /* QEMU_BSD_H */ --=20 2.41.0 From nobody Sun May 19 09:42:24 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1696376157; cv=none; d=zohomail.com; s=zohoarc; b=jw8du1ECeM6TkJvrw3vJEI+sBgZDQSgDoAvQEhVxJ4/LMmprDgAqETmn7XVWN23s/3pDBHMEQS20wD4cVI5XMxF84JRHyGm2Oh8xPjvaZs79JE6eEjcX5ERr2KFQg/xxWS0T2SGNQHbgptB8ysL1tcRQG7CVYwCRvFSO0wmaOuw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696376157; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=xFpktNXIySwtSsbpcJMzWq911+k8gCH4IHFHAdVVqKM=; b=DcV+9IyAoCnvBNlLiuUgrxvdvY74cKVSJbpD4o6Ss+9zfWeES9zoy8ZAii+3cQ9uzc2nhuHA8L6gx4Nhz5xizGdNNw7Od+zm0euRJIr44aerWSeS/pKY7yEeVc0DzqbuUOJRxbqVH5MVZ/LeQBAmTcEeLdXN/FkT8TUdMyq8wAQ= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1696376157390110.17420761491985; Tue, 3 Oct 2023 16:35:57 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qnov9-0003y0-Vo; Tue, 03 Oct 2023 19:35:20 -0400 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 1qnov6-0003vx-Lq for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:16 -0400 Received: from mail-io1-xd44.google.com ([2607:f8b0:4864:20::d44]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qnov3-0006gy-UL for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:16 -0400 Received: by mail-io1-xd44.google.com with SMTP id ca18e2360f4ac-79f915e5b47so59899339f.2 for ; Tue, 03 Oct 2023 16:35:13 -0700 (PDT) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id w25-20020a6b4a19000000b0079fa1a7cd36sm593596iob.30.2023.10.03.16.35.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 16:35:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1696376112; x=1696980912; 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=xFpktNXIySwtSsbpcJMzWq911+k8gCH4IHFHAdVVqKM=; b=E++xI/zizL7OjRk7lk61mjLYqrpizSdeWJGEEGzBnw1hBJSd6YT3A728j3JCRliNF6 eiFHXp2sHC30QFUFUHaj7adf7SE2cUe3pltO532bGdy5Tt1BfO/9vJpqSkBjLGP6vrBP t/02TxF4v+xPRO6XOo6DlFQzDetRo6FRoaDAnGfHjMzBC5RFa5Ttf8PAPG8Xh9ouPGCe Q7wVRn4vu85IBWXFFfzb3gmzL9kCLAnXr+bR4auSutTKadtPp9LMlOumEXXoWQD40uWm e4oYzStGjThIedEEA3BGEZcqAYDm9IMqcgRdadCQ3Dn8MKgg6WvQ3x83fzcYArgr5ZtS QJnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696376112; x=1696980912; 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=xFpktNXIySwtSsbpcJMzWq911+k8gCH4IHFHAdVVqKM=; b=cqfXgBT8c3njWQNKbnk50arRj2JVG0BlSZgxPdTc3cnTqWUz8vHpoWh47dZBHzOgGE UbowWz7UmzJpnutm6XaZG35oHKelRIk0OdeflCR15QDyWcHDwj+UB2KArZSJ5Wc1SdOH /e0vASLFrG104oalLd+2AmTFEyB3p0yQ75xn7z1n/5BSPLntAMnsE/HHAjujKICNPQ2/ TOqgmta7WwMLGPIhBhE3PhVVao1ZoIgafJP1Y4MSoSxMZTjZpFERLiRab9ivfQhQ36td ucDfz92cUAbDYQdRf4CAVhNZzCCQzGv48P101sLyD7o5lsdUeLLnCQJIKIooErP53eI0 9U4w== X-Gm-Message-State: AOJu0YxTN8ra/0fLvCmxxQZerLuIGtQ/vyZSXqhSA7dX/3gqKIcVPufa 6wIOUz+bkAGZKxDB3cnAG8Tp+V+SxkzOwOloT1HNGReb X-Google-Smtp-Source: AGHT+IEKgm8wmfJAJGTrKRwsn7yuTREMwSJ/dCr2EA7jHzkdPeFF4asHknSy4uYifxXyD4FZjmPduA== X-Received: by 2002:a5e:8804:0:b0:7a2:9fd3:5684 with SMTP id l4-20020a5e8804000000b007a29fd35684mr835735ioj.18.1696376112473; Tue, 03 Oct 2023 16:35:12 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Thomas Huth , Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Wainer dos Santos Moschetta , Beraldo Leal , Warner Losh , Kyle Evans , Stacey Son , Karim Taha Subject: [PULL 06/51] bsd-user: Implement target_to_host_resource conversion function Date: Tue, 3 Oct 2023 17:31:30 -0600 Message-ID: <20231003233215.95557-7-imp@bsdimp.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231003233215.95557-1-imp@bsdimp.com> References: <20231003233215.95557-1-imp@bsdimp.com> MIME-Version: 1.0 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: none client-ip=2607:f8b0:4864:20::d44; envelope-from=imp@bsdimp.com; helo=mail-io1-xd44.google.com 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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 @bsdimp-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1696376158600100001 Content-Type: text/plain; charset="utf-8" From: Stacey Son Signed-off-by: Stacey Son Signed-off-by: Karim Taha Reviewed-by: Warner Losh Message-Id: <20230925182425.3163-7-kariem.taha2.7@gmail.com> --- bsd-user/bsd-proc.c | 40 ++++++++++++++++++++++++++++++++++++++++ bsd-user/bsd-proc.h | 4 ++++ bsd-user/meson.build | 6 ++++++ 3 files changed, 50 insertions(+) create mode 100644 bsd-user/bsd-proc.c diff --git a/bsd-user/bsd-proc.c b/bsd-user/bsd-proc.c new file mode 100644 index 00000000000..68410a0aa9d --- /dev/null +++ b/bsd-user/bsd-proc.c @@ -0,0 +1,40 @@ +/* + * BSD process related system call helpers + * + * Copyright (c) 2013-14 Stacey D. Son + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + */ +#include "qemu/osdep.h" + +#include +#include +#include +#include +#include + +#include "qemu.h" +#include "qemu-bsd.h" +#include "signal-common.h" + +#include "bsd-proc.h" + +/* + * resource/rusage conversion + */ +int target_to_host_resource(int code) +{ + return code; +} + diff --git a/bsd-user/bsd-proc.h b/bsd-user/bsd-proc.h index a1061bffb8f..048773a75dd 100644 --- a/bsd-user/bsd-proc.h +++ b/bsd-user/bsd-proc.h @@ -22,6 +22,10 @@ =20 #include =20 +#include "qemu-bsd.h" +#include "gdbstub/syscalls.h" +#include "qemu/plugin.h" + /* exit(2) */ static inline abi_long do_bsd_exit(void *cpu_env, abi_long arg1) { diff --git a/bsd-user/meson.build b/bsd-user/meson.build index 5243122fc56..b97fce14722 100644 --- a/bsd-user/meson.build +++ b/bsd-user/meson.build @@ -7,6 +7,7 @@ bsd_user_ss =3D ss.source_set() common_user_inc +=3D include_directories('include') =20 bsd_user_ss.add(files( + 'bsd-proc.c', 'bsdload.c', 'elfload.c', 'main.c', @@ -16,6 +17,11 @@ bsd_user_ss.add(files( 'uaccess.c', )) =20 +elf =3D cc.find_library('elf', required: true) +procstat =3D cc.find_library('procstat', required: true) +kvm =3D cc.find_library('kvm', required: true) +bsd_user_ss.add(elf, procstat, kvm) + # Pull in the OS-specific build glue, if any subdir(targetos) =20 --=20 2.41.0 From nobody Sun May 19 09:42:24 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1696376251; cv=none; d=zohomail.com; s=zohoarc; b=ZcaaLC2euAN2Wz58Zy13d5eFOeAYFpMelvCssf/o54woqIK632A8mNBiEhku6LBwq71y9Ou93Mp3+41r2SSsAoEOzl2pqYhkC7OZvDyM8A/c0oncaPhKLP5xpO3J/RDvKAhLOQk/VuaykENQDYRjJ3jczfy73o5t5zfD6/RnShI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696376251; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=qAzCYw2NEfSKNP7dM+RUN8lAAw5B4Z+NHtHEbIs3+uw=; b=P9ebaOphv6TRErb9HE9C1xtVX8w9rN5zbLEK5M6GFYl72CaN0ciUgVsT3jKtj40L2lHUHjCtnrDbWppOsaDDfjvmcMazv6lk3PFB97qF3CoO9wmbsClmFgTzw4hlCuDgs8jG/MdGiZ+MYbKRtQnVCPyHwgyKorq0s+Yglscoiyk= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1696376251294863.7170591209449; Tue, 3 Oct 2023 16:37:31 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qnov7-0003wZ-Ki; Tue, 03 Oct 2023 19:35:17 -0400 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 1qnov6-0003vz-Rx for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:16 -0400 Received: from mail-io1-xd36.google.com ([2607:f8b0:4864:20::d36]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qnov5-0006hl-Ay for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:16 -0400 Received: by mail-io1-xd36.google.com with SMTP id ca18e2360f4ac-7a2a9e5451bso58458339f.1 for ; Tue, 03 Oct 2023 16:35:14 -0700 (PDT) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id w25-20020a6b4a19000000b0079fa1a7cd36sm593596iob.30.2023.10.03.16.35.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 16:35:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1696376113; x=1696980913; 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=qAzCYw2NEfSKNP7dM+RUN8lAAw5B4Z+NHtHEbIs3+uw=; b=jRepES0hLoCFN5mZF/I2IM2SMeZhrG36Mh8riZA3wA8He0E/UIdRnMUrAfDc89hpV7 u12R2BqXgSTqlTc1i0ZrHho5695MnRLnrD5OCMk6xgZcQ3LYtdv24BcCrSLgpCS04HzD Z6KI4NBHm9u2GNQZM1QuNobYfIRJPVOk9avC7byh32w6BdfuHgTEYFElHDvvluXOdwXx ni9VZctDICCdXVH5JWN/S2AOhnABAh+uHFqlrbZbN45oRY7OLSyz5rLe5lzQNbS/6yvW oVz+RP/9qtefLEt8FeVyJCfs5oQQxX6USbZI32fsoeI/GpQFpYPyhr0JNKjYqM3wuzH0 2JUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696376113; x=1696980913; 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=qAzCYw2NEfSKNP7dM+RUN8lAAw5B4Z+NHtHEbIs3+uw=; b=WeTis2S0YUinbPNI1ZKIBYnVoUeDXWY2VTqXMYkdyLgcPgW47MB3ANsWOnyVKlKADo 4hIx/K2oVMJKln2gXvWLEYOniPXpS1cAAriEpBXVJvyhJUC5cQu5YjPQav7tIcRWtRl5 edmi277KDFClUSYnEwv9sPP4pRSVQNUDSmab5Vq9bplBn6Tjez1TaeAQMxzP5h1OyvL4 w6sVffsHjq7uOXQpkO5f9ymZEeyq8OUnB22yoUCGy3XDl+IBvkVqghZnobvKXArbboDg IKOglrkaac3FXeBDx4/wcDpYnGuUu6aa+ChWTTmD7o0AO+g5FDss2eL+6epbQiIhK5ia 6faQ== X-Gm-Message-State: AOJu0YwJ+/OJiEvzvAA4ZXdmGzv6sL/9kRw5MATtJHyYlNiaXdTB1501 bstWGF/MDgRG6dbuSqxM4FUlTWelI7xvGfZ8K1zUWw== X-Google-Smtp-Source: AGHT+IG90aPxYsj1Nu4V14DoTqZI2eaArW07wSDQHrRombzQoAqJJ4/yW0/Mugjt+lbAUx0mpkHKcw== X-Received: by 2002:a6b:7e05:0:b0:792:7f26:dc95 with SMTP id i5-20020a6b7e05000000b007927f26dc95mr863296iom.14.1696376113341; Tue, 03 Oct 2023 16:35:13 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Thomas Huth , Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Wainer dos Santos Moschetta , Beraldo Leal , Warner Losh , Kyle Evans , Stacey Son , Karim Taha , Richard Henderson Subject: [PULL 07/51] bsd-user: Implement target_to_host_rlim and host_to_target_rlim conversion. Date: Tue, 3 Oct 2023 17:31:31 -0600 Message-ID: <20231003233215.95557-8-imp@bsdimp.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231003233215.95557-1-imp@bsdimp.com> References: <20231003233215.95557-1-imp@bsdimp.com> MIME-Version: 1.0 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: none client-ip=2607:f8b0:4864:20::d36; envelope-from=imp@bsdimp.com; helo=mail-io1-xd36.google.com 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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 @bsdimp-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1696376252738100003 Content-Type: text/plain; charset="utf-8" From: Stacey Son Signed-off-by: Stacey Son Signed-off-by: Karim Taha Reviewed-by: Richard Henderson Reviewed-by: Warner Losh Message-Id: <20230925182425.3163-8-kariem.taha2.7@gmail.com> --- bsd-user/bsd-proc.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/bsd-user/bsd-proc.c b/bsd-user/bsd-proc.c index 68410a0aa9d..19e39a2f764 100644 --- a/bsd-user/bsd-proc.c +++ b/bsd-user/bsd-proc.c @@ -38,3 +38,13 @@ int target_to_host_resource(int code) return code; } =20 +rlim_t target_to_host_rlim(abi_llong target_rlim) +{ + return tswap64(target_rlim); +} + +abi_llong host_to_target_rlim(rlim_t rlim) +{ + return tswap64(rlim); +} + --=20 2.41.0 From nobody Sun May 19 09:42:24 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1696376269; cv=none; d=zohomail.com; s=zohoarc; b=bW9emvpwy8sOc2TDkibRtBTPak+rezJZrWyVgmSVxr7a4ZbYgnHobtMI4AqmonNZ6BX6FWQRH4Fmtamn+tJySWSF/LfY+ySmowIuGQ/fY1dEB3derdEguO4EDk5/BHy3spIWLAOK09TwXQDsFuRkDgJWvhzKwae6/pgtpXEk/Us= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696376269; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=JWF4bLnZdn+X6WLEHlvePe0JZlfECQ9IWk4w/3GZptI=; b=fM/fsrfOI142Nk3UHxpXt2vpnGl/TpKP+tpjkJfTxw1FevqSg7vomSWMC2TMbV9WUHexG+eiXd6uVbfHdg40bO0laYiESM17JGv0VPwCvecZwdBAQ5g7maKsDyVhp4fFpW86uiWFc8ieKaHnkojaTQ3ciRRG9ERD0aeWEyfnRr4= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 169637626923020.394601014436034; Tue, 3 Oct 2023 16:37:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qnovA-0003y2-0W; Tue, 03 Oct 2023 19:35:20 -0400 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 1qnov7-0003wW-DQ for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:17 -0400 Received: from mail-io1-xd41.google.com ([2607:f8b0:4864:20::d41]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qnov5-0006iM-PZ for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:17 -0400 Received: by mail-io1-xd41.google.com with SMTP id ca18e2360f4ac-79fe6da0095so60238539f.0 for ; Tue, 03 Oct 2023 16:35:15 -0700 (PDT) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id w25-20020a6b4a19000000b0079fa1a7cd36sm593596iob.30.2023.10.03.16.35.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 16:35:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1696376114; x=1696980914; 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=JWF4bLnZdn+X6WLEHlvePe0JZlfECQ9IWk4w/3GZptI=; b=lDAFgN6+UT+xRp4EN/hoNNKLgQwer9eoduB3jthnEMRgL5A/EhxiQhiy9sOAsuxo/5 SaTO2GP7ad7/+ZNYf2wi+VYlLAEyQYLoCUm8gZxzH3lRNnijQg7EdaQAIusaCNVEc7u/ d0bRgfYfB5Xeix6s114obsgc8lT0hD8/xgGIxYecWfJehUGKJw9QfOvasEeekjGsFANW MGoozWJh3VpszCWP684u9Uy3+iUp7mHkcrFSpSpI0RckRY17aCybnRFoOOZ7kL9vCEtC htIQ6ThgsVOYJYzlyzpLcyqqwB0/8E3f03ARJY2566SPZqraoMh27KdpPI7IiCDg5Y2H 9O1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696376114; x=1696980914; 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=JWF4bLnZdn+X6WLEHlvePe0JZlfECQ9IWk4w/3GZptI=; b=dZKRsn7m4degEbv73oomhiDCn2LfQYnbGX/uNfzfsGS/EIsShUHe2KYWAG/Q5yD/7y 1aiAmVtdFNPCoY7LRYF3yELsOFP0uDt72/3+6MW9e5VLINkdzMdSr9C38l7mZFArUdkY MvKuBIvlRC6+S975cyMgZOq8PT7VDjzA7cUBMVQSZLgB8d4B6LVNXILQhKkEz+qmh4Rh uhjYbw4cprp8qvq9NRC+qt/73twuPKX8Vb4aT4EbebvYDJ8JxQvadYu9eWbpO4VsZAhG x185248uw6mQqi7AOu5kLXLf11bfD6Rk8ItzWAzJaCoPD1iZmimI94hdXJWuayKU7zZ1 lWzg== X-Gm-Message-State: AOJu0YzRZLUYMeiiZDj62jILvYALiq/7KhAt5eMtrZE0W0QOZ8UHJvX5 9RM6+tfBoPzJwsjozpUqMhufx1MluTQNK+mk78e9Xaw7 X-Google-Smtp-Source: AGHT+IGJmjY1RHkj3MxMan6j9kAJq/5A641UxM+oZB6HsJcRZThUHtMCsDb3QPxAR1LxMI1JY5+gfA== X-Received: by 2002:a5d:9946:0:b0:77e:249e:d84 with SMTP id v6-20020a5d9946000000b0077e249e0d84mr907010ios.5.1696376114263; Tue, 03 Oct 2023 16:35:14 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Thomas Huth , Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Wainer dos Santos Moschetta , Beraldo Leal , Warner Losh , Kyle Evans , Stacey Son , Karim Taha , Richard Henderson Subject: [PULL 08/51] bsd-user: Implement host_to_target_rusage and host_to_target_wrusage. Date: Tue, 3 Oct 2023 17:31:32 -0600 Message-ID: <20231003233215.95557-9-imp@bsdimp.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231003233215.95557-1-imp@bsdimp.com> References: <20231003233215.95557-1-imp@bsdimp.com> MIME-Version: 1.0 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: none client-ip=2607:f8b0:4864:20::d41; envelope-from=imp@bsdimp.com; helo=mail-io1-xd41.google.com 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, TVD_SPACE_RATIO=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 @bsdimp-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1696376271317100003 Content-Type: text/plain; charset="utf-8" From: Stacey Son Signed-off-by: Stacey Son Signed-off-by: Karim Taha Reviewed-by: Richard Henderson Reviewed-by: Warner Losh Message-Id: <20230925182425.3163-9-kariem.taha2.7@gmail.com> --- bsd-user/bsd-proc.c | 54 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/bsd-user/bsd-proc.c b/bsd-user/bsd-proc.c index 19e39a2f764..aa386ff4820 100644 --- a/bsd-user/bsd-proc.c +++ b/bsd-user/bsd-proc.c @@ -48,3 +48,57 @@ abi_llong host_to_target_rlim(rlim_t rlim) return tswap64(rlim); } =20 +void h2g_rusage(const struct rusage *rusage, + struct target_freebsd_rusage *target_rusage) +{ + __put_user(rusage->ru_utime.tv_sec, &target_rusage->ru_utime.tv_sec); + __put_user(rusage->ru_utime.tv_usec, &target_rusage->ru_utime.tv_usec); + + __put_user(rusage->ru_stime.tv_sec, &target_rusage->ru_stime.tv_sec); + __put_user(rusage->ru_stime.tv_usec, &target_rusage->ru_stime.tv_usec); + + __put_user(rusage->ru_maxrss, &target_rusage->ru_maxrss); + __put_user(rusage->ru_idrss, &target_rusage->ru_idrss); + __put_user(rusage->ru_idrss, &target_rusage->ru_idrss); + __put_user(rusage->ru_isrss, &target_rusage->ru_isrss); + __put_user(rusage->ru_minflt, &target_rusage->ru_minflt); + __put_user(rusage->ru_majflt, &target_rusage->ru_majflt); + __put_user(rusage->ru_nswap, &target_rusage->ru_nswap); + __put_user(rusage->ru_inblock, &target_rusage->ru_inblock); + __put_user(rusage->ru_oublock, &target_rusage->ru_oublock); + __put_user(rusage->ru_msgsnd, &target_rusage->ru_msgsnd); + __put_user(rusage->ru_msgrcv, &target_rusage->ru_msgrcv); + __put_user(rusage->ru_nsignals, &target_rusage->ru_nsignals); + __put_user(rusage->ru_nvcsw, &target_rusage->ru_nvcsw); + __put_user(rusage->ru_nivcsw, &target_rusage->ru_nivcsw); +} + +abi_long host_to_target_rusage(abi_ulong target_addr, + const struct rusage *rusage) +{ + struct target_freebsd_rusage *target_rusage; + + if (!lock_user_struct(VERIFY_WRITE, target_rusage, target_addr, 0)) { + return -TARGET_EFAULT; + } + h2g_rusage(rusage, target_rusage); + unlock_user_struct(target_rusage, target_addr, 1); + + return 0; +} + +abi_long host_to_target_wrusage(abi_ulong target_addr, + const struct __wrusage *wrusage) +{ + struct target_freebsd__wrusage *target_wrusage; + + if (!lock_user_struct(VERIFY_WRITE, target_wrusage, target_addr, 0)) { + return -TARGET_EFAULT; + } + h2g_rusage(&wrusage->wru_self, &target_wrusage->wru_self); + h2g_rusage(&wrusage->wru_children, &target_wrusage->wru_children); + unlock_user_struct(target_wrusage, target_addr, 1); + + return 0; +} + --=20 2.41.0 From nobody Sun May 19 09:42:24 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1696376209; cv=none; d=zohomail.com; s=zohoarc; b=ilNSeDMCRDGbdeP7yIlmGFOzkacSO3xhie7rpGuVdJ/JyFig0ePafYSTrV6YQcJRIzNuq6LQjAa9GExi1KZGR8j9Sa1XFszbzZWaKtjjz6wEysq1jhjboMwPyNBh59Kbq2tZX5RZXSSL94wJ22u7D8dbCE4JUuF1z1hxltpmfwY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696376209; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=hSOU5X81V46msYlqeKtgkBYQcLTO4MUKpgJ2TqbhBJ4=; b=NQ39nVDqfEeWHwVV2C4GBCHUDGWFKeukuKzbR1DndsQnp/VXMOmWmXeC8FY+ingY2HhzUupfsLsOQKl+offrWCqxnAFLj7hJeE4l/nvlWltKXsVKtc5tsYTxmOOZThBVr49qLIjPHawAfhxdOKNJcrEuaqzXYJnOvQIbWn0Vxdc= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1696376209171204.68897788614447; Tue, 3 Oct 2023 16:36:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qnovC-00041d-TL; Tue, 03 Oct 2023 19:35:22 -0400 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 1qnov8-0003xN-Sm for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:18 -0400 Received: from mail-io1-xd2c.google.com ([2607:f8b0:4864:20::d2c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qnov6-0006no-Nf for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:18 -0400 Received: by mail-io1-xd2c.google.com with SMTP id ca18e2360f4ac-7a26fd82847so59598839f.3 for ; Tue, 03 Oct 2023 16:35:16 -0700 (PDT) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id w25-20020a6b4a19000000b0079fa1a7cd36sm593596iob.30.2023.10.03.16.35.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 16:35:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1696376115; x=1696980915; 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=hSOU5X81V46msYlqeKtgkBYQcLTO4MUKpgJ2TqbhBJ4=; b=Sd17vx6mPJnVDbhQGFe8veuqwKwUQlrnqBb9yTz5wHi7yBjZU7B+PkeBAQuvErZIon eLEG9j+DgotawFbgUCRXMXuL7D9P/gIB3xGf+2D4Q/EzMoR28zBnx0TrUmdmTYkM5/pw F6+VN2uRCwYDkCTjU6LUDMUcUWa7AIKGa2T42EmIwjNlcVvW+/hxrgdetaznkrY6VOjR 6tEdh0V791yVZtNRHXkBjgmxHaOJdbg34XP8Z7veoNmTT+Cf2KaC6vI8VzV6IUF62F9d /MNoxp2NzR79Dz3pWupcrfvE2wmAGWMaffWbXfp3EIpBScgVR96DZFcbDhSeOUAdLSyV h1bw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696376115; x=1696980915; 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=hSOU5X81V46msYlqeKtgkBYQcLTO4MUKpgJ2TqbhBJ4=; b=MS4NCpIb9w5tTpmHrT9mokE3oFEE8wkq+mj8mOhBfcXJodtsD9vFrqeF6gB/rzcT85 tX5y4KFqTfcYf2JDAFEUxqdaKLZEhNBNAweB9O5ayBZKrvYwSLuAl4hzUClizDkiAT4Y FxmctiDY7Dz4cylw7cXvaXm0E8xFDwxsY+Kgpva3i4Gm26/39tQTxmJ/1Gn4GjQGfC6E v0qW/s5KulqzJErT+leVSHxv2WhTraHfOo6R2py8s88YGNa9msNKzaKiyGalSswgXxsU cvNBwVykSNE4BXAsQjaZwzpFp3tb+cXJqNp7XszjFjg2hjmvDrLi/W+6FD1+DYvvdjL0 heaQ== X-Gm-Message-State: AOJu0YzU2SWqTMJPKaTgf+3UkdiHOpC7UMmsKF40pBKq7Xo6VZQK++BW cQEou5UGwaDWCEtnf7KBwKHdNGvSIopiyGCW2J8VfA== X-Google-Smtp-Source: AGHT+IG5PNLmQyRmAMa1NbA085CROIItjB8d06zzgrt/o4J5y34IYtYFQAX1TH3vlmpjusYlwNLoiw== X-Received: by 2002:a5d:9cd5:0:b0:79f:d4e6:5175 with SMTP id w21-20020a5d9cd5000000b0079fd4e65175mr981597iow.16.1696376115226; Tue, 03 Oct 2023 16:35:15 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Thomas Huth , Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Wainer dos Santos Moschetta , Beraldo Leal , Warner Losh , Kyle Evans , Stacey Son , Karim Taha , Richard Henderson Subject: [PULL 09/51] bsd-user: Implement host_to_target_waitstatus conversion. Date: Tue, 3 Oct 2023 17:31:33 -0600 Message-ID: <20231003233215.95557-10-imp@bsdimp.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231003233215.95557-1-imp@bsdimp.com> References: <20231003233215.95557-1-imp@bsdimp.com> MIME-Version: 1.0 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: none client-ip=2607:f8b0:4864:20::d2c; envelope-from=imp@bsdimp.com; helo=mail-io1-xd2c.google.com 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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 @bsdimp-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1696376209451100001 Content-Type: text/plain; charset="utf-8" From: Stacey Son Signed-off-by: Stacey Son Signed-off-by: Karim Taha Reviewed-by: Richard Henderson Reviewed-by: Warner Losh Message-Id: <20230925182425.3163-10-kariem.taha2.7@gmail.com> --- bsd-user/bsd-proc.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/bsd-user/bsd-proc.c b/bsd-user/bsd-proc.c index aa386ff4820..19f6efe1f78 100644 --- a/bsd-user/bsd-proc.c +++ b/bsd-user/bsd-proc.c @@ -102,3 +102,20 @@ abi_long host_to_target_wrusage(abi_ulong target_addr, return 0; } =20 +/* + * wait status conversion. + * + * Map host to target signal numbers for the wait family of syscalls. + * Assume all other status bits are the same. + */ +int host_to_target_waitstatus(int status) +{ + if (WIFSIGNALED(status)) { + return host_to_target_signal(WTERMSIG(status)) | (status & ~0x7f); + } + if (WIFSTOPPED(status)) { + return (host_to_target_signal(WSTOPSIG(status)) << 8) | (status & = 0xff); + } + return status; +} + --=20 2.41.0 From nobody Sun May 19 09:42:24 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1696376233; cv=none; d=zohomail.com; s=zohoarc; b=ftNmLpPsN2ootNIWX6gtcD7EqD+OF6s/XhP9BjuCO6iV+SkuTEG5//UIEwSzKr4hsxBd69LKAucCcHli1DYdWDOmYGh1HD/gOx4ZknEO0Thrh5NK7qt9GT5OdJ6peK3U+yo7KXnR5U+GzHRFGx9zuLoHdQAfu/g3+VqTo2tb/N4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696376233; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=7FAk+UvZhi8lAunIPUyYc1Eov2CJXu6KRzN3IKE5mSs=; b=CzjnMSlzGGHTZPlpxDrxZhM3tsN88R0SnvScNX7SKuYOTYDktE8cdTS99lojoXBPqmftLdk7fVClyifh+vfM8Ng6p8/pVIP7jEgg6FVqw2LY4epRYS5WRgmU7DLe0jk3p1sxCxdrvXm2/cNug/Jvb6ZzaVTI3qPuv8nt9O4xdBg= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1696376233535707.8391942742654; Tue, 3 Oct 2023 16:37:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qnovC-00041Z-Sf; Tue, 03 Oct 2023 19:35:22 -0400 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 1qnov9-0003xn-84 for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:19 -0400 Received: from mail-io1-xd35.google.com ([2607:f8b0:4864:20::d35]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qnov7-0006ph-NW for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:18 -0400 Received: by mail-io1-xd35.google.com with SMTP id ca18e2360f4ac-79f95cd15dfso58506839f.0 for ; Tue, 03 Oct 2023 16:35:17 -0700 (PDT) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id w25-20020a6b4a19000000b0079fa1a7cd36sm593596iob.30.2023.10.03.16.35.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 16:35:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1696376116; x=1696980916; 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=7FAk+UvZhi8lAunIPUyYc1Eov2CJXu6KRzN3IKE5mSs=; b=nHbrOhc+JIHn8E/18Qd+LQCidWORKbCg2slFxOA8LShoZR+SjeLfj+XVe0HLYnzGos yPFNgLgoaTsSVb6ACqDkrDdcSUx0H0QXCBpM0OryI4aNlwO/cn1oBdpkhyrsy8MTokN8 x/lf04sE5MMqfKA919dsKD4Z99yUY5a4Ga8duBHqSL+LG1U15zVcMcAQcVE3OP9u8hGV co0Oqp1Gv3jbiyCzycgQjRsYkGrHR1HZA6p3gTe/iu61lb9EzZEnQVhFuYOR3bNtWOdX OsLJQZP5ZPyB3fRO8HJgz6hcRLabxnr99J0aWRNRL/hSb1gDOAuoM8Rcnus9ZGCh8Drw wiEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696376116; x=1696980916; 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=7FAk+UvZhi8lAunIPUyYc1Eov2CJXu6KRzN3IKE5mSs=; b=Wyy7VTWyWk/P3mH8yXEgIgyTcuJwAtBBGdiZibJZmywSzPSkZSGo2gckAl/Fkt07xP vHQsGfOMqPuTWcJ7u5Syo8LD42TleCHEDEwk7hHZ7WvYahNUVHjiWWEzKoZfQKz3RSRT 2oPwGD2dxyuD20vivdSWzwH6bj3rLiQRB1xmI2pE7nbBIZzHNODTzZABqLh63WkzyY9g LhF7DH1ivglKzaYCtx+oo4MawRIML343WHXevZpsKTZIupLHqZe/WQxTwrcAFBN+ujxq bQAJK03p65YvP9OO+YsLvWlvVEJxl5Fu4rVBjXR7Exa2bjMdaZp+W+2Ycuvupeb1qpcu yYrw== X-Gm-Message-State: AOJu0Yx4K4fG0rotSaj+e09rcE8QbcVUidvH5KeA1j3x4pPmDHqkCwbo esXjdQvceEnSnuqiduQpcGOuy5MUZUaoyMie54wFFw== X-Google-Smtp-Source: AGHT+IGRgjFxlsD69e0vWVBL+UzIOcI8W4zqbyGYNbaD2jGXCR/6TyzlRaJFbu05Vb/KM5fRyXW7Ng== X-Received: by 2002:a6b:7b05:0:b0:791:280:839e with SMTP id l5-20020a6b7b05000000b007910280839emr875375iop.16.1696376116160; Tue, 03 Oct 2023 16:35:16 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Thomas Huth , Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Wainer dos Santos Moschetta , Beraldo Leal , Warner Losh , Kyle Evans , Kyle Evans , Karim Taha Subject: [PULL 10/51] bsd-user: Get number of cpus. Date: Tue, 3 Oct 2023 17:31:34 -0600 Message-ID: <20231003233215.95557-11-imp@bsdimp.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231003233215.95557-1-imp@bsdimp.com> References: <20231003233215.95557-1-imp@bsdimp.com> MIME-Version: 1.0 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: none client-ip=2607:f8b0:4864:20::d35; envelope-from=imp@bsdimp.com; helo=mail-io1-xd35.google.com 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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 @bsdimp-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1696376235049100007 Content-Type: text/plain; charset="utf-8" From: Kyle Evans Signed-off-by: Kyle Evans Signed-off-by: Karim Taha Reviewed-by: Warner Losh Message-Id: <20230925182425.3163-11-kariem.taha2.7@gmail.com> --- bsd-user/bsd-proc.c | 24 ++++++++++++++++++++++++ bsd-user/bsd-proc.h | 2 ++ 2 files changed, 26 insertions(+) diff --git a/bsd-user/bsd-proc.c b/bsd-user/bsd-proc.c index 19f6efe1f78..ca3c1bf94f4 100644 --- a/bsd-user/bsd-proc.c +++ b/bsd-user/bsd-proc.c @@ -119,3 +119,27 @@ int host_to_target_waitstatus(int status) return status; } =20 +int bsd_get_ncpu(void) +{ + int ncpu =3D -1; + cpuset_t mask; + + CPU_ZERO(&mask); + + if (cpuset_getaffinity(CPU_LEVEL_WHICH, CPU_WHICH_TID, -1, sizeof(mask= ), + &mask) =3D=3D 0) { + ncpu =3D CPU_COUNT(&mask); + } + + if (ncpu =3D=3D -1) { + ncpu =3D sysconf(_SC_NPROCESSORS_ONLN); + } + + if (ncpu =3D=3D -1) { + gemu_log("XXX Missing bsd_get_ncpu() implementation\n"); + ncpu =3D 1; + } + + return ncpu; +} + diff --git a/bsd-user/bsd-proc.h b/bsd-user/bsd-proc.h index 048773a75dd..b6225e520ea 100644 --- a/bsd-user/bsd-proc.h +++ b/bsd-user/bsd-proc.h @@ -26,6 +26,8 @@ #include "gdbstub/syscalls.h" #include "qemu/plugin.h" =20 +int bsd_get_ncpu(void); + /* exit(2) */ static inline abi_long do_bsd_exit(void *cpu_env, abi_long arg1) { --=20 2.41.0 From nobody Sun May 19 09:42:24 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1696376652; cv=none; d=zohomail.com; s=zohoarc; b=no1+bwVl8ly5vRdF0wm3mWp6NkYufz59QCRWmMAW1yxRz14r7v5n9331/W8e+mn6UQ+K9P72WNqPnp5EFWdDOMXqp36zNQRlBODcGvyks5LQAFz9k8GEbStKmSDTKnSuPnkVrHJ4GcyRZWgOC1OiEuTaV+oforeAAVfKm0YnpTU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696376652; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=cAZ4CluLSnk0lLew81sItiili5rTiFhyUaEMqNMoRMs=; b=GEbxIK+NW9ZbCci8IgRs7G7/wd0s3Tqp9rA4Ke83S0PHL3TYMvFO4AzP1uYvp0daTMSAtlNT68tQ25Ox2AWx0vimoyAiEN2BCIDMo8F9ULcY+spT84sloXGfn8PQElEAwH5vyX11ExlAScSzaZBuf78yjyJSWPRs8sPMg7zWC6g= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1696376652920956.7940377034688; Tue, 3 Oct 2023 16:44:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qnovD-00042h-UV; Tue, 03 Oct 2023 19:35:23 -0400 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 1qnovA-0003z2-9P for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:21 -0400 Received: from mail-io1-xd31.google.com ([2607:f8b0:4864:20::d31]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qnov8-0006pv-Kk for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:20 -0400 Received: by mail-io1-xd31.google.com with SMTP id ca18e2360f4ac-79fa416b7ffso60872039f.2 for ; Tue, 03 Oct 2023 16:35:18 -0700 (PDT) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id w25-20020a6b4a19000000b0079fa1a7cd36sm593596iob.30.2023.10.03.16.35.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 16:35:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1696376117; x=1696980917; 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=cAZ4CluLSnk0lLew81sItiili5rTiFhyUaEMqNMoRMs=; b=InlRV+GrrLWiwbT94sXnLHeuAce6qQAuuJ1yf25QtFQP6t5U4CbYbImR6bi+q8oaB7 6wNeGppXW/p+CUvRV+M7eaton6tk3fNwkBm0J2SGRtI2sqIXm1dt8QEG3/uasDwh+pzA wARkKaoNhEKXY8aNNuiIctWd+ua27yTwwe78f8qT4w+iaGMJWPtF6S53CckLkTnmS0LI ZRGkDXHJb82bb3aFTnIX1gV98L+KMivpvmLkWa3MG/bBWFwwtsRP4bE2zzn4H9rMZfd3 5BDCkBp5FQEp3uBk98154wWKTliiFp2rzPxXwziZIaLQCkgQJK1fpF/bUfyKPUVzRsH8 l6qQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696376117; x=1696980917; 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=cAZ4CluLSnk0lLew81sItiili5rTiFhyUaEMqNMoRMs=; b=JZsUSYzv+MLDLHGkEfDEBB5s5mndhATxijJY0rA09N11GQwSwHa6vBsc5GH1yCT4aR D9YmtRWjj8AuBiapix4Crhwt9yl1Vu7iaHDpCyEnjXdI1FVQBIjeKxW49Ac1nYdCKq6i w6N+ljhQ3F/aFVX6+yzxheuwZQaaS2FRrhiufv5adax26aiq0MyhV/YyZXdGQAekOpN2 H/gf2iVpMKmlQbkEJfSs7qXsG7UfOM0YsEBNxlR5CrFH49M9+sWassFSBSAI60pgxY9i JHqHOQUhHA/8pGZHW3SQw+9ORk3mbxcqhbTvq9QbKiyUVFRgTOjAk7vhnNPv5MVnOLiK f7MQ== X-Gm-Message-State: AOJu0YyV8bx0vbrR0sTwACvflIjl3YKl1+LA80wTVsAzJmxT2Y4DdRLW t67jCVKrTWJLgP1W+w1zKUi32gB4SE9c7A+7oapd3Q== X-Google-Smtp-Source: AGHT+IF53ey32ANStuXRcWk9D8de1+JirYX4n7HCg5044cYeS2waK8s6bP9CkJIuMdnjKefApoJCpw== X-Received: by 2002:a6b:ea15:0:b0:790:a010:4c42 with SMTP id m21-20020a6bea15000000b00790a0104c42mr1035876ioc.13.1696376117069; Tue, 03 Oct 2023 16:35:17 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Thomas Huth , Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Wainer dos Santos Moschetta , Beraldo Leal , Warner Losh , Kyle Evans , Stacey Son , Karim Taha Subject: [PULL 11/51] bsd-user: Implement getgroups(2) and setgroups(2) system calls. Date: Tue, 3 Oct 2023 17:31:35 -0600 Message-ID: <20231003233215.95557-12-imp@bsdimp.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231003233215.95557-1-imp@bsdimp.com> References: <20231003233215.95557-1-imp@bsdimp.com> MIME-Version: 1.0 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: none client-ip=2607:f8b0:4864:20::d31; envelope-from=imp@bsdimp.com; helo=mail-io1-xd31.google.com 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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 @bsdimp-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1696376653476100001 Content-Type: text/plain; charset="utf-8" From: Stacey Son Signed-off-by: Stacey Son Signed-off-by: Karim Taha Reviewed-by: Warner Losh Message-Id: <20230925182425.3163-12-kariem.taha2.7@gmail.com> --- bsd-user/bsd-proc.h | 44 +++++++++++++++++++++++++++++++++++ bsd-user/freebsd/os-syscall.c | 9 +++++++ 2 files changed, 53 insertions(+) diff --git a/bsd-user/bsd-proc.h b/bsd-user/bsd-proc.h index b6225e520ea..7b25aa19829 100644 --- a/bsd-user/bsd-proc.h +++ b/bsd-user/bsd-proc.h @@ -41,4 +41,48 @@ static inline abi_long do_bsd_exit(void *cpu_env, abi_lo= ng arg1) return 0; } =20 +/* getgroups(2) */ +static inline abi_long do_bsd_getgroups(abi_long gidsetsize, abi_long arg2) +{ + abi_long ret; + uint32_t *target_grouplist; + g_autofree gid_t *grouplist; + int i; + + grouplist =3D g_try_new(gid_t, gidsetsize); + ret =3D get_errno(getgroups(gidsetsize, grouplist)); + if (gidsetsize !=3D 0) { + if (!is_error(ret)) { + target_grouplist =3D lock_user(VERIFY_WRITE, arg2, gidsetsize = * 2, 0); + if (!target_grouplist) { + return -TARGET_EFAULT; + } + for (i =3D 0; i < ret; i++) { + target_grouplist[i] =3D tswap32(grouplist[i]); + } + unlock_user(target_grouplist, arg2, gidsetsize * 2); + } + } + return ret; +} + +/* setgroups(2) */ +static inline abi_long do_bsd_setgroups(abi_long gidsetsize, abi_long arg2) +{ + uint32_t *target_grouplist; + g_autofree gid_t *grouplist; + int i; + + grouplist =3D g_try_new(gid_t, gidsetsize); + target_grouplist =3D lock_user(VERIFY_READ, arg2, gidsetsize * 2, 1); + if (!target_grouplist) { + return -TARGET_EFAULT; + } + for (i =3D 0; i < gidsetsize; i++) { + grouplist[i] =3D tswap32(target_grouplist[i]); + } + unlock_user(target_grouplist, arg2, 0); + return get_errno(setgroups(gidsetsize, grouplist)); +} + #endif /* !BSD_PROC_H_ */ diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index fa60df529ef..535e6287bde 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -223,6 +223,15 @@ static abi_long freebsd_syscall(void *cpu_env, int num= , abi_long arg1, ret =3D do_bsd_exit(cpu_env, arg1); break; =20 + case TARGET_FREEBSD_NR_getgroups: /* getgroups(2) */ + ret =3D do_bsd_getgroups(arg1, arg2); + break; + + case TARGET_FREEBSD_NR_setgroups: /* setgroups(2) */ + ret =3D do_bsd_setgroups(arg1, arg2); + break; + + /* * File system calls. */ --=20 2.41.0 From nobody Sun May 19 09:42:24 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1696376230; cv=none; d=zohomail.com; s=zohoarc; b=civj79I8XgkghZJGIbQSgD3YAoPkLWgsIBt0+Mk+AXf1z3Xut3yKSZih264iKlcglG97mkL62ssHH+M025iuVaOP8UKRgxWtqSLrgI1dW5nQh634NkUFovlhekcuw4IXV85junJMoQwYsaI7HTnXz8Kw6CLN9K9MDS5pPox8JNk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696376230; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=0ieaVmtKu6WB7XBYFcTLrCbXTONlGyxzlpnV4UW4ZRY=; b=L5eZUD2ja6/EUAVGf5PFAsBZZT0z8ljRihF/rjoMfM0BqBcBp2VXsfe/ak3HiXccNyxsz9aifCTWQcBU6haLkccQGbB4CyZCEDksCJpFCw1wHdLv1bGguwS+76MtAoY91WlA40OFgIvs9VrRecuHCTv6GAyfdL16PjmcbpqY5NM= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1696376230031844.8270761866542; Tue, 3 Oct 2023 16:37:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qnovE-000444-O2; Tue, 03 Oct 2023 19:35:24 -0400 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 1qnovB-00040K-8q for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:21 -0400 Received: from mail-il1-x129.google.com ([2607:f8b0:4864:20::129]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qnov9-0006q9-Gi for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:20 -0400 Received: by mail-il1-x129.google.com with SMTP id e9e14a558f8ab-35133097583so5856445ab.1 for ; Tue, 03 Oct 2023 16:35:19 -0700 (PDT) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id w25-20020a6b4a19000000b0079fa1a7cd36sm593596iob.30.2023.10.03.16.35.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 16:35:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1696376118; x=1696980918; 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=0ieaVmtKu6WB7XBYFcTLrCbXTONlGyxzlpnV4UW4ZRY=; b=vgG0NfFSs826xUkDXUwaQwvw856BpYzk7dSL3OOH47EoZ5sOKHJ+tPc7KwKPPyJRdh 1b2CfQnzV/yBZBSsvDSoGqvCCqMbgJNP/0PdGv51ae2NlNpDqZVCB+4Q2xk+xryrRfUf 3ZTSQgYIGjQPQvVjoYMzilNjYw8LYEho9kMsG0PcOpUH9PCUvrIDcYQQbuWETOIXttV4 gsE5m8GbTf7LBWfy8GSQ/sn/EoPGu5uzbiTo/tqVsIqssUwf2cgKVDR7sPVwQen+4sb4 wj2vYDv4UjnZxXABaKsrm2dqGJsYiWrIRUptfUPYcCKx8GGNDXbTeiHXuPbfZ3GmOEir uevw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696376118; x=1696980918; 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=0ieaVmtKu6WB7XBYFcTLrCbXTONlGyxzlpnV4UW4ZRY=; b=TLGys+DwL5ZQWvKjH65LDD6hvCiNBtqoD9jY9LiV89jgizU2fdo+/OWHuE+0Gzeurg rYO9gr1L6uEOvTKpnzlP38yRfhJeQu0B9a2YmbsLtb6/VMYeeCLItzEdZXgOgRXRB2SU 6LJm/Dv1kMKXgAuqp3Am3DUds3tL/9psYbhW4joiy7We4i6e80f/RxUWarEFB3gMA4eM Gr9++q3cTy9r9m8zLaM3qQf7RIW4HSYjavAglUHbBuz0Ya5j/MRqFx2vmnZpWKW3oAlz J2X3UXIR3U3ULKE0O5eXqSEBT/kmGvdUHespVqktCYNQ4k5Za7ifa/rGwBf7BimuSNPo QvLA== X-Gm-Message-State: AOJu0Yy3vQXewp96S+m6/B5c7A5NIRVtU5gOXff6A40BflCKjSnDDDVs SB/EDrZZPf66/sVF3PsfFxRimZBJOLNISAc6ELBB2w== X-Google-Smtp-Source: AGHT+IFMtdvEoOHG9DOjBFAK1IjGbs+cEgXLsDRAScOqeqR/wHqtYhLnQlokB6ZZgA/mS32iskYxAQ== X-Received: by 2002:a6b:c413:0:b0:79a:b526:2f2a with SMTP id y19-20020a6bc413000000b0079ab5262f2amr823991ioa.5.1696376117918; Tue, 03 Oct 2023 16:35:17 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Thomas Huth , Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Wainer dos Santos Moschetta , Beraldo Leal , Warner Losh , Kyle Evans , Stacey Son , Karim Taha Subject: [PULL 12/51] bsd-user: Implement umask(2), setlogin(2) and getlogin(2) Date: Tue, 3 Oct 2023 17:31:36 -0600 Message-ID: <20231003233215.95557-13-imp@bsdimp.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231003233215.95557-1-imp@bsdimp.com> References: <20231003233215.95557-1-imp@bsdimp.com> MIME-Version: 1.0 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: none client-ip=2607:f8b0:4864:20::129; envelope-from=imp@bsdimp.com; helo=mail-il1-x129.google.com 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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 @bsdimp-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1696376230757100001 Content-Type: text/plain; charset="utf-8" From: Stacey Son Signed-off-by: Stacey Son Signed-off-by: Karim Taha Reviewed-by: Warner Losh Message-Id: <20230925182425.3163-13-kariem.taha2.7@gmail.com> --- bsd-user/bsd-proc.h | 39 +++++++++++++++++++++++++++++++++++ bsd-user/freebsd/os-syscall.c | 12 +++++++++++ 2 files changed, 51 insertions(+) diff --git a/bsd-user/bsd-proc.h b/bsd-user/bsd-proc.h index 7b25aa19829..cb7c69acb0c 100644 --- a/bsd-user/bsd-proc.h +++ b/bsd-user/bsd-proc.h @@ -26,6 +26,7 @@ #include "gdbstub/syscalls.h" #include "qemu/plugin.h" =20 +extern int _getlogin(char*, int); int bsd_get_ncpu(void); =20 /* exit(2) */ @@ -85,4 +86,42 @@ static inline abi_long do_bsd_setgroups(abi_long gidsets= ize, abi_long arg2) return get_errno(setgroups(gidsetsize, grouplist)); } =20 +/* umask(2) */ +static inline abi_long do_bsd_umask(abi_long arg1) +{ + return get_errno(umask(arg1)); +} + +/* setlogin(2) */ +static inline abi_long do_bsd_setlogin(abi_long arg1) +{ + abi_long ret; + void *p; + + p =3D lock_user_string(arg1); + if (p =3D=3D NULL) { + return -TARGET_EFAULT; + } + ret =3D get_errno(setlogin(p)); + unlock_user(p, arg1, 0); + + return ret; +} + +/* getlogin(2) */ +static inline abi_long do_bsd_getlogin(abi_long arg1, abi_long arg2) +{ + abi_long ret; + void *p; + + p =3D lock_user(VERIFY_WRITE, arg1, arg2, 0); + if (p =3D=3D NULL) { + return -TARGET_EFAULT; + } + ret =3D get_errno(_getlogin(p, arg2)); + unlock_user(p, arg1, arg2); + + return ret; +} + #endif /* !BSD_PROC_H_ */ diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index 535e6287bde..44cbf52f087 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -231,6 +231,18 @@ static abi_long freebsd_syscall(void *cpu_env, int num= , abi_long arg1, ret =3D do_bsd_setgroups(arg1, arg2); break; =20 + case TARGET_FREEBSD_NR_umask: /* umask(2) */ + ret =3D do_bsd_umask(arg1); + break; + + case TARGET_FREEBSD_NR_setlogin: /* setlogin(2) */ + ret =3D do_bsd_setlogin(arg1); + break; + + case TARGET_FREEBSD_NR_getlogin: /* getlogin(2) */ + ret =3D do_bsd_getlogin(arg1, arg2); + break; + =20 /* * File system calls. --=20 2.41.0 From nobody Sun May 19 09:42:24 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1696376390; cv=none; d=zohomail.com; s=zohoarc; b=d4+9PwC74R+opV9HmCKzGXgOf9xuFxXf0+ess/0B7jYQPOguoN5Ypx9SZ0OnQ5FKO6RDTA93OXTPhpK/2AuffpaAXbvSYZmO9w6el1j6Md3dyjUaDoiTZ+DfGIwqeSqDiGalUBuNGG9xrDXEMQf0BF9BwV6qAMV2v2y/UFW3GgY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696376390; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=C7VRFr4gHk91MagU57mxTPEhJmPz5+DN76M+3LJyxsA=; b=mMds2bu1mzeIqqeHKoKEzSaCAw7Vq6c/JDhYgv0tPwVz9hD6bfqQIOBHd0Z9H+T3mdLfTg7jKqAQ19VPew4l+qR5gnfTguenGFXZvPXz+m4bp3PHs5rfZUbFvUHpHVuSTf8PYacf2vZQ/slEEJeeR5P9rrPnL1nqQBG9QZUIvk8= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1696376390285343.76215177032316; Tue, 3 Oct 2023 16:39:50 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qnovG-00044P-3P; Tue, 03 Oct 2023 19:35:26 -0400 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 1qnovD-00041v-3R for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:23 -0400 Received: from mail-io1-xd30.google.com ([2607:f8b0:4864:20::d30]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qnovA-0006qR-9Y for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:22 -0400 Received: by mail-io1-xd30.google.com with SMTP id ca18e2360f4ac-79545e141c7so14837939f.0 for ; Tue, 03 Oct 2023 16:35:19 -0700 (PDT) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id w25-20020a6b4a19000000b0079fa1a7cd36sm593596iob.30.2023.10.03.16.35.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 16:35:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1696376119; x=1696980919; 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=C7VRFr4gHk91MagU57mxTPEhJmPz5+DN76M+3LJyxsA=; b=3FeLSFVnivgvxTLodcbyaV+PWwF17To8sjkZNQOHcHsQbwlXIcgPrJy7utrrTlpoXe 7ZXFd9qv98yyHZyrsXMc+QaEAPxfvYuSs9+g8QU6W3H2+bufLV/ajA4vREAG1ok+Oi4a nEi/v5ilVvff3T9rvyx6hgC1V5mxmf4ChVqDyXdixsj1PK6g+v7Hr1So/2FotGfnQbvV amFHrpbZJ5a4EclFJWO998RfeLPdfNf2BNE7odHmj8AZhEtFFliC0fM4Z+QedEvxJ8Hw f5zn4JvNBc8QgNRCEXybkWaYzE6dG/a15goolbPPv9ean9Ysw0dIDwwVQcEmwxeNwpUZ 1VhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696376119; x=1696980919; 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=C7VRFr4gHk91MagU57mxTPEhJmPz5+DN76M+3LJyxsA=; b=mWlVoKL2pp9eCztqOn2LM2O7KlzRNXq/F6gmwc+1CJ+WCN7XTK3x0hCqFBqGtvKxnu 3GLSd4Yzly2OcYZI6P80/vkklulPUUvjZUJLqTtcyYmXyY2d6PMVG9xTf/q1D8oKAMIL ylPonGqw1coHPdkW8JoGL4hUWOQEU1hU8GMBHcOvrN0VjixGt8rbT4ZyLS3Gd5CNz0yl BO9QA0v0uKYPQT1tfmiAr6aTnpEfMBmjdni2aiovoctW+iE8RBxe7Km3XcQeCkBfPowA mNgZVVqLZIsFsbRAUeP6d5AOj+yfhy3oV7otQp3bkb4dJnmoHsKVDBzVfdVlM65TlDeU 6QUA== X-Gm-Message-State: AOJu0Yxlk3RRMoQ+E8V+QKSExKWcfDge93siritPXJYLFegbXXRt1YMu 6E8ApOPAULj7AQj3BbWSlr1ObXuGa04/Zq9fhfkygg== X-Google-Smtp-Source: AGHT+IEbBdmKKfbHwDq0CPzm+u8y/OaUYYygPT0FNV9jBQxLPC6xSVZkVB8UBcNwtiso3ONvfera8w== X-Received: by 2002:a05:6602:2c4c:b0:79f:e800:ea95 with SMTP id x12-20020a0566022c4c00b0079fe800ea95mr4015629iov.3.1696376118823; Tue, 03 Oct 2023 16:35:18 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Thomas Huth , Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Wainer dos Santos Moschetta , Beraldo Leal , Warner Losh , Kyle Evans , Stacey Son , Karim Taha , Richard Henderson Subject: [PULL 13/51] bsd-user: Implement getrusage(2). Date: Tue, 3 Oct 2023 17:31:37 -0600 Message-ID: <20231003233215.95557-14-imp@bsdimp.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231003233215.95557-1-imp@bsdimp.com> References: <20231003233215.95557-1-imp@bsdimp.com> MIME-Version: 1.0 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: none client-ip=2607:f8b0:4864:20::d30; envelope-from=imp@bsdimp.com; helo=mail-io1-xd30.google.com 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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 @bsdimp-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1696376391206100003 Content-Type: text/plain; charset="utf-8" From: Stacey Son Signed-off-by: Stacey Son Signed-off-by: Karim Taha Reviewed-by: Richard Henderson Reviewed-by: Warner Losh Message-Id: <20230925182425.3163-14-kariem.taha2.7@gmail.com> --- bsd-user/bsd-proc.h | 13 +++++++++++++ bsd-user/freebsd/os-syscall.c | 4 ++++ 2 files changed, 17 insertions(+) diff --git a/bsd-user/bsd-proc.h b/bsd-user/bsd-proc.h index cb7c69acb0c..133c1b0eaf8 100644 --- a/bsd-user/bsd-proc.h +++ b/bsd-user/bsd-proc.h @@ -124,4 +124,17 @@ static inline abi_long do_bsd_getlogin(abi_long arg1, = abi_long arg2) return ret; } =20 +/* getrusage(2) */ +static inline abi_long do_bsd_getrusage(abi_long who, abi_ulong target_add= r) +{ + abi_long ret; + struct rusage rusage; + + ret =3D get_errno(getrusage(who, &rusage)); + if (!is_error(ret)) { + host_to_target_rusage(target_addr, &rusage); + } + return ret; +} + #endif /* !BSD_PROC_H_ */ diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index 44cbf52f087..5d8693ed550 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -243,6 +243,10 @@ static abi_long freebsd_syscall(void *cpu_env, int num= , abi_long arg1, ret =3D do_bsd_getlogin(arg1, arg2); break; =20 + case TARGET_FREEBSD_NR_getrusage: /* getrusage(2) */ + ret =3D do_bsd_getrusage(arg1, arg2); + break; + =20 /* * File system calls. --=20 2.41.0 From nobody Sun May 19 09:42:24 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1696376390; cv=none; d=zohomail.com; s=zohoarc; b=FpVF/bmBmxaGt30r+IZn5TeW3rrs1JOCDEsakHjnpMbSz6TRpz/OM8/Y2X1LJE/pVETajUzgQ7uwpR3UzKJ1Z+RBrAqtrxa/a0hnc0qaEfHN3i6T2+OhrcScr+yPmjFW6fHbh5ou1isWyR+inHCPMhV0vZmvYqXTk+CNxCu6LWM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696376390; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=+wZeMIbIZWAaczukeU9kCYH0/v8NZZkLUqmuVnhx+go=; b=m9j1kbfODYK+n/D9jmhXfTbWK43WJ6uxkwRMhsbI8j4dw4lqLMu7F4lrvR5RtmHQf8Sv3L8YGUQ9ei4BeGMT+bqTc2mCZvRwKBr7IYGssqWlqo4iuIAw5xej7T2dfz2XChPk80iU/ztviTSKgpLb7PD9wsDbWF2Ylg0yqbdCpFw= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1696376390354313.543442519427; Tue, 3 Oct 2023 16:39:50 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qnovG-00046A-Ru; Tue, 03 Oct 2023 19:35:26 -0400 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 1qnovD-00042e-Lp for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:23 -0400 Received: from mail-io1-xd2d.google.com ([2607:f8b0:4864:20::d2d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qnovC-0006uM-16 for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:23 -0400 Received: by mail-io1-xd2d.google.com with SMTP id ca18e2360f4ac-79fa2dbd793so64824839f.2 for ; Tue, 03 Oct 2023 16:35:21 -0700 (PDT) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id w25-20020a6b4a19000000b0079fa1a7cd36sm593596iob.30.2023.10.03.16.35.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 16:35:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1696376120; x=1696980920; 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=+wZeMIbIZWAaczukeU9kCYH0/v8NZZkLUqmuVnhx+go=; b=FWPY3CwqhWgXLpXpus/On1XD0gH5NJj52UzR60NxL8YFuQbtqcFB5iXM7xm6toBynu 2z7y0rivH5H3kcedc4gL32xfu2330MgloaZJD9Pv+OBP8qyw6rhviruWYAtkFXoqgjb4 H4iTF/gNXMwnBVVagYii0pFOSoYL44OYl7avm/EowlmckifyiC8PkXlxRd7XeI6uVf2G voAjuD3zMKVxOgRjA3j1c2AY8ckOGvVfySc4sYb6evZPA795otr2zaU8Q6NM5OFEDNze nYFSVYZdw7tuzns2LHzSUeKvI+pkO/N46flc1I/Ab9gVxBtQf62lC8+QutJr/8Mk1FiU W+pA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696376120; x=1696980920; 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=+wZeMIbIZWAaczukeU9kCYH0/v8NZZkLUqmuVnhx+go=; b=tH7sXQrjnKnUFsQUcZBZINOMox2wey8ozkaba9oNmxX+XM4Z5QTDSKX+eFth3oDz// NSZIpgzOvrtwhncZRQTo0+o2lFX7BShR6mKr4j98STVsbqGnS8z0to10tR34w27KMsSu 9UMsh9fRjK+y1fNLYdWavoXPvuGBim8RLrZvm4DPXKZVBHKFMAANyElv78PdiGY6d/HW IVVWacb8aIwA6qpDr1zPVLv+iXHffpuf8NVDrGo2/aNXyWCZtEjJgGbYbHQpWSQdYYq+ nGex1s/M1oPJenpWZkycYRV2jpvwzX0kgIpHNFoL40jkOAL5I/gKfoxpS/KMykrDiy5f vKIQ== X-Gm-Message-State: AOJu0YzgD4kdnWPsd2xZy7NRwtGKsF20xdNhXcNtZA7K/u6Fe2N+8lFU 8tw8PsDaPyF8EkUamUYGdiODcdHDzui1S/cxk1pYaA== X-Google-Smtp-Source: AGHT+IF06LilV5Cn0XrVWSHUAxItPfBp/84dkxgYmTo6aI8/AMpUgKW8GXT7rmL/pg+EOHUs+44A6w== X-Received: by 2002:a6b:fd01:0:b0:790:c3d0:8f87 with SMTP id c1-20020a6bfd01000000b00790c3d08f87mr834956ioi.19.1696376119699; Tue, 03 Oct 2023 16:35:19 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Thomas Huth , Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Wainer dos Santos Moschetta , Beraldo Leal , Warner Losh , Kyle Evans , Stacey Son , Karim Taha , Richard Henderson Subject: [PULL 14/51] bsd-user: Implement getrlimit(2) and setrlimit(2) Date: Tue, 3 Oct 2023 17:31:38 -0600 Message-ID: <20231003233215.95557-15-imp@bsdimp.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231003233215.95557-1-imp@bsdimp.com> References: <20231003233215.95557-1-imp@bsdimp.com> MIME-Version: 1.0 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: none client-ip=2607:f8b0:4864:20::d2d; envelope-from=imp@bsdimp.com; helo=mail-io1-xd2d.google.com 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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 @bsdimp-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1696376392457100015 Content-Type: text/plain; charset="utf-8" From: Stacey Son Signed-off-by: Stacey Son Signed-off-by: Karim Taha Reviewed-by: Richard Henderson Reviewed-by: Warner Losh Message-Id: <20230925182425.3163-15-kariem.taha2.7@gmail.com> --- bsd-user/bsd-proc.h | 59 +++++++++++++++++++++++++++++++++++ bsd-user/freebsd/os-syscall.c | 8 +++++ 2 files changed, 67 insertions(+) diff --git a/bsd-user/bsd-proc.h b/bsd-user/bsd-proc.h index 133c1b0eaf8..38d1324034c 100644 --- a/bsd-user/bsd-proc.h +++ b/bsd-user/bsd-proc.h @@ -137,4 +137,63 @@ static inline abi_long do_bsd_getrusage(abi_long who, = abi_ulong target_addr) return ret; } =20 +/* getrlimit(2) */ +static inline abi_long do_bsd_getrlimit(abi_long arg1, abi_ulong arg2) +{ + abi_long ret; + int resource =3D target_to_host_resource(arg1); + struct target_rlimit *target_rlim; + struct rlimit rlim; + + switch (resource) { + case RLIMIT_STACK: + rlim.rlim_cur =3D target_dflssiz; + rlim.rlim_max =3D target_maxssiz; + ret =3D 0; + break; + + case RLIMIT_DATA: + rlim.rlim_cur =3D target_dfldsiz; + rlim.rlim_max =3D target_maxdsiz; + ret =3D 0; + break; + + default: + ret =3D get_errno(getrlimit(resource, &rlim)); + break; + } + if (!is_error(ret)) { + if (!lock_user_struct(VERIFY_WRITE, target_rlim, arg2, 0)) { + return -TARGET_EFAULT; + } + target_rlim->rlim_cur =3D host_to_target_rlim(rlim.rlim_cur); + target_rlim->rlim_max =3D host_to_target_rlim(rlim.rlim_max); + unlock_user_struct(target_rlim, arg2, 1); + } + return ret; +} + +/* setrlimit(2) */ +static inline abi_long do_bsd_setrlimit(abi_long arg1, abi_ulong arg2) +{ + abi_long ret; + int resource =3D target_to_host_resource(arg1); + struct target_rlimit *target_rlim; + struct rlimit rlim; + + if (RLIMIT_STACK =3D=3D resource) { + /* XXX We should, maybe, allow the stack size to shrink */ + ret =3D -TARGET_EPERM; + } else { + if (!lock_user_struct(VERIFY_READ, target_rlim, arg2, 1)) { + return -TARGET_EFAULT; + } + rlim.rlim_cur =3D target_to_host_rlim(target_rlim->rlim_cur); + rlim.rlim_max =3D target_to_host_rlim(target_rlim->rlim_max); + unlock_user_struct(target_rlim, arg2, 0); + ret =3D get_errno(setrlimit(resource, &rlim)); + } + return ret; +} + #endif /* !BSD_PROC_H_ */ diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index 5d8693ed550..5cb60862303 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -247,6 +247,14 @@ static abi_long freebsd_syscall(void *cpu_env, int num= , abi_long arg1, ret =3D do_bsd_getrusage(arg1, arg2); break; =20 + case TARGET_FREEBSD_NR_getrlimit: /* getrlimit(2) */ + ret =3D do_bsd_getrlimit(arg1, arg2); + break; + + case TARGET_FREEBSD_NR_setrlimit: /* setrlimit(2) */ + ret =3D do_bsd_setrlimit(arg1, arg2); + break; + =20 /* * File system calls. --=20 2.41.0 From nobody Sun May 19 09:42:24 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1696376377; cv=none; d=zohomail.com; s=zohoarc; b=nhlhLl3rStkrEUFNvO7/EGoZCGh5LocBeYK0TiM/AyS9Z0Y10l1xzgiHqxI0Fr1LJ2m38aYtkSUsF02kmMdY9WHea2CNHTf28rmdkK8EEpI0duQFf48AVicR50Bmab9pFoLAtYvfZQTsm06D5QO6n7YH3aoQTqmvg/ysttEfRpo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696376377; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=qie3M6dlAyV2pYetlYDOFKB5joUdVo7JudFsExcH3bA=; b=LX23r/hpuWZMu/O4RszjOJx/UMnQFCUuigtAdra8h6C9+Md2Z4Ct0cyd3dmc0cIl2gJqm+vGXlDufizuRh/06FuB8d+JQxuIYGn+ph+Q2wtdbJidD9hUTIffhMWNePedcVnEndqXx0BMGOmFQ+nIYqEsWiHRn6d/zk3B91Y7qD4= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1696376377097613.7686833814381; Tue, 3 Oct 2023 16:39:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qnovI-000489-TW; Tue, 03 Oct 2023 19:35:28 -0400 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 1qnovE-00042z-4i for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:24 -0400 Received: from mail-io1-xd2a.google.com ([2607:f8b0:4864:20::d2a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qnovC-0006uU-13 for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:23 -0400 Received: by mail-io1-xd2a.google.com with SMTP id ca18e2360f4ac-79fe87cd74eso59103939f.3 for ; Tue, 03 Oct 2023 16:35:21 -0700 (PDT) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id w25-20020a6b4a19000000b0079fa1a7cd36sm593596iob.30.2023.10.03.16.35.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 16:35:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1696376120; x=1696980920; 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=qie3M6dlAyV2pYetlYDOFKB5joUdVo7JudFsExcH3bA=; b=HYmlepfJtwsGATV4Wpa3oLA7H+74P+y5vWQoIt3YS8/nEsHzknmRGchVY5jtZ1LL9j 5bh4pBSnQ27pqKF2Jy8Qptee1Z/I9awolLxt8wyo/H8jZ4XNliIHUzKSagNKPVpLHNcC 4DbENKNxaP6T200Wqo0Rmwes+TWiAUuuaGBoRegncxxhHKJV4wnUghrSDZ++/HxcICnm pnqa6w2dKQAbONLqfwGfnSSRClJ4awZ4D3SHcL3eeR4JqryRe3rl5blupQE7vA8piw/S 59YUfGR7g6+dBlugHQJxGZC2gaWt7HCkKH2JWwoCG1wGyhYHal2dgnHkQyystYHlyy3w d4eQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696376120; x=1696980920; 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=qie3M6dlAyV2pYetlYDOFKB5joUdVo7JudFsExcH3bA=; b=hEnYjv8E8/i5gfzGfQomO+mW1JBkxMqWOA0MWdBgAhykrNw7L8GYR7Bx9qwXb+L6b+ T2988/0ZSGJMjuaq+WoeKAVvEH+t42kuQUSGJ5cqVdpsXTbnlS4sbkknX+Jelp4mBplE 9ht0V4UhSxRMZ7/fRSwNu66gkvZaC9b8alLQNZ1MYl2ERPHGZRQqWSTwMr3vh22Cb0d/ xdZOUa14QRqEBpJIHmwsNDFte4nAnusWqZ2uu4Uq59SWfa8c6gtttK0jlLtnlhYHndlT ysvaGdY0HgghtM3K6FYuzIQ706gYvyiUaCCgcIa8ARegZKro/annEQNbstrT0nzJGFLg SdEA== X-Gm-Message-State: AOJu0YxXgE4jCydB3OyoA1q4Y25sj46GzbChWZ/fJbKkWFcnpXUK4BdM 5LUl210nlZmieAJZxrOY/+oaUTZaV/IcgAfRlkRq4A== X-Google-Smtp-Source: AGHT+IGnUKk3qHhAD7F8kJABbW+kQnQ2d/TyJbQes9WuZRm/PbGT/kUry6eUuNu/gFn769V2Ss/i9w== X-Received: by 2002:a6b:6f09:0:b0:79f:ca2f:9198 with SMTP id k9-20020a6b6f09000000b0079fca2f9198mr816906ioc.2.1696376120636; Tue, 03 Oct 2023 16:35:20 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Thomas Huth , Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Wainer dos Santos Moschetta , Beraldo Leal , Warner Losh , Kyle Evans , Stacey Son , Karim Taha , Richard Henderson Subject: [PULL 15/51] bsd-user: Implement several get/set system calls: Date: Tue, 3 Oct 2023 17:31:39 -0600 Message-ID: <20231003233215.95557-16-imp@bsdimp.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231003233215.95557-1-imp@bsdimp.com> References: <20231003233215.95557-1-imp@bsdimp.com> MIME-Version: 1.0 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: none client-ip=2607:f8b0:4864:20::d2a; envelope-from=imp@bsdimp.com; helo=mail-io1-xd2a.google.com 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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 @bsdimp-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1696376379169100007 Content-Type: text/plain; charset="utf-8" From: Stacey Son getpid(2), getppid(2), getpgrp(2) setreuid(2), setregid(2) getuid(2), geteuid(2), getgid(2), getegid(2), getpgid(2) setuid(2), seteuid(2), setgid(2), setegid(2), setpgid(2) Signed-off-by: Stacey Son Signed-off-by: Karim Taha Reviewed-by: Richard Henderson Reviewed-by: Warner Losh Message-Id: <20230925182425.3163-16-kariem.taha2.7@gmail.com> --- bsd-user/bsd-proc.h | 90 +++++++++++++++++++++++++++++++++++ bsd-user/freebsd/os-syscall.c | 60 +++++++++++++++++++++++ 2 files changed, 150 insertions(+) diff --git a/bsd-user/bsd-proc.h b/bsd-user/bsd-proc.h index 38d1324034c..6ff07c0ac36 100644 --- a/bsd-user/bsd-proc.h +++ b/bsd-user/bsd-proc.h @@ -196,4 +196,94 @@ static inline abi_long do_bsd_setrlimit(abi_long arg1,= abi_ulong arg2) return ret; } =20 +/* getpid(2) */ +static inline abi_long do_bsd_getpid(void) +{ + return get_errno(getpid()); +} + +/* getppid(2) */ +static inline abi_long do_bsd_getppid(void) +{ + return get_errno(getppid()); +} + +/* getuid(2) */ +static inline abi_long do_bsd_getuid(void) +{ + return get_errno(getuid()); +} + +/* geteuid(2) */ +static inline abi_long do_bsd_geteuid(void) +{ + return get_errno(geteuid()); +} + +/* getgid(2) */ +static inline abi_long do_bsd_getgid(void) +{ + return get_errno(getgid()); +} + +/* getegid(2) */ +static inline abi_long do_bsd_getegid(void) +{ + return get_errno(getegid()); +} + +/* setuid(2) */ +static inline abi_long do_bsd_setuid(abi_long arg1) +{ + return get_errno(setuid(arg1)); +} + +/* seteuid(2) */ +static inline abi_long do_bsd_seteuid(abi_long arg1) +{ + return get_errno(seteuid(arg1)); +} + +/* setgid(2) */ +static inline abi_long do_bsd_setgid(abi_long arg1) +{ + return get_errno(setgid(arg1)); +} + +/* setegid(2) */ +static inline abi_long do_bsd_setegid(abi_long arg1) +{ + return get_errno(setegid(arg1)); +} + +/* getpgid(2) */ +static inline abi_long do_bsd_getpgid(pid_t pid) +{ + return get_errno(getpgid(pid)); +} + +/* setpgid(2) */ +static inline abi_long do_bsd_setpgid(int pid, int pgrp) +{ + return get_errno(setpgid(pid, pgrp)); +} + +/* getpgrp(2) */ +static inline abi_long do_bsd_getpgrp(void) +{ + return get_errno(getpgrp()); +} + +/* setreuid(2) */ +static inline abi_long do_bsd_setreuid(abi_long arg1, abi_long arg2) +{ + return get_errno(setreuid(arg1, arg2)); +} + +/* setregid(2) */ +static inline abi_long do_bsd_setregid(abi_long arg1, abi_long arg2) +{ + return get_errno(setregid(arg1, arg2)); +} + #endif /* !BSD_PROC_H_ */ diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index 5cb60862303..7565e69e76d 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -255,6 +255,66 @@ static abi_long freebsd_syscall(void *cpu_env, int num= , abi_long arg1, ret =3D do_bsd_setrlimit(arg1, arg2); break; =20 + case TARGET_FREEBSD_NR_getpid: /* getpid(2) */ + ret =3D do_bsd_getpid(); + break; + + case TARGET_FREEBSD_NR_getppid: /* getppid(2) */ + ret =3D do_bsd_getppid(); + break; + + case TARGET_FREEBSD_NR_getuid: /* getuid(2) */ + ret =3D do_bsd_getuid(); + break; + + case TARGET_FREEBSD_NR_geteuid: /* geteuid(2) */ + ret =3D do_bsd_geteuid(); + break; + + case TARGET_FREEBSD_NR_getgid: /* getgid(2) */ + ret =3D do_bsd_getgid(); + break; + + case TARGET_FREEBSD_NR_getegid: /* getegid(2) */ + ret =3D do_bsd_getegid(); + break; + + case TARGET_FREEBSD_NR_setuid: /* setuid(2) */ + ret =3D do_bsd_setuid(arg1); + break; + + case TARGET_FREEBSD_NR_seteuid: /* seteuid(2) */ + ret =3D do_bsd_seteuid(arg1); + break; + + case TARGET_FREEBSD_NR_setgid: /* setgid(2) */ + ret =3D do_bsd_setgid(arg1); + break; + + case TARGET_FREEBSD_NR_setegid: /* setegid(2) */ + ret =3D do_bsd_setegid(arg1); + break; + + case TARGET_FREEBSD_NR_getpgrp: /* getpgrp(2) */ + ret =3D do_bsd_getpgrp(); + break; + + case TARGET_FREEBSD_NR_getpgid: /* getpgid(2) */ + ret =3D do_bsd_getpgid(arg1); + break; + + case TARGET_FREEBSD_NR_setpgid: /* setpgid(2) */ + ret =3D do_bsd_setpgid(arg1, arg2); + break; + + case TARGET_FREEBSD_NR_setreuid: /* setreuid(2) */ + ret =3D do_bsd_setreuid(arg1, arg2); + break; + + case TARGET_FREEBSD_NR_setregid: /* setregid(2) */ + ret =3D do_bsd_setregid(arg1, arg2); + break; + =20 /* * File system calls. --=20 2.41.0 From nobody Sun May 19 09:42:24 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1696376240; cv=none; d=zohomail.com; s=zohoarc; b=XQ2nQ59bde3HYHFk+fJgwyGrfgIp3+EY254NYeaKovW/G8VnwyXlbUsk0KsqOuRrtIkwPhCZRDIEi8hMwewYxaRsZDKiKqfAXZ76tlzkOFDqO94gY2XPzOovZlQfM1TREdCytsV4LXDyNB6sF+Gp539QB/SHHhRI/rs9FV5zAsY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696376240; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=xg910hClygM/w6Q17aFFZ0+QF/l/YWUoxR0V7peyA8Y=; b=PzRrHEi9da+cJGA6VDmQEv9O4NHj7AMH96kujJbV/TGTyBdAFOO6z2vse7j3r38wu9Mvmz30KP2ByvvCZKZzswEVpo+4gOqFjSuX7PPYWcDx3U5/9cW5jPoxrSclYqVFYFsw0WOkOzJMXF0XD/Cw9HHBvoqEr7DIEBZ/sIfJwrM= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1696376240770335.4343888086637; Tue, 3 Oct 2023 16:37:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qnovK-00048d-Hq; Tue, 03 Oct 2023 19:35:30 -0400 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 1qnovE-000445-Oh for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:24 -0400 Received: from mail-io1-xd33.google.com ([2607:f8b0:4864:20::d33]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qnovC-0006yQ-Rr for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:24 -0400 Received: by mail-io1-xd33.google.com with SMTP id ca18e2360f4ac-79545e141c7so14838439f.0 for ; Tue, 03 Oct 2023 16:35:22 -0700 (PDT) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id w25-20020a6b4a19000000b0079fa1a7cd36sm593596iob.30.2023.10.03.16.35.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 16:35:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1696376121; x=1696980921; 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=xg910hClygM/w6Q17aFFZ0+QF/l/YWUoxR0V7peyA8Y=; b=f6FNrg2W6/ejP6y0xwjMzGL61J2APLHZNbRStvzjnTAnDdaaOu+RhoEzwyv3N9Xf3q KPYhm51nOqE+HaDQSpfg2vNJCH2M99BtdIsms2n/eHyeqUmaagnyg4KK/zwwQ+4zx+zD 9K3oZsomRUA5ygaslfcPU+g1c+vW6pU3XsHci54v5HLKBvVb/lEWuPz2UZTCxlBA9+Jm nI0NE4It5ui2N+TFzNyWzxtl6Gks9uUmjlaoCV2JV7nOBbWYB6jO7MPowZZHfpiDSw/9 N2MCiC+U1P3xSO5QxhgH3b56GUAEGKieL9O/7c1XzpqsjPEwMIRHmG56Mf5D9VrtiyO8 AOcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696376121; x=1696980921; 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=xg910hClygM/w6Q17aFFZ0+QF/l/YWUoxR0V7peyA8Y=; b=FEYR6Y7Lh2IkSQ+rr/DqeAjqS9lHOpBlvgcuI6Vby2I7Mgx1cw+z6Lqt9/rpnStxaq V6Y9ACmolGlX6F+bOSNVZBzRtnIS0TJxP0y8SZ02w8YvCJ96n4n2xW5kmoYsok2Jjjjy RGZuHL1Mjh1GW8gS0OCUzgSWO22BacNwGNZsTfNu1Iw5Dp06yv5zOLcmS9nnh00zeLs/ tsm2omELcL0r6IhjGksQzu37rBYPQ2EiV06Ji7ZGLqXbnIhjauV9TcqTiW5EPJvNA5V2 p49u/4ynL7Oam2sEedy2wb+ZhatF5XgZ5bLcE8295SnhXs3+Tn7n6vYHtn114DAvQxLH OyfA== X-Gm-Message-State: AOJu0YxwirCQKc6zlunAFa7mx0ppvlO01IaN3LJOklBpfRSXfqG93/2x yxJ0/R+EFRPFS7XYxTRulArpCKHk5iUZH46dZxFytw== X-Google-Smtp-Source: AGHT+IGC8Xy/X/xViCnHld6BISjIwpaCRCcii3SWQKrC+2BwwTLPCscoiFHBKpSozaO5og4EiRouEQ== X-Received: by 2002:a5e:c90c:0:b0:79f:b4f1:186a with SMTP id z12-20020a5ec90c000000b0079fb4f1186amr526394iol.1.1696376121472; Tue, 03 Oct 2023 16:35:21 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Thomas Huth , Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Wainer dos Santos Moschetta , Beraldo Leal , Warner Losh , Kyle Evans , Stacey Son , Karim Taha , Richard Henderson Subject: [PULL 16/51] bsd-user: Implement get/set[resuid/resgid/sid] and issetugid. Date: Tue, 3 Oct 2023 17:31:40 -0600 Message-ID: <20231003233215.95557-17-imp@bsdimp.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231003233215.95557-1-imp@bsdimp.com> References: <20231003233215.95557-1-imp@bsdimp.com> MIME-Version: 1.0 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: none client-ip=2607:f8b0:4864:20::d33; envelope-from=imp@bsdimp.com; helo=mail-io1-xd33.google.com 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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 @bsdimp-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1696376241270100003 Content-Type: text/plain; charset="utf-8" From: Stacey Son Signed-off-by: Stacey Son Signed-off-by: Karim Taha Reviewed-by: Richard Henderson Reviewed-by: Warner Losh Message-Id: <20230925182425.3163-17-kariem.taha2.7@gmail.com> --- bsd-user/bsd-proc.h | 76 +++++++++++++++++++++++++++++++++++ bsd-user/freebsd/os-syscall.c | 28 +++++++++++++ 2 files changed, 104 insertions(+) diff --git a/bsd-user/bsd-proc.h b/bsd-user/bsd-proc.h index 6ff07c0ac36..a5f301c72ff 100644 --- a/bsd-user/bsd-proc.h +++ b/bsd-user/bsd-proc.h @@ -286,4 +286,80 @@ static inline abi_long do_bsd_setregid(abi_long arg1, = abi_long arg2) return get_errno(setregid(arg1, arg2)); } =20 +/* setresgid(2) */ +static inline abi_long do_bsd_setresgid(gid_t rgid, gid_t egid, gid_t sgid) +{ + return get_errno(setresgid(rgid, egid, sgid)); +} + +/* setresuid(2) */ +static inline abi_long do_bsd_setresuid(uid_t ruid, uid_t euid, uid_t suid) +{ + return get_errno(setresuid(ruid, euid, suid)); +} + +/* getresuid(2) */ +static inline abi_long do_bsd_getresuid(abi_ulong arg1, abi_ulong arg2, + abi_ulong arg3) +{ + abi_long ret; + uid_t ruid, euid, suid; + + ret =3D get_errno(getresuid(&ruid, &euid, &suid)); + if (is_error(ret)) { + return ret; + } + if (put_user_s32(ruid, arg1)) { + return -TARGET_EFAULT; + } + if (put_user_s32(euid, arg2)) { + return -TARGET_EFAULT; + } + if (put_user_s32(suid, arg3)) { + return -TARGET_EFAULT; + } + return ret; +} + +/* getresgid(2) */ +static inline abi_long do_bsd_getresgid(abi_ulong arg1, abi_ulong arg2, + abi_ulong arg3) +{ + abi_long ret; + uid_t ruid, euid, suid; + + ret =3D get_errno(getresgid(&ruid, &euid, &suid)); + if (is_error(ret)) { + return ret; + } + if (put_user_s32(ruid, arg1)) { + return -TARGET_EFAULT; + } + if (put_user_s32(euid, arg2)) { + return -TARGET_EFAULT; + } + if (put_user_s32(suid, arg3)) { + return -TARGET_EFAULT; + } + return ret; +} + +/* getsid(2) */ +static inline abi_long do_bsd_getsid(abi_long arg1) +{ + return get_errno(getsid(arg1)); +} + +/* setsid(2) */ +static inline abi_long do_bsd_setsid(void) +{ + return get_errno(setsid()); +} + +/* issetugid(2) */ +static inline abi_long do_bsd_issetugid(void) +{ + return get_errno(issetugid()); +} + #endif /* !BSD_PROC_H_ */ diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index 7565e69e76d..7b51f4f16e4 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -315,6 +315,34 @@ static abi_long freebsd_syscall(void *cpu_env, int num= , abi_long arg1, ret =3D do_bsd_setregid(arg1, arg2); break; =20 + case TARGET_FREEBSD_NR_getresuid: /* getresuid(2) */ + ret =3D do_bsd_getresuid(arg1, arg2, arg3); + break; + + case TARGET_FREEBSD_NR_getresgid: /* getresgid(2) */ + ret =3D do_bsd_getresgid(arg1, arg2, arg3); + break; + + case TARGET_FREEBSD_NR_setresuid: /* setresuid(2) */ + ret =3D do_bsd_setresuid(arg1, arg2, arg3); + break; + + case TARGET_FREEBSD_NR_setresgid: /* setresgid(2) */ + ret =3D do_bsd_setresgid(arg1, arg2, arg3); + break; + + case TARGET_FREEBSD_NR_getsid: /* getsid(2) */ + ret =3D do_bsd_getsid(arg1); + break; + + case TARGET_FREEBSD_NR_setsid: /* setsid(2) */ + ret =3D do_bsd_setsid(); + break; + + case TARGET_FREEBSD_NR_issetugid: /* issetugid(2) */ + ret =3D do_bsd_issetugid(); + break; + =20 /* * File system calls. --=20 2.41.0 From nobody Sun May 19 09:42:24 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1696376274; cv=none; d=zohomail.com; s=zohoarc; b=NhQcOmhIKxIddol1hPJ+T4o8WjLhEPWbrynnxTgqdUCYl0xllECiJL2rPVfTRbM/fiCSCHw6zWM9XBbFT4K1Z/GAnThCza+oBklgR+ZRbqRw4X+mEgBsh3wbjAyVyhReIQRWkt/HP9GdSfrLWRxqIc3hUMUIb+EL29cNFSStTYU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696376274; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=zC6tWs4rfSzDMqqF62xFCimHfrup5j1pBNgITHNb/0k=; b=JZ2qmDxN9W2mjr566bxHR2GeTuI2OG7ak2EimIpDvBugzyGpt0wFCA1KFWloDvudGncDNfLuFo3UMsJ3FdO4fvxBvgQZ1UCEnr1UndxYONp+6zAs7eWc+XoUf7j5B09RJAVDTJswpvQNw74VTEs2x1Xv8ejdaJaOYnnKAF0QjwY= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1696376274563661.1692132007292; Tue, 3 Oct 2023 16:37:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qnovI-00047l-Kr; Tue, 03 Oct 2023 19:35:28 -0400 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 1qnovF-00045N-Qx for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:25 -0400 Received: from mail-io1-xd35.google.com ([2607:f8b0:4864:20::d35]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qnovE-00070n-0F for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:25 -0400 Received: by mail-io1-xd35.google.com with SMTP id ca18e2360f4ac-79f8e4108c3so64861039f.3 for ; Tue, 03 Oct 2023 16:35:23 -0700 (PDT) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id w25-20020a6b4a19000000b0079fa1a7cd36sm593596iob.30.2023.10.03.16.35.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 16:35:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1696376122; x=1696980922; 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=zC6tWs4rfSzDMqqF62xFCimHfrup5j1pBNgITHNb/0k=; b=nYSR44qxyJvpGlWBujbeUWKVeRqCNBi3k8iapNP4q44j5o2P/tDnjgkQoAFNU1rVMc bI1VJFERW/8yMF+aC1X9nYXEpTnJY6iozCbYFcbqSh1IKsCACg7mLRN/dg5OzEUkWhaS ILEPfZkGmMIh4wzVfww6hTo+Hk7tBYQQaNVzQUntEd1HZRc1agy4dfcBZ8kM7sU/LuVr cSADprbKSqT3gQQUngJeIjmNx1ic21LQ6fMmApn+pEvLNgoZF0uA69HVybq5m/0FFeJt QVxeMNW7x2ErWjqLFD0SN2IlYKmIYNYQPp1gI+jdbAvZ0jPv91GpoRYOdX/MDRmxLj38 KhMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696376122; x=1696980922; 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=zC6tWs4rfSzDMqqF62xFCimHfrup5j1pBNgITHNb/0k=; b=Rwsca4QRdZ3NC9Tr7g1AdJjhnJHd+Qt0dTt2/noKR3r74HS5JulMdwgW6nijSdCI5O 95dC2qgNtGAOtdr888iOJ8x5RFNAaEsGNFHwjJyXTebPvdQ0anH6yc5DNPBND39m8tqv QYpCP2vAMQUYRuPI3Ilm9+cMhxR5R7/B9UaoRoi3v3mMOjpqVgirIwW9I40TsKd1v7ND iZkKMGdkU1BIiW3nRlnjS7jubZWdNE9zowtaorwXd7c8VFGKtjHG+YUEIJrzHPDizU8t UesU8Nzl7VfWo4ykIf0giXuOlGvYFOyURPt0I83QVmAPP5gYxKnKwcos0Lk8nmY6x1ya EKFA== X-Gm-Message-State: AOJu0YyVF6HtnQIY6l7lN9rInbW25n4UN5UOolR+aFLN6SYO2/QHe10m lkSxQqGRYzN0hV9Ww5vn8N45apzd+8bpqK3VYy2SRw== X-Google-Smtp-Source: AGHT+IEgvy38efNg4J5FZthuXhfl+xpTKfx0io9lT/m+8ulb/uQBYchlvjujBlkp7JFAZ9HxxboU9Q== X-Received: by 2002:a6b:f209:0:b0:79f:9574:b93c with SMTP id q9-20020a6bf209000000b0079f9574b93cmr879342ioh.0.1696376122486; Tue, 03 Oct 2023 16:35:22 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Thomas Huth , Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Wainer dos Santos Moschetta , Beraldo Leal , Warner Losh , Kyle Evans , Stacey Son , Karim Taha , Richard Henderson Subject: [PULL 17/51] bsd-user: Add stubs for profil(2), ktrace(2), utrace(2) and ptrace(2). Date: Tue, 3 Oct 2023 17:31:41 -0600 Message-ID: <20231003233215.95557-18-imp@bsdimp.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231003233215.95557-1-imp@bsdimp.com> References: <20231003233215.95557-1-imp@bsdimp.com> MIME-Version: 1.0 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: none client-ip=2607:f8b0:4864:20::d35; envelope-from=imp@bsdimp.com; helo=mail-io1-xd35.google.com 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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 @bsdimp-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1696376276438100003 Content-Type: text/plain; charset="utf-8" From: Stacey Son Signed-off-by: Stacey Son Signed-off-by: Karim Taha Reviewed-by: Richard Henderson Reviewed-by: Warner Losh Message-Id: <20230925182425.3163-18-kariem.taha2.7@gmail.com> --- bsd-user/bsd-proc.h | 28 ++++++++++++++++++++++++++++ bsd-user/freebsd/os-syscall.c | 16 ++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/bsd-user/bsd-proc.h b/bsd-user/bsd-proc.h index a5f301c72ff..2c1a9ae22fa 100644 --- a/bsd-user/bsd-proc.h +++ b/bsd-user/bsd-proc.h @@ -362,4 +362,32 @@ static inline abi_long do_bsd_issetugid(void) return get_errno(issetugid()); } =20 +/* profil(2) */ +static inline abi_long do_bsd_profil(abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4) +{ + return -TARGET_ENOSYS; +} + +/* ktrace(2) */ +static inline abi_long do_bsd_ktrace(abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4) +{ + return -TARGET_ENOSYS; +} + +/* utrace(2) */ +static inline abi_long do_bsd_utrace(abi_long arg1, abi_long arg2) +{ + return -TARGET_ENOSYS; +} + + +/* ptrace(2) */ +static inline abi_long do_bsd_ptrace(abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4) +{ + return -TARGET_ENOSYS; +} + #endif /* !BSD_PROC_H_ */ diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index 7b51f4f16e4..1a760b13808 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -343,6 +343,22 @@ static abi_long freebsd_syscall(void *cpu_env, int num= , abi_long arg1, ret =3D do_bsd_issetugid(); break; =20 + case TARGET_FREEBSD_NR_profil: /* profil(2) */ + ret =3D do_bsd_profil(arg1, arg2, arg3, arg4); + break; + + case TARGET_FREEBSD_NR_ktrace: /* ktrace(2) */ + ret =3D do_bsd_ktrace(arg1, arg2, arg3, arg4); + break; + + case TARGET_FREEBSD_NR_utrace: /* utrace(2) */ + ret =3D do_bsd_utrace(arg1, arg2); + break; + + case TARGET_FREEBSD_NR_ptrace: /* ptrace(2) */ + ret =3D do_bsd_ptrace(arg1, arg2, arg3, arg4); + break; + =20 /* * File system calls. --=20 2.41.0 From nobody Sun May 19 09:42:24 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1696376396; cv=none; d=zohomail.com; s=zohoarc; b=M/fVLxCujtnm02i2b0CXWyAzDWKvKvCKTADI3JmNzkoZ1da4sjHvZUe1uWbEZWyup9MfsVLs1XKpiRfgcL0clVF6HKhGFoOrI5hrvVSvL6mwnywAQM+hQ7RYQXJpzdICgNZRHWvE4hAohc4n2+xLeUv8odOV92ITIByppPDM9fo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696376396; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=tN2OEe5rYzQGfb+nOOMon2seHs5SrR+EQ42mg0JPMFg=; b=KBg7xW77ro26RDExO6BoAeuyu22yUJIfAQu2jedz0+SO9dRg8iZldQZ0YdHvve9S+t1EraPg5sCIlCR23v5EtLuRJq1xUQOwfqLQbOJSIYpaNZeXr2rY0mxpHbJKUlFYYad7QqwVYzOBxokZSSgiAz+C5Edf4BVuTxhVfwr/bJQ= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1696376396489267.33244129381114; Tue, 3 Oct 2023 16:39:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qnovI-00047P-3H; Tue, 03 Oct 2023 19:35:28 -0400 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 1qnovG-00045h-Aw for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:26 -0400 Received: from mail-io1-xd34.google.com ([2607:f8b0:4864:20::d34]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qnovE-000719-M8 for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:26 -0400 Received: by mail-io1-xd34.google.com with SMTP id ca18e2360f4ac-79fe6da0095so60241539f.0 for ; Tue, 03 Oct 2023 16:35:24 -0700 (PDT) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id w25-20020a6b4a19000000b0079fa1a7cd36sm593596iob.30.2023.10.03.16.35.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 16:35:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1696376123; x=1696980923; 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=tN2OEe5rYzQGfb+nOOMon2seHs5SrR+EQ42mg0JPMFg=; b=oRtvZQN/ok44oUDkrKAQJLiElIfAAADDhzzQHhinGmjDVcDOz1VNHG63sshI4+c/B8 T60vOK/eDdoOvHbtx53o2tnwamDtAGNMYWgTQFBDOOKdOXHw1OA3K2IuDXb/sQ4VJ+2L JKui/M9OzbLDyxtiDzfNmB8ADYp7Iv9wl3A6iAoNqGb9xh6O8fVHZpp5A9vz9JPXcnln YmU+nsdwK3rpuzVq9QTARHo1MbIxDSLLuj+zqrAJPTWfay+Z/C4HYCUY2o1PZVH18iFl f2E6fFrjwPNpTxFsrQyyOH8yZcsVlWMKzF2YXT4k/08bg48LG/jI5siSZ9VPjaJUxyo1 Re0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696376123; x=1696980923; 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=tN2OEe5rYzQGfb+nOOMon2seHs5SrR+EQ42mg0JPMFg=; b=FJyGCu4/dkt+qF+k9W3vfrfoMMJTKgkt29RbhD3x98fZWzu6NhHJVBYd3wYy7avNvA +XVrNSCPSEsv1U8uxkhG+U2DYghsn4yK0ztwclzS26pR+Sg/Ku0OBwu3Mr9p4uLJWcOA 8dwLQNt8ii0JxPS2qWyYOIbjvXIz62qo9H0ZNs9eijH2fGMH4M1pi1rxtxMHuiAPKS+t 7lyYHBwJ7PjWnN53WXUVgEprd6c9/ucX+AnIKObMwSYq6eLE/sz03axyYh/MR/6g72DW k9R3C1gmYHy55XInBn8zNWWi5WlrwpXyqIYaEhjLpEul50UQ0z0vMwYXVV8YE1cEY43U hPFA== X-Gm-Message-State: AOJu0YyO0rtMV/BZp9qrKA2Umx7L1OG3yBfbFX0SrBDVgU4A7OPNeSrE YaNT+dSZFo4J9vvqSc6GrO50zLU19YM0jgHhJIdLAA== X-Google-Smtp-Source: AGHT+IGu73C870FKUKyG6qdiMQofMSs+XPxu0tSixF/UVsAwldP05qJ6CzVK6ArPBhsKGAqD3rpasw== X-Received: by 2002:a05:6602:220e:b0:786:f352:e3d4 with SMTP id n14-20020a056602220e00b00786f352e3d4mr983515ion.7.1696376123392; Tue, 03 Oct 2023 16:35:23 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Thomas Huth , Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Wainer dos Santos Moschetta , Beraldo Leal , Warner Losh , Kyle Evans , Stacey Son , Karim Taha Subject: [PULL 18/51] bsd-user: Implement getpriority(2) and setpriority(2). Date: Tue, 3 Oct 2023 17:31:42 -0600 Message-ID: <20231003233215.95557-19-imp@bsdimp.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231003233215.95557-1-imp@bsdimp.com> References: <20231003233215.95557-1-imp@bsdimp.com> MIME-Version: 1.0 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: none client-ip=2607:f8b0:4864:20::d34; envelope-from=imp@bsdimp.com; helo=mail-io1-xd34.google.com 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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 @bsdimp-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1696376398180100003 Content-Type: text/plain; charset="utf-8" From: Stacey Son Signed-off-by: Stacey Son Signed-off-by: Karim Taha Reviewed-by: Warner Losh Message-Id: <20230925182425.3163-19-kariem.taha2.7@gmail.com> --- bsd-user/bsd-proc.h | 24 ++++++++++++++++++++++++ bsd-user/freebsd/os-syscall.c | 8 ++++++++ 2 files changed, 32 insertions(+) diff --git a/bsd-user/bsd-proc.h b/bsd-user/bsd-proc.h index 2c1a9ae22fa..9a8912361f6 100644 --- a/bsd-user/bsd-proc.h +++ b/bsd-user/bsd-proc.h @@ -390,4 +390,28 @@ static inline abi_long do_bsd_ptrace(abi_long arg1, ab= i_long arg2, return -TARGET_ENOSYS; } =20 +/* getpriority(2) */ +static inline abi_long do_bsd_getpriority(abi_long which, abi_long who) +{ + abi_long ret; + /* + * Note that negative values are valid for getpriority, so we must + * differentiate based on errno settings. + */ + errno =3D 0; + ret =3D getpriority(which, who); + if (ret =3D=3D -1 && errno !=3D 0) { + return -host_to_target_errno(errno); + } + + return ret; +} + +/* setpriority(2) */ +static inline abi_long do_bsd_setpriority(abi_long which, abi_long who, + abi_long prio) +{ + return get_errno(setpriority(which, who, prio)); +} + #endif /* !BSD_PROC_H_ */ diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index 1a760b13808..71a2657dd0f 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -359,6 +359,14 @@ static abi_long freebsd_syscall(void *cpu_env, int num= , abi_long arg1, ret =3D do_bsd_ptrace(arg1, arg2, arg3, arg4); break; =20 + case TARGET_FREEBSD_NR_getpriority: /* getpriority(2) */ + ret =3D do_bsd_getpriority(arg1, arg2); + break; + + case TARGET_FREEBSD_NR_setpriority: /* setpriority(2) */ + ret =3D do_bsd_setpriority(arg1, arg2, arg3); + break; + =20 /* * File system calls. --=20 2.41.0 From nobody Sun May 19 09:42:24 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1696376409; cv=none; d=zohomail.com; s=zohoarc; b=nzV1ugukSzo5px56BJsrUvIlrqfED4TMJ6z13YdmvGo3JRFv6C/jUAD9f6DUCtxd3qSCCPB4aSCSakJaUuBW/QoO6VdLGgL9h9xdOwCWydQuatC02I+0sM3wKBVfdKnYBPwd6q0qK+YzswSeuv+YG8952ajwaqoLGYIS2lbN4X4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696376409; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=vv+aIku3DmAqisUQxx9HbMj8tI0pAJwZVGFoGM6lqnw=; b=by+SHXN7qeiItNza82a1goCEvBYrDslg2Vk93qN/HJRTpMmiyVDYsHzmpjtrnVvOz0aqU/gfmEfXvttzvA09BozzH6OFcPDekdAm+LHIHvL6Ex6pvVUpPlYLlGy2IVtPqFn7NC5ASAvEOUMb38sypApotAFhGrTQ/h4Gx0JS/ZA= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1696376409894552.1689422022971; Tue, 3 Oct 2023 16:40:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qnovL-00049W-5E; Tue, 03 Oct 2023 19:35:31 -0400 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 1qnovJ-00048T-UD for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:29 -0400 Received: from mail-io1-xd41.google.com ([2607:f8b0:4864:20::d41]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qnovI-00071Q-4Z for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:29 -0400 Received: by mail-io1-xd41.google.com with SMTP id ca18e2360f4ac-79f915e5b47so59904339f.2 for ; Tue, 03 Oct 2023 16:35:27 -0700 (PDT) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id w25-20020a6b4a19000000b0079fa1a7cd36sm593596iob.30.2023.10.03.16.35.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 16:35:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1696376124; x=1696980924; 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=vv+aIku3DmAqisUQxx9HbMj8tI0pAJwZVGFoGM6lqnw=; b=kokjwctmR6dOZXx8mqR/7KOyarl6r7QTq5FaSo6N9kkW+CzVtjqd7LjVAsW11xLePW Mi+6X9kdkMLWt7FmLCsAJRaNEWf9bqgS6x5O3pEFuXt2tbAjYDIUhcKaScaZzyuVJ7yo Ms6XPwLl1/2g0n9GpBgihIL6wvodm4ore9L8QXln0SphV2EhACCBXbNK3yRbB3/JjH0H hGfRPRwI2UNODPd4yNMwPYjhRjdUG+l86zPqjz+rmtBDdlTBPmMIrEVxMNm3okq3BrRg J9eJ2sogXFEUlkL49Pp+ai21oUxk9aGduWI9Te8NppKLW/gbYFyaNLs1zt5BPnp0iBo3 ZkGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696376124; x=1696980924; 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=vv+aIku3DmAqisUQxx9HbMj8tI0pAJwZVGFoGM6lqnw=; b=C1zdKnyHieWmca/LwzSlJELQR3r/9g4q40UhbImWMV6cmGFHoB2mS+EKsKdUQxxmMu 1mbqhw+WgLdQVFt6Pf4WVWuJbqr2essTixXP5JPsBGEkSJLmTVAS2PJzMbyWgxV0GJAh b8aXTNAM3c1AY2wjFLm133oQyUsHnL1huUPr4WZ0ea+irx8fBe/pZQ49U/glnkjg/zQn AB8ttyZpMK0dyKRbrh9vkdNPnnSYDP/eWcSKMAiN9b7Zl+1ZUjt4jrlB6a0Rx7YOZtWr GUZQAJk0leoiFBnJ8GMCgaFQT5DE72qLdwgWxa6slLFBWG5+03pg7eKzeOO9K/3TsB99 kHWA== X-Gm-Message-State: AOJu0YwPGz4ky4bixA9Q4wpoZyOWI76Pc/vdmgWIIDrZY8Sj1aHpdKxn cUWuwc+omUSwVTiLh1DqvjQ0IJK3W/QsTH01wygelhpZ X-Google-Smtp-Source: AGHT+IFw4OoDwo4flJGVdNrfgTtXrScqPpMtqyLxdUBmxMbcaRVLolhNc8uhX597cfLvsI7THGuRbg== X-Received: by 2002:a5d:9943:0:b0:79f:9eb4:3ea1 with SMTP id v3-20020a5d9943000000b0079f9eb43ea1mr1019417ios.3.1696376124287; Tue, 03 Oct 2023 16:35:24 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Thomas Huth , Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Wainer dos Santos Moschetta , Beraldo Leal , Warner Losh , Kyle Evans , Karim Taha , Stacey Son , Richard Henderson Subject: [PULL 19/51] bsd-user: Implement get_filename_from_fd. Date: Tue, 3 Oct 2023 17:31:43 -0600 Message-ID: <20231003233215.95557-20-imp@bsdimp.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231003233215.95557-1-imp@bsdimp.com> References: <20231003233215.95557-1-imp@bsdimp.com> MIME-Version: 1.0 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: none client-ip=2607:f8b0:4864:20::d41; envelope-from=imp@bsdimp.com; helo=mail-io1-xd41.google.com 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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 @bsdimp-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1696376411670100010 Content-Type: text/plain; charset="utf-8" From: Karim Taha Signed-off-by: Stacey Son Signed-off-by: Karim Taha Reviewed-by: Richard Henderson Reviewed-by: Warner Losh Message-Id: <20230925182425.3163-20-kariem.taha2.7@gmail.com> --- bsd-user/freebsd/meson.build | 1 + bsd-user/freebsd/os-proc.c | 82 ++++++++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+) create mode 100644 bsd-user/freebsd/os-proc.c diff --git a/bsd-user/freebsd/meson.build b/bsd-user/freebsd/meson.build index f2f047cca31..8fd6c7cfb82 100644 --- a/bsd-user/freebsd/meson.build +++ b/bsd-user/freebsd/meson.build @@ -1,5 +1,6 @@ bsd_user_ss.add(files( 'os-stat.c', + 'os-proc.c', 'os-sys.c', 'os-syscall.c', )) diff --git a/bsd-user/freebsd/os-proc.c b/bsd-user/freebsd/os-proc.c new file mode 100644 index 00000000000..2603c5c6538 --- /dev/null +++ b/bsd-user/freebsd/os-proc.c @@ -0,0 +1,82 @@ +/* + * FreeBSD process related emulation code + * + * Copyright (c) 2013-15 Stacey D. Son + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + */ +#include "qemu/osdep.h" + +#include +#include +#include +struct kinfo_proc; +#include + +#include "qemu.h" + +/* + * Get the filename for the given file descriptor. + * Note that this may return NULL (fail) if no longer cached in the kernel. + */ +char * +get_filename_from_fd(pid_t pid, int fd, char *filename, size_t len); +char * +get_filename_from_fd(pid_t pid, int fd, char *filename, size_t len) +{ + char *ret =3D NULL; + unsigned int cnt; + struct procstat *procstat =3D NULL; + struct kinfo_proc *kp =3D NULL; + struct filestat_list *head =3D NULL; + struct filestat *fst; + + procstat =3D procstat_open_sysctl(); + if (procstat =3D=3D NULL) { + goto out; + } + + kp =3D procstat_getprocs(procstat, KERN_PROC_PID, pid, &cnt); + if (kp =3D=3D NULL) { + goto out; + } + + head =3D procstat_getfiles(procstat, kp, 0); + if (head =3D=3D NULL) { + goto out; + } + + STAILQ_FOREACH(fst, head, next) { + if (fd =3D=3D fst->fs_fd) { + if (fst->fs_path !=3D NULL) { + (void)strlcpy(filename, fst->fs_path, len); + ret =3D filename; + } + break; + } + } + +out: + if (head !=3D NULL) { + procstat_freefiles(procstat, head); + } + if (kp !=3D NULL) { + procstat_freeprocs(procstat, kp); + } + if (procstat !=3D NULL) { + procstat_close(procstat); + } + return ret; +} + --=20 2.41.0 From nobody Sun May 19 09:42:24 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1696376460; cv=none; d=zohomail.com; s=zohoarc; b=H2gydtMRV9r1LS/zzdVo6dddfchSAb04eTZmF83yryaqAHzXc4H3gkZJHo485+LrFgtACHFCC/qYWH7N9qmdM6r1TPL7G0oMmYC5FxDTsSv0LyqEoCTGT4dv8ogiMcd3p99x/VJwR2hG08LHSuZTJc5F+ZgQlh5SvOpyEvYKKPg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696376460; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=sv5fIcvD1HSjiZO4IkYJ3Frs5DqY4m3pn2tlZXjMwRw=; b=ZUNbIofJ78+PZ3B1Bx/GmBo7cN2vDyBmz6zqw9t2ZYfBcfPGT4TapiaIvkD8okI0igTDJYw+2CUkZcFBxXb2EcWVkJb4dSUXtE9tT2UfTW4iRDIXb6FCedjSqdn7ktkOVLG15IiH8BWvcxqHomwXEZbHXpETCM1tMp2lUI9X4xU= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1696376460838713.0011088562198; Tue, 3 Oct 2023 16:41:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qnovK-00049N-Tk; Tue, 03 Oct 2023 19:35:30 -0400 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 1qnovI-000486-Lk for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:28 -0400 Received: from mail-io1-xd29.google.com ([2607:f8b0:4864:20::d29]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qnovG-00072n-Pb for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:28 -0400 Received: by mail-io1-xd29.google.com with SMTP id ca18e2360f4ac-79fe8986355so59681139f.2 for ; Tue, 03 Oct 2023 16:35:26 -0700 (PDT) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id w25-20020a6b4a19000000b0079fa1a7cd36sm593596iob.30.2023.10.03.16.35.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 16:35:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1696376125; x=1696980925; 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=sv5fIcvD1HSjiZO4IkYJ3Frs5DqY4m3pn2tlZXjMwRw=; b=NzOkPeKZDKo5R8PFmAP5/IiOgx3c/2pyDiCGz43xiZPrn7M0RO9Yoz3NFUzbwirNBF rjJ+5BHAklZ2fqasZ//HcGFPdfUUXXblCWzVDJsw6dIYcMdhrdHLYgotrpYr0/H8lfJx iA+m4gVmQFycyxGovqamuN72E6TyRgwLtfMzsLqJvjF3FP+kechZL2pQaWKY4fD1Fg16 PIT5mkbj9kELQ192ljafjBJ/CLmVSaBbR5F/KWZYUuTInkSbdmw6eD1BbnBr363IhG66 fia47EVVQ5gJnS1STg0JKKMDnWjiPwZiHVU09sJVzWte0DHFLHgBrxmLM4h1gUHovUBk dFFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696376125; x=1696980925; 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=sv5fIcvD1HSjiZO4IkYJ3Frs5DqY4m3pn2tlZXjMwRw=; b=CkYJNyDPdS/fGxQVjVgubtfjen9NpGMVSbaQ2EMVEUgOg9loXOh7AJ2tSeidyJBgMC EKP0pdRwFVKuMXFwsY9ud+877OCnYfPy2CFa3VUQH8EXWRP4EN7H2HmgJcLCYY2TUDzP SsGFzcaoaAb9TTbsE0UNQZ6TVI1oOY4kLwTnwhBP0SpxcWI+Rw6J31pXfT76Gx2qebg2 RdE62UIs4QBUFl46oO1RaSnU+KigpTY8KAP3DE2b/9XDT16CqprG2CBMc81UDvxqg7XJ e9b3Q8NhKOFkrydeQIY57drFQ9Vu4QSD+QxfBRJdYHIvpyiiZ+0KYlwrsaANB53c+LfE mDkw== X-Gm-Message-State: AOJu0YzUrFDDEFyN8v1oyNyxE0j/d4O89w4/oQHAx6dQRHksnEPGoRez 7Yi/y4pWIyvET+l0+/7DDP88GYcbKW86Il9qJZ516g== X-Google-Smtp-Source: AGHT+IHihLl8StzxS1Av2J8nfFrSkmsiigD5A2jkilmvDE6tVDJ3UGgleQ8UsZyDqLw3y8uNlwkClw== X-Received: by 2002:a5d:9e19:0:b0:792:82f8:7402 with SMTP id h25-20020a5d9e19000000b0079282f87402mr991412ioh.16.1696376125147; Tue, 03 Oct 2023 16:35:25 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Thomas Huth , Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Wainer dos Santos Moschetta , Beraldo Leal , Warner Losh , Kyle Evans , Stacey Son , Karim Taha Subject: [PULL 20/51] bsd-user: Implement freebsd_exec_common, used in implementing execve/fexecve. Date: Tue, 3 Oct 2023 17:31:44 -0600 Message-ID: <20231003233215.95557-21-imp@bsdimp.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231003233215.95557-1-imp@bsdimp.com> References: <20231003233215.95557-1-imp@bsdimp.com> MIME-Version: 1.0 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: none client-ip=2607:f8b0:4864:20::d29; envelope-from=imp@bsdimp.com; helo=mail-io1-xd29.google.com 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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 @bsdimp-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1696376461440100003 Content-Type: text/plain; charset="utf-8" From: Stacey Son Signed-off-by: Stacey Son Signed-off-by: Karim Taha Reviewed-by: Warner Losh Message-Id: <20230925182425.3163-21-kariem.taha2.7@gmail.com> --- bsd-user/freebsd/os-proc.c | 181 ++++++++++++++++++++++++++++++++++++- bsd-user/main.c | 2 +- bsd-user/qemu.h | 1 + 3 files changed, 180 insertions(+), 4 deletions(-) diff --git a/bsd-user/freebsd/os-proc.c b/bsd-user/freebsd/os-proc.c index 2603c5c6538..12d78b7fc98 100644 --- a/bsd-user/freebsd/os-proc.c +++ b/bsd-user/freebsd/os-proc.c @@ -30,9 +30,7 @@ struct kinfo_proc; * Get the filename for the given file descriptor. * Note that this may return NULL (fail) if no longer cached in the kernel. */ -char * -get_filename_from_fd(pid_t pid, int fd, char *filename, size_t len); -char * +static char * get_filename_from_fd(pid_t pid, int fd, char *filename, size_t len) { char *ret =3D NULL; @@ -80,3 +78,180 @@ out: return ret; } =20 +/* + * execve/fexecve + */ +abi_long freebsd_exec_common(abi_ulong path_or_fd, abi_ulong guest_argp, + abi_ulong guest_envp, int do_fexec) +{ + char **argp, **envp, **qargp, **qarg1, **qarg0, **qargend; + int argc, envc; + abi_ulong gp; + abi_ulong addr; + char **q; + int total_size =3D 0; + void *p; + abi_long ret; + + argc =3D 0; + for (gp =3D guest_argp; gp; gp +=3D sizeof(abi_ulong)) { + if (get_user_ual(addr, gp)) { + return -TARGET_EFAULT; + } + if (!addr) { + break; + } + argc++; + } + envc =3D 0; + for (gp =3D guest_envp; gp; gp +=3D sizeof(abi_ulong)) { + if (get_user_ual(addr, gp)) { + return -TARGET_EFAULT; + } + if (!addr) { + break; + } + envc++; + } + + qarg0 =3D argp =3D g_new0(char *, argc + 9); + /* save the first agrument for the emulator */ + *argp++ =3D (char *)getprogname(); + qargp =3D argp; + *argp++ =3D (char *)getprogname(); + qarg1 =3D argp; + envp =3D g_new0(char *, envc + 1); + for (gp =3D guest_argp, q =3D argp; gp; gp +=3D sizeof(abi_ulong), q++= ) { + if (get_user_ual(addr, gp)) { + ret =3D -TARGET_EFAULT; + goto execve_end; + } + if (!addr) { + break; + } + *q =3D lock_user_string(addr); + if (*q =3D=3D NULL) { + ret =3D -TARGET_EFAULT; + goto execve_end; + } + total_size +=3D strlen(*q) + 1; + } + *q++ =3D NULL; + qargend =3D q; + + for (gp =3D guest_envp, q =3D envp; gp; gp +=3D sizeof(abi_ulong), q++= ) { + if (get_user_ual(addr, gp)) { + ret =3D -TARGET_EFAULT; + goto execve_end; + } + if (!addr) { + break; + } + *q =3D lock_user_string(addr); + if (*q =3D=3D NULL) { + ret =3D -TARGET_EFAULT; + goto execve_end; + } + total_size +=3D strlen(*q) + 1; + } + *q =3D NULL; + + /* + * This case will not be caught by the host's execve() if its + * page size is bigger than the target's. + */ + if (total_size > MAX_ARG_PAGES * TARGET_PAGE_SIZE) { + ret =3D -TARGET_E2BIG; + goto execve_end; + } + + if (do_fexec) { + if (((int)path_or_fd > 0 && + is_target_elf_binary((int)path_or_fd)) =3D=3D 1) { + char execpath[PATH_MAX]; + + /* + * The executable is an elf binary for the target + * arch. execve() it using the emulator if we can + * determine the filename path from the fd. + */ + if (get_filename_from_fd(getpid(), (int)path_or_fd, execpath, + sizeof(execpath)) !=3D NULL) { + memmove(qarg1 + 2, qarg1, (qargend - qarg1) * sizeof(*qarg= 1)); + qarg1[1] =3D qarg1[0]; + qarg1[0] =3D (char *)"-0"; + qarg1 +=3D 2; + qargend +=3D 2; + *qarg1 =3D execpath; +#ifndef DONT_INHERIT_INTERP_PREFIX + memmove(qarg1 + 2, qarg1, (qargend - qarg1) * sizeof(*qarg= 1)); + *qarg1++ =3D (char *)"-L"; + *qarg1++ =3D (char *)interp_prefix; +#endif + ret =3D get_errno(execve(qemu_proc_pathname, qargp, envp)); + } else { + /* Getting the filename path failed. */ + ret =3D -TARGET_EBADF; + goto execve_end; + } + } else { + ret =3D get_errno(fexecve((int)path_or_fd, argp, envp)); + } + } else { + int fd; + + p =3D lock_user_string(path_or_fd); + if (p =3D=3D NULL) { + ret =3D -TARGET_EFAULT; + goto execve_end; + } + + /* + * Check the header and see if it a target elf binary. If so + * then execute using qemu user mode emulator. + */ + fd =3D open(p, O_RDONLY | O_CLOEXEC); + if (fd > 0 && is_target_elf_binary(fd) =3D=3D 1) { + close(fd); + /* execve() as a target binary using emulator. */ + memmove(qarg1 + 2, qarg1, (qargend - qarg1) * sizeof(*qarg1)); + qarg1[1] =3D qarg1[0]; + qarg1[0] =3D (char *)"-0"; + qarg1 +=3D 2; + qargend +=3D 2; + *qarg1 =3D (char *)p; +#ifndef DONT_INHERIT_INTERP_PREFIX + memmove(qarg1 + 2, qarg1, (qargend - qarg1) * sizeof(*qarg1)); + *qarg1++ =3D (char *)"-L"; + *qarg1++ =3D (char *)interp_prefix; +#endif + ret =3D get_errno(execve(qemu_proc_pathname, qargp, envp)); + } else { + close(fd); + /* Execve() as a host native binary. */ + ret =3D get_errno(execve(p, argp, envp)); + } + unlock_user(p, path_or_fd, 0); + } + +execve_end: + for (gp =3D guest_argp, q =3D argp; *q; gp +=3D sizeof(abi_ulong), q++= ) { + if (get_user_ual(addr, gp) || !addr) { + break; + } + unlock_user(*q, addr, 0); + } + + for (gp =3D guest_envp, q =3D envp; *q; gp +=3D sizeof(abi_ulong), q++= ) { + if (get_user_ual(addr, gp) || !addr) { + break; + } + unlock_user(*q, addr, 0); + } + + g_free(qarg0); + g_free(envp); + + return ret; +} + diff --git a/bsd-user/main.c b/bsd-user/main.c index f913cb55a72..a12b4be80f1 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -88,7 +88,7 @@ unsigned long reserved_va =3D MAX_RESERVED_VA; unsigned long reserved_va; #endif =20 -static const char *interp_prefix =3D CONFIG_QEMU_INTERP_PREFIX; +const char *interp_prefix =3D CONFIG_QEMU_INTERP_PREFIX; const char *qemu_uname_release; char qemu_proc_pathname[PATH_MAX]; /* full path to exeutable */ =20 diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h index 41c7bd31d3c..6047805ae38 100644 --- a/bsd-user/qemu.h +++ b/bsd-user/qemu.h @@ -111,6 +111,7 @@ typedef struct TaskState { } __attribute__((aligned(16))) TaskState; =20 void stop_all_tasks(void); +extern const char *interp_prefix; extern const char *qemu_uname_release; =20 /* --=20 2.41.0 From nobody Sun May 19 09:42:24 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1696376234; cv=none; d=zohomail.com; s=zohoarc; b=S62k5pj+2SG7vs2liMFjTfDdsyiWiZOljJUo0RN3V4x2Ae5qRSoCsCBIR4tuL7On/BHiKUQcKtKQybV0uMWik8fKJ+M5Wjr4Dm9xcORfIX4wL3lpd4qh8lTVqk/cMhl7M9bQMCHGu5Z+Sq6ZSqXEqyDnzQ0psA47amhYNItmikw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696376234; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=XzrnmNRArI5YZLKP54kV4TVNyU5J4UUrUXJQ/E152oI=; b=XGAziPmXySkBj8d2nwMlbPv2fhZ70JE+aZsaALYmLY+3yaH8kgG6AcelpNXs+PArmVa78+p/qBefpoVVJRzNa9m7YXpGtQ+5TZSq9MlZVcAUxHXrpg1IOW+HHxO1g1god74RvYob/aqrbVkx/2XM0+hekuKeB8Ymo8nhmgMl5f4= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1696376234297646.6495012011391; Tue, 3 Oct 2023 16:37:14 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qnovZ-0004FS-4E; Tue, 03 Oct 2023 19:35:46 -0400 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 1qnovW-0004Ee-PH for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:43 -0400 Received: from mail-io1-xd44.google.com ([2607:f8b0:4864:20::d44]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qnovH-00077d-DD for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:42 -0400 Received: by mail-io1-xd44.google.com with SMTP id ca18e2360f4ac-79fbbb2bed0so12694439f.1 for ; Tue, 03 Oct 2023 16:35:27 -0700 (PDT) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id w25-20020a6b4a19000000b0079fa1a7cd36sm593596iob.30.2023.10.03.16.35.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 16:35:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1696376126; x=1696980926; 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=XzrnmNRArI5YZLKP54kV4TVNyU5J4UUrUXJQ/E152oI=; b=lcMnqVVdFImCWDT5CLciz2VyEOeuOL6Iov2ksGwf75PcqvPqBSxwzJKmZBokJqnQBe ghIxD5ArHqBpogc2DaJVpAeJ+pRrCYLjxDlmuZ/RO0FEUFKwnkF7rwpCie5DlB1M/UUh 4R32bCUZAfRIX8vs8GnPFwi3aPiN4juGS3SeVkASZqNP0ubllv6zzXJhVoEQ6IFapFHD oBZdTZumRoYlkog+srl5Gkt3hsGqlVQsCqo8eSEMi5+tNOKhWKMtuZ47J6UeFZdEfmvY L25AXDtRqY2CD8tPkiun+Sspu8w0bqjladyeB69q66K7YF4bH3xipL/0NAY+saXshSrY AgJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696376126; x=1696980926; 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=XzrnmNRArI5YZLKP54kV4TVNyU5J4UUrUXJQ/E152oI=; b=lEPS912//S+1OcQFumjUGpGKG50F6SOPcyD8ZzoyntVweYh3Mgs0hUBVO/+EyfUXrP 7fJTemS9pXM5PU5q0l+C9D/bap2C3VuaehSuSYe1MVBmGpH+6Q2bQ6HGtCvqrR31Vz7T j/JR0CzqBCE0WnXsLRJo9j0aFAPOb/BCCMXxEOvu4kFd7imuDnLkq+J8dNY3SkNNXW4E aNdbcNUJ6lIiOW+lx5VEOftM4/fUi7eqPq3iE4WgpPrK97EtDVAqYodLIQJ9FVTbhIOk wIOnl/0DUAds1f1a930rjkDJujaXxjz0+9AVYfAidDKY13yvHkcbCZxJv3Ci4IDQE66c sCUQ== X-Gm-Message-State: AOJu0Yyam8Dq3c43BoblCilNCqH1WTZ27gk5e/xad7Nex/QPMTl/ugqQ 0m8a5jxHboIqcVgOOpcqCqBRshivsELjlvg2/U274Hqr X-Google-Smtp-Source: AGHT+IEOM6zCTFwEwwYHJOFC6Z92TAqv1Eg04bCd4ztp56QCTf5GFBqIn8nUxX3MhljOaMezxPFmxA== X-Received: by 2002:a6b:740d:0:b0:790:aed5:d0b0 with SMTP id s13-20020a6b740d000000b00790aed5d0b0mr578583iog.0.1696376126114; Tue, 03 Oct 2023 16:35:26 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Thomas Huth , Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Wainer dos Santos Moschetta , Beraldo Leal , Warner Losh , Kyle Evans , Stacey Son , Karim Taha Subject: [PULL 21/51] bsd-user: Implement procctl(2) along with necessary conversion functions. Date: Tue, 3 Oct 2023 17:31:45 -0600 Message-ID: <20231003233215.95557-22-imp@bsdimp.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231003233215.95557-1-imp@bsdimp.com> References: <20231003233215.95557-1-imp@bsdimp.com> MIME-Version: 1.0 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: none client-ip=2607:f8b0:4864:20::d44; envelope-from=imp@bsdimp.com; helo=mail-io1-xd44.google.com 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, SPF_HELO_NONE=0.001, SPF_NONE=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 @bsdimp-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1696376234676100001 Content-Type: text/plain; charset="utf-8" From: Stacey Son Implement t2h_procctl_cmd, h2t_reaper_status, h2t_reaper_pidinfo and h2t/t2= h reaper_kill conversion functions. Signed-off-by: Stacey Son Signed-off-by: Karim Taha Reviewed-by: Warner Losh Message-Id: <20230925182425.3163-22-kariem.taha2.7@gmail.com> --- bsd-user/freebsd/os-proc.c | 223 ++++++++++++++++++++++++++++++++++ bsd-user/freebsd/os-syscall.c | 3 + 2 files changed, 226 insertions(+) diff --git a/bsd-user/freebsd/os-proc.c b/bsd-user/freebsd/os-proc.c index 12d78b7fc98..4e67ae4d56c 100644 --- a/bsd-user/freebsd/os-proc.c +++ b/bsd-user/freebsd/os-proc.c @@ -255,3 +255,226 @@ execve_end: return ret; } =20 +#include + +static abi_long +t2h_procctl_cmd(int target_cmd, int *host_cmd) +{ + switch (target_cmd) { + case TARGET_PROC_SPROTECT: + *host_cmd =3D PROC_SPROTECT; + break; + + case TARGET_PROC_REAP_ACQUIRE: + *host_cmd =3D PROC_REAP_ACQUIRE; + break; + + case TARGET_PROC_REAP_RELEASE: + *host_cmd =3D PROC_REAP_RELEASE; + break; + + case TARGET_PROC_REAP_STATUS: + *host_cmd =3D PROC_REAP_STATUS; + break; + + case TARGET_PROC_REAP_KILL: + *host_cmd =3D PROC_REAP_KILL; + break; + + default: + return -TARGET_EINVAL; + } + + return 0; +} + +static abi_long +h2t_reaper_status(struct procctl_reaper_status *host_rs, + abi_ulong target_rs_addr) +{ + struct target_procctl_reaper_status *target_rs; + + if (!lock_user_struct(VERIFY_WRITE, target_rs, target_rs_addr, 0)) { + return -TARGET_EFAULT; + } + __put_user(host_rs->rs_flags, &target_rs->rs_flags); + __put_user(host_rs->rs_children, &target_rs->rs_children); + __put_user(host_rs->rs_descendants, &target_rs->rs_descendants); + __put_user(host_rs->rs_reaper, &target_rs->rs_reaper); + __put_user(host_rs->rs_pid, &target_rs->rs_pid); + unlock_user_struct(target_rs, target_rs_addr, 1); + + return 0; +} + +static abi_long +t2h_reaper_kill(abi_ulong target_rk_addr, struct procctl_reaper_kill *host= _rk) +{ + struct target_procctl_reaper_kill *target_rk; + + if (!lock_user_struct(VERIFY_READ, target_rk, target_rk_addr, 1)) { + return -TARGET_EFAULT; + } + __get_user(host_rk->rk_sig, &target_rk->rk_sig); + __get_user(host_rk->rk_flags, &target_rk->rk_flags); + __get_user(host_rk->rk_subtree, &target_rk->rk_subtree); + __get_user(host_rk->rk_killed, &target_rk->rk_killed); + __get_user(host_rk->rk_fpid, &target_rk->rk_fpid); + unlock_user_struct(target_rk, target_rk_addr, 0); + + return 0; +} + +static abi_long +h2t_reaper_kill(struct procctl_reaper_kill *host_rk, abi_ulong target_rk_a= ddr) +{ + struct target_procctl_reaper_kill *target_rk; + + if (!lock_user_struct(VERIFY_WRITE, target_rk, target_rk_addr, 0)) { + return -TARGET_EFAULT; + } + __put_user(host_rk->rk_sig, &target_rk->rk_sig); + __put_user(host_rk->rk_flags, &target_rk->rk_flags); + __put_user(host_rk->rk_subtree, &target_rk->rk_subtree); + __put_user(host_rk->rk_killed, &target_rk->rk_killed); + __put_user(host_rk->rk_fpid, &target_rk->rk_fpid); + unlock_user_struct(target_rk, target_rk_addr, 1); + + return 0; +} + +static abi_long +h2t_procctl_reaper_pidinfo(struct procctl_reaper_pidinfo *host_pi, + abi_ulong target_pi_addr) +{ + struct target_procctl_reaper_pidinfo *target_pi; + + if (!lock_user_struct(VERIFY_WRITE, target_pi, target_pi_addr, 0)) { + return -TARGET_EFAULT; + } + __put_user(host_pi->pi_pid, &target_pi->pi_pid); + __put_user(host_pi->pi_subtree, &target_pi->pi_subtree); + __put_user(host_pi->pi_flags, &target_pi->pi_flags); + unlock_user_struct(target_pi, target_pi_addr, 1); + + return 0; +} + +abi_long +do_freebsd_procctl(void *cpu_env, int idtype, abi_ulong arg2, abi_ulong ar= g3, + abi_ulong arg4, abi_ulong arg5, abi_ulong arg6) +{ + abi_long error =3D 0, target_rp_pids; + void *data; + int host_cmd, flags; + uint32_t u, target_rp_count; + g_autofree union { + struct procctl_reaper_status rs; + struct procctl_reaper_pids rp; + struct procctl_reaper_kill rk; + } host; + struct target_procctl_reaper_pids *target_rp; + id_t id; /* 64-bit */ + int target_cmd; + abi_ulong target_arg; + +#if TARGET_ABI_BITS =3D=3D 32 + /* See if we need to align the register pairs. */ + if (regpairs_aligned(cpu_env)) { + id =3D (id_t)target_arg64(arg3, arg4); + target_cmd =3D (int)arg5; + target_arg =3D arg6; + } else { + id =3D (id_t)target_arg64(arg2, arg3); + target_cmd =3D (int)arg4; + target_arg =3D arg5; + } +#else + id =3D (id_t)arg2; + target_cmd =3D (int)arg3; + target_arg =3D arg4; +#endif + + error =3D t2h_procctl_cmd(target_cmd, &host_cmd); + if (error) { + return error; + } + switch (host_cmd) { + case PROC_SPROTECT: + data =3D &flags; + break; + + case PROC_REAP_ACQUIRE: + case PROC_REAP_RELEASE: + if (target_arg =3D=3D 0) { + data =3D NULL; + } else { + error =3D -TARGET_EINVAL; + } + break; + + case PROC_REAP_STATUS: + data =3D &host.rs; + break; + + case PROC_REAP_GETPIDS: + if (!lock_user_struct(VERIFY_READ, target_rp, target_arg, 1)) { + return -TARGET_EFAULT; + } + __get_user(target_rp_count, &target_rp->rp_count); + __get_user(target_rp_pids, &target_rp->rp_pids); + unlock_user_struct(target_rp, target_arg, 0); + host.rp.rp_count =3D target_rp_count; + host.rp.rp_pids =3D g_try_new(struct procctl_reaper_pidinfo, + target_rp_count); + + if (host.rp.rp_pids =3D=3D NULL) { + error =3D -TARGET_ENOMEM; + } else { + data =3D &host.rp; + } + break; + + case PROC_REAP_KILL: + error =3D t2h_reaper_kill(target_arg, &host.rk); + break; + } + + if (error) { + return error; + } + error =3D get_errno(procctl(idtype, id, host_cmd, data)); + + if (error) { + return error; + } + switch (host_cmd) { + case PROC_SPROTECT: + if (put_user_s32(flags, target_arg)) { + return -TARGET_EFAULT; + } + break; + + case PROC_REAP_STATUS: + error =3D h2t_reaper_status(&host.rs, target_arg); + break; + + case PROC_REAP_GETPIDS: + /* copyout reaper pidinfo */ + for (u =3D 0; u < target_rp_count; u++) { + error =3D h2t_procctl_reaper_pidinfo(&host.rp.rp_pids[u], + target_rp_pids + + (u * sizeof(struct target_procctl_reaper_pidinfo))); + if (error) { + break; + } + } + break; + + case PROC_REAP_KILL: + error =3D h2t_reaper_kill(&host.rk, target_arg); + break; + } + + return error; +} diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index 71a2657dd0f..b7bd0b92a65 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -367,6 +367,9 @@ static abi_long freebsd_syscall(void *cpu_env, int num,= abi_long arg1, ret =3D do_bsd_setpriority(arg1, arg2, arg3); break; =20 + case TARGET_FREEBSD_NR_procctl: /* procctl(2) */ + ret =3D do_freebsd_procctl(cpu_env, arg1, arg2, arg3, arg4, arg5, = arg6); + break; =20 /* * File system calls. --=20 2.41.0 From nobody Sun May 19 09:42:24 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1696376195; cv=none; d=zohomail.com; s=zohoarc; b=StJPDLpsZWYaMZtz0XCu3a30wNNUyi6Qi/cFK98XUVlMSQ2YtarpRXHzb1+tTC/vm2S+nWmAHFcCN2K2WXmb2pw8jOa8+0YDf4XsCoa9swYAnEbmL0VHNz4nlq+SlX67k+zSFJpLT63ahOTkUpaj6eV44Dd4vqhcs9YdAONc9vg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696376195; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=khpHNEzdfaCxbzIOhGKqgUaYTgRrgL4oE446jB+w2fk=; b=hkD+Bdv2Iyf1TGcMsxX8jjHxeNDKJpQrey4pYtBzcDJC7reLTsQKO8vbNRuAgI+334RZZv77YPVn8YTJSMHmiVBuHWZrczqPiW+0jc8NBFbE2W5BVXR9aAujhWW72UciuOYo/L/7Bu2tCmQxJ9w8aODoNiWdwDpXT7bgqB18y7I= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1696376195659865.7415841596303; Tue, 3 Oct 2023 16:36:35 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qnovS-0004DN-NT; Tue, 03 Oct 2023 19:35:38 -0400 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 1qnovN-0004AZ-PR for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:33 -0400 Received: from mail-io1-xd41.google.com ([2607:f8b0:4864:20::d41]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qnovI-00077q-CZ for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:33 -0400 Received: by mail-io1-xd41.google.com with SMTP id ca18e2360f4ac-79fa7e33573so58985339f.0 for ; Tue, 03 Oct 2023 16:35:28 -0700 (PDT) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id w25-20020a6b4a19000000b0079fa1a7cd36sm593596iob.30.2023.10.03.16.35.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 16:35:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1696376127; x=1696980927; 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=khpHNEzdfaCxbzIOhGKqgUaYTgRrgL4oE446jB+w2fk=; b=jEHKqPNNid6cj37tjHV71FKm/wBiTNCwcgi1EDvdqJEmdeyjkU8Vn7eX+cGSCjM/dz wMMU+rQvqPe3S3z/SGHLZwQuIeqU0XSZkdOnsar77bubHLxEOxF9a5ftACE92tIhbMno tP6CkDbfUUO2KL5b4fbXa3bJ3y0j/gmofqBr1m6olVGzBcQ0/aXhm3GoCTLLmGX/lZnv GyV0YhQ7spuCCndnm3DRs8yzS0Syn1/jFFKPArajVc4yYMj1iK0kL3LxGWWBeepZsFwW 8BwKWLNrlpFfsJ5E8DLypu6atW9Qtu3SEzfoFiXEcPssfhHHNELFfhlmOM6KoPSIq9Qf d7YA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696376127; x=1696980927; 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=khpHNEzdfaCxbzIOhGKqgUaYTgRrgL4oE446jB+w2fk=; b=gKGpWcEEYoj4ZYkOG19v98ShWUE4fk0Wf2rKPJ+f/gXO25Rr+PnzUONrlyLc0tNT8o ekJokhm851R8TAeJhQQAaD2XzG+g+odfvznFp1J05TXZwrLsPQxibfyTy/5x/3oRp/q+ 1Cv65Flxrq63W8BbnCbCVzIQtMaO+sxQJQXbw3FHfXObk9tFGFeYbqrARmXHytCYgjU/ 1F6q7UXCOqW9vK4S9CN6sm2lNCw9VykjAf6sRc+N7Yf2HbA1tJRRwgP64fCbPLVF9Ry/ UYHq/WBg8yH6rwxfcg6H2u2d8ovyEtnB5ebYpaCJquSFrRrfED4ri/y/KnNrP0TH+WzW 1QzQ== X-Gm-Message-State: AOJu0YzaGpg9r315Lb/grWkRqiB5gdfc9kAyngsr7PeNCHiPqH/mmOAc /8v16c8AVO/YsEQz12dZ2tKFjR3YrJSweprMbjD95WqQ X-Google-Smtp-Source: AGHT+IEPv+LwyuqopHtCwJPkJmaoe6ylMiGdwKP7pV7r3B7QYlLzRXCazGXaRgnZ+XsSe231hKzOsA== X-Received: by 2002:a5e:dd0d:0:b0:786:7100:72de with SMTP id t13-20020a5edd0d000000b00786710072demr895056iop.16.1696376127036; Tue, 03 Oct 2023 16:35:27 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Thomas Huth , Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Wainer dos Santos Moschetta , Beraldo Leal , Warner Losh , Kyle Evans , Karim Taha , Stacey Son , Richard Henderson Subject: [PULL 22/51] bsd-user: Implement execve(2) and fexecve(2) system calls. Date: Tue, 3 Oct 2023 17:31:46 -0600 Message-ID: <20231003233215.95557-23-imp@bsdimp.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231003233215.95557-1-imp@bsdimp.com> References: <20231003233215.95557-1-imp@bsdimp.com> MIME-Version: 1.0 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: none client-ip=2607:f8b0:4864:20::d41; envelope-from=imp@bsdimp.com; helo=mail-io1-xd41.google.com 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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 @bsdimp-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1696376196627100005 Content-Type: text/plain; charset="utf-8" From: Karim Taha Signed-off-by: Stacey Son Signed-off-by: Karim Taha Reviewed-by: Richard Henderson Reviewed-by: Warner Losh Message-Id: <20230925182425.3163-23-kariem.taha2.7@gmail.com> --- bsd-user/freebsd/os-proc.h | 49 +++++++++++++++++++++++++++++++++++ bsd-user/freebsd/os-syscall.c | 11 +++++++- 2 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 bsd-user/freebsd/os-proc.h diff --git a/bsd-user/freebsd/os-proc.h b/bsd-user/freebsd/os-proc.h new file mode 100644 index 00000000000..75ed39f8ddd --- /dev/null +++ b/bsd-user/freebsd/os-proc.h @@ -0,0 +1,49 @@ +/* + * process related system call shims and definitions + * + * Copyright (c) 2013-14 Stacey D. Son + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + */ + +#ifndef BSD_USER_FREEBSD_OS_PROC_H +#define BSD_USER_FREEBSD_OS_PROC_H + +#include +#include +#include +#include +#include +#include +#include + +#include "target_arch_cpu.h" + +/* execve(2) */ +static inline abi_long do_freebsd_execve(abi_ulong path_or_fd, abi_ulong a= rgp, + abi_ulong envp) +{ + + return freebsd_exec_common(path_or_fd, argp, envp, 0); +} + +/* fexecve(2) */ +static inline abi_long do_freebsd_fexecve(abi_ulong path_or_fd, abi_ulong = argp, + abi_ulong envp) +{ + + return freebsd_exec_common(path_or_fd, argp, envp, 1); +} + +#endif /* BSD_USER_FREEBSD_OS_PROC_H */ diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index b7bd0b92a65..515eaaf31f1 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -36,8 +36,9 @@ #include "bsd-file.h" #include "bsd-proc.h" =20 -/* *BSD dependent syscall shims */ +/* BSD dependent syscall shims */ #include "os-stat.h" +#include "os-proc.h" =20 /* I/O */ safe_syscall3(int, open, const char *, path, int, flags, mode_t, mode); @@ -219,6 +220,14 @@ static abi_long freebsd_syscall(void *cpu_env, int num= , abi_long arg1, /* * process system calls */ + case TARGET_FREEBSD_NR_execve: /* execve(2) */ + ret =3D do_freebsd_execve(arg1, arg2, arg3); + break; + + case TARGET_FREEBSD_NR_fexecve: /* fexecve(2) */ + ret =3D do_freebsd_fexecve(arg1, arg2, arg3); + break; + case TARGET_FREEBSD_NR_exit: /* exit(2) */ ret =3D do_bsd_exit(cpu_env, arg1); break; --=20 2.41.0 From nobody Sun May 19 09:42:24 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1696376160; cv=none; d=zohomail.com; s=zohoarc; b=NK+gIg+78alVut1sMFDNIVVBqke3tdObMBYIIGGVrJ0eSNjpSaiYsUfBmg+hayybrOKwOHfBgo4fgGJa8tQ33CaqD7fGGss/tMDnGEi46YvyZ/w7Apgt4Bd3BXYPDR1NdWQX809o3wL+1ameLG56cHiKZRo0IYHUK8WZwazyYEA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696376160; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=MApO9kv1LCt8gsX2fOSXKRD/PiBDzPPW73bw9SC1hGs=; b=QDKNbvUlojquDTIpWlB78gJh9zc//kTNrtO1TpndCUas6oTBUhXTkkcd+fuUsaTmt43n5XLnK0HKzKN0AklwjSUX1hcxfBPMOrPMbS+w+jxteJEnd7/LOQnk5kowXEZxzQvOeS1em/e5u+QDNLcvG3+vv0HcKlf0ETTOc46oSCA= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1696376160744225.38861357662086; Tue, 3 Oct 2023 16:36:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qnovN-0004AV-Mx; Tue, 03 Oct 2023 19:35:33 -0400 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 1qnovL-0004A0-UB for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:31 -0400 Received: from mail-io1-xd36.google.com ([2607:f8b0:4864:20::d36]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qnovK-00078O-7W for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:31 -0400 Received: by mail-io1-xd36.google.com with SMTP id ca18e2360f4ac-79fe6da0095so60242839f.0 for ; Tue, 03 Oct 2023 16:35:28 -0700 (PDT) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id w25-20020a6b4a19000000b0079fa1a7cd36sm593596iob.30.2023.10.03.16.35.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 16:35:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1696376128; x=1696980928; 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=MApO9kv1LCt8gsX2fOSXKRD/PiBDzPPW73bw9SC1hGs=; b=NPY8/T8ENlSffc5jdN7f/Kdr8n7lBr6rx+kA3o98VSNaKC+oNC7sGkPSP/a63DUZoc 6XYUoKDImG0VsYSuUwruKT9rxiROmQd6BrmgFTpAuTCvIO0QvbV3Vf+cuwHGNGl37VXu bw7hmTKrnGqBvbFhVk6ZntRReem7d2Qm+ZzDT0nh4uu956psSpokWasIpxnVZi7MWt8I IvOJwHSec8qO7Bo2l1d0hTv4bFmI1DEyZ+PBjsBkwDMYJOp4tNyB93V2EUY0SZNzYQHa EHPKstq0m37RKTm8iky8ffcAcvMMxtljz382keIt2401fnEkKmeB72p/i1pPJ/NyBS1x +MFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696376128; x=1696980928; 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=MApO9kv1LCt8gsX2fOSXKRD/PiBDzPPW73bw9SC1hGs=; b=I8W7JXK2pzm2j3PsSypaV0W5tVbjFtzk3e8/CaNlbh0LDG93fcM4CCiFpzYlXs2Jog m63LPp7hjUYD4ZXsmS4psLiUy0XdW8N0E/CwhtuU6w3JXHe+Acobp1Wi9AvfxMlQoV9O /+Ycle6EZ3+lFYAO3tCQ9o3adGNW0QNOgo+nrpuksHFfLEO6fx2PADhdRmG4eFvex23n lZeAASjoYjdEkmKbqkYY9j5vJkkitUyNTA5lVnTv8thZtPEj6NNBZYjiOAhFKSEmpxbi 8MJ3gZSaPsKFTzWjPe7T/rmCDHp2xkXKpVAKyk25+KDlI7ANQadmSrAinoscZdkuhyB5 KkBw== X-Gm-Message-State: AOJu0YyfpgJD1kqWlgX8GXZJQlrQe8sId7HrVlV3cZDOY+yJ318bnwEn JD1JWcEJEnlFLBYBeUHHExygBupPD1VXxTg6sMDEpg== X-Google-Smtp-Source: AGHT+IHIJ6CnXCwlI+pGUidKxP3QG8+BUfiwt0sbHrTYnK9ER6aKuIGeRFogbKP8opbDfERVgNOUQg== X-Received: by 2002:a6b:5b16:0:b0:79f:d04d:ce59 with SMTP id v22-20020a6b5b16000000b0079fd04dce59mr976623ioh.6.1696376127996; Tue, 03 Oct 2023 16:35:27 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Thomas Huth , Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Wainer dos Santos Moschetta , Beraldo Leal , Warner Losh , Kyle Evans , Stacey Son , Karim Taha Subject: [PULL 23/51] bsd-user: Implement wait4(2) and wait6(2) system calls. Date: Tue, 3 Oct 2023 17:31:47 -0600 Message-ID: <20231003233215.95557-24-imp@bsdimp.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231003233215.95557-1-imp@bsdimp.com> References: <20231003233215.95557-1-imp@bsdimp.com> MIME-Version: 1.0 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: none client-ip=2607:f8b0:4864:20::d36; envelope-from=imp@bsdimp.com; helo=mail-io1-xd36.google.com 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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 @bsdimp-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1696376162936100003 Content-Type: text/plain; charset="utf-8" From: Stacey Son Signed-off-by: Stacey Son Signed-off-by: Karim Taha Reviewed-by: Warner Losh Message-Id: <20230925182425.3163-24-kariem.taha2.7@gmail.com> --- bsd-user/freebsd/os-proc.h | 84 +++++++++++++++++++++++++++++++++++ bsd-user/freebsd/os-syscall.c | 15 +++++++ 2 files changed, 99 insertions(+) diff --git a/bsd-user/freebsd/os-proc.h b/bsd-user/freebsd/os-proc.h index 75ed39f8ddd..04bce755e58 100644 --- a/bsd-user/freebsd/os-proc.h +++ b/bsd-user/freebsd/os-proc.h @@ -30,6 +30,10 @@ =20 #include "target_arch_cpu.h" =20 +pid_t safe_wait4(pid_t wpid, int *status, int options, struct rusage *rusa= ge); +pid_t safe_wait6(idtype_t idtype, id_t id, int *status, int options, + struct __wrusage *wrusage, siginfo_t *infop); + /* execve(2) */ static inline abi_long do_freebsd_execve(abi_ulong path_or_fd, abi_ulong a= rgp, abi_ulong envp) @@ -46,4 +50,84 @@ static inline abi_long do_freebsd_fexecve(abi_ulong path= _or_fd, abi_ulong argp, return freebsd_exec_common(path_or_fd, argp, envp, 1); } =20 +/* wait4(2) */ +static inline abi_long do_freebsd_wait4(abi_long arg1, abi_ulong target_st= atus, + abi_long arg3, abi_ulong target_rusage) +{ + abi_long ret; + int status; + struct rusage rusage, *rusage_ptr =3D NULL; + + if (target_rusage) { + rusage_ptr =3D &rusage; + } + ret =3D get_errno(safe_wait4(arg1, &status, arg3, rusage_ptr)); + + if (ret < 0) { + return ret; + } + if (target_status !=3D 0) { + status =3D host_to_target_waitstatus(status); + if (put_user_s32(status, target_status) !=3D 0) { + return -TARGET_EFAULT; + } + } + if (target_rusage !=3D 0) { + host_to_target_rusage(target_rusage, &rusage); + } + return ret; +} + +/* wait6(2) */ +static inline abi_long do_freebsd_wait6(void *cpu_env, abi_long idtype, + abi_long id1, abi_long id2, + abi_ulong target_status, abi_long options, abi_ulong target_wrusage, + abi_ulong target_infop, abi_ulong pad1) +{ + abi_long ret; + int status; + struct __wrusage wrusage, *wrusage_ptr =3D NULL; + siginfo_t info; + void *p; + + if (regpairs_aligned(cpu_env) !=3D 0) { + /* printf("shifting args\n"); */ + /* 64-bit id is aligned, so shift all the arguments over by one */ + id1 =3D id2; + id2 =3D target_status; + target_status =3D options; + options =3D target_wrusage; + target_wrusage =3D target_infop; + target_infop =3D pad1; + } + + if (target_wrusage) { + wrusage_ptr =3D &wrusage; + } + ret =3D get_errno(safe_wait6(idtype, target_arg64(id1, id2), + &status, options, wrusage_ptr, &info)); + + if (ret < 0) { + return ret; + } + if (target_status !=3D 0) { + status =3D host_to_target_waitstatus(status); + if (put_user_s32(status, target_status) !=3D 0) { + return -TARGET_EFAULT; + } + } + if (target_wrusage !=3D 0) { + host_to_target_wrusage(target_wrusage, &wrusage); + } + if (target_infop !=3D 0) { + p =3D lock_user(VERIFY_WRITE, target_infop, sizeof(target_siginfo_= t), 0); + if (p =3D=3D NULL) { + return -TARGET_EFAULT; + } + host_to_target_siginfo(p, &info); + unlock_user(p, target_infop, sizeof(target_siginfo_t)); + } + return ret; +} + #endif /* BSD_USER_FREEBSD_OS_PROC_H */ diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index 515eaaf31f1..55e68e48159 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -40,6 +40,12 @@ #include "os-stat.h" #include "os-proc.h" =20 +/* used in os-proc */ +safe_syscall4(pid_t, wait4, pid_t, wpid, int *, status, int, options, + struct rusage *, rusage); +safe_syscall6(pid_t, wait6, idtype_t, idtype, id_t, id, int *, status, int, + options, struct __wrusage *, wrusage, siginfo_t *, infop); + /* I/O */ safe_syscall3(int, open, const char *, path, int, flags, mode_t, mode); safe_syscall4(int, openat, int, fd, const char *, path, int, flags, mode_t, @@ -228,6 +234,15 @@ static abi_long freebsd_syscall(void *cpu_env, int num= , abi_long arg1, ret =3D do_freebsd_fexecve(arg1, arg2, arg3); break; =20 + case TARGET_FREEBSD_NR_wait4: /* wait4(2) */ + ret =3D do_freebsd_wait4(arg1, arg2, arg3, arg4); + break; + + case TARGET_FREEBSD_NR_wait6: /* wait6(2) */ + ret =3D do_freebsd_wait6(cpu_env, arg1, arg2, arg3, + arg4, arg5, arg6, arg7, arg8); + break; + case TARGET_FREEBSD_NR_exit: /* exit(2) */ ret =3D do_bsd_exit(cpu_env, arg1); break; --=20 2.41.0 From nobody Sun May 19 09:42:24 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1696376462; cv=none; d=zohomail.com; s=zohoarc; b=L/+mV8K5GNfT2eEMoptZ4qMWrc5wnlupvo9ZzjC6GnoC2WxNhTwd2J6nZ5lqv20jF8PkIZY6rxNjrZwEEuGsBhZQu/Lzop4i0wRL+FZHSjpkPfKVq3XBADu5379ICUKuxH/qioDr8kh1HEYn8b9fusMeDjhggsq2p64kxEfAkAU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696376462; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=jUbIdhN9Y3KW08Z4NFjwxOiSbSnqRae3Iwiwnvnh+H4=; b=FD/KQjei3qQ8OOH+SUb3WtWxAEh8z+5ZPNQbOsKgW8r8dpDc8q1L12myHVmiOug6IsPZSDr2sGUpaKMOOVMg7Hnsn2a2Zx6G5qMdxz7YERkXCNGM8DD6ofc9xzbsGCZXB4ipr2e0GWum5AYlrtWTEzbclntIxjZ9Zx7KUFEoKE4= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1696376462127467.98630181697865; Tue, 3 Oct 2023 16:41:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qnovQ-0004CM-VC; Tue, 03 Oct 2023 19:35:37 -0400 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 1qnovO-0004B2-7K for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:34 -0400 Received: from mail-io1-xd2f.google.com ([2607:f8b0:4864:20::d2f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qnovK-0007Cm-9F for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:32 -0400 Received: by mail-io1-xd2f.google.com with SMTP id ca18e2360f4ac-79f909071c3so60621439f.0 for ; Tue, 03 Oct 2023 16:35:29 -0700 (PDT) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id w25-20020a6b4a19000000b0079fa1a7cd36sm593596iob.30.2023.10.03.16.35.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 16:35:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1696376129; x=1696980929; 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=jUbIdhN9Y3KW08Z4NFjwxOiSbSnqRae3Iwiwnvnh+H4=; b=QfVLKGNoe2H/3DpPLXtE/ZiUs5T/FuqUhB5qs3tpl+ivpKa68iYtzVwHjvy/P9FHQC UAG/SplyIfG/p6LEfzHO/TPUk9vkGVvMrkPzEDbX5E9L3hd3JDnnSQuu3gPEohzn6oS+ tbiWsB8KvdSF+euZ3eARgZcbd2TFprp5C0TaY0IDCSs1eYINQQb6UmUpY7UiFWbPjq+H eT9UdMPuTyi1wymSeLjYSOclyYizmDlWymPqpSuo4D0ziKSamF6hgCbo5Jn6ynUXjDEb LQ6Jh3V1aNEuyxNFX05Cqk6UcM8kXLkYFl/mYSmzF3SJubyNM0VdX7x/N/Gn3gEGtSsG jKlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696376129; x=1696980929; 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=jUbIdhN9Y3KW08Z4NFjwxOiSbSnqRae3Iwiwnvnh+H4=; b=wNbGkqr0hhbT9lhtEZgBESaDEmKrYK5ctjDwOkWxlI2UX3v3Eh334P4MhbtYZ3RA/7 1dL/U/E4bQ5QSZiLDIolsIMt3MprSlfIqRmEFkibuD42yGOtLQQDzfqS7E4sk48YP9te XnpvlKtSs7OkIwxPmqFzdLcgVTKrul0pl35tA2IKuVtTj+5zjvSeaefxGArX5Ew6dyGv b3xy1HuPCwqn4ntrYQfZozpktw2dNtywYcf5ZKsH2T+vdAUdbLaDnowjFygMq3GVKHtu +5FDchMYnHfmZ0ffOzjnew79pUt0vNfR5MfE/J7LTBMUFwygqVeNfBZfVxMLpe8KxLuQ hlpQ== X-Gm-Message-State: AOJu0YwPDlr93NOwNJyOTLi8za1NLkOQ1lNYvv0aFB6B69suhoefGHNZ L8ygNsiyFOC6Ho5rm3jP62Cm+sKRFRL1JaVWp+bU/w== X-Google-Smtp-Source: AGHT+IEZUz1APCDkGc4HP7xH/e6MXjZtYED1MPQI0gtnrQy0+BEJrwGfzepntQuNF6EoMTfXtkq83w== X-Received: by 2002:a05:6602:39a:b0:790:f735:4d30 with SMTP id f26-20020a056602039a00b00790f7354d30mr946352iov.13.1696376128874; Tue, 03 Oct 2023 16:35:28 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Thomas Huth , Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Wainer dos Santos Moschetta , Beraldo Leal , Warner Losh , Kyle Evans , Stacey Son , Karim Taha Subject: [PULL 24/51] bsd-user: Implement setloginclass(2) and getloginclass(2) system calls. Date: Tue, 3 Oct 2023 17:31:48 -0600 Message-ID: <20231003233215.95557-25-imp@bsdimp.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231003233215.95557-1-imp@bsdimp.com> References: <20231003233215.95557-1-imp@bsdimp.com> MIME-Version: 1.0 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: none client-ip=2607:f8b0:4864:20::d2f; envelope-from=imp@bsdimp.com; helo=mail-io1-xd2f.google.com 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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 @bsdimp-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1696376462618100007 Content-Type: text/plain; charset="utf-8" From: Stacey Son Signed-off-by: Stacey Son Signed-off-by: Karim Taha Reviewed-by: Warner Losh Message-Id: <20230925182425.3163-25-kariem.taha2.7@gmail.com> --- bsd-user/freebsd/os-proc.h | 32 ++++++++++++++++++++++++++++++++ bsd-user/freebsd/os-syscall.c | 8 ++++++++ 2 files changed, 40 insertions(+) diff --git a/bsd-user/freebsd/os-proc.h b/bsd-user/freebsd/os-proc.h index 04bce755e58..2eaba141dcd 100644 --- a/bsd-user/freebsd/os-proc.h +++ b/bsd-user/freebsd/os-proc.h @@ -130,4 +130,36 @@ static inline abi_long do_freebsd_wait6(void *cpu_env,= abi_long idtype, return ret; } =20 +/* setloginclass(2) */ +static inline abi_long do_freebsd_setloginclass(abi_ulong arg1) +{ + abi_long ret; + void *p; + + p =3D lock_user_string(arg1); + if (p =3D=3D NULL) { + return -TARGET_EFAULT; + } + ret =3D get_errno(setloginclass(p)); + unlock_user(p, arg1, 0); + + return ret; +} + +/* getloginclass(2) */ +static inline abi_long do_freebsd_getloginclass(abi_ulong arg1, abi_ulong = arg2) +{ + abi_long ret; + void *p; + + p =3D lock_user(VERIFY_WRITE, arg1, arg2, 0); + if (p =3D=3D NULL) { + return -TARGET_EFAULT; + } + ret =3D get_errno(getloginclass(p, arg2)); + unlock_user(p, arg1, arg2); + + return ret; +} + #endif /* BSD_USER_FREEBSD_OS_PROC_H */ diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index 55e68e48159..d614409e694 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -375,6 +375,14 @@ static abi_long freebsd_syscall(void *cpu_env, int num= , abi_long arg1, ret =3D do_bsd_ktrace(arg1, arg2, arg3, arg4); break; =20 + case TARGET_FREEBSD_NR_setloginclass: /* setloginclass(2) */ + ret =3D do_freebsd_setloginclass(arg1); + break; + + case TARGET_FREEBSD_NR_getloginclass: /* getloginclass(2) */ + ret =3D do_freebsd_getloginclass(arg1, arg2); + break; + case TARGET_FREEBSD_NR_utrace: /* utrace(2) */ ret =3D do_bsd_utrace(arg1, arg2); break; --=20 2.41.0 From nobody Sun May 19 09:42:24 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1696376496; cv=none; d=zohomail.com; s=zohoarc; b=MOkk1Q4toQfj39CjLJGouJRvfRliAKMUVwlxUPQDqwW5eWJrwMCCzG/zsz7ChHR+9D7VF/DVgoSGbV07a9rzEidhaQm2KSefd3Qp2hKaeI/8nufGXSE4r8NZh+qdKoSotiFnk8FMf3JRC9IEwzdw1e7/PhahpXlE/uHZWOWPTiE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696376496; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=lXNCT8uVBORK7tv8PpGRtzJSxuc5NgZcrHLSenHKxTc=; b=ZrNoqJSqxCRxyUCUs2X3Hb8SzotO0HesE9qBDc9DFAL8BSIE+NpOZ+zRGPT/k5fcb3hKCVl+/9xAD07gtyE05vQSqEaCyyndZES2EWdD1iTMy0c1Kp02NLc8u1NGcFIb0fefjxEmLW1lqQcVoDGALVqrtFBIINzFaInAHG1IQgE= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1696376496562630.2231732427241; Tue, 3 Oct 2023 16:41:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qnovQ-0004Bl-AH; Tue, 03 Oct 2023 19:35:36 -0400 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 1qnovN-0004AL-BN for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:33 -0400 Received: from mail-io1-xd2d.google.com ([2607:f8b0:4864:20::d2d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qnovL-0007DD-0k for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:33 -0400 Received: by mail-io1-xd2d.google.com with SMTP id ca18e2360f4ac-7a2a9e5451bso58465439f.1 for ; Tue, 03 Oct 2023 16:35:30 -0700 (PDT) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id w25-20020a6b4a19000000b0079fa1a7cd36sm593596iob.30.2023.10.03.16.35.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 16:35:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1696376130; x=1696980930; 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=lXNCT8uVBORK7tv8PpGRtzJSxuc5NgZcrHLSenHKxTc=; b=WL6lpS0aIoRyLXEm7Lu0on0wHlPAc+Dm77ZvispNHchVMrwy621OqwN7XRPa0PjjlR 80YYLvECD442JHl0EcP67+DTK4kEKhC5Mrs6faYZeLFfg9Ya4iNbZmZpkCrgAwKzgdW5 RqtDPhRMU4A02UynGT3rGRkxTcnwrw+CWKHrwf+Bumh7gZPJy3s985TG2Q7sFcXAgJwY Sy6YZIRceYA5LlUqTned37gw3f5L2+iKuYTTp8HLXkJBN31Mv97IihUKZUAH2WVl9+Im 2sjreC5Gij+dpU3XHmbpf1gkcz84rjZN7xltw0iy3HI+XflKIQiSXnNi/MTbB9VoNS6e qxqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696376130; x=1696980930; 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=lXNCT8uVBORK7tv8PpGRtzJSxuc5NgZcrHLSenHKxTc=; b=Jszaua+0rwTB0XjlR14h8FWLzAxJiTZKdrjaS1J5zcRODct0XDLXGEu1vHCBqdiGVE r/gLJ1lEN0mnZpZb4B6JzHY6CUuxTzMQBYd81JMk9MtDO3gPbtaBgSdSLiPAA1cpfgvx de3oupqifNs0ZjN3hKlTwkQP5zfaqUmbJ9GsuNDaQ5k0nkuU+DVrxOLaUl3yoAmbPakF 3BzJGY45aqtYSWlphqVNWRwH71U2bsq9JkPfYsZgfiLBASkAMqQeVDiMcGsHbOgbcRck W7Cn366BMkFVTOaHc4J79O0txcMB80YtujlfqfgG7VyGERn3KcVbuUoGrhK0piK9uZJ+ 50JQ== X-Gm-Message-State: AOJu0Yx9l1q/q7tDM9Q2UEpPXPzn0bcBFTbw9LlTaesiVB6m3sFXU/1S nhdl89Bq5yh8Uhdic3sXm2Lzxt7kR3FH3t26tq8ytA== X-Google-Smtp-Source: AGHT+IGcgKaQM5/o72V5tJG92Oz0a/1MC4XmMh29lPgmGK8By8b5Z1IU1/Yp1y3uJhNHaAcX69F7tQ== X-Received: by 2002:a6b:e31a:0:b0:791:acd7:233f with SMTP id u26-20020a6be31a000000b00791acd7233fmr724023ioc.15.1696376129726; Tue, 03 Oct 2023 16:35:29 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Thomas Huth , Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Wainer dos Santos Moschetta , Beraldo Leal , Warner Losh , Kyle Evans , Stacey Son , Karim Taha , Richard Henderson Subject: [PULL 25/51] bsd-user: Implement pdgetpid(2) and the undocumented setugid. Date: Tue, 3 Oct 2023 17:31:49 -0600 Message-ID: <20231003233215.95557-26-imp@bsdimp.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231003233215.95557-1-imp@bsdimp.com> References: <20231003233215.95557-1-imp@bsdimp.com> MIME-Version: 1.0 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: none client-ip=2607:f8b0:4864:20::d2d; envelope-from=imp@bsdimp.com; helo=mail-io1-xd2d.google.com 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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 @bsdimp-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1696376497071100003 Content-Type: text/plain; charset="utf-8" From: Stacey Son Signed-off-by: Stacey Son Signed-off-by: Karim Taha Reviewed-by: Richard Henderson Reviewed-by: Warner Losh Message-Id: <20230925182425.3163-26-kariem.taha2.7@gmail.com> --- bsd-user/freebsd/os-proc.h | 23 +++++++++++++++++++++++ bsd-user/freebsd/os-syscall.c | 8 ++++++++ 2 files changed, 31 insertions(+) diff --git a/bsd-user/freebsd/os-proc.h b/bsd-user/freebsd/os-proc.h index 2eaba141dcd..42bdd61904b 100644 --- a/bsd-user/freebsd/os-proc.h +++ b/bsd-user/freebsd/os-proc.h @@ -34,6 +34,8 @@ pid_t safe_wait4(pid_t wpid, int *status, int options, st= ruct rusage *rusage); pid_t safe_wait6(idtype_t idtype, id_t id, int *status, int options, struct __wrusage *wrusage, siginfo_t *infop); =20 +extern int __setugid(int flag); + /* execve(2) */ static inline abi_long do_freebsd_execve(abi_ulong path_or_fd, abi_ulong a= rgp, abi_ulong envp) @@ -162,4 +164,25 @@ static inline abi_long do_freebsd_getloginclass(abi_ul= ong arg1, abi_ulong arg2) return ret; } =20 +/* pdgetpid(2) */ +static inline abi_long do_freebsd_pdgetpid(abi_long fd, abi_ulong target_p= idp) +{ + abi_long ret; + pid_t pid; + + ret =3D get_errno(pdgetpid(fd, &pid)); + if (!is_error(ret)) { + if (put_user_u32(pid, target_pidp)) { + return -TARGET_EFAULT; + } + } + return ret; +} + +/* undocumented __setugid */ +static inline abi_long do_freebsd___setugid(abi_long arg1) +{ + return -TARGET_ENOSYS; +} + #endif /* BSD_USER_FREEBSD_OS_PROC_H */ diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index d614409e694..99af0f6b156 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -383,6 +383,14 @@ static abi_long freebsd_syscall(void *cpu_env, int num= , abi_long arg1, ret =3D do_freebsd_getloginclass(arg1, arg2); break; =20 + case TARGET_FREEBSD_NR_pdgetpid: /* pdgetpid(2) */ + ret =3D do_freebsd_pdgetpid(arg1, arg2); + break; + + case TARGET_FREEBSD_NR___setugid: /* undocumented */ + ret =3D do_freebsd___setugid(arg1); + break; + case TARGET_FREEBSD_NR_utrace: /* utrace(2) */ ret =3D do_bsd_utrace(arg1, arg2); break; --=20 2.41.0 From nobody Sun May 19 09:42:24 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1696376400; cv=none; d=zohomail.com; s=zohoarc; b=gV4+8W+5TdCKLM4oGmX3poy2Fwch4eq9rsDKB1hXybMC82zLNi2iwS7rhWWKz9Ge0y4621M3S87DHAV27MOc77hrFFWDhq2amNdoayAzfB2lQuw7kvAdzA+bqoSlN6AcH96MrIdgMdgP1RgFWdyyD6dOjIgPYGJsyr1yfirmGvo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696376400; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=wO4tVRw6GlbIQ1GG5INdJAgQnEIiQn4ZKOXZr2a9REg=; b=Ym2L/ZpvXrrTe/P8VAvKMCwFwWhLGNldfgKKOMiQi1wKnJXEqoe2tiwAbJn21FoKTpZ3kdp4QR0yRPPsZAYW2Hv6uYfuVhCp6d1t5KShKZHDO+qf3VKujCf+ZqttLIFxPKRwwGEpbpk9S/pt78+wF1IMILG3G6SfgrZkIHtBTVc= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1696376400200653.0873320957701; Tue, 3 Oct 2023 16:40:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qnovP-0004Bo-Be; Tue, 03 Oct 2023 19:35:35 -0400 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 1qnovN-0004AU-K6 for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:33 -0400 Received: from mail-io1-xd35.google.com ([2607:f8b0:4864:20::d35]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qnovL-0007F7-Sx for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:33 -0400 Received: by mail-io1-xd35.google.com with SMTP id ca18e2360f4ac-79f915e5b47so59907139f.2 for ; Tue, 03 Oct 2023 16:35:31 -0700 (PDT) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id w25-20020a6b4a19000000b0079fa1a7cd36sm593596iob.30.2023.10.03.16.35.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 16:35:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1696376130; x=1696980930; 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=wO4tVRw6GlbIQ1GG5INdJAgQnEIiQn4ZKOXZr2a9REg=; b=SLvtC4hncjChD5ZpgsuOqTHaOFzcl1QsOEl+C+FppjndkAUmYTplzr/SIVM1wa1aL8 /HuDqwx1yg494D8m1HAtrIeBBzl1nKmpuxxh+0ZCdYYbinPiti3FpmWujMS5F+OAPZmo 9/PfjCANLqm83OlWD+b2UHJVPkJecCzsetiV/x0A8Vo18GVrAIGujyxwGBVWuBkzglNX 4o0kpHSbIEMoWnk5jFWXduFk6p1aJ8RCrORoQj9D2WhecxhhRY3tEuVHBSEOaqzKSq0N P+CCUxX4BwiVjWpEmKSUWsghfyhnbp8P9GfcvavZooXLDqmIUFfd5m99ByC9rVifP6Qx h6+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696376130; x=1696980930; 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=wO4tVRw6GlbIQ1GG5INdJAgQnEIiQn4ZKOXZr2a9REg=; b=XMsuhXT69VdNkCzJEYJFNPkTGfgizxDn7y3rnFgS0HsMS0z6vd3mI0o/HfEfNleUec ciCkv/mp2FREDXMW+WPTDXyl4knj5m3l3lwHGtmDo7354sR7mklzJvhE+buptNzwowXM Aj2FF9L+R8Q9ufZL74U73+01/uFgvWMkL6Af0T06pxX17LXP5nNgnzCrUBr8OTas4VjO nJSuItbon7oF3HqMDPNmm0MnTs3vDN39NxYFEsf4VLaD/odhLYb3BttqJGAIetNNses6 K6Mvu1vDG2nriA/dhGsQ+Ky4fnGonp6iWKQ8FFpjsfSnTpRkz44llTQ3m8miTpfdNwoL h2fQ== X-Gm-Message-State: AOJu0YyJeos6Ow0Yi2wMRyRhq16OABuCkHWm8tqb9WGw+DPMYZ5Z4tPT qz/bGrYB/Xc9qVCHL/rUPmQXiu3aMw4ANNEgliVFcQ== X-Google-Smtp-Source: AGHT+IGy6my0ZZD3fR0/wBbzmX+GSQs9ow4UL5S88V2q6PF3OzIxSy9z7nR/MitvADImGLqJT9UXkw== X-Received: by 2002:a5d:9c1a:0:b0:790:fa58:69d2 with SMTP id 26-20020a5d9c1a000000b00790fa5869d2mr958587ioe.20.1696376130604; Tue, 03 Oct 2023 16:35:30 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Thomas Huth , Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Wainer dos Santos Moschetta , Beraldo Leal , Warner Losh , Kyle Evans , Stacey Son , Karim Taha , Richard Henderson Subject: [PULL 26/51] bsd-user: Implement fork(2) and vfork(2) system calls. Date: Tue, 3 Oct 2023 17:31:50 -0600 Message-ID: <20231003233215.95557-27-imp@bsdimp.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231003233215.95557-1-imp@bsdimp.com> References: <20231003233215.95557-1-imp@bsdimp.com> MIME-Version: 1.0 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: none client-ip=2607:f8b0:4864:20::d35; envelope-from=imp@bsdimp.com; helo=mail-io1-xd35.google.com 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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 @bsdimp-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1696376401566100011 Content-Type: text/plain; charset="utf-8" From: Stacey Son Signed-off-by: Stacey Son Signed-off-by: Karim Taha Reviewed-by: Richard Henderson Reviewed-by: Warner Losh Message-Id: <20230925182425.3163-27-kariem.taha2.7@gmail.com> --- bsd-user/freebsd/os-proc.h | 34 ++++++++++++++++++++++++++++++++++ bsd-user/freebsd/os-syscall.c | 8 ++++++++ 2 files changed, 42 insertions(+) diff --git a/bsd-user/freebsd/os-proc.h b/bsd-user/freebsd/os-proc.h index 42bdd61904b..7b2e6a9f796 100644 --- a/bsd-user/freebsd/os-proc.h +++ b/bsd-user/freebsd/os-proc.h @@ -185,4 +185,38 @@ static inline abi_long do_freebsd___setugid(abi_long a= rg1) return -TARGET_ENOSYS; } =20 +/* fork(2) */ +static inline abi_long do_freebsd_fork(void *cpu_env) +{ + abi_long ret; + abi_ulong child_flag; + + fork_start(); + ret =3D fork(); + if (ret =3D=3D 0) { + /* child */ + child_flag =3D 1; + target_cpu_clone_regs(cpu_env, 0); + } else { + /* parent */ + child_flag =3D 0; + } + + /* + * The fork system call sets a child flag in the second return + * value: 0 for parent process, 1 for child process. + */ + set_second_rval(cpu_env, child_flag); + + fork_end(child_flag); + + return ret; +} + +/* vfork(2) */ +static inline abi_long do_freebsd_vfork(void *cpu_env) +{ + return do_freebsd_fork(cpu_env); +} + #endif /* BSD_USER_FREEBSD_OS_PROC_H */ diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index 99af0f6b156..cb9425c9bab 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -226,6 +226,14 @@ static abi_long freebsd_syscall(void *cpu_env, int num= , abi_long arg1, /* * process system calls */ + case TARGET_FREEBSD_NR_fork: /* fork(2) */ + ret =3D do_freebsd_fork(cpu_env); + break; + + case TARGET_FREEBSD_NR_vfork: /* vfork(2) */ + ret =3D do_freebsd_vfork(cpu_env); + break; + case TARGET_FREEBSD_NR_execve: /* execve(2) */ ret =3D do_freebsd_execve(arg1, arg2, arg3); break; --=20 2.41.0 From nobody Sun May 19 09:42:24 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1696376588; cv=none; d=zohomail.com; s=zohoarc; b=cBcteE9bw74Xp3f/czystlUVWq+2d8Cj36xFrLZuuXP9theLQsvLddYQNHhBMvF8PSr1KYGFG3y7HTD3O2AhBDX+zDlzX24Cw3G0o8/objgyuXIuQsfEVhepqtbQTtJmx+0j2KQfI6zBaGQx6OMHvgZyve6YwptMrEOQIV/05zg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696376588; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=SQQ6DsBUp3HuF6Th08+OwRbSNoljuWJ7IZ0BaPOPKuU=; b=IUH5/rhLBCn4blOw4Ze/iFfwyVOEhmdyN1QD1f8FR0i0OOByKNq1YfpcUwjTW/qScKchjmFKBfodJM53auTSbxyVquPF3abr5+AO2BC1rfmBdc9vrhhVjxcF05PdI/Wd1y3XSu4if7LRI12Emo6Gh/B1SSIQICVYd9dEb+Jula0= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 169637658827343.863400920621075; Tue, 3 Oct 2023 16:43:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qnovQ-0004CL-VX; Tue, 03 Oct 2023 19:35:37 -0400 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 1qnovO-0004B9-GK for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:34 -0400 Received: from mail-io1-xd30.google.com ([2607:f8b0:4864:20::d30]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qnovM-0007Ia-SK for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:34 -0400 Received: by mail-io1-xd30.google.com with SMTP id ca18e2360f4ac-79fd60f40ebso14549639f.1 for ; Tue, 03 Oct 2023 16:35:32 -0700 (PDT) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id w25-20020a6b4a19000000b0079fa1a7cd36sm593596iob.30.2023.10.03.16.35.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 16:35:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1696376131; x=1696980931; 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=SQQ6DsBUp3HuF6Th08+OwRbSNoljuWJ7IZ0BaPOPKuU=; b=DgMx/F4TzGh65v5iKlAazAvWIRffmccsifR9+eFmpK95Rhne8l9me1SMAptN3+KJsZ Nef9JW9Xd8gLqZhVbtYzSHiH1R8TOppuNXwM1JI0Zpa02PgQ8UgIkF1qI4SYq6cH/3lF bfyyL6/+c32aqmHzEhBOCd1MFGnC9TjoFqkDEZgSRozC+eRoG1PaUUAIBVm1rHr4xR1t 0HYALDI3WXHxMaQQEonHRhuJHlQPLZEsyA3fu4/rUP/3TwxBjRrSM95gH5Zl67GBo7+a 7tG1GPDf4WgPoA8BuyMVJelS8uYQKAXjAjnj8IUfJK/KEwqT2tkHbqSJJWGWrbOuuIEJ QPfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696376131; x=1696980931; 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=SQQ6DsBUp3HuF6Th08+OwRbSNoljuWJ7IZ0BaPOPKuU=; b=eix8awYOhUe7YKShxAnnC+BRFCcUn5XpZ6pdg7zw79EFwlIyMwcwvFI1c+Vu47MgKF ZrF6JH111EAKoQm02L6bWHqo7LzPm5TxsPEdAHCG7LbeyBCOoTYM6HsuNaIqn3pvXgti 7VTBIFKtTBGhAI26Ai+p0U6/O+aK8O9wW7M1bn7gEjO3FLzBDTymY1boy5xcYL0a8aXj rAkStXZQQ3CQ/wkAMEdFlMcOMcPXm1rUsw3AUMFFiyUCEh6qJvgW9EcCTWpxcYTDi+Jn 6XlZz/jpSS7xZu7CqBUGgnN02eq6Di7r3jwriqa8N89KYeBWQ65Fb8f6uPxtVpHGWvvv Rg3A== X-Gm-Message-State: AOJu0Yxdl4OiEja9Mblln9+30bVFR/igwOMQBbqjGa8mN8Gx+iR9g6F/ AFz06Y1ir1d/bW1jyqjkYcBKQdgLPC+LUJf7/ntgwQ== X-Google-Smtp-Source: AGHT+IHA0YZegynhPVgC+6AGqr0VQC9nz2t1IK9PjcbvwxDyW+15XF3/FcgWRvrwJUUGliAbuaz/hQ== X-Received: by 2002:a6b:7f4a:0:b0:79f:88af:500c with SMTP id m10-20020a6b7f4a000000b0079f88af500cmr543723ioq.4.1696376131531; Tue, 03 Oct 2023 16:35:31 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Thomas Huth , Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Wainer dos Santos Moschetta , Beraldo Leal , Warner Losh , Kyle Evans , Stacey Son , Karim Taha , Richard Henderson Subject: [PULL 27/51] bsd-user: Implement rfork(2) system call. Date: Tue, 3 Oct 2023 17:31:51 -0600 Message-ID: <20231003233215.95557-28-imp@bsdimp.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231003233215.95557-1-imp@bsdimp.com> References: <20231003233215.95557-1-imp@bsdimp.com> MIME-Version: 1.0 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: none client-ip=2607:f8b0:4864:20::d30; envelope-from=imp@bsdimp.com; helo=mail-io1-xd30.google.com 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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 @bsdimp-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1696376588860100001 Content-Type: text/plain; charset="utf-8" From: Stacey Son Signed-off-by: Stacey Son Signed-off-by: Karim Taha Reviewed-by: Richard Henderson Reviewed-by: Warner Losh Message-Id: <20230925182425.3163-28-kariem.taha2.7@gmail.com> --- bsd-user/freebsd/os-proc.h | 39 +++++++++++++++++++++++++++++++++++ bsd-user/freebsd/os-syscall.c | 4 ++++ 2 files changed, 43 insertions(+) diff --git a/bsd-user/freebsd/os-proc.h b/bsd-user/freebsd/os-proc.h index 7b2e6a9f796..0a3cd0ef57c 100644 --- a/bsd-user/freebsd/os-proc.h +++ b/bsd-user/freebsd/os-proc.h @@ -219,4 +219,43 @@ static inline abi_long do_freebsd_vfork(void *cpu_env) return do_freebsd_fork(cpu_env); } =20 +/* rfork(2) */ +static inline abi_long do_freebsd_rfork(void *cpu_env, abi_long flags) +{ + abi_long ret; + abi_ulong child_flag; + + /* + * XXX We need to handle RFMEM here, as well. Neither are safe to exe= cute + * as-is on x86 hosts because they'll split memory but not the stack, + * wreaking havoc on host architectures that use the stack to store the + * return address as both threads try to pop it off. Rejecting RFSPAWN + * entirely for now is ok, the only consumer at the moment is posix_sp= awn + * and it will fall back to classic vfork(2) if we return EINVAL. + */ + if ((flags & TARGET_RFSPAWN) !=3D 0) { + return -TARGET_EINVAL; + } + fork_start(); + ret =3D rfork(flags); + if (ret =3D=3D 0) { + /* child */ + child_flag =3D 1; + target_cpu_clone_regs(cpu_env, 0); + } else { + /* parent */ + child_flag =3D 0; + } + + /* + * The fork system call sets a child flag in the second return + * value: 0 for parent process, 1 for child process. + */ + set_second_rval(cpu_env, child_flag); + fork_end(child_flag); + + return ret; + +} + #endif /* BSD_USER_FREEBSD_OS_PROC_H */ diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index cb9425c9bab..4c4e773d1d3 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -234,6 +234,10 @@ static abi_long freebsd_syscall(void *cpu_env, int num= , abi_long arg1, ret =3D do_freebsd_vfork(cpu_env); break; =20 + case TARGET_FREEBSD_NR_rfork: /* rfork(2) */ + ret =3D do_freebsd_rfork(cpu_env, arg1); + break; + case TARGET_FREEBSD_NR_execve: /* execve(2) */ ret =3D do_freebsd_execve(arg1, arg2, arg3); break; --=20 2.41.0 From nobody Sun May 19 09:42:24 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1696376421; cv=none; d=zohomail.com; s=zohoarc; b=e47cwoix652hSMDKQ3T3dyoPTqRAHATwB38rdpUVEz9cLTIsJvMfSYb320sEI3dyc7j5hkCClkTCtT1I5uSDoTZEEfH4820A9bLSCDOfFbu62spOjtdP4AGT23FdtsBwWdqko7fJ0SHk3+UzB1zy2RgQYVwiTB6DV1sHpelkwT4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696376421; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=DTFZRe9LfB18mFM3p+ZpT+MrPqZPyJHc23fZZDwLdFE=; b=lWaT/39xLx2SWHwbHOt7sTOt4K7qGkMk3P0VFDcefWWvAxJAeiKvfDT+5V7Q64gCciyPY3s7C8KgVJcD9E1nqjCl0B7Ea6j+tANMrXT4T0a8JXQCcgIbpw9SiiUP0cUh4QajYLMo6HFz2YlTmMznHbhTfwVyvt8fQlT3tq+XTCM= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1696376421938921.560662279316; Tue, 3 Oct 2023 16:40:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qnovU-0004Da-8F; Tue, 03 Oct 2023 19:35:40 -0400 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 1qnovQ-0004CE-JY for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:36 -0400 Received: from mail-il1-x12b.google.com ([2607:f8b0:4864:20::12b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qnovO-0007LN-W0 for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:36 -0400 Received: by mail-il1-x12b.google.com with SMTP id e9e14a558f8ab-352a22e1471so3963935ab.0 for ; Tue, 03 Oct 2023 16:35:34 -0700 (PDT) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id w25-20020a6b4a19000000b0079fa1a7cd36sm593596iob.30.2023.10.03.16.35.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 16:35:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1696376132; x=1696980932; 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=DTFZRe9LfB18mFM3p+ZpT+MrPqZPyJHc23fZZDwLdFE=; b=D9T2BYTxt++7e/53rwE4X5T4bRkeX2DG+cYF8aMVKm0l57r5c97iBFo62ohLy5aWIP S3+BtSlh1fl3ue7bybbwHFjRnkxTNJeEQaM2NPPswvtOB8n27BkO6ltDjCKkkeT44XtD yYZerYQzNp2gS69oX0Zod88G5V4UFMjnrigKdkjN21VOHCtUoNwJ7DorfjvfWEh6tVSv rr+Pp9LP2+SNEK3FqsV47945HqURnMDvA9DNuThDG6jsRl9nvoS8kd7B0mPPl07oCzh5 WCSfAuTCnQRgYAQnJKqw83yrTdPwEwWlXHKcemLX1ZB3zFu8C2xVWm+h10S+kggjS9tf Qm3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696376132; x=1696980932; 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=DTFZRe9LfB18mFM3p+ZpT+MrPqZPyJHc23fZZDwLdFE=; b=ORUx0Yyl7iILL2cpYWuSoYnWlGm2Er6j3GI959rgmxbHVRNaWX5HDPi/Oj2UHQdqJ8 hg7tN58hLI92MxuEMoFXiojp1nR+Yrwy+sfbDVe5ADuwUPq42bplNUzq8Qy/JSBVQu61 OVlJJAd+rkP3ZxO+y1emLvAefKRs4N/0VsEhiDZNmS4BMBGItu42OAbI0nCkOsUX5lAW COpTD4TTEkK7kOqV1TCXQylILfuUsDZb1x4axKQ1S5HoGY/bnx8dxVoZZGe41k0obhKc ZcmsvrF+9OGL/9ZiKX3hbbCPeLsxaobKfsHsW4vY/iCCKcOgYU8HxMkMJ94PrWXJHA5L +XtA== X-Gm-Message-State: AOJu0YyFxrvGvzzITj6/XG+FPZ3uroGDg7aBe3V+hpsKOs8Hp4Q1aLXC QutQUBhgNCWAzC5DFh4VrqwG2Pg4vvYDKSA7eFvxPA== X-Google-Smtp-Source: AGHT+IGvTmrSLkZuJjT+BfaWx+ag3NAfOIblLqYg1kSir8JnTT+It79ypmJyGEaw4Is9GC25EJlUtA== X-Received: by 2002:a05:6602:3351:b0:795:16b8:8601 with SMTP id c17-20020a056602335100b0079516b88601mr911418ioz.0.1696376132452; Tue, 03 Oct 2023 16:35:32 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Thomas Huth , Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Wainer dos Santos Moschetta , Beraldo Leal , Warner Losh , Kyle Evans , Stacey Son , Karim Taha , Richard Henderson Subject: [PULL 28/51] bsd-user: Implement pdfork(2) system call. Date: Tue, 3 Oct 2023 17:31:52 -0600 Message-ID: <20231003233215.95557-29-imp@bsdimp.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231003233215.95557-1-imp@bsdimp.com> References: <20231003233215.95557-1-imp@bsdimp.com> MIME-Version: 1.0 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: none client-ip=2607:f8b0:4864:20::12b; envelope-from=imp@bsdimp.com; helo=mail-il1-x12b.google.com 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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 @bsdimp-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1696376422977100001 Content-Type: text/plain; charset="utf-8" From: Stacey Son Signed-off-by: Stacey Son Signed-off-by: Karim Taha Acked-by: Richard Henderson Reviewed-by: Warner Losh Message-Id: <20230925182425.3163-29-kariem.taha2.7@gmail.com> --- bsd-user/freebsd/os-proc.h | 32 ++++++++++++++++++++++++++++++++ bsd-user/freebsd/os-syscall.c | 4 ++++ 2 files changed, 36 insertions(+) diff --git a/bsd-user/freebsd/os-proc.h b/bsd-user/freebsd/os-proc.h index 0a3cd0ef57c..d6418780344 100644 --- a/bsd-user/freebsd/os-proc.h +++ b/bsd-user/freebsd/os-proc.h @@ -258,4 +258,36 @@ static inline abi_long do_freebsd_rfork(void *cpu_env,= abi_long flags) =20 } =20 +/* pdfork(2) */ +static inline abi_long do_freebsd_pdfork(void *cpu_env, abi_ulong target_f= dp, + abi_long flags) +{ + abi_long ret; + abi_ulong child_flag; + int fd; + + fork_start(); + ret =3D pdfork(&fd, flags); + if (ret =3D=3D 0) { + /* child */ + child_flag =3D 1; + target_cpu_clone_regs(cpu_env, 0); + } else { + /* parent */ + child_flag =3D 0; + if (put_user_s32(fd, target_fdp)) { + return -TARGET_EFAULT; + } + } + + /* + * The fork system call sets a child flag in the second return + * value: 0 for parent process, 1 for child process. + */ + set_second_rval(cpu_env, child_flag); + fork_end(child_flag); + + return ret; +} + #endif /* BSD_USER_FREEBSD_OS_PROC_H */ diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index 4c4e773d1d3..d04712f0a7e 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -238,6 +238,10 @@ static abi_long freebsd_syscall(void *cpu_env, int num= , abi_long arg1, ret =3D do_freebsd_rfork(cpu_env, arg1); break; =20 + case TARGET_FREEBSD_NR_pdfork: /* pdfork(2) */ + ret =3D do_freebsd_pdfork(cpu_env, arg1, arg2); + break; + case TARGET_FREEBSD_NR_execve: /* execve(2) */ ret =3D do_freebsd_execve(arg1, arg2, arg3); break; --=20 2.41.0 From nobody Sun May 19 09:42:24 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1696376217; cv=none; d=zohomail.com; s=zohoarc; b=ayQ1PRrRjpfo5Cl58MJAo23PAKzOtq3OrC3Gn5Xypf73s96ecf+rClSTYzivoAG0kNKOhOy7EkbdAP6P8d38Rl74357nzi5YZoRu7WphmhCVhdVHgJ7BFIaSMQpI3MSZuhJBRXRCs/MnuIRCRRqlA2/rW76gDDNMCkrhu/0jceI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696376217; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=azy/SYSaQ16IVZQzbRRCdYoe/s4kbJ733g8Itr242Ak=; b=a9lqacWD3BSW6TJnMDy7vttviSf59zh9bgfcdN7KOj87NrEdAC/TykAoyqqwDYMbw/Q1LqYSrePAZRNXOoc2vqDCnIruNCmVzhLvmSbq00sqAEV6/mhdH15Sv4WE8ZtjyMbLtLOZdYYDRoZANcXTKeOWYb23tFSfdusBx+fFB4s= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1696376217056848.4481261612513; Tue, 3 Oct 2023 16:36:57 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qnovS-0004DO-Mm; Tue, 03 Oct 2023 19:35:38 -0400 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 1qnovQ-0004C4-3C for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:36 -0400 Received: from mail-io1-xd31.google.com ([2607:f8b0:4864:20::d31]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qnovO-0007Mx-LY for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:35 -0400 Received: by mail-io1-xd31.google.com with SMTP id ca18e2360f4ac-79fce245bf6so58303839f.1 for ; Tue, 03 Oct 2023 16:35:34 -0700 (PDT) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id w25-20020a6b4a19000000b0079fa1a7cd36sm593596iob.30.2023.10.03.16.35.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 16:35:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1696376133; x=1696980933; 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=azy/SYSaQ16IVZQzbRRCdYoe/s4kbJ733g8Itr242Ak=; b=LrNVoSpGcix51dVDz75z8iuPx0I5MCAMFl8zc5a5ZJEdyzZr3LBP7lhBBuqF4FvmHu hVipKubW8Pktj47+MZLWdiHCPmd6linurKJy3JiR24YG2zeA7qLRyDDu84wCc5ivNYNx 2mhYXQykeaBfWZXapoSkMJMq7ka2TUDqhIMj1qEEm/1F8CpUuvP2XCz7eOi7zKAM1bkD uqAwiiwNRcdNKeMMegwEAKpIFOYR07HPJKuT5RS1bkRQQLl9Lff9OjcT9j1os1JDVwHI no/1UK/jUbD5TrBpf/SRME9WTN8X5Vi69jIi9GEZK/BUhdSFVIFljO0w8uZfxlBj1hgZ 6bBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696376133; x=1696980933; 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=azy/SYSaQ16IVZQzbRRCdYoe/s4kbJ733g8Itr242Ak=; b=Qfp8oYnoDq6CUD/yAxkUKkgldy0j+fY6PtxuFrjDMH3wpHhzX8LRe7+v+mUEzSw2pJ 4SxZqs6CcT+sZU/znsvc8JblUiIl258QcbiQKbLvkt+VAHm+1J5objtRijKHIsVVu7sm WgbXTJqxrqSrivFrVkCGMbPEajFp+kRlhF/WlhY4BsGDCZNDxzPHh9Tlca+tNUua5Yds Z7F5p0Zj2pTNo96hlTpR/wCaCLux15S0XyeYpEccPrmh0ucqMrAiKDPX3lOi4NoedHWB 4QHrtQlrOLEdNMEX7pRnGpw1jDi9m4ZEksRwT1EzTys2Kt/aJ47+u/l11tQ1c1sITL4j BuYg== X-Gm-Message-State: AOJu0YwQot5AtZ6bgzLWTZ3bYAPPMf9ARppju5h2B/bFw9FIt5oGZ8wf 8E6feYtQ+vKXDZkcueEM6oeA4TACxWbB4X8qS56Pyw== X-Google-Smtp-Source: AGHT+IH/lqG4uzzUMfFhHWMdPvFEcvbvSkBfz2WcmuPUt56nPuR7jWtoxxbGaXNodf2lxoMTiNdh4A== X-Received: by 2002:a5e:dd0d:0:b0:786:7100:72de with SMTP id t13-20020a5edd0d000000b00786710072demr895226iop.16.1696376133350; Tue, 03 Oct 2023 16:35:33 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Thomas Huth , Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Wainer dos Santos Moschetta , Beraldo Leal , Warner Losh , Kyle Evans , Stacey Son , Karim Taha , Richard Henderson Subject: [PULL 29/51] bsd-user: Implement struct target_ipc_perm Date: Tue, 3 Oct 2023 17:31:53 -0600 Message-ID: <20231003233215.95557-30-imp@bsdimp.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231003233215.95557-1-imp@bsdimp.com> References: <20231003233215.95557-1-imp@bsdimp.com> MIME-Version: 1.0 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: none client-ip=2607:f8b0:4864:20::d31; envelope-from=imp@bsdimp.com; helo=mail-io1-xd31.google.com 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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 @bsdimp-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1696376217535100001 Content-Type: text/plain; charset="utf-8" From: Stacey Son Signed-off-by: Stacey Son Signed-off-by: Karim Taha Reviewed-by: Richard Henderson Reviewed-by: Warner Losh Message-Id: <20230925182709.4834-2-kariem.taha2.7@gmail.com> --- bsd-user/syscall_defs.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/bsd-user/syscall_defs.h b/bsd-user/syscall_defs.h index a3bc738ff89..0e54d7df690 100644 --- a/bsd-user/syscall_defs.h +++ b/bsd-user/syscall_defs.h @@ -55,6 +55,23 @@ struct target_iovec { abi_long iov_len; /* Number of bytes */ }; =20 +/* + * sys/ipc.h + */ +struct target_ipc_perm { + uint32_t cuid; /* creator user id */ + uint32_t cgid; /* creator group id */ + uint32_t uid; /* user id */ + uint32_t gid; /* group id */ + uint16_t mode; /* r/w permission */ + uint16_t seq; /* sequence # */ + abi_long key; /* user specified msg/sem/shm key */ +}; + +#define TARGET_IPC_RMID 0 /* remove identifier */ +#define TARGET_IPC_SET 1 /* set options */ +#define TARGET_IPC_STAT 2 /* get options */ + /* * sys/mman.h */ --=20 2.41.0 From nobody Sun May 19 09:42:24 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1696376595; cv=none; d=zohomail.com; s=zohoarc; b=Z4X0+m6s/IjCw1lm+CiVtohyZDyD4jUZGKy+xL35vNp9NgzCjs0pGMxG3YGMoHJuUwtFFN45lf0qRLKWQVFT274H54ZXE8yj4ncl5SIiVDygRnByFWtJNXOrs2wvcEhXkFjTZ5y536bBwBitRlLusKsgp+MwdRU4ho1/OgjQoxs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696376595; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ye1cEufpabX0kbmM/Z2tKJUqMwLD3um1kdO4giPewb0=; b=Z8DU9pYpaWz7dUxRD/rRW1YhtSXchEtR2mOlSnO0v2JMeTyBfKq1Q/VvKzSu5ZSPpXTDjB0cT67/v/CCuMbL2sNzmlNdtJ3pz0NxGWWZID7Z0W4THFamY1ASG7C5it0vvCjcLxT2cXSZqZf3ms/aqPukOhJ9bWYxwq79PcCjbZE= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1696376595928734.5140394965658; Tue, 3 Oct 2023 16:43:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qnovU-0004DX-7G; Tue, 03 Oct 2023 19:35:40 -0400 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 1qnovR-0004Cn-BN for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:37 -0400 Received: from mail-io1-xd35.google.com ([2607:f8b0:4864:20::d35]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qnovP-0007PC-JH for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:37 -0400 Received: by mail-io1-xd35.google.com with SMTP id ca18e2360f4ac-79fa5d9f3a2so57655039f.3 for ; Tue, 03 Oct 2023 16:35:35 -0700 (PDT) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id w25-20020a6b4a19000000b0079fa1a7cd36sm593596iob.30.2023.10.03.16.35.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 16:35:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1696376134; x=1696980934; 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=ye1cEufpabX0kbmM/Z2tKJUqMwLD3um1kdO4giPewb0=; b=ztUoqKUqGlkrLPx8k+O3vpI4RgaqSp3OpwQgqRPMM0kxakIdX6H1zZKtpXUiRcv0wU yeoc2EhyoozLQOZ4BTeX/edfUWcefAaXp1/uPJcll09Us4kIbPmVz1u88nzAjcyId6qM mKVw49yXyT6qxYcHrZAO9jquBadYw1I0zn/Vy7crFWTOo96vh04wS0V/n7a/VfJx6RqH TEzU4qlzSICU5rwlJO4Qp/J5sa+Is5SfrrjKRZGe6uD1K2q+AoHKEQQf1iyYTXatGd2j lI91+pvw5fgVJO8ykf/xsVKbYFgEQq9KBhaIKWn+6tTlBfQjezq28HMl3mVyNZLGvG4R CBgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696376134; x=1696980934; 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=ye1cEufpabX0kbmM/Z2tKJUqMwLD3um1kdO4giPewb0=; b=iw/m1XzHVDD4R60r1e8fJnkEx3Pvgf5OABZ13siLdP2jV3TORthfwpOXYi3CmRK4hs ftrjR/9QP9hY6/d4jHPVmSBfx0+KQgKtBjNzX/M5vJmhtt5Y4zw3CVui+OXqaZGf190n MnSDPYoFCGrjaGdCbIQI2nSPOIRHi94DBY66KmGTm3ZJJORsLIyEkDeFhfTAU3hZBz+8 oZxyHlqYHz2z2p1LQiOA8SBSBQh3NS550/MJGi05BD/DuDd1htwp6t2p9iB2LYZ200vE jTgJ05YVdTby44jBSmLp1Xjy9Dc9gd+swP+bzObaljBLCktB1e/iweV56X76ZT9gjYEP F+LA== X-Gm-Message-State: AOJu0Yycl6fzOA5/x0XSf984xF5vy8G8sZc4dfcd8dEKPrWz7CzaCQ4B sM15iXDOBtnq5DRtdF7NF5j6QrHnv/+S+ZFdCI/WYw== X-Google-Smtp-Source: AGHT+IGeB6hdWA8FRXupStEbwSYbK7kOP4iMD8WJtFXxXJ6IGSRlpS8jwXaOXi+4eERcrvvF/X5RUQ== X-Received: by 2002:a6b:e31a:0:b0:791:acd7:233f with SMTP id u26-20020a6be31a000000b00791acd7233fmr724119ioc.15.1696376134255; Tue, 03 Oct 2023 16:35:34 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Thomas Huth , Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Wainer dos Santos Moschetta , Beraldo Leal , Warner Losh , Kyle Evans , Stacey Son , Karim Taha , Richard Henderson Subject: [PULL 30/51] bsd-user: Implement struct target_shmid_ds Date: Tue, 3 Oct 2023 17:31:54 -0600 Message-ID: <20231003233215.95557-31-imp@bsdimp.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231003233215.95557-1-imp@bsdimp.com> References: <20231003233215.95557-1-imp@bsdimp.com> MIME-Version: 1.0 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: none client-ip=2607:f8b0:4864:20::d35; envelope-from=imp@bsdimp.com; helo=mail-io1-xd35.google.com 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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 @bsdimp-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1696376597096100005 Content-Type: text/plain; charset="utf-8" From: Stacey Son Signed-off-by: Stacey Son Signed-off-by: Karim Taha Reviewed-by: Richard Henderson Reviewed-by: Warner Losh Message-Id: <20230925182709.4834-3-kariem.taha2.7@gmail.com> --- bsd-user/syscall_defs.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/bsd-user/syscall_defs.h b/bsd-user/syscall_defs.h index 0e54d7df690..ff692814333 100644 --- a/bsd-user/syscall_defs.h +++ b/bsd-user/syscall_defs.h @@ -72,6 +72,26 @@ struct target_ipc_perm { #define TARGET_IPC_SET 1 /* set options */ #define TARGET_IPC_STAT 2 /* get options */ =20 +/* + * sys/shm.h + */ +struct target_shmid_ds { + struct target_ipc_perm shm_perm; /* peration permission structure */ + abi_ulong shm_segsz; /* size of segment in bytes */ + int32_t shm_lpid; /* process ID of last shared memory op */ + int32_t shm_cpid; /* process ID of creator */ + int32_t shm_nattch; /* number of current attaches */ + target_time_t shm_atime; /* time of last shmat() */ + target_time_t shm_dtime; /* time of last shmdt() */ + target_time_t shm_ctime; /* time of last change by shmctl() */ +}; + +#define N_BSD_SHM_REGIONS 32 +struct bsd_shm_regions { + abi_long start; + abi_long size; +}; + /* * sys/mman.h */ --=20 2.41.0 From nobody Sun May 19 09:42:24 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1696376675; cv=none; d=zohomail.com; s=zohoarc; b=cyCprnG4XiMhtbqPmr5C5I9q/9P8t/owBt7VBwS1RNHdXDa0/jicxDAVvuOYTTw3oZqf1AIL1DW75Rk5NtOf3/oBGYB4Ue49kz3KgmF2/BJbiEFcCWMKA4GqvH+uRweXwuTCyybBKHoAq+nIaLvvwYYZQAHwCLChiIb9H0v6ZyQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696376675; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=xbdd7u9NeVPCkT9yPQuY1ndY3BOt1BhLoy0Idqk3wZ0=; b=V4Cm9xS3RUPxgTYsOyq3LAbvsOj161xtXCrW1hDIWg3BbxGsD81ikKSsouqRACb89GSu/rS5TKj9TSA9gcqyXtvdw5nK70fLKvGICRhRE+PL607v3yNBw4neCBugXfBnfWZPrxNYc48Ekpvz8HMvG3ZHS/Ar9ylA8j2kXgb+C2U= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1696376675002376.42979532594507; Tue, 3 Oct 2023 16:44:35 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qnovT-0004DU-So; Tue, 03 Oct 2023 19:35:39 -0400 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 1qnovS-0004DF-26 for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:38 -0400 Received: from mail-io1-xd36.google.com ([2607:f8b0:4864:20::d36]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qnovQ-0007PN-H8 for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:37 -0400 Received: by mail-io1-xd36.google.com with SMTP id ca18e2360f4ac-79fa5d9f3a2so57655539f.3 for ; Tue, 03 Oct 2023 16:35:36 -0700 (PDT) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id w25-20020a6b4a19000000b0079fa1a7cd36sm593596iob.30.2023.10.03.16.35.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 16:35:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1696376135; x=1696980935; 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=xbdd7u9NeVPCkT9yPQuY1ndY3BOt1BhLoy0Idqk3wZ0=; b=XFpoU95FBMaxl5vVpYbRYXCjGj+oiluW3ouUBElxZgNoIjv/42OoMtB4H/1ilc9C2B mGEAF6IypEUdmz57dSzsQtNavT9L7LlKC5iwcCwZCcA8dKivYcz/hzk2a8FZhnUPp/+o XfDGKmoyWisHxxfZN/fy3GupDAgCVNYHIrhRSjYENiJAhf5AlzU9pIB1kwogKiksmK5f H18TAf7li5V0EsnFGuwScE1bml47jLtXckNPs6eTdbhLd5J+lQctoKFDt6E95+nSxX5W VgPUezbODL15nFShLapgH2zklptzNoRyKRp8SkSNmzMXFQIZ7X2oK1U+yE+H79fsg/m/ inBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696376135; x=1696980935; 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=xbdd7u9NeVPCkT9yPQuY1ndY3BOt1BhLoy0Idqk3wZ0=; b=YwQhzb3D0j/3Om34WefJP0ox85Fdi3jM4ToWRHXFi+OX0JNZED9GVNlj85covO25Po C/qs5TNcvSrmnb6353GhWiDXIIHsK7s935n5NxI7UpneU/s7mWN8x7hV0D9M0M5Bs/XY EIqGGf+MhAfCbGOXE4c6mHjQWOCEEV7L7+AN8ynu3gIsO3tjQXROKMd7h3zmwlH9vFyF UDTOSon1wODPgfqWbMUexo7CIWixlkX5T1/FTGh424o6XZDlgIXPm9+Y3+M1WSo2fcMJ 9TYIXkzc8k5F0cOzPvKM/mT1V8HMijuVU2oqT7nLZgnMOGHPSS1RgfSeCO3MADh2Ivid K6Pw== X-Gm-Message-State: AOJu0YxnRwqd/j7HCqMueGQOdf+HM9s/rMlp8KwhvhaXflBuMxpijQ4F BCXhEpouLJrwQ0f/GSa/HuyyttRsRCu1Twh9QA368w== X-Google-Smtp-Source: AGHT+IFmSOg8VqZyhZRuh2gBPHeO8RkxjzjDX47q1Jnw4RUwOmgkh5K+xip80MGigalbqPujIAu7tA== X-Received: by 2002:a05:6602:228a:b0:79f:a25b:51c with SMTP id d10-20020a056602228a00b0079fa25b051cmr969481iod.11.1696376135171; Tue, 03 Oct 2023 16:35:35 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Thomas Huth , Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Wainer dos Santos Moschetta , Beraldo Leal , Warner Losh , Kyle Evans , Stacey Son , Karim Taha , Richard Henderson Subject: [PULL 31/51] bsd-user: Declarations for ipc_perm and shmid_ds conversion functions Date: Tue, 3 Oct 2023 17:31:55 -0600 Message-ID: <20231003233215.95557-32-imp@bsdimp.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231003233215.95557-1-imp@bsdimp.com> References: <20231003233215.95557-1-imp@bsdimp.com> MIME-Version: 1.0 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: none client-ip=2607:f8b0:4864:20::d36; envelope-from=imp@bsdimp.com; helo=mail-io1-xd36.google.com 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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 @bsdimp-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1696376676152100001 Content-Type: text/plain; charset="utf-8" From: Stacey Son Signed-off-by: Stacey Son Signed-off-by: Karim Taha Reviewed-by: Richard Henderson Reviewed-by: Warner Losh Message-Id: <20230925182709.4834-4-kariem.taha2.7@gmail.com> --- bsd-user/qemu-bsd.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/bsd-user/qemu-bsd.h b/bsd-user/qemu-bsd.h index b93a0b7fd5b..ffc64bb244a 100644 --- a/bsd-user/qemu-bsd.h +++ b/bsd-user/qemu-bsd.h @@ -22,6 +22,16 @@ =20 #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include =20 /* bsd-proc.c */ int target_to_host_resource(int code); @@ -35,4 +45,14 @@ int host_to_target_waitstatus(int status); void h2g_rusage(const struct rusage *rusage, struct target_freebsd_rusage *target_rusage); =20 +/* bsd-mem.c */ +void target_to_host_ipc_perm__locked(struct ipc_perm *host_ip, + struct target_ipc_perm *target_ip); +void host_to_target_ipc_perm__locked(struct target_ipc_perm *target_ip, + struct ipc_perm *host_ip); +abi_long target_to_host_shmid_ds(struct shmid_ds *host_sd, + abi_ulong target_addr); +abi_long host_to_target_shmid_ds(abi_ulong target_addr, + struct shmid_ds *host_sd); + #endif /* QEMU_BSD_H */ --=20 2.41.0 From nobody Sun May 19 09:42:24 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1696376467; cv=none; d=zohomail.com; s=zohoarc; b=Q9boEsijw/8JEEr7pgAstZa0hTY3DRPG8GrYUBgskFQUXmUhJJCo7YkShSX5DzzaTSFTbvcfvxmPC+GjP/ny/LlaPE5sOMXk+4QEqLjt8G3DoxHG9PO+njsmZx/XBzYPNzf0Dn5T94yYHj64gQPX4wXG3dGoTWoxx9S91QQhP8w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696376467; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Ci9IVvBHiMF+Kz9t9dpXV7nFDmS/9Z/PKiZ4KFlDEC8=; b=BvEjErPhj64RbTWGt7VWjqLKY8mlIZQ6wbAcLI+SNzdTEwcWzcJhnLWhQsCT4y3pZR4b6Z2FY2BB3a0+zbW+dP2CWI5bxKw/RG32efeV7X7DvpQ+BiLpstcFofw3yJLE9OCvD9am0DqD6kwfq5TX14wMoOAy32aBsXNzi/8dYa8= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16963764671901000.0874416957347; Tue, 3 Oct 2023 16:41:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qnovn-0004QQ-4K; Tue, 03 Oct 2023 19:35:59 -0400 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 1qnovl-0004MH-L7 for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:57 -0400 Received: from mail-io1-xd41.google.com ([2607:f8b0:4864:20::d41]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qnovR-0007Pn-Ch for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:52 -0400 Received: by mail-io1-xd41.google.com with SMTP id ca18e2360f4ac-79fc3d32a2fso60170339f.1 for ; Tue, 03 Oct 2023 16:35:37 -0700 (PDT) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id w25-20020a6b4a19000000b0079fa1a7cd36sm593596iob.30.2023.10.03.16.35.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 16:35:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1696376136; x=1696980936; 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=Ci9IVvBHiMF+Kz9t9dpXV7nFDmS/9Z/PKiZ4KFlDEC8=; b=EL0z/VGJ1wHeuZlsfVMFhXIzvdVMP1l18o0b55Y7ZZ445PL1B4FiP1/fpmwachEoGo mSG+REXbAAHQ8eq5iA94C1FtOUd4OX6CisuDUg+qX5qh5JPfZxyamGhdn98YibaJNtU7 csu12xXn1q19ltSIV5AqEUIORvrYSunYEcXeJMbZwnujBB06PKm4oKG7bq47WD/gk2II cCCPgCm2Bp8CGvFrEkRR07YYRG3WT7xRI8RCnV7/5o4i7ZFUIB0dw2+nIul9b2ea7Nw+ Fak8BOdULgBZfBF7qGn4CpayC+eve4KI1VCK8t4OGrbtt7i4jgOBFnFmxqSarisUZMo3 OMaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696376136; x=1696980936; 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=Ci9IVvBHiMF+Kz9t9dpXV7nFDmS/9Z/PKiZ4KFlDEC8=; b=Q23oZCa0zKxarUdkz4g0dvzfVfeRkcaHwWPqVYnrT6vj0cNa6Y19gZC7lkhiHDzA2o 2ljR/syH9GS2SO9Y5uYSxDOCjSgsTm4SWVrvrqgYnHiCbsD5iVXuouWY/XJnlWUDc06e Hp2HIDg+9z/avG41y5VP+Hk57NtgAOvZA+6ONFgpJZWyQ3r9oJWEpFtpptBO8E+6iZ8w W1Mqkh4TpS7h+6+aJ1IZ65pBhxW1x+r2uEVDTR2Px7F4cMVoaI7Mc7xEqU19lxmhRsuR ZdTEviImISMAA9kFBgjtTcP+pBlb7UpoUQ2nD+Ql2skbiRhYQHaHwQJzpyRL1oW/LiOA HtDw== X-Gm-Message-State: AOJu0Yx/+BaH6g5pVO7Xd6oDKs38SAJ8CuVxMExAlrZUPcySVmxYh9Yw CmF1wJcKb6Wd8Zk34ldPfMJzmpgSSCTN0/iGaXSERkbK X-Google-Smtp-Source: AGHT+IFCPkyodsoP7KEVRj3inRcDTDEVAL3WglJsXJD2pdw/bMGLW1eYlKvqHT2PEG0kB+snbPQgiw== X-Received: by 2002:a6b:7841:0:b0:79f:e99b:474a with SMTP id h1-20020a6b7841000000b0079fe99b474amr865190iop.18.1696376136111; Tue, 03 Oct 2023 16:35:36 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Thomas Huth , Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Wainer dos Santos Moschetta , Beraldo Leal , Warner Losh , Kyle Evans , Stacey Son , Karim Taha , Richard Henderson Subject: [PULL 32/51] bsd-user: Introduce freebsd/os-misc.h to the source tree Date: Tue, 3 Oct 2023 17:31:56 -0600 Message-ID: <20231003233215.95557-33-imp@bsdimp.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231003233215.95557-1-imp@bsdimp.com> References: <20231003233215.95557-1-imp@bsdimp.com> MIME-Version: 1.0 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: none client-ip=2607:f8b0:4864:20::d41; envelope-from=imp@bsdimp.com; helo=mail-io1-xd41.google.com 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, SPF_NONE=0.001, T_SPF_HELO_TEMPERROR=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @bsdimp-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1696376468650100001 Content-Type: text/plain; charset="utf-8" From: Stacey Son To preserve the copyright notice and help with the 'Author' info for subsequent changes to the file. Signed-off-by: Stacey Son Signed-off-by: Karim Taha Reviewed-by: Richard Henderson Reviewed-by: Warner Losh Message-Id: <20230925182709.4834-5-kariem.taha2.7@gmail.com> --- bsd-user/freebsd/os-misc.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 bsd-user/freebsd/os-misc.h diff --git a/bsd-user/freebsd/os-misc.h b/bsd-user/freebsd/os-misc.h new file mode 100644 index 00000000000..8436ccb2f7d --- /dev/null +++ b/bsd-user/freebsd/os-misc.h @@ -0,0 +1,28 @@ +/* + * miscellaneous FreeBSD system call shims + * + * Copyright (c) 2013-14 Stacey D. Son + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + */ + +#ifndef OS_MISC_H +#define OS_MISC_H + +#include +#include +#include + + +#endif /* OS_MISC_H */ --=20 2.41.0 From nobody Sun May 19 09:42:24 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1696376595; cv=none; d=zohomail.com; s=zohoarc; b=KOrtMntkWKHk4MeGy3N+au8TfRSgtl8aK26rxeqgjMe460JC7l9I1rdnQBNIvL+8lj77rqLEb5k/ZFWxCgvdYIw+sHN08N2wyNqw/nccxqqak7B2rhS6dJqX7PvjBp76MnYJffL545QRJPyd/qx0XM363kzGoa53M5SdfulBRxs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696376595; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=9k2xFREJ+w8CMIVs9kMy/TL+LfskRJju2B00DBUrNyk=; b=LTmtdwKjas8laN+yprkxFu7ITpaZ0nD7EBCIbhl60X4QQ27yB39rlfyjvyIRjD/O3jNhKkZTWgo1QOF1/n0clJX2127P3D8mki3TC3g3+ohfSUq+xsWNavgk+d0qhuABvtIL9QWTm9P07urc+Q46Sf/AYfC75lWzhWY5UuVEqEY= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1696376595964103.31104422262479; Tue, 3 Oct 2023 16:43:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qnovY-0004Eq-3f; Tue, 03 Oct 2023 19:35:44 -0400 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 1qnovW-0004EW-1g for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:42 -0400 Received: from mail-io1-xd35.google.com ([2607:f8b0:4864:20::d35]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qnovS-0007Q3-A6 for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:40 -0400 Received: by mail-io1-xd35.google.com with SMTP id ca18e2360f4ac-79fb78e297bso61796539f.0 for ; Tue, 03 Oct 2023 16:35:38 -0700 (PDT) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id w25-20020a6b4a19000000b0079fa1a7cd36sm593596iob.30.2023.10.03.16.35.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 16:35:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1696376137; x=1696980937; 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=9k2xFREJ+w8CMIVs9kMy/TL+LfskRJju2B00DBUrNyk=; b=wparATsjCtYScuR3dh8DZNV35+ocs6LUEKa57sWPoKkwrukPImllUoXJtNL707lLpl DR/kkBryl6SgB9fm3QunJOCycUkUKEbbJrJhiMnmqS8DgG2gC5sRVs3cgyYOOxRbIxzb iDLqY/DbIp7/l8wur31UnP4vMj8UH6VmkXQEBAQt38tOqa4gmneeRuXNGds7/5tbXiX5 mfoG/ZtS/IJ/P3WwtKWmJaWBqVwKS2CBwnmsqR6b2iyG4iaAFM1X6vo6/3MTf/enRimj /YtHSC0M6LYCp/1HfiIyxns/PskJZKnKbV1Y0naL2biEvxxP85mCkA0xPPiqwVYteteb YmHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696376137; x=1696980937; 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=9k2xFREJ+w8CMIVs9kMy/TL+LfskRJju2B00DBUrNyk=; b=IHbt4HeAi1cOr0+jBO3MlbwISBnoWgGbYfk517z4dH6Wn+uJXq9gDx5IEQulxXBt1x YoBGqoaoEQN8IaIUk7J9tYxMZTQNPnjxxuXlYgW6isDgNjkTAWwk7H1PualTbXalZTr0 iyvevaQv9dsxnaMmvniqiyXzi6eWSLDI1s+rNDPEeNprAnU+6r02QUC6K0Ixw5AvBR0Y CgFlgXNLAvWrbgFkUq3p0Qx2KfO3AoZ6aQwkKtG1y42H9jaUi7WFFxwUX0xcwrtEp01L fpbhAFQWWmFxhkOPsRDLQbKzs2HPA5XwPQtDzWJChhj9LLYXL8qH4eE45vJ5ecmW9zJ5 dP6g== X-Gm-Message-State: AOJu0YytPA19PL2q796VMmkYposV6JMZQMgMe4ggEtE3qu4ywWadI8qV nQzkAO+Gq1Ga7n9DgeHXJrnYvnp/6FrgWs+Tn6L8Lg== X-Google-Smtp-Source: AGHT+IEXvxd++3vx1MPatOmVfIjdDMCH25RkSj/Vd4sxC/x7wwpwnFatxOZ64owcaFiVKyBejeBLmg== X-Received: by 2002:a6b:4f0b:0:b0:783:5209:c01 with SMTP id d11-20020a6b4f0b000000b0078352090c01mr990534iob.17.1696376137025; Tue, 03 Oct 2023 16:35:37 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Thomas Huth , Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Wainer dos Santos Moschetta , Beraldo Leal , Warner Losh , Kyle Evans , Karim Taha , Kyle Evans , Richard Henderson Subject: [PULL 33/51] bsd-user: Implement shm_open2(2) system call Date: Tue, 3 Oct 2023 17:31:57 -0600 Message-ID: <20231003233215.95557-34-imp@bsdimp.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231003233215.95557-1-imp@bsdimp.com> References: <20231003233215.95557-1-imp@bsdimp.com> MIME-Version: 1.0 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: none client-ip=2607:f8b0:4864:20::d35; envelope-from=imp@bsdimp.com; helo=mail-io1-xd35.google.com 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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 @bsdimp-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1696376597849100009 Content-Type: text/plain; charset="utf-8" From: Karim Taha Signed-off-by: Kyle Evans Signed-off-by: Karim Taha Reviewed-by: Richard Henderson Message-Id: <20230925182709.4834-6-kariem.taha2.7@gmail.com> --- bsd-user/freebsd/os-misc.h | 46 +++++++++++++++++++++++++++++++++++ bsd-user/freebsd/os-syscall.c | 22 ++++++++++++----- 2 files changed, 62 insertions(+), 6 deletions(-) diff --git a/bsd-user/freebsd/os-misc.h b/bsd-user/freebsd/os-misc.h index 8436ccb2f7d..d5e8b5484c8 100644 --- a/bsd-user/freebsd/os-misc.h +++ b/bsd-user/freebsd/os-misc.h @@ -24,5 +24,51 @@ #include #include =20 +/* + * shm_open2 isn't exported, but the __sys_ alias is. We can use either fo= r the + * static version, but to dynamically link we have to use the sys version. + */ +int __sys_shm_open2(const char *path, int flags, mode_t mode, int shmflags, + const char *); + +#if defined(__FreeBSD_version) && __FreeBSD_version >=3D 1300048 +/* shm_open2(2) */ +static inline abi_long do_freebsd_shm_open2(abi_ulong pathptr, abi_ulong f= lags, + abi_long mode, abi_ulong shmflags, abi_ulong nameptr) +{ + int ret; + void *uname, *upath; + + if (pathptr =3D=3D (uintptr_t)SHM_ANON) { + upath =3D SHM_ANON; + } else { + upath =3D lock_user_string(pathptr); + if (upath =3D=3D NULL) { + return -TARGET_EFAULT; + } + } + + uname =3D NULL; + if (nameptr !=3D 0) { + uname =3D lock_user_string(nameptr); + if (uname =3D=3D NULL) { + unlock_user(upath, pathptr, 0); + return -TARGET_EFAULT; + } + } + ret =3D get_errno(__sys_shm_open2(upath, + target_to_host_bitmask(flags, fcntl_flags_tbl), mode, + target_to_host_bitmask(shmflags, shmflag_flags_tbl), uname= )); + + if (upath !=3D SHM_ANON) { + unlock_user(upath, pathptr, 0); + } + if (uname !=3D NULL) { + unlock_user(uname, nameptr, 0); + } + return ret; +} +#endif /* __FreeBSD_version >=3D 1300048 */ + =20 #endif /* OS_MISC_H */ diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index d04712f0a7e..122e186b501 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -33,18 +33,14 @@ #include "signal-common.h" #include "user/syscall-trace.h" =20 +/* BSD independent syscall shims */ #include "bsd-file.h" #include "bsd-proc.h" =20 /* BSD dependent syscall shims */ #include "os-stat.h" #include "os-proc.h" - -/* used in os-proc */ -safe_syscall4(pid_t, wait4, pid_t, wpid, int *, status, int, options, - struct rusage *, rusage); -safe_syscall6(pid_t, wait6, idtype_t, idtype, id_t, id, int *, status, int, - options, struct __wrusage *, wrusage, siginfo_t *, infop); +#include "os-misc.h" =20 /* I/O */ safe_syscall3(int, open, const char *, path, int, flags, mode_t, mode); @@ -65,6 +61,12 @@ safe_syscall3(ssize_t, writev, int, fd, const struct iov= ec *, iov, int, iovcnt); safe_syscall4(ssize_t, pwritev, int, fd, const struct iovec *, iov, int, i= ovcnt, off_t, offset); =20 +/* used in os-proc */ +safe_syscall4(pid_t, wait4, pid_t, wpid, int *, status, int, options, + struct rusage *, rusage); +safe_syscall6(pid_t, wait6, idtype_t, idtype, id_t, id, int *, status, int, + options, struct __wrusage *, wrusage, siginfo_t *, infop); + void target_set_brk(abi_ulong new_brk) { } @@ -796,6 +798,14 @@ static abi_long freebsd_syscall(void *cpu_env, int num= , abi_long arg1, ret =3D do_freebsd_fcntl(arg1, arg2, arg3); break; =20 + /* + * Memory management system calls. + */ +#if defined(__FreeBSD_version) && __FreeBSD_version >=3D 1300048 + case TARGET_FREEBSD_NR_shm_open2: /* shm_open2(2) */ + ret =3D do_freebsd_shm_open2(arg1, arg2, arg3, arg4, arg5); + break; +#endif =20 /* * sys{ctl, arch, call} --=20 2.41.0 From nobody Sun May 19 09:42:24 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1696376390; cv=none; d=zohomail.com; s=zohoarc; b=aBu0uN5djrT/NzIeRZo029muumMG8rehN5ApgenVjwWf/JiVOnYlew6LbrgxrdHzHpyhblwtQp36AVLzqohs6gVzvvrWYVKC1cmxwQxcrrP7HovpwksFS+Uzb6iayRRLVfCJwBIiboqw0URqRlbrxABii9cD5GzzvpuRF3Vwdko= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696376390; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=snLfS2fmcfQu7v+qFvXCzYllQM35vPKtXXGh7bze+p8=; b=WoZDFw3DxoCCSln2MFPqzybKqMpcUdteObBDyxevLy+WvXkTtouv8Pe0ZWA/PbivXjP0N9xgqrzYcjlMMROGUMTb3Ba+UiuVsVN9hNHCd3Kgbt4+zKmsrhPisNAvK7bck0bQSP09vwUTZuF+QckurMBHVogeFxnpYWDS6xvPcE0= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1696376390428514.594994736556; Tue, 3 Oct 2023 16:39:50 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qnova-0004Ga-SI; Tue, 03 Oct 2023 19:35:46 -0400 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 1qnovZ-0004Ff-AT for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:45 -0400 Received: from mail-io1-xd36.google.com ([2607:f8b0:4864:20::d36]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qnovT-0007QG-7r for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:45 -0400 Received: by mail-io1-xd36.google.com with SMTP id ca18e2360f4ac-79fa387fb96so59614439f.1 for ; Tue, 03 Oct 2023 16:35:38 -0700 (PDT) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id w25-20020a6b4a19000000b0079fa1a7cd36sm593596iob.30.2023.10.03.16.35.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 16:35:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1696376138; x=1696980938; 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=snLfS2fmcfQu7v+qFvXCzYllQM35vPKtXXGh7bze+p8=; b=vylYitD2pk2dn9bkA/Em4T3PyTXXFGammOLqrTvZ+VnlpddavYE6nBu579hMYhl5/2 xtiXqiiQh9YoJbd52zmhv37jb6atXQOPZbnVIINP7GAxvPdjQ4nlrQcJDIPbvaWKx8Ql Dfp2cbNWcjKrPk9C0+6FGOIekggEhY+lPKtO2toHfZ/dlj1ZiOaUCphlJyvIufae385p M29X28NipsvhTzZY5xa55/uPFAsM6+sfAwz3+eKr9SSaXvUgmdCQTMO4AlB5bsDwUCeA F02g4dUTcpyHUOu+f5ucstNBH1QOhWQ5Go4RFTGy/ZsNaVW+lsmh/vlMVjd84djNPnA8 Cvyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696376138; x=1696980938; 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=snLfS2fmcfQu7v+qFvXCzYllQM35vPKtXXGh7bze+p8=; b=aoFXb6tvMExXdr4SV7ohH/F5e0J+efbOBZOW5m5aq41agxnwtQAUcJD0gzYlfj4EMu wlU9ASzoFRkd0F2lyovQH70aIp2wlqB4TTkz3vk8u2iXTO0rmSSWNJCzfSotONE683ui JXDrSfg6TSmiTlaL555P79rTorln9qJp1IZsyS+Bn66lyi7GcRaAwn+OkQBaeIWyaEYY 0bvE6Ykya3KxYNJ5NvJE+IGnN2wyx9259zPLlDO1FsWGBVPYhngmgaCdtZBR9uKJwVZP 6p0UEWVmoeQYLcv9Xq/EKqfOjXRFaSj2rqDkEv+D97zkv5rzNzl1/BxCuZi0nd/xIL+i mrIQ== X-Gm-Message-State: AOJu0YxayNUJZEnSW7wxdJeEamCWasgcKHatzfUfMM1it8H2FS4Wfum6 1wjSL5A4z0bM0AMTVipZZ/kg/pfvWsem3k5z322vRA== X-Google-Smtp-Source: AGHT+IGYKg2LvvQOV0NqnYxEDxK5SFIv2jJoDtbxF7lgzJERLovzPpCs1+xsqQx481RDwL45NeGf1w== X-Received: by 2002:a5e:8919:0:b0:787:34d:f1ea with SMTP id k25-20020a5e8919000000b00787034df1eamr873017ioj.8.1696376137916; Tue, 03 Oct 2023 16:35:37 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Thomas Huth , Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Wainer dos Santos Moschetta , Beraldo Leal , Warner Losh , Kyle Evans , Kyle Evans , Karim Taha , Richard Henderson Subject: [PULL 34/51] bsd-user: Implement shm_rename(2) system call Date: Tue, 3 Oct 2023 17:31:58 -0600 Message-ID: <20231003233215.95557-35-imp@bsdimp.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231003233215.95557-1-imp@bsdimp.com> References: <20231003233215.95557-1-imp@bsdimp.com> MIME-Version: 1.0 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: none client-ip=2607:f8b0:4864:20::d36; envelope-from=imp@bsdimp.com; helo=mail-io1-xd36.google.com 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_NONE=0.001, T_SPF_HELO_TEMPERROR=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @bsdimp-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1696376391403100009 Content-Type: text/plain; charset="utf-8" From: Kyle Evans Signed-off-by: Kyle Evans Signed-off-by: Karim Taha Reviewed-by: Richard Henderson Reviewed-by: Warner Losh Message-Id: <20230925182709.4834-7-kariem.taha2.7@gmail.com> --- bsd-user/freebsd/os-misc.h | 24 ++++++++++++++++++++++++ bsd-user/freebsd/os-syscall.c | 6 ++++++ 2 files changed, 30 insertions(+) diff --git a/bsd-user/freebsd/os-misc.h b/bsd-user/freebsd/os-misc.h index d5e8b5484c8..71145764a4d 100644 --- a/bsd-user/freebsd/os-misc.h +++ b/bsd-user/freebsd/os-misc.h @@ -70,5 +70,29 @@ static inline abi_long do_freebsd_shm_open2(abi_ulong pa= thptr, abi_ulong flags, } #endif /* __FreeBSD_version >=3D 1300048 */ =20 +#if defined(__FreeBSD_version) && __FreeBSD_version >=3D 1300049 +/* shm_rename(2) */ +static inline abi_long do_freebsd_shm_rename(abi_ulong fromptr, abi_ulong = toptr, + abi_ulong flags) +{ + int ret; + void *ufrom, *uto; + + ufrom =3D lock_user_string(fromptr); + if (ufrom =3D=3D NULL) { + return -TARGET_EFAULT; + } + uto =3D lock_user_string(toptr); + if (uto =3D=3D NULL) { + unlock_user(ufrom, fromptr, 0); + return -TARGET_EFAULT; + } + ret =3D get_errno(shm_rename(ufrom, uto, flags)); + unlock_user(ufrom, fromptr, 0); + unlock_user(uto, toptr, 0); + + return ret; +} +#endif /* __FreeBSD_version >=3D 1300049 */ =20 #endif /* OS_MISC_H */ diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index 122e186b501..5fb42b2c218 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -807,6 +807,12 @@ static abi_long freebsd_syscall(void *cpu_env, int num= , abi_long arg1, break; #endif =20 +#if defined(__FreeBSD_version) && __FreeBSD_version >=3D 1300049 + case TARGET_FREEBSD_NR_shm_rename: /* shm_rename(2) */ + ret =3D do_freebsd_shm_rename(arg1, arg2, arg3); + break; +#endif + /* * sys{ctl, arch, call} */ --=20 2.41.0 From nobody Sun May 19 09:42:24 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1696376255; cv=none; d=zohomail.com; s=zohoarc; b=d/kFHLfRGjO45r9zX2KPMqldqiw1G3cpA8o58j8uYPWNPPVyLLZddq3lYEjl2XZhqmuQJsYRJ8RRyyyS6H6JVhztvqJkeBMEUPD9g1MjX00Lj851H6+OoX7HKmD2+MAOM2wbfbsKJ5/iU9cdOGDY3b8tS9mJNHeYWqBm9pEEwM8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696376255; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Lf2DJ/U5pZm2sH4vEROH814jsncDavzfH54NHOK5mnI=; b=TOelGtaTPQgOmbRPuAcUu1QRZ3ULX/PCY6twlv171BVFxzaut0QPQIhzBIwGaRlp8qTLWTY58F7OKgdil8MJ1rlJcy62XPyP98NkYJshJZDPKur+MVsNW/2JuyaQlzND6yGx+t/ptzNXz09jcvTNPt2hdtaoYNlsDx60/s41Bdw= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1696376255300341.9429034638216; Tue, 3 Oct 2023 16:37:35 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qnovn-0004Qg-E1; Tue, 03 Oct 2023 19:35:59 -0400 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 1qnovk-0004M6-Lh for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:57 -0400 Received: from mail-io1-xd32.google.com ([2607:f8b0:4864:20::d32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qnovU-0007QR-7H for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:53 -0400 Received: by mail-io1-xd32.google.com with SMTP id ca18e2360f4ac-79fa2dbd793so64833339f.2 for ; Tue, 03 Oct 2023 16:35:39 -0700 (PDT) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id w25-20020a6b4a19000000b0079fa1a7cd36sm593596iob.30.2023.10.03.16.35.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 16:35:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1696376139; x=1696980939; 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=Lf2DJ/U5pZm2sH4vEROH814jsncDavzfH54NHOK5mnI=; b=beIBeVRIwr+iSLVT759fEoGoOwGNpIPQliRIS6sMlQ8MoCKGALY1CsDugMFvH2jwDL VikPvFILhUxjiZwMGZm/pAwnw7lqxGUvn8X4SwWSoFI8y1W7bT7DBX162p6SuR8azRLo IeLoggEYfhYUb0zWgdpy4hcWqNj0WcSI9qyftwk5NGZc8VoJNHo6/u6MVTf84ayj9QYc rOgkfMJAZraL4eqWFOOdhNoTlukg021sZuoidbQMmVt6cMF6Gx5s1OSWxPxAEHJyGNLI W5f+ugVjMozDCfEwWM8WjMI3oLjIV5XUiMfpFVrUeDP2T7YJ2ns4EVoZwsdQV5lnmFl2 eFQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696376139; x=1696980939; 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=Lf2DJ/U5pZm2sH4vEROH814jsncDavzfH54NHOK5mnI=; b=tQC7m/otSkgZfLNwSaA8oIS+F4yX3NY6vmZC7GyzcLEb8KYnwppnq1JuCuIa+ekil/ /jailcvE4KK4/NGVJFYD8roJAvRLOEtkMpU9xMC0eRZ9fkfsjZhadd2JR1LjVZb6NSXj 4SReFeDvGrE+SdLyd3JY3oQ/iymd6sjqVzMztdDn/EwRPDGMCiTBNZhsdjkJmdGjj706 ztANSq9owQjghQAS7u0/Unz2KkEjeAQnn2cZO6i787Tf9xtfQEYx+D/XmXQohX291mz6 DD13GGxT+cPBtQBpebx1CI4bmPOrVmNslb6ElF/F/m9ZOV30xu66EKaIa9WsB53g7ueJ mLNA== X-Gm-Message-State: AOJu0YxWt33S+7Umh3+1Mckyx1MS/vnXmsKqgG0hdT28bnsMZ5bTYqfT i/wXeXsmnHw43Szg0B1GSMNPpjr8cmGOyN48vAm0yg== X-Google-Smtp-Source: AGHT+IGeMItmvoNFnerw+z4zcjU4ecusxV9/NxaqduSB0gjpJvCGQ+oL+5u6yjH70RsXsGI/Vah4dQ== X-Received: by 2002:a6b:a05:0:b0:792:70f2:a8ed with SMTP id z5-20020a6b0a05000000b0079270f2a8edmr963506ioi.4.1696376138891; Tue, 03 Oct 2023 16:35:38 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Thomas Huth , Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Wainer dos Santos Moschetta , Beraldo Leal , Warner Losh , Kyle Evans , Karim Taha , Richard Henderson Subject: [PULL 35/51] bsd-user: Add bsd-mem.c to meson.build Date: Tue, 3 Oct 2023 17:31:59 -0600 Message-ID: <20231003233215.95557-36-imp@bsdimp.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231003233215.95557-1-imp@bsdimp.com> References: <20231003233215.95557-1-imp@bsdimp.com> MIME-Version: 1.0 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: none client-ip=2607:f8b0:4864:20::d32; envelope-from=imp@bsdimp.com; helo=mail-io1-xd32.google.com 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, SPF_HELO_NONE=0.001, SPF_NONE=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 @bsdimp-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1696376256819100001 Content-Type: text/plain; charset="utf-8" From: Karim Taha Signed-off-by: Karim Taha Reviewed-by: Richard Henderson Reviewed-by: Warner Losh Message-Id: <20230925182709.4834-8-kariem.taha2.7@gmail.com> --- bsd-user/bsd-mem.c | 0 bsd-user/meson.build | 1 + 2 files changed, 1 insertion(+) create mode 100644 bsd-user/bsd-mem.c diff --git a/bsd-user/bsd-mem.c b/bsd-user/bsd-mem.c new file mode 100644 index 00000000000..e69de29bb2d diff --git a/bsd-user/meson.build b/bsd-user/meson.build index b97fce14722..c6bfd3b2b53 100644 --- a/bsd-user/meson.build +++ b/bsd-user/meson.build @@ -7,6 +7,7 @@ bsd_user_ss =3D ss.source_set() common_user_inc +=3D include_directories('include') =20 bsd_user_ss.add(files( + 'bsd-mem.c', 'bsd-proc.c', 'bsdload.c', 'elfload.c', --=20 2.41.0 From nobody Sun May 19 09:42:24 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1696376390; cv=none; d=zohomail.com; s=zohoarc; b=NeChrTxWfra29Kn5P9iTIRU42RlNmgnrMgW3bAYiai/kkXE5bKVZd3AWKX06ak2zQRj0HkWpFAKTDgBOvzVAYte0TVnsmqG6xpbPehxiyZgxmGoDamjHDD3iph3dPR5j3KW537DzBnd507NrUiAxY5RWSCqMXILRrjam5IRExi8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696376390; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=enWxn1UiA0RiRwD9f+pbmm7z2XRqILatx/jv7cDD9xY=; b=f6UjShYLxtiGTo+lKyxUxw4IWYLDPB0uwAVOA7o6EjH+3AlhQnEubbu1/Zw1SzNeMF5ydiNkOjOVd4saAmmLiLwAM9ckwFZ/S9FQKjwyhGY1R4nKhMIPJQU27iJ5aVUDbvxrrZxEIYk/PldzT8Hjl1tP5mHvmlA4aYXXV9HBRpQ= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1696376390430660.0896033623554; Tue, 3 Oct 2023 16:39:50 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qnova-0004Fe-8N; Tue, 03 Oct 2023 19:35:46 -0400 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 1qnovY-0004FE-BK for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:44 -0400 Received: from mail-io1-xd44.google.com ([2607:f8b0:4864:20::d44]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qnovV-0007Qe-6H for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:44 -0400 Received: by mail-io1-xd44.google.com with SMTP id ca18e2360f4ac-79faf4210b2so57699239f.2 for ; Tue, 03 Oct 2023 16:35:40 -0700 (PDT) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id w25-20020a6b4a19000000b0079fa1a7cd36sm593596iob.30.2023.10.03.16.35.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 16:35:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1696376140; x=1696980940; 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=enWxn1UiA0RiRwD9f+pbmm7z2XRqILatx/jv7cDD9xY=; b=V+7rP5znmNxti0xymyZZZW52NeCzjJAwI7ExzqGzCWg5kyUy5heV7yaOHTdw+GLNFT QD4mR169sgzWC+5e6+vRHcaZiGxn5XfWY1F1JoJN9eolFSWibttR2fWM1B+0YAJpmtm5 ioPLcHEPaI6nVLrvo8MrG/vEi3q5HOF3zms5qxpUPnqfBw6O+TF/mya9iZVH1Ejv44HY w0pmu+ZGmOgr2oWC0uMI5kHvctmrvW18bD4MroEdJ6xFa7IaHftHrYmJdWa7wfF2sSIK +mJBUCUky4Rh0cVMUnfnmzHbl0dHeEJULV2yVqFuH4oCeFn+e2ynUSZl1yzs6EIo7YkG XLHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696376140; x=1696980940; 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=enWxn1UiA0RiRwD9f+pbmm7z2XRqILatx/jv7cDD9xY=; b=U2MHQ0wCQdm72gdGPFwq1/vmnVULrqNRHP0hPydjg+MpraPJhEhrXGHOqH6kBVm5LX ls619OWdEv3UInNbnQWFIn31t5o8mfKpKN2uPL9NShds4X8HQudWvTjoccdmW4ZTm5mt B6mvjWhwzw6mtb2KhWU8//iij3uILzZmZtNTV4HWra6d3/G3/m4pmRdkNzOyFzfMPEva jil0+EBj+/xddNK7Ks5KSaFBXQaiBB+J1+IAjA0jOifgbqXp0c/ppd+8KfknlJRWzKT4 JsTq28RQl0GwogFlFqnFaOwK2cavHhjl/EBHnxmeSooC6JBpAdTETdjoCo5n2ILOmxmK L8bg== X-Gm-Message-State: AOJu0YwWfHeEPANBGOwP7/cFPwKn9GEoZOeMpeiYXjg0dhPx7hj02P54 AvIulaelxt6y4aCYP5ITc4LFwElSSB8QSe4iF/ky4GGQ X-Google-Smtp-Source: AGHT+IG1PN+TTC13IgUFUMmXjQSeDrl8VXPgpUcimciK6K0BCojl31ibeyV1qW42AtXaoy+fBavJrw== X-Received: by 2002:a5d:9943:0:b0:79f:d194:d6e2 with SMTP id v3-20020a5d9943000000b0079fd194d6e2mr1054224ios.10.1696376139827; Tue, 03 Oct 2023 16:35:39 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Thomas Huth , Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Wainer dos Santos Moschetta , Beraldo Leal , Warner Losh , Kyle Evans , Stacey Son , =?UTF-8?q?Mika=C3=ABl=20Urankar?= , Karim Taha , Richard Henderson Subject: [PULL 36/51] bsd-user: Implement target_set_brk function in bsd-mem.c instead of os-syscall.c Date: Tue, 3 Oct 2023 17:32:00 -0600 Message-ID: <20231003233215.95557-37-imp@bsdimp.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231003233215.95557-1-imp@bsdimp.com> References: <20231003233215.95557-1-imp@bsdimp.com> 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: none client-ip=2607:f8b0:4864:20::d44; envelope-from=imp@bsdimp.com; helo=mail-io1-xd44.google.com 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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 @bsdimp-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1696376391413100010 From: Stacey Son The definitions and variables names matches the corresponding ones in linux-user/syscall.c, for making later implementation of do_obreak easier Co-authored-by: Mika=C3=ABl Urankar Signed-off-by: Mika=C3=ABl Urankar Signed-off-by: Karim Taha Reviewed-by: Warner Losh Reviewed-by: Richard Henderson Message-Id: <20230925182709.4834-9-kariem.taha2.7@gmail.com> --- bsd-user/bsd-mem.c | 32 ++++++++++++++++++++++++++++++++ bsd-user/freebsd/os-syscall.c | 4 ---- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/bsd-user/bsd-mem.c b/bsd-user/bsd-mem.c index e69de29bb2d..8834ab2e588 100644 --- a/bsd-user/bsd-mem.c +++ b/bsd-user/bsd-mem.c @@ -0,0 +1,32 @@ +/* + * memory management system conversion routines + * + * Copyright (c) 2013 Stacey D. Son + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + */ +#include "qemu/osdep.h" +#include "qemu.h" +#include "qemu-bsd.h" + +struct bsd_shm_regions bsd_shm_regions[N_BSD_SHM_REGIONS]; + +abi_ulong target_brk; +abi_ulong initial_target_brk; + +void target_set_brk(abi_ulong new_brk) +{ + target_brk =3D TARGET_PAGE_ALIGN(new_brk); + initial_target_brk =3D target_brk; +} diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index 5fb42b2c218..c9d34b59bbe 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -67,10 +67,6 @@ safe_syscall4(pid_t, wait4, pid_t, wpid, int *, status, = int, options, safe_syscall6(pid_t, wait6, idtype_t, idtype, id_t, id, int *, status, int, options, struct __wrusage *, wrusage, siginfo_t *, infop); =20 -void target_set_brk(abi_ulong new_brk) -{ -} - /* * errno conversion. */ --=20 2.41.0 From nobody Sun May 19 09:42:24 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1696376459; cv=none; d=zohomail.com; s=zohoarc; b=i+P3TZ0Dux3uceaKU6RY/NSjXaE9iKpqXoVMZEaPwxUfJJetxhL9jt+vHpV9Q9ZXJ7Tk8Anqnf4jc8NWt6e2Q/FVh6gkIxRlyHO0TQ6ha/9MaWqjOokd2Nmur3HzTfSJlMOw5V3Hfrt4AitGCROfQeSyWJhlMceyJGftlW7Tk9c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696376459; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=8GmmJ7cOFUeiFT48AhnZ61JPhLUFSCR6i7jpIveL+bg=; b=NxzCw6+Hno0DnimxTqW6ezP1IMrkHoI8O2zhVGuxh4zuSVon/aC1mDkiJb/C9qH6qIPkqeSQp4BDWBkVcKnRv6o3WbQwzkWjXpO2x7RoUIQmdfkqwQ229yCn7a62dfOsIxMRfY0ovqFKuV44AkqFCfG+8ROA+/fh00r+On6SRIY= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1696376459164605.0640699405084; Tue, 3 Oct 2023 16:40:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qnovb-0004H2-Ob; Tue, 03 Oct 2023 19:35:47 -0400 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 1qnovZ-0004Fm-Ho for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:45 -0400 Received: from mail-io1-xd35.google.com ([2607:f8b0:4864:20::d35]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qnovW-0007Qr-Ec for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:45 -0400 Received: by mail-io1-xd35.google.com with SMTP id ca18e2360f4ac-79f909071c3so60627139f.0 for ; Tue, 03 Oct 2023 16:35:41 -0700 (PDT) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id w25-20020a6b4a19000000b0079fa1a7cd36sm593596iob.30.2023.10.03.16.35.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 16:35:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1696376140; x=1696980940; 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=8GmmJ7cOFUeiFT48AhnZ61JPhLUFSCR6i7jpIveL+bg=; b=jcg5XqXdj2NNzOqZK/2TjorH0TgUZqT/oEDxkEIvB1HDggN4QS0lvwdWCTSXG5zd3p RF4dWl79J/wBAtKM/Jodt1kxse9AlEUkrF5Krl7YGDvkGgc+ltbW/+DQU0bLFL5ks8mF 4z+uakmLVqJvEMTm9iMIfTCcVGcGdTANOrL7O2cWkKgoxAViGxbeMmAZduQcE8sz6kJb LVTcxe1EUOTiBMPZBVJq3zzBd4A43cGI4qUUr5Pfk4pHKQ69veN0W3OuAqEJaCxNyVtB kBfSrNr4KVEP72nm0BvO1/4KoDvHwpub3s2V4Et+KDbDmiYF9ti+1glOFwgvQDMOfOOV HhSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696376140; x=1696980940; 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=8GmmJ7cOFUeiFT48AhnZ61JPhLUFSCR6i7jpIveL+bg=; b=D1XmmvP8s6O8eehkvoXVS5FEk45zq+CrVX/1CH+PARa93lIR9UUG3XUFMn/fdghtv6 +Vdb0Fa7uevmejFfQ4dFxcJ1WOdspojo+SvjrkIPWzl4CsTvpoG4JX2bb8GoQlQ+M2yO j6yxK+qMvejOs1PUe6P2J2ewUrWlkBShtAVYkNaUU6p6sRMiKJkAcQyR4FWQ/HlpDgEY EVQK2cYOWzSorsif20j2zLf7KUZzv5tg960IPfrJo0uvPxFQ+7RZtB59Ir+4myib5yIK LniNly4egOR33GeI0i/LhB8/5iv3shnTQOEXEl/rJBccl8e/fQ0WGBjuR/Q4636QTsdK 2YGQ== X-Gm-Message-State: AOJu0Yyz+4XL13NsGdL+KvyIGMMcLSvsiq0HZxqQWBxGmITnFFTOjo+0 ectElGcE33vdMHKdmzUAl7rPpH4OeWG+e2Xjr6Lfrg== X-Google-Smtp-Source: AGHT+IFuvLGJBbbrYBuwSC45c6lMiKnZtKLDhd2uYkDOtA+yvnSz3576Z2cSIC3fuO+VieGB44TKiw== X-Received: by 2002:a5d:9ec3:0:b0:790:bc17:1c63 with SMTP id a3-20020a5d9ec3000000b00790bc171c63mr942882ioe.1.1696376140677; Tue, 03 Oct 2023 16:35:40 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Thomas Huth , Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Wainer dos Santos Moschetta , Beraldo Leal , Warner Losh , Kyle Evans , Stacey Son , Karim Taha , Richard Henderson Subject: [PULL 37/51] bsd-user: Implement ipc_perm conversion between host and target. Date: Tue, 3 Oct 2023 17:32:01 -0600 Message-ID: <20231003233215.95557-38-imp@bsdimp.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231003233215.95557-1-imp@bsdimp.com> References: <20231003233215.95557-1-imp@bsdimp.com> MIME-Version: 1.0 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: none client-ip=2607:f8b0:4864:20::d35; envelope-from=imp@bsdimp.com; helo=mail-io1-xd35.google.com 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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 @bsdimp-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1696376459895100001 Content-Type: text/plain; charset="utf-8" From: Stacey Son Signed-off-by: Stacey Son Signed-off-by: Karim Taha Reviewed-by: Richard Henderson Message-Id: <20230925182709.4834-10-kariem.taha2.7@gmail.com> --- bsd-user/bsd-mem.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/bsd-user/bsd-mem.c b/bsd-user/bsd-mem.c index 8834ab2e588..46cda8eb5ce 100644 --- a/bsd-user/bsd-mem.c +++ b/bsd-user/bsd-mem.c @@ -30,3 +30,28 @@ void target_set_brk(abi_ulong new_brk) target_brk =3D TARGET_PAGE_ALIGN(new_brk); initial_target_brk =3D target_brk; } + +void target_to_host_ipc_perm__locked(struct ipc_perm *host_ip, + struct target_ipc_perm *target_ip) +{ + __get_user(host_ip->cuid, &target_ip->cuid); + __get_user(host_ip->cgid, &target_ip->cgid); + __get_user(host_ip->uid, &target_ip->uid); + __get_user(host_ip->gid, &target_ip->gid); + __get_user(host_ip->mode, &target_ip->mode); + __get_user(host_ip->seq, &target_ip->seq); + __get_user(host_ip->key, &target_ip->key); +} + +void host_to_target_ipc_perm__locked(struct target_ipc_perm *target_ip, + struct ipc_perm *host_ip) +{ + __put_user(host_ip->cuid, &target_ip->cuid); + __put_user(host_ip->cgid, &target_ip->cgid); + __put_user(host_ip->uid, &target_ip->uid); + __put_user(host_ip->gid, &target_ip->gid); + __put_user(host_ip->mode, &target_ip->mode); + __put_user(host_ip->seq, &target_ip->seq); + __put_user(host_ip->key, &target_ip->key); +} + --=20 2.41.0 From nobody Sun May 19 09:42:24 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1696376376; cv=none; d=zohomail.com; s=zohoarc; b=WcMB7vKltWHCl3NNIrxBeHD37u/uNQQvACwr1H/1hcMz6KiTt6t436hz4/uS7pqyNEBviqAP1tzw5GjJBvQIF41n1BbfGHftfEQeJFAd0RqAiIJ0gv4Hxz34oI9vX3D/JzQzLfommYc7GakPq3MlhrJpJqwZZxeyJTLXSYaAdac= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696376376; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Gu7LXH0KtqoAmWr0NOHNKS6NC88NWxHbhJG+bHoQChE=; b=eNi8U3+vp2YQnWBoUJj8dv+m7ZXmooCPDIJBvHp8bgHDdtynJmywXceyxLWLakIe+ua9M1A5FVSLYaElcTh03U3pf036uljpwzG/9rjr/+6sHmPn4eGGsx081si+2l1xf6hrmzul6inCXl/VLoP/vniR7dvNhm5CZ4W5RYjvccs= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1696376376543113.97146901732572; Tue, 3 Oct 2023 16:39:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qnovw-0004Z2-41; Tue, 03 Oct 2023 19:36:08 -0400 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 1qnovm-0004Pd-Jh for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:58 -0400 Received: from mail-io1-xd33.google.com ([2607:f8b0:4864:20::d33]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qnovX-0007R2-0j for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:58 -0400 Received: by mail-io1-xd33.google.com with SMTP id ca18e2360f4ac-79faba5fe12so57774439f.3 for ; Tue, 03 Oct 2023 16:35:42 -0700 (PDT) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id w25-20020a6b4a19000000b0079fa1a7cd36sm593596iob.30.2023.10.03.16.35.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 16:35:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1696376141; x=1696980941; 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=Gu7LXH0KtqoAmWr0NOHNKS6NC88NWxHbhJG+bHoQChE=; b=rClnTB0/dqFgMyRzNKcDHMjwD1cWcCo3rX97qVlL8Q0d8EwdFcFHWl3JU6l9S/VASL NsE6bZOM4eKGjwXfe640RG+pZaA7N8SF6BVOQmYDClvax52PYXDYBxL87T668HqS+uEL k2O1Aitqn7aCIk6TFER/cRqrwdZCluulJ6skjI6EIAPZArHV0trOZOJs3QQVtBai0sh3 xBcasPbUhvnU+i/zT1Xom3DVeW3NWrGFdbljDl+6qM2MNTQlsazUGpdRqnJl9JN9UETP bG9unRyUbFyF/YPZFTsvI6Nm9gkaS1HZEITRd0Ha336T4Bz4qyESXR4A2hrTv8BTYa2W lahQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696376141; x=1696980941; 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=Gu7LXH0KtqoAmWr0NOHNKS6NC88NWxHbhJG+bHoQChE=; b=Q7fqahNV8i9JarTbJcmSSGwQFu+dirEpGBC/cKbxvjtDxlO/sl0u3POocAVl0Ily3o zpIQRAvLmnmmveJVBUXJzX0hBNQ8tU5zyi3HBn3PVTYG4d+WKgVV9hTl8fX76DxbpmD7 RTa2tnu49IdAVOxQDoPvTjWZoRLdGjQzED7xHDKd6CufO3BkSJdWa+879GMeKA+iDJy0 SbBueK6OOO0fNrHE/hRFcgSTFLfeEKzAKmP82tEWzr67PLcg/dsBKdwMr4KCCnMvJJRS kncKCAEPhBlClh+DdNI7njeAR9gBK/OINAuVHGh+L3/KZjBdiOhvozxTrOnxxvjkVC48 ODsw== X-Gm-Message-State: AOJu0Yz+cr/pi+E3DQPne7bLRLFNz6JpdkzrhdbPE2sOtDWUgtKw0ziK yYKJyQuWIusIdbWNJc6r7lwbRhfnDl/WOU3T/QfMVg== X-Google-Smtp-Source: AGHT+IFw9EtrHE1xzilxHySckHYty5OkfbUttYYQ1PHJJOTMfig8QHD+OXPkVpns8NVYJUbC1JJZQA== X-Received: by 2002:a05:6602:22d8:b0:794:c9a2:5fe3 with SMTP id e24-20020a05660222d800b00794c9a25fe3mr977403ioe.4.1696376141497; Tue, 03 Oct 2023 16:35:41 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Thomas Huth , Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Wainer dos Santos Moschetta , Beraldo Leal , Warner Losh , Kyle Evans , Stacey Son , Karim Taha , Richard Henderson Subject: [PULL 38/51] bsd-user: Implement shmid_ds conversion between host and target. Date: Tue, 3 Oct 2023 17:32:02 -0600 Message-ID: <20231003233215.95557-39-imp@bsdimp.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231003233215.95557-1-imp@bsdimp.com> References: <20231003233215.95557-1-imp@bsdimp.com> MIME-Version: 1.0 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: none client-ip=2607:f8b0:4864:20::d33; envelope-from=imp@bsdimp.com; helo=mail-io1-xd33.google.com 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, SPF_HELO_NONE=0.001, SPF_NONE=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 @bsdimp-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1696376377639100005 Content-Type: text/plain; charset="utf-8" From: Stacey Son Signed-off-by: Stacey Son Signed-off-by: Karim Taha Reviewed-by: Richard Henderson Message-Id: <20230925182709.4834-11-kariem.taha2.7@gmail.com> --- bsd-user/bsd-mem.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/bsd-user/bsd-mem.c b/bsd-user/bsd-mem.c index 46cda8eb5ce..2ab1334b700 100644 --- a/bsd-user/bsd-mem.c +++ b/bsd-user/bsd-mem.c @@ -43,6 +43,30 @@ void target_to_host_ipc_perm__locked(struct ipc_perm *ho= st_ip, __get_user(host_ip->key, &target_ip->key); } =20 +abi_long target_to_host_shmid_ds(struct shmid_ds *host_sd, + abi_ulong target_addr) +{ + struct target_shmid_ds *target_sd; + + if (!lock_user_struct(VERIFY_READ, target_sd, target_addr, 1)) { + return -TARGET_EFAULT; + } + + target_to_host_ipc_perm__locked(&(host_sd->shm_perm), + &(target_sd->shm_perm)); + + __get_user(host_sd->shm_segsz, &target_sd->shm_segsz); + __get_user(host_sd->shm_lpid, &target_sd->shm_lpid); + __get_user(host_sd->shm_cpid, &target_sd->shm_cpid); + __get_user(host_sd->shm_nattch, &target_sd->shm_nattch); + __get_user(host_sd->shm_atime, &target_sd->shm_atime); + __get_user(host_sd->shm_dtime, &target_sd->shm_dtime); + __get_user(host_sd->shm_ctime, &target_sd->shm_ctime); + unlock_user_struct(target_sd, target_addr, 0); + + return 0; +} + void host_to_target_ipc_perm__locked(struct target_ipc_perm *target_ip, struct ipc_perm *host_ip) { @@ -55,3 +79,26 @@ void host_to_target_ipc_perm__locked(struct target_ipc_p= erm *target_ip, __put_user(host_ip->key, &target_ip->key); } =20 +abi_long host_to_target_shmid_ds(abi_ulong target_addr, + struct shmid_ds *host_sd) +{ + struct target_shmid_ds *target_sd; + + if (!lock_user_struct(VERIFY_WRITE, target_sd, target_addr, 0)) { + return -TARGET_EFAULT; + } + + host_to_target_ipc_perm__locked(&(target_sd->shm_perm), + &(host_sd->shm_perm)); + + __put_user(host_sd->shm_segsz, &target_sd->shm_segsz); + __put_user(host_sd->shm_lpid, &target_sd->shm_lpid); + __put_user(host_sd->shm_cpid, &target_sd->shm_cpid); + __put_user(host_sd->shm_nattch, &target_sd->shm_nattch); + __put_user(host_sd->shm_atime, &target_sd->shm_atime); + __put_user(host_sd->shm_dtime, &target_sd->shm_dtime); + __put_user(host_sd->shm_ctime, &target_sd->shm_ctime); + unlock_user_struct(target_sd, target_addr, 1); + + return 0; +} --=20 2.41.0 From nobody Sun May 19 09:42:24 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1696376421; cv=none; d=zohomail.com; s=zohoarc; b=YQ34erKZ9VjmWmwm7be9vCRBLm1CsGsm5b4WLKay6QPg+mJUFxMnXGoPxgx9+JoCIE+bkNpvu/pkdfYQYQyfHJYa1ZGHgNgClQYXsfCLVR5ZpOlILKDUsAcFpkMmP4HJa6RKCOxjkyj4D23oV/rnrABkVzgSJPuzST8ZUocwgiw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696376421; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=toTg5XymdIq2DzzIW6fWIsDHgRoIQT+xw06H9JfCJnM=; b=jhcGjy3yCC2Euwpb1XH72VIKcVeIXZNsUH96zXxoqiZgBfxC7eL4N13hO2eS/mMHDkUtFBmutOczYyBPHo6qCgnhaFQ/U0GXV/J+KOOe/QBRjhDtTrt7KTw6nPHby53jf1l64skQD6lNnW0jYuZJhH46QpdFgfvoueN5tGT1hzU= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1696376421950299.80724339248286; Tue, 3 Oct 2023 16:40:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qnovc-0004HS-Dv; Tue, 03 Oct 2023 19:35:48 -0400 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 1qnovb-0004Gc-1I for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:47 -0400 Received: from mail-io1-xd42.google.com ([2607:f8b0:4864:20::d42]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qnovY-0007RG-0f for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:46 -0400 Received: by mail-io1-xd42.google.com with SMTP id ca18e2360f4ac-79fc3d32a2fso60172639f.1 for ; Tue, 03 Oct 2023 16:35:43 -0700 (PDT) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id w25-20020a6b4a19000000b0079fa1a7cd36sm593596iob.30.2023.10.03.16.35.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 16:35:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1696376142; x=1696980942; 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=toTg5XymdIq2DzzIW6fWIsDHgRoIQT+xw06H9JfCJnM=; b=PSkApX6NmnhZjKaBmHRJtcD8bY+AteuQhtfqVuootL0q3+SZuQfCmB13ok2gi/r46N 3QuwEgnIAFc2ow7F2S2i8sRtuqne3UGHTK16REXi4k5xlL+HdnrRsdEcxgIItKp3G+KI aWg+WpUgmvNnJtQX/EWSCFL0LnyTr/A37fAxdNnuqWLEKDbB4rYK3s3hcwZHHs3WX/Hw jDJk95j2P/DtAYkoEUwsJOGOBskwPbPQxozRxvVzYK4ZeXFrTMhJwdG/Lse3jXr6a+7G D7W4xOhLmymkW2HT20Dpli09ccQA9kwTVrLpWCiHFRZP/qlGw22Ey00xao8jbuUkMJue wPWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696376142; x=1696980942; 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=toTg5XymdIq2DzzIW6fWIsDHgRoIQT+xw06H9JfCJnM=; b=kSqCmFJIn5pZx11Aq6xBQcoVRglB3ATQ0d3c8TXFY9R6Dy/x4hjtHVTJF43/iT/sbD hs5KmUtfvZ9RLghJAmxNZG7jGB82dj4DeE1neNy4ZAkli9rQ9Ygg3VMXiWkQOA4nnHJh tkT4Y5aZ81cSugy1QPbYxdKR21SW2kr78ZVsYsQpARV/pPhmhS9aYbRUeLia/s/vt2ii k1/mIUsoSw4dZCto+YQa2Hj2qW/j9PXeSC9J2yhxdlzWlBRi5r8QyD9urpo1ZCJPp8a1 5Op90OKvSeSY1Y9VULit4QsfdOlqTFN+j1DjkFjQgTBCG05P8tXqhJxvNAJA+fZBaE0S lqkw== X-Gm-Message-State: AOJu0YzqIsMmiIHatfflhUgKCHR8TzkuBvKpsrRe9j/DyD5LYyWqaTwA WEdTyurd8qbCLDB7asVWYQzebWe8m0nh4mLh68UGKuFZ X-Google-Smtp-Source: AGHT+IGiD29wlcXmF7+48ZnH/u2i1ITbKGOxX/BJd8+QJRZMALPSFj8TRI+1ELOoWnB9jIPkzcP7VQ== X-Received: by 2002:a5d:9943:0:b0:787:ff98:c38c with SMTP id v3-20020a5d9943000000b00787ff98c38cmr1100009ios.10.1696376142413; Tue, 03 Oct 2023 16:35:42 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Thomas Huth , Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Wainer dos Santos Moschetta , Beraldo Leal , Warner Losh , Kyle Evans , Stacey Son , Karim Taha , Richard Henderson Subject: [PULL 39/51] bsd-user: Introduce bsd-mem.h to the source tree Date: Tue, 3 Oct 2023 17:32:03 -0600 Message-ID: <20231003233215.95557-40-imp@bsdimp.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231003233215.95557-1-imp@bsdimp.com> References: <20231003233215.95557-1-imp@bsdimp.com> MIME-Version: 1.0 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: none client-ip=2607:f8b0:4864:20::d42; envelope-from=imp@bsdimp.com; helo=mail-io1-xd42.google.com 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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 @bsdimp-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1696376423342100004 Content-Type: text/plain; charset="utf-8" From: Stacey Son Preserve the copyright notice and help with the 'Author' info for subsequent changes to the file. Signed-off-by: Stacey Son Signed-off-by: Karim Taha Reviewed-by: Warner Losh Reviewed-by: Richard Henderson Message-Id: <20230925182709.4834-12-kariem.taha2.7@gmail.com> --- bsd-user/bsd-mem.h | 64 +++++++++++++++++++++++++++++++++++ bsd-user/freebsd/os-syscall.c | 1 + 2 files changed, 65 insertions(+) create mode 100644 bsd-user/bsd-mem.h diff --git a/bsd-user/bsd-mem.h b/bsd-user/bsd-mem.h new file mode 100644 index 00000000000..d865e0807d8 --- /dev/null +++ b/bsd-user/bsd-mem.h @@ -0,0 +1,64 @@ +/* + * memory management system call shims and definitions + * + * Copyright (c) 2013-15 Stacey D. Son + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + */ + +/* + * Copyright (c) 1982, 1986, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURP= OSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENT= IAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STR= ICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY W= AY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef BSD_USER_BSD_MEM_H +#define BSD_USER_BSD_MEM_H + +#include +#include +#include +#include +#include + +#include "qemu-bsd.h" + +extern struct bsd_shm_regions bsd_shm_regions[]; +extern abi_ulong target_brk; +extern abi_ulong initial_target_brk; + +#endif /* BSD_USER_BSD_MEM_H */ diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index c9d34b59bbe..7887ad4c0c6 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -35,6 +35,7 @@ =20 /* BSD independent syscall shims */ #include "bsd-file.h" +#include "bsd-mem.h" #include "bsd-proc.h" =20 /* BSD dependent syscall shims */ --=20 2.41.0 From nobody Sun May 19 09:42:24 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1696376661; cv=none; d=zohomail.com; s=zohoarc; b=ZlF6t389vsTiCjq/NlT2vg4Q8+R3LaSuAjGpov3t3TmEPelQXm6OfxAzc7lslH2IpCqI4wghYj0SYaP5OTbATXBX1/hnZb8mOXqD0pFB6X3Vv+Lrdk+qSrEpEguoWEU3QK8WSNkYETi4YSHeqBHlrjKmaVcR3fJfdbDFUmrzsYQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696376661; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=5PHERJl8GQhbey89K8x6f4j4Q8OwnuZ/ncrkVlq5O9w=; b=bGQ8u+4cUyLKhr7jAfgnlwrwArInNzwJNdP+pPkYmNkEbL+ttcbnrWnI2uh+cqE85tI1SxlyEvqnV9nmuarSkT4y/oyo60mEBAtf0Z+gkk05PP/A1r07e7XAxzkoHR4zYZ+07R6xvWKy0exbSIxyF6s6M6kjooWTQfDC+kFUYNQ= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1696376661421960.2756017038593; Tue, 3 Oct 2023 16:44:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qnovd-0004Hp-Lv; Tue, 03 Oct 2023 19:35:49 -0400 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 1qnovc-0004HN-83 for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:48 -0400 Received: from mail-io1-xd35.google.com ([2607:f8b0:4864:20::d35]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qnovY-0007RV-KQ for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:47 -0400 Received: by mail-io1-xd35.google.com with SMTP id ca18e2360f4ac-79fce245bf6so58308039f.1 for ; Tue, 03 Oct 2023 16:35:44 -0700 (PDT) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id w25-20020a6b4a19000000b0079fa1a7cd36sm593596iob.30.2023.10.03.16.35.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 16:35:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1696376143; x=1696980943; 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=5PHERJl8GQhbey89K8x6f4j4Q8OwnuZ/ncrkVlq5O9w=; b=cCcwhsB1+oqnUmB3xg+W9BA/ssR1rHLUQqXLGEXAws2fkl1wWJL5UVmg+gTuLi2xvR uIZcBWO6JPU/WX4yDDjUF3jFgAPx7sUbMC8/ONsofXTgOnVDxT8EM3mggeRJ4G8HaFjN VDBG19ms68AKHbnCdRPlfpvoP52aM6e0WP5z+f9Fl7CJYf7ZW4HKEk0GSuEkkaZ3u0k5 isDZr/oGAqVa9pPxXRiLaF/XeAy1hrNvYIHQ5Lcc6TAgvpd9dcnKHM1PV1mPzUwwijQG bwlh314nH4X15wG6QSV9PK93xKTYLPNkM46Xo7lhjiQJ5S2ttd6K2idgn0SW4AWM/ZLc fahw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696376143; x=1696980943; 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=5PHERJl8GQhbey89K8x6f4j4Q8OwnuZ/ncrkVlq5O9w=; b=HrucR3rD9UjVsVyS1STBuHE4XL56cR6olYnZvRpox8gTq8RVGvHaMlyOr3KBvHd2Fd kuNGiITNTKbou9rnGUjh1Qo2BnKAagFGTVeiLtCfozbEbNDzkE2Ozi8m4+uhTV5HVjX0 z5vMdFXTIBtvo/FFk3ueIcWVTcpGWi6ULOqadcvL4srd47Wqtw1L7EffJMAr/yLTvH33 eFJxsFZFtalysfUgxNAW5hFFUhxzPd1UGg6NWKJ6el+R7kx0MF0AQyIWQtd9c0+rPjnJ acQOQJGuztaDie/46vseAIYXSKDlkrwxxI0mkpCJqup1DOkHaJM4zP8qrA46Hbx08b4T JxuA== X-Gm-Message-State: AOJu0Yy9h4xnP08nmn32M6iT4cPLGsTKRxHcAT1bM0uSgYH4tDnyF1Bn Abf9Zs2YKtcJ4b7DQbzv89uFRTdZUlctJdvwVW2UOg== X-Google-Smtp-Source: AGHT+IGgHX/teRChYawrxjQXFIcTwY0y2OSfMDOhMTtXYTkyTcBre7viDHKFtGo17DW9FBpYWK7DkA== X-Received: by 2002:a05:6602:220c:b0:786:fff8:13c2 with SMTP id n12-20020a056602220c00b00786fff813c2mr973198ion.11.1696376143372; Tue, 03 Oct 2023 16:35:43 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Thomas Huth , Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Wainer dos Santos Moschetta , Beraldo Leal , Warner Losh , Kyle Evans , Stacey Son , Karim Taha , Richard Henderson Subject: [PULL 40/51] bsd-user: Implement mmap(2) and munmap(2) Date: Tue, 3 Oct 2023 17:32:04 -0600 Message-ID: <20231003233215.95557-41-imp@bsdimp.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231003233215.95557-1-imp@bsdimp.com> References: <20231003233215.95557-1-imp@bsdimp.com> MIME-Version: 1.0 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: none client-ip=2607:f8b0:4864:20::d35; envelope-from=imp@bsdimp.com; helo=mail-io1-xd35.google.com 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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 @bsdimp-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1696376663127100009 Content-Type: text/plain; charset="utf-8" From: Stacey Son Signed-off-by: Stacey Son Signed-off-by: Karim Taha Reviewed-by: Warner Losh Reviewed-by: Richard Henderson Message-Id: <20230925182709.4834-13-kariem.taha2.7@gmail.com> --- bsd-user/bsd-mem.h | 20 ++++++++++++++++++++ bsd-user/freebsd/os-syscall.c | 9 +++++++++ 2 files changed, 29 insertions(+) diff --git a/bsd-user/bsd-mem.h b/bsd-user/bsd-mem.h index d865e0807d8..76b504f70c5 100644 --- a/bsd-user/bsd-mem.h +++ b/bsd-user/bsd-mem.h @@ -61,4 +61,24 @@ extern struct bsd_shm_regions bsd_shm_regions[]; extern abi_ulong target_brk; extern abi_ulong initial_target_brk; =20 +/* mmap(2) */ +static inline abi_long do_bsd_mmap(void *cpu_env, abi_long arg1, abi_long = arg2, + abi_long arg3, abi_long arg4, abi_long arg5, abi_long arg6, abi_long a= rg7, + abi_long arg8) +{ + if (regpairs_aligned(cpu_env) !=3D 0) { + arg6 =3D arg7; + arg7 =3D arg8; + } + return get_errno(target_mmap(arg1, arg2, arg3, + target_to_host_bitmask(arg4, mmap_flags_t= bl), + arg5, target_arg64(arg6, arg7))); +} + +/* munmap(2) */ +static inline abi_long do_bsd_munmap(abi_long arg1, abi_long arg2) +{ + return get_errno(target_munmap(arg1, arg2)); +} + #endif /* BSD_USER_BSD_MEM_H */ diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index 7887ad4c0c6..b03837d032a 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -798,6 +798,15 @@ static abi_long freebsd_syscall(void *cpu_env, int num= , abi_long arg1, /* * Memory management system calls. */ + case TARGET_FREEBSD_NR_mmap: /* mmap(2) */ + ret =3D do_bsd_mmap(cpu_env, arg1, arg2, arg3, arg4, arg5, arg6, a= rg7, + arg8); + break; + + case TARGET_FREEBSD_NR_munmap: /* munmap(2) */ + ret =3D do_bsd_munmap(arg1, arg2); + break; + #if defined(__FreeBSD_version) && __FreeBSD_version >=3D 1300048 case TARGET_FREEBSD_NR_shm_open2: /* shm_open2(2) */ ret =3D do_freebsd_shm_open2(arg1, arg2, arg3, arg4, arg5); --=20 2.41.0 From nobody Sun May 19 09:42:24 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1696376201; cv=none; d=zohomail.com; s=zohoarc; b=VYmaXbYe4oH2bAxDiXYKgdQGcDfa8PpRo1Xee+KEGDJjBHCicDg7aagdLpiWomrRshnfooa6ljnCSaG84vj4faYSHECCpbGyB8c8nJ4ro56v1HQwJ7BYo2AUYlH24TAnmr7BGMkY+3rt1MJp7Iphahd+nkXgM1jJ4tN0MgwTP0M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696376201; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=jhtBcCLqYRdXH9l+jJ0/HOZSt1P08pHO71aNhpu5SkU=; b=Px43NJuydM6QVicf0OVhzVnQ1sRccCk9QZiFUSw6F+IL4B+pZn4V9jtRK14sHbm/cKSofc21Ly1YcSwNa35jw2syPWxubp0Hvhg6eUQQTYNl+YScUemcNooVKkGNud9puT7XqrvOe/OSorZbfhXgK/LQ1onUknJlYZ5TgzMRn60= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1696376201638953.4937567023552; Tue, 3 Oct 2023 16:36:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qnovq-0004UU-Rh; Tue, 03 Oct 2023 19:36:02 -0400 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 1qnovl-0004MC-KX for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:57 -0400 Received: from mail-io1-xd33.google.com ([2607:f8b0:4864:20::d33]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qnova-0007Rp-N3 for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:53 -0400 Received: by mail-io1-xd33.google.com with SMTP id ca18e2360f4ac-7a2a9e5451bso58473039f.1 for ; Tue, 03 Oct 2023 16:35:46 -0700 (PDT) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id w25-20020a6b4a19000000b0079fa1a7cd36sm593596iob.30.2023.10.03.16.35.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 16:35:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1696376144; x=1696980944; 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=jhtBcCLqYRdXH9l+jJ0/HOZSt1P08pHO71aNhpu5SkU=; b=KePwgqR+LjZVCeHEvB6Ra/e50uGGhPKZYGizutrfJfdpSl9FQ0VvQBMLhcXIR/278k QgMvNl50XRhtEhsAoOLyjxcuZsFvanDJP383WOJZqNsLEdG3DLCXzQuARkchJT9VroVo xBQFVJQdzxKH+pKiRjKXBD4HMCMiYfGl2qkd+acXUQLz/6LiodD6uhdfJFGNy/b/ZXJW XM5Bs0Z/eaaoX2m+1tFMsRhDb6Ny0GI0Q3HehJZ2zduWOxobi46RCu5jSTtASKAXp+4e wUQOdpsYXzFcIkhNgq4S1acd41Bs+Nzdn9YrVFYaGDp2nC3rZf4hGrGqjo1HD2eYCdwM pNJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696376144; x=1696980944; 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=jhtBcCLqYRdXH9l+jJ0/HOZSt1P08pHO71aNhpu5SkU=; b=Hx+X2TUIrz2OJZ8gq7Tngl8QYQUgqVbaldySasWNf/vdDEsk3MdJ5QjC3GX6ZBUOl6 JxxUQu4cg6KZXOEA88mIOQn3vA8SHUhiTmSQMzyZBuq8Y6MYP5qwdhJDSrnphvQ6aO1Z BE1KbjXtTXCZyapLKU9pHD55L3chzfkecOKS6eGP8QWe0QuFvBcPrvOD9NAN1FJD30og WjCbkKbTaW+Zq3yoDTtvsHExUveOHohpHxQTZ/Sq0crdjAMHop7hvaR9mrpuSz9c0AUs /UFe0bwVjUU2WJjFNrEX1J+o1CscGTNtB88xiON55Hehhah/3Qf6XjzxFNXmEjUaper8 kpfg== X-Gm-Message-State: AOJu0YwdEUVnnUfw9GPZeJtJccBW/x3Td4x2ssgP99Ilj7SJFJJf0DXK HcclBK2vo+P4qr8ttD0eDCm0H4p9/3OC4nUMDJGrtw== X-Google-Smtp-Source: AGHT+IFWNfpsiO8BvmONe6EdFceFlZ5Ap0NP1iqQnIsvyXBQdKEQZ0fgKkbxrsSMYcvwKQdwW8dbvg== X-Received: by 2002:a6b:6816:0:b0:79f:b37f:98e6 with SMTP id d22-20020a6b6816000000b0079fb37f98e6mr839194ioc.20.1696376144232; Tue, 03 Oct 2023 16:35:44 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Thomas Huth , Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Wainer dos Santos Moschetta , Beraldo Leal , Warner Losh , Kyle Evans , Stacey Son , Karim Taha , Richard Henderson Subject: [PULL 41/51] bsd-user: Implement mprotect(2) Date: Tue, 3 Oct 2023 17:32:05 -0600 Message-ID: <20231003233215.95557-42-imp@bsdimp.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231003233215.95557-1-imp@bsdimp.com> References: <20231003233215.95557-1-imp@bsdimp.com> MIME-Version: 1.0 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: none client-ip=2607:f8b0:4864:20::d33; envelope-from=imp@bsdimp.com; helo=mail-io1-xd33.google.com 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, T_SPF_TEMPERROR=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @bsdimp-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1696376203306100003 Content-Type: text/plain; charset="utf-8" From: Stacey Son Signed-off-by: Stacey Son Signed-off-by: Karim Taha Reviewed-by: Richard Henderson Reviewed-by: Warner Losh Message-Id: <20230925182709.4834-14-kariem.taha2.7@gmail.com> --- bsd-user/bsd-mem.h | 7 +++++++ bsd-user/freebsd/os-syscall.c | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/bsd-user/bsd-mem.h b/bsd-user/bsd-mem.h index 76b504f70c5..0f9e4a1d4be 100644 --- a/bsd-user/bsd-mem.h +++ b/bsd-user/bsd-mem.h @@ -81,4 +81,11 @@ static inline abi_long do_bsd_munmap(abi_long arg1, abi_= long arg2) return get_errno(target_munmap(arg1, arg2)); } =20 +/* mprotect(2) */ +static inline abi_long do_bsd_mprotect(abi_long arg1, abi_long arg2, + abi_long arg3) +{ + return get_errno(target_mprotect(arg1, arg2, arg3)); +} + #endif /* BSD_USER_BSD_MEM_H */ diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index b03837d032a..2d8f1a953b2 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -807,6 +807,10 @@ static abi_long freebsd_syscall(void *cpu_env, int num= , abi_long arg1, ret =3D do_bsd_munmap(arg1, arg2); break; =20 + case TARGET_FREEBSD_NR_mprotect: /* mprotect(2) */ + ret =3D do_bsd_mprotect(arg1, arg2, arg3); + break; + #if defined(__FreeBSD_version) && __FreeBSD_version >=3D 1300048 case TARGET_FREEBSD_NR_shm_open2: /* shm_open2(2) */ ret =3D do_freebsd_shm_open2(arg1, arg2, arg3, arg4, arg5); --=20 2.41.0 From nobody Sun May 19 09:42:24 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1696376545; cv=none; d=zohomail.com; s=zohoarc; b=BmNsOr5Z64YzDq1mq2rEYBq86Z5dYGLv/HFo8mDO18O2q8hQsI/joxv0N1QksjltI1g2pjonPe/Ur8WossYlPQsr1CW5stuNRUe4gQDRRlCKOvsSNQMN99em7hmrMfiqys7O9Kvqhp48Co9GEbSFk9mtMzvwJbuDOWQ9XTfSb7E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696376545; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=fs1dcVqCXTX8RM3B0vVfSAr/XS18s4HpUbI3OIrGI0Y=; b=IlNWh6ZRcpgcNv72OcAMsW7jjv7zPnZlniPCChdhWqy5hJ3BtxdYEGPdNmV54BirMW0xYa7zuAQfXy2ujHycNGQil+V/7yXGGuhCXjSEFj8f/PgUNDW6uxpzkW1pKJSb8/WFrqZpgQsWkr5HaIbaAseBhXJ4B5F6rCZHjhr0mRU= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1696376545821230.85651077771502; Tue, 3 Oct 2023 16:42:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qnovo-0004TA-DZ; Tue, 03 Oct 2023 19:36:00 -0400 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 1qnovk-0004M5-M7 for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:57 -0400 Received: from mail-io1-xd30.google.com ([2607:f8b0:4864:20::d30]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qnova-0007S7-FL for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:52 -0400 Received: by mail-io1-xd30.google.com with SMTP id ca18e2360f4ac-79fb64b5265so61150539f.1 for ; Tue, 03 Oct 2023 16:35:46 -0700 (PDT) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id w25-20020a6b4a19000000b0079fa1a7cd36sm593596iob.30.2023.10.03.16.35.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 16:35:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1696376145; x=1696980945; 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=fs1dcVqCXTX8RM3B0vVfSAr/XS18s4HpUbI3OIrGI0Y=; b=KTK9fEh5MZYKXqqouRY5vncDUHC4jS6OHf0XghSOL/6648bBUkQvySwJqOnZ92caGW PXjGSyYcZKiYYjY02T27lXQ6l7IP8bCpTj4YO76Xh3xtLaBQUgi3PRvDdWbWdhspofX5 LvvDLz3asDdnR8vRSlFvFExUCvU9oXItKNaSp0aI1tdLRHk3mFpE0Bgi1CM04nCZvFeD Qv4FKoNYiWEkPaU58ZuFsHQEQevKEI/sNm15D6XkWpvvQ0owIrQH99tSj8xj5jPQ9orW YvKv/kVWlVZ7hgVS2NRiBEwo+Epbrzhu3bePg6LFFrY7A4MHH8HHKXaMlgSGNiQKvnku 6WnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696376145; x=1696980945; 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=fs1dcVqCXTX8RM3B0vVfSAr/XS18s4HpUbI3OIrGI0Y=; b=Gi6DEG2BiO5ecegixHooU70EQE7mxgr43OiPcI+e+t62O/c/zXXZLtlCE/g6SzNfQj LQyCOzAHiCASHLqRdDYN+j2N95GiBOqHzQ4wq/vRxukhEsDY1pXNiEMPWqw9cAxD1lrQ 0JX43gxKUi/NMej6BPifU/h8HlX/KUoTSRswuRzzDSUY9dcVRkMu1tJT3gKr9tJKd8Yy S3gS+sLtxVOQLZQ17oOv6ynkDOfAf+jKzOSiElobM2kl6+fj89W+16CBnyG86N/tShSx S/3ykATWwMCi7E7ebbi+OLTFKo07meskDCS7rv1LfYrHRMTYmxZHjOvdXOuaiApoRYqT gEgQ== X-Gm-Message-State: AOJu0Yzk/TcPXkAV4Hd2A5f5/GRuVolZ++6X1uh8/wQMNPitfA2xe7X8 PsdA0iw31fXAkOO1qIirVtt95Mp0pUUUOVJN57pWaw== X-Google-Smtp-Source: AGHT+IEHnC7V/j9hifiV5Z5q6mlaapcsOC0dzD+cGD75OjFTY3x7iyienk3kWXWEpQqsqKzoZrKs6A== X-Received: by 2002:a5e:8c0c:0:b0:795:16b8:85fc with SMTP id n12-20020a5e8c0c000000b0079516b885fcmr1006158ioj.0.1696376145177; Tue, 03 Oct 2023 16:35:45 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Thomas Huth , Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Wainer dos Santos Moschetta , Beraldo Leal , Warner Losh , Kyle Evans , Stacey Son , Kyle Evans , Karim Taha , Richard Henderson Subject: [PULL 42/51] bsd-user: Implement msync(2) Date: Tue, 3 Oct 2023 17:32:06 -0600 Message-ID: <20231003233215.95557-43-imp@bsdimp.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231003233215.95557-1-imp@bsdimp.com> References: <20231003233215.95557-1-imp@bsdimp.com> MIME-Version: 1.0 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: none client-ip=2607:f8b0:4864:20::d30; envelope-from=imp@bsdimp.com; helo=mail-io1-xd30.google.com 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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 @bsdimp-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1696376547129100002 Content-Type: text/plain; charset="utf-8" From: Stacey Son Co-authored-by: Kyle Evans Signed-off-by: Stacey Son Signed-off-by: Kyle Evans Signed-off-by: Karim Taha Reviewed-by: Warner Losh Reviewed-by: Richard Henderson Message-Id: <20230925182709.4834-15-kariem.taha2.7@gmail.com> --- bsd-user/bsd-mem.h | 11 +++++++++++ bsd-user/freebsd/os-syscall.c | 4 ++++ 2 files changed, 15 insertions(+) diff --git a/bsd-user/bsd-mem.h b/bsd-user/bsd-mem.h index 0f9e4a1d4be..5e885823a79 100644 --- a/bsd-user/bsd-mem.h +++ b/bsd-user/bsd-mem.h @@ -88,4 +88,15 @@ static inline abi_long do_bsd_mprotect(abi_long arg1, ab= i_long arg2, return get_errno(target_mprotect(arg1, arg2, arg3)); } =20 +/* msync(2) */ +static inline abi_long do_bsd_msync(abi_long addr, abi_long len, abi_long = flags) +{ + if (!guest_range_valid_untagged(addr, len)) { + /* It seems odd, but POSIX wants this to be ENOMEM */ + return -TARGET_ENOMEM; + } + + return get_errno(msync(g2h_untagged(addr), len, flags)); +} + #endif /* BSD_USER_BSD_MEM_H */ diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index 2d8f1a953b2..2525e0bc316 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -811,6 +811,10 @@ static abi_long freebsd_syscall(void *cpu_env, int num= , abi_long arg1, ret =3D do_bsd_mprotect(arg1, arg2, arg3); break; =20 + case TARGET_FREEBSD_NR_msync: /* msync(2) */ + ret =3D do_bsd_msync(arg1, arg2, arg3); + break; + #if defined(__FreeBSD_version) && __FreeBSD_version >=3D 1300048 case TARGET_FREEBSD_NR_shm_open2: /* shm_open2(2) */ ret =3D do_freebsd_shm_open2(arg1, arg2, arg3, arg4, arg5); --=20 2.41.0 From nobody Sun May 19 09:42:24 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1696376659; cv=none; d=zohomail.com; s=zohoarc; b=EIOUkrTYQNY5EAALxDfECLfw/ucV2EwvcKDs5gLItiU4OghjCZh+eE7MdcNtkEdrMVK/9DQvgPSB3toH4CKIan5YFaee1GpBrgZ2Wu8J6FC4Vt7WIC4nlWzMNTLaJiuOdXcHQCT9dZCXgdd7UPItNohsSH0UEfDyKTIJescC5OI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696376659; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=5NCyHAC9bXim/1mXpJd490XbnS8liuXo8kxgl9Yya/4=; b=I2bWwflt9204j6HmN+K0MBoDONmFGjkgkrvVmaQl9QwfHHpi/fJyGB2dZgYD5R2XzQMMV4DZa2zg/QRQZnSTHM1w3U5d9ndQ7i/vsD6v5OZ/sFJcMnaJBul7yDo5urkMLulVLbtIWYPCIS7FLk2uta/ej+IOtRNokvPbJad9CKk= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1696376659535942.2520563872681; Tue, 3 Oct 2023 16:44:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qnovp-0004UI-Ol; Tue, 03 Oct 2023 19:36:02 -0400 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 1qnovk-0004M8-MR for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:57 -0400 Received: from mail-io1-xd2b.google.com ([2607:f8b0:4864:20::d2b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qnovc-0007SO-0X for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:53 -0400 Received: by mail-io1-xd2b.google.com with SMTP id ca18e2360f4ac-79fa5d9f3a2so57662039f.3 for ; Tue, 03 Oct 2023 16:35:47 -0700 (PDT) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id w25-20020a6b4a19000000b0079fa1a7cd36sm593596iob.30.2023.10.03.16.35.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 16:35:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1696376146; x=1696980946; 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=5NCyHAC9bXim/1mXpJd490XbnS8liuXo8kxgl9Yya/4=; b=FDWWUnQ1/1qa/U0+1VFdwE6hqdijGcGJ5LpGf/hKMVLgwBYwxxP6NS/EIDiEKSo8ri YAVLyWaRRPEUJIsfLWi0ay+BNQNyLkYIgXhsrR23AvoudrID+TwJQERydceRo5KCyXWv fQUJIxYECFFrYsUoIElaM5Cq9iTFlO4SNY6naM9OXCa2PF+pFe5mV5LUmyHLKnBsXmOe 9nS86NoHX/SBY7SLW9TfwiiKtVqf3pHujWIutUGONoD86rYsAC5FBB8nZz/sPyHWQ53X 0YxzlwvKa2Jg7/Twv8sCi88pksrpG1PtLiwCmwccYyhjvTDIeiTh20rP3eC2rk6767WL my8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696376146; x=1696980946; 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=5NCyHAC9bXim/1mXpJd490XbnS8liuXo8kxgl9Yya/4=; b=sLQ0tLNwvNm2hJmgOhION2jFWm+pok7pd5E3721A8aGvExWt5D/sKEAPHWhXSDvVpi UzUw+hB4Ka6LZqTFzsiutQMlEjIMQr21np1B///a3TebR20MxirJKJ/6Yc3+w8lP4XAr tDEa9S90xaMDplQiViUJ4rpFmy64Mc5plpCmvtuALQoxZujJ+I3cyzZ4SayMUhoKXfho twPomH+m1AUtfnxGo8EDGN8iXp7TJ+ktm6n32BvnmABCg/h3L0nR2WawvExlBVJ3u4I9 yTSAmr4eQ6n3rUvg9WBRRdSrTR3ZNDUgHu7Hc7rLNNQCDJ1MPg2fiBOvfFxOLEgrcOsn N5Eg== X-Gm-Message-State: AOJu0Yxm3WQlrzcmHOi+ixi6FrdgAvGpNlUNF8ljJGrQ72UJDJMkbbMO My+K89Hqy08vqQP4UM2eaOfCAo1tdlP0hkedugADng== X-Google-Smtp-Source: AGHT+IGsOFW3d+6U1fFTOGki2d3Si6JtXpKrW6BN//d2GpH0FKZwc/xjXi3/J0QlZ1AbKvNshEQgPw== X-Received: by 2002:a05:6602:228a:b0:79f:a25b:51c with SMTP id d10-20020a056602228a00b0079fa25b051cmr969801iod.11.1696376146172; Tue, 03 Oct 2023 16:35:46 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Thomas Huth , Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Wainer dos Santos Moschetta , Beraldo Leal , Warner Losh , Kyle Evans , Stacey Son , Karim Taha , Richard Henderson Subject: [PULL 43/51] bsd-user: Implement mlock(2), munlock(2), mlockall(2), munlockall(2), minherit(2) Date: Tue, 3 Oct 2023 17:32:07 -0600 Message-ID: <20231003233215.95557-44-imp@bsdimp.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231003233215.95557-1-imp@bsdimp.com> References: <20231003233215.95557-1-imp@bsdimp.com> MIME-Version: 1.0 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: none client-ip=2607:f8b0:4864:20::d2b; envelope-from=imp@bsdimp.com; helo=mail-io1-xd2b.google.com 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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 @bsdimp-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1696376659790100001 Content-Type: text/plain; charset="utf-8" From: Stacey Son Signed-off-by: Stacey Son Signed-off-by: Karim Taha Reviewed-by: Richard Henderson Message-Id: <20230925182709.4834-16-kariem.taha2.7@gmail.com> --- bsd-user/bsd-mem.h | 37 +++++++++++++++++++++++++++++++++++ bsd-user/freebsd/os-syscall.c | 20 +++++++++++++++++++ 2 files changed, 57 insertions(+) diff --git a/bsd-user/bsd-mem.h b/bsd-user/bsd-mem.h index 5e885823a79..16c22593bfd 100644 --- a/bsd-user/bsd-mem.h +++ b/bsd-user/bsd-mem.h @@ -99,4 +99,41 @@ static inline abi_long do_bsd_msync(abi_long addr, abi_l= ong len, abi_long flags) return get_errno(msync(g2h_untagged(addr), len, flags)); } =20 +/* mlock(2) */ +static inline abi_long do_bsd_mlock(abi_long arg1, abi_long arg2) +{ + if (!guest_range_valid_untagged(arg1, arg2)) { + return -TARGET_EINVAL; + } + return get_errno(mlock(g2h_untagged(arg1), arg2)); +} + +/* munlock(2) */ +static inline abi_long do_bsd_munlock(abi_long arg1, abi_long arg2) +{ + if (!guest_range_valid_untagged(arg1, arg2)) { + return -TARGET_EINVAL; + } + return get_errno(munlock(g2h_untagged(arg1), arg2)); +} + +/* mlockall(2) */ +static inline abi_long do_bsd_mlockall(abi_long arg1) +{ + return get_errno(mlockall(arg1)); +} + +/* munlockall(2) */ +static inline abi_long do_bsd_munlockall(void) +{ + return get_errno(munlockall()); +} + +/* minherit(2) */ +static inline abi_long do_bsd_minherit(abi_long addr, abi_long len, + abi_long inherit) +{ + return get_errno(minherit(g2h_untagged(addr), len, inherit)); +} + #endif /* BSD_USER_BSD_MEM_H */ diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index 2525e0bc316..7a7ae26793f 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -815,6 +815,26 @@ static abi_long freebsd_syscall(void *cpu_env, int num= , abi_long arg1, ret =3D do_bsd_msync(arg1, arg2, arg3); break; =20 + case TARGET_FREEBSD_NR_mlock: /* mlock(2) */ + ret =3D do_bsd_mlock(arg1, arg2); + break; + + case TARGET_FREEBSD_NR_munlock: /* munlock(2) */ + ret =3D do_bsd_munlock(arg1, arg2); + break; + + case TARGET_FREEBSD_NR_mlockall: /* mlockall(2) */ + ret =3D do_bsd_mlockall(arg1); + break; + + case TARGET_FREEBSD_NR_munlockall: /* munlockall(2) */ + ret =3D do_bsd_munlockall(); + break; + + case TARGET_FREEBSD_NR_minherit: /* minherit(2) */ + ret =3D do_bsd_minherit(arg1, arg2, arg3); + break; + #if defined(__FreeBSD_version) && __FreeBSD_version >=3D 1300048 case TARGET_FREEBSD_NR_shm_open2: /* shm_open2(2) */ ret =3D do_freebsd_shm_open2(arg1, arg2, arg3, arg4, arg5); --=20 2.41.0 From nobody Sun May 19 09:42:24 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1696376477; cv=none; d=zohomail.com; s=zohoarc; b=D/7/Ml+iEjN2WdkqrI/7D9+ZXeBV0v9fuW1v64Kehq2wOqipoLt0LPX6GMZcLPZhYSDo5RT/JK3R0RW/58EniUSzdm8JOHKKNVCvZSg+J68Wre72tbKB/NVJoaEmWZW+3KxJz3JV2emg7ryLBFymIAIfc9tCH4EvmMJ8j9RJmnk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696376477; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=bS/7XD3QWTqjRTlEK+pQc9fvJl6oodvE6Kcpj/qv1/I=; b=j4307huXCXFWcgPa6YNADsFeq359mX+UdiXh/8XDBsX9LmWNs0HjngI2x/17o7YgZyEFMDa20BxYVq5rjv+nbRBI7X+LxxhXsc8aksJspZHWDlxQ1a7aclbiMmuIBlNytvhKiJBK2vqEK6tZuplFnRMAw3OcEFFSlUokp80iSGc= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1696376477911977.2582359606231; Tue, 3 Oct 2023 16:41:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qnovs-0004Wl-2o; Tue, 03 Oct 2023 19:36:04 -0400 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 1qnovm-0004Pe-JB for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:58 -0400 Received: from mail-io1-xd36.google.com ([2607:f8b0:4864:20::d36]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qnove-0007Sm-C3 for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:57 -0400 Received: by mail-io1-xd36.google.com with SMTP id ca18e2360f4ac-79fce245bf6so58309539f.1 for ; Tue, 03 Oct 2023 16:35:48 -0700 (PDT) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id w25-20020a6b4a19000000b0079fa1a7cd36sm593596iob.30.2023.10.03.16.35.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 16:35:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1696376147; x=1696980947; 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=bS/7XD3QWTqjRTlEK+pQc9fvJl6oodvE6Kcpj/qv1/I=; b=K+FZsvYQn/Dms7+tGp7rIEXU4TyWxNDSuLA8jz8SGQIpE7IeRjsmKBEs/TXBTMYAaW nUdY9KL/1gzLyTX0p47MGCTvSUzi83qNLss6oagKv70/mYi8isaEhZGADCyccx7bUCVz q3bGvXrAni54YbK/MwiUWbKbqFSVQYK8nEt0n3Fjwfvjv5UyNGlcAAqR5ztRClgN0Ndl zG7A6ORMeT7cfGLZYVrgutl5AfXvo5GokWq+QmEbsHjCbgaGXH4pV3QM9lS574ivtULY lv6M//h94T3NBKh/hdcXtImYGqwyvwwKzFHnESSrMhsQRqaqUaPzhnctysda6t6zLh8E ra6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696376147; x=1696980947; 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=bS/7XD3QWTqjRTlEK+pQc9fvJl6oodvE6Kcpj/qv1/I=; b=RZDFieL9RBvSB07KN4h0sL5ypgx9+MeIj5Ia1e4QTfvZCaV9+vK6P5/jWD92YA6MDy cGatA4XKgA5VZao395NLryVbpngd9eVrxZEARJzYEF00+cr60O6Or96i1N+HNCR+Fh5K oGa/kn3RlYksRs+rqmLthhSwvO2pUI0UCEOSaW7rAwkK8Pcba3/gciuvkUtgIkLidaC3 jzW1gYeqT1JvLF2tqE2mHMrJUjWYMAdZ4Wc6qJ1QgcNhR3zpR94wPjScIBvB7c5GyP/p HgwiCUmyAzvwrHMp2b3kHvxM6uc97GF8dIFy+6V4mrQUojzgSYvwNCDKf0Gpmy7QIYh3 Wmrg== X-Gm-Message-State: AOJu0Yz5lY6oQyI0TjQerjdf98WkxRuiujwAQvnBaDAwvs7cq+lYacPL 684B/X8LPSMsOJPiCLhTKx927clQvJdJ239iMq32gw== X-Google-Smtp-Source: AGHT+IFTgELGiniy3zspwhILwfQ6tZZeSqWzKg5NIzC/6o8EBcGUX5m24V3c+TJ8PHKa84yt4JeZXA== X-Received: by 2002:a6b:7e05:0:b0:79f:cb49:f476 with SMTP id i5-20020a6b7e05000000b0079fcb49f476mr859321iom.21.1696376147085; Tue, 03 Oct 2023 16:35:47 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Thomas Huth , Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Wainer dos Santos Moschetta , Beraldo Leal , Warner Losh , Kyle Evans , Karim Taha , Richard Henderson Subject: [PULL 44/51] bsd-user: Implment madvise(2) to match the linux-user implementation. Date: Tue, 3 Oct 2023 17:32:08 -0600 Message-ID: <20231003233215.95557-45-imp@bsdimp.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231003233215.95557-1-imp@bsdimp.com> References: <20231003233215.95557-1-imp@bsdimp.com> MIME-Version: 1.0 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: none client-ip=2607:f8b0:4864:20::d36; envelope-from=imp@bsdimp.com; helo=mail-io1-xd36.google.com 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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 @bsdimp-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1696376478267100003 Content-Type: text/plain; charset="utf-8" From: Karim Taha Signed-off-by: Karim Taha Reviewed-by: Richard Henderson Message-Id: <20230925182709.4834-17-kariem.taha2.7@gmail.com> --- bsd-user/bsd-mem.h | 53 +++++++++++++++++++++++++++++++++++ bsd-user/freebsd/os-syscall.c | 4 +++ bsd-user/syscall_defs.h | 2 ++ 3 files changed, 59 insertions(+) diff --git a/bsd-user/bsd-mem.h b/bsd-user/bsd-mem.h index 16c22593bfd..b00ab3aed8e 100644 --- a/bsd-user/bsd-mem.h +++ b/bsd-user/bsd-mem.h @@ -129,6 +129,59 @@ static inline abi_long do_bsd_munlockall(void) return get_errno(munlockall()); } =20 +/* madvise(2) */ +static inline abi_long do_bsd_madvise(abi_long arg1, abi_long arg2, + abi_long arg3) +{ + abi_ulong len; + int ret =3D 0; + abi_long start =3D arg1; + abi_long len_in =3D arg2; + abi_long advice =3D arg3; + + if (start & ~TARGET_PAGE_MASK) { + return -TARGET_EINVAL; + } + if (len_in =3D=3D 0) { + return 0; + } + len =3D TARGET_PAGE_ALIGN(len_in); + if (len =3D=3D 0 || !guest_range_valid_untagged(start, len)) { + return -TARGET_EINVAL; + } + + /* + * Most advice values are hints, so ignoring and returning success is = ok. + * + * However, some advice values such as MADV_DONTNEED, are not hints and + * need to be emulated. + * + * A straight passthrough for those may not be safe because qemu somet= imes + * turns private file-backed mappings into anonymous mappings. + * If all guest pages have PAGE_PASSTHROUGH set, mappings have the + * same semantics for the host as for the guest. + * + * MADV_DONTNEED is passed through, if possible. + * If passthrough isn't possible, we nevertheless (wrongly!) return + * success, which is broken but some userspace programs fail to work + * otherwise. Completely implementing such emulation is quite complica= ted + * though. + */ + mmap_lock(); + switch (advice) { + case MADV_DONTNEED: + if (page_check_range(start, len, PAGE_PASSTHROUGH)) { + ret =3D get_errno(madvise(g2h_untagged(start), len, advice)); + if (ret =3D=3D 0) { + page_reset_target_data(start, start + len - 1); + } + } + } + mmap_unlock(); + + return ret; +} + /* minherit(2) */ static inline abi_long do_bsd_minherit(abi_long addr, abi_long len, abi_long inherit) diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index 7a7ae26793f..b8c44cea0ff 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -831,6 +831,10 @@ static abi_long freebsd_syscall(void *cpu_env, int num= , abi_long arg1, ret =3D do_bsd_munlockall(); break; =20 + case TARGET_FREEBSD_NR_madvise: /* madvise(2) */ + ret =3D do_bsd_madvise(arg1, arg2, arg3); + break; + case TARGET_FREEBSD_NR_minherit: /* minherit(2) */ ret =3D do_bsd_minherit(arg1, arg2, arg3); break; diff --git a/bsd-user/syscall_defs.h b/bsd-user/syscall_defs.h index ff692814333..52f84d5dd17 100644 --- a/bsd-user/syscall_defs.h +++ b/bsd-user/syscall_defs.h @@ -95,6 +95,8 @@ struct bsd_shm_regions { /* * sys/mman.h */ +#define TARGET_MADV_DONTNEED 4 /* dont need these pages */ + #define TARGET_FREEBSD_MAP_RESERVED0080 0x0080 /* previously misimplement= ed */ /* MAP_INHERIT */ #define TARGET_FREEBSD_MAP_RESERVED0100 0x0100 /* previously unimplemente= d */ --=20 2.41.0 From nobody Sun May 19 09:42:24 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1696376701; cv=none; d=zohomail.com; s=zohoarc; b=ZPALX2KDP+Qwg1chGtegusUbXdWdmnZ0m8cFxkHD8wQ5vnl/bXdYhRCOYXuk18Hoyk+G+mfY1K5FEW5sseSuZQvHYtGfrznQJ2t2ZryissPLXws/80yBXR7bndV3J6QV4xAyToigNSETRsEjF0L+schI+BSy/gKOAnRL0CYugP4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696376701; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=PqkFGNnZr4Hir1xs5a2neZwKr2N6dkSvYPZpyI4/s4A=; b=JLehymmnRiowChMuu0Qr0HjpD4EL7TNs039WMskHL0zflHSSg/gW1i22OqsL2JbzKN8xQqyIaPuT3BKoExK+vesLQ1kjXB0T2NPxJeV2UllAQjb4sP7MjSWf/Y+obWP1sbtwIy2ASBQSiJagqfSzJxICUPCXJ7TOEuV0wu4acZc= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1696376701896340.70757858957654; Tue, 3 Oct 2023 16:45:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qnovu-0004Yz-59; Tue, 03 Oct 2023 19:36:08 -0400 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 1qnovm-0004Pc-JB for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:59 -0400 Received: from mail-io1-xd29.google.com ([2607:f8b0:4864:20::d29]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qnove-0007T5-Bs for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:57 -0400 Received: by mail-io1-xd29.google.com with SMTP id ca18e2360f4ac-79f9acc857cso54764539f.2 for ; Tue, 03 Oct 2023 16:35:49 -0700 (PDT) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id w25-20020a6b4a19000000b0079fa1a7cd36sm593596iob.30.2023.10.03.16.35.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 16:35:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1696376148; x=1696980948; 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=PqkFGNnZr4Hir1xs5a2neZwKr2N6dkSvYPZpyI4/s4A=; b=POGwBzSXi82zmQJOXY8JV948drkEgDqBXWDu6Zdnz0SrdG/ZE3bto1BfImqYdzil0E K7srIHOkqH1q52JkTPpQ+4po0xXACyKLprZzgrtMIEi/J3r69q+OipbAH2uUBRAcRz0v tBCDnEWIGrhyZQMfCblbPaYSWPUVPKK/ej/1SFAfvSoVKEHFFfyw7Gd10NhkMWRfIxpD 4EeHzKSBWIbpau/odvBs1/8yzwGYZmNlG9Iy02E+XfPszoPEaeexpzQSrV0A8Ax8jIe7 1ubQIrYPqs2j3sCB3uj86VxXHtyaYu4pr0qBihxcUo7D/Q8VSzMhMSMSMdIYON5btsPY oqRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696376148; x=1696980948; 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=PqkFGNnZr4Hir1xs5a2neZwKr2N6dkSvYPZpyI4/s4A=; b=ivD4kGwxwCMAH6jy1o9ckDueVkF1fuYHDYV75gtWWspg6745LWKZzGpwZBD5qiwCQO zjTDARetIiUTnuoHJ6R3vNUklWDe8NtFij/iKpTZT0rCp6Ev7ysCGfgaCgmFJeTwXyhm MSxcHs7le+dnA3Bvwrcy08+h/BFhZexfSOXhrp5DJhuBE+CnEGaRWyWq2/RZibJXkoyR HCkD2JNcrOPHFc9YIu/9QxqR+IJaCsDwxd3VgaMrc3Ahn97KxZNVEEakuHbb92kJlvmC Lmww3bJfUXZ2kdOTqavJOYJBD8cjeK/cQAgyNuykqoNocwINeAWEeGniY/NgvcWVf+n9 dm4A== X-Gm-Message-State: AOJu0YxxdYuKHyf7FgBdcPCwS/7HYnIhj+2qTKpJnXJe0YCWyjYMD5/W ZDMpZPFHwoDhQuam/RQmS4OsV7ewB+gk08Nzx02Apw== X-Google-Smtp-Source: AGHT+IE8k3C998aY9XOLM13sV0eb+89fAHhmQr2pEZw6OPPLmaYSrl0q+alpWcfbEb5k5ZqcSZcWWQ== X-Received: by 2002:a6b:da06:0:b0:794:d7e8:d239 with SMTP id x6-20020a6bda06000000b00794d7e8d239mr844399iob.17.1696376147942; Tue, 03 Oct 2023 16:35:47 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Thomas Huth , Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Wainer dos Santos Moschetta , Beraldo Leal , Warner Losh , Kyle Evans , Stacey Son , Karim Taha , Richard Henderson Subject: [PULL 45/51] bsd-user: Implement mincore(2) Date: Tue, 3 Oct 2023 17:32:09 -0600 Message-ID: <20231003233215.95557-46-imp@bsdimp.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231003233215.95557-1-imp@bsdimp.com> References: <20231003233215.95557-1-imp@bsdimp.com> MIME-Version: 1.0 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: none client-ip=2607:f8b0:4864:20::d29; envelope-from=imp@bsdimp.com; helo=mail-io1-xd29.google.com 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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 @bsdimp-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1696376702983100001 Content-Type: text/plain; charset="utf-8" From: Stacey Son Signed-off-by: Stacey Son Signed-off-by: Karim Taha Reviewed-by: Richard Henderson Message-Id: <20230925182709.4834-18-kariem.taha2.7@gmail.com> --- bsd-user/bsd-mem.h | 23 +++++++++++++++++++++++ bsd-user/freebsd/os-syscall.c | 4 ++++ 2 files changed, 27 insertions(+) diff --git a/bsd-user/bsd-mem.h b/bsd-user/bsd-mem.h index b00ab3aed8e..0c8d96d9a43 100644 --- a/bsd-user/bsd-mem.h +++ b/bsd-user/bsd-mem.h @@ -189,4 +189,27 @@ static inline abi_long do_bsd_minherit(abi_long addr, = abi_long len, return get_errno(minherit(g2h_untagged(addr), len, inherit)); } =20 +/* mincore(2) */ +static inline abi_long do_bsd_mincore(abi_ulong target_addr, abi_ulong len, + abi_ulong target_vec) +{ + abi_long ret; + void *p; + abi_ulong vec_len =3D DIV_ROUND_UP(len, TARGET_PAGE_SIZE); + + if (!guest_range_valid_untagged(target_addr, len) + || !page_check_range(target_addr, len, PAGE_VALID)) { + return -TARGET_EFAULT; + } + + p =3D lock_user(VERIFY_WRITE, target_vec, vec_len, 0); + if (p =3D=3D NULL) { + return -TARGET_EFAULT; + } + ret =3D get_errno(mincore(g2h_untagged(target_addr), len, p)); + unlock_user(p, target_vec, vec_len); + + return ret; +} + #endif /* BSD_USER_BSD_MEM_H */ diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index b8c44cea0ff..f054241cd62 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -839,6 +839,10 @@ static abi_long freebsd_syscall(void *cpu_env, int num= , abi_long arg1, ret =3D do_bsd_minherit(arg1, arg2, arg3); break; =20 + case TARGET_FREEBSD_NR_mincore: /* mincore(2) */ + ret =3D do_bsd_mincore(arg1, arg2, arg3); + break; + #if defined(__FreeBSD_version) && __FreeBSD_version >=3D 1300048 case TARGET_FREEBSD_NR_shm_open2: /* shm_open2(2) */ ret =3D do_freebsd_shm_open2(arg1, arg2, arg3, arg4, arg5); --=20 2.41.0 From nobody Sun May 19 09:42:24 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1696376661; cv=none; d=zohomail.com; s=zohoarc; b=RIooqoLEn5PROwk4xW137h4d9bSGZNLPdcVyzPeyofvvxXIug5GRj8IDO7tzbvymmeMuK2ul4C9bm1JHwiw/ToAj6d3czvCE9K+/SUwUruzCth4/9gRMPPmAFP0NS9muItOmP3iw6kZIjWdZiI3x4YAOAVM1GK05h65nVhf8ZIM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696376661; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ghXvw1CEOFvx+EvpSHrnuN4yclzjxnuEasAI7tTRTeg=; b=MZBoMVtjvzeOrwQq4M5w1rTPG0GfktnliDTqAaZqoNOBHZ1Olt6oFos7vLqGrqapopSzy5ro/Q1wEDSpGkmT3VAT4jfiLs0QY3Wqnp0vBRfkQ2M5UtSIOjQLxSSU2wxkt5jMLGNiNVfmJAh+6qHexiPZlnfepEoSg46ws9T5E8M= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1696376661006984.4789560174364; Tue, 3 Oct 2023 16:44:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qnovs-0004X1-9e; Tue, 03 Oct 2023 19:36:04 -0400 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 1qnovk-0004M7-ML for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:57 -0400 Received: from mail-io1-xd2a.google.com ([2607:f8b0:4864:20::d2a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qnove-0007TE-AV for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:55 -0400 Received: by mail-io1-xd2a.google.com with SMTP id ca18e2360f4ac-79f9acc857cso54765439f.2 for ; Tue, 03 Oct 2023 16:35:49 -0700 (PDT) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id w25-20020a6b4a19000000b0079fa1a7cd36sm593596iob.30.2023.10.03.16.35.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 16:35:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1696376149; x=1696980949; 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=ghXvw1CEOFvx+EvpSHrnuN4yclzjxnuEasAI7tTRTeg=; b=dRe8swVltzr+HHlLGyuEfxzrHxNxOTb6hIj1KDSitQoFM2ZxeWd/vV1a0CHPHhnjSZ xo+CQ+nwj8gvYM5/DQpEW+WUTr5yGr8HjoiroFlq9SMSpoM43jpjszBaiuiL8CQxxipu Kee5pHAY0Uq8gFtY0314H8Ba+mSePAqvij/HFV/HY+cqkHhUUsexpeQqcz+rjnHx6lzD 6Z/EQ9/XkqXf2derIglgEoNjcifclV85uYAEg7XbsF8BmgxkevVyG/DA4RKqelfwvmyt 0lBrbsBH70uRoTCtIv6R1oHzFW4BLWGuPg08JgYxx+okMmqvbl71bpOZc3m7PBJZGQC9 P/EQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696376149; x=1696980949; 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=ghXvw1CEOFvx+EvpSHrnuN4yclzjxnuEasAI7tTRTeg=; b=EUTQWjmnSyYiPgAEVt+yLdN3w/xs0qSoVP3D7tVnpg12CjuVy68e5+umeRz1lE7GlL J9gc8fAVZYBTNwXJDdmxeUgxrlMFcePobMgO+7S88I2RAfUP4n5HdzeyLTgI7iZaYkZl LCq4SNOdENTIINDoHAxYTLdsq7EHIE3RBfwNp6r+eKjBoNXAJuZCpbQmEUYogYh/izoO HoNX8DS+RzPrBRUfc4oBicIyLYqPFArAB0a6mRoStzTCNgRarb4z03pWtKoEksVAHonO 3rvOvY7gdLjqAwADRSXY9UYlr1yBZOULGG04wViw3vFTK9LcJjA9NRjFT4xqSQ/y3N03 poew== X-Gm-Message-State: AOJu0Yx2sqDeLFVlAr1Sb2TJ4yclSnLeKT4zQcR793SdrDWjsdKtr9iB Dh3Jpn7wtPioxbPGK/Shv/CMHxbGcDHnk+f52/STVg== X-Google-Smtp-Source: AGHT+IF+6wKP+V3wIDGh99xCOo70Dp3HH0MoioiFo/BjpX83WufD5quPu81pZ855r0Y+KzcH7kGOTQ== X-Received: by 2002:a6b:c413:0:b0:79f:99f5:fadd with SMTP id y19-20020a6bc413000000b0079f99f5faddmr868530ioa.6.1696376149011; Tue, 03 Oct 2023 16:35:49 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Thomas Huth , Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Wainer dos Santos Moschetta , Beraldo Leal , Warner Losh , Kyle Evans , Stacey Son , Karim Taha , Richard Henderson Subject: [PULL 46/51] bsd-user: Implement do_obreak function Date: Tue, 3 Oct 2023 17:32:10 -0600 Message-ID: <20231003233215.95557-47-imp@bsdimp.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231003233215.95557-1-imp@bsdimp.com> References: <20231003233215.95557-1-imp@bsdimp.com> MIME-Version: 1.0 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: none client-ip=2607:f8b0:4864:20::d2a; envelope-from=imp@bsdimp.com; helo=mail-io1-xd2a.google.com 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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 @bsdimp-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1696376663131100010 Content-Type: text/plain; charset="utf-8" From: Stacey Son Match linux-user, by manually applying the following commits, in order: d28b3c90cfad1a7e211ae2bce36ecb9071086129 linux-user: Make sure initial br= k(0) is page-aligned 15ad98536ad9410fb32ddf1ff09389b677643faa linux-user: Fix qemu brk() to no= t zero bytes on current page dfe49864afb06e7e452a4366051697bc4fcfc1a5 linux-user: Prohibit brk() to to= shrink below initial heap address eac78a4b0b7da4de2c0a297f4d528ca9cc6256a3 linux-user: Fix signed math over= flow in brk() syscall c6cc059eca18d9f6e4e26bb8b6d1135ddb35d81a linux-user: Do not call get_errn= o() in do_brk() e69e032d1a8ee8d754ca119009a3c2c997f8bb30 linux-user: Use MAP_FIXED_NOREPL= ACE for do_brk() cb9d5d1fda0bc2312fc0c779b4ea1d7bf826f31f linux-user: Do nothing if too sm= all brk is specified 2aea137a425a87b930a33590177b04368fd7cc12 linux-user: Do not align brk wit= h host page size Signed-off-by: Stacey Son Signed-off-by: Karim Taha Reviewed-by: Richard Henderson Message-Id: <20230925182709.4834-19-kariem.taha2.7@gmail.com> --- bsd-user/bsd-mem.h | 45 +++++++++++++++++++++++++++++++++++ bsd-user/freebsd/os-syscall.c | 7 ++++++ 2 files changed, 52 insertions(+) diff --git a/bsd-user/bsd-mem.h b/bsd-user/bsd-mem.h index 0c8d96d9a43..b296c5c6f0a 100644 --- a/bsd-user/bsd-mem.h +++ b/bsd-user/bsd-mem.h @@ -212,4 +212,49 @@ static inline abi_long do_bsd_mincore(abi_ulong target= _addr, abi_ulong len, return ret; } =20 +/* do_brk() must return target values and target errnos. */ +static inline abi_long do_obreak(abi_ulong brk_val) +{ + abi_long mapped_addr; + abi_ulong new_brk; + abi_ulong old_brk; + + /* brk pointers are always untagged */ + + /* do not allow to shrink below initial brk value */ + if (brk_val < initial_target_brk) { + return target_brk; + } + + new_brk =3D TARGET_PAGE_ALIGN(brk_val); + old_brk =3D TARGET_PAGE_ALIGN(target_brk); + + /* new and old target_brk might be on the same page */ + if (new_brk =3D=3D old_brk) { + target_brk =3D brk_val; + return target_brk; + } + + /* Release heap if necesary */ + if (new_brk < old_brk) { + target_munmap(new_brk, old_brk - new_brk); + + target_brk =3D brk_val; + return target_brk; + } + + mapped_addr =3D target_mmap(old_brk, new_brk - old_brk, + PROT_READ | PROT_WRITE, + MAP_FIXED | MAP_EXCL | MAP_ANON | MAP_PRIVAT= E, + -1, 0); + + if (mapped_addr =3D=3D old_brk) { + target_brk =3D brk_val; + return target_brk; + } + + /* For everything else, return the previous break. */ + return target_brk; +} + #endif /* BSD_USER_BSD_MEM_H */ diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index f054241cd62..92793ab1fb3 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -855,6 +855,13 @@ static abi_long freebsd_syscall(void *cpu_env, int num= , abi_long arg1, break; #endif =20 + /* + * Misc + */ + case TARGET_FREEBSD_NR_break: + ret =3D do_obreak(arg1); + break; + /* * sys{ctl, arch, call} */ --=20 2.41.0 From nobody Sun May 19 09:42:24 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1696376409; cv=none; d=zohomail.com; s=zohoarc; b=dufI5aRLkgPnO4RSDLihip1TNGeTy/aE/A+ZMU+Gh7Jp9Ci4Usz82cxgGQDxJwk38BX2SLwFq4WkixZ2ivtINAlndrsHXjovtMy/BuTjmaTs5xwhDMgDuSYZMCxMbOm3NFUZPLlgOl5XUxmR/UMQfLQE9K+jrrdKkW2d1XMgTgU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696376409; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=5o5uCmY06ZAYAK3HvpohN7Kj3r79hSbBC/UkGrV9km8=; b=C5apzv9uZNDtFUHRvSxzt+Lf+mz6imrn3xEAcV269xuDovnl36E0749rKTeQSaYhEa5oVd33EER5h2RGC7h0GD2Lgq+4M4ooClbSFBen3Z7vCbUFsnpa0J8hgCGgq7CDVOcke6Uzx6y+jJ3C8Ow4jf0V6V6oAAlqYJuAqt+svfg= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1696376409617311.94037751559506; Tue, 3 Oct 2023 16:40:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qnow1-0004sg-F5; Tue, 03 Oct 2023 19:36:13 -0400 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 1qnow0-0004qS-7m for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:36:12 -0400 Received: from mail-io1-xd2e.google.com ([2607:f8b0:4864:20::d2e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qnovf-0007TW-SA for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:36:10 -0400 Received: by mail-io1-xd2e.google.com with SMTP id ca18e2360f4ac-79f915e5b47so59914839f.2 for ; Tue, 03 Oct 2023 16:35:50 -0700 (PDT) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id w25-20020a6b4a19000000b0079fa1a7cd36sm593596iob.30.2023.10.03.16.35.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 16:35:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1696376150; x=1696980950; 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=5o5uCmY06ZAYAK3HvpohN7Kj3r79hSbBC/UkGrV9km8=; b=jNsHU9AI9DCpKr8bHG/cbqKN4o7grMASAUbf6FtZv1Lb4QLVytvcXgA9X0UtJ+rUsM v64AQwTmiH1Zm7aWa+rN7xHj/N3p/KKldQQaUu70AoOydMbAy1qLWCRXHX1MiMcJgoYK xPOjFZ/obFsiFE2xZ1alTPyWfxHI68sCSDAmH45ZItxH1+MmSOPp+maMso2/QrZ8UT1v KrvoQGHNzsr/CTqDi6bycs0iknoMr7Mllgy2tOgT5ZGCvh29ojDdpV6S3zMuhIUjZ/MQ H8MEXryEVI98DTvRTWXd6KOfgrrbyKwCOEMU3pljujOoema/cI1rs0bdCXMfihH6Rij5 qgRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696376150; x=1696980950; 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=5o5uCmY06ZAYAK3HvpohN7Kj3r79hSbBC/UkGrV9km8=; b=OVlZoJGaUFUT/toOQYMo3f65ENmr92GQtwdXn6rY39Tfv6tiS90RGADqKw8Wap1NmF SPw0FRX4sXIHe5m9wDQ6jYJ27mccnB9Hkn+tGMYXjlGOfzZFso/jUE5+yY3qZ0FPZQJD kVC61zD4U0ZvvJtLjlqx/s5LQcK2TmbV+YRM5aoOZPLeCex1KlxfmyP5DEnkB6bqn/qj VtifmWJrtjjxO7n5QamJxLRfcdOwcg94TG+drTFd0GN3yDSm6TXeuIuTnAcsjVGYgWhZ zkXTA7yYaMeQlVrpW6z2DHM4KO/5/ZDxJtRJk4OCrBRysOfRp8QyBeNmIek1XmYCbqvG p4ag== X-Gm-Message-State: AOJu0Yzr4CLuwoz+Yj8cD6fgIp8WH1zFN/MWXhwIhg+MxOpnwyrInxVY 4BNd/jM+YTBFBzMQttlQhIbLsT2m5ef+sJmlA6L2LQ== X-Google-Smtp-Source: AGHT+IGlpaFEVbjQZyw51q+z5W4ZE3DAOlQQ4z1pvtOSFHeJ+sOaFH+nw30bfq5o2dJqOijwKaMRxQ== X-Received: by 2002:a5d:9943:0:b0:79f:9eb4:3ea1 with SMTP id v3-20020a5d9943000000b0079f9eb43ea1mr1020336ios.3.1696376149917; Tue, 03 Oct 2023 16:35:49 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Thomas Huth , Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Wainer dos Santos Moschetta , Beraldo Leal , Warner Losh , Kyle Evans , Stacey Son , Kyle Evans , Karim Taha , Richard Henderson Subject: [PULL 47/51] bsd-user: Implement shm_open(2) Date: Tue, 3 Oct 2023 17:32:11 -0600 Message-ID: <20231003233215.95557-48-imp@bsdimp.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231003233215.95557-1-imp@bsdimp.com> References: <20231003233215.95557-1-imp@bsdimp.com> MIME-Version: 1.0 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: none client-ip=2607:f8b0:4864:20::d2e; envelope-from=imp@bsdimp.com; helo=mail-io1-xd2e.google.com 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, SPF_NONE=0.001, T_SPF_HELO_TEMPERROR=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @bsdimp-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1696376410696100005 Content-Type: text/plain; charset="utf-8" From: Stacey Son Co-authored-by: Kyle Evans Signed-off-by: Stacey Son Signed-off-by: Kyle Evans Signed-off-by: Karim Taha Reviewed-by: Richard Henderson Message-Id: <20230925182709.4834-20-kariem.taha2.7@gmail.com> --- bsd-user/bsd-mem.h | 25 +++++++++++++++++++++++++ bsd-user/freebsd/os-syscall.c | 4 ++++ 2 files changed, 29 insertions(+) diff --git a/bsd-user/bsd-mem.h b/bsd-user/bsd-mem.h index b296c5c6f0a..f8dc943c234 100644 --- a/bsd-user/bsd-mem.h +++ b/bsd-user/bsd-mem.h @@ -257,4 +257,29 @@ static inline abi_long do_obreak(abi_ulong brk_val) return target_brk; } =20 +/* shm_open(2) */ +static inline abi_long do_bsd_shm_open(abi_ulong arg1, abi_long arg2, + abi_long arg3) +{ + int ret; + void *p; + + if (arg1 =3D=3D (uintptr_t)SHM_ANON) { + p =3D SHM_ANON; + } else { + p =3D lock_user_string(arg1); + if (p =3D=3D NULL) { + return -TARGET_EFAULT; + } + } + ret =3D get_errno(shm_open(p, target_to_host_bitmask(arg2, fcntl_flags= _tbl), + arg3)); + + if (p !=3D SHM_ANON) { + unlock_user(p, arg1, 0); + } + + return ret; +} + #endif /* BSD_USER_BSD_MEM_H */ diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index 92793ab1fb3..0d4c3118f0d 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -843,6 +843,10 @@ static abi_long freebsd_syscall(void *cpu_env, int num= , abi_long arg1, ret =3D do_bsd_mincore(arg1, arg2, arg3); break; =20 + case TARGET_FREEBSD_NR_freebsd12_shm_open: /* shm_open(2) */ + ret =3D do_bsd_shm_open(arg1, arg2, arg3); + break; + #if defined(__FreeBSD_version) && __FreeBSD_version >=3D 1300048 case TARGET_FREEBSD_NR_shm_open2: /* shm_open2(2) */ ret =3D do_freebsd_shm_open2(arg1, arg2, arg3, arg4, arg5); --=20 2.41.0 From nobody Sun May 19 09:42:24 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1696376252; cv=none; d=zohomail.com; s=zohoarc; b=FbZo+IUSVzypSRkm7v0+XzYJTHM1PXa9RLlGPANEijeVO4iLkevIQlVHfjCVaidY/NW2SND4fb0lr0LoA30LB7J9mJ2RmjuPjqfq63hJWWdyySBE8dibQmvpQv8LJfGn+xNlzTam0FTroCc6AWGwYof/eIDVhZaw4lTJAdhHxN0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696376252; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=MQsJ8aRx34rU+BSo16ILhtd0DDp2FIzYDvvE6gfNhKU=; b=CNKD5zC6WVw06aOiHE2/3zo1/sT1ObsVHWSqTP1zy1SG2Ww/OfYbQtsyqxA5MPgZp9HCcPZwCEGBV22gBex06J1DBW9i0iW0jj5CfaOf1+/vL5aJ1GAzspDNAc6I+9v2TmU012e3WZA2MJhhL14a9LYQXfc1X0zcVTuhWUaKrM0= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1696376252187498.28878932400266; Tue, 3 Oct 2023 16:37:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qnovy-0004nm-6e; Tue, 03 Oct 2023 19:36:10 -0400 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 1qnovq-0004Vi-Af for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:36:02 -0400 Received: from mail-io1-xd35.google.com ([2607:f8b0:4864:20::d35]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qnovg-0007Th-KU for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:58 -0400 Received: by mail-io1-xd35.google.com with SMTP id ca18e2360f4ac-79faba5fe12so57777939f.3 for ; Tue, 03 Oct 2023 16:35:51 -0700 (PDT) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id w25-20020a6b4a19000000b0079fa1a7cd36sm593596iob.30.2023.10.03.16.35.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 16:35:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1696376151; x=1696980951; 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=MQsJ8aRx34rU+BSo16ILhtd0DDp2FIzYDvvE6gfNhKU=; b=C//SUph2bxxglbF/2VxlSQAGkIcHgj22gZ9INDaZgEx/JM5NO3kGJ8zZxhzSvNHo0N DCEJX39+IKuyJnq9FmFS71wDnkkR+/FQil8ZeDasLKDMaLpHMrimHAVgUiVjzRcYQlik qXqmYCPJddQzRBZcTkG0jQ0CMcY6M+FLjyySNuyaszXnl9yYNlg4nRbEMzr6GmjDkEQm aJGQl/QuYF0NP0G6d9034Eb4nMB6YlT50ESePbiE97OA6jXc0tfAByEsdOzKa1vKPnTE pPqlfpYUpaF5wTCNbw+IlG858esVsc+zZcuQCapKtTo2+zvYM81nkbBnlY1Aaj7u/FMG b8GA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696376151; x=1696980951; 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=MQsJ8aRx34rU+BSo16ILhtd0DDp2FIzYDvvE6gfNhKU=; b=da6rIaVvJ80lIcyvk05CdHEKpZUoahc5u/ngpIHGyYxCRQyqtCjXzM3HWWI1DQFpAk aJvQ55+ZZcCNrSe78ibKFHOmYkBUfwnP3QsNNo6TZ2TyNHdzoZCiQEyJlP2x9NC+ZEr0 5umg/pC5/a6qllv0Neo5GAeB146ShJZ/IuX9yyiiV70XXi3IXnSnERYmyrxhQZxJedeP I0lbu8E6RuJxLphDLZ0bUONxx3NuRlWd/+HJKa4HITA1UoX3k23osX62wCSYFTcx0hJ0 LLt6cKzFmifAfve5lVxRyoewvowU0+TUB5ccMWMyJiuRmrapbe9kwHW3WZ9/InupRv2X 9qpg== X-Gm-Message-State: AOJu0YzjzkCiJLXnkiauCTbuilUXdH8imdqNsWfdLOgI0Gs1S8SzX3a2 TyC43uSVPHiFKCZW+lBsAPyZBX1E2AdrFH7R3VImcA== X-Google-Smtp-Source: AGHT+IFO8VMixQfnBRpfHvBiTa0e3rYsXETfRm8ppcSf9j0Fwp71HyQvkUkP2dY6u/QmT4gTFfEqKA== X-Received: by 2002:a5d:9943:0:b0:79f:d194:d6e2 with SMTP id v3-20020a5d9943000000b0079fd194d6e2mr1054628ios.10.1696376150744; Tue, 03 Oct 2023 16:35:50 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Thomas Huth , Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Wainer dos Santos Moschetta , Beraldo Leal , Warner Losh , Kyle Evans , Stacey Son , Karim Taha , Richard Henderson Subject: [PULL 48/51] bsd-user: Implement shm_unlink(2) and shmget(2) Date: Tue, 3 Oct 2023 17:32:12 -0600 Message-ID: <20231003233215.95557-49-imp@bsdimp.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231003233215.95557-1-imp@bsdimp.com> References: <20231003233215.95557-1-imp@bsdimp.com> MIME-Version: 1.0 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: none client-ip=2607:f8b0:4864:20::d35; envelope-from=imp@bsdimp.com; helo=mail-io1-xd35.google.com 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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 @bsdimp-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1696376254152100007 Content-Type: text/plain; charset="utf-8" From: Stacey Son Signed-off-by: Stacey Son Signed-off-by: Karim Taha Reviewed-by: Warner Losh Reviewed-by: Richard Henderson Message-Id: <20230925182709.4834-21-kariem.taha2.7@gmail.com> --- bsd-user/bsd-mem.h | 23 +++++++++++++++++++++++ bsd-user/freebsd/os-syscall.c | 8 ++++++++ 2 files changed, 31 insertions(+) diff --git a/bsd-user/bsd-mem.h b/bsd-user/bsd-mem.h index f8dc943c234..c362cc07a30 100644 --- a/bsd-user/bsd-mem.h +++ b/bsd-user/bsd-mem.h @@ -282,4 +282,27 @@ static inline abi_long do_bsd_shm_open(abi_ulong arg1,= abi_long arg2, return ret; } =20 +/* shm_unlink(2) */ +static inline abi_long do_bsd_shm_unlink(abi_ulong arg1) +{ + int ret; + void *p; + + p =3D lock_user_string(arg1); + if (p =3D=3D NULL) { + return -TARGET_EFAULT; + } + ret =3D get_errno(shm_unlink(p)); /* XXX path(p)? */ + unlock_user(p, arg1, 0); + + return ret; +} + +/* shmget(2) */ +static inline abi_long do_bsd_shmget(abi_long arg1, abi_ulong arg2, + abi_long arg3) +{ + return get_errno(shmget(arg1, arg2, arg3)); +} + #endif /* BSD_USER_BSD_MEM_H */ diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index 0d4c3118f0d..4f67677eb92 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -859,6 +859,14 @@ static abi_long freebsd_syscall(void *cpu_env, int num= , abi_long arg1, break; #endif =20 + case TARGET_FREEBSD_NR_shm_unlink: /* shm_unlink(2) */ + ret =3D do_bsd_shm_unlink(arg1); + break; + + case TARGET_FREEBSD_NR_shmget: /* shmget(2) */ + ret =3D do_bsd_shmget(arg1, arg2, arg3); + break; + /* * Misc */ --=20 2.41.0 From nobody Sun May 19 09:42:24 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1696376675; cv=none; d=zohomail.com; s=zohoarc; b=V+ch0my7NdhW9qVLCfkwRJqbg/8e/ktJ7Wmt0XlzgC/P7VvrVix6m3tvLkhTo5Ul2wixBQRBwAQv9C1HealMpeWrypzy/fdDLFzf5piEE5tcfV01oye2djDxvXVE4JXT478M5ddzAZC1OX8fXWTagVLGPa7IXisw+hcJI7V+f+8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696376675; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=5Vsuy4csP7DLV7i/HttRGs3+j2Bhu0vejsp7G9mGTsU=; b=SCxexhd3DDh4WyUk0ysuHVj7EG3Mdo95nBhZ3UofKbF9XJukbv7wpSHH1taXzh8NJKSvNzQ/7xqiYlqVtX6VxTu1wce7Bqdn66adcNqWh9DPijJJhw2rmNZVNdHviCAPeJMOKmJgzK677XFbAqFeFU9D0QnLGxO0D0xadsxbazg= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1696376675120619.8463875552377; Tue, 3 Oct 2023 16:44:35 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qnovx-0004k2-05; Tue, 03 Oct 2023 19:36:09 -0400 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 1qnovq-0004Vk-BE for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:36:02 -0400 Received: from mail-io1-xd34.google.com ([2607:f8b0:4864:20::d34]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qnovj-0007Tu-P5 for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:59 -0400 Received: by mail-io1-xd34.google.com with SMTP id ca18e2360f4ac-79fa7e33573so58992439f.0 for ; Tue, 03 Oct 2023 16:35:53 -0700 (PDT) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id w25-20020a6b4a19000000b0079fa1a7cd36sm593596iob.30.2023.10.03.16.35.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 16:35:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1696376151; x=1696980951; 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=5Vsuy4csP7DLV7i/HttRGs3+j2Bhu0vejsp7G9mGTsU=; b=M59Z5raogs6+TpWLVQ6iHPKjprtsTaUXch+tExhjU9GUHxCrfcS0ElL0nZPqVrS5te w1j5X2WzWchCv3tZ62B7UEpH8nSQ3XfFesp+J3gLhygioOzqUi5QauY72OuY3c4ImD7j lFbMSTMRSZIkwOOlnLvZ96SUozy2B1Ut79n5lyz/K5CGrku8QKgNIpvVmx53RgynaXtg 4JzrlrVfmADQAuWvLTfqM9R6tShJI+3d0oJSwT6qW0MEPmX3Dy690Ncx9xIsMaaykp08 PEsWyGQ7Jofw3uO4Fu0sTAtUAnTX25QxKQdTzuggZe2dK6lX59atdEIrT4WsXRLiQAqW MxPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696376151; x=1696980951; 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=5Vsuy4csP7DLV7i/HttRGs3+j2Bhu0vejsp7G9mGTsU=; b=xACo9D8JXsI51B3gRBPgr/C/DU3dmwFLFsDtnRLv3e6JZ5Swy8ZFZaP3RfPgQP7nDi rF1cQvAoNCnsQMdDDERLhU0T0aXMCI7g/Zd1DAnYiymHNjhl2+2NTX3tI0/S/GbRf2V4 XjMWGFEJgTc/hbJV4eu6hGBGAR6u16r80nX39/4fbjreaJT0XgboOfdQQ8WgwGk4meQ8 twO81AwgDMAtycAnIX/96DmkFqUoA0RcvEJg3Eelh0Y0DDpCZ0/zcaGsaOdTWMD69gKc hGdtD/pBdrwFiPH8CNwTnQ9sFqMeRHd5OjQTfBqxRKus057Cdjv1Mi0cjur/15/RMSBf rUmw== X-Gm-Message-State: AOJu0YymOgwb++qCkmLZuFP/GQQms+yyAGl5dIvl6bP/EGnMeywQHf6q zYZhYIJxlvcfz5s40Y9cx7zQcra0O7kNC8CT5a6L3A== X-Google-Smtp-Source: AGHT+IFKM6vGvz5V+n5lUQ8G0tphd58TGHC6BBWwHIJMXox8P1sm8B9mdnB0Bl8PBb1CcY4B3xjyvQ== X-Received: by 2002:a5e:dd0d:0:b0:786:7100:72de with SMTP id t13-20020a5edd0d000000b00786710072demr895824iop.16.1696376151658; Tue, 03 Oct 2023 16:35:51 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Thomas Huth , Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Wainer dos Santos Moschetta , Beraldo Leal , Warner Losh , Kyle Evans , Stacey Son , Karim Taha , Richard Henderson Subject: [PULL 49/51] bsd-user: Implement shmctl(2) Date: Tue, 3 Oct 2023 17:32:13 -0600 Message-ID: <20231003233215.95557-50-imp@bsdimp.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231003233215.95557-1-imp@bsdimp.com> References: <20231003233215.95557-1-imp@bsdimp.com> MIME-Version: 1.0 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: none client-ip=2607:f8b0:4864:20::d34; envelope-from=imp@bsdimp.com; helo=mail-io1-xd34.google.com 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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 @bsdimp-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1696376677269100007 Content-Type: text/plain; charset="utf-8" From: Stacey Son Signed-off-by: Stacey Son Signed-off-by: Karim Taha Reviewed-by: Richard Henderson Message-Id: <20230925182709.4834-22-kariem.taha2.7@gmail.com> --- bsd-user/bsd-mem.h | 39 +++++++++++++++++++++++++++++++++++ bsd-user/freebsd/os-syscall.c | 4 ++++ 2 files changed, 43 insertions(+) diff --git a/bsd-user/bsd-mem.h b/bsd-user/bsd-mem.h index c362cc07a30..b82f3eaa253 100644 --- a/bsd-user/bsd-mem.h +++ b/bsd-user/bsd-mem.h @@ -305,4 +305,43 @@ static inline abi_long do_bsd_shmget(abi_long arg1, ab= i_ulong arg2, return get_errno(shmget(arg1, arg2, arg3)); } =20 +/* shmctl(2) */ +static inline abi_long do_bsd_shmctl(abi_long shmid, abi_long cmd, + abi_ulong buff) +{ + struct shmid_ds dsarg; + abi_long ret =3D -TARGET_EINVAL; + + cmd &=3D 0xff; + + switch (cmd) { + case IPC_STAT: + if (target_to_host_shmid_ds(&dsarg, buff)) { + return -TARGET_EFAULT; + } + ret =3D get_errno(shmctl(shmid, cmd, &dsarg)); + if (host_to_target_shmid_ds(buff, &dsarg)) { + return -TARGET_EFAULT; + } + break; + + case IPC_SET: + if (target_to_host_shmid_ds(&dsarg, buff)) { + return -TARGET_EFAULT; + } + ret =3D get_errno(shmctl(shmid, cmd, &dsarg)); + break; + + case IPC_RMID: + ret =3D get_errno(shmctl(shmid, cmd, NULL)); + break; + + default: + ret =3D -TARGET_EINVAL; + break; + } + + return ret; +} + #endif /* BSD_USER_BSD_MEM_H */ diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index 4f67677eb92..0512d41db7c 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -867,6 +867,10 @@ static abi_long freebsd_syscall(void *cpu_env, int num= , abi_long arg1, ret =3D do_bsd_shmget(arg1, arg2, arg3); break; =20 + case TARGET_FREEBSD_NR_shmctl: /* shmctl(2) */ + ret =3D do_bsd_shmctl(arg1, arg2, arg3); + break; + /* * Misc */ --=20 2.41.0 From nobody Sun May 19 09:42:24 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1696376596; cv=none; d=zohomail.com; s=zohoarc; b=CRLxwjBG/9K5blZMUdAGWycC+L4T6FHRXlx3Zk20BTukGgFT3MkVNIwQHfVwszzcrm/rJBa3wkXTWzYl43StEJ5ObFQZFIXeM/krKkaGmC6oZBNvn8SsRmAYojBGeieARXk2g8T1DekTwdWf+GX7A42I0JOQ4XcJwmxmG241zLw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696376596; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=0xs6F3bQ3X0JBHAPx4Ith6fLrpCOwQaP480klykNHXU=; b=mQZKnk+DyFXqicLSR2zcDqcGZzw6giBx5q8d2TNK8+LI8X3AZLMJJIBLdvjrgdr5u2xMIrbmFhElG/RLaSKp/0XChbChv8ykjcJjKJPXtQolZafs7AA3EaaSn/gxDrU/ZxFcVVS9SQwg8rifFEUTXEFcjLQj+0PP+oJbQAq8HkU= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1696376596318257.25941776743366; Tue, 3 Oct 2023 16:43:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qnovy-0004nf-78; Tue, 03 Oct 2023 19:36:10 -0400 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 1qnovq-0004Vj-Aq for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:36:02 -0400 Received: from mail-io1-xd30.google.com ([2607:f8b0:4864:20::d30]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qnovl-0007U2-EN for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:59 -0400 Received: by mail-io1-xd30.google.com with SMTP id ca18e2360f4ac-79fe8986355so59690739f.2 for ; Tue, 03 Oct 2023 16:35:53 -0700 (PDT) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id w25-20020a6b4a19000000b0079fa1a7cd36sm593596iob.30.2023.10.03.16.35.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 16:35:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1696376152; x=1696980952; 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=0xs6F3bQ3X0JBHAPx4Ith6fLrpCOwQaP480klykNHXU=; b=1jXBHGD/moKy7aVUCLb8K9wscR71p5HJndlfTLDp4jf5AORG6Grqq9ZJfZUtvJe/3g SLnvyw7LDJ2csQVUzqf8cBPrui4sDgTs7akMXyJRFQfRICT+Gh0C342bAX+rI9hTr3r4 jZgVIveKPTZJR8HDXXrH3EabMaOzYWa7VVPSqkPNoP6YYuNHJVdtIXSTMtGf8RDl7QbE ufIp5cCilPf6eZDgYNdyfIF3Z3xYaK/ZK1e7xPZkEbGDLVXh8b2ubHT/Xa4H23QlSOwP reqIPpMiKcS57m5GkfYrHHwbK0CqYVAh3/m3RUUZfxCPiah0f6681nUAz9K4Dmqk9GYV truw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696376152; x=1696980952; 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=0xs6F3bQ3X0JBHAPx4Ith6fLrpCOwQaP480klykNHXU=; b=psTzFHjFsEKhNLwq5xMp/nb6QHB9Mp+n8ShDlvIPW021Lp6ytwfqPC2iif2sTDeJiu RNFKUeg+j7QnEdaE6P6b/kCazwfi2IJ5zsAVuHEfcZc7LNqwpoOaAmw/sw8+KOEwigeE dFhsW3Idgug1XM8zRUcMRdzx0BL305e2b2avX4s4lmvvSkdR0D2tKkG+76CxGz4CCD6d rCTT1ik/GikuQtRsc6ANvuOHZbF74gDxX6e6h44vP8wAgjK7bOum+NUt92iEsZqqPto6 BlW+HmUOOciwpOj0ekt6XdjVfWIF1VZkSuPUyi9gr0OwVG0pXJzDSU/Y2poVul7dP6KL v+7A== X-Gm-Message-State: AOJu0YxfmcseR/EijHX/SD4QeT2wZi8guwjAo9KB/Dw9nj98AKpeeOrg IMsh8Am4S4O6WgJ4fJ0+rVhnv7VfV8TbcdTcfq0miA== X-Google-Smtp-Source: AGHT+IF8WUqyCpk83nfDn3hIHdJ5tPbzsXtgSwyPH/X++I1YLXERXzMqlKkSrChUGOHxIMFHnMIY7w== X-Received: by 2002:a5e:8c15:0:b0:787:1472:3181 with SMTP id n21-20020a5e8c15000000b0078714723181mr1027873ioj.3.1696376152518; Tue, 03 Oct 2023 16:35:52 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Thomas Huth , Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Wainer dos Santos Moschetta , Beraldo Leal , Warner Losh , Kyle Evans , Stacey Son , Karim Taha Subject: [PULL 50/51] bsd-user: Implement shmat(2) and shmdt(2) Date: Tue, 3 Oct 2023 17:32:14 -0600 Message-ID: <20231003233215.95557-51-imp@bsdimp.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231003233215.95557-1-imp@bsdimp.com> References: <20231003233215.95557-1-imp@bsdimp.com> MIME-Version: 1.0 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: none client-ip=2607:f8b0:4864:20::d30; envelope-from=imp@bsdimp.com; helo=mail-io1-xd30.google.com 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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 @bsdimp-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1696376596637100001 Content-Type: text/plain; charset="utf-8" From: Stacey Son Use `WITH_MMAP_LOCK_GUARD` instead of mmap_lock() and mmap_unlock(), to match linux-user implementation, according to the following commits: 69fa2708a216df715ba5102a0f98468b540a464e linux-user: Use WITH_MMAP_LOCK_GUA= RD in target_{shmat,shmdt} ceda5688b650646248f269a992c06b11148c5759 linux-user: Fix shmdt Signed-off-by: Stacey Son Signed-off-by: Karim Taha Message-Id: <20230925182709.4834-23-kariem.taha2.7@gmail.com> --- bsd-user/bsd-mem.h | 87 +++++++++++++++++++++++++++++++++++ bsd-user/freebsd/os-syscall.c | 8 ++++ bsd-user/mmap.c | 2 +- bsd-user/qemu.h | 1 + 4 files changed, 97 insertions(+), 1 deletion(-) diff --git a/bsd-user/bsd-mem.h b/bsd-user/bsd-mem.h index b82f3eaa253..c512a4e3756 100644 --- a/bsd-user/bsd-mem.h +++ b/bsd-user/bsd-mem.h @@ -344,4 +344,91 @@ static inline abi_long do_bsd_shmctl(abi_long shmid, a= bi_long cmd, return ret; } =20 +/* shmat(2) */ +static inline abi_long do_bsd_shmat(int shmid, abi_ulong shmaddr, int shmf= lg) +{ + abi_ulong raddr; + abi_long ret; + struct shmid_ds shm_info; + + /* Find out the length of the shared memory segment. */ + ret =3D get_errno(shmctl(shmid, IPC_STAT, &shm_info)); + if (is_error(ret)) { + /* Can't get the length */ + return ret; + } + + if (!guest_range_valid_untagged(shmaddr, shm_info.shm_segsz)) { + return -TARGET_EINVAL; + } + + WITH_MMAP_LOCK_GUARD() { + void *host_raddr; + + if (shmaddr) { + host_raddr =3D shmat(shmid, (void *)g2h_untagged(shmaddr), shm= flg); + } else { + abi_ulong mmap_start; + + mmap_start =3D mmap_find_vma(0, shm_info.shm_segsz); + + if (mmap_start =3D=3D -1) { + return -TARGET_ENOMEM; + } + host_raddr =3D shmat(shmid, g2h_untagged(mmap_start), + shmflg | SHM_REMAP); + } + + if (host_raddr =3D=3D (void *)-1) { + return get_errno(-1); + } + raddr =3D h2g(host_raddr); + + page_set_flags(raddr, raddr + shm_info.shm_segsz - 1, + PAGE_VALID | PAGE_RESET | PAGE_READ | + (shmflg & SHM_RDONLY ? 0 : PAGE_WRITE)); + + for (int i =3D 0; i < N_BSD_SHM_REGIONS; i++) { + if (bsd_shm_regions[i].start =3D=3D 0) { + bsd_shm_regions[i].start =3D raddr; + bsd_shm_regions[i].size =3D shm_info.shm_segsz; + break; + } + } + } + + return raddr; +} + +/* shmdt(2) */ +static inline abi_long do_bsd_shmdt(abi_ulong shmaddr) +{ + abi_long ret; + + WITH_MMAP_LOCK_GUARD() { + int i; + + for (i =3D 0; i < N_BSD_SHM_REGIONS; ++i) { + if (bsd_shm_regions[i].start =3D=3D shmaddr) { + break; + } + } + + if (i =3D=3D N_BSD_SHM_REGIONS) { + return -TARGET_EINVAL; + } + + ret =3D get_errno(shmdt(g2h_untagged(shmaddr))); + if (ret =3D=3D 0) { + abi_ulong size =3D bsd_shm_regions[i].size; + + bsd_shm_regions[i].start =3D 0; + page_set_flags(shmaddr, shmaddr + size - 1, 0); + mmap_reserve(shmaddr, size); + } + } + + return ret; +} + #endif /* BSD_USER_BSD_MEM_H */ diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index 0512d41db7c..39e66312da1 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -871,6 +871,14 @@ static abi_long freebsd_syscall(void *cpu_env, int num= , abi_long arg1, ret =3D do_bsd_shmctl(arg1, arg2, arg3); break; =20 + case TARGET_FREEBSD_NR_shmat: /* shmat(2) */ + ret =3D do_bsd_shmat(arg1, arg2, arg3); + break; + + case TARGET_FREEBSD_NR_shmdt: /* shmdt(2) */ + ret =3D do_bsd_shmdt(arg1); + break; + /* * Misc */ diff --git a/bsd-user/mmap.c b/bsd-user/mmap.c index 8e148a2ea3e..3ef11b28079 100644 --- a/bsd-user/mmap.c +++ b/bsd-user/mmap.c @@ -636,7 +636,7 @@ fail: return -1; } =20 -static void mmap_reserve(abi_ulong start, abi_ulong size) +void mmap_reserve(abi_ulong start, abi_ulong size) { abi_ulong real_start; abi_ulong real_end; diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h index 6047805ae38..dc842fffa7d 100644 --- a/bsd-user/qemu.h +++ b/bsd-user/qemu.h @@ -233,6 +233,7 @@ abi_long target_mremap(abi_ulong old_addr, abi_ulong ol= d_size, 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); +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 --=20 2.41.0 From nobody Sun May 19 09:42:24 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1696376229; cv=none; d=zohomail.com; s=zohoarc; b=fVM72PnqExy3rE0G6SoHqEenVQDity5Ty/nwiQxfVKAfBh/TSTj8m7kr974lk7qdJjeUghnGyofLTi1fp6oyJeMSmBgDR4tjvMofH87VequijaMfyO22TMJFL7IWsAyub12Mu79q9s1an2//bpUXvj2xsiR0SYdlU0b/65JJldQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696376229; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=8QWoVmGnb5jKyajwly1l0ccTXwxvqdiZY2ICtiENtz8=; b=O8YF+3Pd2Ikb9H23ekcbD6Bs91Sy6SzEyX8id3igeBhX4ZDP47XZmjFAWjSlK3QiujmLUPea3wE2QLD/PAwNGG0YeLf/YJ4y2CAyU+e0pyGmZ5UmvF8AU82jyFKQCYgtLHZZjqxPaGbHaR+m4gSsfouHqIJxIeF3cyepEC6j+k8= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1696376229319825.8136462535072; Tue, 3 Oct 2023 16:37:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qnovw-0004jR-UQ; Tue, 03 Oct 2023 19:36:08 -0400 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 1qnovs-0004X2-Al for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:36:04 -0400 Received: from mail-io1-xd2b.google.com ([2607:f8b0:4864:20::d2b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qnovl-0007UD-Ef for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:36:02 -0400 Received: by mail-io1-xd2b.google.com with SMTP id ca18e2360f4ac-79fce245bf6so58311539f.1 for ; Tue, 03 Oct 2023 16:35:54 -0700 (PDT) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id w25-20020a6b4a19000000b0079fa1a7cd36sm593596iob.30.2023.10.03.16.35.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 16:35:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1696376153; x=1696980953; 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=8QWoVmGnb5jKyajwly1l0ccTXwxvqdiZY2ICtiENtz8=; b=gkjYgtDvyF0zIskyJuTyf1wGj2gNyW+qI5ogHfrGNbSXFstR9blxtfZKIczpxgBy8C AGljVIM20G1aaA3MN5IZZgc5vlPqxfLgFVvAVNl6vQVKTJ03KF05geYjm7p8A51eIb9b sUDTHWApUEolZHquRITvps+J5nPGRrc7Xr11E8TVQ2LsgUuZGavFUkt8uwGIoX+D8ALs /kUljWQjYPoloTsHJ+ick8ehK4RFCrPROAJ7ZEsvrmMHZL5XRyIMxyyFP01Bkrzvisb8 M92/+pDl0uB8f0du840dp7igcKsswy7ELokl9jKtsLVzN04/ijIxkYks/yDIQIr4QAQg ATFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696376153; x=1696980953; 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=8QWoVmGnb5jKyajwly1l0ccTXwxvqdiZY2ICtiENtz8=; b=ther5flVnUbEt7KhpXeeMoZgTsurNPfAv+crdJeiRjc8EdFfVXk9fTCdbqZ+5ScHaf RCsb4uCPQniNtGFGQdbs63zRZ0rO0MaXas0kGY3KKtz2lsrUT9e9KBi44F6DI8SV8n6d sRpNmAPCmtn1jGRpAjY7mFi/ic3ax163Veria4uM0fqU47Hrx7YOnmL34PaSMeqR5yRc 9lMQjEkLKAcYuhHy7Tu/q5j2qJcaJumONsB8PHMho/FqbunfvnspNZWK2xprnq713OxY dZF0pfreT9X7jwqnJaRa6yk/ir4hY8zPYLrJu+6XXVjynx0Kq+UJK6BEfK14QDVF+nln hpvw== X-Gm-Message-State: AOJu0Yz4AUQQBtdMBy5s4wWJ3Sg6m23hwUITX21QPaHdAS1AOjc//CRl 0T7ZrZeyZQpTiZLvFX57r2Dn1U4p2EDUbgsTdq6/GQ== X-Google-Smtp-Source: AGHT+IGpkD2xsr+rgxMVyqd7hKzw9lQxrbyv+l7sgWG+Q+Nt0Y3px9eKMI3FBNQmiBHE4HGgj+PMQg== X-Received: by 2002:a6b:dc0a:0:b0:795:12b0:c2a1 with SMTP id s10-20020a6bdc0a000000b0079512b0c2a1mr933073ioc.10.1696376153327; Tue, 03 Oct 2023 16:35:53 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Thomas Huth , Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Wainer dos Santos Moschetta , Beraldo Leal , Warner Losh , Kyle Evans , Karim Taha , Richard Henderson Subject: [PULL 51/51] bsd-user: Add stubs for vadvise(), sbrk() and sstk() Date: Tue, 3 Oct 2023 17:32:15 -0600 Message-ID: <20231003233215.95557-52-imp@bsdimp.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231003233215.95557-1-imp@bsdimp.com> References: <20231003233215.95557-1-imp@bsdimp.com> MIME-Version: 1.0 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: none client-ip=2607:f8b0:4864:20::d2b; envelope-from=imp@bsdimp.com; helo=mail-io1-xd2b.google.com 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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 @bsdimp-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1696376230904100004 Content-Type: text/plain; charset="utf-8" The above system calls are not supported by qemu. Signed-off-by: Warner Losh Signed-off-by: Karim Taha Reviewed-by: Richard Henderson Message-Id: <20230925182709.4834-24-kariem.taha2.7@gmail.com> --- bsd-user/bsd-mem.h | 18 ++++++++++++++++++ bsd-user/freebsd/os-syscall.c | 12 ++++++++++++ 2 files changed, 30 insertions(+) diff --git a/bsd-user/bsd-mem.h b/bsd-user/bsd-mem.h index c512a4e3756..c3e72e3b866 100644 --- a/bsd-user/bsd-mem.h +++ b/bsd-user/bsd-mem.h @@ -431,4 +431,22 @@ static inline abi_long do_bsd_shmdt(abi_ulong shmaddr) return ret; } =20 +static inline abi_long do_bsd_vadvise(void) +{ + /* See sys_ovadvise() in vm_unix.c */ + return -TARGET_EINVAL; +} + +static inline abi_long do_bsd_sbrk(void) +{ + /* see sys_sbrk() in vm_mmap.c */ + return -TARGET_EOPNOTSUPP; +} + +static inline abi_long do_bsd_sstk(void) +{ + /* see sys_sstk() in vm_mmap.c */ + return -TARGET_EOPNOTSUPP; +} + #endif /* BSD_USER_BSD_MEM_H */ diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index 39e66312da1..ca2f6fdb66e 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -879,6 +879,18 @@ static abi_long freebsd_syscall(void *cpu_env, int num= , abi_long arg1, ret =3D do_bsd_shmdt(arg1); break; =20 + case TARGET_FREEBSD_NR_freebsd11_vadvise: + ret =3D do_bsd_vadvise(); + break; + + case TARGET_FREEBSD_NR_sbrk: + ret =3D do_bsd_sbrk(); + break; + + case TARGET_FREEBSD_NR_sstk: + ret =3D do_bsd_sstk(); + break; + /* * Misc */ --=20 2.41.0