From nobody Fri May 17 08:39:47 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=1694989492; cv=none; d=zohomail.com; s=zohoarc; b=iOzjBWQxOULC0LvVALOXdK8kIgtKQjwcehhaqV27Q9adDgYx2CsBTcRvjqZD+Sg8q4xUvhQyK8GjuoFjNHI4r9AvsVMcjM3ws2Ag3OrucMB2pvQCMe5v6PhVJ57UCYw0+FaKoSYDGs+jTIm4M54AfilruOBd3sTW17clpt19o3U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694989492; 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=eYpt2ioQJSEAwqEnmuFRoApoMSU0kxelk1SDVfrZujeOhQVHPnB0+buYsyI7bDlTMTrcmmXa0URO5y2ShfKEkfOJr1uzMEr8CfdNd7Q+F17zLsrdgQ+EUstzZ9qI4EWlzAouaqHudVrb2Fam7qOjBkLO/rDO4kCeVzJlD0uMGJo= 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 1694989492822520.4582291626609; Sun, 17 Sep 2023 15:24:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qi0Bc-0006St-5O; Sun, 17 Sep 2023 18:24:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qi0BY-0006Rg-MZ for qemu-devel@nongnu.org; Sun, 17 Sep 2023 18:24:13 -0400 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qi0BW-0002tR-DQ for qemu-devel@nongnu.org; Sun, 17 Sep 2023 18:24:11 -0400 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-402cc6b8bedso44711665e9.1 for ; Sun, 17 Sep 2023 15:24:10 -0700 (PDT) Received: from karim.my.domain ([197.39.215.8]) by smtp.gmail.com with ESMTPSA id f7-20020adff987000000b0031c8a43712asm10652527wrr.69.2023.09.17.15.24.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 15:24:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694989448; x=1695594248; 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=jGAH27/t1IxsvJLx6O8UJ0Biovn5H4dJBnxOMg5anpc+tMlte0kcSLbPPpre2hCi2U YnEtp/pppuVP2aMMk3KP6fw99U4AMqyaeo6QDZRjCP3t7D2ZvQmcrTIHS0yqrpSRSMyL JIOqffZL5OIUQ6cPPIk7jxj3KkPuDlSLO+uzt/uf2rF/aj3ryiZLIBgL4ssXuH9pEF1I xM1RnJ+UoRLrXBO+ehsvyJxaFT0K6r8dl3ZHRvwU24E30vWu+Fr6jpiWbqZWF9PyYYia UY3FCRfl0OEUOHXUJB4NeTeDv/80n7ybs9C+lgQrUQIBRbHvo6oS7RJ3zGgTbuC35Psr H2Ng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694989448; x=1695594248; 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=IDziVLL5I/gpWWk8shSJtL3OSE4lVVexy1tQNtypc8iZrlkqrEFxW2zbut1PwmmMcO lker5rkNnV1YLPffC7OwJubUUDVaGYmRTOJtcYmoBVw8g+4nXQlKdKDIM5jwEpaSQpBU 7eOyPahfwy09i5j/8FK6XRUcTg//XtdoIhMUKMYntKvnZjqLsxtAa8RtShD+xO3cmHhk cjno9LGzgzcoXRTRsW/RrbT+4WSmZCmb7Z4xn2Bl+ffhpTo3wLDYqQG8hsdd9n5RmQdu f1St2oFqFj7snoEjvLk3xStX8S9wI3Aql+fpkV0sZRUQMDpXUut+1ChlicgJcU3ScUHC x6uA== X-Gm-Message-State: AOJu0YwXo9HPnFSPdQYpbOhh4v9eDdPLbqMQgvSJ7qyGxbrh89MyLJ4f 3AjPB6tpH8G2nqTGx3ZbBmaOE1TIW10= X-Google-Smtp-Source: AGHT+IG6aOS3FyfHQowK8dut0fQeLwHyfKPmbFqlaPq2lzZqr58Fl/lK/Sb0WxpK0CvaEp2H3rbNdw== X-Received: by 2002:a05:6000:1c0d:b0:320:459:5a3 with SMTP id ba13-20020a0560001c0d00b00320045905a3mr3233000wrb.33.1694989448392; Sun, 17 Sep 2023 15:24:08 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: Richard Henderson , imp@bsdimp.com, Karim Taha , Kyle Evans Subject: [PATCH v3 01/28] bsd-user: define TARGET_RFSPAWN for rfork to use vfork(2) semantics, and fix RLIM_INFINITY Date: Mon, 18 Sep 2023 01:22:18 +0300 Message-ID: <20230917222246.1921-2-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230917222246.1921-1-kariem.taha2.7@gmail.com> References: <20230917222246.1921-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::336; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wm1-x336.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: 1694989495124100008 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 . --- 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 Fri May 17 08:39:47 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=1694989661; cv=none; d=zohomail.com; s=zohoarc; b=jaTvtz2ICnUBbuta5Mh7NwasdiraLFQFtRSmZ2Jnp1t7okpR1TVIpUhKWko1OH0x5lojJzk6iYzXXmjkr7hWO48NUDzbQ6odBC+7Kns/wpTLGyk5RHL1o/24CK0qb70B+qYHDnCK9DZ/euLDg7EKV+Gu7B2UgInjBMYEnDwHFw8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694989661; 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=ipU42ZbTnKVgsJTxmyoiDEgHMmps7ithB25Njg3LAYhJLzQ8aUUs7pnJIrgLfeFwj69gqVsHydALqmuJXoHnNZNv4URreqpu0HB2Q5B+tgLgPzpui7sjJ6toVqXimzi1iO89y9YLC3+5EcNWT9IZ8c1tPSX9vIBlpzYc+5ibaOM= 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 1694989661259282.85148898004115; Sun, 17 Sep 2023 15:27:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qi0Bb-0006SY-V1; Sun, 17 Sep 2023 18:24:15 -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 1qi0BZ-0006Rr-IW for qemu-devel@nongnu.org; Sun, 17 Sep 2023 18:24:13 -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 1qi0BX-0002tZ-EL for qemu-devel@nongnu.org; Sun, 17 Sep 2023 18:24:13 -0400 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-31ff2ce9d4cso2441546f8f.0 for ; Sun, 17 Sep 2023 15:24:10 -0700 (PDT) Received: from karim.my.domain ([197.39.215.8]) by smtp.gmail.com with ESMTPSA id f7-20020adff987000000b0031c8a43712asm10652527wrr.69.2023.09.17.15.24.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 15:24:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694989450; x=1695594250; 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=UhQYn8SMBpPcZ2QTHAL83B929cI+sM8WJt/6HATziETv0Ls8du/TUrP1mVGFidJv4C ZWXV/WxrHl3hlSGAN2z+uNyZzgdWk1eHHKphNvIEtCk8CJX220NCAkxwEBiZsz+IIw+Z RyPEbaGCVxvmFmmXWi2cGRtruuCuRK6f+vJFV0+dUaZZz0YJF++fKbGEDBeiEzkc5Sys YjRnkma1KKNwV1rKxq/uEsyaOXC35PjFItPdIH2Z+fBQDmbg0sxk3P/cQgBuKrNwoMsA 61IxSNREAkzdfG7nu39mD17hsYBD/BEn9vl+lkG0+KVKu2rG72Fr9jN2qye+cQ+rHCtX 33jQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694989450; x=1695594250; 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=JbxQwMc3USUxRxhG5FB+VuaYJY32ovpkNt9Z/d4oTEsHfxfq9/opiKg/AcFhDrhQXG AjIsRtLs3kJ+6vGjiaG8K25QHiLC018os26YHMa0YgIBVs/3AzdDUrsA35FSHJD/Y0xp niaQN0wIsnHn1AwsQvblKVXm/pKXq3nxzRD9oI/Sk3XtrZPtHiqK78yP9DqGXRoZ5bPN QnM5VLCMJB5ZpP8fUXfjH0PwKd90P5rrcW4V56kRAFsj/pWPT2SMUMhiFdzCXlhtBTgv mo75SJjbAoeU05oCBHM6aVIKb2EYrHjtCHz+vhuMOudyNF7Y5XUa0haCfoK3WwZA5iHJ IS9w== X-Gm-Message-State: AOJu0YyqrhDe/0+38MmZBBDdbj6rUpOqwt8pkJ7KG6O8gQbcP15O7Yy9 0VgBZ2BYKmfElUnMzv+Nj4Hao0R9i1o= X-Google-Smtp-Source: AGHT+IEWyt+Y2elFGMsoLkSd/tKdJJ/S750XQH+UNpGzwH4hnR3N3KPS7rmn2sO2iVyEaMXW1EXcOQ== X-Received: by 2002:adf:9dcc:0:b0:31f:fb02:4dcd with SMTP id q12-20020adf9dcc000000b0031ffb024dcdmr4157230wre.4.1694989449642; Sun, 17 Sep 2023 15:24:09 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: Richard Henderson , imp@bsdimp.com, Stacey Son , Karim Taha Subject: [PATCH v3 02/28] bsd-user: Define procctl(2) related structs Date: Mon, 18 Sep 2023 01:22:19 +0300 Message-ID: <20230917222246.1921-3-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230917222246.1921-1-kariem.taha2.7@gmail.com> References: <20230917222246.1921-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: 1694989662017100001 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 --- 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 Fri May 17 08:39:47 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=1694989547; cv=none; d=zohomail.com; s=zohoarc; b=DdO86nXEGWQZLcYnbK0fnVkcQCij1EaDdPhT2Hjr0PqbYJuWA+GlPIZTX0bulN/ynYcR2VhoOOW1znk+ovlw0zZTDu1dHhu2xIfaUrWqm6QeEKpB5e6EBF8vggPZdDHG+2M/MvTteBUnM7nDKjPYCFdlxRS1TIgW0SX/PnGO4+Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694989547; 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=LwdT86sNhZXwPkqq4k3EtlaaCZzUNqZOIDok9m0RodC9RaPooS00HwBfzjpSbjRbpgjzLNnuPdOpRh1ddkQkDaSBtBJytLex8qVxcaXcEosDRkit9TON61C/pFTTtCG0Anh8PqMaUGTZCr6CqGzu0uD9j0e9hwDCGJ+PkDTif7M= 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 1694989547765899.3611087039824; Sun, 17 Sep 2023 15:25:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qi0Be-0006Td-DE; Sun, 17 Sep 2023 18:24:18 -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 1qi0Bb-0006SV-Q5 for qemu-devel@nongnu.org; Sun, 17 Sep 2023 18:24:15 -0400 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qi0BZ-0002tl-AH for qemu-devel@nongnu.org; Sun, 17 Sep 2023 18:24:15 -0400 Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-32008e339adso960225f8f.2 for ; Sun, 17 Sep 2023 15:24:12 -0700 (PDT) Received: from karim.my.domain ([197.39.215.8]) by smtp.gmail.com with ESMTPSA id f7-20020adff987000000b0031c8a43712asm10652527wrr.69.2023.09.17.15.24.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 15:24:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694989451; x=1695594251; 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=EzeQ0GcQra1oGT1g2+K7L5PY3vfpkhxF4IT5FEbNYq3vBzjML6qCp0AfossWbbvlKI kriPtGMT9LRE1M3fAfZbrr28/KqWaxSp1RDxAW5Dgo8jwPLeUw5XlpDqPyxFQP/DpKlB stUqnNOCw2jhV/1Eh/q4A2+G2dhT9PZMyjwXRaUXpGug2N/+QJSNhTqI7VpGksxBCpvh bL1aoST8DZf7/4XEmz8E61k/oNcCUjl8rjar61/f22/YIwoNyvR8AmemBaJdrlz2gc+E +riUH6IHURsjmBNcPugJMTmgm17bPzit8sG814wxQFwVWvnj/YmkEn+R54v8djHqQAPl tEYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694989451; x=1695594251; 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=sBa7Cpi4rhTT4Hl8XoZJxDynKo4KU/ycGf2o64oIiQXPkbn43tAII7t0hx1w0rvzXn +QKyY5QKWZJo2xGMTBeIXVGKMgryv8jCVOZqobx9SmrC5bDLZeUfd5sfW+IAyt3XpkBR DJqmXcef/Ow76VLIlfR6sXKrLQv1IisNXPmvDNE7Qf1tLQ7iIQRmMlmOsYr8mFID+OWB gwhkpNJbDqaNP7wTcrPXPtGehbOZDXrBSpq3kBFezAEA1pul8M5PeqVywC0CW3U+dcSQ zu6nCTw/bYkvBKO+lDD5OMEckv+2DIJUlPnZIzkz2yNctElgNuv71w4Mcb5bB/vstzgC fo5w== X-Gm-Message-State: AOJu0Yyy4IG/c9gUBEEFBPvtqNtI5bLXwiytQXC7KkrEqpjy5dM4l/XQ r3v1bb4yAYgpnP4JpadTVPzwFWw5Z9g= X-Google-Smtp-Source: AGHT+IFl5WMymWTKkPGkRYGRoPTMTEXCMFoJiP90a26m/K0PFV2h9Q9UA6U2UGT79e9RxKnOSmVPYg== X-Received: by 2002:a5d:69d0:0:b0:317:f70b:3156 with SMTP id s16-20020a5d69d0000000b00317f70b3156mr6469268wrw.28.1694989450821; Sun, 17 Sep 2023 15:24:10 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: Richard Henderson , imp@bsdimp.com, Stacey Son , Karim Taha Subject: [PATCH v3 03/28] bsd-user: Implement host_to_target_siginfo. Date: Mon, 18 Sep 2023 01:22:20 +0300 Message-ID: <20230917222246.1921-4-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230917222246.1921-1-kariem.taha2.7@gmail.com> References: <20230917222246.1921-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::42f; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wr1-x42f.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: 1694989547997100004 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 --- 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 Fri May 17 08:39:47 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=1694989547; cv=none; d=zohomail.com; s=zohoarc; b=PO3z7m7t/+ZY42Il/wFVLDDSQsIHc7zyaTfvwLrf5cKVsbmIEkSKfYlrnKYoXVvQSWvt/Qfcx7E1476h7vVVUvEoYsYntjbvTxfXuKTM2w/axtMgMT/4vtcN6BXZqwX2xHuLrzIoc0aVK9tVS+gEOwH0xKMnhqJ1TRJGaIqCJIs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694989547; 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=DPD2wEtuQeHp+veeHRh2H7/58vY/R/fItqYjcGrwQDI5uxDvdoeKUO4DtP3v1MUgfhpQ+u9XDIJ1dTWFC/Gg8jZopV2QHRQlCQrXKqXjgyewHLFKVbgj4fZ8Vbt3EJEWEZ4ovGBQIiXn+e44/93wV3mAEBsv4N17+FblfAyh4B0= 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 1694989547391604.1730765676384; Sun, 17 Sep 2023 15:25:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qi0Bf-0006Tm-2L; Sun, 17 Sep 2023 18:24:19 -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 1qi0Bd-0006T4-3y for qemu-devel@nongnu.org; Sun, 17 Sep 2023 18:24:17 -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 1qi0Ba-0002u0-8o for qemu-devel@nongnu.org; Sun, 17 Sep 2023 18:24:16 -0400 Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-31f7400cb74so3427633f8f.2 for ; Sun, 17 Sep 2023 15:24:13 -0700 (PDT) Received: from karim.my.domain ([197.39.215.8]) by smtp.gmail.com with ESMTPSA id f7-20020adff987000000b0031c8a43712asm10652527wrr.69.2023.09.17.15.24.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 15:24:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694989452; x=1695594252; 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=cgGfanEcLF5X8LTrR7hRYAvoTZlhveGvBOEpNxCfiPCR/UtUydCxr7vUiY7eAJmofz m+b0fDCNjyI2h0LwAk+EjqSexyHB+xIuKX8DyYQWZ5EUdKZsYFChcS+BJe5ZrOz6M3q4 DIgP8Lhyqudxi1hySusHIlkaizowx2X1oLhuPTDcslP6HmddgI+iTeWBXr6jhHiAEN6D H5Z1PZonqeJ7j1N76FfxjDTVnw9bjNwgBpHgOlL7rGCNETvAuzveNKeoEaNWT1KU07B8 /3g73OaEJOKv3T1inMsxWvddqc11+G4I8HWSKcefmvO8fuR8W283cP7o0Zh0iRFLwkF9 yRyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694989452; x=1695594252; 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=vCKcKf0w6N6J/OvkIrZAa33rQm07zIMPoFv6Nt8FDrUY6csIROfhrgJT3gwhanVou9 XKxDqzoEYPaU16p4Zz+eLfcwHQ04vy/sWz6/5R4UmdfblQ6db4W4YiCYa85bIUzgqaPW o2S15Zic4xBPS9BkbvklyKs67rv1IgKCKfd2Azmg0XC6PbTCB5rnKnaKzgK7y0ZE+0l9 +3o9maCMJHXPHQ6BFtgkrVj/X7u4Hua9nzRj/QZl1q+TRxVOpMfed7d0PkzxUHRkJEOD It7dYC+Ty3fsQxQx4MWdTYM+0dIe7Ag68uIYDCDQX8tUvuk8wTYGKeQfo2zrZH2ChG/y KtOQ== X-Gm-Message-State: AOJu0Yy1YNProBlQRbwDhbYDqpVPoIZIvRk4FRQ7Pu8+cuT3AF79qqVd tiFoAqZmzp6hOY7lVlnr1VgCJTZtyrU= X-Google-Smtp-Source: AGHT+IF4B3U38pmnvfmTD/bC+5YcPjpRAAqDuzqLtOddvDZUTD3l2t4j1jQDG4nSRyK+05BJHYCR/g== X-Received: by 2002:a05:6000:1942:b0:317:5d3d:c9df with SMTP id e2-20020a056000194200b003175d3dc9dfmr5221628wry.18.1694989452058; Sun, 17 Sep 2023 15:24:12 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: Richard Henderson , imp@bsdimp.com, Stacey Son , Karim Taha Subject: [PATCH v3 04/28] bsd-user: Add freebsd_exec_common and do_freebsd_procctl to qemu.h. Date: Mon, 18 Sep 2023 01:22:21 +0300 Message-ID: <20230917222246.1921-5-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230917222246.1921-1-kariem.taha2.7@gmail.com> References: <20230917222246.1921-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: 1694989547837100001 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/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 Fri May 17 08:39:47 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=1694989588; cv=none; d=zohomail.com; s=zohoarc; b=CJ/je8gEDSWErmNMVA/1cHkQFXF4v8LcYGksXRgQsGixRojZp9GZqabfdOTrWXPX3c2n7lzw3K3z3KYYoQ222cxlE03hHCVuax6SVi8ii6uPn1n5LB9jz+9cBFrhRrx9e0RQcUTrRoQ4GXDlrN1LewsoxG8HEVC0hoxC1kf27f0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694989588; 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=WKj7tM2TYdE4HgYxZLL30zlZ2O3Eu+CcBzc+G/N7WoQc/TJ1Ih8wN2lyyHNQ+nU7K6Nc+gAfclN5Jpu4Xh41ZLx1FkES8rGBgaLqThon21OE2kT/N0deocg/4a4HD9GoioIaYOqq0TOHD0fpX4zWGMkqEx1tgktrPLp5f77pZms= 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 169498958799717.213499057981608; Sun, 17 Sep 2023 15:26:27 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qi0Bf-0006Tn-4k; Sun, 17 Sep 2023 18:24:19 -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 1qi0Bd-0006TK-9t for qemu-devel@nongnu.org; Sun, 17 Sep 2023 18:24:17 -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 1qi0Bb-0002uQ-7c for qemu-devel@nongnu.org; Sun, 17 Sep 2023 18:24:17 -0400 Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-32155a45957so144334f8f.0 for ; Sun, 17 Sep 2023 15:24:14 -0700 (PDT) Received: from karim.my.domain ([197.39.215.8]) by smtp.gmail.com with ESMTPSA id f7-20020adff987000000b0031c8a43712asm10652527wrr.69.2023.09.17.15.24.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 15:24:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694989453; x=1695594253; 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=Xqbaq9JcLr5K4Vq2Npzg9x3mqw4+oAsddQ9Ou8gTc7LXTxXUhoyZ5X3568doniaDGP mrvQznpZ1CglZzmP/xMtezlVkyPWrnfvU3BSz44EuurU5Sz6QGlhUpu/59oqnj2QfcQJ fRqqRGYlcwpabTgushnguXH3u2aNBzey9xDlGvZ2yR8+wNXkPdeJEn3YQxRSYOK9v/xO +hHcFJHVJht+FBxjlMqZLYQx/QdL0JMnWIdZ6dVHMsi4jPI/00Zfc8UP0PNwaoOprVlr 5bwpzU3UilGLEDoipsOGwUO7tVYTUYhQCzqUb5VFRlsJlEXGwp7zawjgm9mcT76wpeA6 HMfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694989453; x=1695594253; 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=VvfZxmp+VwwndevVLbDiK6HDUDEh3YKMl0CCecIVaC72Bi7+S927774kUvBtPohtA1 t9As6KMiDYK83dcD4UHpyvDiCVkRWj03i+VhuNzFM+FwNQys+6N0LTljZFpkI7hd3U8a p85UUeTBg+n1ZIDY7uFOhJDlOXfabOV8cm4UZmb8nIqIR51EcudGB3QcTPGg6J76czoa uaL2fKz8WTlgrN4UplDFPzShhFQuXxBiRshDq+wujnaW9rMqNSr2Es4IpFnd/NswkCD6 lFapP79KMa6lI97GjEmOYT7E3lE2w5WtpTyBtA67LwP83XqBZgiduSj9+FJKVsr4CjkT AHNg== X-Gm-Message-State: AOJu0YzivCtR9ExFNYxxAufAZsabR04cXtfrqPmW8x+Pbmd/D6eqj1kk myMMoJriYgpgsE1MIrVTNNZ+6lCcE94= X-Google-Smtp-Source: AGHT+IGVQZR0f+rYJcCkDtp540l4S+NUvVWO5egJWZLBOz2aPHcHkZ2RsrqEKIt0ttdZWKxV/OB68Q== X-Received: by 2002:adf:ce87:0:b0:317:57f0:fae with SMTP id r7-20020adfce87000000b0031757f00faemr5680328wrn.63.1694989453376; Sun, 17 Sep 2023 15:24:13 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: Richard Henderson , imp@bsdimp.com, Stacey Son , Karim Taha Subject: [PATCH v3 05/28] bsd-user: add extern declarations for bsd-proc.c conversion functions Date: Mon, 18 Sep 2023 01:22:22 +0300 Message-ID: <20230917222246.1921-6-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230917222246.1921-1-kariem.taha2.7@gmail.com> References: <20230917222246.1921-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: 1694989589280100011 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/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 Fri May 17 08:39:47 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=1694989643; cv=none; d=zohomail.com; s=zohoarc; b=U6xoaiuX6E1+hSI6HG3Oy1UCE6DpqbS7vmVO0VcqKnJFhPGAZoV9Uca92MNg7EF4Nr9pSVmuamKeJlbRgXPZuzOW+ErlFRj8LMU8kPZyTSP0L7xOrsY/p6xgSAGOo/bAzbBToDbhvvy8rc5z5M8ctlIM77QFa9P5itmOO/tm1Xw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694989643; 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=D5z11CECfQe/U2gM6Xmd1mIH8xF5WBVKgP/momP9AT89lBb31wcEw6zol5W/gzcT4n+WyoQ5s6G6lQmBi81dJp6Rfbpez9dFzfXFV17LY8Exos29rwm8BlBO/UagoE8dFaJGsAnCCpisbm3IN+w5puRR/I1okQoY+PCCkg52hYQ= 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 1694989643714947.8856391917968; Sun, 17 Sep 2023 15:27:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qi0Bh-0006VZ-Jx; Sun, 17 Sep 2023 18:24:21 -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 1qi0Be-0006TW-1v for qemu-devel@nongnu.org; Sun, 17 Sep 2023 18:24:18 -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 1qi0Bc-0002uW-8T for qemu-devel@nongnu.org; Sun, 17 Sep 2023 18:24:17 -0400 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-3ff7d73a6feso44181725e9.1 for ; Sun, 17 Sep 2023 15:24:15 -0700 (PDT) Received: from karim.my.domain ([197.39.215.8]) by smtp.gmail.com with ESMTPSA id f7-20020adff987000000b0031c8a43712asm10652527wrr.69.2023.09.17.15.24.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 15:24:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694989454; x=1695594254; 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=Npw633csGwvDQpcwGk0ABC5huDcuvdfBYOGM12A6MFw4ZEkpwEw83MGKH/4fAuiYA8 wjFmCfzn4NyiA4lndDP72bwo2G86yF0slw+p9jc9m/VZrXtSl5+j42pAsZpYdJXwzL0f iZENMZZa4SPIIW3WLrunTP9eG7ivgUEoka/ku8jRnT0W3O2woqJx6ryxf0J7UlZ2BnaT ipnyWk0DR7cii4f1t+nHeICaobhEc+QpPhF5bQQSq3INOnoTyomPp2zxOiBEHEdEffjY cwhnngMTYUStfl9Z6T3QBjAfPHTb/9gLHgpea8HgZ1tWiJdzPl4HfTpfmKt9jeU/qo32 OB/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694989454; x=1695594254; 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=Uh4fKWqDoF5aVsXyfOIWXXLBxKAkd/v9jTmZFLi9d6dGZ46Ure/aocwScXBYuAiCWa zCfwSbT8KiO8LAhQ9vQcm2gWzEEfNWgk1zby8+8D5PfdNVVIf28SwISzZzMAEh+7q+oc 8J6QHDpt2v4XHNbc9m0ChJIQ3nBa05A/C9xOL7je0vorOOpsTOaBxQQueHWFZ01rog69 01RBfJHkj4UPp2px5s+fK6Y7N1xw6R+NgDY6cUT9BeQJPQkXDM9T/h7QFCxPwVbxS3N/ y9CazJt+97R2txyJW9xC/H3miJW/bkTxXlhlEd5CybPzVb9ccfurbp8IHxNDUQ3AFWQf k9ew== X-Gm-Message-State: AOJu0Yws8quSIefZGoYEhCsniYm3OCWMcV+eulIaRowGthfdj72IQCKe wDZ52bN6EKi1M3jcpQAE0+uZ65CgFgM= X-Google-Smtp-Source: AGHT+IFHnN1r8RxG/koQcTNeHz+P7aM3qKbzd+eDqF9mucLhf2rBK1/gcOfQfgQAL7WXFT/7cM6l8Q== X-Received: by 2002:adf:e40d:0:b0:317:61af:d64a with SMTP id g13-20020adfe40d000000b0031761afd64amr6472727wrm.3.1694989454524; Sun, 17 Sep 2023 15:24:14 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: Richard Henderson , imp@bsdimp.com, Stacey Son , Karim Taha Subject: [PATCH v3 06/28] bsd-user: Implement target_to_host_resource conversion function Date: Mon, 18 Sep 2023 01:22:23 +0300 Message-ID: <20230917222246.1921-7-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230917222246.1921-1-kariem.taha2.7@gmail.com> References: <20230917222246.1921-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: 1694989645872100005 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 Fri May 17 08:39:47 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=1694989604; cv=none; d=zohomail.com; s=zohoarc; b=kGW9VF7Vz0RZYy6KaMoC/LvIRakT5n2P7ST/JFr6C0QsN+JSFUwIgzRY0Pk6B751nUnm27bLQ0ac+QOrkFXv5+NPpjZPUtg1foDfqvJmGIRGaEX1HZOFp1qH0T/7A+JGAIbiktyc6XOnjWCYx2OUE2io8DBYBe0n7er7TBqp3w4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694989604; 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=LkXfyH6KgloZJk9TILTFKxDA5IyMAkSpj5iE1BJbgtong9fqDd/uDB1AlFembhnZQv+efLqnQTtINYtoepWkdTins1bmHpislfUfvulLQKVk+nLSkBS8Vb+IP4SO2jnQh8xXgHtk9bDJfq4niNZFvioW98e3Rp+ryArxFzcDPlw= 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 169498960425395.02638845093895; Sun, 17 Sep 2023 15:26:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qi0Bh-0006V5-Bx; Sun, 17 Sep 2023 18:24:21 -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 1qi0Bf-0006To-7A for qemu-devel@nongnu.org; Sun, 17 Sep 2023 18:24:19 -0400 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qi0Bd-0002uj-Kw for qemu-devel@nongnu.org; Sun, 17 Sep 2023 18:24:18 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-402d499580dso42233625e9.1 for ; Sun, 17 Sep 2023 15:24:17 -0700 (PDT) Received: from karim.my.domain ([197.39.215.8]) by smtp.gmail.com with ESMTPSA id f7-20020adff987000000b0031c8a43712asm10652527wrr.69.2023.09.17.15.24.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 15:24:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694989456; x=1695594256; 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=ioJAUD7DnyjkijwFNbBbCHfELSRO+4Qc0sD7AZ/WvxTImmXs2A+7t06IKHwrJb5LNG gHviEx+4bqwTgUQds36ufLgCljQhBYK5atTl0swpB/UhBqXGhdgAXLsJCiMydy5IHIrI vNiY045LtOTN2ql4q8vBJngK3CFLYJUT0DhvEfsiHR4fcHIXckEFRTiQV5+IMIfJzOu9 UT9ZL/oWbLFBICFKqyDhr1ITfcwfidDyGMy0woICXI4WZp8duPISHqc7js6/0WifERxq WCkaoNqQ98cwYHt7LXeacLqUAo/fPLRzM7FhlvTJ4Ig2+4QMsbseB04mFiUhdeGp4+SJ ZmcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694989456; x=1695594256; 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=bQO8P5NnuG6QrtqPlLwTKqfGTQ/HI6T7K8/U/hQ0pX6QH+80EoKzYqAs3Bp2b2FvOg o2+rPpl4yUOF62eVkc7GTLF/Z3bnRL0zYmfdklaaKHhHN1lVFHvpU70yLv+zq5xQ62Ox txao+FxKk9pBuoqrlBrtL5qb8p6GtE4nILVwI9YO5XmPsFXBz3jxuqG6fF66RGwXMccH gKavP9C1fiqKo+f1ZhWsfa8BPuUYNduWxJoEu1lkFfUI1X7IOY649ci497y90lDHCYcc tohsysOMb6xjshKNOY/Ql+vcsdWA3m/7Uwxcl22Szui+77NkCTalDTltMqHp4+jToevu RWZw== X-Gm-Message-State: AOJu0YzHBS/y8rLRri7VdR0sAIUpDHSamkGVASucRXqRCo26fWHXS3Fg U3o8qSuGGqhkLVaUgZT4yDIxG6X4wFw= X-Google-Smtp-Source: AGHT+IEexgJbOGFQY/wg0WfjAtXy7WGzsukFxIyjOqBC4JkE2wE++LRYUZMTsOa4Tb/RBReTRi9zWg== X-Received: by 2002:a5d:4952:0:b0:317:6653:60b8 with SMTP id r18-20020a5d4952000000b00317665360b8mr5830122wrs.50.1694989455744; Sun, 17 Sep 2023 15:24:15 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: Richard Henderson , imp@bsdimp.com, Stacey Son , Karim Taha Subject: [PATCH v3 07/28] bsd-user: Implement target_to_host_rlim and host_to_target_rlim conversion. Date: Mon, 18 Sep 2023 01:22:24 +0300 Message-ID: <20230917222246.1921-8-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230917222246.1921-1-kariem.taha2.7@gmail.com> References: <20230917222246.1921-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::32c; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wm1-x32c.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: 1694989605360100003 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.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 Fri May 17 08:39:47 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=1694989668; cv=none; d=zohomail.com; s=zohoarc; b=TK6IrngyTW9Pa7l3kstJD4yNJe6iF+MvlyRlA12cvrC6GehjPDnaTuXuLinopWGILBK5GIX0cnOYnOH+fQQL4TAJsdPVWJ/oXJ2EBASC+OYTAsEwVauNPb0u+1RC0ndP0pO2LKX6Qxe/5DeLGWQadAuttDSxrM0Bse760s6gCJM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694989668; 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=erMMvIFBo2wV0XyH2lTLmNKuwfkG1PJYecdv8QFbyIjkCwG+99Oo6dsuWtxB0mfCFWR87eWDPgP2o4AuPTuDZjlrbrjf6UIrV4RnlrKQjnMvA3mrCQlM9OJv1g+zT8TGbW++mQyghFJ/LX3Gc7KdBqLxP8FMsuMMB+Z4bRzEDoM= 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 1694989668458351.8426572727186; Sun, 17 Sep 2023 15:27:48 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qi0Bi-0006WN-TT; Sun, 17 Sep 2023 18:24:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qi0Bg-0006Uh-IG for qemu-devel@nongnu.org; Sun, 17 Sep 2023 18:24:20 -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 1qi0Be-0002v4-VT for qemu-devel@nongnu.org; Sun, 17 Sep 2023 18:24:20 -0400 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-40434d284f7so40603095e9.3 for ; Sun, 17 Sep 2023 15:24:18 -0700 (PDT) Received: from karim.my.domain ([197.39.215.8]) by smtp.gmail.com with ESMTPSA id f7-20020adff987000000b0031c8a43712asm10652527wrr.69.2023.09.17.15.24.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 15:24:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694989457; x=1695594257; 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=HVO+od+YHIqeqL+K9uvvu8fHfmUlH2JT3lmYm7X6OxRVof5sSIaWQQE1X5r/KqWIoO fO0eel5urOgstgIeB1FEZc8qfsbKHPvj/7gZ0rNZ8uTi8GUlFtfnq2rwoLlIbBnRHqnd JYw2R5u2PrZ84U97aHM1etfYA84FGjobQzKH9/Ciu2FFNZrf0iVhRFnsq/5ESmAyFPyr B9cRo699bLeEMGD+RkAzoa94YK6WVI7netQ7XngHUmRV3cc3CBD3JrsJKfwvt0ybAgo8 1RZolcL0KHW5UrLsOKj7dCDewDOfUoCzCGdYFlqnkJY2UnivdciAQmR0yWkJ/GIFt5mC DjWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694989457; x=1695594257; 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=re6xiNTGsEqvYTJzqsqsGtTJkDlhiuyzOubJGQSg7U5mAlQHcrTsYZ7AsfS6H0/T1e e6vKGFY0pLOOHpj0AW8ODXLJa57K0YF2fvrEbBODPa7fgzP+0EGUM5kv6nxohu+vue+5 ZHC1R2ng1KUz2NXvROX7jP4R0+sPN9dkYsnQ6IVOt9WFvQ0NzXaRAgh+lnOuGZ24rWAj Lrj/AjJYtwEi6gSyWTMzfYBIUqxqwEjFu5yGpAo5JUOo2xC4hdSBhLsmNoqXwDzO2jq+ VJbBBtx8H17HNa6h6FUECeguzIJ0/16ye70TOM0LXnvqBOF6dVIVPy1ZwDZFEe5PTiyi pQHw== X-Gm-Message-State: AOJu0Yz1SCaBdjfviLE6qMt/aGAhseW5FmI5CwgtlFdhHgobor+BfMk9 p8zpjTZdkXUzjqCGDu6u/qQZFxPYdBU= X-Google-Smtp-Source: AGHT+IHS2Vr1b0i/4X2ZCA5GdcRhy93Nd8fzBsdsnp3Fc7xbTlqD5W5sfy/i0PAnDt0fwBr9Xd0sWA== X-Received: by 2002:a05:6000:38e:b0:31f:fdd8:7d56 with SMTP id u14-20020a056000038e00b0031ffdd87d56mr4943623wrf.12.1694989456886; Sun, 17 Sep 2023 15:24:16 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: Richard Henderson , imp@bsdimp.com, Stacey Son , Karim Taha Subject: [PATCH v3 08/28] bsd-user: Implement host_to_target_rusage and host_to_target_wrusage. Date: Mon, 18 Sep 2023 01:22:25 +0300 Message-ID: <20230917222246.1921-9-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230917222246.1921-1-kariem.taha2.7@gmail.com> References: <20230917222246.1921-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: 1694989670289100005 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.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 Fri May 17 08:39:47 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=1694989493; cv=none; d=zohomail.com; s=zohoarc; b=AQjEqHF8pb4t818ckXBdeZC3S4ZIWfMqUxe0DxdbMzQJqq8h1kOW2llIfzVN6hne0LMor90nH8DlfFUrTPeGYulQEQ06GithGcB9ekTQdMeYALgL0y7LxNSnZhiyV35QrSOft+0bcsFmb45dmUR8ocL55GDWc6ork8Iax5uCfWI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694989493; 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=T21qcI5s5gBP6d0HDZQlATylrf9zP1Y5P8rldC9vFbf1kKEME7nbv/HFDir+asEuRSDD2gCI3L6OA65zAs+szol//bf946K4YvzYw7vtO0vW5fbznQ4Sls536oQj5DWRON1ryJU+JntoKqqYFptngPqZvg57112anyyE5xhDaxs= 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 1694989493535943.5563375203235; Sun, 17 Sep 2023 15:24:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qi0Bk-0006We-N1; Sun, 17 Sep 2023 18:24:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qi0Bh-0006VF-Be for qemu-devel@nongnu.org; Sun, 17 Sep 2023 18:24:21 -0400 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qi0Bf-0002vI-Rn for qemu-devel@nongnu.org; Sun, 17 Sep 2023 18:24:21 -0400 Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-32001d16a14so1238193f8f.1 for ; Sun, 17 Sep 2023 15:24:19 -0700 (PDT) Received: from karim.my.domain ([197.39.215.8]) by smtp.gmail.com with ESMTPSA id f7-20020adff987000000b0031c8a43712asm10652527wrr.69.2023.09.17.15.24.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 15:24:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694989458; x=1695594258; 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=OEIfn2kPA61Rn7T30JSvLssohG75wCbkw2Dh9GeiuF+dQEslWU9brnswaqI4kRfCb6 /t+y5nFtoI5SFYUcM5HfHp1HLhlVX++t1JQpsoUDjuNty0Jsb3N2uV42rU8HCdTpwD0N IF0tGUsi8lYjHVTe+tQMiZq8k9w1Lr40Kt85NdkcYaSlFUMhAMp5yx7IOgtDLyC2m1ym 9mAgFj4zqQ2Dy16fZgbjLefUqQpfOR5U/5Mnom01qrVEwGS6zVq8gu2Ud3mY1Wbm4Ms4 f+cmqlJL/x6BRax8y3Wr3eo5NNiuzE0cHPLZkpgs/TLWL3CE0EGQ/3BWMNCpQXoKKkZI lxZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694989458; x=1695594258; 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=WpbLN0FKs75QSQtTneDo/IqRhaSDv/iHRFnkaYsINdrfovrrUJk20FR28iUfa0aR/w eAkzfnlskU4VcGKwr+2oWuy9ur7Js7mdrUwVaf1W8WZHqzttOA8XnQZ55yFfNtyk5NuR gELkuYKouWLtoxMfqHN7gkVX8+DjHGr5j/HbTd0Y7uiyp3wSchoSsM4OWqpiZUkQKtsk 1Qfaomt/n/5cAgj9GVzxD34qRahlwnP9+I2OVpMeoq4fROKb7d5tYNGJziQ9J+3hg/O9 hs8g0aRPY0J8Ga3u9ouarUkyp/0bxjqcgPPz6pRfssYLrO33LfwG6bEwLgs/IPY7O+Y8 OJmg== X-Gm-Message-State: AOJu0YzCc2HBGxE2LcmXmRYExOPPEl9OPudsnhhfkLGRWAYJyazrLC6e 3CAl/y/bJsJK4fCmcDil5SRdkJiGeY8= X-Google-Smtp-Source: AGHT+IFh/9s15b9YDjig29WinbWxgitEh5pMXub215cgCFIE2D29GZuF2HIaB4xHV3+21LL6O2efpQ== X-Received: by 2002:a5d:60c5:0:b0:31f:eb88:e3c8 with SMTP id x5-20020a5d60c5000000b0031feb88e3c8mr6040559wrt.32.1694989458209; Sun, 17 Sep 2023 15:24:18 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: Richard Henderson , imp@bsdimp.com, Stacey Son , Karim Taha Subject: [PATCH v3 09/28] bsd-user: Implement host_to_target_waitstatus conversion. Date: Mon, 18 Sep 2023 01:22:26 +0300 Message-ID: <20230917222246.1921-10-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230917222246.1921-1-kariem.taha2.7@gmail.com> References: <20230917222246.1921-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::42f; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wr1-x42f.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: 1694989495126100010 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.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 Fri May 17 08:39:47 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=1694989536; cv=none; d=zohomail.com; s=zohoarc; b=XfxLLeKKj9ufY6BYFX8++by6zIyJHwORUs1VBP96TuD+zZgZX11+ckyaEFFjk6F6/OmS4hE+HgqyjoZDE2JfuiYfeY87wGHoQH4JND/RrnZxz9fQbwVnLHIYfD6TcvfOnlUMfArp6frjDeCuVIIIpeR9iYOIRiq0cT8AGCGdCIg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694989536; 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=dFnOERbGhumKz0Zj/7wTBDJToCeJDYW05AWRnvQUW0iwDpILBblNZQe/lEamZGzVzlznZsGePSD4Re9iPIHiA9Y2bbdt8TbNE2Hrh531jgDkQIWNcNiGkKpT9DdPjzBvlAPVG2Dz2XjIZCvpx7dnKJLtG7Cqy7C6PAXrteji59s= 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 1694989536263208.1210982442666; Sun, 17 Sep 2023 15:25:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qi0Bl-0006X1-BQ; Sun, 17 Sep 2023 18:24:25 -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 1qi0Bi-0006WE-Io for qemu-devel@nongnu.org; Sun, 17 Sep 2023 18:24:22 -0400 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qi0Bh-0002vX-1y for qemu-devel@nongnu.org; Sun, 17 Sep 2023 18:24:22 -0400 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-403012f27e3so44552475e9.3 for ; Sun, 17 Sep 2023 15:24:20 -0700 (PDT) Received: from karim.my.domain ([197.39.215.8]) by smtp.gmail.com with ESMTPSA id f7-20020adff987000000b0031c8a43712asm10652527wrr.69.2023.09.17.15.24.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 15:24:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694989459; x=1695594259; 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=EXX3Mq6UuiaYohZwEfDQJ4IuSAtsD2iE+CIfTmDbUNLHrZ654AdTWsEaWWVKxcY2Cp dQzkIoqYlRrXEl49X/PBrI1dJBTi7izAyC08zzPIpURY62W+zqYFnUi2K/x6GVJLC2s4 3MVO8qDxV0zYkpVDrfEKe+Ita0tcGtI6/dTcmpCvPtvyjDTLinWj2F5my7Bbn1YVs6vm sqR5+JUMZojFwdIzn84K7Vj3mCov7lCA5CX5fpOKpegN5Ku2E+AjWhM73qr9/mIvOZug DwZ2SwXpOI4sYT3xmHYW7s2S3ExtzYYTI2+Fnvd1Vw3o8fula+6U7emraRktxlwv7ql8 J0Cw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694989459; x=1695594259; 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=dWeKvfVeQgz970Ep1YDYk8EEPMmbnJ+yBgT5Hs318r2TmQViuDapVJgG5wCcyAn3aR 6SXF/ApQlUc2JE8WGNYamfGA/DMOfOcqYOFtpKz7XqcYhwHNCwt0sgFebC+WI4KUV0O9 w/AjZNdufR0dmYsW4rBIYdhl6KuSOYr0u404aOnkSkf9SCkvwk6o2b6LcXfwVtxEtl23 cWbI51M8eTG0g6Ud6JtGEVq9L9UtF0nAreW7CQrB1bU7ZqlJsjJW/EwPiBGNs8Px44uV 8FKhV+FcrhAf2G1oYg5HRIDeioVkwJGA1a0FowK1i/S8LyO8MsoyGw/YL8PVI2std/fc BvDw== X-Gm-Message-State: AOJu0YysVy2R4CdqptcySEMlFkXlMTx36yfPPSWgpya4XgyCwH/KX6NB uLZvM7ZgGpWz5BApXykw0zqkOy7+440= X-Google-Smtp-Source: AGHT+IFf7Z9ghCkuJdtx4HtCPqvcAxLB++Wbn7dRK2KGr9L9L7wxJ1rrG8TeDgu7bbZuzE+QQg9Phg== X-Received: by 2002:a1c:7709:0:b0:3fe:e842:60a0 with SMTP id t9-20020a1c7709000000b003fee84260a0mr6839297wmi.31.1694989459422; Sun, 17 Sep 2023 15:24:19 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: Richard Henderson , imp@bsdimp.com, Kyle Evans , Karim Taha Subject: [PATCH v3 10/28] bsd-user: Get number of cpus. Date: Mon, 18 Sep 2023 01:22:27 +0300 Message-ID: <20230917222246.1921-11-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230917222246.1921-1-kariem.taha2.7@gmail.com> References: <20230917222246.1921-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::336; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wm1-x336.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: 1694989537897100004 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 Fri May 17 08:39:47 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=1694989505; cv=none; d=zohomail.com; s=zohoarc; b=XX2aHVCrA8Pb9z827f21o9SlaGm4BvZEJXzotyhNPeEG58ecpD0yG9UnERzvWraYjwEPgJxWqH6bPrrbWY5SpiYTYhHP97mOZOcT2QLKHy44I8moxk+iLnwE8bbE31phfa7CRDOjvZIl4VOJXjBggWdOfWOAsA44LiTpNVdT99E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694989505; 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=na1YqEh1G5omCnIO/b7/F3OqjCnTWI8twi33YDYtR7y9fDukFto2dJcJnEXOjnyfgrVBlpeXX47YGHOwsIA0q7t1liZ2vp7lImvGf64ShoVaU3sh+nReuXmOgSfsIaBzYE3QKrwqp2fpl6dmpOVaBRwuOaVemSa3p7dq1SW1QZc= 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 1694989505435661.3020110323248; Sun, 17 Sep 2023 15:25:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qi0Bl-0006XZ-Nc; Sun, 17 Sep 2023 18:24:25 -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 1qi0Bj-0006WW-Sw for qemu-devel@nongnu.org; Sun, 17 Sep 2023 18:24:23 -0400 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qi0Bi-0002vp-8W for qemu-devel@nongnu.org; Sun, 17 Sep 2023 18:24:23 -0400 Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-3200257b9a3so1084535f8f.3 for ; Sun, 17 Sep 2023 15:24:21 -0700 (PDT) Received: from karim.my.domain ([197.39.215.8]) by smtp.gmail.com with ESMTPSA id f7-20020adff987000000b0031c8a43712asm10652527wrr.69.2023.09.17.15.24.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 15:24:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694989461; x=1695594261; 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=ngy515Zm8ReEIoRMP2FmdP63vL05ntibuuXRfEqQoO5tHfWzG5K8Jq6rsy+oF+4Kgd 9ke7fc2u4PuhjSHUvoT7gXmPLK3MZw/55tG2zpZKgKmN9LTIiQscqNROm5Nww6nDU0do G0dYOljVHA6JoNTm2VZNqXSQAySkefQB6FKks22OFTKkJDjmmOmkvoXFoViWY59dmgFr mXZhZMb+v/mwKGO9pmZbeg8rNdHr2rbpZhcc85UywTa2ja6hV99u/AqrEx9XZA+xwhhd 5tPuTHvWEfmiYRtEOSrrU8YgnTzaL9ModiHEdtSR494K9Ss/GpCUL9vxjvk46DnOBnlf JQUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694989461; x=1695594261; 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=u77XZcaVWZH2luIxYAm67+xO0nxfTYzeAg/v8h6NPDzmhOiIx9zzAEb8ACIZxiR2D1 ZIryKyTZoZK25sPYaXmZNK/Fl29rFE6iTHX0XUm/jboH9clsFxMXFmKGsKf17yrkqkvm wvI6rEVtgb9kSaG0J6h9mMRAgn3VEvJYFiD66mP220RaF4mm5o+V+NBJ5fi3gKFKBu8I pCeHUBUmKefv1DHO6QngyzpU4rPcljBaxC2/uBvZg6YBptyKPw+THwxY23t12+BWHHJw LX6c13IAt1zaDE4eIsbo8N2qQzAVOnZvTtMH3o6sJtFo+5VXcrFU49jiI9C41KUQw0WE dUSw== X-Gm-Message-State: AOJu0YzK7YxFsTlEoGAUOmZwfXvT3c19zUbGfZHsGAx6vZGv16oURolA Nmz08W7X49jUFZq6pcFIFXUYTKWBxO0= X-Google-Smtp-Source: AGHT+IETfchPFROfmlftHvBGdZw7dIP/ZZi8GLxosMoZ8F7jo0fMDZz8ZPa+ifiS/bsC/yH4CahOvw== X-Received: by 2002:a05:6000:1192:b0:317:636b:fcb1 with SMTP id g18-20020a056000119200b00317636bfcb1mr6653622wrx.27.1694989460671; Sun, 17 Sep 2023 15:24:20 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: Richard Henderson , imp@bsdimp.com, Stacey Son , Karim Taha Subject: [PATCH v3 11/28] bsd-user: Implement getgroups(2) and setgroups(2) system calls. Date: Mon, 18 Sep 2023 01:22:28 +0300 Message-ID: <20230917222246.1921-12-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230917222246.1921-1-kariem.taha2.7@gmail.com> References: <20230917222246.1921-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::42f; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wr1-x42f.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: 1694989506549100001 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 Fri May 17 08:39:47 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=1694989492; cv=none; d=zohomail.com; s=zohoarc; b=k+w10pOe7ttv5jAu+xDbth5w87ir6FZZp+qrxUplxJt9psSQaTjMs23IZf9v1DPqb5leZawP62y5PXiR5OAH8bD6RdL7HsGnB6kpHqondggEshB14S5Rav57uliPwWC4IOOrXrhjBP7XIHs0Gb5ng2dubgi9Fcfr17VYjNvLGHI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694989492; 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=nuz1OKnhgJeDlrFs706Cu7gq6gRvRbAP0ovUwhwIPw9C7AYucQ4g5zWbJBO7aHF2gKDRXa/g+HfmmQ2E3phiPsE+UKDA0QPWAT6Kh3YFfCJqGKBiPqgHX4MVL9v2Bdn532AlYtQV1s7PfJOXf7YbxP/ROkLDCixCxwHuCC6w/GI= 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 1694989492912599.9050402551742; Sun, 17 Sep 2023 15:24:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qi0Bl-0006Xc-Vc; Sun, 17 Sep 2023 18:24:25 -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 1qi0Bl-0006Wq-8q for qemu-devel@nongnu.org; Sun, 17 Sep 2023 18:24:25 -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 1qi0Bj-0002vz-J0 for qemu-devel@nongnu.org; Sun, 17 Sep 2023 18:24:24 -0400 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-402cc6b8bedso44712695e9.1 for ; Sun, 17 Sep 2023 15:24:23 -0700 (PDT) Received: from karim.my.domain ([197.39.215.8]) by smtp.gmail.com with ESMTPSA id f7-20020adff987000000b0031c8a43712asm10652527wrr.69.2023.09.17.15.24.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 15:24:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694989462; x=1695594262; 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=KEwD4LGz1lHnJW9O3p2dR6M5qIBqgw6gpQBDgtDOzkBDQc8rwbrBTTpNZ+hgWVmasw MjDv8PUjZhB6bE122AoGkcuN/QhCbVaJvgGpY3fOwPmmG8KcF3IKziu4HvqYXm76jntj la0kvqZuMLVEfMtlgaCeYnwSrz1sV30AzQraTL/gxIB/LspBn/GGXKYydIrpU0uUImX1 3cSAH3toja3/i6GUDpckoRoxKIlRUdQPQ7+cGeZhNrZ6lyxvr6Y5As9BEbczzAT0y6lU Wj8OJMFq7CHDsHKaxTIiYAz5AcGUy7M9lyOXiwpGqxUibx5tE4ATsQOibH1F5rKkTpoJ bUWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694989462; x=1695594262; 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=OhdMSaFSJsZnZedt5g2t8KGmUHUHKgVa11CpF2lB0LflrPQFe2SOKT/1ZbGfTItFO4 YgIjuX32mawzCueRo5qqVhRzqyaWmZeqeN8JXxoTwnvJCzrALwHWqa07Gc9iWhHvt61T wb0gRz7HlaD2HQdmkZxYaZTEAS23ZP3RPc9OFO/MQuoDSrMTDV0nCSW+zJW7d/Ghm0aS ZevIDVHSF5TcEpJu0iNNgZne0g5UFdekHzeQTJcpq72rcsoRcQXTL3qph//MGF1vVJ60 gU72lSsY0r6g9shJ870+jHfUFbC52+yiIPVvuuK5H6rhrLjQKsIbnsYQ0+8eef3t7obK L0Og== X-Gm-Message-State: AOJu0YxS6D57CImvSphCHPGn734Ky6JwaDF8p1wKAVYYXm19UVV6NQuH RPgHRUwi9nQsHT4IPNAJ9PS0U9otOQw= X-Google-Smtp-Source: AGHT+IF/Y7ZumRj/09OQhpI/O9k5QcZGeAkHVresbk0u1/OZHGnUqVl7zvzFFmywPhdtruTbHbnFRw== X-Received: by 2002:a5d:60ce:0:b0:31c:82ad:a015 with SMTP id x14-20020a5d60ce000000b0031c82ada015mr7330349wrt.49.1694989461889; Sun, 17 Sep 2023 15:24:21 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: Richard Henderson , imp@bsdimp.com, Stacey Son , Karim Taha Subject: [PATCH v3 12/28] bsd-user: Implement umask(2), setlogin(2) and getlogin(2) Date: Mon, 18 Sep 2023 01:22:29 +0300 Message-ID: <20230917222246.1921-13-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230917222246.1921-1-kariem.taha2.7@gmail.com> References: <20230917222246.1921-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: 1694989495228100014 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 Fri May 17 08:39:47 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=1694989616; cv=none; d=zohomail.com; s=zohoarc; b=M0sKvyocfV8VJ64gRv+jgUZdOAoRCJ+qa3hgjtEFpEnJrU9sRPhHrQqtfvecrJldGsxju4g9NtSBKfxLRhRQRa1UsDPuYN8TIlB0ypnuk2iSfdKoXKO/jSrPoyV2Y/NLGYeOAh8MoWM5US7iqX1GYMk9wRc9iyD3oD4wafryyWg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694989616; 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=m8fkZ7jWsTkzfd7xJljfK1Q/LKmPDz93xjxV6Nny0nDxkFnHuQo9b9fA2zMQ1u/o9Yk8ZdKZsEuCY/a3N+c+r2DN5v1iHYCusKvP/bRIv93sAXkky2FDCDKoJ7amAp1YQ0yc9exLpmPtTKolB0IijoWF9BIcnaQWtT4qN6xwqpI= 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 1694989616326171.3701335077792; Sun, 17 Sep 2023 15:26:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qi0Bt-0006aJ-WA; Sun, 17 Sep 2023 18:24: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 1qi0Bq-0006YO-77 for qemu-devel@nongnu.org; Sun, 17 Sep 2023 18:24:30 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qi0Bl-0002w9-2G for qemu-devel@nongnu.org; Sun, 17 Sep 2023 18:24:29 -0400 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-401f68602a8so42974575e9.3 for ; Sun, 17 Sep 2023 15:24:24 -0700 (PDT) Received: from karim.my.domain ([197.39.215.8]) by smtp.gmail.com with ESMTPSA id f7-20020adff987000000b0031c8a43712asm10652527wrr.69.2023.09.17.15.24.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 15:24:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694989463; x=1695594263; 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=Ot+DQePFnrb5ILObqNtAuX0PFRpUj1gY3KemeHn/tAEwgpd7Cvh09jm1TBgL5uHkRl iIT48OPcQJ6qxXmjzBE97Zo/ApvMgyiIScrTrsQIg760biHjPLFKxz3wAvZTuuf0NJtA omiqyL/22/N32PIeiD9o/LntsmPjtamTFL6eJJ/i+XlbwdiyYINm1JdGsIeA1ucXnB82 MCuJA7wiQUjWkoritITezti0urSEOaFB0klSXgfY1n11KoUmJcD4Vy7xXb17mxewoVqE Rck8rcLdsiaLH6Q4O/Yj0wttSuirTlQg/M0sa8mc00LmQNO3volmixqIK6tXmmmvhHN1 hmjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694989463; x=1695594263; 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=Nilov+4ekHmZZIsa3khjP6WKh5SC5A/yGSybfUPHurFFKJvtI0GdZOV0U5cndb1fSc x3SGEsKS7SfbUYn2ekZZlnC8kCc92XjQX55u1YWZRa16XekC6gkvVvq21IQ5GgAQSFYf v+ZkgwIjLuFxepSJSBIcu3a0SjY7pOz5BRJo3c+C7pfhQZzxpIzrNCvoCf8jaofMm/Qp TF5Pk6aOUqYSCN/fmWfnYCLMO73lLRz4yo+vL16rJS6g0GUIp0qR1Yn3BZuX0HQrnHlb M5VsVLX0ycJ+r0rbEYVwajcigreMCZzKc2mWAk25YMOHg9Jz5f6ThtGY5FQFr3+tsPeb gcIw== X-Gm-Message-State: AOJu0YxYz3i5e54qi+UMvESM7Hgvfpf5QPUgHSt20K0B+HBfKzwWamXd A2IIrQ4Jce2q6nGMwCesmMXnBoZlrJk= X-Google-Smtp-Source: AGHT+IH+a8oYE+fdHN4mCrf5Kak3EgYNqtE3x1JP4oFeSP2vwr4E3gMtakbyWrQ1WBXnXf8O+hDe9Q== X-Received: by 2002:a05:6000:706:b0:321:5218:9434 with SMTP id bs6-20020a056000070600b0032152189434mr811616wrb.3.1694989463223; Sun, 17 Sep 2023 15:24:23 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: Richard Henderson , imp@bsdimp.com, Stacey Son , Karim Taha Subject: [PATCH v3 13/28] bsd-user: Implement getrusage(2). Date: Mon, 18 Sep 2023 01:22:30 +0300 Message-ID: <20230917222246.1921-14-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230917222246.1921-1-kariem.taha2.7@gmail.com> References: <20230917222246.1921-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::331; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wm1-x331.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, T_SPF_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1694989617573100005 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 Fri May 17 08:39:47 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=1694989644; cv=none; d=zohomail.com; s=zohoarc; b=gIbfl1zKLVPrDn+H57v8yvZf6dbXtubBgn8kSjOP5mHgTd78R56RQ60hob9Q2qMoi42OogPRjlAVg+1gbTRHE7MD9g2LQBPviq8LHlDyBDV6RCQGNOSqf4QA7Qq8D6DVMxNz7eIiHj7o7GK1C69F8MSzM41C/6HPR42OoWC4rMg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694989644; 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=Sxi8stB8uDA7+9fExm4MJ0zL0ZF5ZbJAgbAWIrfUUNLNs537mulZ+PoSwXX0+IzFwoixYs4pZSxNW/pT1ZWAmwXk6rtGOmwV2Ma9tKAngT5s9TRkf3xI+zjjX2q+qRx7jyxVnqEXpWkVZtGBh/wtUkHwPDc6+RJNHoQf5qU8Oac= 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 1694989644870597.538142926611; Sun, 17 Sep 2023 15:27:24 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qi0Bq-0006YY-Ky; Sun, 17 Sep 2023 18:24:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qi0Bp-0006Y7-9W for qemu-devel@nongnu.org; Sun, 17 Sep 2023 18:24:29 -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 1qi0Bm-0002wK-Hz for qemu-devel@nongnu.org; Sun, 17 Sep 2023 18:24:29 -0400 Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-31427ddd3fbso3445819f8f.0 for ; Sun, 17 Sep 2023 15:24:26 -0700 (PDT) Received: from karim.my.domain ([197.39.215.8]) by smtp.gmail.com with ESMTPSA id f7-20020adff987000000b0031c8a43712asm10652527wrr.69.2023.09.17.15.24.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 15:24:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694989464; x=1695594264; 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=IA+kC3UBs/zn5cuLYV4iN8GBSD++tAjFQx8JH6b5E4AXh2nM/GziKXd651ZweO2485 Rg1sWk5ncvjeAACCTmKqhuCMd1RG+nA/yDOeRpIw9sy2N0yFmoFjL/9SRT/X2rMYkcVr r1iYAzuXGOCfc0ZlBuFE0o3RmKeXmw9IiEgf4iLWaijk/GOv2UYBCNbNt2EA84G+NITs xhgMzGoylu5MuOTOKSo+UsH10wFFxJX063F9ErchhDEWJZCmMSkKd0kyqS9Fs6AUOTce MC6J+2RbtRdi3EjHKVzeSRaxNeCUzaHcTcV1lVCtj0mkki/nwP9BUK1pmZZ2cN39Ligt cUCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694989464; x=1695594264; 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=n6IuydNMcAZEC9BViGevtl+RbQAnpYDazFhstMxiGptRaEE2lGTnS4LP26S6CRiX2Y J1GkyR78/dyuMGNjrV16drYu0vEhCMZlZGVGHvBsPnQbsrvwZ2vnGbG2uevGHubTQzuS b8JB5IQHcNkF7bCx+W554Vpn2oRgoFi/FQWX1ZuhR/LtfVmnOQJu803+i9dRL61xxyZ6 7M4yiDt9tlaOPxb/Qo5iC+6HazMhD4vhjTIbTOFCPmylLBC1J/7uQGSAgOTJ/4nlyT02 M9MFESN5F2MbED0cciJd8epMS5fexEkhUzzsmbM9HW4Zs4IxwkDNLVF1kXYD5TlR8xo0 r5DQ== X-Gm-Message-State: AOJu0Yy34RfgzsHwsleezysmt6GBhJxye0MomYpzSC2x3/I2sklMl+xW QyR+RqDvEaSazu0IQjS7P8RxSuibKOQ= X-Google-Smtp-Source: AGHT+IHYvJp2HPjUOz5zcUNQGz4nPWTdNEKGnUZgV4zqFzOSfCGNZ5w3oNJ8d5yP7P1TsZNHuNilyg== X-Received: by 2002:a05:6000:18cf:b0:31f:8276:5d04 with SMTP id w15-20020a05600018cf00b0031f82765d04mr5797102wrq.34.1694989464373; Sun, 17 Sep 2023 15:24:24 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: Richard Henderson , imp@bsdimp.com, Stacey Son , Karim Taha Subject: [PATCH v3 14/28] bsd-user: Implement getrlimit(2) and setrlimit(2) Date: Mon, 18 Sep 2023 01:22:31 +0300 Message-ID: <20230917222246.1921-15-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230917222246.1921-1-kariem.taha2.7@gmail.com> References: <20230917222246.1921-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: 1694989645844100003 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 | 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 Fri May 17 08:39:47 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=1694989586; cv=none; d=zohomail.com; s=zohoarc; b=jgqsqY+4Qn9dcXonl8+HXxtMDv4Wjj29aigJhYUgAZo03cF8oUa8Y7+oxjiTCHshsGsTYKv43pucK7lf2fa/wDJVkCwv8MyEQ+Jrw/jFgQlMPDUDZVUA9X3xsmKyLP1hx4X5Bz3M0e3HupuCWeauNUBH04f1bjkjHYkjw20ORIc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694989586; 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=OZZJG4yoDhghKCIe5rK0PM8xHr+YkQ01knkSMlOfiVmz4XYgBLEEEQPwDrgH/kvElKZE3H+Nhg0lOJHlbjAhHSUdMg35WE9Tu+zhgw/szpCNUFHUyVaAG+S7wnQOixRV4GY81+kvE8MOOuVuQMVDRlfi3c+BmwnGBidC8DnooMU= 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 1694989586419900.9323775422824; Sun, 17 Sep 2023 15:26:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qi0Br-0006ZQ-Nj; Sun, 17 Sep 2023 18:24:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qi0Bp-0006YE-H2 for qemu-devel@nongnu.org; Sun, 17 Sep 2023 18:24:29 -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 1qi0Bn-0002wR-9s for qemu-devel@nongnu.org; Sun, 17 Sep 2023 18:24:29 -0400 Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-32155a45957so144425f8f.0 for ; Sun, 17 Sep 2023 15:24:26 -0700 (PDT) Received: from karim.my.domain ([197.39.215.8]) by smtp.gmail.com with ESMTPSA id f7-20020adff987000000b0031c8a43712asm10652527wrr.69.2023.09.17.15.24.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 15:24:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694989466; x=1695594266; 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=OPo4bxzkmGSOfuMHoxGKlf2GAGy3El69JWdCv7np7RhSEMAjK1/lJcNXuJF2reI+BJ C6CPci+3FJb7uqWITkNoKDxIJp0XanRJmOYEJUXLTrsshYyHUAgN3l8oVQQ0kb65UO4S e6L+U329W/9RRXxTUsOYDLNYtmVFH14N3ehcNojzgzJJTGxhLzs/i+GjjbQ2q7NTWPSu MsWbhEJbzXC5HP88Lk5uRmFOEAJl6RZoAIBFXUCholGb09P7CCuwet4vxoWan69iHnei uHcn7Co1IhN6iF0t4AJ3vti36nACkECg2DD3IWftlEEyDNCdwYRu09BmQSJ6DerVxpmI Qf5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694989466; x=1695594266; 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=MYPeIqv87FMQTtePHIk1V02xYEIjZAlyJP3itPcMwVDW0TxcsL+3ci8sCXZN+hJi2e GjOIYYY1h1dWjK7f7/UrHM+coXV+rA1OG4CpreT2tQkCZso4vcQX13/bPbIi5wclTyb+ kQktt+QL3cyiUnMqeSCgRWM1d6qrEaxlRi3zq16ppqCcbewR4C0R1ofD5tgDuqbp4Ubr YtbDtk2s06jV/lsr1aTEBZQgehu1YggF5UJ7MGU9ZMzni/CVzqjON9ZAFq0+jfAhCdxK nTfCutHsw3zSFmRrEUl7aulYuDsNvOjoh7riMJRtYTnp8jydKqpkzikbhvIUTBgI5II1 JJLg== X-Gm-Message-State: AOJu0YxovNHLruZ+4kaUh9HxFaaNP0oVWQ52blONXSEQenQOCT4idpgF ag1VxGgI5SZrHwcNSs+cwKcH7cRMEJc= X-Google-Smtp-Source: AGHT+IGfYxxosHoD2vx2v2QUjbe7uv1dBR/BLhfPuPutDRm6QwWtslXuDRMIPnuscBRqvVK+5Jdw7Q== X-Received: by 2002:adf:e9c6:0:b0:317:5e73:7594 with SMTP id l6-20020adfe9c6000000b003175e737594mr5863349wrn.28.1694989465727; Sun, 17 Sep 2023 15:24:25 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: Richard Henderson , imp@bsdimp.com, Stacey Son , Karim Taha Subject: [PATCH v3 15/28] bsd-user: Implement several get/set system calls: Date: Mon, 18 Sep 2023 01:22:32 +0300 Message-ID: <20230917222246.1921-16-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230917222246.1921-1-kariem.taha2.7@gmail.com> References: <20230917222246.1921-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: 1694989587227100003 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 --- 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 Fri May 17 08:39:47 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=1694989671; cv=none; d=zohomail.com; s=zohoarc; b=koV+EtxE5tkIDSTqgdPa0A53lfV6M0y4WLRFt+jl0Zzca4FCul4aehITAYqaDlvp5plE/AlAP04atfXeR7+gXma9PqjGkuwz7OCEOIj69TsjVtjkt3OvQ2HrrWYRH4pn2hUXM+rzftjrAYbFOhYH0ZI8NXJCMdh/vyX7IrWhgaU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694989671; 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=bcw2B77a7Yj02WVmdBpedvdZbKyLH7wGKvYvfxl6kGatxUHeYW+GeI6h63Goz2MhLEwO/FbZpwjHPKx3zOQDneqZrAoAlfcDVOeTwutaRBn+8URL71YcLp224DORwm4/KrOdguBjPSLCDrVys0AA2P6lw9uAgvKKSQhLi1Wn2zE= 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 1694989671987344.5556792144571; Sun, 17 Sep 2023 15:27:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qi0Bs-0006Zk-D5; Sun, 17 Sep 2023 18:24:32 -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 1qi0Bq-0006YW-Gz for qemu-devel@nongnu.org; Sun, 17 Sep 2023 18:24:30 -0400 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qi0Bo-0002wZ-KM for qemu-devel@nongnu.org; Sun, 17 Sep 2023 18:24:30 -0400 Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-31c4d5bd69cso3825133f8f.3 for ; Sun, 17 Sep 2023 15:24:28 -0700 (PDT) Received: from karim.my.domain ([197.39.215.8]) by smtp.gmail.com with ESMTPSA id f7-20020adff987000000b0031c8a43712asm10652527wrr.69.2023.09.17.15.24.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 15:24:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694989467; x=1695594267; 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=hnJm1eNOPmRt24qecrew52OAFn3n0icLshWPUB7thhXpCO6a4BZ2OyRIGVTlmsf7v5 jr51Xw0N7LmZZ3TqvFkGh5B9rexIUG2kFybLYUdqE3eGvZ7SHNKX6NGLiELAbNRSVd3/ NrAeCA5yrwRYDFtxmhIFvzSVs1SDYp6NCOAjvFRZI5rycv3t+gJteeLSJuzJfnZzZtsW Vq6EcmYdbl3Juh8vCj3MkDTHuvuMq2FjL7idGHt56g/EDjosQfJxNGTDJ2VcO18Cn5nE Y1o5M78zDDnGcZ5UDMlYxywva4akICX6cETSbxknELXT47Ho672wzYtWx7+ie0kYrv9Q /YJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694989467; x=1695594267; 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=vPcmXDpcPpuARaajFVZ4/L3ajbHKv/9CQfDgzEykLKa2Y7iWrC4mw3OSV4Wb6g2k+u wC4yza5Vijq43XTD35eOfygTZ+wXWM9r03YcIs1Ur/fBOa4rOn7Ljd6971jINlNx6zlV V1dpA8XhtLPjVwd2qu4O9UmzSWJ36IXfIGoOOcEW35moSUwU5Br+F3O/kuPDmrcshxWX TkFa89NRVMekB2ZrfS+dKIhyMjUzmWLlykIlYH1cO24LIdLW3bXxn3QFe7SWH80PkOfn G/Fq8pfWr0wH0UDWe+NWWlMHh7RGNwjPHfQbfkobWkSvSzo8R7dNiTE/AIwhhtzCKAFZ ZC+g== X-Gm-Message-State: AOJu0YyrID7WjO72ZMpLui0vwZ6Fv6En/osI+ca7PWJrPGY66jBB50ar WdU6WuCb8FnQWe0Twf//+HFptr3CBdw= X-Google-Smtp-Source: AGHT+IHxad3yXQpTORn97UkAIgnU4e9mIrqRhSYI/jt1/ThAh5OVp2VZzUzzxOVAhGfiNg+qclIH5g== X-Received: by 2002:adf:f80e:0:b0:313:f45f:74a1 with SMTP id s14-20020adff80e000000b00313f45f74a1mr5818434wrp.51.1694989466933; Sun, 17 Sep 2023 15:24:26 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: Richard Henderson , imp@bsdimp.com, Stacey Son , Karim Taha Subject: [PATCH v3 16/28] bsd-user: Implement get/set[resuid/resgid/sid] and issetugid. Date: Mon, 18 Sep 2023 01:22:33 +0300 Message-ID: <20230917222246.1921-17-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230917222246.1921-1-kariem.taha2.7@gmail.com> References: <20230917222246.1921-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::430; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wr1-x430.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: 1694989674014100001 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 | 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 Fri May 17 08:39:47 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=1694989610; cv=none; d=zohomail.com; s=zohoarc; b=O/UXSewsxcpgMh9DLmMdZZLtoXcXzw8adT8BSiquTHLuXf//R2T8H/QKyrA/CTOQDqoc7qy4tx0ZPH40R3Iw7DWeX76sgWqHSyRDkX085Nt6P20u/J8VFjDLe7WF6uFAK1x0MUd4e5dwarJSObBoEzf9Lf2sZ2kES1lalywcLtY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694989610; 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=LmrqmyTSxcdzsyvSZjDQuoh482MrBHEhYcOSvbKH1kziGScjOIP2f0JeTxSWio6BKXLs0cT7b113KLZXxDKLUCROy87VaOsb7gseVyv64aQSnufPGBlQwW41qO1twy0gAk5kXvjTqrVSIWA9jitE4JvnP+ULRDpDwmeQaxNM6Sw= 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 1694989610094589.8551127838314; Sun, 17 Sep 2023 15:26:50 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qi0Bt-0006a1-5O; Sun, 17 Sep 2023 18:24: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 1qi0Br-0006ZM-KL for qemu-devel@nongnu.org; Sun, 17 Sep 2023 18:24:31 -0400 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qi0Bp-0002wn-Vg for qemu-devel@nongnu.org; Sun, 17 Sep 2023 18:24:31 -0400 Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-31aeef88a55so3439527f8f.2 for ; Sun, 17 Sep 2023 15:24:29 -0700 (PDT) Received: from karim.my.domain ([197.39.215.8]) by smtp.gmail.com with ESMTPSA id f7-20020adff987000000b0031c8a43712asm10652527wrr.69.2023.09.17.15.24.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 15:24:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694989468; x=1695594268; 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=CY5gR8BKr0ucGVvVf7kE0aBRqi0JiVHAB4FVqmg1t+7iqNLTIAIcdya64pVeVEqtI5 zfU5xgkfATGiuBe3Rw6kUkwr3/RyIqYwOZrYu8Pqf9jIVAxFZ+yA3GQP5qoUfsY2yUhG h2GDvxvN1KJYnncbGSbCSVnxRiN/5pOTdNjD1wNaixbAwEif+NAI0cs7WAanfU8M2mv7 QkOtyVq0i+d8xaO5Zn/ACuWgXW43KuG9gHxP+7PndtRCGSHmqh8sdBrnsQVE5qLFptUf dhv0NIgfOCxEiWM3sz7PVgB/spvd+Aqu7j1EexAh3q9KZk1bW1RZbW0Nay6N4MYKe+v1 jNOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694989468; x=1695594268; 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=JYGgyvkJbNh4xOMz1TQxJC5goq1dqX5Tpf8ZUIPqvhSNrKOabB/xGlP9RauDbDiS/M IozgZc6sc5zFnMTNpLB6TIgx/oprB02Q+oaFdqlVA8JLQWVn/mF8XF3CKbX8c/XdINT9 6L3yqeVldyM9D0/1Hor6pi1gZVGPbvsaY52Z+mF3NeE7N8Mk548OyPyWseYzbBVVTMHQ DGGFpnHBRj6Sd7oHeA96AXID6svdb3xsRy25nWnG9OGC20vCXwlH9Ja1ZSLmx/Ri6W15 fAhlC/f6OxY3IBWY//hUpDJ9IqZ1BP/yxTCrMEmAECdy58bg8Ja4X3xLgKv3o1L870hH kssw== X-Gm-Message-State: AOJu0YxZ6hPc5/5fDdS9QADGH1F2UZHvuJuUqa2WrsUzmqGP8KV92oHK pR6Eij7eQOqshYS87VXwFhQ+BkztHE8= X-Google-Smtp-Source: AGHT+IEYsU6ybJeyII9W/c8MU/3aGY2BcJZS16WdH9h1WVIvglbXzIEjhtEUvj/pRjPXG1WH39sQgA== X-Received: by 2002:a5d:5091:0:b0:317:dada:2417 with SMTP id a17-20020a5d5091000000b00317dada2417mr5836132wrt.31.1694989468363; Sun, 17 Sep 2023 15:24:28 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: Richard Henderson , imp@bsdimp.com, Stacey Son , Karim Taha Subject: [PATCH v3 17/28] bsd-user: Add stubs for profil(2), ktrace(2), utrace(2) and ptrace(2). Date: Mon, 18 Sep 2023 01:22:34 +0300 Message-ID: <20230917222246.1921-18-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230917222246.1921-1-kariem.taha2.7@gmail.com> References: <20230917222246.1921-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::435; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wr1-x435.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: 1694989611596100001 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 | 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 Fri May 17 08:39:47 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=1694989565; cv=none; d=zohomail.com; s=zohoarc; b=RUPr9GdZhPPYBhIIcqHT/V8Tt8U19ReXjAtTj4rQT8gIyHAC0iimQrtbwxhJQM0VEh+joCsX9KChI/5t2hICIKiR1OqBJB3qhfS3IEgj8bKELeGFRYiOYlzA4bDAyPo5gv1auY+VYrWpOXsC3dCpdDxvBR6hmJy70K3uMpiG0WI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694989565; 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=b1NKIpbTmQ97TpwS/8ANgFSxYnyRCDzlmrTnSl8ORo8723Jm5nMS2AgN9rh1UfWtOlqeW25R9s6vqY8syoXmcD/68ry+I9y3HYUX40vEDzhaXV36z1euT4E7Gsl8T4bf8D5dd43AWkM8vI/ccfBmm/1DO9iSUG9DLZTX7fiPhrI= 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 1694989565697196.90224691249432; Sun, 17 Sep 2023 15:26:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qi0Bv-0006ah-95; Sun, 17 Sep 2023 18:24: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 1qi0Bt-0006aI-UU for qemu-devel@nongnu.org; Sun, 17 Sep 2023 18:24:33 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qi0Br-0002xC-86 for qemu-devel@nongnu.org; Sun, 17 Sep 2023 18:24:32 -0400 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-402c46c49f4so42357505e9.1 for ; Sun, 17 Sep 2023 15:24:30 -0700 (PDT) Received: from karim.my.domain ([197.39.215.8]) by smtp.gmail.com with ESMTPSA id f7-20020adff987000000b0031c8a43712asm10652527wrr.69.2023.09.17.15.24.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 15:24:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694989469; x=1695594269; 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=LcXvvf+LmtYz47iTgOAEjQxJ7WRgb3ar9i4DOzggAmdpgwhufVHq1FFzLWHbEora5f 8n37xFM1MqZs6wS8kE+ZGoq4YeE64sw604bHt2gh4UUffaA2FBcw1lvHY2uGlC8tg6cj nlns2Iq0Hg8ICFW8HOMMyux7O/tSsdWo3ew6f60dWz0FgTZN/Rcjidu0gdVmPoUwDYFe +U/IUO4UyurfrbfaDUxTx9sbQoa/RAZreJXPgpZTETcxzDChZqsrmbx7OmG1hP2LfySG Qfdlp410kBlypEI8/OkfG04iA/AP70Nd9Z3R6AC6EcBf+S5MD2d+a50P2jcKDTzGucHR aK5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694989469; x=1695594269; 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=vUJkwE2fS7GIFEMtYKXDvVKsPLZw495qyDQhddgMHdm1AQTmKddKcGyCeprvE5uH+V xpe0EzQ3v/RXDNjNE7LMKWB1i7c4pOmgnoQUApRM8zycHi9HaknMaL4ajOap0r2WpCWj n9A8Ag5A8lzocYkmFqg+gTHEFApx+mJpzVNeoyT3zpguF17jDYnndTHkmZB3hbDEPTt6 mEWu5HxWKAwXyIcJnHuR3sbFPFb8YEMvooKVGVAawn2sxk95/0W2a3OWkqqtdbu68C0n GYeohu01ugo0J72IqhMmZT/znPj9o3B1fx3XJPy2xGcIaZCHOHs6tm4B5CGLHe3L87tM FRMA== X-Gm-Message-State: AOJu0YwAUOMPKSnsjZZ3SbxZCfo/CVJEyPhHSKF/pNtgfyuS2nYKTOq8 7qV0eh765BZep+yS1hJTP2d2q37II2k= X-Google-Smtp-Source: AGHT+IFsGu0vx0DjF1Rf3MlNa/mOJt4cu2OEhGIjBmqqD1SFxhVKbm24LAG1gFew9X21d1lGx6gKSA== X-Received: by 2002:adf:ef90:0:b0:317:e515:d623 with SMTP id d16-20020adfef90000000b00317e515d623mr6225831wro.60.1694989469575; Sun, 17 Sep 2023 15:24:29 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: Richard Henderson , imp@bsdimp.com, Stacey Son , Karim Taha Subject: [PATCH v3 18/28] bsd-user: Implement getpriority(2) and setpriority(2). Date: Mon, 18 Sep 2023 01:22:35 +0300 Message-ID: <20230917222246.1921-19-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230917222246.1921-1-kariem.taha2.7@gmail.com> References: <20230917222246.1921-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::32f; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wm1-x32f.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: 1694989566167100005 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 | 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 Fri May 17 08:39:47 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=1694989562; cv=none; d=zohomail.com; s=zohoarc; b=VqRhY2KVdfn/pk/SesPsZoKqze16pb7PqAMdIDKBqH9UO+mQE18vCNIKOnS0BlAq0U3372qxs5rqjvRcVJbuD7gwF3hiwzVmwHyvSLMDnejR3paaznQzOveNCz2nh+CUrWBEGNRqpPRX/jXBJwYPp6SCdj8JbRQe3EwcJTvnrFY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694989562; 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=D7ZJLwma9hAwd8BtypL+khzjhHCewLElnvWD8+SmGjnbaicCQmsm0MtI0aO3HgGe9OiKJnvETr5uvmqVbRPrvqGhs3xC6qW8nNHSS8C2QSLXhpJIOmKGltDJJkW4yWmWm60IZzoAtylxq5kaZog91R8Q3V1HO+gn7JbSHW2Emsc= 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 1694989562380556.2689033232779; Sun, 17 Sep 2023 15:26:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qi0C9-0006ge-KF; Sun, 17 Sep 2023 18:24: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 1qi0C8-0006gA-0C for qemu-devel@nongnu.org; Sun, 17 Sep 2023 18:24:48 -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 1qi0Bs-0002xP-MD for qemu-devel@nongnu.org; Sun, 17 Sep 2023 18:24:47 -0400 Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-3214cdb4b27so450383f8f.1 for ; Sun, 17 Sep 2023 15:24:32 -0700 (PDT) Received: from karim.my.domain ([197.39.215.8]) by smtp.gmail.com with ESMTPSA id f7-20020adff987000000b0031c8a43712asm10652527wrr.69.2023.09.17.15.24.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 15:24:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694989471; x=1695594271; 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=SG9Pe9GcBJPAS68TyxEZjQjUvysg8w/+dIQg386kkaX4t4CEDRcaP9gRVBBJkdT9XC 5WV8rI2Z5tJovEI8a2FAWKu2Mrvcjf9AWqk76+5mvRtO8KG5J3NmOmjxfFzL0FcxtldC uJ77x/RAMF3ShSiyOQHEVHt7hOlE4T4+f0lf3r2NIRDfeFFaMU24BzgUApw3KboTUpJb Dy/0VxFIfs0wi41KwjUp5GV4mrwsdjpkBPGGuGHH41r38TkmNoxL6MGXke8fKEtMyj6B q3qj/d0OR7Kk9lB/QqavLUsvsOT7rJrXg2xfjEcVBvIkES/MczkavNg3fYqSC5Na1mCt qXoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694989471; x=1695594271; 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=aRSVyo54W0LWIndWjAVTvXebO0ZieSaFr27P25RwdMCIFcug7m1z/GTwkyfbk3vi53 hK/PmqwhjMoQhJBg7lX3tYyp2D6n0sLRF896EAqp+DdsyushqrB5ZWhgVu13wzs4pHNg 0fy2Tj1QwxFHQX6ViM2mAbLGFv/q7PeLl2W4hR8HleHl8MCmRbKAh0Dnb+GlPJOdZPTy CnCXAaAdf2Yi+lLK5SkGDW4aHw2qrg/GefzaWFrLyBh0wX3kqLW0CsXY+tO1g8qnfcrx G0hhK6wZVifwmMbkpUPm8xJnRJUkR1ECdG2YkCBej0oErJ4W3cBmAmZ7jXrNB78M01GF TlUA== X-Gm-Message-State: AOJu0Ywxh9WMiUB2XL2l8yPywZgEeSNzo8JqikWTiiHPqNHRtE34sJia s6TH5NvPsPtyJWSpK44VuYb3Dcb/57c= X-Google-Smtp-Source: AGHT+IFd6XSv6XVgmDxhoOmfLby5woCeeUyh4qNZ10wrYTauue9Fbx2OEyNvTPNCGdGfuHkk0gxnYQ== X-Received: by 2002:a5d:4e46:0:b0:31a:d2f9:7372 with SMTP id r6-20020a5d4e46000000b0031ad2f97372mr6087087wrt.29.1694989470819; Sun, 17 Sep 2023 15:24:30 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: Richard Henderson , imp@bsdimp.com, Karim Taha , Stacey Son Subject: [PATCH v3 19/28] bsd-user: Implement get_filename_from_fd. Date: Mon, 18 Sep 2023 01:22:36 +0300 Message-ID: <20230917222246.1921-20-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230917222246.1921-1-kariem.taha2.7@gmail.com> References: <20230917222246.1921-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, 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: 1694989563009100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Stacey Son Signed-off-by: Karim Taha Reviewed-by: Richard Henderson --- 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 Fri May 17 08:39:47 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=1694989536; cv=none; d=zohomail.com; s=zohoarc; b=d26ixegkKpsWZwXz2pfynPP6AOeaC2FivNmrfNTL4YH+HO31MFIFkgAppzTXEWPsoRde2LF2dKxxhvWp06F1yKP1DD1MUX0CcMaoWIPxtgOGbdj0VFGcLBCRSIkdOJDDYTFgwH+9mvtmHynyrsOcH0WRL9Xt/yoZ/GEmVE7+MJM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694989536; 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=GBK6eL3VQI/BZzG59/qr96FIbU6eJF/CSV98HA0fwGH6bY7lIFm6IqfVdD+mfllXoDfi6mHegc2vRxbrnwjE6hIQ9f26US3bk4YErHACpRxeA7U9C9ms4zXxb9Qjcps9CfZBdmilq44j5SVfaHY5Dc5GVzgPLvgLjsgKhP0gcxs= 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 1694989536324355.4985386789001; Sun, 17 Sep 2023 15:25:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qi0Bz-0006dD-OJ; Sun, 17 Sep 2023 18:24: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 1qi0Bx-0006bU-HR for qemu-devel@nongnu.org; Sun, 17 Sep 2023 18:24: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 1qi0Bu-0002xZ-O0 for qemu-devel@nongnu.org; Sun, 17 Sep 2023 18:24:37 -0400 Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-31ff2ce9d4cso2441712f8f.0 for ; Sun, 17 Sep 2023 15:24:34 -0700 (PDT) Received: from karim.my.domain ([197.39.215.8]) by smtp.gmail.com with ESMTPSA id f7-20020adff987000000b0031c8a43712asm10652527wrr.69.2023.09.17.15.24.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 15:24:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694989472; x=1695594272; 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=VJIMjXNPk9/weHeLY9fQ+/4dbRWzGIq641ve//ifOHgsHmxGKls32yEG55vC98qtSN 08HbGKf01kaCcGmKjCZkKnB9e8iQUnfv3tpjXDWZVo7h4OrL+aDBnbBiuBx1ljTafGQi po5KnQs06HUbaGJloXA+RV+M4sbOge5W+AYuC3Zd4H+72uV7hlOIklNdylNhmt1rbIup 9UltIy783Z42QQH+BkuVxaE1mXAS57T5jDK1TSsPt/XDn8/1mYtH5nZl5Ucp4hIkAO2L jMrAlzMpoWTQvCk0j2HL5bvwajwC1NI2BTuJmpiLgbV6SnG2xq+GdSRXYQiZFTEAhLfE kVpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694989472; x=1695594272; 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=a1oJk0VXsDuso1MSmKsngHuGWFdns9nW6ViKmiwcCzQGqu4r85KIiA4Y9m1Yc/ClB1 i6fzg+DdH6kqXUGkXHK4SlSBwqdHqjauGgusoFSP13szSsD5vrIzVuwfhW8AKnQfmpwA OMfuWJvuDq55+1O8YiP9i81c+wSfX+EN7oaSRht3WiifL49lQbaQizF2quuOwMvZKZ0H 3FKghh6IlSbchzhT44fs41gujWcNsfly6i9mpCUmPPvb9TvFN/oPjLhnYCgXA0Q2Ag5s PKwyyeATYkkfuZr6Yfe1w3fMqJtmBxPmdhbi6/NFYTqp/FSRkSJ1+BCtn7m9+bK/f+a6 dXoA== X-Gm-Message-State: AOJu0YyjBY+ETO5cIWHBm3eGuWizHtRxpI9frBpqm32BvUUU0WH0gRr3 l7q+q84quJfLfEDnnrCP1kq+iSOC4+4= X-Google-Smtp-Source: AGHT+IE1fJVpaZ3o1gPv5VIWRnl8XFwnx0DDnvaY8IJItAgN34TV0DHrE8JdZgNPH8TDAoCToglrfA== X-Received: by 2002:a05:6000:1e88:b0:31f:f893:e07f with SMTP id dd8-20020a0560001e8800b0031ff893e07fmr5317694wrb.12.1694989472192; Sun, 17 Sep 2023 15:24:32 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: Richard Henderson , imp@bsdimp.com, Stacey Son , Karim Taha Subject: [PATCH v3 20/28] bsd-user: Implement freebsd_exec_common, used in implementing execve/fexecve. Date: Mon, 18 Sep 2023 01:22:37 +0300 Message-ID: <20230917222246.1921-21-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230917222246.1921-1-kariem.taha2.7@gmail.com> References: <20230917222246.1921-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: 1694989537923100005 Content-Type: text/plain; charset="utf-8" From: Stacey Son Signed-off-by: Stacey Son Signed-off-by: Karim Taha --- 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 Fri May 17 08:39:47 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=1694989613; cv=none; d=zohomail.com; s=zohoarc; b=AXnO/Ot776PF7LsCxsftugLHkECWK9Cx/ZjTG+AuY4CmoIjDmCNgjAAOIw8upb8+RD1R1cCdsQ8S0T/VyJ5ioSOBNAfejGClRgB8RYFfNJOV4x+xaqdb3/0I7MYElJkoCLKtQR+lYsqUbHL0dhHrCijWuPO2WTkV0xtYAqbxwNQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694989613; 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=LWvhHYGHpRGY2ZJIlUl24G7GwWz9wfrvkZEfuXzvo9zY4LPhU0h6lwsoG1SMJMM+UFCq5o7+zEkGUV2bDQby/FLiJ0hDbznB9AUmY8ywZit20f5UMifNsjp6AXivOKrx3d2jiKCPk6bO8ZYReNCAzhPwlukoS1cAT0/EEnI9O8I= 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 169498961319713.322067502066716; Sun, 17 Sep 2023 15:26:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qi0CD-0006sU-2R; Sun, 17 Sep 2023 18:24:53 -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 1qi0CB-0006kq-Oa for qemu-devel@nongnu.org; Sun, 17 Sep 2023 18:24:51 -0400 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qi0Bv-0002xf-IF for qemu-devel@nongnu.org; Sun, 17 Sep 2023 18:24:51 -0400 Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-313e742a787so2446513f8f.1 for ; Sun, 17 Sep 2023 15:24:35 -0700 (PDT) Received: from karim.my.domain ([197.39.215.8]) by smtp.gmail.com with ESMTPSA id f7-20020adff987000000b0031c8a43712asm10652527wrr.69.2023.09.17.15.24.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 15:24:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694989473; x=1695594273; 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=Hhs7VzP0HQlzYheV9ycorW2/R5GChSL3yAXgqyYVd5jn8f4OXgudZbc6QlAfZ9SoeH y2cvujWERX4gBSz0yEvVS5Nyktp+iqcArObjmgMEpNgyLQCc/buiCWXgasE4APSkkDhI MtgHBM8AD4hZ6lsGNsVaz6NVbI4FJ7bPjjbMy3DTpM/IA/WlVZ6q+2ZvF+bRTWkK+F+K R36TXeaLa0vi8VEN286wt30Vd/y6rDRlIWvjI+2kpl3RocucXN2F7EwnrbefoMAUeTWd qAcUpBtj3+OcRES2GnHNMM8veI6FixyF3pMz2ETWD+p+99aAjoElCXPS4PAo0AW3Et3d daIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694989473; x=1695594273; 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=TSGDZwnXqW+AlC9JZjOMQHYLaN4R3IbFEBGIwRK1K4nKdGcW1i0xGb1AXkUujRNB6/ sosZfkxSek1e6PO5eFizAduzjw3KO/LnqmPia8AclO6wDL2oOGbp91NvFEtV9IvWmFGN 3Fx6iR6cVat0AvxYadUHgV4OsNWsAMqOi5WlxEgXxH9og0nnVjx+j9YjaOyoq3Tpb44O 8F/5rtweIWS1jZw22+W3z2yNzynS3Fiq+1cWVfI3dSAwn4GP+8jucOxCpOw6//cCcGtF XiZGGabVwd1R/eBsatVupv+F9LSSTefu5nXeVl/mkUIGY+D7OUm7P8xAnWzq2xFlCy1W U+Pw== X-Gm-Message-State: AOJu0Yww9iLh4GHx2BZSKp3XhGmknXQobtLTn5yxzN66Bdfjy0LN5qEN K+a4sdZ2mMwVcVZs+FSAXxiYaWId96A= X-Google-Smtp-Source: AGHT+IFBVBPKYR7Mfq+tEiSahjH6VibuzuOtG3DvraWMiQ14THHD0wrf5z5FVQhYz0wyqlaI3ihFLQ== X-Received: by 2002:adf:ea12:0:b0:31f:9bd6:e8c3 with SMTP id q18-20020adfea12000000b0031f9bd6e8c3mr4851547wrm.22.1694989473552; Sun, 17 Sep 2023 15:24:33 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: Richard Henderson , imp@bsdimp.com, Stacey Son , Karim Taha Subject: [PATCH v3 21/28] bsd-user: Implement procctl(2) along with necessary conversion functions. Date: Mon, 18 Sep 2023 01:22:38 +0300 Message-ID: <20230917222246.1921-22-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230917222246.1921-1-kariem.taha2.7@gmail.com> References: <20230917222246.1921-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::432; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wr1-x432.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, 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: 1694989613525100005 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 Fri May 17 08:39:47 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=1694989667; cv=none; d=zohomail.com; s=zohoarc; b=Ma8m465oYQshb7iI6I3mvyLAeHDKvF4uXIFUIIHpY7I4F0lQ3xl4rn2awMe0zEC27vmn19snhQfxuEd/ep96IEWTj4q6lRaNEOzPDg/RypwphmzXuDbYI7ZdtwmWMEYzTqBUjFWPqD4iGyxM28GMPbo2EyyQKE1boeLJDrW+fNA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694989667; 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=ZtOLlAQOIuqgh3QMe0Xrl4k1EOOW7r4N8B0oB7LqXFhVMKt+NmLDnU4w0MeTaeudXdtFqTh/KgUAl83d3Rq+ThNwivC5vT+w16kUVbebpKrfmQJsi+Abh4tRysp85tLdNmmH3ZRIJJhklVrMPqr+RKp7mZjgOFj8ypjdS4SslyU= 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 1694989667240895.9363868078184; Sun, 17 Sep 2023 15:27:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qi0C0-0006dP-GF; Sun, 17 Sep 2023 18:24: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 1qi0Bz-0006cw-C4 for qemu-devel@nongnu.org; Sun, 17 Sep 2023 18:24:39 -0400 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qi0Bx-0002xp-GT for qemu-devel@nongnu.org; Sun, 17 Sep 2023 18:24:39 -0400 Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-31ff1f3cde5so2480310f8f.2 for ; Sun, 17 Sep 2023 15:24:36 -0700 (PDT) Received: from karim.my.domain ([197.39.215.8]) by smtp.gmail.com with ESMTPSA id f7-20020adff987000000b0031c8a43712asm10652527wrr.69.2023.09.17.15.24.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 15:24:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694989475; x=1695594275; 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=RLpqYpEn/HBJRyU0bO8PBrjJEGiK3uDHlN6n5ebXnRWItv4Ujsv53cFqbZU/HhBC6r LNLhKFDFo1FSIKN/8FmfnKRoQpO79n4TRa0tDqeT7a0Z36aUxwLlN4BSkFUN6n6SiWBf yHDmrnsxrsWrEIGSeASOZwC7HVf8scC3wY7Kd/SVgWQSOOBg5T9YOYiiCNCG1oGcww1U SIKC2iP1S2Al64dxVsotw9MbtAEiOunazFDG4ZE8sbBmHC9QGdRHWL3Rhw0gTZVnzqAp RPzvzXKo7YPCyaz/fA3F2rPkkbbpgaIFbSi27vgKs97ay+WBBnRXSiPFixKpEkDGq7I4 U1lQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694989475; x=1695594275; 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=bCTx7VwETVcyG5PNJfoDo6CpSseoWEaq/2z0PeoGQvhPAdvX4RA3xMWAqKqaalgs4t eAxXHNmuyXG0sJ3LW3U4hzXHOw+8f4p/KKgiXlKtmAXtw3dG6xA77NnH8yB6hjd8E3f5 CGTvmrik0F45G45KPm0L53D08YC+6d5Lu0GSm5Csu5hVImWMJmWZrChhf+VWFSGfoA09 igKVf6qK8HFjG5iXRZs4S2GfEeuW3/iAv1n2SisYaqRC2U8bgZKUE0n+00FHOE1X50nZ OYLqUcSxria9/xXEwVTgcKZDOmnph1T4ynccwpM8B0HoJSA2oH/phrT5ayJkCTOcfJjm eN3Q== X-Gm-Message-State: AOJu0YzzpkRhYm1QmVIb5/811I7b/RkuZLRxg6B90cWcMxgOejQVVcoO dBG1lD3TqH4QvqQcltyAiHT+vwqQnKk= X-Google-Smtp-Source: AGHT+IEDYTZbR4c66IHuyPCZtQWE47fsIjDkk9vqNZ/J5yJa/xFLztR8WkCRmNKWMOfTSj61yI08Pg== X-Received: by 2002:a5d:69d0:0:b0:31a:d9bc:47aa with SMTP id s16-20020a5d69d0000000b0031ad9bc47aamr6772815wrw.67.1694989474799; Sun, 17 Sep 2023 15:24:34 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: Richard Henderson , imp@bsdimp.com, Karim Taha , Stacey Son Subject: [PATCH v3 22/28] bsd-user: Implement execve(2) and fexecve(2) system calls. Date: Mon, 18 Sep 2023 01:22:39 +0300 Message-ID: <20230917222246.1921-23-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230917222246.1921-1-kariem.taha2.7@gmail.com> References: <20230917222246.1921-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::432; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wr1-x432.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: 1694989669236100003 Content-Type: text/plain; charset="utf-8" Signed-off-by: Stacey Son Signed-off-by: Karim Taha Reviewed-by: Richard Henderson --- 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 Fri May 17 08:39:47 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=1694989573; cv=none; d=zohomail.com; s=zohoarc; b=QqBBGiZ8AKBD52TU86AkLHGkyl3jSIAgitoEuzAZrfLVesHYbL2UKp5EuK0I6j3fw6CyYHiPd4kXCMMXZQ6Nc2T9tEN6x9OhFYEYzmA0ZUsdzvuUEb5jZ6PCaPwy9DLi0CQO1QQ4FUsZtzrxFUeuXT4ezCwkPJkcoDujE0kReH4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694989573; 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=P6mhpVp1I6lgNUKghYdBIWiA8f0wvyB3g55iLevMRXO0LdLl5fabhVuM2uDTaDCVnK1FychfMWbWMsmdakqZtP2bPyHkFCfo9BmmJrx7OLq56aXAl+Ljq+UZSb2KN+j/wcedJA5FocDoryftlh9k+75MFVR1U5tywfTzH3kzOX8= 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 1694989573399983.5602352506974; Sun, 17 Sep 2023 15:26:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qi0C3-0006eS-2h; Sun, 17 Sep 2023 18:24: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 1qi0C0-0006dU-QZ for qemu-devel@nongnu.org; Sun, 17 Sep 2023 18:24:40 -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 1qi0Bx-0002xv-NC for qemu-devel@nongnu.org; Sun, 17 Sep 2023 18:24:40 -0400 Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-317c3ac7339so3466483f8f.0 for ; Sun, 17 Sep 2023 15:24:37 -0700 (PDT) Received: from karim.my.domain ([197.39.215.8]) by smtp.gmail.com with ESMTPSA id f7-20020adff987000000b0031c8a43712asm10652527wrr.69.2023.09.17.15.24.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 15:24:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694989476; x=1695594276; 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=jAL/psUGjm+znkvv+3o2WZSmOAEk9plUk5cEuTEaVldyAl4kF5rmDQrfHOp19fRNTI PTffnOENv96pyIUEAL3NC4EvkU8Fz+saaGmiyvXXa29Gq9xZPZsq4AxGhaTB+BY8eRBS oX/4Ys+kNNXI5SIDbwsGomReRwxqJrdB/2TGrU0+YrS4rj/3NW1DI1ZM5SUEHjdhd48B FRS6RerAS/ibQ9YtNq0zaHvvvzRHxjkV08E5bu6621PmCJAVkAcnGX9jR+uM734NmXnL f9Gk2+9UvmttIhARHKcoXXM7mw12EyLslUd/ZtRjEfPJqVotn06cvuJnj5DubWELyQXk HdFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694989476; x=1695594276; 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=pnhXRIXpzspSHvymwwnYr8U96dphHWu61/GiFxnYBmLwEhk0oDYii9ocF/zgNe7a6b fstMolZA+TN/ADylQIIZpF98+SInagjJ4idMcAewytRVB4sTYqAMx86DcfHut+rYQtt4 nGgXVok2kj79AkPCgJkcaF9G2wZTbn4fsgYurcXr1A7w5Qx76qXyieNo1oYHgDFVm3m9 afiLviz2CrycYBzjJJ4RbH7teWrKQT2zHEsQNCmeEae5HHMD3KJ+AFrqXyKc86Vnx3Ei 3uZD4aCYiWmtJHdyhspOk6p0mTggUnHxX55/sONuRJivX/Bz758WV5YJMh5+IgLE0Wkm mP2Q== X-Gm-Message-State: AOJu0YxsRGw9ZUbEZN8a8nLupu7NyBIWpZctayCB70VZB+KpPQOeRGNC pUfR1uQ6j69ME5/Ky4XnrEvJFYPuXks= X-Google-Smtp-Source: AGHT+IGGCTjTFbHJtyDD1snS0k0Y9+92IKOtYchSniTBJ491V8KxiIC6kWok02OiWYapWEAJMqr8hQ== X-Received: by 2002:a5d:484a:0:b0:317:6c19:6445 with SMTP id n10-20020a5d484a000000b003176c196445mr6343615wrs.39.1694989476150; Sun, 17 Sep 2023 15:24:36 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: Richard Henderson , imp@bsdimp.com, Stacey Son , Karim Taha Subject: [PATCH v3 23/28] bsd-user: Implement wait4(2) and wait6(2) system calls. Date: Mon, 18 Sep 2023 01:22:40 +0300 Message-ID: <20230917222246.1921-24-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230917222246.1921-1-kariem.taha2.7@gmail.com> References: <20230917222246.1921-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: 1694989574410100001 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 Fri May 17 08:39:47 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=1694989653; cv=none; d=zohomail.com; s=zohoarc; b=GqyTdJMiNsyAD/rlxeb0boVF/eOuYEI+WQjLrpCNMQWlH+4xjo/yFoIIeQsa1b99tklfFOMTJWjrNCs9Ui5kBe9Di3oCqNBsl/ASy+gXkK54LXxXiH8roxr+WLA9GZta1dMwvtPAescSiluN4bl3kyhmxHMIdif0tPTV5fP6YWo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694989653; 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=bWECFffGwrFd6rKvtzeTBbTHDCc+CHQ/+u6R9jh89AWN3z+q8ThwIJUAiDLSCwIt3tJNGlrxr7BBwni3oVOY1CPvkpXOtjC6jytksOUbNnzdO7oW6BhHZsVP74OjThGTznbOuXOKnmtt3Ef7I0RkY0KnGfOoKQKrHM3upD0Z24c= 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 1694989653322515.8628642655412; Sun, 17 Sep 2023 15:27:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qi0C1-0006e4-Q3; Sun, 17 Sep 2023 18:24: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 1qi0C1-0006dm-21 for qemu-devel@nongnu.org; Sun, 17 Sep 2023 18:24:41 -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 1qi0Bz-0002y8-9f for qemu-devel@nongnu.org; Sun, 17 Sep 2023 18:24:40 -0400 Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-3200bc30666so681052f8f.2 for ; Sun, 17 Sep 2023 15:24:38 -0700 (PDT) Received: from karim.my.domain ([197.39.215.8]) by smtp.gmail.com with ESMTPSA id f7-20020adff987000000b0031c8a43712asm10652527wrr.69.2023.09.17.15.24.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 15:24:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694989478; x=1695594278; 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=Cwrut0NeuHfLcoM/O79BshsZtrPYHH84BE8tSXwDWEkzIL+TqUqy0rYX8aQHL1+9K/ EUEYkkdLXgu93tld7HgxrzG+6w/QO5dCqjoK8w3/+wFVWkNljJXTjOtugtBLXRXyqvBk CufBsJbyFvD+HP8EyFNdMBeMcEkMyNEbbCwCkU0CKYDnUrg63lSd6TqRLwIef0iNjko6 AEwyzp0YqAqZBN2mPpwLAmK0xzT/Rsqt3p5Bd/XatS2a7/pJAhOeE8Fg0wP9/+o5F7XP TCcROG65i+vqesv0eTKQS213cS1zyzeAcJfipB6eAJyve63T9T4zszFR3f0fsR1msIlZ HVuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694989478; x=1695594278; 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=UMYXV9/67BlxblDohA4Xw3efClEJDd5GPOszwvTmlnqxhnc3cNaUhkyioFSJ7xAFXI 5WnunchY9VvOHiF+Q6d7conYzojAD6kPtUNkOdcm/OJXVZ8D8fZJSjKxkqKXqCG3LHN0 nJyRwxZPQH0WCBx+157yNsHhgIIU3fgyKjvYwcL2xFrOUYarerjkATxJLjNLdDT54NnL dXaodj1MZdMfHJ4KEBI2/aYABkOxom2KE7bNPlc4sBt2HqSnQFE8xns07Q2UnbJ10IZg D5XTiHIIITNw+NCc/6ILiz6S5H7PN/clbu09euv850br+OqvjTqq0fWjZwNPmZDlRLmy xkzw== X-Gm-Message-State: AOJu0YyRiHc6Ny6dXSlek+po/KHEhzqOAcc901DUAw1uEgcQ5ysiq4ls 2WcyUNT0njIJ57R7uOoNQB6aEeytgFw= X-Google-Smtp-Source: AGHT+IGa3s2N3/AGt+KFHxUWrVEwuT3M8+dilECL/fAGSiF0LYHrNfnnbjTZMkk1b0wRA8RrccZBQg== X-Received: by 2002:adf:f54b:0:b0:31f:b138:5a0 with SMTP id j11-20020adff54b000000b0031fb13805a0mr6089452wrp.48.1694989477694; Sun, 17 Sep 2023 15:24:37 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: Richard Henderson , imp@bsdimp.com, Stacey Son , Karim Taha Subject: [PATCH v3 24/28] bsd-user: Implement setloginclass(2) and getloginclass(2) system calls. Date: Mon, 18 Sep 2023 01:22:41 +0300 Message-ID: <20230917222246.1921-25-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230917222246.1921-1-kariem.taha2.7@gmail.com> References: <20230917222246.1921-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: 1694989655483100003 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 Fri May 17 08:39:47 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=1694989617; cv=none; d=zohomail.com; s=zohoarc; b=lwHoZaHb8d5ieYVg3DqqR9BocPX10aeRFun/GD/bG+/mSLiiUa2OXWq9XqD4m4K8vkC6FJgU7/epjeI2o3DFtMBEKPvRqXKCZzAVBSda1dy+NBpVh3ajT5t5KoFCHhnKosqBH42688XOg3o0M1piu+PvzjpRBp0nTVGpJe6+H8o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694989617; 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=Xjcglx42m077TGloI0lQeBHtAEx4Slew3pydhCw552E=; b=aaerIaM/PsGvUTznu57KUSOMq/phTUndxSa/KZg98Bon40nI/xGQbIUgp2PlQpWOGTnpyVYwAEegX6i9lBzpW/H6Iv6jUn2DJU1k7XfFMB16PQKKiRL1JzmOwtmDHQEqpk+UdyBB4e3i7dnFLU1x474rUg9FjfMJAcZMQmfXqjg= 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 1694989617129606.4014999179526; Sun, 17 Sep 2023 15:26:57 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qi0C4-0006ev-Fv; Sun, 17 Sep 2023 18:24:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qi0C2-0006eI-5J for qemu-devel@nongnu.org; Sun, 17 Sep 2023 18:24: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 1qi0C0-0002yR-LS for qemu-devel@nongnu.org; Sun, 17 Sep 2023 18:24:41 -0400 Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-31c8321c48fso3166030f8f.1 for ; Sun, 17 Sep 2023 15:24:40 -0700 (PDT) Received: from karim.my.domain ([197.39.215.8]) by smtp.gmail.com with ESMTPSA id f7-20020adff987000000b0031c8a43712asm10652527wrr.69.2023.09.17.15.24.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 15:24:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694989479; x=1695594279; 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=Xjcglx42m077TGloI0lQeBHtAEx4Slew3pydhCw552E=; b=ZDbpma3aNebRo4riZQi9Cz6RvQt1B/2El6kCbfRwcxCri9aUve9GAFbtSsy7eyeRoA BL9IZY+F3QnenZpYr7Y/7RMCkKZd2mIv4b5emFzUUaHPJKkoGFs9ZhzT+E2uQinOC9ZH Nj5jA0Cu4yqTLADfcwQY5ccWzPo7h+Pv+l4ThJeWeP7Q8mW5F36XG78G/k8szo+0ncWN tE+/3xjJqrZn/qQNs1fwH6FFXheXtnv7Cr4XwgLWlQqdk5V32uyPL8l+MTGgJvtpvj7b IacjSjeLtu/pA3mYON0QsnLeKHE69vkMNK6P1lHMgnGdQKEz5F4N+YM9I+B4DHQ/p1HY nXUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694989479; x=1695594279; 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=Xjcglx42m077TGloI0lQeBHtAEx4Slew3pydhCw552E=; b=nlddtS6sXvR3wu9CmBtEcYajd/qWOB/0ScWsuE5U8QvnwrRayLyLmJ4misQmH2MKej FEVhvKRf69I81QP7Ut4YQvZXKxOZmKam39rHwKB30re2PGXv062oOXhmOJp8dE8pOINI oi4rIWqNm1lmCFquew0mcCDXW1PVPfgVyBdQKrUESSGE7Oz1JLRZS9Pe7kdClOVN67ch yzp2v4MKrdH7YvqhhKIca4jwexPsJJWZ92yBX3DTvQWahRv5RQ5s91JdDsBQPWijpS5n eRYZKwAZ7nGYWARQadb3e4G3Rd6ydrmokGSkWYS3hYoU4pf56GkriP6hvBNN6qR0jlCL e4jg== X-Gm-Message-State: AOJu0YwKD26UOncPGXxHjvAZkf7I3ftzFe+J9a8fdoR1vC9P9xSm/Vxk eQwZmLh5XC7vvy6VGBekvNTjjqB0cWY= X-Google-Smtp-Source: AGHT+IFdJTnkLWzdqU1eOmVmIBTFI4Q5QI4JSjoFuWx494YnX+dRidQaVzH3tgyytxLRzIMXgYSP9Q== X-Received: by 2002:a5d:6ac8:0:b0:317:6734:c2ae with SMTP id u8-20020a5d6ac8000000b003176734c2aemr7986441wrw.11.1694989478988; Sun, 17 Sep 2023 15:24:38 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: Richard Henderson , imp@bsdimp.com, Stacey Son , Karim Taha Subject: [PATCH v3 25/28] bsd-user: Implement pdgetpid(2) and the undocumented setugid. Date: Mon, 18 Sep 2023 01:22:42 +0300 Message-ID: <20230917222246.1921-26-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230917222246.1921-1-kariem.taha2.7@gmail.com> References: <20230917222246.1921-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: 1694989617521100003 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..964be4ad87 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 -TARGET_ENOSYS; +} + #endif /* BSD_USER_FREEBSD_OS_PROC_H */ diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index 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 Fri May 17 08:39:47 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=1694989586; cv=none; d=zohomail.com; s=zohoarc; b=g2us54CldGDdd4lZ6ltzCrQyLxwp5gP0Pe0N0RRdX2qQNkATnYKpfhLPX0Qh+QeYFqLIuqDJq1OHuAr1mKWBGIBDLtD226taCnaN6rOdz7oEC5W7D66ILIRJzJWl0eD7MHoDBBND68qUiSMEBOkdCrvyPNX6ZTGbXeihdsLr9mc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694989586; 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=2S8FXSzNKMQIuGGPJ7n1TKh338FdyhommirmsIYSgdk=; b=j9O//j141LwvV+n/PCIU5HF3g6EaCNI++QTx9/DIvcPOyfEGIVJgmDbak29UzhUS2jn+TAqmjldcWYyaw1xPMFmmqQNHN125U9GsZmUaDAOsEd37TQWdIEUt4MR9gZzEzvBU7FaEOadFc46TkHO/+AnG9U81TMgK3WSZiIG5rdI= 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 1694989585810275.0211997383557; Sun, 17 Sep 2023 15:26:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qi0C5-0006fC-AW; Sun, 17 Sep 2023 18:24: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 1qi0C3-0006ej-IK for qemu-devel@nongnu.org; Sun, 17 Sep 2023 18:24:43 -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 1qi0C1-0002ye-V8 for qemu-devel@nongnu.org; Sun, 17 Sep 2023 18:24:43 -0400 Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-31ff2ce9d4cso2441776f8f.0 for ; Sun, 17 Sep 2023 15:24:41 -0700 (PDT) Received: from karim.my.domain ([197.39.215.8]) by smtp.gmail.com with ESMTPSA id f7-20020adff987000000b0031c8a43712asm10652527wrr.69.2023.09.17.15.24.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 15:24:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694989480; x=1695594280; 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=2S8FXSzNKMQIuGGPJ7n1TKh338FdyhommirmsIYSgdk=; b=i7gEGDC7FPc1omTlYN9GVi5hTFpd3FnW0qy1EwvLQ5XRPcoM2cLy1/ozhWR8olZd95 HaaoXN4FOfB2CgDMEj/e2XaIZR+KBXcElFg0JQiUafvmPWJaGFygQ8zDNORA9Zg43sjb U0Qaq5QXJGMrjw3nVU4vI6KXKvYRezXFrXf0WbG9+hD7nMo6X3JuwP8TAyIn4qqr4P4j 8XKCfnaoSjhAEJN3+D+d7VuZuOWftAjO40DTolS/n8XmNaV/GFyIcP2UYyO+CCcSGbFj +bP+0gW8sB5iqB96DrNtAWN24lISdgtPmnN65NzkIae048VR4GUWw3aOEmBVsySsmL2R UCfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694989480; x=1695594280; 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=2S8FXSzNKMQIuGGPJ7n1TKh338FdyhommirmsIYSgdk=; b=g3mwJzD4LiqzeOinp5XeC4qCICns/vsWLijLofeFZ7AwSxDQx/j08yMqz5ZvJVV3j6 qjFcODJlmBksdzsZsPxpm2oFd6tePC7YocKDDhlmB5YWbyez5th3/E1CEAsPEcc2Ml5p Q+PCUBvk0nMjscyqOX8NhqlrhGh/bO5p3W6KgJUE6ykgw0S1SPBwsHmvv1kprYW00Ph8 ukNgfU77Y5piM8Yh5FyvPSaZB4hcyK853Qm/tdwLhukr6g4lOuKFI93XQYSi3Nok1Zx1 iffs+V2ZSA0DTk+8h04De7h0liRN8lJHjKppI9wjYR2C3y+p5Z4ymdptQEuf6EqVRzJv 2y6A== X-Gm-Message-State: AOJu0YzI1+JPxh/3PmDMtyR4wtfEuqUVEI5DcsmhgtvfG2zU3q3EPWLK BevM0gKPVTPw8OdChk9WuhFBjd8rBMs= X-Google-Smtp-Source: AGHT+IHtTRyz6ECq3MI3zw2MXcDkTYXlZjk1IBPTMKGpLfjGliOv1nLy+bKYHwmoV/vs+iMKknCXNQ== X-Received: by 2002:adf:a30d:0:b0:31f:fa38:425f with SMTP id c13-20020adfa30d000000b0031ffa38425fmr4509152wrb.9.1694989480123; Sun, 17 Sep 2023 15:24:40 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: Richard Henderson , imp@bsdimp.com, Stacey Son , Karim Taha Subject: [PATCH v3 26/28] bsd-user: Implement fork(2) and vfork(2) system calls. Date: Mon, 18 Sep 2023 01:22:43 +0300 Message-ID: <20230917222246.1921-27-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230917222246.1921-1-kariem.taha2.7@gmail.com> References: <20230917222246.1921-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: 1694989586753100001 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 | 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 964be4ad87..23b2f77a73 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 -TARGET_ENOSYS; } =20 +/* fork(2) */ +static inline abi_long do_freebsd_fork(void *cpu_env) +{ + abi_long ret; + abi_ulong child_flag; + + fork_start(); + ret =3D fork(); + if (ret =3D=3D 0) { + /* child */ + child_flag =3D 1; + target_cpu_clone_regs(cpu_env, 0); + } else { + /* parent */ + child_flag =3D 0; + } + + /* + * The fork system call sets a child flag in the second return + * value: 0 for parent process, 1 for child process. + */ + set_second_rval(cpu_env, child_flag); + + fork_end(child_flag); + + return ret; +} + +/* vfork(2) */ +static inline abi_long do_freebsd_vfork(void *cpu_env) +{ + return do_freebsd_fork(cpu_env); +} + #endif /* BSD_USER_FREEBSD_OS_PROC_H */ diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index 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 Fri May 17 08:39:47 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=1694989493; cv=none; d=zohomail.com; s=zohoarc; b=dt0mZ42QCeOdCLtWp5q2PEnNVIVPy2H/xAy9RaxdNDpwcbKWzQ/Rv2BGuXmtXOzV21IMR0ctBX9Lysnz8gO+ERTOBkUxXUGvw9gwcuMhly4dOCpVc+jVroUxnFIZY/hgo7cFBFtVneMPE9wbrwn0bo3FDso4VNDYKIX8DgICO9A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694989493; 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=mw8oJ6RJMLfyGngcXE7kSkbQnhvZ0mfQP6CsE/YxQqI=; b=jOsg5SyV8LhmR3GifGhuyZnzzmT+Kqo3TxRAn3nLRb2Jk02K1guuzD8txZF8To6zY1D0IpKAUFSzS9eXlqEW6SjFVko01r+FvRqHbks4f6JP0QSQC3MkayOXHI9GwnKEQ7VPmvE7WMOtwsj4NKb+kx5ib40KEw1HAwSDmtT85+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 1694989493535549.270887022252; Sun, 17 Sep 2023 15:24:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qi0C6-0006ff-3E; Sun, 17 Sep 2023 18:24:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qi0C4-0006ey-Ol for qemu-devel@nongnu.org; Sun, 17 Sep 2023 18:24:44 -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 1qi0C3-0002yr-5d for qemu-devel@nongnu.org; Sun, 17 Sep 2023 18:24:44 -0400 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-31f7400cb74so3427773f8f.2 for ; Sun, 17 Sep 2023 15:24:42 -0700 (PDT) Received: from karim.my.domain ([197.39.215.8]) by smtp.gmail.com with ESMTPSA id f7-20020adff987000000b0031c8a43712asm10652527wrr.69.2023.09.17.15.24.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 15:24:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694989481; x=1695594281; 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=mw8oJ6RJMLfyGngcXE7kSkbQnhvZ0mfQP6CsE/YxQqI=; b=cIOih3pA1Xci/pxeSmNjtpubMGxCsGLqlmTyneQZAw2HEwctryU27awFSDBj3T30pM p/3gw9m3he9tAFhCv+IYN54uP98doT073brqB/OvV7+OjgG7JPbqSZQD05ivsv5GBG+l WaeuTna5QOAKGIunvfJezEhm5rA14utYv5FwPzy73jyWo53NF61rz3rBiD4CIYhOPHil qlJDUTumfoKWYPfI5D+fFh7YatlwLD0FV4FusdrCbqoGjUxg2GvSbIzY/ygvHp8X+DjZ 4mXCgtmzTxm0JL/20gC7IcdlIAFN/FM9YCTpB4Auo2xyMQ8OmB2diYMgd8aB8uqL5PUr 7Afw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694989481; x=1695594281; 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=mw8oJ6RJMLfyGngcXE7kSkbQnhvZ0mfQP6CsE/YxQqI=; b=YbPsDyglUbQPX7t7+K+3ur1UnCVKMCE648OnrFVBaAdBArXEGHRNiaYZXlH32TyNCD Pi9zVTMShJaFKZOD0v02JT4YFxz+EQH1h8WFZLE2C8VX2Z0Ckepw6r3jNJDb+J1kdNVv P+IUVhiGO2gradCJFgh7NhNbEWR4bi9PLnhFztQ6bavILo7VFeWmkAoUM8HNBG/o5AOM Zji0D7oufP++5yDirSSwSATvi33ORHdmI6MknHJzpsd0QfkTbZMsf3wvwEjP95c9xhFe x4p0aYVDA65+Q7r4RxE3Zb/J08BZSe0MwpmGFySchKAWE/bhICQZhja7a22i5zmQKdXW k88g== X-Gm-Message-State: AOJu0YyfJLRBInhFnYN8XAzZsdtlNbFmAWm7Hz7CjAcIByZg3YWd1yic C7bWUMV6cYPFdGpIgYF1JaRbCnUa6ZI= X-Google-Smtp-Source: AGHT+IF+G8VdYiZ8iqkIWwojTqGMATZ2pqg7P2MBu6dFL8igNNzVYeydKyDmql9K4h2T+6SwxIqjeg== X-Received: by 2002:a05:6000:1f9b:b0:31f:fb63:12d8 with SMTP id bw27-20020a0560001f9b00b0031ffb6312d8mr5090792wrb.44.1694989481363; Sun, 17 Sep 2023 15:24:41 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: Richard Henderson , imp@bsdimp.com, Stacey Son , Karim Taha Subject: [PATCH v3 27/28] bsd-user: Implement rfork(2) system call. Date: Mon, 18 Sep 2023 01:22:44 +0300 Message-ID: <20230917222246.1921-28-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230917222246.1921-1-kariem.taha2.7@gmail.com> References: <20230917222246.1921-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: 1694989495091100007 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 | 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 23b2f77a73..6121af9efd 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 Fri May 17 08:39:47 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=1694989551; cv=none; d=zohomail.com; s=zohoarc; b=EP0y6i8u0xUMseaVPS0lgLhCpcxygnMCeOUnP0kpTcyy6xFiNncXxRxMH/Ew9yth2Eq8DGCgxyPPCZaWFN3IwnASLEbszit3PO+d16i22MwUxIBCSvdcZTI0iehnw5DH+LVNH2NJ1fmrZ0cIy47AJR4jMWXtELUHuJ4cf5Zhij4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694989551; 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=lHrLm3D+56wj1h7VzyOPMu3lSfb2xouAbdsbSwPc/XM=; b=kzJgU5eS+TzirS4h6GcHsimfJB0XpagkBAB8QOFrVs4by+DgwNnT0nSN5+oDg8BKz5/bUJJRbXsdhllOThdbW6zZ4c02CcxTzgNB2pVebmoQS5YmTTdT80i2B1h9bXxzyhoRkW3XYLZ7tStFKwXy/Lq734qve5ojXECW7LpZrmc= 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 1694989551525116.63318742231195; Sun, 17 Sep 2023 15:25:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qi0CB-0006h4-Cd; Sun, 17 Sep 2023 18:24:51 -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 1qi0C5-0006fe-WB for qemu-devel@nongnu.org; Sun, 17 Sep 2023 18:24:46 -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 1qi0C4-0002yy-Au for qemu-devel@nongnu.org; Sun, 17 Sep 2023 18:24:45 -0400 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-404314388ceso41531385e9.2 for ; Sun, 17 Sep 2023 15:24:43 -0700 (PDT) Received: from karim.my.domain ([197.39.215.8]) by smtp.gmail.com with ESMTPSA id f7-20020adff987000000b0031c8a43712asm10652527wrr.69.2023.09.17.15.24.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 15:24:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694989482; x=1695594282; 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=lHrLm3D+56wj1h7VzyOPMu3lSfb2xouAbdsbSwPc/XM=; b=d0ACD9wawtQb5fpyPPAV5LNLc/GMcVSGskhI5Xgx0ZYe3amzm3ljeTV7vSJLgnF9Fw s8caqei4s+ACxUifaTy5li0LlyhwlcDhZWhyxkMMMkqEJQBwkd7tplHiF7PgQ+AwPJgn 0/M3FDNpQja3Lkj9XULi72BOGdMk13XTm8W2RBSMZSCUe+RcGlR+HnrWoE1WgIyTAqJc sTrHPLSxHgKs8C25ZUWdC5t/7mPKDOLQlXcxhdyjHfJr2At2d1Xw1XM1NAbEU8zP4+rS gEVRWpQ88biQqS6iAfzrXT/JuSYHwt16qrIynjHL91Wf5aSDJAeQti3HB8mNw86LNvz1 O8tg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694989482; x=1695594282; 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=lHrLm3D+56wj1h7VzyOPMu3lSfb2xouAbdsbSwPc/XM=; b=rEG5UYRbHA5m2rwCMtVM0kXbcBTd1Zq60burCtKGE6Onqyfbkk4+ykfG4/ZMBd0ie3 Np9Uh/mU0ShNPbDpNy54liko5nZGQ1omK26k2vhUbuIsZBr5VKbVVriE1LqvJUY5QBZ9 Htrk/ZiFy3DikU4lspyWGaJHbmM3jfncGALras3TlYK98ahLLs5YyxKVIQANbbVGPMDs Atr92IrYvXI88abGnxaUZu9BBl5PQBOc7I8vc+/3cer462/R5aP8Osaq8/btqWSxAwNO N1INOOD8ogiLTkprpTzDXp35ADKsIa6LfHDUeoxsHCzisv3u/iRSV9LUByMvQzymReM1 mvww== X-Gm-Message-State: AOJu0YyKNl/o2/puOMo9aN+1s/VEKwAXVmJ3Iv+q3SaHqIS+iqyxSLg0 LiY1jYIba0AAGsCEh1yVTw3giJwcTVs= X-Google-Smtp-Source: AGHT+IFbgUmLJKzd4mtrkhSMjOChWcCvmfAdBNqlHcoUDrcyKQYJUEvHvOz1Zgjv5lWBkO7514uLHQ== X-Received: by 2002:a05:6000:68c:b0:31f:f72c:dfa3 with SMTP id bo12-20020a056000068c00b0031ff72cdfa3mr6689122wrb.68.1694989482591; Sun, 17 Sep 2023 15:24:42 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: Richard Henderson , imp@bsdimp.com, Stacey Son , Karim Taha Subject: [PATCH v3 28/28] bsd-user: Implement pdfork(2) system call. Date: Mon, 18 Sep 2023 01:22:45 +0300 Message-ID: <20230917222246.1921-29-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230917222246.1921-1-kariem.taha2.7@gmail.com> References: <20230917222246.1921-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: 1694989551901100001 Content-Type: text/plain; charset="utf-8" From: Stacey Son Signed-off-by: Stacey Son Signed-off-by: Karim Taha Acked-by: Richard Henderson --- 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 6121af9efd..57ee20a93f 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