From nobody Thu Oct 31 00:22:44 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1694986888; cv=none; d=zohomail.com; s=zohoarc; b=d6BhSkjyC94YocMy6BOARpISQRN5XbJVX0Mk7dpg2QNzRMGkn7ytYJPT4FRkCDmLj4XcLpLwtoOgDphlzjT2kLAWNZbYj/R2WI8Z38sW4190A14heuZCTPzGonJKi83LjPMSsvf3UVGDmKE65iGkMoH/yEkqn9ZMfb88vvivo7A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694986888; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=SrhHSKh9Zy1jpJox1NZgc4ABlNUS27qhkUc+VlL02Mc=; b=aBvWWKL8FzLx9iJrj4xcR9cJPyaxDRZLxeSny7yyvAFjosIL72Q/x0xU0VdeXlt62RIcoGTYzUU/+TeEZf8XVv+P7vWha9rFe4HHlJTEBmu9aG6NqMGzX21DRY7jZf4okhQz29FoTghGDcOFCeVPTtNmqMm84IzEEh2hvDLfqsA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694986888577566.196697708946; Sun, 17 Sep 2023 14:41:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qhzUr-0004ei-9u; Sun, 17 Sep 2023 17:40:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qhzUi-0004cB-Ri for qemu-devel@nongnu.org; Sun, 17 Sep 2023 17:39:56 -0400 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qhzUg-0004JO-RP for qemu-devel@nongnu.org; Sun, 17 Sep 2023 17:39:56 -0400 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-4050bd2e33aso2274995e9.2 for ; Sun, 17 Sep 2023 14:39:54 -0700 (PDT) Received: from karim.my.domain ([197.39.215.8]) by smtp.gmail.com with ESMTPSA id n11-20020a5d484b000000b00317ddccb0d1sm10561735wrs.24.2023.09.17.14.39.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 14:39:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694986793; x=1695591593; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=SrhHSKh9Zy1jpJox1NZgc4ABlNUS27qhkUc+VlL02Mc=; b=JcT+dm04B2yUYJr6ztrnVU/2TExgFRg96IfUojtr6ebAWDH8RbAY82aj6lFMcVYqa2 Meh3Stz1NFdU1/aYV4O+bIExtUIoE2xD0GgxRaSY+F9WPTW9DshLACXmJTzA35P9RKyc zOwgOOQXb+TVjaaotZJqu8yq6dNjTgJXBSBcmVpE02aAM2sO/MWHlyWoS4+2ccJqdVrS xSVd8igiQWDDjrkoB/d7Ym/9v7X0rcGjgA3TioUsT7LKt8q5ucmWr2IrRAjAd5qHSxEN AJtpEBU2ZcJMClQpuTKu/ZTphI146gFuJzGV3/Qnnzb2nkJQGBkXphKkMV6LdxX2P0kO hbFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694986793; x=1695591593; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SrhHSKh9Zy1jpJox1NZgc4ABlNUS27qhkUc+VlL02Mc=; b=XM5Qvd9gBKk0P/WlqQDQk+6Q2KD008N7rGzSpEdvCNpbuPv1/HeWJz0Vt48IKSTZdK uv1qCSghj9iqPcxyNP4vNdfb64xB5MOkZW6MA16G1KNc8Rg/YMGnxnKpw9kP6xhvIFL8 Fua04tptXRPZ9ry9+EAYUfIPGC6t/TwWFn8hwgLxhp60T5bqsNpoiLimilG/Ys5Yt3CQ e8fmxg30DTN4WUNViXSlhrfCQSUv21ODdeL31zXiu7lZ1F/PtLfh5zaGfdr7NjiRdFti MvOWSqSEmugoE0u00h+2swVOS9PMLwANyPYJ5gBv7RQgWM+7yVdY6YH1gaQ8iblfpg/J UsFQ== X-Gm-Message-State: AOJu0YwtZ2JBViwhTcvJCs7GzgYaVl6tTSjnGD4GsvzDS5W4EPc3sxcZ 2MLQeeZVd74me82Crg7NxOvsqrlWAnY= X-Google-Smtp-Source: AGHT+IHCsLWO9Oom+NsaebJNx7WjKd0SvEIYLbPK6JIbYDwt+RVzgp5S5SXq8TSfSblSAY9YoWw08Q== X-Received: by 2002:a7b:c38c:0:b0:3fe:785:abf9 with SMTP id s12-20020a7bc38c000000b003fe0785abf9mr6698691wmj.2.1694986793210; Sun, 17 Sep 2023 14:39:53 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: imp@bsdimp.com, Richard Henderson , Karim Taha , Stacey Son Subject: [PATCH v2 22/28] bsd-user: Implement execve(2) and fexecve(2) system calls. Date: Mon, 18 Sep 2023 00:37:57 +0300 Message-ID: <20230917213803.20683-23-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230917213803.20683-1-kariem.taha2.7@gmail.com> References: <20230917213803.20683-1-kariem.taha2.7@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wm1-x334.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1694986890020100003 Content-Type: text/plain; charset="utf-8" Signed-off-by: Stacey Son Signed-off-by: Karim Taha Reviewed-by: Richard Henderson Reviewed-by: Warner Losh --- bsd-user/freebsd/os-proc.h | 49 +++++++++++++++++++++++++++++++++++ bsd-user/freebsd/os-syscall.c | 11 +++++++- 2 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 bsd-user/freebsd/os-proc.h diff --git a/bsd-user/freebsd/os-proc.h b/bsd-user/freebsd/os-proc.h new file mode 100644 index 0000000000..75ed39f8dd --- /dev/null +++ b/bsd-user/freebsd/os-proc.h @@ -0,0 +1,49 @@ +/* + * process related system call shims and definitions + * + * Copyright (c) 2013-14 Stacey D. Son + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + */ + +#ifndef BSD_USER_FREEBSD_OS_PROC_H +#define BSD_USER_FREEBSD_OS_PROC_H + +#include +#include +#include +#include +#include +#include +#include + +#include "target_arch_cpu.h" + +/* execve(2) */ +static inline abi_long do_freebsd_execve(abi_ulong path_or_fd, abi_ulong a= rgp, + abi_ulong envp) +{ + + return freebsd_exec_common(path_or_fd, argp, envp, 0); +} + +/* fexecve(2) */ +static inline abi_long do_freebsd_fexecve(abi_ulong path_or_fd, abi_ulong = argp, + abi_ulong envp) +{ + + return freebsd_exec_common(path_or_fd, argp, envp, 1); +} + +#endif /* BSD_USER_FREEBSD_OS_PROC_H */ diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index b7bd0b92a6..515eaaf31f 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -36,8 +36,9 @@ #include "bsd-file.h" #include "bsd-proc.h" =20 -/* *BSD dependent syscall shims */ +/* BSD dependent syscall shims */ #include "os-stat.h" +#include "os-proc.h" =20 /* I/O */ safe_syscall3(int, open, const char *, path, int, flags, mode_t, mode); @@ -219,6 +220,14 @@ static abi_long freebsd_syscall(void *cpu_env, int num= , abi_long arg1, /* * process system calls */ + case TARGET_FREEBSD_NR_execve: /* execve(2) */ + ret =3D do_freebsd_execve(arg1, arg2, arg3); + break; + + case TARGET_FREEBSD_NR_fexecve: /* fexecve(2) */ + ret =3D do_freebsd_fexecve(arg1, arg2, arg3); + break; + case TARGET_FREEBSD_NR_exit: /* exit(2) */ ret =3D do_bsd_exit(cpu_env, arg1); break; --=20 2.42.0