From nobody Tue May 14 15:16:59 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; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1694986917; cv=none; d=zohomail.com; s=zohoarc; b=l9E6366rOx4Dn6JR3naJ00nJNMkxXVzkJ+EjALH6cAxhJrm/Vh5lXjDalD5fPP2uh0BSGsDqiZdz1CdJ2d3qzEq0Oh7K+0GE/LveFYEAAeLKPZMgMJ9KG9Da0XymcAq1O0osWnqI7dz78KnzjCD2pmsdOlxl7VeQ0s7NYwGA0fE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694986917; 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=4xyYvDm6vr5FBlsfvLve2y0GH2jJ4Bm4yKdVTAQCQ7A=; b=IQnctP0BzNUkQHqZe2EE3pGn32P958x8lldHmwwDI4t+wfD3Nth3reEKDKc3p3QxaJ4JdR6uoi6Bw64JgQzhs87EKaJxZjAbaLgQlqibFiSsARd8dutIkGRjeCVYOliU7xHW3fnW51vHTmLrn9wEPLWvu84X55PGXawXXaqekjI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694986917189640.9005288856273; Sun, 17 Sep 2023 14:41:57 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qhzUM-0004Rw-BT; Sun, 17 Sep 2023 17:39:34 -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 1qhzUK-0004RC-ID for qemu-devel@nongnu.org; Sun, 17 Sep 2023 17:39:32 -0400 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qhzUI-0004EV-In for qemu-devel@nongnu.org; Sun, 17 Sep 2023 17:39:31 -0400 Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-3214de9cd8bso418626f8f.2 for ; Sun, 17 Sep 2023 14:39:30 -0700 (PDT) Received: from karim.my.domain ([197.39.215.8]) by smtp.gmail.com with ESMTPSA id n11-20020a5d484b000000b00317ddccb0d1sm10561735wrs.24.2023.09.17.14.39.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 14:39:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694986769; x=1695591569; 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=4xyYvDm6vr5FBlsfvLve2y0GH2jJ4Bm4yKdVTAQCQ7A=; b=GOBiTGEX34Ox9qWdEPsVT+f+9UfvMsFG+ox7b40DE+t2HIIV7p+m+fiR/YJbXgm00u 52ROo7Fskg/cqY2Uw9DqZBgdMmPQGYrb3etyldQVn+zQeafl/+d1zA3fQhqivNmsRTC3 iST6QK+q1JVpR9Yx6BERrg9Gz4KT9NNU+Ng32mg5ESm4n3+Pv9GGf7N64zT+/4MhMZaw XnCghVz88PBhiU6eomUfSyED5Q6wZvu6K/6bGnIgcUc/o9vWMnAFOQPVTGuzQdICMmZ2 I77Or9HUSwgZ1rNMjCkC0FwZ79kPx2XthhlA+92CzcP4/xj/4B8NVez/PC8bIpkhoOmM ctUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694986769; x=1695591569; 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=4xyYvDm6vr5FBlsfvLve2y0GH2jJ4Bm4yKdVTAQCQ7A=; b=vrmbgNTmvIDynVYLtjyV5Eapy37tBder4dbErkXUqP1OB3058dyzObooTO7d+KNOhF UOSkw26DYaxJ+2CGsIyIHmqRtooghMO38Ms3dsWnnAkk/7s7TQsQymvooZtay49LjWFK kbDjdXhn9cIF4qDmtPGhRjFA0W/AKIudDKpqdxlP8/a3OmGywMIT4ADRbg+ZqsJ9lcI6 kC9XDzFzzwnbubgGEtDALoMLYId3CAqqp4spFEYzlDAS/SsaQsYZBWhzF6dd9jUzp4CA nyjdwRxib1ffkAkzXV7SXxtqUVMTkFF1DslTt0kIV+3uoxYdvMaXsF1XJ3FGWcWK7eCt U93g== X-Gm-Message-State: AOJu0YxTczm944SwT4etbPk5yiR06oQUExNPiv+dHIiG8pC6kTh0sU0/ tr6ku9dvwUimvrvWmRk6GOT0LjAEViU= X-Google-Smtp-Source: AGHT+IHSv+V7gJr27VpQNDxBkUjCI+0Hbxa2NkUGlZrsOMn2516xiYxQkyjrLI27b6HtBPXLbSB2SA== X-Received: by 2002:adf:de90:0:b0:31f:a4fa:130a with SMTP id w16-20020adfde90000000b0031fa4fa130amr7690469wrl.14.1694986768525; Sun, 17 Sep 2023 14:39:28 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: imp@bsdimp.com, Richard Henderson , Karim Taha , Kyle Evans Subject: [PATCH v2 01/28] bsd-user: define TARGET_RFSPAWN for rfork to use vfork(2) semantics, and fix RLIM_INFINITY Date: Mon, 18 Sep 2023 00:37:36 +0300 Message-ID: <20230917213803.20683-2-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230917213803.20683-1-kariem.taha2.7@gmail.com> References: <20230917213803.20683-1-kariem.taha2.7@gmail.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: pass client-ip=2a00:1450:4864:20::436; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wr1-x436.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1694986917737100009 Content-Type: text/plain; charset="utf-8" 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 --- 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 9c90616baa..ddd38c13e0 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.42.0 From nobody Tue May 14 15:16:59 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; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1694986915; cv=none; d=zohomail.com; s=zohoarc; b=fii2m1zlapufSG0oBAWsempWik1N98QhF3RAWookzpjx8eV68/naFrBK4IFQgSSZOBqaGPvCceiVXtaetoGxBbDO5krPSyllfRYq7+zaiXOhsgiBRXY8ZQps1utcam99LogUiaW9HJZCaKG4+xvrAtafwyMMqah3xoWhEtt4/PY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694986915; 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=rUP8g2y0GYSaHwIi9+PE/D/jagxt1ep3Rybvm1zGJcc=; b=kslTiv9EDZWSVyJFRhDjkUOIQUheMQOlqWaKcFiWJv6xHL2/PaL/CenPduxPnv1bNDYcitFZ8lyd917X0F6O7uuD6A6CaGMNDKMK90qKpBd5dObwg+/AZM+KRnfSbNZ5LDdQtC8k7V+EWl7+UMp6kXmqTfnWTJv7CA94sLYh45U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694986915131223.52589732026865; Sun, 17 Sep 2023 14:41:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qhzUN-0004S9-Bm; Sun, 17 Sep 2023 17:39: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 1qhzUL-0004RT-8R for qemu-devel@nongnu.org; Sun, 17 Sep 2023 17:39:33 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qhzUJ-0004Eb-ER for qemu-devel@nongnu.org; Sun, 17 Sep 2023 17:39:33 -0400 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-401f68602a8so42727085e9.3 for ; Sun, 17 Sep 2023 14:39:30 -0700 (PDT) Received: from karim.my.domain ([197.39.215.8]) by smtp.gmail.com with ESMTPSA id n11-20020a5d484b000000b00317ddccb0d1sm10561735wrs.24.2023.09.17.14.39.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 14:39:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694986770; x=1695591570; 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=rUP8g2y0GYSaHwIi9+PE/D/jagxt1ep3Rybvm1zGJcc=; b=DQhqIskI6oYTMtyQqRJXvvUvZVQk75JLuAlv3r9uvxgpDING0rP390iZllgnDH8BgX jrEnAbB+TO6IMZlGrEUC87kBOtLMe5/kGK3uCHK/w8VNxoeRczgN9T/hr2L+OgT7UeVl svN9MdpqMX6E0dVPX0b5E05a5KfEzvfvPra8mcNZY36nmTnDU9fvLhoWO9LwF8suVUS8 SOTVHOLSBZTU3VjZIWPx7EDVeNzk0iz7qTQWclomV+zrWITnO9JSIC+XlC7iiUw1Q0dV fDfGefzmhfZDqFymSr7CM7iuZ93Ij7Kfns2N365V/4YGHkyNNsLfrixeHCpbYEZuy8Bv s0tg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694986770; x=1695591570; 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=rUP8g2y0GYSaHwIi9+PE/D/jagxt1ep3Rybvm1zGJcc=; b=MGpUe409zxlzoJ4tC1weRnU0TI5moIP6WrZA6pp2UoFTYsBYamCZJ0Yrd0pOq2hjM0 ajU9YTmffhG8c5sQuHd4FEKCKLJvDTqUX1Tc8u429JWbnRzwLWTRyJCCGnfzRvRAIexT AKn1WsqagVM6Bl5XuRolgM3w9LRWqErLVxoLnkk5yfaTDWm4E3D0ubOxN2at5tb0r2NY EBj6WlTzaCH/0zNBR2czJDJVNDiEK/KeB+ak5MfQxU5hPGpNopvgKuy9bQKmMgzlofcv XRB4lCiBLmEZbVbin/M0Z3alHIVK8uPVbJ5smmsk0KPZvjzlF/HH/ufzYHq96K+M3BMX DYhw== X-Gm-Message-State: AOJu0YynH6m0mfs8cWcK0fQCjot+8/oUSncZDtX6cTt4gZZwY9/CR4kD Gy57zEn4jvvXOzeWs1mxdFIoBnE1fsA= X-Google-Smtp-Source: AGHT+IEu6+H1TV9SN2OO0w5uFO6jrj2x/ArxAIdBmUyeed0Y69p2DshPjvvMXkFjzTkSWF1muPf8PQ== X-Received: by 2002:a05:600c:2057:b0:3fe:d1b9:7ea9 with SMTP id p23-20020a05600c205700b003fed1b97ea9mr6743705wmg.36.1694986769709; Sun, 17 Sep 2023 14:39:29 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: imp@bsdimp.com, Richard Henderson , Stacey Son , Karim Taha Subject: [PATCH v2 02/28] bsd-user: Define procctl(2) related structs Date: Mon, 18 Sep 2023 00:37:37 +0300 Message-ID: <20230917213803.20683-3-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230917213803.20683-1-kariem.taha2.7@gmail.com> References: <20230917213803.20683-1-kariem.taha2.7@gmail.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: pass client-ip=2a00:1450:4864:20::335; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wm1-x335.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1694986916906100007 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 --- 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 ddd38c13e0..a3bc738ff8 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.42.0 From nobody Tue May 14 15:16:59 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; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1694986869; cv=none; d=zohomail.com; s=zohoarc; b=h6pL6hO/OBBUEJn9/v0WNomVi4lG+QWfV2Zf/y14Ni9ElD83+5vRO4RckIujz9X/4vMXAFSc/z2jZrZmsajv5BnAu4znEcviWjFnCNnVb1p0stD6kcZ7DGv0KdAsAX9vmmnAiqqfJZZ95y5XYL1f4WYZ0woGf58z35/CSKZyjbM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694986869; 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=6AJdtgHq9fYznWnCzA7KoMOc1RO9pIOiwcxEQMuC6hk=; b=FmDBg3Lt9IeWRnjP44+cctS0CgfJFdTM5yjLkmiCOMFtedEL0Yvwji64bl3eG7BDPw60l5eromUUVgniGSbnuGf9ygIvqbNcNCm/FsdEHxquIS0qK9x6GJwrgZL4EE4pQTvrUesSLwFPTPLuFUlRGAClkQ/HHe11y+204HLNrxw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16949868690081004.7503953984057; Sun, 17 Sep 2023 14:41:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qhzUO-0004Se-0N; Sun, 17 Sep 2023 17:39: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 1qhzUM-0004Rd-5X for qemu-devel@nongnu.org; Sun, 17 Sep 2023 17:39:34 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qhzUK-0004Ei-Hu for qemu-devel@nongnu.org; Sun, 17 Sep 2023 17:39:33 -0400 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-403004a96a4so43804105e9.3 for ; Sun, 17 Sep 2023 14:39:32 -0700 (PDT) Received: from karim.my.domain ([197.39.215.8]) by smtp.gmail.com with ESMTPSA id n11-20020a5d484b000000b00317ddccb0d1sm10561735wrs.24.2023.09.17.14.39.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 14:39:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694986771; x=1695591571; 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=6AJdtgHq9fYznWnCzA7KoMOc1RO9pIOiwcxEQMuC6hk=; b=Yd0t+eH68Za6yLDnVM1Qm1mzGk5g/yX6Wz6PR5DuDk7zApBqP7EUhKv041O4rv+rN2 UpfOr5WBrmxlr0jfniZUunr0hmiv04On4L7WW+1yzyY7BD5XfBLB2tBZC4Tzbfd/TGxY yzAxhBUz+PZj9cfNQZx7IeRzt7Xh55t49nSjTaXiJXIMl4tY1saN/tY2cKIT16K2kTQs Gmu8Wn22vUqN6L6sk4I+IKrEsT3CAHoglGmM0ReSrhfFoUwMjT4I6wukE/eOieO8lYd7 ZdKEJHAZUFr4brG7R1wIwE5wC7aXEKDGY+b0wN3VZfwWMJJ0gLbvTM7ljrHupPtDZ7/A zdFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694986771; x=1695591571; 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=6AJdtgHq9fYznWnCzA7KoMOc1RO9pIOiwcxEQMuC6hk=; b=V2BbeeIECtLvQK4UJEr67DYLS8GXrpZhQseqGwv8H5xnWPqc192JWUdtFk53HQy7Ge sYPjpCeroR14SrQntysbHkg6EQiefrNtMLhi+MJL3UWQuhYW1tGPyyKL7Ruscd5MdHGC sDxYQP9mOuvkQMpytBj8RN1J6kCR69CuLcyRYWQAaLDviv8NeM2nR4msstzSeDx7c6u5 bMuq431cwyRzfo8E8SHh27lv7ymF3BNw1KUScSXbPdK9LSMWRAtVY8REujxPYL6gkhZE sVrRSN+ys/tHnW+QNf3VQqAjbKhtvitopnJAvscz7yeuQ+HndrRhYYNkXF+mZvlLh1cE +p+g== X-Gm-Message-State: AOJu0YyxiHUdxTB0PECsjGjkF7KMnL/AnqlIBHOW1Mcstys/FvuJv/1K UjhY3zFUYVkyXmvaR4C9p6pL23BHLeg= X-Google-Smtp-Source: AGHT+IGaXLvFEypDVInQLGBn5jOJQ2LqkDPkqJgJfmfFC9DfG8EIXHrnSmJfD8H1RFik52UC1j0bXw== X-Received: by 2002:a1c:720f:0:b0:3fb:feb0:6f40 with SMTP id n15-20020a1c720f000000b003fbfeb06f40mr6836410wmc.11.1694986770979; Sun, 17 Sep 2023 14:39:30 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: imp@bsdimp.com, Richard Henderson , Stacey Son , Karim Taha Subject: [PATCH v2 03/28] bsd-user: Implement host_to_target_siginfo. Date: Mon, 18 Sep 2023 00:37:38 +0300 Message-ID: <20230917213803.20683-4-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230917213803.20683-1-kariem.taha2.7@gmail.com> References: <20230917213803.20683-1-kariem.taha2.7@gmail.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: pass client-ip=2a00:1450:4864:20::329; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wm1-x329.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1694986870640100007 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 --- 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 6f90345bb2..e37e1c3f9c 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 4db85a3485..3ee2ceb910 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.42.0 From nobody Tue May 14 15:16:59 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; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1694986811; cv=none; d=zohomail.com; s=zohoarc; b=eyQy8C4kHkiKPgzgq/0rIqWkYRgvTphc3Wwah/nujPD0QZDZ7B1SaiCs6cFdPATaA+bTDeoIJNASs8dCwvUzAdMvi3cg3mWLrarH+vLPK1VW6MgbB0K0vANA8D+jcPS7YTePy0N2xjlwYlowun+0zsR0ue6OiPLdSCEV92/vEIE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694986811; 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=WF9rPxUO3cPdaNIEzhYsX6B/whcPjXI3AQNo+xWFSaI=; b=YcOxqsvPqA8N93BPZZ2WZRp1XBwqJMpkdaXc8s23a+KhO77AFH/AKxpMxgwMTc5LG9Fgy9pRbqxMGpM3It6YQgI5dR/7iNfwjdiSbab/PNdWvL+s+GM4983DlzFHNPOEefgGoKi6LOuWzz+tXsI5w7yxSBtc7h6Yl//EkchjY+c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694986811098959.399044454449; Sun, 17 Sep 2023 14:40:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qhzUO-0004T2-Je; Sun, 17 Sep 2023 17:39: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 1qhzUN-0004S3-4q for qemu-devel@nongnu.org; Sun, 17 Sep 2023 17:39:35 -0400 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qhzUL-0004F0-Mx for qemu-devel@nongnu.org; Sun, 17 Sep 2023 17:39:34 -0400 Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-31f7400cb74so3409244f8f.2 for ; Sun, 17 Sep 2023 14:39:33 -0700 (PDT) Received: from karim.my.domain ([197.39.215.8]) by smtp.gmail.com with ESMTPSA id n11-20020a5d484b000000b00317ddccb0d1sm10561735wrs.24.2023.09.17.14.39.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 14:39:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694986772; x=1695591572; 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=WF9rPxUO3cPdaNIEzhYsX6B/whcPjXI3AQNo+xWFSaI=; b=klP5lP0Mi1UAm+TTSECGiYrilHF2nlC2FXJrwaoUFLBreY3NFv71hT8ozA+Rl+Y3G7 3paz4qhglR/V1X8QgNtfLYqk0vZ1+pegri2FdDNxp6IzJkzxP5eFQ3iw6qM26MOIH+4G qCXiQF8Fukomyr7DW5iXC5pz2Dtv21G6oqgbOXL6KFl05ioHgrkd+nJRDS3a14MrH2TD hEH+5190k1IA3BhkSaGf1inoaiZlYOgHs/m35TRySyp8yr2W1k2576u7csXxtUbSQIE4 asgUYWtI2m+mXHmlZ2xrcniXvWLc2KDXuHFczooCEOO6/0kG0mdL6auXItTf0Qrl5IjR XKKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694986772; x=1695591572; 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=WF9rPxUO3cPdaNIEzhYsX6B/whcPjXI3AQNo+xWFSaI=; b=OyPyi1XgEpTcxUDYNkwvtdhdze/P9rkrC2cRyiTAn0zzvZvS8wEoFWJZTU/5UoGZ7P 1iGFWI2KAvGOHVyetSEDf+FpWl8DMQ7nEk2lXRrnhyXn5ctItWeW8dRVgLxEVSnjMp76 ukzgQqcewBwB/o6IJEid9miy4zmubj6VxAx5pazQ7N9coo89oQrWMawO9t1JuRyZu/V+ lweOz0DxOVYxUsjTI6MyGY58cgbLNLuH5irHFYSmOMIO71XjgTTGBMwWMxjFDqBwZnZI hAEm+VsRLIbXS0tqwxRysyqs3gb/OL+EuSdyY5KvcTL902onXjt4hdC4ATFS9OMjFp+B QwQQ== X-Gm-Message-State: AOJu0YxM0BuZx99rdCuvjzV7r8atiS+OWG6KmH718P//j+CuoO9Kj1J7 HBWks5+Wy/CFAyP0pcGgMCQqlS5f4b8= X-Google-Smtp-Source: AGHT+IGqeLh1mpurWsaMU38IZbbM3sd9ZcmGSV59B0Bhv1KvhWgyHYNbQTCzdJW840hqBFFZiLXW3g== X-Received: by 2002:adf:e18b:0:b0:31f:fa1a:83fb with SMTP id az11-20020adfe18b000000b0031ffa1a83fbmr5728278wrb.7.1694986772118; Sun, 17 Sep 2023 14:39:32 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: imp@bsdimp.com, Richard Henderson , Stacey Son , Karim Taha Subject: [PATCH v2 04/28] bsd-user: Add freebsd_exec_common and do_freebsd_procctl to qemu.h. Date: Mon, 18 Sep 2023 00:37:39 +0300 Message-ID: <20230917213803.20683-5-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230917213803.20683-1-kariem.taha2.7@gmail.com> References: <20230917213803.20683-1-kariem.taha2.7@gmail.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: pass client-ip=2a00:1450:4864:20::431; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wr1-x431.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1694986813224100003 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 --- bsd-user/qemu.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h index d3158bc2ed..2cf96d9a15 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.42.0 From nobody Tue May 14 15:16:59 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; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1694986921; cv=none; d=zohomail.com; s=zohoarc; b=gAKeELu2favcP7DF/tbeqvPLSS3eEl3tp/6wazA6yTlrhIx0dGCvGYva+SEjOrxIGu62c/fTuhBYBvdQwhzxxHdfsW6ZH7G1stdXFO3nGQYpOBVB6NK6qDu5tdQek65XcqNl/nuycl61edTeVfSdqUoMvJFbpYnQ+TKf1uufhA4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694986921; 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=zzVZUygPnc0xMYEmryNsNXyk8Md93nZ92t99k9OH81k=; b=WOxdOfrKvAdresr7Rw4VfOmAFW7UBe2Dgc6Zrmw+uU1HJBKQTMI3PyFZz7Drpmkr45xX7uBhjEwoBxNZZdGBfwSaz/5zDtxltZ025SxthXCpPiMcvgl5J+pMEn8qYqmDiKWVpjPdPo6ZgV14Xy6p4EOU9MBgJNWdkDJsnjjQ9Ak= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694986921886501.99768119047576; Sun, 17 Sep 2023 14:42:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qhzUQ-0004VX-SZ; Sun, 17 Sep 2023 17:39: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 1qhzUO-0004T3-Jg for qemu-devel@nongnu.org; Sun, 17 Sep 2023 17:39:36 -0400 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qhzUM-0004FE-V0 for qemu-devel@nongnu.org; Sun, 17 Sep 2023 17:39:36 -0400 Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-32001d16a14so1218528f8f.1 for ; Sun, 17 Sep 2023 14:39:34 -0700 (PDT) Received: from karim.my.domain ([197.39.215.8]) by smtp.gmail.com with ESMTPSA id n11-20020a5d484b000000b00317ddccb0d1sm10561735wrs.24.2023.09.17.14.39.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 14:39:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694986773; x=1695591573; 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=zzVZUygPnc0xMYEmryNsNXyk8Md93nZ92t99k9OH81k=; b=cpvDejG/LpqRAZ20Aji8NjPHw6ttRogMi8RLNFC6q183KpFWj6iKKWlBqwH7pLucI3 md5qb+GSM0EyRO+yonek0OrhcLIeKnjfHRx8K3ytoFlWI59VLZxkjRIhepX18iVxYDUz TomzBAoZaNedOwxMvvIAY79N7yRWe95t5zLGwNJiiwB/eNFiKLFabGLtcZELrKxizaoi M+cQdBng6Jl2RKQZmyc4MoW+2JFmqeikEIC4jHGA7or9GmGVR9rqP6d0htnzxrC/Da4B hI+BOKtrtqfo8c0eLqGm4RI4L1yys674TwuMFO+afaPrV7JIzkkkHT6cBhicStFCxClv ahoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694986773; x=1695591573; 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=zzVZUygPnc0xMYEmryNsNXyk8Md93nZ92t99k9OH81k=; b=asVE6ePCQ1ax2yzYjSBCfoYroEREVPnSIbIvvrgX5VhcfQ31Y/bHQLbtCEfU7pDtzd oV+QKbmrI13a6DKlfMjO8qMVOg9TXAjObDUvaquRedEXmbPldqhADJ10sPRACOuV7NXR CJbAw15EPTLsdc/WoBhNZ5CAPNOkzrZAIi9urbTdLYkSOhtCFDQvp6668IunNexTHTzQ FO1i+Wtk+6pIAY1EnJ0xfE39WVcGk7cKmbLlAsdOj8goGCg/UnM14KV8q7wxL+hQ1/wM hvLCFTkVnsSNZ0JE9wqRgTHyKkK0/7EujbRUDp2mEClFLqzYp+IZkuDN8ZaDKDpH4bhj 3tnw== X-Gm-Message-State: AOJu0Yw+3THg6tp+73GLXJrkd6ljKJXzKi5/qc4X9yBo7UG1HWSK9FBF lvBkHdzqJHywrA1EgYw8Hj86stpdaJo= X-Google-Smtp-Source: AGHT+IHZk6WHin2euna1pbj+jufI4q+OVRFPEyEchBra9+OP02GD90RfvxASLCmoB46OqPhl5gUI0g== X-Received: by 2002:a5d:54c1:0:b0:31f:97e2:a924 with SMTP id x1-20020a5d54c1000000b0031f97e2a924mr6098382wrv.14.1694986773340; Sun, 17 Sep 2023 14:39:33 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: imp@bsdimp.com, Richard Henderson , Stacey Son , Karim Taha Subject: [PATCH v2 05/28] bsd-user: add extern declarations for bsd-proc.c conversion functions Date: Mon, 18 Sep 2023 00:37:40 +0300 Message-ID: <20230917213803.20683-6-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230917213803.20683-1-kariem.taha2.7@gmail.com> References: <20230917213803.20683-1-kariem.taha2.7@gmail.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: pass client-ip=2a00:1450:4864:20::42d; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wr1-x42d.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1694986922944100005 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 --- 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 0000000000..b93a0b7fd5 --- /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.42.0 From nobody Tue May 14 15:16:59 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; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1694986923; cv=none; d=zohomail.com; s=zohoarc; b=ST5nZOBTzhzm48GPsjPZ8XF2XHiDzwCMfS28JjxHC1E2ih3wCvO4oyyZkVWBt8EqIgD13/1NrqhMIf9dpfVEiWcOGUgj0MVzMoAa1hOR7sxQnbpxevelwRkbfqxOvU8h2aHdW/grDcF8enGelrHmnACN1j6PMxz3rZCQ0kKpZm4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694986923; 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=u1vmTkZas+Mn1wLG44nID34aYL1fdKfYh9PS0Nb3bf0=; b=QIKvk8yZjwoFzxxgrWsiH0jrBWab9QSl/TzE/uNB11l0+W+8e3tfbMAFjkUXHMBo8tddoMjxKdjp2d3fcDPLN982kNDMToDkE2YznnwvieJfE1/5vdGJRZp3XYOC/N2XiMB4/Pt2kHCmWbvvjCVM5kN7XxC5TAazoH3Y16hvf1U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694986923357186.21999045079065; Sun, 17 Sep 2023 14:42:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qhzUR-0004Vj-Ft; Sun, 17 Sep 2023 17:39: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 1qhzUP-0004UN-OB for qemu-devel@nongnu.org; Sun, 17 Sep 2023 17:39:37 -0400 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qhzUO-0004FP-2h for qemu-devel@nongnu.org; Sun, 17 Sep 2023 17:39:37 -0400 Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-31fa15f4cc6so3726935f8f.2 for ; Sun, 17 Sep 2023 14:39:35 -0700 (PDT) Received: from karim.my.domain ([197.39.215.8]) by smtp.gmail.com with ESMTPSA id n11-20020a5d484b000000b00317ddccb0d1sm10561735wrs.24.2023.09.17.14.39.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 14:39:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694986774; x=1695591574; 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=u1vmTkZas+Mn1wLG44nID34aYL1fdKfYh9PS0Nb3bf0=; b=RbrQc40JdC1JsYsgrtpIdoyQybLRf6cMNZ0p61J4Zuz8v6G4D7x9KHyWLGLa8DAtql neTvcm88qc7szQWL40NEuahZ6b+HMR+n8B0ZJfRz6isGgn22AK7RRlpMd0l6VDQa78mD 61kD2ZQurk79Rz2I9Ue//UhwhxWTelpaWtDF368SugLcHvBsahOTIcxuWd/GA5OjdlGP jMPQOIPFgV7R1WlBtuvmsfLtmUyLtccVFPzUGb3eYKuoDYhA/NIqeo+RWPf/+pSRdgS/ yWKE1Gz2RtjkfYZaOzi1Zse1qi9f2TVNQO+MIuwsD+/5nNmVaA0XQBZLJ0R4Tk0ecQGC bTyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694986774; x=1695591574; 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=u1vmTkZas+Mn1wLG44nID34aYL1fdKfYh9PS0Nb3bf0=; b=g6B33CU1gnZ9ut7T62orDiYxBgWG0hez3gtbr2CG5wUtPjOBbZ9IP4KV5asBIV7egr jnhtFvpG1uc6wNttbF7SYRJ+DJjd5UE6e9Sty1Wgbci7yCkX0FgKrRljrUzggNvJmb9r /8QLfN4m/U88EgDPQi7W201rsLhi+epuYnYFLotEmnMM6Vv1vzdICvpW+WzR1s+Wvzqi PV/kJOfffqrR7R2bvCFBfJzTPlVFOcRT3Xo04nk0/i/fbkhgozf12opki+G29iuIRhdT TUs7f6LhtIVzWgYnwI0GnHAh2c6mX2DzOq3m7sq8Pk7cOjfXwCVAKCcbvfT05HGHHm8O XXlQ== X-Gm-Message-State: AOJu0Yxt8MDYMrIgJNEjxPkHB/ClWhXp1huwzdDXWrQIsBRP8lxrA2ms 78EBk+jg2V2r4vT0ONjGz5QhCDElZio= X-Google-Smtp-Source: AGHT+IF42lktu9FJLWE9/D33Lvsc1U4lIDwUxYfqDdKYGXrAMb4/W9+Hc0IFCNvtobtIhK70hyelWg== X-Received: by 2002:adf:a40c:0:b0:31f:fa1b:bbb3 with SMTP id d12-20020adfa40c000000b0031ffa1bbbb3mr4459562wra.40.1694986774367; Sun, 17 Sep 2023 14:39:34 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: imp@bsdimp.com, Richard Henderson , Stacey Son , Karim Taha Subject: [PATCH v2 06/28] bsd-user: Implement target_to_host_resource conversion function Date: Mon, 18 Sep 2023 00:37:41 +0300 Message-ID: <20230917213803.20683-7-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230917213803.20683-1-kariem.taha2.7@gmail.com> References: <20230917213803.20683-1-kariem.taha2.7@gmail.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: pass client-ip=2a00:1450:4864:20::42b; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wr1-x42b.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1694986924004100012 Content-Type: text/plain; charset="utf-8" From: Stacey Son Signed-off-by: Stacey Son Signed-off-by: Karim Taha --- 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 0000000000..68410a0aa9 --- /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 a1061bffb8..048773a75d 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 5243122fc5..b97fce1472 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.42.0 From nobody Tue May 14 15:16:59 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; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1694986862; cv=none; d=zohomail.com; s=zohoarc; b=B74MWQNGELPeDCjw1CejZXelpYy7M9FRuQmeQ9DJElXad6I+UTKEJyD8siTtBI7QuJW2X/ppelSBduhLxV3TXpqAed+pW131XgWai63vOUVFL3heXW+950++KVYSuS8q9n0ygeFHiDoim786BNA7nbkiDn8zA9JjzNFjaqvMUxI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694986862; 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=yw1dyfbeN3ouZtpJ+EsLMpnbrhAyvsGjO2B8aC+yH6E=; b=CQ5sSrOrm9kVr79xDee6rlreiPRXQmU9oM2uIBginNx+x9jCoPcoFAaRPEU5oqwumLCIGNGxUhxj3PUAafK4NbnaDQsUIn45REKBvJ9qiemcHzNPUrHgHJxJdN1DdX/IpRLAlx8i2btRIqwlOVXPW19mKgbwyt8f1qp/+95OWLM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694986862136160.9508551607655; Sun, 17 Sep 2023 14: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 1qhzUS-0004W0-4W; Sun, 17 Sep 2023 17:39: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 1qhzUR-0004VY-5V for qemu-devel@nongnu.org; Sun, 17 Sep 2023 17:39:39 -0400 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qhzUP-0004Fb-MP for qemu-devel@nongnu.org; Sun, 17 Sep 2023 17:39:38 -0400 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-402d499580dso42001465e9.1 for ; Sun, 17 Sep 2023 14:39:37 -0700 (PDT) Received: from karim.my.domain ([197.39.215.8]) by smtp.gmail.com with ESMTPSA id n11-20020a5d484b000000b00317ddccb0d1sm10561735wrs.24.2023.09.17.14.39.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 14:39:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694986776; x=1695591576; 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=yw1dyfbeN3ouZtpJ+EsLMpnbrhAyvsGjO2B8aC+yH6E=; b=VXVOWguCbuNLkdlaED0NqMwhNQ4gRCySgcOkC+Xv44hOYezLelmARX6UZbex3rx4RO wA87j/u396SX7qVOBhutS0KGpkqLVR1l+tqRwQDDfypju2u+AkkdoSGrqJkK7tYThtM+ pW+DbwLrM5QSIaKNQabh5s5H2II73dv9ugGM0dlwQVKwAKIFh1R/SLeyfX6a28rcCRkw 9c0RsCbVJt/qDF8Y6c1lKlMa4E/5yH3MjMXtxdsHRcagq0OZzsDqz11uuLDUImaq3dOL 4Jh/bpR/1DRYMgPzeMfge5vins0OVrzGgP9GbRW3zGY3XxIlHk//QJWpUOywOj3MzTWC 1hLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694986776; x=1695591576; 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=yw1dyfbeN3ouZtpJ+EsLMpnbrhAyvsGjO2B8aC+yH6E=; b=AREE7MsUrO5jzfv0PiKRqBbLHyoMniZr32rUlxRN668VffLs6p9gUu3XhcFWwQSSwt PqgVWlUnHqMvXRxblNgR0/7hOHjc4VrMpf7R04UAnkxqub2+/d3gIWgBDTij4YQZ3WEY zypFwygpTTofyqOIdc3gY1Tlzf0Meu5POPpxtTZHCassbEPz8RpJ1WangSxKMXNsxVrx cnJ4R9YGZGOyUeFNOWnBssBDqQyx4pc3j+avdM+h6am3q6hG3fOgeawJY50Q6BE5GiEK Cla0zWFwYDsji+70bpvADkTZdJOxCqOUFfLljniVQrm2wwUihf2IntYXauQC+6iBdgXt H5PA== X-Gm-Message-State: AOJu0Yyd1b23pX+8uOGKo61loO+U31j6iadCygd1hL+aPYRtCLjnIK0x FJHqRfzXfUhEu6RyY7yX4VZSaM8pBjs= X-Google-Smtp-Source: AGHT+IG4ATdtN1ghyB3V/fwnYaMS8NyjA13exQYG25oG8rf/YvBQMStTCF1J5dSbeuy+w6Dq+351ZA== X-Received: by 2002:adf:e748:0:b0:31f:e759:d68e with SMTP id c8-20020adfe748000000b0031fe759d68emr5877417wrn.58.1694986775613; Sun, 17 Sep 2023 14:39:35 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: imp@bsdimp.com, Richard Henderson , Stacey Son , Karim Taha Subject: [PATCH v2 07/28] bsd-user: Implement target_to_host_rlim and host_to_target_rlim conversion. Date: Mon, 18 Sep 2023 00:37:42 +0300 Message-ID: <20230917213803.20683-8-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230917213803.20683-1-kariem.taha2.7@gmail.com> References: <20230917213803.20683-1-kariem.taha2.7@gmail.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: pass client-ip=2a00:1450:4864:20::32b; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wm1-x32b.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1694986863256100002 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 --- 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 68410a0aa9..19e39a2f76 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.42.0 From nobody Tue May 14 15:16:59 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; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1694987007; cv=none; d=zohomail.com; s=zohoarc; b=dutybSEaIngSiWetW+rKzufV+mxQhmpwWbBm0L7Prp99lW8sV1kwvlPgPLtmEjuRReudxJo5RPbNaNsnS4z669/DI84V8RnixpKqMHp2731HYUWfeeJX8GR0hChMLXiq6C3gm5XTJDPIAL2F1PkkWYvh5HppzTMMRohkSATelI4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694987007; 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=HB1r6vri6wZU6JRWVjYo0sYtxx/vxZGkhUe0qob/CIg=; b=CQlyA3AXGCqjrYCAb2u7D9A7hSejl+yZaHauk3jTlgFVDx0v1D3xz0jvEHVdtVv2eiDwlu/v7HWdiAKhs7jn+E7B4p+buYFkHedUk/STcdQ/4f15GVvfHzJeokU8E1fi/sM3/PEp7tumnlcQyUiForgr8G/BGrFgOg1F47cLQqw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694987007974408.69959024619413; Sun, 17 Sep 2023 14:43:27 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qhzUT-0004Wp-J0; Sun, 17 Sep 2023 17:39:41 -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 1qhzUS-0004W1-CT for qemu-devel@nongnu.org; Sun, 17 Sep 2023 17:39:40 -0400 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qhzUQ-0004Fk-ON for qemu-devel@nongnu.org; Sun, 17 Sep 2023 17:39:40 -0400 Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-32008e339adso940032f8f.2 for ; Sun, 17 Sep 2023 14:39:38 -0700 (PDT) Received: from karim.my.domain ([197.39.215.8]) by smtp.gmail.com with ESMTPSA id n11-20020a5d484b000000b00317ddccb0d1sm10561735wrs.24.2023.09.17.14.39.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 14:39:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694986777; x=1695591577; 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=HB1r6vri6wZU6JRWVjYo0sYtxx/vxZGkhUe0qob/CIg=; b=R2SMevOZv27Gvn2rHho2LD/ac/ZXiBFTDPmmTu2MWfiO6fbbFjLb6Zq1zhlL+hesXm x90YP4UmwwPYn4XUXIh4Z+jgmWqyCjumvY0lXaGKIHwi5SduJu2PN/uFDwL1m1DCWzpn oGYH4ZGB5OVh0iPctziHTyqM5VfGld2Hj2w5DnOd5CAX7V7lJ/AcOJtkYIytHW0VD1qX y+8Io8QFRaMWYIteqnYUtMfdUyF3G4+Qod2fWm+gh9flzIHCYKGeE+cFWqPZX3EDr7LN /HoRyhyQhJYb+WMekTo0vJ499GsSLqvIoW8fodQFSZ+lOp0anRPozKedC2WYnmaPVeE8 Nwgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694986777; x=1695591577; 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=HB1r6vri6wZU6JRWVjYo0sYtxx/vxZGkhUe0qob/CIg=; b=n+hQDTGHfsWO8YTF2H2pBVE8TkWPV5VbBbO0AVoW/w0Wp8ugP+q3Sb61Qt3RWR5gHQ 7Z8h6XTKdJ8iqRdpYjKFqDD5XlkJECFLZQRbfcAWjGkNYdbb/dh5LS29ZOsEPLOE347r QCPud2ubkUFAsVSH3aTGi1f0iD7ulacfp8/GhSOho9FvZRUf6c9vQre4y81VPX3FINnN SAVTcncJ2ZDDZuXukLekyZMm1EYisMgKgtauKX1DGBhA1ODmKPgN0A7T89xVFh3xyoZ/ S4YMAUZc59NMgS6U3jo7hNtxGumE/VGmAdMCGi+m2NgYZRQ09h6dUHfO4Rr9yoMY1llT hmlQ== X-Gm-Message-State: AOJu0YxjVLnHRy6tgqZBNaSb7qptuy31oAQKjlEqRnis1JTOPMCP1DkW JZK2E9D7JvQePeB8fjf6ZKIajqFqfyQ= X-Google-Smtp-Source: AGHT+IFZCj8rCHwjzuNAzBVr/0YIL35ldtP6tOpPdGHPrZKJaN/uveIuYZ6PQB3x5ZP0Ad/JGJKF1A== X-Received: by 2002:a5d:4209:0:b0:31f:ef77:67e8 with SMTP id n9-20020a5d4209000000b0031fef7767e8mr4689613wrq.13.1694986776710; Sun, 17 Sep 2023 14:39:36 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: imp@bsdimp.com, Richard Henderson , Stacey Son , Karim Taha Subject: [PATCH v2 08/28] bsd-user: Implement host_to_target_rusage and host_to_target_wrusage. Date: Mon, 18 Sep 2023 00:37:43 +0300 Message-ID: <20230917213803.20683-9-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230917213803.20683-1-kariem.taha2.7@gmail.com> References: <20230917213803.20683-1-kariem.taha2.7@gmail.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: pass client-ip=2a00:1450:4864:20::431; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wr1-x431.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1694987008584100006 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 --- 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 19e39a2f76..aa386ff482 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.42.0 From nobody Tue May 14 15:16:59 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; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1694987007; cv=none; d=zohomail.com; s=zohoarc; b=JdSPgtYjy89aQ+FrEdSCpN3SGn3bZIN6rKqi67ZoDxSjXUKhR1r0Q30XZU7tpq01DO5/LN2AsI9+qxNe1/JFv+OlEE38vEvCRALXIFEdBpjsrKdY8PagBHpf3pL8fvJ7UR9XkMYCLwaj6w+rOV3m7PjrWQCDLKDiCn13fve8J0k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694987007; 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=tytbz2GrtArc4cKJgoRBdOuRp5xjR4etKhXFM07GeUo=; b=cN9w0cAGvTrE1tyNz7NQb3HUXMQimmKhyGle3FnyiFSBWlIvNaSIhxfEFuEcUnRxkQvdnF0YnJS8jmSSCa+Oe8I6SZAFBK+H0ZPcu/8OCFI8/Tht4t4i4Sb9FJw80dZVMWS7HYwqwnZd0k6UTfxi2xiETam5lRqm5wEag9jAaEA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694987007123969.0238735408498; Sun, 17 Sep 2023 14:43:27 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qhzUT-0004Wr-MY; Sun, 17 Sep 2023 17:39:41 -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 1qhzUT-0004WW-2Y for qemu-devel@nongnu.org; Sun, 17 Sep 2023 17:39:41 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qhzUR-0004Fr-HV for qemu-devel@nongnu.org; Sun, 17 Sep 2023 17:39:40 -0400 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-40472c3faadso37676805e9.2 for ; Sun, 17 Sep 2023 14:39:39 -0700 (PDT) Received: from karim.my.domain ([197.39.215.8]) by smtp.gmail.com with ESMTPSA id n11-20020a5d484b000000b00317ddccb0d1sm10561735wrs.24.2023.09.17.14.39.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 14:39:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694986778; x=1695591578; 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=tytbz2GrtArc4cKJgoRBdOuRp5xjR4etKhXFM07GeUo=; b=Hv3E8NtpzPBBpGO2XaHdvLdqwhfMgjiYcjh6Kry9zQCUQ4LjS9wSQW03pB+Ph0quk+ NLKnkCPEshhM/ith6EkmJU5gi9EIomoAZFR6XV+KdYM/zdYdMAIElj7G69wlYUSRLUPf WaKXdbO3so3aUJmFWoRy3ZkPG8lWLU0UAgPJ5ojlhOnCmEOMD9ODo0xrGpOnm5MblzJm cJcaZCmRsbsL+eNRlAT9zWSdEhjJSn6iKmQ/yG9mzXBu48rEI905dp0aGUa0HlzK3FEM q6nXHIceuMwBL8VIlXOfS5n/kGZiYK07h8qVLft6ZoNG/JsxedymghafmSAyxasVDwGt Yg1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694986778; x=1695591578; 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=tytbz2GrtArc4cKJgoRBdOuRp5xjR4etKhXFM07GeUo=; b=nHSlQC6rddig3dQkebql4N1Sp+mzKcKXwKECna1LgOZ2CbpOLBriYTySe+r+yunffx kOjuM4fJS2JnwyyIlo1hTzOvI5S3Ktqx6J+L0B4gvDUOORWEHavlAbLlS7WGbp4NWxfM Pp7kl96qzuJ/JNOX0tBf7lOAvFew3WUIgs2ti4Mzn9M7Z94zsBENkbLcBmiCO43dkIFc GVNfJiDTrL9Rih4ES+jv8rk1fVH/YVuysdy/mG5da4TuUplEHqSarxxljLM98XrcatuH 4F1okEzrZXgJHeWBatP+moROTEG8cA5833C+5P/3JFVHkBury2RP7TY8ZHJ61sDB6/qA BiyA== X-Gm-Message-State: AOJu0Yz1Q97zb1lP2lyiAW0OgbS+SBHQGa8DFWnl1VXy9OSUIib71Vz5 qo+MkgPctZ0NAxAkPqqAb8e5/dm38Sk= X-Google-Smtp-Source: AGHT+IHt4uUBFNrEaijztUUb4iWZ2YF+gMHIV0bqXr6ekBn5jUOUsWGt53D8+uIvhvdiasJaRKDj0w== X-Received: by 2002:a5d:53d0:0:b0:31c:84e9:20fd with SMTP id a16-20020a5d53d0000000b0031c84e920fdmr5331640wrw.13.1694986777926; Sun, 17 Sep 2023 14:39:37 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: imp@bsdimp.com, Richard Henderson , Stacey Son , Karim Taha Subject: [PATCH v2 09/28] bsd-user: Implement host_to_target_waitstatus conversion. Date: Mon, 18 Sep 2023 00:37:44 +0300 Message-ID: <20230917213803.20683-10-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230917213803.20683-1-kariem.taha2.7@gmail.com> References: <20230917213803.20683-1-kariem.taha2.7@gmail.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: pass client-ip=2a00:1450:4864:20::333; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wm1-x333.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1694987008479100003 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 --- 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 aa386ff482..19f6efe1f7 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.42.0 From nobody Tue May 14 15:16:59 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; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1694986880; cv=none; d=zohomail.com; s=zohoarc; b=WU8PBp2xiHhVUMqT1/d5+APakpoe3TGTCEFcLFHdDl5TeBupiuMPX1Ky5oqL0lOwsTux1YRE++lO9uZu0K0S+wjwR2x2jeRlX9Kz/pe5PtxwU8l+Mu3AMHTkSJelld/xNycWs7jN1hLVlB8/nXqhtoZbGCF6oWycD+mfDSL/tmM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694986880; 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=Tcm4lmXBa5x1vWIwc3sC3J6lpJhMK9gQtwcOR8qWqPw=; b=RZuUmb+Enhu89sntpWY/WehnIudUG+5hJMXbxYQ+wZyqiVaoBa9YKyWtLWqFixRliEV4b0ZK08Jar+hZRcf6Z86VfZr9nMTerB2/mtPBYfnSUvu1Og3IzGA3U09taAn73cse+9M2cL5P9D+RW1whvGLPTVZIn33Ap8IAEQFR5cA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694986880008832.5561026189524; Sun, 17 Sep 2023 14:41:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qhzUV-0004Xk-CE; Sun, 17 Sep 2023 17:39:43 -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 1qhzUU-0004XF-5W for qemu-devel@nongnu.org; Sun, 17 Sep 2023 17:39:42 -0400 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qhzUS-0004G1-MC for qemu-devel@nongnu.org; Sun, 17 Sep 2023 17:39:41 -0400 Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-32155a45957so123104f8f.0 for ; Sun, 17 Sep 2023 14:39:40 -0700 (PDT) Received: from karim.my.domain ([197.39.215.8]) by smtp.gmail.com with ESMTPSA id n11-20020a5d484b000000b00317ddccb0d1sm10561735wrs.24.2023.09.17.14.39.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 14:39:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694986779; x=1695591579; 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=Tcm4lmXBa5x1vWIwc3sC3J6lpJhMK9gQtwcOR8qWqPw=; b=AUBhNGNwI9dB8GA256jlzRu30udyGfPEqcmSodVLA99c5hCmz07UcK5ASUWwhOvNcU 77RVmJfw91loss8itbTRRoIU0dBTYFe987IsshsS8F9YyzQjt7n4OOFjpva8QMdWtPvv dD8s3Xyj+RCcknGHOt8obxUQpyLfBY2ldkJZHEY0SZm9Lnyww9wdK2ILe9NByo3OHoXl pSB7TTgrc5Qmv38q0VdP2TmsWx20Wzv9elluKpvD5Hpkgb9Uzn2nlRnKpOmtSB75V786 qzypZEAjFkmbcRgQwV1Eu1D31cZODP8XYJRh5u79unyB03uV7Sck6uI52pnsB4IC40Pr SMjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694986779; x=1695591579; 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=Tcm4lmXBa5x1vWIwc3sC3J6lpJhMK9gQtwcOR8qWqPw=; b=w9q3uC6uePcEa5zrx39MvVLTHN3dspTyilTXM9i1/1d2Jm2AsVgcAKIJ82lOWCZs0w yp/dvaIdHM489dy2LCS8iD3sv2fJfV0OYsotosqmJd4Wt1ATaL/ajAaafqmkluHO8aff TOBcVZ2T0DdjPACAak3fgb3I73ktE+1inl4mg7FpaQdJ7nUSkmR77dPIx9X1iBFI4cXq WV5alBC45c/trIbLQ74Q7JbuL0J9v29WyZRtRzh+PcfZUrnpZ1HVuP5gzRCGRd9gR7jw CzaMk1h3vm5EqR0UsGqqSSgHmpzuvmccFMw7Hs1FqE0oil7iOAODwGq6D4e0z1I1mnbw cfLw== X-Gm-Message-State: AOJu0YywLyX2dFz8SeQ7u3ZpCg108pMdS707vW1fkZJ+7S8ZjbMRTqxn ZvdgaArbD2AC3vDnOMchjM8QGAZSweg= X-Google-Smtp-Source: AGHT+IFtZS6Gam5M4/Oi8Wum+d8M6P6mV0aNMlLMZ+f7wVI5QRNXgHEvIjU82toIuqpMn2wSLgTMmQ== X-Received: by 2002:adf:ce87:0:b0:317:57f0:fae with SMTP id r7-20020adfce87000000b0031757f00faemr5639275wrn.63.1694986779060; Sun, 17 Sep 2023 14:39:39 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: imp@bsdimp.com, Richard Henderson , Kyle Evans , Karim Taha Subject: [PATCH v2 10/28] bsd-user: Get number of cpus. Date: Mon, 18 Sep 2023 00:37:45 +0300 Message-ID: <20230917213803.20683-11-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230917213803.20683-1-kariem.taha2.7@gmail.com> References: <20230917213803.20683-1-kariem.taha2.7@gmail.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: pass client-ip=2a00:1450:4864:20::42b; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wr1-x42b.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1694986880884100010 Content-Type: text/plain; charset="utf-8" From: Kyle Evans Signed-off-by: Kyle Evans Signed-off-by: Karim Taha --- bsd-user/bsd-proc.c | 23 +++++++++++++++++++++++ bsd-user/bsd-proc.h | 2 ++ 2 files changed, 25 insertions(+) diff --git a/bsd-user/bsd-proc.c b/bsd-user/bsd-proc.c index 19f6efe1f7..78f5b172d7 100644 --- a/bsd-user/bsd-proc.c +++ b/bsd-user/bsd-proc.c @@ -119,3 +119,26 @@ 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); + } +#ifdef _SC_NPROCESSORS_ONLN + if (ncpu =3D=3D -1) { + ncpu =3D sysconf(_SC_NPROCESSORS_ONLN); + } +#endif + 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 048773a75d..b6225e520e 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.42.0 From nobody Tue May 14 15:16:59 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; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1694986835; cv=none; d=zohomail.com; s=zohoarc; b=YaVYS5wg9QQGao6AYESkoyDxeFUXHf07yCuzVbng9uzJJoOwM9K55JHtqkPotmjI7OyUpCzdW/uuCNRixCIAK1d5W2oG8kSumU4lexdQa7bLjEamW6cjWgJWlK5OWrAAf8awBKo4s/sDMnqvJi6ejPgwHyzd/U0wVNv6m/QJPqs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694986835; 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=30VV4yt2ro3MiuAoHh+3abDe9zHvykVDAdOKnvHSpvs=; b=YNlqAVBdyFzXOjE9UweDmJ2dOM67/f5AndjBU4/lQTQMnsT5e99Xv+9Pjcznk30VERZOx2OpvzY1v67j8rEDiPTYIooA2wWk5DX2HEBfeRHqd1eWTMX9ff5jXP9vcftPbqJLH8QRUkGST64YoPfHWqmW2DJmEtVC6S288gagqec= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694986835552429.8321530664691; Sun, 17 Sep 2023 14:40:35 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qhzUX-0004YG-5U; Sun, 17 Sep 2023 17:39:45 -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 1qhzUV-0004Xy-S2 for qemu-devel@nongnu.org; Sun, 17 Sep 2023 17:39:43 -0400 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qhzUU-0004GG-9D for qemu-devel@nongnu.org; Sun, 17 Sep 2023 17:39:43 -0400 Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-31f7638be6eso3714876f8f.3 for ; Sun, 17 Sep 2023 14:39:41 -0700 (PDT) Received: from karim.my.domain ([197.39.215.8]) by smtp.gmail.com with ESMTPSA id n11-20020a5d484b000000b00317ddccb0d1sm10561735wrs.24.2023.09.17.14.39.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 14:39:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694986780; x=1695591580; 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=30VV4yt2ro3MiuAoHh+3abDe9zHvykVDAdOKnvHSpvs=; b=YvNQqqmDtJbN51NnUm+tIlWmFsCKM5c6OBcjksenmCGS0WYvCfGUmVP34nB2KYv7hb hw5idC9r3JlaHoC+Cyi7g7g5qhVaK8rqKB+WmmKjb+DAO9JbtzM69xZK6glofmB5Zp+M Dp6Kc4ug5kQNTxHXQWlR0v7US+oesMTW5QcD5icsmnKLxaEb785xb+/AH2utQ1rcAchj 1rgiQtsml6nmTF3OKChHzHEXibzoExQ034y5OM9J/I3aMvYnHR91QVQ8xPWiOn1k1A2C UEIhc0U49MFeZU30vUqJPFNfoDRsIbjJegFm3gtcbKSYtO0TGMiIO8I3HGunA+mD0tl8 SEEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694986780; x=1695591580; 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=30VV4yt2ro3MiuAoHh+3abDe9zHvykVDAdOKnvHSpvs=; b=FbXpX957MOcTfx790wMvelX8sU7SH6UkBlPIkatG1pTH2MnlK9Z3kJisu2rAuv1EqL LOLI6bindW3QVPf67045Cye5S6vEnNbiKnDXNJwJHU46o8LHdNw6jatvsMC5sumTflhG cQZsBwNvwni7jllgpemHNjUZrPcNLVu+qpNozeyJ2kF5gt6h7Yc4Ff6x4H8ZqLWZKHeh YmdBQWoY0o3Piv9xmahbeQI/wPDnDhxI+ajkchcBx6OpO6GpOkOtiEVq3T/klVRUuhtV hoiGAKaBNHZ8KQz8CUjl914NRKpYESyg+NBNV+BmDAYbj451iC/0Km5zROHcE3qWUPwE ZP2g== X-Gm-Message-State: AOJu0YzQCGywrQRFiLsW2ATF3EGn7bkhDtf1QP0mFmDqE9ikqYEfDXzh dU3k3wP3zq1ElFn9M4wUH4+qeE05VBA= X-Google-Smtp-Source: AGHT+IFe7BsZLaRJpx3TcxsvWyFc9p/eOsNjNARo8akm4BOaN8B/9n5jLuNEWxFzkxaNshoADq3yjw== X-Received: by 2002:a5d:5746:0:b0:31f:db58:993e with SMTP id q6-20020a5d5746000000b0031fdb58993emr5514400wrw.66.1694986780307; Sun, 17 Sep 2023 14:39:40 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: imp@bsdimp.com, Richard Henderson , Stacey Son , Karim Taha Subject: [PATCH v2 11/28] bsd-user: Implement getgroups(2) and setgroups(2) system calls. Date: Mon, 18 Sep 2023 00:37:46 +0300 Message-ID: <20230917213803.20683-12-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230917213803.20683-1-kariem.taha2.7@gmail.com> References: <20230917213803.20683-1-kariem.taha2.7@gmail.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: pass client-ip=2a00:1450:4864:20::433; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wr1-x433.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1694986835796100001 Content-Type: text/plain; charset="utf-8" From: Stacey Son Signed-off-by: Stacey Son Signed-off-by: Karim Taha --- 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 b6225e520e..7b25aa1982 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 fa60df529e..535e6287bd 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.42.0 From nobody Tue May 14 15:16:59 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; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1694986878; cv=none; d=zohomail.com; s=zohoarc; b=UY44K4jf3CdOUKkapJ4J2Yo0fq1czXssVcGVDQ5Yc7sQArT6CpBhPJozGb78mh7ZQtYaQoJv6AGU3REF8j4KFj1aOrFuq7UlrrRoku+jv+EgH3FZsXERX7lXse5ahowY4gqikyUq5l6D02Av1ADKqbpfsGKQJfF/spCpPZhRfW0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694986878; 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=S2C+DXDFtElhsZcWyV9HhqsA3jXU6683RqCl1iGRJvU=; b=XAHjSbdgFiEjPHE1ywta0JxC6tPxfwuf36zI5E/blipQ2/8GN8GSYUZOcWRwnBAgOGJhCeQSKZXC4Miv9hcaqDx4+1QLmYKVGdwhlqbFcnOW1/7dik3fpBPX2fGGG9qn2LZCqqrh212JgFW955oEpODE7HWFQWnoOD4VUH1ByYc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694986878599839.4445674612185; Sun, 17 Sep 2023 14:41:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qhzUX-0004Yg-U3; Sun, 17 Sep 2023 17:39:45 -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 1qhzUW-0004Y7-HY for qemu-devel@nongnu.org; Sun, 17 Sep 2023 17:39:44 -0400 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qhzUV-0004GR-07 for qemu-devel@nongnu.org; Sun, 17 Sep 2023 17:39:44 -0400 Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-31c5cac3ae2so3420638f8f.3 for ; Sun, 17 Sep 2023 14:39:42 -0700 (PDT) Received: from karim.my.domain ([197.39.215.8]) by smtp.gmail.com with ESMTPSA id n11-20020a5d484b000000b00317ddccb0d1sm10561735wrs.24.2023.09.17.14.39.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 14:39:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694986781; x=1695591581; 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=S2C+DXDFtElhsZcWyV9HhqsA3jXU6683RqCl1iGRJvU=; b=QS+KudI+8LD5Y+v5v9MmCFSGL9Q9QzQgmKGPxWYfXHTawaK4dckv4JhYGtvemW8FmF FfzFK+snCPyasYcxBhzQov+Z8IIOL/ilrfKqFSC1UkkdlmNGOE3Rem8heZTR4mDH0+af NC0PNad7V5I/Eggd+GdqX/dAbFBkWa1njsuWCjWKK3BxqQ2G3dN395HoWA5LE2Jnj/iF yFl3W9YL8zY4ZnRZ+U24w4d+6JvYGP7JCNpPVJrfDSUpvSBMgIIVpnvKrgtw8bx60lXe RYP9NE3qeSFDQAcmieAnNn08M+khaTKc0VaKcRpKl2UVZdNcbHVolLxstFvyZcjhtQwI 4bHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694986781; x=1695591581; 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=S2C+DXDFtElhsZcWyV9HhqsA3jXU6683RqCl1iGRJvU=; b=wwA6u3XW9rHiWnB7/KSAVL6Pa0+MaT7UzRJ3ZlXeUEF5GmXDHYx7TgmDwXmi7p1dK6 Y+UxOeI+Gxe4SK5E50XoNXFeNagUMKujCK5SbHbRep1VbkmFk72Zcu061hjcC2csrvuW 4ihCoF1k2M/zKr8ULx5ZJbOc0Ojd/5IZIoJCoQi09Ed3T3x7PTP5vvziDkxYuAkg9rdD 6o1qOFNDyutLiJ55mPZhq1G+lp1uoKvpMpX0uUOhPOdAGiXUQ9uGrL4/F4FGlh9H5e0m z8ZTkkho9NDuzdTiUp3lA8nfnGgcHsQIolACqDJc9wj+ks4Sh9E2OWkv+qzdEIt4Fwgt Easg== X-Gm-Message-State: AOJu0YzMoo5YxGCqFRgFK5k3ncLWYAtG9GAJ1sBOP8Fsq3avElQjSoNZ nK/xCF/NPSRjVfjQWp7jslaSyphV3z0= X-Google-Smtp-Source: AGHT+IH9d4U+7aA6/EWtZcZ14rPVrmheDTgxTM7K637TsYfOHDoq7MDOAI7RYrHywTG5KHLFhDGr0A== X-Received: by 2002:a5d:6952:0:b0:31f:a259:73c with SMTP id r18-20020a5d6952000000b0031fa259073cmr6234232wrw.27.1694986781497; Sun, 17 Sep 2023 14:39:41 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: imp@bsdimp.com, Richard Henderson , Stacey Son , Karim Taha Subject: [PATCH v2 12/28] bsd-user: Implement umask(2), setlogin(2) and getlogin(2) Date: Mon, 18 Sep 2023 00:37:47 +0300 Message-ID: <20230917213803.20683-13-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230917213803.20683-1-kariem.taha2.7@gmail.com> References: <20230917213803.20683-1-kariem.taha2.7@gmail.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: pass client-ip=2a00:1450:4864:20::433; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wr1-x433.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1694986880699100007 Content-Type: text/plain; charset="utf-8" From: Stacey Son Signed-off-by: Stacey Son Signed-off-by: Karim Taha Reviewed-by: Richard Henderson --- 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 7b25aa1982..fd05422d9a 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_string(arg1); + if (p =3D=3D NULL) { + return -TARGET_EFAULT; + } + ret =3D get_errno(_getlogin(p, arg2)); + unlock_user(p, arg1, 0); + + return ret; +} + #endif /* !BSD_PROC_H_ */ diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index 535e6287bd..44cbf52f08 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.42.0 From nobody Tue May 14 15:16:59 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; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1694986862; cv=none; d=zohomail.com; s=zohoarc; b=hDXeEpd4o6/56avXgAMtGJka//d72Fo7zo2yH1LxF+Zg+AUJ0jjplHtCcfyu6IK5UTVo242pxKo+u8hnQd0Zy2DOI9zeBWfSyGHpyTPND3tmbJmGnUTcQy044gnbUrYnxFgHahYZwogAcNQE9CweF7KmS0F9OlOZcQSD6JwewLA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694986862; 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=yBFk+yreDDX0nWyL6EEcBdBkcxtfOjeuNT23emez/IU=; b=kY4BkWYae/bpmsCqFTDyYNWfJ0kVir3AtH7h1eoXZf5Xx+96u51eUsYhXvVrCiGEcBHwb+QRQQoJsG1C9DJKDs3Le0RRTrf6b6d1MQ2WemW5etFWpT/HPLKl8R+ILzjOvtLQ1plsZ6Haz146el5HHARwbYIF6OlxIaMVb5hfj5s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694986862076782.986243748042; Sun, 17 Sep 2023 14: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 1qhzUZ-0004Yz-Fg; Sun, 17 Sep 2023 17:39: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 1qhzUX-0004Yd-Q4 for qemu-devel@nongnu.org; Sun, 17 Sep 2023 17:39:45 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qhzUW-0004GW-BD for qemu-devel@nongnu.org; Sun, 17 Sep 2023 17:39:45 -0400 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-404fbfac998so12917865e9.3 for ; Sun, 17 Sep 2023 14:39:44 -0700 (PDT) Received: from karim.my.domain ([197.39.215.8]) by smtp.gmail.com with ESMTPSA id n11-20020a5d484b000000b00317ddccb0d1sm10561735wrs.24.2023.09.17.14.39.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 14:39:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694986782; x=1695591582; 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=yBFk+yreDDX0nWyL6EEcBdBkcxtfOjeuNT23emez/IU=; b=GDDu2FNe7vbPWOI9Xsv+AxykHPpxB9VbgLIyKQ6b4sfbk0UKvwxWC8RKpK61VdSRky CJUGSmME3zSd9qlrtWJ+Kg5YdbEYPtnGE/mKA0/capklxihu0YlJpntrdMraqBx5KKTp nyio5xp74gBvVVgyCvt57uZou8++lzMiqjVGc8h5uPCY5qGfDCuaKZuVxmvEQdZWf22z jmozsRpt8GnTjoPPvvolbD8TVjrqpNWKPrOegr4zWnfbU08bnNtxWe+3PwR8V1EtYXM+ zar35VmEgaxRGMXh5ETFJYNxDuYorkUE24IPqY44GV/MMq86RMyN4LKV9evdCscaGfZK Xsng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694986782; x=1695591582; 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=yBFk+yreDDX0nWyL6EEcBdBkcxtfOjeuNT23emez/IU=; b=U0KfzfioCCGD4BnFLX0WPP9VRCbmdoqkWYFmw42mbEbUxcJcdtaU/L8m6R9JH1wycH DC9A81PvzwbkP3o43VyhTITkGUiYstXH8nx3xMiBQx45nmBBo06enIp0h4F9aFoyoNel IpCtAFkIeQUN59E/OCM60Cjtd5pDrVq8JZpBSOlBEN5plIvJQrZ+hCDqwdcboxvQoJY/ IAatGex0qstIheU+XZJXquUf42V5MW95iiJ4e2VyW7Lli6Rton75FHvJxGP63KqiXd8o jQlOL03SYDlxefr26S3BvVq943m5QVdZl6kqxjRZOY60/n+Tz/5ipWQP6GLNPt+APs2C asyg== X-Gm-Message-State: AOJu0YwIxjsRA1d8I+psv1xHuSea1yIUuZkGH1hmCMvJeChARuSkM61r kAIvJBCo/fNnyuAnVLXKMRHtRvLKbvQ= X-Google-Smtp-Source: AGHT+IHre4pbkUDPTd0KDxPLXSA8cvp5PC7He+YTsZ71MuSc7PUn7fCEDgLdcPv1a+zdRilPG5j0iw== X-Received: by 2002:adf:a296:0:b0:321:4d1d:26f with SMTP id s22-20020adfa296000000b003214d1d026fmr1156365wra.29.1694986782536; Sun, 17 Sep 2023 14:39:42 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: imp@bsdimp.com, Richard Henderson , Stacey Son , Karim Taha Subject: [PATCH v2 13/28] bsd-user: Implement getrusage(2). Date: Mon, 18 Sep 2023 00:37:48 +0300 Message-ID: <20230917213803.20683-14-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230917213803.20683-1-kariem.taha2.7@gmail.com> References: <20230917213803.20683-1-kariem.taha2.7@gmail.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: pass client-ip=2a00:1450:4864:20::332; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wm1-x332.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1694986864757100005 Content-Type: text/plain; charset="utf-8" From: Stacey Son Signed-off-by: Stacey Son Signed-off-by: Karim Taha Reviewed-by: Richard Henderson --- 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 fd05422d9a..57fea173c2 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 44cbf52f08..5d8693ed55 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.42.0 From nobody Tue May 14 15:16:59 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; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1694986872; cv=none; d=zohomail.com; s=zohoarc; b=KTOnbo+7GHUQ5zyWj4RviscC+YO/n7tUtRt46ceXlv5S+xmmTxARq0ghXSgNntlLzlQWXusDjPDzzmaGC1L2jfdqJsLAlCozjU3VhdZ405CiaeAFAu3/WXv6i1Bcl3JuMvraSlQmAaxsZ1DXvYoBhS/kUPkUlz4B/9vxZzo3E7M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694986872; 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=mLdkkdZEPKyUic0lLlf7pM01ehziiit06d6Q+F/iamk=; b=gc8Zcj912wwkkp6hzWPROaU2HstE6ujbVPFkCXRaJxHwUffScj51ETUHEwprFoNFumVvg6c/i1565b0xdLl5jccnoJWP/fGfKBPXKXx/urksT9qlwolwgA7w3hLKMI+H2ViQkoQetwQ4qlx5ynRM5PH/qCK3zgX4f6KXrQXLflU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694986872369497.1907263663827; Sun, 17 Sep 2023 14:41:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qhzUb-0004Zr-34; Sun, 17 Sep 2023 17:39: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 1qhzUY-0004Yp-VL for qemu-devel@nongnu.org; Sun, 17 Sep 2023 17:39:46 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qhzUX-0004Gk-Aw for qemu-devel@nongnu.org; Sun, 17 Sep 2023 17:39:46 -0400 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-404573e6c8fso38787615e9.1 for ; Sun, 17 Sep 2023 14:39:44 -0700 (PDT) Received: from karim.my.domain ([197.39.215.8]) by smtp.gmail.com with ESMTPSA id n11-20020a5d484b000000b00317ddccb0d1sm10561735wrs.24.2023.09.17.14.39.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 14:39:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694986784; x=1695591584; 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=mLdkkdZEPKyUic0lLlf7pM01ehziiit06d6Q+F/iamk=; b=nbjkct6wbbQQW/iWaqYyKuMnq0H7oapVV9sRLDxBG/ZXi4RV5EtsWuHANWzmcuJnle 4FdDzTblWJQH0YSD/DAIBYIwBOn2wgygl3pzQ1I6JB85RGkJiUz+qkooIaZ4wCXWPWu+ 5tnM+q3W1cUbktLgUkWzyUmQW6J+kF2DduT1K61wNYVsifMZrujo8TsYwBNq796Vrc+q jqHzagn8/QGTm08IfJDV3VSshEMlUSp5l4Yv2G7GimOgKK1FZ+GjLgMdJLs8EZnTSETX tHokPEGTGmY6iDu2Ik14EwyQs+PB+/DL4xry923AzdEgml0TgEYvUicCDqHCJlURTW3f qn1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694986784; x=1695591584; 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=mLdkkdZEPKyUic0lLlf7pM01ehziiit06d6Q+F/iamk=; b=UYxydIs0W8ndzfLqLmw0MaEjkV8ZIWQtchKiV5IjIlpnz7ocnfPr3/wzlDYE4m5iea h21Tw+qs4hUbHjeoScF6jmENiKIvJsiFKDgUQMWIJNmfvkzmqumy2awkX+2tWrlWsmOY CKIx1VaTlOD+4/sjIwOccs2N/f9veIS4tELCiGwxjzhfj9zAej7fuRlhVyf/OF9QFnNq fLm1CjKjoyF02MsmR1ku0Y6XwHDBv97yEc6iQU+LUXVVAWK5MjrILnbc8bQzGN+9Tj7W rvxcAtvK3HCwiWFeMaM37olHkBwYDknHShYCFRYfuYOen2sIe+LP+nPM+p4DA5cfCjnR ORiA== X-Gm-Message-State: AOJu0YwGAHtRd7ckqs7Cb6SOAndEJb75wbPEJZTqUsqNHRUw4tFB9AKs nYdISaI2Gmx88YicW9CkT6d1hnoOH+s= X-Google-Smtp-Source: AGHT+IGUMDUCa7PeT5dI1b91fYj7Y8yXNuFqyyd20CfXJVEDWR5GElXrlyjRIfF03xMs7N7rGB2T1g== X-Received: by 2002:a05:6000:184e:b0:321:5211:8e20 with SMTP id c14-20020a056000184e00b0032152118e20mr855780wri.59.1694986783775; Sun, 17 Sep 2023 14:39:43 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: imp@bsdimp.com, Richard Henderson , Stacey Son , Karim Taha Subject: [PATCH v2 14/28] bsd-user: Implement getrlimit(2) and setrlimit(2) Date: Mon, 18 Sep 2023 00:37:49 +0300 Message-ID: <20230917213803.20683-15-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230917213803.20683-1-kariem.taha2.7@gmail.com> References: <20230917213803.20683-1-kariem.taha2.7@gmail.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: pass client-ip=2a00:1450:4864:20::329; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wm1-x329.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1694986873368100011 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 --- 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 57fea173c2..06b5b9e03c 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 5d8693ed55..5cb6086230 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.42.0 From nobody Tue May 14 15:16:59 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; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1694987001; cv=none; d=zohomail.com; s=zohoarc; b=KgH5EZzR1D8B9KCAvY5TTbXmsHfVQMgGHLuzqmnweQELw79I4FQDfPDJEUIlnuxpfxWBuhAkFkpN7JPcSjudO6EUhgcH2sVpuJPBhektAae9EPOlgZrWrRqv2gOADzHFXX9rnYc+XhhhlYXNNE9pVPLyE385n/dMzp1ybKX2Obk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694987001; 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=82PM6u/NCtIDdzLUc80xbOvNf5qmXl4JA7JhjNThRVs=; b=ITDmqBjSHeRNrt+09Cgawow0jA5Bo6/XVvPlp+bOQxSJZbWKxpuexgqJcavQGYWP3LsW/W5qKlL+qMWEz1msAtLWfqIpW6ddOuJYsdYoRr/5+3VooozBWMrm2Ye6caSsyR0fiDCaHvz8XiHhUU/c9TwZInYXJeJK8GeEPrXxZv8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694987001254784.7440462641304; Sun, 17 Sep 2023 14:43:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qhzUd-0004aG-V9; Sun, 17 Sep 2023 17:39:52 -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 1qhzUa-0004ZT-IQ for qemu-devel@nongnu.org; Sun, 17 Sep 2023 17:39:48 -0400 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qhzUY-0004Gu-QZ for qemu-devel@nongnu.org; Sun, 17 Sep 2023 17:39:48 -0400 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-403012f27e3so44307765e9.3 for ; Sun, 17 Sep 2023 14:39:46 -0700 (PDT) Received: from karim.my.domain ([197.39.215.8]) by smtp.gmail.com with ESMTPSA id n11-20020a5d484b000000b00317ddccb0d1sm10561735wrs.24.2023.09.17.14.39.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 14:39:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694986785; x=1695591585; 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=82PM6u/NCtIDdzLUc80xbOvNf5qmXl4JA7JhjNThRVs=; b=AntfOyvD5RcBxv+7ez2TnWTFqCdcLQWQ/HrnLJc8xQ5f7icPCgboZK5gfoPfTkDltR c/5lXs1HVT8bpPXGBO9KiPscbTv7rfyfR/bbn8/hUQt2sUF4LQEClFL62vjo33sB9d7F G+8mOcqMzJ0rsz4OO/SI9FdnGV9ClCyrP1Ks20sctfhPkQ11GC5oOj91/SETHyfY4kVG RjhkDhkY9qghat2vlROVJP3wMOKdXXMm4SrF3owW+TxWqJbiZS4T3FFzAO8OkoLoIz4J X4wUsiHcIquvf9v9JK+rKus41K0RdcFqQCbs7ZgQM8lD+LpGvn3XhiF9UYIbhvuWsTEa sWnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694986785; x=1695591585; 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=82PM6u/NCtIDdzLUc80xbOvNf5qmXl4JA7JhjNThRVs=; b=U61u25EJr9oPhN1OV6mgstHArT39G2VqdzPLysNr3pY5Tvf9pgL1+stDnfdP7osz2z XC627LSjIhK9Uyy+mJRe0uHfIRU+hro3KNPSjWyVmhiYMNI8bmAsK2uSiWx31AoNQImf M5Kt8f83EKVmDqK4D5+Oe28GQm7gAk9iptVGR1FSHxORcuTHJTgz9LSWwzbbWR5GChHN TdvWI6Xx8p9phoNi3KtO42DhN9N1ehu5egsZA4aIvJmFtO/i44MWfc7z7RpBwNQx9rgO Q5RKHMxv9WIYHLJmOXVOMXs6K6vXdyhP3JRolCd3RxFF4SJMSxkyUJEVY8Rbzdhju4oM lsYQ== X-Gm-Message-State: AOJu0YzOPdAM6e0ahHV6pgd4vgngPmAMtl/657E2+kyndfiROgM7A4y5 BSU8Rr+gXwWHWDyeGHXgS75SSBf8Ngg= X-Google-Smtp-Source: AGHT+IGWInc5TEhyfsnmmVo5IXQ76bizcXSBGGB625Vgr2Z7bie0nWUxap15t+H//yZ6aBm5boFzIg== X-Received: by 2002:a7b:cb8f:0:b0:3fb:e189:3532 with SMTP id m15-20020a7bcb8f000000b003fbe1893532mr6269512wmi.20.1694986785007; Sun, 17 Sep 2023 14:39:45 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: imp@bsdimp.com, Richard Henderson , Stacey Son , Karim Taha Subject: [PATCH v2 15/28] bsd-user: Implement several get/set system calls: Date: Mon, 18 Sep 2023 00:37:50 +0300 Message-ID: <20230917213803.20683-16-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230917213803.20683-1-kariem.taha2.7@gmail.com> References: <20230917213803.20683-1-kariem.taha2.7@gmail.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: pass client-ip=2a00:1450:4864:20::330; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wm1-x330.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1694987002355100003 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 --- 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 06b5b9e03c..9709939337 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 5cb6086230..7565e69e76 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.42.0 From nobody Tue May 14 15:16:59 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; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1694986877; cv=none; d=zohomail.com; s=zohoarc; b=OlkIm2SZWY4oG9B5jSA9VSOXvje/s/54dJx+s3siOpeeDrkeB6gNdA3rr1gmYDAXwQNXezF/W5TRn6+r4ow/zbBpy4CgY0yxfkXLDATM2V6S2wRtn2Yd3Cag1q0r/E8e5SiTk56rDsMCxJBEdMwvKxWEGyHLcmMVvnx7H2E4nEY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694986877; 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=4XO44dATT/BC4OT705qsiRIOdp9R+PZLsbNAQswN5pU=; b=U2s1T+6DSUvxCBOq2KJDsbT3r7VN1KNTfLY2SiUNqTCwnde+nTUILIs9so3Tbcdi5sXfntzQoZ2i5op64613QMGERE8e8y964FqZFnId0Umvd7iulM/EGzRVCs3WfBS5dRCnkwz31HCiqgAIUFhjOs6/d+/BUA86H51DdOUWRvw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16949868777101014.6961067817778; Sun, 17 Sep 2023 14: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 1qhzUg-0004aq-PQ; Sun, 17 Sep 2023 17:39:54 -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 1qhzUc-0004Zx-Cb for qemu-devel@nongnu.org; Sun, 17 Sep 2023 17:39:50 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qhzUa-0004H6-0J for qemu-devel@nongnu.org; Sun, 17 Sep 2023 17:39:49 -0400 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-403004a96eeso41990545e9.3 for ; Sun, 17 Sep 2023 14:39:47 -0700 (PDT) Received: from karim.my.domain ([197.39.215.8]) by smtp.gmail.com with ESMTPSA id n11-20020a5d484b000000b00317ddccb0d1sm10561735wrs.24.2023.09.17.14.39.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 14:39:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694986786; x=1695591586; 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=4XO44dATT/BC4OT705qsiRIOdp9R+PZLsbNAQswN5pU=; b=nm/7CObR8G8ysWew/DsG0Il16et6E9RXpJ2wfrzoTry8sGSYZJcAasMzkoThlwjyUK FRBCXQJNX4bQn146Nmo/o/HhnZyENUlTu1XkbbWYX2afeVOymIg1ZTaVvhwz9eKxUSW4 5ukZpZXkVB7S0NkvNer+4o32ZvD+Z94qJK/aMzuqacDtgIebHhsAAKA21p2gLQHcQqR+ +bv4+qURpUA2aUlgJ/JI/gspKpeTQhqg4YHwWEjRmc4HQ2q66cbecDqyk+wQTFwFlIF4 bR4HvHCz0wDPHAQYyaa7e5JYt7x0wj+s0YhFYFuuD0avpNllu+lk7eeUyoLueFrwWtE5 Q5ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694986786; x=1695591586; 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=4XO44dATT/BC4OT705qsiRIOdp9R+PZLsbNAQswN5pU=; b=GwiC9tvbf3Y0bdsSRNFtpEqHw/bkksV+IKpvOPQvDja1f0RjWVyZqP1mnpBMA+HfIj esxQ0EWupxIDQaLb1sacOueB1w+dXVjELfXaMXNGDynfysZ2Jwcw03BNbEwstGSQ6qaU aDt9Ie6rUCG6rxPz9WEDschVpyfOa3BMu5FxznkIJkxmVLN/IBunoNu8jNrsSESyr/Kq CNNcAOE+vhV/DImlyXbl8zHKqD3S4kO9btcdZ67gXikiaSC2TKYbX0MbUGyDLbvglmbA Q4SfzgrkOgMbe17N9JFQYxC6+SIJfSkVVpwnUR76sEcdSDjlvIQhMnBzl5LIMsq3Qaj6 ooaA== X-Gm-Message-State: AOJu0Yx8gORcO4BS3YP+7fQtJJEs33thdZQMw8YcbY0iyt/BtJXzUjuE vP+KMTuW+zz5E4kD4rlVsnQFXstc+oE= X-Google-Smtp-Source: AGHT+IFB2OiyUzMc1VXD4rOWSTjPFBobaPQekakhLy3qukv0Lm+RNAiORK/VKlc7wUFI6IJqCBPt9w== X-Received: by 2002:adf:cc8c:0:b0:31f:f1f4:ca8b with SMTP id p12-20020adfcc8c000000b0031ff1f4ca8bmr6127305wrj.40.1694986786235; Sun, 17 Sep 2023 14:39:46 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: imp@bsdimp.com, Richard Henderson , Stacey Son , Karim Taha Subject: [PATCH v2 16/28] bsd-user: Implement get/set[resuid/resgid/sid] and issetugid. Date: Mon, 18 Sep 2023 00:37:51 +0300 Message-ID: <20230917213803.20683-17-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230917213803.20683-1-kariem.taha2.7@gmail.com> References: <20230917213803.20683-1-kariem.taha2.7@gmail.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: pass client-ip=2a00:1450:4864:20::32e; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wm1-x32e.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1694986879325100005 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 --- 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 9709939337..edbd408995 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 7565e69e76..7b51f4f16e 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.42.0 From nobody Tue May 14 15:16:59 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; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1694986889; cv=none; d=zohomail.com; s=zohoarc; b=JGn8Q7t1wJbYnelajoYn4DVczoFmCnxXoD+sPqcUVZRf+zP0qFYOfbOwx3U74gb34TUMn/mRp4OithsFU4uvulKLtUbiDOvtnmavargZKS+txDeqlHeku2elamtXT2X1tVjlih0iMb1VHztvwBrebbgQU1URSwLHsRv1ZSrXTtU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694986889; 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=hLCu0wW1o+yl34lwKBXtNHDIXsCq3rTr0rq5b6L0+9E=; b=dgEoiPqM6/50BgZWybUVyWP1xgr+Jo5JlUT8DFSdO2lwQBUveqc5E19WU/xI3eZOhr3AYJpWdjSmJSQYi/mHHJcFluC4FM13CmV5JE77jKvU4EGlcDfDavIugkqOfRKHPaU16DTOPMdn+a7TNw6hESBr/bcs8U0PPl1Ihq05gS0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694986889618188.2473509251016; Sun, 17 Sep 2023 14:41:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qhzUg-0004as-PM; Sun, 17 Sep 2023 17:39:54 -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 1qhzUd-0004aE-JL for qemu-devel@nongnu.org; Sun, 17 Sep 2023 17:39:51 -0400 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qhzUc-0004Ib-5Q for qemu-devel@nongnu.org; Sun, 17 Sep 2023 17:39:51 -0400 Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-31c5c06e8bbso3722838f8f.1 for ; Sun, 17 Sep 2023 14:39:48 -0700 (PDT) Received: from karim.my.domain ([197.39.215.8]) by smtp.gmail.com with ESMTPSA id n11-20020a5d484b000000b00317ddccb0d1sm10561735wrs.24.2023.09.17.14.39.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 14:39:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694986787; x=1695591587; 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=hLCu0wW1o+yl34lwKBXtNHDIXsCq3rTr0rq5b6L0+9E=; b=abwndNDAJCdia0vTFEb+6YETlohRzb4Hml4qYHR35s3zExPJJUfE7SrJs2mwZphbGZ rk9YkCvg+TKjTYjJRuEZexKiQgnYsBSW+JGNvmCB16jf4fv8iKVUiKxGhwUm7I10VRBy QfLCAmvtkOHDxOHAOodoscmA/fPnzy6oLKDLCjMcfAXsY4uDdV3PPd1e1i1pG0P8BZ5t 76PI3SXulrKYKqUJ/s2n2UFPM+azYva2JRwz/9VdTbUdokME6riANJ9G4hJoOVg25K8e KK/xFoVPsMuXOdCd8/QTcaDo4nnYGSB5lgw382cQRqldZ6dBO2/j1ts8rvirF9xNdfoW ecZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694986787; x=1695591587; 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=hLCu0wW1o+yl34lwKBXtNHDIXsCq3rTr0rq5b6L0+9E=; b=vz/5hdZfLROH0X8Nv2V1NctNRIfgf9BRJqC6TwbWGP/Ew0bCr/9JBF4a9rmsBxo9mw 1tpI0jlHAscs3lNeAD2aYGX6ayIDPeCKwTUxy1KhfKnViIuqklTriqt30+g97kEI6U/i HXkV5MbRkd+7ikUXpCrkxWZgw9+S6tSwUICwTgBlrChUrmeh5O3IdRqRdjdRvCpFLf1w u2y7uEBQn5NXMN5rVfsR3amK16ZbW5eGvIDbG4sCXpqjH/cZoJRlxWHJ+o0gQYLdksFv hhiyg2wEpIuT+zDdsvZpopsxxlxZKjILrDRGDJwoKtE0D6Q4mvITsXy3yENQJQpuMcug mPmw== X-Gm-Message-State: AOJu0YxvJb8n6HYf89MYh1rKx3yISn0SeWaTSAO8TnquAfykbYXLLdnn 6LWzvbduig43pbjPoMFm89jTZsrXHrw= X-Google-Smtp-Source: AGHT+IGCP+VJDwIZQmep0/6AeyskGmXbBpLRmSzrd0Yi5QmA9ZtAonoqgydwYMRF6/eTYVVVjDvPnw== X-Received: by 2002:adf:a15b:0:b0:31f:fafe:a741 with SMTP id r27-20020adfa15b000000b0031ffafea741mr4312097wrr.67.1694986787337; Sun, 17 Sep 2023 14:39:47 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: imp@bsdimp.com, Richard Henderson , Stacey Son , Karim Taha Subject: [PATCH v2 17/28] bsd-user: Add stubs for profil(2), ktrace(2), utrace(2) and ptrace(2). Date: Mon, 18 Sep 2023 00:37:52 +0300 Message-ID: <20230917213803.20683-18-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230917213803.20683-1-kariem.taha2.7@gmail.com> References: <20230917213803.20683-1-kariem.taha2.7@gmail.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: pass client-ip=2a00:1450:4864:20::42d; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wr1-x42d.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1694986890035100004 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 --- 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 edbd408995..fff1d4cded 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 7b51f4f16e..1a760b1380 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.42.0 From nobody Tue May 14 15:16:59 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; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1694986911; cv=none; d=zohomail.com; s=zohoarc; b=CIAPHyleBDVLTZHeLYeNC4YwKLAOZh84eZxOEKj91jsxQfbmpGXjG9ELaxFQgEFF2xagCF1MTAQwRHpU05uYQf1xfRtCQ/8wTZL2IO0f7Bqvh6LP4i3IHhbuTW7leXFgXDpwRxA8FQxicnn484ggjZ0n+Vi5cCFL/91umuEhoXU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694986911; 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=TGH2XqlCKs+v6ITttHKED17bHsAug7I+bG1RPQmNFlY=; b=RESkhQWnyuBl4xJf4sMLu0Jb/GQ7rXNFwOM2fQKEoBZEZgXiLMQUMb702t8SEpKwVfITIWYRNjteR4j2NHu17V7N/5Aot4n0CytJmDRspMDvPAPacp2RakqkH7ijLkdfRI6UdBNNm3sXmu2DK5DYqtGYE5TtLH0CIx4WXUP/mkI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694986911806992.1207173631299; Sun, 17 Sep 2023 14:41:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qhzUi-0004by-Jg; Sun, 17 Sep 2023 17:39:56 -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 1qhzUd-0004aH-Pz for qemu-devel@nongnu.org; Sun, 17 Sep 2023 17:39:51 -0400 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qhzUc-0004Il-AY for qemu-devel@nongnu.org; Sun, 17 Sep 2023 17:39:51 -0400 Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-31ad9155414so3649466f8f.3 for ; Sun, 17 Sep 2023 14:39:49 -0700 (PDT) Received: from karim.my.domain ([197.39.215.8]) by smtp.gmail.com with ESMTPSA id n11-20020a5d484b000000b00317ddccb0d1sm10561735wrs.24.2023.09.17.14.39.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 14:39:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694986788; x=1695591588; 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=TGH2XqlCKs+v6ITttHKED17bHsAug7I+bG1RPQmNFlY=; b=JNM1OY+vUGpU78wREiAQTBNKOWaWbELgC/MIg6wamsjTPUDMdO/QcGrrD9uMtVaWvl bUMUK9l2wLc5YhuMOZrLYcZtYTEyHN/HomR5w4hQgQk6zB3S4TcvZTWCQLlqBimPeicw QkKf5Q/HqlaBl8Wxp8IZSkTUspJWrPGD0Vl76bY0098OgDZIqWHU0s+ibmfQlSMPSVnA aHPHyEFf8wAlh3rmDkYWfzl2PLpSQhF3TpcAh+yX4si91bTBVkJJhFR897/1gj2aASAr zhEUjRSopZ8RurIbRNKOh4dkgDfkD6R/5s6g+CjsWq3fX2QPMt9G61oZ80Bxmug/GlCL AyIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694986788; x=1695591588; 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=TGH2XqlCKs+v6ITttHKED17bHsAug7I+bG1RPQmNFlY=; b=ZHyLF6GzgeNZt01+l3NA/fWcZyZwizdD/C2n5kGruwreKR3Pog8PnFMPSEqqdUOqdI qcoILMTMx3DrC1FushKtZ9x4ywJdO0omOkUlLj4S4TQ5Xs3V9TM5wTJq0wAhGCe5tPGo DifC0XTx5H4ku2n+UFp+VAzND99GRiLYSL31/O6apbdqzFwQHjc5c7+3O7ZuHPgP69pt WcCkIq3zVFsOAOa2k8d8znkFtG8BgO8eb3pO8QNasYfqy1AXJOhWjk0nYuK9bBB1i2GM lc1tX3rPsxGv+uqfai4wpAYml7aAr7W0o1aT0ElzzP7mdHzAOxr/V22E/9s0PgE7TO1P AX0w== X-Gm-Message-State: AOJu0Yzu0Uikv4OIr0upncHVQ1b2dkn3fgGBLd0B4ygDBosxbuqKhV3E tbeh/POjxOTzgejKf/1fxNIOTtLSj7Q= X-Google-Smtp-Source: AGHT+IEVX3FSQYSmJq9LrKp6LgWy1m836NJ7oci6NsKg/5kJegMApluvNf09BuVfXXJeWZNUklybrQ== X-Received: by 2002:adf:e40c:0:b0:31f:e80a:33aa with SMTP id g12-20020adfe40c000000b0031fe80a33aamr5848015wrm.27.1694986788522; Sun, 17 Sep 2023 14:39:48 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: imp@bsdimp.com, Richard Henderson , Stacey Son , Karim Taha Subject: [PATCH v2 18/28] bsd-user: Implement getpriority(2) and setpriority(2). Date: Mon, 18 Sep 2023 00:37:53 +0300 Message-ID: <20230917213803.20683-19-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230917213803.20683-1-kariem.taha2.7@gmail.com> References: <20230917213803.20683-1-kariem.taha2.7@gmail.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: pass client-ip=2a00:1450:4864:20::42a; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wr1-x42a.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1694986913816100003 Content-Type: text/plain; charset="utf-8" From: Stacey Son Signed-off-by: Stacey Son Signed-off-by: Karim Taha Reviewed-by: Warner Losh --- 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 fff1d4cded..89792d26c6 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 1a760b1380..71a2657dd0 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.42.0 From nobody Tue May 14 15:16:59 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; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1694986958; cv=none; d=zohomail.com; s=zohoarc; b=idLW84dNv4hWhdpKxL+SM1DfoRxyoweYYOB9gL5WnaT2Pxj60UkgPLzFzzmiNT3hUGDnIgTI6IXcu/EokC+WPLuOz4Fl5Z6R2zELgaAczmwfATsuyrxiUDWZ5/zvM5rNJJX6IeRaIv43yi29727PaHi4rTdlpdtktIm+d5U1PtU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694986958; 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=si5dpHlVizbBUEmC1yaur7aiNcqM1wSFje2BFdDGY6c=; b=MH1+TkxIotNBO/S+96M8NX26o4iR8mDc3s9OO6lxND+UZ3VsWo9SahxjqYHuL6QsLoho9aqGfj+9CPUJg9NY/OZDByzqg8t+U8ArpJe8B9GwN4m8hjfUs//G7QMY6528Sr4cQ6/wLyIDn2PnJdgaYa5X4iZcQQKZbF1DnxJpTYo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694986958330431.98909102765003; Sun, 17 Sep 2023 14:42:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qhzUm-0004cO-2R; Sun, 17 Sep 2023 17:40: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 1qhzUf-0004ar-6i for qemu-devel@nongnu.org; Sun, 17 Sep 2023 17:39:54 -0400 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qhzUd-0004It-Gd for qemu-devel@nongnu.org; Sun, 17 Sep 2023 17:39:52 -0400 Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-31c65820134so3426157f8f.1 for ; Sun, 17 Sep 2023 14:39:51 -0700 (PDT) Received: from karim.my.domain ([197.39.215.8]) by smtp.gmail.com with ESMTPSA id n11-20020a5d484b000000b00317ddccb0d1sm10561735wrs.24.2023.09.17.14.39.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 14:39:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694986790; x=1695591590; 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=si5dpHlVizbBUEmC1yaur7aiNcqM1wSFje2BFdDGY6c=; b=hPGZBvlMu9a4taknKvqqSzYVzRmqSX7UYEUVoz4TigItkilL9z0YhiG7xIyrG1pBZP ySjmR00TqaCS/5faSgVF/dgaim97TQ8w5hHj6XFr115ogfd3gNFqRIXh4jTQcxti7Aw6 g0MVjGtmxLN39jjOHyo5TxyKvc6npiAE5vU8fqGYngKBEjQe2Ij8v1Yrch28vawfgBNQ PCU4FGoiJ7PEqnIzCnNve6nZFkLfwxTLsJiZEXiRLxU/fefOQ/jMlQK64mDH1U87Jl/y qEceXsEVKyLN5BHN8v+3ZQS4P93gDYOcWGHTiJRwpc2O2G9cDLowQYpTLMOU0u5g6QQi E5cQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694986790; x=1695591590; 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=si5dpHlVizbBUEmC1yaur7aiNcqM1wSFje2BFdDGY6c=; b=VuK0Yt/mIzNWTZ1kryfJ80TGaroUjICOonvvorPlAZ3P+fbcWwMP9odAHcjnyU8NrJ orK2uaKYxpEn038SdUfvrX9UuFYXu5RJ7SSASkOVnOI6LQbIyYPtXESTymszqvQjbVPu rM9GO9qbe0JlYAmb2Pf5HJALrxOkNtLYZY3WfATdCQKOpo3UyLxGCY+dBwxHs3USPVEY LntnhhuMYh/kTmlfQFv5Z9fnP+SZGxxOwOW849t5inUAHI1t8KCzMIMfZH/grDg6f5ra TWGXmVeJ72qlqoF5XFkrtolq+pXh/B6eBeBOV29OF5Ys4HAnwUIQ0vfNcFyZlCOo2l5F Hrcw== X-Gm-Message-State: AOJu0Yzs09VmNWNYUYHAwEsQQGdruh+U1tarsUhB6HUmsaGI+J9JWVQH SMz5MVS/p0qC8jxPt0u5YtI41NoT0BI= X-Google-Smtp-Source: AGHT+IGHeknOgZkr+GGEY/Unc01du6fnSnjPuRBC/KVAxW8xPV+Zl6fwhjtnaCoZU5XCqEzrqrMmKw== X-Received: by 2002:a5d:69c2:0:b0:319:8bb3:ab83 with SMTP id s2-20020a5d69c2000000b003198bb3ab83mr5537151wrw.66.1694986789711; Sun, 17 Sep 2023 14:39:49 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: imp@bsdimp.com, Richard Henderson , Karim Taha , Stacey Son Subject: [PATCH v2 19/28] bsd-user: Implement get_filename_from_fd. Date: Mon, 18 Sep 2023 00:37:54 +0300 Message-ID: <20230917213803.20683-20-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230917213803.20683-1-kariem.taha2.7@gmail.com> References: <20230917213803.20683-1-kariem.taha2.7@gmail.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: pass client-ip=2a00:1450:4864:20::42e; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wr1-x42e.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1694986959498100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Stacey Son Signed-off-by: Karim Taha Reviewed-by: Richard Henderson Reviewed-by: Warner Losh --- bsd-user/freebsd/meson.build | 1 + bsd-user/freebsd/os-proc.c | 80 ++++++++++++++++++++++++++++++++++++ 2 files changed, 81 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 f2f047cca3..8fd6c7cfb8 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 0000000000..cb35f29f10 --- /dev/null +++ b/bsd-user/freebsd/os-proc.c @@ -0,0 +1,80 @@ +/* + * 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. + */ +static 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.42.0 From nobody Tue May 14 15:16:59 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; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1694986866; cv=none; d=zohomail.com; s=zohoarc; b=Q8t0jwidnEHqBrRbW2kJEAOthKBeJA/gflyPMmr/633hbf4DCCY6HDA9FTouwDORRC2xrTW7fGnRGnit0VFSOp9QEDYQYardyE5t3ZXfurlUfdJstMWWdnyPLhdC8rND9LpFsVuQEM1FVEKhcG7CJ5MDPTW1SvzuOnCah+H4DNw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694986866; 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=ys1OyN6LWTWmM5gC1nm5PCKVJBs4yHemXKcMj/MrNMQ=; b=hki5Vnv9zhCT0TPMW/LZlYFk2ZIlItYsiYT2ZiPJm3+Kp0gav1QBTGvxtpr6DPbCsc4tnA5ZCdQBfEFhBYC2uG9sWLBPJjHxicZar8tQeEegUlNaW3PD0MX5Xbe4FhFfk2DMHIcn7Ph1HmsxllWldXWMv4882MVAQBZ07au3Rtw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694986866330824.7784597141001; Sun, 17 Sep 2023 14:41:06 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qhzUq-0004dp-76; Sun, 17 Sep 2023 17:40: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 1qhzUh-0004bF-LB for qemu-devel@nongnu.org; Sun, 17 Sep 2023 17:39:56 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qhzUe-0004J7-MA for qemu-devel@nongnu.org; Sun, 17 Sep 2023 17:39:55 -0400 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-404773f2501so33428275e9.0 for ; Sun, 17 Sep 2023 14:39:52 -0700 (PDT) Received: from karim.my.domain ([197.39.215.8]) by smtp.gmail.com with ESMTPSA id n11-20020a5d484b000000b00317ddccb0d1sm10561735wrs.24.2023.09.17.14.39.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 14:39:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694986791; x=1695591591; 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=ys1OyN6LWTWmM5gC1nm5PCKVJBs4yHemXKcMj/MrNMQ=; b=kSY7i+/whaRaHl2t7j6Aa+OkrRUzndx6gJZc9nOLludvf8DsZbBMpGsbgCDLGogRfQ VSc9LtwNw/kJJOCJSSRissxLayz03GoNSb6qDWy305q3VS4S/VPCSjjMRrXM7Zku7dtb hTEhsXvXhGSTYqreSSKHSHVYUTWi2yLEjCu64Q2II0szqhorH1QS5lxgD6YmtORCNZLg iD7vpiDQgVJOML7/eD4Mp+0CkV9TAmY42nCZffO0e1Ng32yON+3m2LzvRwv/0JiIMfpK mqBWxyzVMD1pjzjeDnaNEldtQPo+dnhhhuKfmmbhN1/9TlJNUZfwDfDLeqhjsaoXerbD XKcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694986791; x=1695591591; 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=ys1OyN6LWTWmM5gC1nm5PCKVJBs4yHemXKcMj/MrNMQ=; b=BU/7iI47XhJ+ODLm0imcWkDHAW0Figzp8xrlUM3G2hMf5ypmtL+z7Lfv2eYcrR1Mb4 7RzjkLSDJcG7Y74iWGwqY6sZ/kdP/UDqDy25PxllmYGrEoJn8/zS6iikpPuF88bZwWjF MBVMczjHQPWXs6T5bNQ71AXLFF+lCor6/DTMUo6ABxbGP5fdlpuZobJtTMVnq68jC1r3 FYrUF8zaqGU3znDOINvzN4v12gEqJ6qHHOprgvXp7u9YLXwH5GucMpPXJHKIpGzdWH92 yIRaVutP11xfCFL3lWgY2UFjFbnjptHZFrQCtnarfqiD4aJPd7PWiljdK0Wsv4s9+sFi 3yIQ== X-Gm-Message-State: AOJu0YyGrMPvsmGX9pJgMubM28B/hEGLn7xOm9KVnoX8FoNNav1fIf/5 XbcXS+0ZqJ87ilPUcW/zlmsnDTR4ZOA= X-Google-Smtp-Source: AGHT+IFNgoi7UX++iKtkq0Hn0JpDjWDZtoMXltfbr97lZOl0O5nWIqLCBaikDyYAo9OY6UcHaJA2pg== X-Received: by 2002:a7b:cd9a:0:b0:401:264b:5df7 with SMTP id y26-20020a7bcd9a000000b00401264b5df7mr6112826wmj.35.1694986790871; Sun, 17 Sep 2023 14:39:50 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: imp@bsdimp.com, Richard Henderson , Stacey Son , Karim Taha Subject: [PATCH v2 20/28] bsd-user: Implement freebsd_exec_common, used in implementing execve/fexecve. Date: Mon, 18 Sep 2023 00:37:55 +0300 Message-ID: <20230917213803.20683-21-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230917213803.20683-1-kariem.taha2.7@gmail.com> References: <20230917213803.20683-1-kariem.taha2.7@gmail.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: pass client-ip=2a00:1450:4864:20::32e; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wm1-x32e.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1694986867317100001 Content-Type: text/plain; charset="utf-8" From: Stacey Son Signed-off-by: Stacey Son Signed-off-by: Karim Taha Reviewed-by: Warner Losh --- bsd-user/freebsd/os-proc.c | 177 +++++++++++++++++++++++++++++++++++++ bsd-user/main.c | 2 +- bsd-user/qemu.h | 1 + 3 files changed, 179 insertions(+), 1 deletion(-) diff --git a/bsd-user/freebsd/os-proc.c b/bsd-user/freebsd/os-proc.c index cb35f29f10..12d78b7fc9 100644 --- a/bsd-user/freebsd/os-proc.c +++ b/bsd-user/freebsd/os-proc.c @@ -78,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 f913cb55a7..a12b4be80f 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 2cf96d9a15..1ed6024b5d 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.42.0 From nobody Tue May 14 15:16:59 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; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1694986944; cv=none; d=zohomail.com; s=zohoarc; b=mlh7L44HlydndO+vnB7YB9g85hcj6Q0jM996xAEISv947AR5mDCWwccfy03oM5tl4VO7kIKJb2gM9NaRpOyucTfUEPeSkVHNcIqYXtxiL6kYfvqyRRH1ixDqQmkrazaMnGCX0m9HiQnGXY5k+hW01dbcvsX4m3Gvy0bjTXefI4g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694986944; 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=lQgG8CXW4u1VDTt9+gWEd2GeC9t1mY5/dGt9dMGKs/4=; b=BgGr2Uf29hHwptg7Qcz1ILlIvSLXubqM4mXt+prz8f/WHjOKSULxyJbvQzvh2lRUwFa7/+IBXgQpU6AeQdMw78ueQr+EFqDq2FNSpC17eC3ssH/4OclaeA4v4LdQsNLTkpzr8b0rWqs6tt1w308MApDq18XYiqzpnUNMxibHPJE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694986944169228.09528906759203; Sun, 17 Sep 2023 14:42:24 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qhzUo-0004dW-BX; Sun, 17 Sep 2023 17:40: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 1qhzUh-0004bE-G2 for qemu-devel@nongnu.org; Sun, 17 Sep 2023 17:39:56 -0400 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qhzUf-0004JF-I7 for qemu-devel@nongnu.org; Sun, 17 Sep 2023 17:39:55 -0400 Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-31f737b8b69so3715906f8f.3 for ; Sun, 17 Sep 2023 14:39:53 -0700 (PDT) Received: from karim.my.domain ([197.39.215.8]) by smtp.gmail.com with ESMTPSA id n11-20020a5d484b000000b00317ddccb0d1sm10561735wrs.24.2023.09.17.14.39.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 14:39:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694986792; x=1695591592; 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=lQgG8CXW4u1VDTt9+gWEd2GeC9t1mY5/dGt9dMGKs/4=; b=RVQi+0X8dcXsBEPktSRddhidZItGpny4zGrE/JCSuzfbtzrVsuEiwvv3TWvNc6t/f2 t2aThqlcqqQLazmmXCLNe8IQJYu5zX/G9+5lvjBsiZNPyhCw/jJMEvKfP3yOn0iySPgX DV+XnStUZSAo8NzqfP2prNIsMfVBnwtGV8MfdJzRR5SRiH35rD757ekhkrW2AxfoxxvB eYFoQYGeRGu0A8zRa0bjjOQhBHbe3Jx+nnFSdkeG/bClcNsqqw0j3h6iMNZwF0e3tYav 0THMujrSbpE/Ov2OR+yJuj8Lhn/kqowTk4vwHfEcVVyncgAx3LgtltiGpKtr89EDirwh E3Bw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694986792; x=1695591592; 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=lQgG8CXW4u1VDTt9+gWEd2GeC9t1mY5/dGt9dMGKs/4=; b=cGGX64FtANBy9BFSYeCN07f7WBGtQ6LMqN0F8288ES52yFoaBLRf0iyjTRJz/lvOal NDC9gXCSn0qN/p2mAWLsW748Tuww3PrfgsVYcC1/5fgnmIrd/9cGz4PWD8wF9wDasbvM FbyI7paxG6VP62dGeXs43Y20uXQwCE4ZlRvxJ7xKWi8gmStjc0wq4+A2LHSJX9ql39iy iRvznotm1ICmOdWBf8QackWkI1iAX7au7Yasqa8bVqURMUBWPn7Flf7f/Ik5gQFxT7in dkxLt2pAPJGI0/UR/GV/m/I4utHALwRITQ0ooNqVFyPZxGrDVb79Ag43uCVw96CYrPeK UraA== X-Gm-Message-State: AOJu0YxC42wIe6eFCe20FWjkyc8S53GKDXpJERX2f6jKhHFILKB8pxT4 wMr5AoSP4pU3rXmzm74Lx5TCcOYJn3o= X-Google-Smtp-Source: AGHT+IHp2SPsd0i34s0mE96R5ZR6A3pUIFvGxYj2dsm2Uyq6Mypl8vHaFZbRqQ84ZIwy9kzJSfeVMA== X-Received: by 2002:a5d:420c:0:b0:31f:91ae:4509 with SMTP id n12-20020a5d420c000000b0031f91ae4509mr5846465wrq.40.1694986791984; Sun, 17 Sep 2023 14:39:51 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: imp@bsdimp.com, Richard Henderson , Stacey Son , Karim Taha Subject: [PATCH v2 21/28] bsd-user: Implement procctl(2) along with necessary conversion functions. Date: Mon, 18 Sep 2023 00:37:56 +0300 Message-ID: <20230917213803.20683-22-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230917213803.20683-1-kariem.taha2.7@gmail.com> References: <20230917213803.20683-1-kariem.taha2.7@gmail.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: pass client-ip=2a00:1450:4864:20::436; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wr1-x436.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1694986944449100001 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 --- 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 12d78b7fc9..6b8753f8e5 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; + 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; + /* XXX we should check target_rc_count to see if it is reasonable.= */ + host.rp.rp_pids =3D alloca(target_rp_count * + sizeof(struct procctl_reaper_pidinfo)); + 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 71a2657dd0..b7bd0b92a6 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.42.0 From nobody Tue May 14 15:16:59 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; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1694986888; cv=none; d=zohomail.com; s=zohoarc; b=d6BhSkjyC94YocMy6BOARpISQRN5XbJVX0Mk7dpg2QNzRMGkn7ytYJPT4FRkCDmLj4XcLpLwtoOgDphlzjT2kLAWNZbYj/R2WI8Z38sW4190A14heuZCTPzGonJKi83LjPMSsvf3UVGDmKE65iGkMoH/yEkqn9ZMfb88vvivo7A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694986888; 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=SrhHSKh9Zy1jpJox1NZgc4ABlNUS27qhkUc+VlL02Mc=; b=aBvWWKL8FzLx9iJrj4xcR9cJPyaxDRZLxeSny7yyvAFjosIL72Q/x0xU0VdeXlt62RIcoGTYzUU/+TeEZf8XVv+P7vWha9rFe4HHlJTEBmu9aG6NqMGzX21DRY7jZf4okhQz29FoTghGDcOFCeVPTtNmqMm84IzEEh2hvDLfqsA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694986888577566.196697708946; Sun, 17 Sep 2023 14:41:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qhzUr-0004ei-9u; Sun, 17 Sep 2023 17:40:05 -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 1qhzUi-0004cB-Ri for qemu-devel@nongnu.org; Sun, 17 Sep 2023 17:39:56 -0400 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qhzUg-0004JO-RP for qemu-devel@nongnu.org; Sun, 17 Sep 2023 17:39:56 -0400 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-4050bd2e33aso2274995e9.2 for ; Sun, 17 Sep 2023 14:39:54 -0700 (PDT) Received: from karim.my.domain ([197.39.215.8]) by smtp.gmail.com with ESMTPSA id n11-20020a5d484b000000b00317ddccb0d1sm10561735wrs.24.2023.09.17.14.39.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 14:39:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694986793; x=1695591593; 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=SrhHSKh9Zy1jpJox1NZgc4ABlNUS27qhkUc+VlL02Mc=; b=JcT+dm04B2yUYJr6ztrnVU/2TExgFRg96IfUojtr6ebAWDH8RbAY82aj6lFMcVYqa2 Meh3Stz1NFdU1/aYV4O+bIExtUIoE2xD0GgxRaSY+F9WPTW9DshLACXmJTzA35P9RKyc zOwgOOQXb+TVjaaotZJqu8yq6dNjTgJXBSBcmVpE02aAM2sO/MWHlyWoS4+2ccJqdVrS xSVd8igiQWDDjrkoB/d7Ym/9v7X0rcGjgA3TioUsT7LKt8q5ucmWr2IrRAjAd5qHSxEN AJtpEBU2ZcJMClQpuTKu/ZTphI146gFuJzGV3/Qnnzb2nkJQGBkXphKkMV6LdxX2P0kO hbFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694986793; x=1695591593; 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=SrhHSKh9Zy1jpJox1NZgc4ABlNUS27qhkUc+VlL02Mc=; b=XM5Qvd9gBKk0P/WlqQDQk+6Q2KD008N7rGzSpEdvCNpbuPv1/HeWJz0Vt48IKSTZdK uv1qCSghj9iqPcxyNP4vNdfb64xB5MOkZW6MA16G1KNc8Rg/YMGnxnKpw9kP6xhvIFL8 Fua04tptXRPZ9ry9+EAYUfIPGC6t/TwWFn8hwgLxhp60T5bqsNpoiLimilG/Ys5Yt3CQ e8fmxg30DTN4WUNViXSlhrfCQSUv21ODdeL31zXiu7lZ1F/PtLfh5zaGfdr7NjiRdFti MvOWSqSEmugoE0u00h+2swVOS9PMLwANyPYJ5gBv7RQgWM+7yVdY6YH1gaQ8iblfpg/J UsFQ== X-Gm-Message-State: AOJu0YwtZ2JBViwhTcvJCs7GzgYaVl6tTSjnGD4GsvzDS5W4EPc3sxcZ 2MLQeeZVd74me82Crg7NxOvsqrlWAnY= X-Google-Smtp-Source: AGHT+IHCsLWO9Oom+NsaebJNx7WjKd0SvEIYLbPK6JIbYDwt+RVzgp5S5SXq8TSfSblSAY9YoWw08Q== X-Received: by 2002:a7b:c38c:0:b0:3fe:785:abf9 with SMTP id s12-20020a7bc38c000000b003fe0785abf9mr6698691wmj.2.1694986793210; Sun, 17 Sep 2023 14:39:53 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: imp@bsdimp.com, Richard Henderson , Karim Taha , Stacey Son Subject: [PATCH v2 22/28] bsd-user: Implement execve(2) and fexecve(2) system calls. Date: Mon, 18 Sep 2023 00:37:57 +0300 Message-ID: <20230917213803.20683-23-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230917213803.20683-1-kariem.taha2.7@gmail.com> References: <20230917213803.20683-1-kariem.taha2.7@gmail.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: pass client-ip=2a00:1450:4864:20::334; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wm1-x334.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1694986890020100003 Content-Type: text/plain; charset="utf-8" Signed-off-by: Stacey Son Signed-off-by: Karim Taha Reviewed-by: Richard Henderson Reviewed-by: Warner Losh --- 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 0000000000..75ed39f8dd --- /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 b7bd0b92a6..515eaaf31f 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.42.0 From nobody Tue May 14 15:16:59 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; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1694986921; cv=none; d=zohomail.com; s=zohoarc; b=Zx54sG8nPKG0CnaVFb2utE/Lw46cBGg3JU/Y0SObE3m57Rroy0904tvF7ieVpZZG1Ns0zVxlu4Q30/QeiEbdhIoAf2c+QAaW+1QBBFYFwwkiCk3awQttC4Yre1igRVvzUUT4ucYfkYjXdb5Z8RVrZavpp8EsB7w80GzLrSGBaxk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694986921; 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=ghjayZwkbL273HpL8TRoMXjx0yU87UyELyhBwrVLyT0=; b=ee0pe+qmFbsfeTYHTg6RDz4HKttO7wiqHpgtwgbLsA9uqFNnlr8z7SeB3LCh9EsfIhInj3shsnL3Uq8X0EbX4keVKrGp0OP4RdksXf2Zp4+4a6L3UMt5fFHozaFPVBsR8YbBTCB83uRBeW0aqko3TZ31R3Cx1s4O37OQ1fy65Ts= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694986921236425.0400265331001; Sun, 17 Sep 2023 14:42:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qhzUr-0004ep-SG; Sun, 17 Sep 2023 17:40:05 -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 1qhzUk-0004cN-Bz for qemu-devel@nongnu.org; Sun, 17 Sep 2023 17:39:59 -0400 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qhzUi-0004JW-4l for qemu-devel@nongnu.org; Sun, 17 Sep 2023 17:39:57 -0400 Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-32008b5e2d2so596127f8f.0 for ; Sun, 17 Sep 2023 14:39:55 -0700 (PDT) Received: from karim.my.domain ([197.39.215.8]) by smtp.gmail.com with ESMTPSA id n11-20020a5d484b000000b00317ddccb0d1sm10561735wrs.24.2023.09.17.14.39.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 14:39:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694986794; x=1695591594; 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=ghjayZwkbL273HpL8TRoMXjx0yU87UyELyhBwrVLyT0=; b=D10wOiFPMGpK3hYZCbGOhJzlvFwzuQtzFZ1UcNq8Sq20aaHOiUq0evUSzmcYk4N3ff Q6TaADPMkfC/E1b9gYLmZbKapYT9dSbcJ/0fiKvRnxRcj2UDh4fVmQ1fv2BtyGkuBS8h sAFAcLk6PLGVcyhrjizmGRameuXP98m5qIOqMdLearK8CYaQlSBywSHViGwOSYAMcLSD TM83GpgLv78add4eJMYinov+SPABLEDE2bbtkS3mgOgXS4OeOUAwr4xwG9qec0erQYIH Abz9/z7GybMAT8uU2Rextg3P4hHEtjUsSVg9CRo6Rr7mu9qd9Q4TJm7DphekMrMQVtXW vaaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694986794; x=1695591594; 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=ghjayZwkbL273HpL8TRoMXjx0yU87UyELyhBwrVLyT0=; b=VsKTAvex1m7Qpclat6W4QwVPKWehkkqj6IiqdNVvc3F7oPd3CWFAbYyMAeQ3mcFyiP cqOJjCvw1biDXqws5lH1gqGsQidkiN9JcFBV/r2aApzrG3DaDBgPRIyfr/O5unlk0/Cs isSz5zJlnpI6Wg4/2Lm32+8MAcTCNsqO/FilehuDvxG8c3AYv4T6PH/kxn5mlfWjTiJB LsNehhjikpeza4g/jZDT8zso4o8E8V+KdzVtKmfF8+/SGVXRxoPk1cgu6aGiMz68UdyI F3QYVzqmdS+82Fl9e4+iqLFVkkV+wp3EbDsfrMnsajtvdzQg6+/Fh8wqu3gySdHYQ6T5 9+xw== X-Gm-Message-State: AOJu0YwR+T+lC2sUMwv+bZyeuOLZTaZwkxlKczyDcZYGquwRgShFl7sr +fKa1tjkb8aFpyqZiFzmmUIJ4SlA7eM= X-Google-Smtp-Source: AGHT+IHmjj52XDaUQfdAyGVtMsr8Lxr3Rcl+fajjPbXiosgOpynR43A9ju9PW75rO+lBac5EFidpYQ== X-Received: by 2002:a5d:530f:0:b0:31f:fc9a:a03 with SMTP id e15-20020a5d530f000000b0031ffc9a0a03mr3626554wrv.20.1694986794388; Sun, 17 Sep 2023 14:39:54 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: imp@bsdimp.com, Richard Henderson , Stacey Son , Karim Taha Subject: [PATCH v2 23/28] bsd-user: Implement wait4(2) and wait6(2) system calls. Date: Mon, 18 Sep 2023 00:37:58 +0300 Message-ID: <20230917213803.20683-24-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230917213803.20683-1-kariem.taha2.7@gmail.com> References: <20230917213803.20683-1-kariem.taha2.7@gmail.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: pass client-ip=2a00:1450:4864:20::42e; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wr1-x42e.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1694986922842100003 Content-Type: text/plain; charset="utf-8" From: Stacey Son Signed-off-by: Stacey Son Signed-off-by: Karim Taha Reviewed-by: Richard Henderson --- bsd-user/freebsd/os-proc.h | 77 +++++++++++++++++++++++++++++++++++ bsd-user/freebsd/os-syscall.c | 15 +++++++ 2 files changed, 92 insertions(+) diff --git a/bsd-user/freebsd/os-proc.h b/bsd-user/freebsd/os-proc.h index 75ed39f8dd..8a0b6e25bb 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,77 @@ 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 (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 safe_wait6(idtype, target_arg64(id1, id2), + &status, options, wrusage_ptr, &info); + ret =3D get_errno(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 515eaaf31f..55e68e4815 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.42.0 From nobody Tue May 14 15:16:59 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; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1694986954; cv=none; d=zohomail.com; s=zohoarc; b=mZTHpq6fP0NLov9H514Q8Axnc+t7J0jcFttb1KHXD9rRiW/kMwV+JheCJ64wGMsU+gAaxY0HOCvE1EU87fbquG/PESesxxyrkceM3wacZa5KumZgPxWBm/PHijaz1fh7SNV8Mn9A6oZzKI+/dK4YgFz7UvGHfk28jimCxRREFI4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694986954; 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=DLSK2Vy19+HO7TG5se0ovaw+QVTaNOOf92Nr5xgAdD8=; b=NcpZM9uqhWPuqB6SRxPOuR7SaDYr210HHvPbVnNuTVcFr17v9TiWr/Q0wBNbkSEEWbongQlsUi3oUheHoTM+k1drYBlK7hgqB+S0fZ9ipXRJJNAnL0eZd5ASYEzwK5XwX96Rq83ZeuJt+21PnZrwj0qGk5qt4wVEkzenoa2Jd7Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694986954707648.6515108861698; Sun, 17 Sep 2023 14:42:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qhzUs-0004fC-Gb; Sun, 17 Sep 2023 17:40:06 -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 1qhzUn-0004cY-7H for qemu-devel@nongnu.org; Sun, 17 Sep 2023 17:40:01 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qhzUj-0004Jl-Ge for qemu-devel@nongnu.org; Sun, 17 Sep 2023 17:39:59 -0400 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-404c023ef5eso20579105e9.2 for ; Sun, 17 Sep 2023 14:39:56 -0700 (PDT) Received: from karim.my.domain ([197.39.215.8]) by smtp.gmail.com with ESMTPSA id n11-20020a5d484b000000b00317ddccb0d1sm10561735wrs.24.2023.09.17.14.39.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 14:39:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694986795; x=1695591595; 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=DLSK2Vy19+HO7TG5se0ovaw+QVTaNOOf92Nr5xgAdD8=; b=ASdZV29QCvFvf0eA6Dg6EAgcMArrykOWYb7ne3v1otmikDYqOziU0eusVZdg7t0irY jRzarDLl4zBW2mcP5UUGf754kiLuGKMummHKuKTp9+hXJP75U2uD9GyJc6cgX2eE+2xN A0mNunwMF1liTLzs4XYB2fiJ+kZW5A/jgUphVjH1RzkFel8Z1yQWMcHeR5C/Seo5hrb1 gyxFGXOyuNXci1SzKulEKiHVq5dRG3iSimQqu81tv2Szi9sORtvqtCe9w/bpuSZRBlFY agXDOWoZij6sxRb4jsksFIMyb43pJqjs+AYkcnzhNL8HqdnBKEr4Sug7IXHe+GUufaBD ZNeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694986795; x=1695591595; 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=DLSK2Vy19+HO7TG5se0ovaw+QVTaNOOf92Nr5xgAdD8=; b=DQAAj4sZE8czvcsVmKg3HGrX0OMGXXXPFZU8YZv0Kc9p3S346s2Z652QD8IaTunRtz bjzhdkhwmNgMs0vQ1Q42VNJT9KvSv/n14lpls91aoLL7MwC4Os9gro30sKpilWOwEebZ z6ibdFJM6BUaZIw0z2mZf7N1JdtwTdZkCT0LZzwhLeZ4yVLY4CrZ/7yng0KXR2bh6F+6 F5O5lUnUlq1Z/cud+PmMcGL8Fads7Q6/mPIWP/CG482/tw++uV9/ztvMY8AvPG3shBra NjvGFLInG9n9aaophXOir5zFaAimMNdRCTiSRhpS9Zwk/gzJrJ9i3Tz5L3Bw1hHn0f5w oAqw== X-Gm-Message-State: AOJu0Yy5we2LKVaMBSxhixRku9NKULj/Y/TKxZicwqwrExzRUD3ZfzEw +W99XfAxa37FzBXidp3Q5FLP7NM9OO8= X-Google-Smtp-Source: AGHT+IFff72HxFYvxMBtHL+iDjhTajulkUwIjO3fkh3AYHZxMQ51skFTAHlZ4UHclNVEehRDH8LTag== X-Received: by 2002:adf:e5cc:0:b0:31f:ddee:d216 with SMTP id a12-20020adfe5cc000000b0031fddeed216mr5961809wrn.69.1694986795520; Sun, 17 Sep 2023 14:39:55 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: imp@bsdimp.com, Richard Henderson , Stacey Son , Karim Taha Subject: [PATCH v2 24/28] bsd-user: Implement setloginclass(2) and getloginclass(2) system calls. Date: Mon, 18 Sep 2023 00:37:59 +0300 Message-ID: <20230917213803.20683-25-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230917213803.20683-1-kariem.taha2.7@gmail.com> References: <20230917213803.20683-1-kariem.taha2.7@gmail.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: pass client-ip=2a00:1450:4864:20::32e; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wm1-x32e.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1694986956143100002 Content-Type: text/plain; charset="utf-8" From: Stacey Son Signed-off-by: Stacey Son Signed-off-by: Karim Taha Reviewed-by: Richard Henderson --- 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 8a0b6e25bb..1866f0b2d6 100644 --- a/bsd-user/freebsd/os-proc.h +++ b/bsd-user/freebsd/os-proc.h @@ -123,4 +123,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_string(arg1); + if (p =3D=3D NULL) { + return -TARGET_EFAULT; + } + ret =3D get_errno(getloginclass(p, arg2)); + unlock_user(p, arg1, 0); + + 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 55e68e4815..d614409e69 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.42.0 From nobody Tue May 14 15:16:59 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; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1694986964; cv=none; d=zohomail.com; s=zohoarc; b=FVatl1bsoMZ5PQ63yDFaCb91PMzbTAEYHuy3b4sX4S+0155rlND/q6ZRO/ZHFVV+Tm0KtFqFu7cr7l2zL0F+OCuAlUg8zRVEGL/eooAqJQ8dp1EhckUW+77d9hUYynEceztb6SGsxYuK5H4lRUUTrYBzNR2cbwvIbcVBADNEMRo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694986964; 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=9JgC3jMOFItmqfccCsYXb/PVYrME+XvZhR9KVu34CAU=; b=DsJFSno805Wd0VQKBRUizBsGxUMc03BWoR5gZYv1jl7DlYY1Jsl8P2bnE26wS9xWSFDdfeV8iJkwBPUrrOK3IpwNUfS/1Eodp1eMJ+0l3cQgCxykuRo1LWjEEsfaiJg0PVLF3ah3YZUWgE9KPeElfOoEouWmI/JPyw12jLBKgOA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694986964079328.8928938692301; Sun, 17 Sep 2023 14:42:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qhzUq-0004dq-9b; Sun, 17 Sep 2023 17:40: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 1qhzUn-0004cZ-7E for qemu-devel@nongnu.org; Sun, 17 Sep 2023 17:40:01 -0400 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qhzUk-0004Jv-DV for qemu-devel@nongnu.org; Sun, 17 Sep 2023 17:39:59 -0400 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-32001d16a14so1218684f8f.1 for ; Sun, 17 Sep 2023 14:39:58 -0700 (PDT) Received: from karim.my.domain ([197.39.215.8]) by smtp.gmail.com with ESMTPSA id n11-20020a5d484b000000b00317ddccb0d1sm10561735wrs.24.2023.09.17.14.39.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 14:39:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694986797; x=1695591597; 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=9JgC3jMOFItmqfccCsYXb/PVYrME+XvZhR9KVu34CAU=; b=bJxmezm3cVG+QmOsrBBcIrrVnKCONWPulKQR6UcBRSLvwOZ+8z3Svu3vZzHsZX8dYA KRkTjpSq31C7y9xYt9Pv+TM2A6vHLmRf4RQFlLgzfs5RJbXsoKAhlqaJQANWk1JZLO0Y nckRRNZKf/0wFwDvo4bOUOgZMu6FWc1caODNxpMqwrjptlrbZZF68mjNH4yelMbYNQ+7 C/g/tSEg2Y2buNHUbOfg38BBgzmvtJx+zVWUH51oxOT5jAwIfoAJhOQzmT44Q9G3ZO5g VtsLz1iHxAB9mcmw6T+HLYYoiIpAl0BV4C/fytACjX/l0WMVn3Wm2k5n1qLK33NGoEy5 mo+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694986797; x=1695591597; 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=9JgC3jMOFItmqfccCsYXb/PVYrME+XvZhR9KVu34CAU=; b=PULT49szHUR5g1zpyXsg3tDecVxdfGvG2xANznYJTAuM36KO5MzYgaS6AmBKDYo+lC oZaOG66kaM50t4R8JdfltcdXgSGQrTu9ZG5reRsm4T16JWlZz64ZtIIf7RXc09vAfFPJ idQZiMGcl0Tec08UJmvy9D9hg4gIXBQO/2Ozi40N6KOVKWmnoN8/vFJHk4gA+1DDDR07 SllyN03AIm+ggF5HEAlf5v6NpFgGJ7bj+tHArssQsvNB7EBgTDQy5TMDhPDBkoUKpysw NZOTrE2PslW4o8uzmR3qOTk0ez7F3TB5tolXaggaGLR2GJV1aNQdSC4zB5bLQzcA7Agc s0RQ== X-Gm-Message-State: AOJu0Yw1PQHB5tcjrZcxNsxJVRSTSz6JEdgvanU8IJU/RfhH4F0Qa7ig KZ0BPmgIleFqgzj+cxzGp9SkCDSrmSg= X-Google-Smtp-Source: AGHT+IG6fo/Ez1xkwekNSbjK9+ZyjZzKF8pcED9NQH4M+zUBmGNjTdI4rjh6nR6wqEX0nBdBbFk8pg== X-Received: by 2002:a5d:62c6:0:b0:31c:6420:fff with SMTP id o6-20020a5d62c6000000b0031c64200fffmr6144973wrv.62.1694986796662; Sun, 17 Sep 2023 14:39:56 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: imp@bsdimp.com, Richard Henderson , Stacey Son , Karim Taha Subject: [PATCH v2 25/28] bsd-user: Implement pdgetpid(2) and the undocumented setugid. Date: Mon, 18 Sep 2023 00:38:00 +0300 Message-ID: <20230917213803.20683-26-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230917213803.20683-1-kariem.taha2.7@gmail.com> References: <20230917213803.20683-1-kariem.taha2.7@gmail.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: pass client-ip=2a00:1450:4864:20::434; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wr1-x434.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1694986966186100003 Content-Type: text/plain; charset="utf-8" From: Stacey Son Signed-off-by: Stacey Son Signed-off-by: Karim Taha Reviewed-by: Richard Henderson --- 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 1866f0b2d6..47bcdcf8a3 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) @@ -155,4 +157,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 get_errno(__setugid(arg1)); +} + #endif /* BSD_USER_FREEBSD_OS_PROC_H */ diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index d614409e69..99af0f6b15 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.42.0 From nobody Tue May 14 15:16:59 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; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1694986901; cv=none; d=zohomail.com; s=zohoarc; b=hjf5iTqVXGvptU32ZwmPU5n6GqVc4cd8gJc2al7v8RoEBJRhacd8ff74+M9vIAx1qbo3cOfn40gQHe85JhcaK49ZETyp5PPvkCLT+j9tBdoYhdVwQuKvsLnUq8xRICKbetbK3D/rJ1JbdkVmP3jV8BnRNe1b64YV4ZdcR3B+U68= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694986901; 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=VpDK27XFYFlUK18Xjk609Zfh0efzDinwgtTC93pyvcY=; b=cVzYeDOYBDcs0gaChaaoy/nBzoKwV1pLAdGinr7IyLIlO1C+6+RJMSxF5jUgWpfzYBNUbYjyn6mBbgPNY0oLo5KpsbU9AJvOgvC6mtcfp3sbjWuKG1VQ7AR0bFpj+9DFCtkBONesOj9N+e4g/sEfWV7vLbcknHQuA9LGPZKcsLY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694986901650272.52919595705384; Sun, 17 Sep 2023 14:41:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qhzVH-0005Dz-Ov; Sun, 17 Sep 2023 17:40: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 1qhzV5-0004sl-4U for qemu-devel@nongnu.org; Sun, 17 Sep 2023 17:40:28 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qhzUm-0004K4-0V for qemu-devel@nongnu.org; Sun, 17 Sep 2023 17:40:16 -0400 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-401d80f4ef8so43414585e9.1 for ; Sun, 17 Sep 2023 14:39:59 -0700 (PDT) Received: from karim.my.domain ([197.39.215.8]) by smtp.gmail.com with ESMTPSA id n11-20020a5d484b000000b00317ddccb0d1sm10561735wrs.24.2023.09.17.14.39.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 14:39:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694986798; x=1695591598; 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=VpDK27XFYFlUK18Xjk609Zfh0efzDinwgtTC93pyvcY=; b=eRb3Tw1PeS5O6Bh0gyVt9sowuUA6LPS7x4k2ANby4VLQstrvue+Uzekh2HpGwBQmAS 7SK7XIt5gWftc2R3jLpj0JpQthdvq9gPn9mJPDeMqsU3Q52YtfFXKXol3n+jSCCc7fY5 fCS3U6GftRUjw4Cgc7MzGDAVhD+JcHgT6kiLJTaqVdq5WObMCi6glINusErfz58Prwbn MlpSAGbJ0yOvB3+f6Z8NQkhbI94oopN+hszrrkqmomCbUt8Q0LEuGZ/Jqhk/qsE02wwK B/NBrJQyr4Ov0+NZoKCjLv/0Kx3LtQe36fRGvoNJELkqPifr2L0ISGFxRwxq6990liRt emvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694986798; x=1695591598; 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=VpDK27XFYFlUK18Xjk609Zfh0efzDinwgtTC93pyvcY=; b=c6Jci2zaKrGC8KrgTTp8qji7BQ7LcuZLkrRUdS+J4JPxBJ2OqOh9GtOTZegSKAS4rS Ssfku7uyFSuCLnktsX6ETrmEi6nGud8jCXxZ0EfSzIRbyGArQlNdKbigs9OftXpOrejk iRNsxPM88UGCojUpl5SVQ1sm2uTqWjUbUkjv+iz8WmdHyhHSIy7MikZIorCMZfuEiEdM G7oSvCVpGtHXkDxcPGGKWQ/hpZyK/ZzbQboSOg8lptfzqcXXH1n0wwrgnMsHBWQXu5z8 /AcaLruGjwSRm75oX/f+gpHudkch215LfdSL7hfTvZZqYNmCJWlk3q4QJXYIL2uUBdSn uhjw== X-Gm-Message-State: AOJu0YxKjFUBDMgM96N6tPxT+vetXWCYyyq7Kbfi7/qocqmBD91b9iyV zdK2VxYSpiVuj4+VbymikGNXQRb+zHc= X-Google-Smtp-Source: AGHT+IGWJWbNamVJ0TJeNIcRyuGlI3ut/Bcnc+BjWDXkpk7VWpeVuf4WVKMuW0ulmDnHVa9HcaJjQQ== X-Received: by 2002:a05:600c:3657:b0:3fa:8db4:91ec with SMTP id y23-20020a05600c365700b003fa8db491ecmr6508351wmq.10.1694986797793; Sun, 17 Sep 2023 14:39:57 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: imp@bsdimp.com, Richard Henderson , Stacey Son , Karim Taha Subject: [PATCH v2 26/28] bsd-user: Implement fork(2) and vfork(2) system calls. Date: Mon, 18 Sep 2023 00:38:01 +0300 Message-ID: <20230917213803.20683-27-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230917213803.20683-1-kariem.taha2.7@gmail.com> References: <20230917213803.20683-1-kariem.taha2.7@gmail.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: pass client-ip=2a00:1450:4864:20::32a; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wm1-x32a.google.com X-Spam_score_int: -13 X-Spam_score: -1.4 X-Spam_bar: - X-Spam_report: (-1.4 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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 @gmail.com) X-ZM-MESSAGEID: 1694986903399100003 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 --- 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 47bcdcf8a3..14478d4bb5 100644 --- a/bsd-user/freebsd/os-proc.h +++ b/bsd-user/freebsd/os-proc.h @@ -178,4 +178,38 @@ static inline abi_long do_freebsd___setugid(abi_long a= rg1) return get_errno(__setugid(arg1)); } =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 99af0f6b15..cb9425c9ba 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.42.0 From nobody Tue May 14 15:16:59 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; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1694986923; cv=none; d=zohomail.com; s=zohoarc; b=ksxpx4sJlVIS8pwCsPGtFR6OKpQnscQ2f5PPWuKUPQb91H/Gb+G1wzBlf86zQ40Skxe1rglEt7XP+SRwtCM7XDRcyl75Jx6uPi7Tk0E6BXru/nX9IjL2qfPpYyH5wpqiD2y0Z5xqwpyCs5eOUwNdX0nLhKc5nhyXF/5OWsLa8R8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694986923; 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=H227gA3OyYFvq4OxqZqbzoLKSUHlAdHUEYmn3BUB/W8=; b=NLfJPr1o7BdgBnXKs0CnHHSDJYYslNVaRskzH+Wg5EZSOpWHOf0oHt+NVKgVDvswal7SH1S1a5Ed5wJW5yg8XQJFejZLYM7MoNVJhwOvIYt3OkV/NyAygHDYn5vYjOte7DcBM90uIS+gxMdMVpZ7qBGBHiEVQg6Ic3iQUuHacRw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694986923182431.42492111234003; Sun, 17 Sep 2023 14:42:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qhzUt-0004fS-8R; Sun, 17 Sep 2023 17:40:07 -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 1qhzUq-0004dv-Fz for qemu-devel@nongnu.org; Sun, 17 Sep 2023 17:40:04 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qhzUn-0004KA-GM for qemu-devel@nongnu.org; Sun, 17 Sep 2023 17:40:02 -0400 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-4050bd2e33aso2275465e9.2 for ; Sun, 17 Sep 2023 14:40:00 -0700 (PDT) Received: from karim.my.domain ([197.39.215.8]) by smtp.gmail.com with ESMTPSA id n11-20020a5d484b000000b00317ddccb0d1sm10561735wrs.24.2023.09.17.14.39.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 14:39:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694986799; x=1695591599; 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=H227gA3OyYFvq4OxqZqbzoLKSUHlAdHUEYmn3BUB/W8=; b=elyLhH9tRC7oEQqHgl/+b8Pn9fWIL5MfZPzCY5f5s7ejKkECwNqJxMx5Sm52sKJ6bT /T754jBox2jPomG0GmWfbS7bXSuRMFGOXCX+Ri/eeDxb+8KDv2JZKGR+YRXuRAJhzEHX fdUbBcR5HxF7T28vA5FoKGAoiDRaXntrthKhQdNjX7s+4pUkcI3xnQWZF8Nrptd7x3fE TJzUW7aaVTgXjkGhNU+Boyd7RaT8xQV4WRX5ohZWHsE9fKgw34JX/2OZT/DIHQOrHhgw AdbhG7RWYcGBLQN9Ex8Zhqj9DCbgYYGllWdhdE/Bwc/I9yOZqR52DqeRKdzm8w4SJ/+h 72iA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694986799; x=1695591599; 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=H227gA3OyYFvq4OxqZqbzoLKSUHlAdHUEYmn3BUB/W8=; b=TxWRJ+yOT5TJgju7RTOunAKHLJ3xKp6LNvCzmxlDIM9BgmMxyJhvD0Cykm8IQQXKGd b+s/kGzGyP38wtOmOOlU6w1C/nhhE0UtL7yxANmJVScf428aMLNRVtWDqQygks1IkHfW O7Js/s7Ec9Ur1VUIQThx9EUvJT7MMu4coVsYbxgDRXUcDtYosS8B78tPpGU1isKGFnTP KDXE8Aj4e7Z2qJPWoykCWoTFN81oBmF10/t3IADVdsc5GgvY4UpOL/IE/D725PwAiNdE qvfXLC5U+pKfy8CtJmf/4f0OeuMm3noHc4auqTE6jeB9VHFzgoaIH/KxbM0hirgU9RTn XEjg== X-Gm-Message-State: AOJu0YyS7Et4h/WMtpxsy5cfxhjcxwSpMHBIfgCmWjCotd0ngKSGY+Jh RRJJYgyxtAjGvXZEwTcR7kLn6eCW6xI= X-Google-Smtp-Source: AGHT+IHhya36nlo0eZ/k/DQIHNZFY6KJWPRGYuO+1MeJT8sPegaCiapvUALgy6HufICXuZ7cZq5BQA== X-Received: by 2002:a5d:5e89:0:b0:321:52fb:5703 with SMTP id ck9-20020a5d5e89000000b0032152fb5703mr575766wrb.13.1694986798851; Sun, 17 Sep 2023 14:39:58 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: imp@bsdimp.com, Richard Henderson , Stacey Son , Karim Taha Subject: [PATCH v2 27/28] bsd-user: Implement rfork(2) system call. Date: Mon, 18 Sep 2023 00:38:02 +0300 Message-ID: <20230917213803.20683-28-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230917213803.20683-1-kariem.taha2.7@gmail.com> References: <20230917213803.20683-1-kariem.taha2.7@gmail.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: pass client-ip=2a00:1450:4864:20::329; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wm1-x329.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1694986923985100011 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 --- 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 14478d4bb5..a406ef7db8 100644 --- a/bsd-user/freebsd/os-proc.h +++ b/bsd-user/freebsd/os-proc.h @@ -212,4 +212,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 cb9425c9ba..4c4e773d1d 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.42.0 From nobody Tue May 14 15:16:59 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; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1694986896; cv=none; d=zohomail.com; s=zohoarc; b=OhQeUEZw1KQbjygWjxfRWRxTYV01+ZY6CbT8NrVyUnR6khd6+zEYXgaAo84/jnN9ynCZZ8aDpO2rgERmAO2uDF3Jf+LYez0RONeytxoJ89IRYGGvgOLzXtrbiyC6NMw6hoF2VylGVvUv6EiKF1zTNVoOKpVvlJtaM3pWVv3v2fE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694986896; 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=szw1D363NLaMzZ2nlSVnjBnf+JZRVRfS7yebtBMdM4M=; b=SyXmoLA7Ml5GkSvKWPrbco3SS6MvyGsuaGcFJCfvjHqkL0ArhOZB4laTQT+mELhhEg4aUBYYP8z0OI0SLGtvaDs9pKHV+TvUzZ4yJ3idVGq+l4/I7KsSBdc0S0dbIQDCxFVD630L154v8xw1bvhDJ4+SW/pvcnNIDdCz9PKy9+8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694986896936638.9376387539581; Sun, 17 Sep 2023 14: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 1qhzUs-0004er-0e; Sun, 17 Sep 2023 17:40:06 -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 1qhzUq-0004dx-GU for qemu-devel@nongnu.org; Sun, 17 Sep 2023 17:40:04 -0400 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qhzUn-0004KL-J7 for qemu-devel@nongnu.org; Sun, 17 Sep 2023 17:40:04 -0400 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-40434d284f7so40367785e9.3 for ; Sun, 17 Sep 2023 14:40:01 -0700 (PDT) Received: from karim.my.domain ([197.39.215.8]) by smtp.gmail.com with ESMTPSA id n11-20020a5d484b000000b00317ddccb0d1sm10561735wrs.24.2023.09.17.14.39.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 14:39:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694986800; x=1695591600; 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=szw1D363NLaMzZ2nlSVnjBnf+JZRVRfS7yebtBMdM4M=; b=P8RimxH4z2uoHAy1VT75+HOpPchEgzmqb24USh4tv4UGja+txlXsIIremkKdRfPREb T/4ixt8+2FjXO+OlGTb0f/hu/Wmg5r3pNUBmvoJGx2N27I8nI2kJhzQnkyOFCbCbh0Pl KuxyIR0c/1F+srGGVncpweJhRXe0t0WFfvb3/Imfx9g+nVeJPJcEXsCjdRrAVGdzy886 NgKSEbCAgYMaFqI2+P220Kq8RELDFK8qZRuTK6oVPDC3SWmB8Lpsd2cTQoBL4dudKnbi LRDfC2Klmhld6Fis7y0gjnx8mp77dm/Lwckv5z1tWlwauV8WfNOX+rfDgegitMLUkZa4 kg3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694986800; x=1695591600; 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=szw1D363NLaMzZ2nlSVnjBnf+JZRVRfS7yebtBMdM4M=; b=S8UlmyJIxnjoQeX2gTxVZ7upjmUumAVocrPcARDQHvKjYilsN2nLnarZ2l9WCd/lrK My2GFUSC8yN0svx8v95rM23wjNGypFZP2cFYKaXbelMkIx6awKA8S38oiMMOKgavr+ZY 0OjBwm7vzY9AnydOgnx4vNQG4kMN9lzgvlPqJXbPWt12TNinK2bEA3zKoVwJ5sE1d5JN NqaWCjv3izE34VDtWr+UtwGo9iZq07eZ/owg+feqgDDH7nBJcsvcnrjGt5hkvfHIALgK YWOnmH1HNhjFWy1SF+9BWjyPZ1EzHljL482HIib2poDqS1cWj8UuUcD66CxyVdolxcV6 V1ig== X-Gm-Message-State: AOJu0Yy3twSEpS9BvbSEAkFtsakse9ubmedK2E/VZvHJ4dJJViSjY26S UtMRrx3opPK+xisEEUSmqSIRNkZ2Bus= X-Google-Smtp-Source: AGHT+IEBlc6rJN//1+hAPNfBWPD8SgJWd3dW7vdgeSqMBV4ujjGkEp2ODBZW5oP9OeIE5iynVNgR0w== X-Received: by 2002:a05:600c:ac5:b0:402:bbe3:827c with SMTP id c5-20020a05600c0ac500b00402bbe3827cmr6555673wmr.31.1694986799936; Sun, 17 Sep 2023 14:39:59 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: imp@bsdimp.com, Richard Henderson , Stacey Son , Karim Taha Subject: [PATCH v2 28/28] bsd-user: Implement pdfork(2) system call. Date: Mon, 18 Sep 2023 00:38:03 +0300 Message-ID: <20230917213803.20683-29-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230917213803.20683-1-kariem.taha2.7@gmail.com> References: <20230917213803.20683-1-kariem.taha2.7@gmail.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: pass client-ip=2a00:1450:4864:20::334; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wm1-x334.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1694986898806100001 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 --- 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 a406ef7db8..563bac8818 100644 --- a/bsd-user/freebsd/os-proc.h +++ b/bsd-user/freebsd/os-proc.h @@ -251,4 +251,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 4c4e773d1d..d04712f0a7 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.42.0