From nobody Fri May 17 08:39:27 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 164371493289068.49072768268763; Tue, 1 Feb 2022 03:28:52 -0800 (PST) Received: from localhost ([::1]:45190 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nErL9-0006D0-Kj for importer@patchew.org; Tue, 01 Feb 2022 06:28:51 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56942) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nEr7o-0004zx-VN for qemu-devel@nongnu.org; Tue, 01 Feb 2022 06:15:04 -0500 Received: from [2607:f8b0:4864:20::12a] (port=41542 helo=mail-il1-x12a.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nEr7k-0003Wp-6e for qemu-devel@nongnu.org; Tue, 01 Feb 2022 06:15:04 -0500 Received: by mail-il1-x12a.google.com with SMTP id 15so13954451ilg.8 for ; Tue, 01 Feb 2022 03:14:50 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id w5sm13526852ilu.83.2022.02.01.03.14.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Feb 2022 03:14:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=A0lUDFAMoJs0uwGgwRvS9AqQpOcBmDEXb/Re9WXU5VE=; b=7u+Ja6/PEOrhzInaamhOrIZlWNI+pgKu6ZrR1C2aLerqKeOUSW9N39yZWTfHP6tR1m k36st9IZZClVCmxleTtZnXSlU52urAaw21kfQ6yWkAE/YxNrmjy+LLkyPvjBTJadOl41 OGNpKn9DiLxl30NrIO0pv+1eeihYjNqBE7GZXe9LIF2HzAv43F5X7vYYzJs7v+SoPq6x i8kroCFTs1Z/m9AawYyjxqmwkxQyDvvpHJCAgNn3dJSniE+mlQ2oJTs2ufRVtpJMOGM/ fv9YP+oUoiavYCFuc/LAAm3Mrhh0u7pRVeEoG2ucNqUg+YEIJdvtkos8ug7qNbFDh1vy +wgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=A0lUDFAMoJs0uwGgwRvS9AqQpOcBmDEXb/Re9WXU5VE=; b=TCEwe+k8xqdfDF+3D+HIY72oPo3LpBo3NvBKsSv5StJ7xtgdc4iDrlEE6AqEly65Of WEU6QCXoQ++auaU0v+/1kWZzgnOydB3vS04cBRlOQU2QmXxUqQpO9qywgbABz+9jHltw XHxuJsSE6Q47skJ8LJxXurUo3z3kudVx5q6WJVukoRYVHEfnK8NqK4BpuVLjDyEmq13V boi+Az0ULcIHf3YkpHM+aRtteOeq0ivgQGDa3AUl8ea5U3ETIT0+CpgLqjXF5yNx1gmp b6+njskvavkarHHUEAej4SjxT8/hgKX2TbEj55gLV0HnqJ70BbLKQGyshwYcOoj7V+qj Xs4A== X-Gm-Message-State: AOAM531CD9cYzS8KUc+Z3ErS1qa4UjlU3hgebQpeFICDHKSQ/jVQZn9Q m3vHzYBHtYrJYolowrKz9Uhs0zPOyiVDBg== X-Google-Smtp-Source: ABdhPJzyFTv0YvpOVCiRqxrWEkdHAW+I3VhyqVoMY0KZ3CIuO2dyOPCWhEKlSARRum5ddBWu1z0H6w== X-Received: by 2002:a05:6e02:1a27:: with SMTP id g7mr14985225ile.284.1643714089306; Tue, 01 Feb 2022 03:14:49 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH 01/22] bsd-user/main.c: Drop syscall flavor arg -bsd Date: Tue, 1 Feb 2022 04:14:34 -0700 Message-Id: <20220201111455.52511-2-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220201111455.52511-1-imp@bsdimp.com> References: <20220201111455.52511-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::12a (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::12a; envelope-from=imp@bsdimp.com; helo=mail-il1-x12a.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , arrowd@FreeBSD.org, Kyle Evans , Richard Henderson , def@FreeBSD.org, jrtc27@FreeBSD.org, Warner Losh , Brad Smith Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1643714935044100001 Content-Type: text/plain; charset="utf-8" We've not realistically been able to actually run any bsd program on any other bsd program. They are too diverged to do this easily. The current code is setup to do it, but implementing it is hard. Stop pretending that we can do this. Signed-off-by: Warner Losh Reviewed-by: Richard Henderson --- bsd-user/main.c | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/bsd-user/main.c b/bsd-user/main.c index f1d58e905e7..bddb830e99b 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -164,7 +164,6 @@ static void usage(void) "-E var=3Dvalue sets/modifies targets environment variable= (s)\n" "-U var unsets targets environment variable(s)\n" "-B address set guest_base address to address\n" - "-bsd type select emulated BSD type FreeBSD/NetBSD/Open= BSD (default)\n" "\n" "Debug options:\n" "-d item1[,...] enable logging of specified items\n" @@ -392,17 +391,6 @@ int main(int argc, char **argv) have_guest_base =3D true; } else if (!strcmp(r, "drop-ld-preload")) { (void) envlist_unsetenv(envlist, "LD_PRELOAD"); - } else if (!strcmp(r, "bsd")) { - if (!strcasecmp(argv[optind], "freebsd")) { - bsd_type =3D target_freebsd; - } else if (!strcasecmp(argv[optind], "netbsd")) { - bsd_type =3D target_netbsd; - } else if (!strcasecmp(argv[optind], "openbsd")) { - bsd_type =3D target_openbsd; - } else { - usage(); - } - optind++; } else if (!strcmp(r, "seed")) { seed_optarg =3D optarg; } else if (!strcmp(r, "singlestep")) { --=20 2.33.1 From nobody Fri May 17 08:39:27 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1643715296040726.0246515743994; Tue, 1 Feb 2022 03:34:56 -0800 (PST) Received: from localhost ([::1]:34798 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nErR1-0001TS-C2 for importer@patchew.org; Tue, 01 Feb 2022 06:34:55 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56876) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nEr7n-0004vt-Nq for qemu-devel@nongnu.org; Tue, 01 Feb 2022 06:15:03 -0500 Received: from [2607:f8b0:4864:20::132] (port=46838 helo=mail-il1-x132.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nEr7k-0003Wu-64 for qemu-devel@nongnu.org; Tue, 01 Feb 2022 06:15:03 -0500 Received: by mail-il1-x132.google.com with SMTP id e8so13933477ilm.13 for ; Tue, 01 Feb 2022 03:14:51 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id w5sm13526852ilu.83.2022.02.01.03.14.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Feb 2022 03:14:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Nc0IiVmtMU6CkZSHSIc0Rennc5vkDh9M9cpSmLz0+iA=; b=hNDvjT4gF3dc0aIN0ndnGbDiCJffPgbxmHZaRa7Ft8yEtsF5aTS04sM3fALUTvq5yK MoOoXSXAl7WniUA11PbjT5iQai7TlTD1hpkMhOPykJ0J1exSb/WwuRXr4Mh3Q34YHjNa pOOd+nDnjgzFmQshlnIhP8SxXSnPu6hCkmnKiLL3soRaEEj+p2opinNJSctKycODzv1e QCWzBf143Okq247DAerC9EX5+4j9u28Avq8QLAO0J84sYwOfLZu0YrEzMPQbP/JFaoZU ko1s/6D78mbWaxBCOde/UHgcx8k5XTTPQFe/suyq1HahoDVRrwL9Q7YPEoN4sxUr5qNy 0NdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Nc0IiVmtMU6CkZSHSIc0Rennc5vkDh9M9cpSmLz0+iA=; b=EWt7FdT9qMrtYv4HR17nmdWs9Eo8Dke/Djywo9/xGh9ARbzrCm1oU88u/8yLwfTkx0 5tgDRWGsZYWwjCaAcPyZsh7ikCuWd9quKs61Kdur423spRsM7Ib0tEOh2+e0VMTjflzZ guu2XNF4O3YWLpuGfTlmxFJS7/4ZLv8c2x+QwuAHV+Di90zVXcww7Fcl4GYlB+C2F9mk 1HyZWN31M0HTLgYlPJBquaVkuEjlYOdsLW6y0zZ/w1BtYSlero0MSD2wjGkI7PJ7dLa6 CbZD6aYTbffs0qYbvRa9PEaw371CzAcHLaLfLxOT1GWWUXcLDdDHtQiDy8ripNvSL58x P4VQ== X-Gm-Message-State: AOAM530UiycDPQk0w2DqKI4m5+Ny6muJ7OoOg90/EKmNmDKlyIuY7ucn FBvm6lkyCmk9rhCW3uZW0S8rbU1v+Baq5Q== X-Google-Smtp-Source: ABdhPJxxUsGhj7JN6fLTJFYXkaLJampETLlFmPK1Wl1yCkNSV3V59zKEwXhtFEnTUbt7cLiPz6OLiA== X-Received: by 2002:a05:6e02:17c6:: with SMTP id z6mr2224260ilu.229.1643714090672; Tue, 01 Feb 2022 03:14:50 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH 02/22] bsd-user/x86_64/target_arch_cpu.h: int $80 never was a BSD system call on amd64 Date: Tue, 1 Feb 2022 04:14:35 -0700 Message-Id: <20220201111455.52511-3-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220201111455.52511-1-imp@bsdimp.com> References: <20220201111455.52511-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::132 (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::132; envelope-from=imp@bsdimp.com; helo=mail-il1-x132.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , arrowd@FreeBSD.org, Kyle Evans , Richard Henderson , def@FreeBSD.org, jrtc27@FreeBSD.org, Warner Losh , Brad Smith Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1643715299292100001 Content-Type: text/plain; charset="utf-8" Although initial versions of NetBSD did use int $80, it was replaced by syscall before any releases. OpenBSD and FreeBSD always did syscall. Signed-off-by: Warner Losh Reviewed-by: Kyle Evans Reviewed-by: Richard Henderson --- bsd-user/x86_64/target_arch_cpu.h | 58 ------------------------------- 1 file changed, 58 deletions(-) diff --git a/bsd-user/x86_64/target_arch_cpu.h b/bsd-user/x86_64/target_arc= h_cpu.h index 0a9c0f08946..9dc52d5afc4 100644 --- a/bsd-user/x86_64/target_arch_cpu.h +++ b/bsd-user/x86_64/target_arch_cpu.h @@ -124,64 +124,6 @@ static inline void target_cpu_loop(CPUX86State *env) process_queued_cpu_work(cs); =20 switch (trapnr) { - case 0x80: - /* syscall from int $0x80 */ - if (bsd_type =3D=3D target_freebsd) { - abi_ulong params =3D (abi_ulong) env->regs[R_ESP] + - sizeof(int32_t); - int32_t syscall_nr =3D env->regs[R_EAX]; - int32_t arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8; - - if (syscall_nr =3D=3D TARGET_FREEBSD_NR_syscall) { - get_user_s32(syscall_nr, params); - params +=3D sizeof(int32_t); - } else if (syscall_nr =3D=3D TARGET_FREEBSD_NR___syscall) { - get_user_s32(syscall_nr, params); - params +=3D sizeof(int64_t); - } - get_user_s32(arg1, params); - params +=3D sizeof(int32_t); - get_user_s32(arg2, params); - params +=3D sizeof(int32_t); - get_user_s32(arg3, params); - params +=3D sizeof(int32_t); - get_user_s32(arg4, params); - params +=3D sizeof(int32_t); - get_user_s32(arg5, params); - params +=3D sizeof(int32_t); - get_user_s32(arg6, params); - params +=3D sizeof(int32_t); - get_user_s32(arg7, params); - params +=3D sizeof(int32_t); - get_user_s32(arg8, params); - env->regs[R_EAX] =3D do_freebsd_syscall(env, - syscall_nr, - arg1, - arg2, - arg3, - arg4, - arg5, - arg6, - arg7, - arg8); - } else { /* if (bsd_type =3D=3D target_openbsd) */ - env->regs[R_EAX] =3D do_openbsd_syscall(env, - env->regs[R_EAX], - env->regs[R_EBX], - env->regs[R_ECX], - env->regs[R_EDX], - env->regs[R_ESI], - env->regs[R_EDI], - env->regs[R_EBP]); - } - if (((abi_ulong)env->regs[R_EAX]) >=3D (abi_ulong)(-515)) { - env->regs[R_EAX] =3D -env->regs[R_EAX]; - env->eflags |=3D CC_C; - } else { - env->eflags &=3D ~CC_C; - } - break; - case EXCP_SYSCALL: /* syscall from syscall instruction */ if (bsd_type =3D=3D target_freebsd) { --=20 2.33.1 From nobody Fri May 17 08:39:27 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1643715840797402.8605147980238; Tue, 1 Feb 2022 03:44:00 -0800 (PST) Received: from localhost ([::1]:49358 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nErZn-0003Ns-Py for importer@patchew.org; Tue, 01 Feb 2022 06:43:59 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56992) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nEr7q-00054U-6h for qemu-devel@nongnu.org; Tue, 01 Feb 2022 06:15:06 -0500 Received: from [2607:f8b0:4864:20::12c] (port=33530 helo=mail-il1-x12c.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nEr7k-0003Wy-BB for qemu-devel@nongnu.org; Tue, 01 Feb 2022 06:15:05 -0500 Received: by mail-il1-x12c.google.com with SMTP id o10so13999690ilh.0 for ; Tue, 01 Feb 2022 03:14:52 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id w5sm13526852ilu.83.2022.02.01.03.14.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Feb 2022 03:14:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=u/RdOufxsgAVRIFnGmjXk9mwEobZpTAulFytqYBcPis=; b=MMxRLKHvUfKXn1Ez0xmYBNJq6iumcWo1WqvCTdBxYp7d+o3VmaUlicST1IYN0l8giX Fs1skyfdc3gcjrZDoPc6QJ3niHTF6sZ3cKuRh7Xnp01dC9tmjsYJc1ZzIGp2Os9ILq5C deHtsyxofcoLJ7TCXQqSArB5l6O9NLug62ghBTIKjNgi2OqCam/KzywU17mE+T2porPD Y3xJooMKR9F+sV4jcwJD7Wakm9h4JyoT+OKZ62PEPrGeYQdE+Ko8Ek4bCNW5l1VlnBO1 i0tNR4SskIkWCOGKUsQQrdIP/lzNNSBQRYhEITNcG8tfTKq1jPMP5tqB2pC+83aG0vzC YLxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=u/RdOufxsgAVRIFnGmjXk9mwEobZpTAulFytqYBcPis=; b=leMUb0j6O5U9hmMm0Eop8InPwS6nuaH2rPYEsIocq3Tssc+JcedhM2bNVOtv25C4hW JW0FH3Lttv5++dSP5m0Lzuizzwy4djinluXPXbMg+z1yJLvGVheyXYx2sWH4O6eRm2yI casNObwesN6B6F+8GcZKygMV2z/Mj9TzzFXr5KbKRL8TnT4ySJfoYyGY/3xR0YsKmnv6 pH69+UXPXQ13DxEC/iwqSkHJ9zJ4Ui36STkX+E/iXoZlkqEx4MZuBuJyHqGAaLKnz3T9 zY3T7uRmVzdvrN186IExb07HEQZ1urAa8mLJmD5bxo4RpmfofiSyn7p/BDXgoIfCtqCZ GM8w== X-Gm-Message-State: AOAM530nEn86wX6sKFdOYTpILP5Oy1/pLHwNOzdH3KW3TiVpTu+pCNYc zP2mg4k7xT/vjKv+I20dz8bQK9HSsOKXDg== X-Google-Smtp-Source: ABdhPJykweJeg5TomQPGiz74kexpgbEtYfsf3GPeXaZ7k1Zi4k/OupDphaTR/NtY2Y/FqhXV4jKIPw== X-Received: by 2002:a05:6e02:1786:: with SMTP id y6mr1786445ilu.152.1643714091619; Tue, 01 Feb 2022 03:14:51 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH 03/22] bsd-user/x86_64/target_arch_cpu.h: Remove openbsd syscall Date: Tue, 1 Feb 2022 04:14:36 -0700 Message-Id: <20220201111455.52511-4-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220201111455.52511-1-imp@bsdimp.com> References: <20220201111455.52511-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::12c (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::12c; envelope-from=imp@bsdimp.com; helo=mail-il1-x12c.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , arrowd@FreeBSD.org, Kyle Evans , Richard Henderson , def@FreeBSD.org, jrtc27@FreeBSD.org, Warner Losh , Brad Smith Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1643715844100100001 Content-Type: text/plain; charset="utf-8" This doesn't build on openbsd at the moment, and this could should arguably be in bsd-user/*bsd/x86_64 somewhere. Until we refactor to support OpenBSD/NetBSD again, drop it here. Signed-off-by: Warner Losh Reviewed-by: Kyle Evans Reviewed-by: Richard Henderson --- bsd-user/x86_64/target_arch_cpu.h | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/bsd-user/x86_64/target_arch_cpu.h b/bsd-user/x86_64/target_arc= h_cpu.h index 9dc52d5afc4..5be2f02416e 100644 --- a/bsd-user/x86_64/target_arch_cpu.h +++ b/bsd-user/x86_64/target_arch_cpu.h @@ -126,25 +126,14 @@ static inline void target_cpu_loop(CPUX86State *env) switch (trapnr) { case EXCP_SYSCALL: /* syscall from syscall instruction */ - if (bsd_type =3D=3D target_freebsd) { - env->regs[R_EAX] =3D do_freebsd_syscall(env, - env->regs[R_EAX], - env->regs[R_EDI], - env->regs[R_ESI], - env->regs[R_EDX], - env->regs[R_ECX], - env->regs[8], - env->regs[9], 0, 0); - } else { /* if (bsd_type =3D=3D target_openbsd) */ - env->regs[R_EAX] =3D do_openbsd_syscall(env, - env->regs[R_EAX], - env->regs[R_EDI], - env->regs[R_ESI], - env->regs[R_EDX], - env->regs[10], - env->regs[8], - env->regs[9]); - } + env->regs[R_EAX] =3D do_freebsd_syscall(env, + env->regs[R_EAX], + env->regs[R_EDI], + env->regs[R_ESI], + env->regs[R_EDX], + env->regs[R_ECX], + env->regs[8], + env->regs[9], 0, 0); env->eip =3D env->exception_next_eip; if (((abi_ulong)env->regs[R_EAX]) >=3D (abi_ulong)(-515)) { env->regs[R_EAX] =3D -env->regs[R_EAX]; --=20 2.33.1 From nobody Fri May 17 08:39:27 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1643715900157746.5255383593767; Tue, 1 Feb 2022 03:45:00 -0800 (PST) Received: from localhost ([::1]:52118 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nEral-0005FE-8z for importer@patchew.org; Tue, 01 Feb 2022 06:44:59 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56974) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nEr7p-00052i-LY for qemu-devel@nongnu.org; Tue, 01 Feb 2022 06:15:05 -0500 Received: from [2607:f8b0:4864:20::12b] (port=46832 helo=mail-il1-x12b.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nEr7k-0003X4-Av for qemu-devel@nongnu.org; Tue, 01 Feb 2022 06:15:05 -0500 Received: by mail-il1-x12b.google.com with SMTP id e8so13933546ilm.13 for ; Tue, 01 Feb 2022 03:14:53 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id w5sm13526852ilu.83.2022.02.01.03.14.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Feb 2022 03:14:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=R7HVIeHMlsKUNdUJ9jwdOaK4GYXpGEwWjSdWL1V6hnI=; b=8DZ+yuRLkG/0qFa95ZC+FwWk/HCn5+J98AroEsBzeHscKq+JntGpj3Rqx/8M00j1lg 4iWoukz+a30cxeLWoXeWnSMVwkMp7Fp1fIQ9fahuHX10EBXE3I3lqE2QukDM6qbSVSya VTBm0WBhceMewHaZ42SKiMLVJAzfr02d/u9QGCb0GwvGbKfLfXAACUn3BEFOFhnWaEdv oTNO9j4Ag2J9QwCMUpQrIZh55YuMD/hClFZTgT2XwtQaoBnx7nWwgbedZzjNT+cMyYvq 8dCmvATo/yZfAhAFvWnHHF7ml55ihX+nSHmx1KfwjltWqM2AXdNCvxiAZL9oX59e9TId 5C6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=R7HVIeHMlsKUNdUJ9jwdOaK4GYXpGEwWjSdWL1V6hnI=; b=4qPj/IshacxgP3Nw6GhvbviHXEOi3ccl2ieRTxxehmwYn9t6Z71LCiP8b6J6kW92YX XjZoGxdIsbbaWC3vyvGoxSI7uDRn6v5VoZ8gN+CwTGS/5VLoHzx1Url4KD2Geg2KPoFN I4/F9OhLU1xX11JcBAeG2cXd6zIjj16mN95E9lJETp7KzG8rY47mufdVqJWIYh6Uh27t NCvuMTbW8BNQsHDZux/k7DubsG4LGZ+gyCIBAOO4SYJ8kQa/Y7v2D3b8VYCunTACO+dj yX6qY8IlRynOrCTTrBhJnlsYQ6bbNBiSP5vZm8EvQX8QjPY4yrD72qXAOA76Mpnbooj7 vLvw== X-Gm-Message-State: AOAM531zMLGRLXJVnfTRnNR3LKFnwLnjxAfrFI1A04GT60qpFpGrJbJn 0pwUStUDr00jRd4dqBIchybMcOtNiYY8zQ== X-Google-Smtp-Source: ABdhPJzvJj9/8C8oyN9mc+Dvz/IMZec7oHLlmCrr+0xdlSboJxxbgTlDhq5TT4dRnAz7wiSDIfZIqw== X-Received: by 2002:a92:b70c:: with SMTP id k12mr5919338ili.210.1643714092635; Tue, 01 Feb 2022 03:14:52 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH 04/22] bsd-user/i386/target_arch_cpu.h: Remove openbsd syscall Date: Tue, 1 Feb 2022 04:14:37 -0700 Message-Id: <20220201111455.52511-5-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220201111455.52511-1-imp@bsdimp.com> References: <20220201111455.52511-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::12b (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::12b; envelope-from=imp@bsdimp.com; helo=mail-il1-x12b.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , arrowd@FreeBSD.org, Kyle Evans , Richard Henderson , def@FreeBSD.org, jrtc27@FreeBSD.org, Warner Losh , Brad Smith Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1643715902273100001 Content-Type: text/plain; charset="utf-8" This doesn't build on openbsd at the moment, and this could should arguably be in bsd-user/*bsd/i386 somewhere. Until we refactor to support OpenBSD/NetBSD again, drop it here. Signed-off-by: Warner Losh Reviewed-by: Kyle Evans Reviewed-by: Richard Henderson --- bsd-user/i386/target_arch_cpu.h | 84 +++++++++++++++------------------ 1 file changed, 37 insertions(+), 47 deletions(-) diff --git a/bsd-user/i386/target_arch_cpu.h b/bsd-user/i386/target_arch_cp= u.h index 3cbf69d8af2..9da22202d48 100644 --- a/bsd-user/i386/target_arch_cpu.h +++ b/bsd-user/i386/target_arch_cpu.h @@ -116,55 +116,45 @@ static inline void target_cpu_loop(CPUX86State *env) process_queued_cpu_work(cs); =20 switch (trapnr) { - case 0x80: + case 0x80: { /* syscall from int $0x80 */ - if (bsd_type =3D=3D target_freebsd) { - abi_ulong params =3D (abi_ulong) env->regs[R_ESP] + - sizeof(int32_t); - int32_t syscall_nr =3D env->regs[R_EAX]; - int32_t arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8; - - if (syscall_nr =3D=3D TARGET_FREEBSD_NR_syscall) { - get_user_s32(syscall_nr, params); - params +=3D sizeof(int32_t); - } else if (syscall_nr =3D=3D TARGET_FREEBSD_NR___syscall) { - get_user_s32(syscall_nr, params); - params +=3D sizeof(int64_t); - } - get_user_s32(arg1, params); - params +=3D sizeof(int32_t); - get_user_s32(arg2, params); - params +=3D sizeof(int32_t); - get_user_s32(arg3, params); - params +=3D sizeof(int32_t); - get_user_s32(arg4, params); - params +=3D sizeof(int32_t); - get_user_s32(arg5, params); - params +=3D sizeof(int32_t); - get_user_s32(arg6, params); - params +=3D sizeof(int32_t); - get_user_s32(arg7, params); + abi_ulong params =3D (abi_ulong) env->regs[R_ESP] + + sizeof(int32_t); + int32_t syscall_nr =3D env->regs[R_EAX]; + int32_t arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8; + + if (syscall_nr =3D=3D TARGET_FREEBSD_NR_syscall) { + get_user_s32(syscall_nr, params); params +=3D sizeof(int32_t); - get_user_s32(arg8, params); - env->regs[R_EAX] =3D do_freebsd_syscall(env, - syscall_nr, - arg1, - arg2, - arg3, - arg4, - arg5, - arg6, - arg7, - arg8); - } else { /* if (bsd_type =3D=3D target_openbsd) */ - env->regs[R_EAX] =3D do_openbsd_syscall(env, - env->regs[R_EAX], - env->regs[R_EBX], - env->regs[R_ECX], - env->regs[R_EDX], - env->regs[R_ESI], - env->regs[R_EDI], - env->regs[R_EBP]); + } else if (syscall_nr =3D=3D TARGET_FREEBSD_NR___syscall) { + get_user_s32(syscall_nr, params); + params +=3D sizeof(int64_t); + } + get_user_s32(arg1, params); + params +=3D sizeof(int32_t); + get_user_s32(arg2, params); + params +=3D sizeof(int32_t); + get_user_s32(arg3, params); + params +=3D sizeof(int32_t); + get_user_s32(arg4, params); + params +=3D sizeof(int32_t); + get_user_s32(arg5, params); + params +=3D sizeof(int32_t); + get_user_s32(arg6, params); + params +=3D sizeof(int32_t); + get_user_s32(arg7, params); + params +=3D sizeof(int32_t); + get_user_s32(arg8, params); + env->regs[R_EAX] =3D do_freebsd_syscall(env, + syscall_nr, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8); } if (((abi_ulong)env->regs[R_EAX]) >=3D (abi_ulong)(-515)) { env->regs[R_EAX] =3D -env->regs[R_EAX]; --=20 2.33.1 From nobody Fri May 17 08:39:27 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1643714931039958.7312414460882; Tue, 1 Feb 2022 03:28:51 -0800 (PST) Received: from localhost ([::1]:44536 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nErL7-0005ua-LA for importer@patchew.org; Tue, 01 Feb 2022 06:28:49 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56958) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nEr7p-00051s-FC for qemu-devel@nongnu.org; Tue, 01 Feb 2022 06:15:05 -0500 Received: from [2607:f8b0:4864:20::135] (port=41553 helo=mail-il1-x135.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nEr7k-0003XB-65 for qemu-devel@nongnu.org; Tue, 01 Feb 2022 06:15:04 -0500 Received: by mail-il1-x135.google.com with SMTP id 15so13954580ilg.8 for ; Tue, 01 Feb 2022 03:14:54 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id w5sm13526852ilu.83.2022.02.01.03.14.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Feb 2022 03:14:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ncWnqsf+UN/vyTIxU3XOpWl26IcR1Ir0CJ6FYV9kHjk=; b=WsYlcgV8rDZQYoO4LtYd5nvESi/HctmamCRVeW6WkNnGtjdQxn2XkyhfCFQ2Qa7lke jsad4M75XuaErmv+A+Dj+2OiOz1XGenApSigxX7Tq/lGfyoy0oFxSTo/VLkYzcuhRM8s 9Zqs0t9UJgVSmCIacNRsxBi1Tu5l0eK0ZIYa2MC/uZK0JZRN+Hq58pjE9eOoQ0y54rv2 iyjWBLDyDj2XGcMQBJ+F5eAfGi149S+l6B+ZaUV4jXNyWsh6SeydCyQGcMTSexkymLGn e1QjIX/XXHDhg7PXBfNSQcRY68KkBX6oRfT5/m+x4KRW3hDasrn+3jOr3ehoVFqOGjGk wiGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ncWnqsf+UN/vyTIxU3XOpWl26IcR1Ir0CJ6FYV9kHjk=; b=qNvLqoTJ9MgopIRHFY8SEHYX8DCA7L5ziQxgloSMaX1hNVAdRMMtF+IHBiRJcl5k50 YbF8mWhs6U570fE0O37EfB39mdJoTgoIgar9+K6YAzKzpPxi6VusVtInXO3uqpBiBPK9 0mCxTtK9wUeDCyPIZDvj8FnAgqriMdAR7CjWogJr+2G3RbGbej+9r/8haFzKGo0Px7MM Ch14aUsWsNf84BfnEYzB69pFaCcF7gd8pxxLIKaXfexY7MAQjQesUpoGY5NNjcaEeUII YhAXdVp4lH3Z9Nqe58cY9q9UbN8Vj0afHUEOOPRgN3oE61h9U1/y0o40wl4xxILZxrO5 PZwQ== X-Gm-Message-State: AOAM5313g8a+yVjEqFsSqFdCfE/GTiI2ZCbTosNcWOu5Bdqv2Pqqm0UN gV2ynmuahY5eQd8TVLUc6v4yk1pjWtcOkA== X-Google-Smtp-Source: ABdhPJxcLyIjXRCtVogEUjbhUC40uAds2717xINVKF1k9Wbt1oOKnNxyESgZTIUveBU/DqJTO89k4Q== X-Received: by 2002:a05:6e02:b41:: with SMTP id f1mr15109068ilu.193.1643714093502; Tue, 01 Feb 2022 03:14:53 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH 05/22] bsd-user/arm/target_arch_cpu.h: Only support FreeBSD sys calls Date: Tue, 1 Feb 2022 04:14:38 -0700 Message-Id: <20220201111455.52511-6-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220201111455.52511-1-imp@bsdimp.com> References: <20220201111455.52511-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::135 (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::135; envelope-from=imp@bsdimp.com; helo=mail-il1-x135.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , arrowd@FreeBSD.org, Kyle Evans , Richard Henderson , def@FreeBSD.org, jrtc27@FreeBSD.org, Warner Losh , Brad Smith Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1643714932823100001 Content-Type: text/plain; charset="utf-8" Since we don't build on OpenBSD, only do FreeBSD system calls here. In the future, we'll need to move this to some place like bsd-user/freebsd/arm/mumble.h, but until then just leave this inline. This reflects changes to the upstream. Signed-off-by: Warner Losh Reviewed-by: Kyle Evans Reviewed-by: Richard Henderson --- bsd-user/arm/target_arch_cpu.h | 139 ++++++++++++++++----------------- 1 file changed, 66 insertions(+), 73 deletions(-) diff --git a/bsd-user/arm/target_arch_cpu.h b/bsd-user/arm/target_arch_cpu.h index b087db48fa4..afb7814a8d1 100644 --- a/bsd-user/arm/target_arch_cpu.h +++ b/bsd-user/arm/target_arch_cpu.h @@ -40,7 +40,6 @@ static inline void target_cpu_init(CPUARMState *env, static inline void target_cpu_loop(CPUARMState *env) { int trapnr, si_signo, si_code; - unsigned int n; CPUState *cs =3D env_cpu(env); =20 for (;;) { @@ -66,82 +65,76 @@ static inline void target_cpu_loop(CPUARMState *env) break; case EXCP_SWI: { - n =3D env->regs[7]; - if (bsd_type =3D=3D target_freebsd) { - int ret; - abi_ulong params =3D get_sp_from_cpustate(env); - int32_t syscall_nr =3D n; - int32_t arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8; + int ret; + abi_ulong params =3D get_sp_from_cpustate(env); + int32_t syscall_nr =3D env->regs[7]; + int32_t arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8; =20 - /* See arm/arm/syscall.c cpu_fetch_syscall_args() */ - if (syscall_nr =3D=3D TARGET_FREEBSD_NR_syscall) { - syscall_nr =3D env->regs[0]; - arg1 =3D env->regs[1]; - arg2 =3D env->regs[2]; - arg3 =3D env->regs[3]; - get_user_s32(arg4, params); - params +=3D sizeof(int32_t); - get_user_s32(arg5, params); - params +=3D sizeof(int32_t); - get_user_s32(arg6, params); - params +=3D sizeof(int32_t); - get_user_s32(arg7, params); - arg8 =3D 0; - } else if (syscall_nr =3D=3D TARGET_FREEBSD_NR___sysca= ll) { - syscall_nr =3D env->regs[0]; - arg1 =3D env->regs[2]; - arg2 =3D env->regs[3]; - get_user_s32(arg3, params); - params +=3D sizeof(int32_t); - get_user_s32(arg4, params); - params +=3D sizeof(int32_t); - get_user_s32(arg5, params); - params +=3D sizeof(int32_t); - get_user_s32(arg6, params); - arg7 =3D 0; - arg8 =3D 0; - } else { - arg1 =3D env->regs[0]; - arg2 =3D env->regs[1]; - arg3 =3D env->regs[2]; - arg4 =3D env->regs[3]; - get_user_s32(arg5, params); - params +=3D sizeof(int32_t); - get_user_s32(arg6, params); - params +=3D sizeof(int32_t); - get_user_s32(arg7, params); - params +=3D sizeof(int32_t); - get_user_s32(arg8, params); - } - ret =3D do_freebsd_syscall(env, syscall_nr, arg1, arg2= , arg3, - arg4, arg5, arg6, arg7, arg8); + /* See arm/arm/syscall.c cpu_fetch_syscall_args() */ + if (syscall_nr =3D=3D TARGET_FREEBSD_NR_syscall) { + syscall_nr =3D env->regs[0]; + arg1 =3D env->regs[1]; + arg2 =3D env->regs[2]; + arg3 =3D env->regs[3]; + get_user_s32(arg4, params); + params +=3D sizeof(int32_t); + get_user_s32(arg5, params); + params +=3D sizeof(int32_t); + get_user_s32(arg6, params); + params +=3D sizeof(int32_t); + get_user_s32(arg7, params); + arg8 =3D 0; + } else if (syscall_nr =3D=3D TARGET_FREEBSD_NR___syscall) { + syscall_nr =3D env->regs[0]; + arg1 =3D env->regs[2]; + arg2 =3D env->regs[3]; + get_user_s32(arg3, params); + params +=3D sizeof(int32_t); + get_user_s32(arg4, params); + params +=3D sizeof(int32_t); + get_user_s32(arg5, params); + params +=3D sizeof(int32_t); + get_user_s32(arg6, params); + arg7 =3D 0; + arg8 =3D 0; + } else { + arg1 =3D env->regs[0]; + arg2 =3D env->regs[1]; + arg3 =3D env->regs[2]; + arg4 =3D env->regs[3]; + get_user_s32(arg5, params); + params +=3D sizeof(int32_t); + get_user_s32(arg6, params); + params +=3D sizeof(int32_t); + get_user_s32(arg7, params); + params +=3D sizeof(int32_t); + get_user_s32(arg8, params); + } + ret =3D do_freebsd_syscall(env, syscall_nr, arg1, arg2, ar= g3, + arg4, arg5, arg6, arg7, arg8); + /* + * Compare to arm/arm/vm_machdep.c + * cpu_set_syscall_retval() + */ + if (-TARGET_EJUSTRETURN =3D=3D ret) { /* - * Compare to arm/arm/vm_machdep.c - * cpu_set_syscall_retval() + * Returning from a successful sigreturn syscall. + * Avoid clobbering register state. */ - if (-TARGET_EJUSTRETURN =3D=3D ret) { - /* - * Returning from a successful sigreturn syscall. - * Avoid clobbering register state. - */ - break; - } - if (-TARGET_ERESTART =3D=3D ret) { - env->regs[15] -=3D env->thumb ? 2 : 4; - break; - } - if ((unsigned int)ret >=3D (unsigned int)(-515)) { - ret =3D -ret; - cpsr_write(env, CPSR_C, CPSR_C, CPSRWriteByInstr); - env->regs[0] =3D ret; - } else { - cpsr_write(env, 0, CPSR_C, CPSRWriteByInstr); - env->regs[0] =3D ret; /* XXX need to handle lseek(= )? */ - /* env->regs[1] =3D 0; */ - } + break; + } + if (-TARGET_ERESTART =3D=3D ret) { + env->regs[15] -=3D env->thumb ? 2 : 4; + break; + } + if ((unsigned int)ret >=3D (unsigned int)(-515)) { + ret =3D -ret; + cpsr_write(env, CPSR_C, CPSR_C, CPSRWriteByInstr); + env->regs[0] =3D ret; } else { - fprintf(stderr, "qemu: bsd_type (=3D %d) syscall " - "not supported\n", bsd_type); + cpsr_write(env, 0, CPSR_C, CPSRWriteByInstr); + env->regs[0] =3D ret; /* XXX need to handle lseek()? */ + /* env->regs[1] =3D 0; */ } } break; --=20 2.33.1 From nobody Fri May 17 08:39:27 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1643715252152142.70278317597786; Tue, 1 Feb 2022 03:34:12 -0800 (PST) Received: from localhost ([::1]:60384 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nErQH-00088x-Ke for importer@patchew.org; Tue, 01 Feb 2022 06:34:09 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56938) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nEr7o-0004zd-RC for qemu-devel@nongnu.org; Tue, 01 Feb 2022 06:15:04 -0500 Received: from [2607:f8b0:4864:20::d2e] (port=38681 helo=mail-io1-xd2e.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nEr7k-0003XD-6b for qemu-devel@nongnu.org; Tue, 01 Feb 2022 06:15:04 -0500 Received: by mail-io1-xd2e.google.com with SMTP id w7so20717268ioj.5 for ; Tue, 01 Feb 2022 03:14:55 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id w5sm13526852ilu.83.2022.02.01.03.14.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Feb 2022 03:14:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SeIissd9yu6sr1EpyUUZEaaK6kIza5Vpduyt6eMziNI=; b=dG2RwdFmh5jSpgQcSqgXnNibD/LupeCO5WrMuau+PQvqPO7q3jh3OlISmBK0vnDrig OF/r4goH16kGXEvlQp1H9Z00wPv30OckWmarE3C9OM3oOLBG19N48T9s1mdbIQL3kBSP GEoNEqFlv7uvzGRU4BZTMT+G1fYzn4o1/yj9uM/8X5D/UeaoUFmDwHFCineRfrr1Hm4T uS5LWpkF2hzXQBrut8H/QcmgLj0vMOrLDIWoA4ckY6oYjMdGU67DWGuESs01TCehBWsN y3RJ9UE5UD8vJCJVfVljXDYYsfgoHxDlOUwLuuTaZvqH5hKldPQ4vx0cLVT/ON+oOI4p +WoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SeIissd9yu6sr1EpyUUZEaaK6kIza5Vpduyt6eMziNI=; b=iC0csU+vzL6Zrz6Xabn5Mah49L6UzaMq3Mq3rvAvEbSWg929r9tyQhRd2yalLzDCge geLVqMgGPSHIduaGBvWjJQl94T9h4oZKxubCg4I1gUQx2oQIINHN0RQ+lUdDI+Z+VPVP PHRWwkiBXGd4MqsRmK6L8esp5fgrxsalanVnrxlai4PGvnT5uci2D+574KQlVehOZq7J hLWH9syloVMz9i2fT/JZf3jzqS2C50Y0Z1RPjLcAMGP+Y+14kXGzjbxuFj/P9Et2UANr nKpJQ/Y6LDOuFLc7iEBhfnZiTnHUqTfNys3mXd4QAIPe/xVx8NdfYiRXsxOZCaRQkuI1 O8bQ== X-Gm-Message-State: AOAM532xcrCsU9Xc6HF+Pc2RSlTDg+r3iEslGoJjcan/nQBpitly+OXb WS1mVYMFFNlOIaQn7oikEw1QXaJX4CQqmg== X-Google-Smtp-Source: ABdhPJwRV772UJ8ajp/eClpFdzYMVrBYdN9H5bRXfu5bpDXUtNkyoj6ywVpX3VMheMJhohvLHaUOmA== X-Received: by 2002:a6b:760c:: with SMTP id g12mr13656908iom.27.1643714094213; Tue, 01 Feb 2022 03:14:54 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH 06/22] bsd-user/arm/target_arch_thread.h: Assume a FreeBSD target Date: Tue, 1 Feb 2022 04:14:39 -0700 Message-Id: <20220201111455.52511-7-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220201111455.52511-1-imp@bsdimp.com> References: <20220201111455.52511-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::d2e (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::d2e; envelope-from=imp@bsdimp.com; helo=mail-io1-xd2e.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , arrowd@FreeBSD.org, Kyle Evans , Richard Henderson , def@FreeBSD.org, jrtc27@FreeBSD.org, Warner Losh , Brad Smith Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1643715253419100001 Content-Type: text/plain; charset="utf-8" Since we can't run on anything else, assume for the moment that this is a FreeBSD target. In the future, we'll need to handle this properly via some include file in bsd-user/*bsd/arm/mumble.h. There's a number of other diffs that would be needed to make things work on OtherBSD, so it doesn't make sense to preseve this one detail today. Signed-off-by: Warner Losh Reviewed-by: Kyle Evans Reviewed-by: Richard Henderson --- bsd-user/arm/target_arch_thread.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/bsd-user/arm/target_arch_thread.h b/bsd-user/arm/target_arch_t= hread.h index 11c7f765838..fcafca2408c 100644 --- a/bsd-user/arm/target_arch_thread.h +++ b/bsd-user/arm/target_arch_thread.h @@ -62,9 +62,7 @@ static inline void target_thread_init(struct target_pt_re= gs *regs, } regs->ARM_pc =3D infop->entry & 0xfffffffe; regs->ARM_sp =3D stack; - if (bsd_type =3D=3D target_freebsd) { - regs->ARM_lr =3D infop->entry & 0xfffffffe; - } + regs->ARM_lr =3D infop->entry & 0xfffffffe; /* * FreeBSD kernel passes the ps_strings pointer in r0. This is used by= some * programs to set status messages that we see in ps. bsd-user doesn't --=20 2.33.1 From nobody Fri May 17 08:39:27 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1643714534777798.6034316740472; Tue, 1 Feb 2022 03:22:14 -0800 (PST) Received: from localhost ([::1]:36392 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nErEk-0008Rp-1c for importer@patchew.org; Tue, 01 Feb 2022 06:22:14 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56878) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nEr7n-0004vu-O8 for qemu-devel@nongnu.org; Tue, 01 Feb 2022 06:15:03 -0500 Received: from [2607:f8b0:4864:20::d2d] (port=34396 helo=mail-io1-xd2d.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nEr7k-0003XK-CI for qemu-devel@nongnu.org; Tue, 01 Feb 2022 06:15:03 -0500 Received: by mail-io1-xd2d.google.com with SMTP id i62so20729526ioa.1 for ; Tue, 01 Feb 2022 03:14:56 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id w5sm13526852ilu.83.2022.02.01.03.14.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Feb 2022 03:14:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=iheEFnm845woGCplflIornHtpf/6w+qx7f7V6lapN5M=; b=aqhMsiiQ/oOqRrbnZA02xIWkFzZAAa5Q/JHzfj8yZztIHnn6U0cDpp7giKOhjktXme GuUnq2Y/Kdz4P2Wt/7ugCYeKDNaAdzJ8xMKIk10/CZj9d+JlsasmJ0ove3VYjYb0ep3n 2ZJMgT5Lb9JUvfjZR/LbGB0+XzbJef3dHBF6cm7iB+M2yySXt01G9pXXsR/GoT0e0BBh MXArv801oC1Mdqi97z9DhbEAtYV+BMSQanD37CSY5qR/mOVij/7TfZnvPap2LyFQ3XSg 1URkxTysj4FqUjZkKX9vtT5nTfTGNyKWVr02xZe8fkWpcmxfu44OGbFdlsqCL3oxHPq1 4yOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=iheEFnm845woGCplflIornHtpf/6w+qx7f7V6lapN5M=; b=IKSY4UuGVn+gN+gAjsi+cX0cZf4Kv8mO3SDMainaEbkQTsUr4AoR2rf0hwxry49iag JtL8sR0O2mNxnyhAxnGkIEZ9cYK7MnJLPRClvkkOaJr35XVJXwC5xZH3yKJrC5H5cc8p szZ9ERzrQD8sPbBk9jHLyaGk3w94iGq08tSC+tXXVAI5ey0rtSXuQf+igHCg+2IwZ7/I mjrHZ+r3eAK+6yItUFUf0vZVsyTfCQDEZeN4ANaFdAjWn3mD8o8PBDtpkrtYtxjTt1gr miSmeMyBr61FERrT8MIiE8rZHZKAh3Yl2CeQgkTozSySppfEC+21CNYTVv2yEPE5ibUD K5Rg== X-Gm-Message-State: AOAM532Sbn5lTpAJ2aWIeZz4n/Wj1LJlc9ng0fUowNr2WNN0GBMjI19l X1BLj5BWb/9sOkUgzdad7VGHUoO0CV9TgA== X-Google-Smtp-Source: ABdhPJwiAj0b2ke46Cz39c3ids14KnovdI/bRXhHIjmofa3WRbvJeReHSx3DYuaUEY2YFpf1Z/IQ5g== X-Received: by 2002:a05:6602:2c8d:: with SMTP id i13mr13830320iow.181.1643714095303; Tue, 01 Feb 2022 03:14:55 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH 07/22] bsd-user/x86_64/target_arch_thread.h: Assume a FreeBSD target Date: Tue, 1 Feb 2022 04:14:40 -0700 Message-Id: <20220201111455.52511-8-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220201111455.52511-1-imp@bsdimp.com> References: <20220201111455.52511-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::d2d (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::d2d; envelope-from=imp@bsdimp.com; helo=mail-io1-xd2d.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , arrowd@FreeBSD.org, Kyle Evans , Richard Henderson , def@FreeBSD.org, jrtc27@FreeBSD.org, Warner Losh , Brad Smith Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1643714537863100003 Content-Type: text/plain; charset="utf-8" Since we can't run on anything else, assume for the moment that this is a FreeBSD target. In the future, we'll need to handle this properly via some include file in bsd-user/*bsd/x86_64/mumble.h. There's a number of other diffs that would be needed to make things work on OtherBSD, so it doesn't make sense to preseve this one detail today. Signed-off-by: Warner Losh Reviewed-by: Kyle Evans Reviewed-by: Richard Henderson --- bsd-user/x86_64/target_arch_thread.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/bsd-user/x86_64/target_arch_thread.h b/bsd-user/x86_64/target_= arch_thread.h index d105e43fd35..b745d7ffeb7 100644 --- a/bsd-user/x86_64/target_arch_thread.h +++ b/bsd-user/x86_64/target_arch_thread.h @@ -32,9 +32,7 @@ static inline void target_thread_init(struct target_pt_re= gs *regs, regs->rax =3D 0; regs->rsp =3D infop->start_stack; regs->rip =3D infop->entry; - if (bsd_type =3D=3D target_freebsd) { - regs->rdi =3D infop->start_stack; - } + regs->rdi =3D infop->start_stack; } =20 #endif /* !_TARGET_ARCH_THREAD_H_ */ --=20 2.33.1 From nobody Fri May 17 08:39:27 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1643714533207132.58492151587632; Tue, 1 Feb 2022 03:22:13 -0800 (PST) Received: from localhost ([::1]:36128 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nErEh-0008GG-Sj for importer@patchew.org; Tue, 01 Feb 2022 06:22:11 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56834) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nEr7m-0004sC-9g for qemu-devel@nongnu.org; Tue, 01 Feb 2022 06:15:02 -0500 Received: from [2607:f8b0:4864:20::12a] (port=38664 helo=mail-il1-x12a.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nEr7k-0003XQ-6j for qemu-devel@nongnu.org; Tue, 01 Feb 2022 06:15:01 -0500 Received: by mail-il1-x12a.google.com with SMTP id i1so13977529ils.5 for ; Tue, 01 Feb 2022 03:14:57 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id w5sm13526852ilu.83.2022.02.01.03.14.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Feb 2022 03:14:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4kADzTN0Wer67ApqMOj+RmImF1jg1CJ8Ks/jZVYJzOM=; b=RLzhsyBwgZPNo0G4sAGZ5ac2WuVtnyb8W2jy9gcjIoN6l+KLgTQQbar6LRliXrmw1R Ma/n9bqaPdEaOo6xzXnpq+E6eRywGT8nRtubGszR8JFePwXDnULs+PODkAHLlRSdcXPh fqk3sLIDQOVaBZmVIyXIGDcSF0o5DlMN36kX3+vxbHe0Dra3Rq0tpuDJaeZPD1vtEHYm gWr1YFcrPd5MqQFK5QlFTvNflcfJjwj4WNwWt371teDbhyyTWLQHHJUT064eHVXfBDAx EnsTGt7kAwTXG2tkGfD6vephUI7Uh1D9nmwKvoHo9Ix0qIipWGSoHN3Op++8ZTAlCB42 d1fg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4kADzTN0Wer67ApqMOj+RmImF1jg1CJ8Ks/jZVYJzOM=; b=i0KnHEMzjIQvvgTUcHrR1JTT7qVwXPA+HwEo9NLLX+zgRsXjfZE6TEHVKl7ofculhk 7pbFXTkc57nyrTBWx+bvVjUYg49sBlvzFhl2I5QksuTpgeZFp2a03lcVkvQVM6uZ6Hwm i9EDMwcqKpP03xSGV9p6oaXV6acHNqIebJHhh13dHcyADhLxaCfjqXWq99/4H486cqpC Bv8+spT/YaVkvGLo6GVaACJs3vvzFFWZM1PeFkOoDBzrfaEdJ7oJBp49KvGsoh3bYbw6 huFxWq9/3vHGx8YrQWZsdYoadkih39lS5ocrsvoDDheVKIhck25WhYtzTcRFoyQCPg5X TXoQ== X-Gm-Message-State: AOAM531Cd3AuZGONBLGIu7yjnYjaNBVhjU96G2xaKw/feOPj1zprHQU+ Ysl0Q1u5BZStx3kjWbfAc5Z6n4fX0cnpXA== X-Google-Smtp-Source: ABdhPJxK6qLLkJj5GNrGpHLOIAv7e/38sEYxWdfLPf/ErrqegGVTz5k9jXvlNBnTxCw25yJei9lH3g== X-Received: by 2002:a05:6e02:1aaf:: with SMTP id l15mr14127213ilv.31.1643714096235; Tue, 01 Feb 2022 03:14:56 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH 08/22] bsd-user: Remove bsd_type Date: Tue, 1 Feb 2022 04:14:41 -0700 Message-Id: <20220201111455.52511-9-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220201111455.52511-1-imp@bsdimp.com> References: <20220201111455.52511-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::12a (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::12a; envelope-from=imp@bsdimp.com; helo=mail-il1-x12a.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , arrowd@FreeBSD.org, Kyle Evans , Richard Henderson , def@FreeBSD.org, jrtc27@FreeBSD.org, Warner Losh , Brad Smith Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1643714536026100001 Content-Type: text/plain; charset="utf-8" Remove keeping track of which type of bsd we're running on. It's no longer referenced in the code. Building bsd-user on NetBSD or OpenBSD isn't possible, let alone running that code. Stop pretending that we can do the cross BSD thing since there's been a large divergence since 2000 that makes this nearly impossible between FreeBSD and {Net,Open}BSD and at least quite difficult between NetBSD and OpenBSD. Signed-off-by: Warner Losh Reviewed-by: Kyle Evans Reviewed-by: Richard Henderson --- bsd-user/main.c | 2 -- bsd-user/qemu.h | 7 ------- 2 files changed, 9 deletions(-) diff --git a/bsd-user/main.c b/bsd-user/main.c index bddb830e99b..88d347d05eb 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -96,7 +96,6 @@ unsigned long reserved_va; =20 static const char *interp_prefix =3D CONFIG_QEMU_INTERP_PREFIX; const char *qemu_uname_release; -enum BSDType bsd_type; char qemu_proc_pathname[PATH_MAX]; /* full path to exeutable */ =20 unsigned long target_maxtsiz =3D TARGET_MAXTSIZ; /* max text size */ @@ -284,7 +283,6 @@ int main(int argc, char **argv) const char *gdbstub =3D NULL; char **target_environ, **wrk; envlist_t *envlist =3D NULL; - bsd_type =3D HOST_DEFAULT_BSD_TYPE; char *argv0 =3D NULL; =20 adjust_ssize(); diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h index 02921ac8b3b..e5742bd6c03 100644 --- a/bsd-user/qemu.h +++ b/bsd-user/qemu.h @@ -29,13 +29,6 @@ =20 extern char **environ; =20 -enum BSDType { - target_freebsd, - target_netbsd, - target_openbsd, -}; -extern enum BSDType bsd_type; - #include "exec/user/thunk.h" #include "target_arch.h" #include "syscall_defs.h" --=20 2.33.1 From nobody Fri May 17 08:39:27 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1643715549087428.37133513011224; Tue, 1 Feb 2022 03:39:09 -0800 (PST) Received: from localhost ([::1]:40750 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nErV6-0005pt-4t for importer@patchew.org; Tue, 01 Feb 2022 06:39:08 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56966) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nEr7p-00051z-FF for qemu-devel@nongnu.org; Tue, 01 Feb 2022 06:15:05 -0500 Received: from [2607:f8b0:4864:20::d2c] (port=33295 helo=mail-io1-xd2c.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nEr7k-0003XX-8g for qemu-devel@nongnu.org; Tue, 01 Feb 2022 06:15:04 -0500 Received: by mail-io1-xd2c.google.com with SMTP id y84so20788426iof.0 for ; Tue, 01 Feb 2022 03:14:58 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id w5sm13526852ilu.83.2022.02.01.03.14.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Feb 2022 03:14:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=YZBADdyHloLLRfcWgOJjkztwEPB9T1oDoqbT7HXyib0=; b=mU1ejld1xxXUtkJeelptK0Cr2z2QDG7Wr3A4VfaChef1CumnChhZWEV06ztB2139ZV nx0+gmP8Wd1T4Pr6eBs/eQevYJT2Q/+fhnT8b9tGOcQANpr0qkLCLBF97ctAs9nz4ttn us22MFGSIPKcrFmBnxHao3Oz0QWUYR1fbA9XtigMZSrlaC884GNht03VDMVBUhQOr+8T OiqYNSKkAE0M5GqiRSfFxf8Ng/XQSq75jGKB69Ubtn3IG0KNnsVkLfGsCoM8+ZLjMN8f J3CD3YB2/X7pM6G0XyvndnGpCjd6qpd6H6WaY+c/sh383TpjKx6Ymv6SozBmY+UVLXGg boZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=YZBADdyHloLLRfcWgOJjkztwEPB9T1oDoqbT7HXyib0=; b=mHBeyCIrv/TIVnLcGELHwqDNQfMpMWZZICkr4vuq5NTB8AoZE0H48/z3MlIvopUzPL /qxU+s0wDc0dUm3u3Ynk7DogqRu572PH9iXyjvW4aNefNpWhs+JiAH7MB0hBVTQLh11i cvsntdn8RBv9SMtvNIpEsbReMNDl0jfwSmMaYClrqQAeBN5VvWvXLVoUS84QaBaHpZVJ Yl6Qo3rN66zyJBLglimmIm9nZPMITF0QcvcnmwWg9L64NNCHRXubq4klkq6FSOctkSt7 7MCiu16/H1L6w/4AvKbEAG6zGjV0hdE9NrO49Firgv3V/bijQNEqzrtnLOWCNWHocu/y 5xpg== X-Gm-Message-State: AOAM533g0s3cUT4FYQLhLyrHSKtlYkJXg82LzyaAQDx8dvaNrLWjmhOe 70doJhPN8dudV8iVRueXYGV1qAeaAtYTcA== X-Google-Smtp-Source: ABdhPJyrLD3PP6MNOZ8O2ucU+KBotyJRgAXa299Hpnw67j76XAYGKjyoLxVUZjVLgtmXn24ikDwQlA== X-Received: by 2002:a05:6602:2d4b:: with SMTP id d11mr13024625iow.50.1643714097019; Tue, 01 Feb 2022 03:14:57 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH 09/22] bsd-user/freebsd/os-syscall.c: Move syscall processing here Date: Tue, 1 Feb 2022 04:14:42 -0700 Message-Id: <20220201111455.52511-10-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220201111455.52511-1-imp@bsdimp.com> References: <20220201111455.52511-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::d2c (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::d2c; envelope-from=imp@bsdimp.com; helo=mail-io1-xd2c.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , arrowd@FreeBSD.org, Kyle Evans , Richard Henderson , def@FreeBSD.org, jrtc27@FreeBSD.org, Warner Losh , Brad Smith Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1643715552446100001 Content-Type: text/plain; charset="utf-8" While there is some commonality between *BSD syscall processing, there's a number of differences and the system call numbers and ABIs have been independent since the late 90s. Move FreeBSD's proessing here and delete it. The upstream implementation is somewhat different than the current implementation. It will be much easier to upstream these from scratch, justifying the final result, rather than working out the diffs and justifying the changes. Also tweak a comment to qemu standard form. Signed-off-by: Warner Losh Reviewed-by: Kyle Evans Reviewed-by: Richard Henderson --- bsd-user/freebsd/os-syscall.c | 68 +++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 bsd-user/freebsd/os-syscall.c diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c new file mode 100644 index 00000000000..7e2bedb918d --- /dev/null +++ b/bsd-user/freebsd/os-syscall.c @@ -0,0 +1,68 @@ +/* + * BSD syscalls + * + * Copyright (c) 2003-2008 Fabrice Bellard + * Copyright (c) 2013-2014 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 . + */ + +/* + * We need the FreeBSD "legacy" definitions. Rust needs the FreeBSD 11 sys= tem + * calls, so we have to emulate that despite FreeBSD being EOL'd. + */ +#define _WANT_FREEBSD11_STAT +#define _WANT_FREEBSD11_STATFS +#define _WANT_FREEBSD11_DIRENT +#define _WANT_KERNEL_ERRNO +#define _WANT_SEMUN +#include "qemu/osdep.h" +#include "qemu/cutils.h" +#include "qemu/path.h" +#include +#include +#include +#include + +#include "qemu.h" +#include "qemu-common.h" +#include "signal-common.h" +#include "user/syscall-trace.h" + +void target_set_brk(abi_ulong new_brk) +{ +} + +bool is_error(abi_long ret) +{ + + return (abi_ulong)ret >=3D (abi_ulong)(-4096); +} + +/* + * do_syscall() should always have a single exit point at the end so that + * actions, such as logging of syscall results, can be performed. All err= nos + * that do_syscall() returns must be -TARGET_. + */ +abi_long do_freebsd_syscall(void *cpu_env, int num, abi_long arg1, + abi_long arg2, abi_long arg3, abi_long arg4, + abi_long arg5, abi_long arg6, abi_long arg7, + abi_long arg8) +{ + return 0; +} + +void syscall_init(void) +{ +} --=20 2.33.1 From nobody Fri May 17 08:39:27 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1643715587615593.1438661036088; Tue, 1 Feb 2022 03:39:47 -0800 (PST) Received: from localhost ([::1]:43368 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nErVi-0007cM-So for importer@patchew.org; Tue, 01 Feb 2022 06:39:46 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56872) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nEr7n-0004vS-Mg for qemu-devel@nongnu.org; Tue, 01 Feb 2022 06:15:03 -0500 Received: from [2607:f8b0:4864:20::134] (port=46841 helo=mail-il1-x134.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nEr7k-0003Xb-5v for qemu-devel@nongnu.org; Tue, 01 Feb 2022 06:15:03 -0500 Received: by mail-il1-x134.google.com with SMTP id e8so13933743ilm.13 for ; Tue, 01 Feb 2022 03:14:58 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id w5sm13526852ilu.83.2022.02.01.03.14.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Feb 2022 03:14:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=crCQBRHKtRPhHypZONQxqwtL7agng1pX4NR7iXT9wi4=; b=bDfo2sfWH51d0uVlrG1INGyOIQbThfcLsJexG1mNSBPiNFpogPV/1ARESd8/amK0Jm PL9RsDpsHhSgBfvy/Ne9Vht/Sum24vzljt23Vjs9vsShoPHkrgzQ3ugsNsTvhEVAHHrz 0ooIfFaWRS1jgLNTlmRt7wdcdwUlKvUhktl2svKwdDkk4ug+gN1UdTerSn+Ky4GzvVuo G1A2F7T4098RTZnbY+lM7H+a+54NxwwSLSu9Ca+GYDpaheEJ5QK+HH6FRtiA44jSKHGk st+/Uoll+47GGGU66G+wWGRhaHSu4C5rWifcy5RRC6ihuZ/47wn00YKQVNmPJ3oHU4az Njig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=crCQBRHKtRPhHypZONQxqwtL7agng1pX4NR7iXT9wi4=; b=2+B3iIlygH0lPD42t2BJDALmx3ayWlaukEYztqx7NspP8wXPL2zFrYm+RQpEmDb3B0 yBLQMMgymRBPDcfbxcC5n/OUeV7KZqEAePjYqq6dZ5SHuJZzzqXylxu2Vew08GvsfOMO INsxt0AU2X0m1lF3jozuBRWmlHeNOgvPhnFIi0zTZJFB3vmnpkD3HZQPZMsEVZ8oMlFZ gHrlMdGu04hP+wacIrQa4p+u3Hf70/X7EBherHRYhERLsDbpViVN2SxsI6TR4wMBS3sG I92z1QgY1+F6cTYV5MgCo27klf1OJEq6X79m6CVbu4pGbJ8eY3FgjVO78p2k0tCV5KM/ TWoA== X-Gm-Message-State: AOAM530eG+XRX3DASjUxeiOWzis2yySY8+DhBNCpXWRekmEbMZzEZAQn Tu+2tiLDc83BdXOhVYAU9fmN3SDJdeCd8Q== X-Google-Smtp-Source: ABdhPJwhut4/Qvkszv+P4gONaXvzcYSggISdxoqVkmsFtOldyevK1yKP/maeAA/FSgT8eUeqVv62gw== X-Received: by 2002:a05:6e02:15c2:: with SMTP id q2mr8570577ilu.226.1643714098037; Tue, 01 Feb 2022 03:14:58 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH 10/22] bsd-user: Move system call building to os-syscall.c Date: Tue, 1 Feb 2022 04:14:43 -0700 Message-Id: <20220201111455.52511-11-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220201111455.52511-1-imp@bsdimp.com> References: <20220201111455.52511-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::134 (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::134; envelope-from=imp@bsdimp.com; helo=mail-il1-x134.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , arrowd@FreeBSD.org, Kyle Evans , Richard Henderson , def@FreeBSD.org, jrtc27@FreeBSD.org, Warner Losh , Brad Smith Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1643715590063100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Warner Losh Reviewed-by: Richard Henderson --- bsd-user/freebsd/meson.build | 1 + bsd-user/meson.build | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/bsd-user/freebsd/meson.build b/bsd-user/freebsd/meson.build index 4b69cca7b90..f87c788e846 100644 --- a/bsd-user/freebsd/meson.build +++ b/bsd-user/freebsd/meson.build @@ -1,3 +1,4 @@ bsd_user_ss.add(files( 'os-sys.c', + 'os-syscall.c', )) diff --git a/bsd-user/meson.build b/bsd-user/meson.build index 8380fa44c25..5243122fc56 100644 --- a/bsd-user/meson.build +++ b/bsd-user/meson.build @@ -13,7 +13,6 @@ bsd_user_ss.add(files( 'mmap.c', 'signal.c', 'strace.c', - 'syscall.c', 'uaccess.c', )) =20 --=20 2.33.1 From nobody Fri May 17 08:39:27 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 164371616612436.41114200785; Tue, 1 Feb 2022 03:49:26 -0800 (PST) Received: from localhost ([::1]:60590 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nErf3-0002j0-E7 for importer@patchew.org; Tue, 01 Feb 2022 06:49:25 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57056) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nEr7r-00059Z-E8 for qemu-devel@nongnu.org; Tue, 01 Feb 2022 06:15:07 -0500 Received: from [2607:f8b0:4864:20::132] (port=44717 helo=mail-il1-x132.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nEr7k-0003Xh-Jv for qemu-devel@nongnu.org; Tue, 01 Feb 2022 06:15:07 -0500 Received: by mail-il1-x132.google.com with SMTP id q11so5790105ild.11 for ; Tue, 01 Feb 2022 03:15:00 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id w5sm13526852ilu.83.2022.02.01.03.14.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Feb 2022 03:14:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=i4PuvmG6XbgqVm3HYX5MDKxBDqU6opCIfs+aK+MD+Fk=; b=kOpk/fxx9083CeKHzwW44hvQ4f/FpeObq04V08iJMgt1XX+P/203wPcIZNE4cQSc89 SnBST5LXirts7gkZkWeXU2xJ7fvpHDUDBJc3sU71LN+BRWbm2rxNd6BnKbp52cp8vzoC 7O2UMPtgtD3XLq4HJIvhXZPyq4Zvc84MJHdQxmjYIoZwCdV2uUZedWYtXaOv6Ykhk1JL 8nxj1HGb4zbz3XZuwR1qZaLwYKHd6Zfeughj/gZva1eEmyqrFzUfPnVEG3kn2igziIoJ kV6dIPvyP3xk5EcxAC0cnPW0n5fLPoHmea2tx2vzkpOca7asScT3LOZlt0Ex8b2z77xa T+yA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=i4PuvmG6XbgqVm3HYX5MDKxBDqU6opCIfs+aK+MD+Fk=; b=LwZmUbuVBEerGd3iZPAqHlt8GnlbjGU71mpGsG38ioCoMZn9oRj1u64h6eA2/VjER+ aC+J25O49mQVFT/Ddo3NcoHwfA+usQBJOj44/dLzEY1efW9LJ2s5f51zKANbEI4Egoyr j7zEqBXVwOpByvMlqrkM9y5hTrdurLKlkpbOUFO76sz1fLTVH7SIJ4TKidg8mLFGIs0l jeDJCcpl4IfF4sCNZbmzy/HB7JkwvJR4ozJUa5BXFGu8JvmPCmsGTxRyhcW2DywO84UY yqkVYbSwPm2khToXN9jhkdRgDo6GlQ484ekmOLLFit7SMO2eSKo8AdOoGiUFj23onwI9 abMg== X-Gm-Message-State: AOAM530uVaUvQIymyoF5QyPhQWhMPuwg93T+s6YRZcf3aoKTE4h85ear bZvfWRF5jvp0yVZ80njaTmHTg4l6Gh7tsg== X-Google-Smtp-Source: ABdhPJzPVec9/Znro/URJtSH6OV7VV2yko1gipYkvT7dvEJ+U9A3xLOKLeofKHfIenHriEQItFT2vw== X-Received: by 2002:a92:b50d:: with SMTP id f13mr15159582ile.80.1643714098983; Tue, 01 Feb 2022 03:14:58 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH 11/22] bsd-user/sycall.c: Now obsolete, remove Date: Tue, 1 Feb 2022 04:14:44 -0700 Message-Id: <20220201111455.52511-12-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220201111455.52511-1-imp@bsdimp.com> References: <20220201111455.52511-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::132 (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::132; envelope-from=imp@bsdimp.com; helo=mail-il1-x132.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , arrowd@FreeBSD.org, Kyle Evans , Richard Henderson , def@FreeBSD.org, jrtc27@FreeBSD.org, Warner Losh , Brad Smith Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1643716168895100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Warner Losh Reviewed-by: Kyle Evans Reviewed-by: Richard Henderson --- bsd-user/syscall.c | 516 --------------------------------------------- 1 file changed, 516 deletions(-) delete mode 100644 bsd-user/syscall.c diff --git a/bsd-user/syscall.c b/bsd-user/syscall.c deleted file mode 100644 index d3322760f43..00000000000 --- a/bsd-user/syscall.c +++ /dev/null @@ -1,516 +0,0 @@ -/* - * BSD syscalls - * - * Copyright (c) 2003 - 2008 Fabrice Bellard - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - */ -#include "qemu/osdep.h" -#include "qemu/cutils.h" -#include "qemu/path.h" -#include -#include -#include -#include - -#include "qemu.h" -#include "qemu-common.h" -#include "user/syscall-trace.h" - -//#define DEBUG - -static abi_ulong target_brk; -static abi_ulong target_original_brk; - -abi_long get_errno(abi_long ret) -{ - if (ret =3D=3D -1) { - /* XXX need to translate host -> target errnos here */ - return -(errno); - } - return ret; -} - -#define target_to_host_bitmask(x, tbl) (x) - -bool is_error(abi_long ret) -{ - return (abi_ulong)ret >=3D (abi_ulong)(-4096); -} - -void target_set_brk(abi_ulong new_brk) -{ - target_original_brk =3D target_brk =3D HOST_PAGE_ALIGN(new_brk); -} - -/* do_obreak() must return target errnos. */ -static abi_long do_obreak(abi_ulong new_brk) -{ - abi_ulong brk_page; - abi_long mapped_addr; - int new_alloc_size; - - if (!new_brk) - return 0; - if (new_brk < target_original_brk) - return -TARGET_EINVAL; - - brk_page =3D HOST_PAGE_ALIGN(target_brk); - - /* If the new brk is less than this, set it and we're done... */ - if (new_brk < brk_page) { - target_brk =3D new_brk; - return 0; - } - - /* We need to allocate more memory after the brk... */ - new_alloc_size =3D HOST_PAGE_ALIGN(new_brk - brk_page + 1); - mapped_addr =3D get_errno(target_mmap(brk_page, new_alloc_size, - PROT_READ|PROT_WRITE, - MAP_ANON|MAP_FIXED|MAP_PRIVATE, -1= , 0)); - - if (!is_error(mapped_addr)) - target_brk =3D new_brk; - else - return mapped_addr; - - return 0; -} - -#ifdef __FreeBSD__ -/* - * XXX this uses the undocumented oidfmt interface to find the kind of - * a requested sysctl, see /sys/kern/kern_sysctl.c:sysctl_sysctl_oidfmt() - * (this is mostly copied from src/sbin/sysctl/sysctl.c) - */ -static int -oidfmt(int *oid, int len, char *fmt, uint32_t *kind) -{ - int qoid[CTL_MAXNAME+2]; - uint8_t buf[BUFSIZ]; - int i; - size_t j; - - qoid[0] =3D 0; - qoid[1] =3D 4; - memcpy(qoid + 2, oid, len * sizeof(int)); - - j =3D sizeof(buf); - i =3D sysctl(qoid, len + 2, buf, &j, 0, 0); - if (i) - return i; - - if (kind) - *kind =3D *(uint32_t *)buf; - - if (fmt) - strcpy(fmt, (char *)(buf + sizeof(uint32_t))); - return (0); -} - -/* - * try and convert sysctl return data for the target. - * XXX doesn't handle CTLTYPE_OPAQUE and CTLTYPE_STRUCT. - */ -static int sysctl_oldcvt(void *holdp, size_t holdlen, uint32_t kind) -{ - switch (kind & CTLTYPE) { - case CTLTYPE_INT: - case CTLTYPE_UINT: - *(uint32_t *)holdp =3D tswap32(*(uint32_t *)holdp); - break; -#ifdef TARGET_ABI32 - case CTLTYPE_LONG: - case CTLTYPE_ULONG: - *(uint32_t *)holdp =3D tswap32(*(long *)holdp); - break; -#else - case CTLTYPE_LONG: - *(uint64_t *)holdp =3D tswap64(*(long *)holdp); - break; - case CTLTYPE_ULONG: - *(uint64_t *)holdp =3D tswap64(*(unsigned long *)holdp); - break; -#endif -#ifdef CTLTYPE_U64 - case CTLTYPE_S64: - case CTLTYPE_U64: -#else - case CTLTYPE_QUAD: -#endif - *(uint64_t *)holdp =3D tswap64(*(uint64_t *)holdp); - break; - case CTLTYPE_STRING: - break; - default: - /* XXX unhandled */ - return -1; - } - return 0; -} - -/* XXX this needs to be emulated on non-FreeBSD hosts... */ -static abi_long do_freebsd_sysctl(abi_ulong namep, int32_t namelen, abi_ul= ong oldp, - abi_ulong oldlenp, abi_ulong newp, abi_ulong new= len) -{ - abi_long ret; - void *hnamep, *holdp, *hnewp =3D NULL; - size_t holdlen; - abi_ulong oldlen =3D 0; - int32_t *snamep =3D g_malloc(sizeof(int32_t) * namelen), *p, *q, i; - uint32_t kind =3D 0; - - if (oldlenp) - get_user_ual(oldlen, oldlenp); - if (!(hnamep =3D lock_user(VERIFY_READ, namep, namelen, 1))) - return -TARGET_EFAULT; - if (newp && !(hnewp =3D lock_user(VERIFY_READ, newp, newlen, 1))) - return -TARGET_EFAULT; - if (!(holdp =3D lock_user(VERIFY_WRITE, oldp, oldlen, 0))) - return -TARGET_EFAULT; - holdlen =3D oldlen; - for (p =3D hnamep, q =3D snamep, i =3D 0; i < namelen; p++, i++) - *q++ =3D tswap32(*p); - oidfmt(snamep, namelen, NULL, &kind); - /* XXX swap hnewp */ - ret =3D get_errno(sysctl(snamep, namelen, holdp, &holdlen, hnewp, newl= en)); - if (!ret) - sysctl_oldcvt(holdp, holdlen, kind); - put_user_ual(holdlen, oldlenp); - unlock_user(hnamep, namep, 0); - unlock_user(holdp, oldp, holdlen); - if (hnewp) - unlock_user(hnewp, newp, 0); - g_free(snamep); - return ret; -} -#endif - -/* FIXME - * lock_iovec()/unlock_iovec() have a return code of 0 for success where - * other lock functions have a return code of 0 for failure. - */ -static abi_long lock_iovec(int type, struct iovec *vec, abi_ulong target_a= ddr, - int count, int copy) -{ - struct target_iovec *target_vec; - abi_ulong base; - int i; - - target_vec =3D lock_user(VERIFY_READ, target_addr, count * sizeof(stru= ct target_iovec), 1); - if (!target_vec) - return -TARGET_EFAULT; - for (i =3D 0;i < count; i++) { - base =3D tswapl(target_vec[i].iov_base); - vec[i].iov_len =3D tswapl(target_vec[i].iov_len); - if (vec[i].iov_len !=3D 0) { - vec[i].iov_base =3D lock_user(type, base, vec[i].iov_len, copy= ); - /* Don't check lock_user return value. We must call writev even - if a element has invalid base address. */ - } else { - /* zero length pointer is ignored */ - vec[i].iov_base =3D NULL; - } - } - unlock_user (target_vec, target_addr, 0); - return 0; -} - -static abi_long unlock_iovec(struct iovec *vec, abi_ulong target_addr, - int count, int copy) -{ - struct target_iovec *target_vec; - abi_ulong base; - int i; - - target_vec =3D lock_user(VERIFY_READ, target_addr, count * sizeof(stru= ct target_iovec), 1); - if (!target_vec) - return -TARGET_EFAULT; - for (i =3D 0;i < count; i++) { - if (target_vec[i].iov_base) { - base =3D tswapl(target_vec[i].iov_base); - unlock_user(vec[i].iov_base, base, copy ? vec[i].iov_len : 0); - } - } - unlock_user (target_vec, target_addr, 0); - - return 0; -} - -/* do_syscall() should always have a single exit point at the end so - that actions, such as logging of syscall results, can be performed. - All errnos that do_syscall() returns must be -TARGET_. */ -abi_long do_freebsd_syscall(void *cpu_env, int num, abi_long arg1, - abi_long arg2, abi_long arg3, abi_long arg4, - abi_long arg5, abi_long arg6, abi_long arg7, - abi_long arg8) -{ - CPUState *cpu =3D env_cpu(cpu_env); - abi_long ret; - void *p; - -#ifdef DEBUG - gemu_log("freebsd syscall %d\n", num); -#endif - record_syscall_start(cpu, num, arg1, arg2, arg3, arg4, arg5, arg6, 0, = 0); - - if (do_strace) - print_freebsd_syscall(num, arg1, arg2, arg3, arg4, arg5, arg6); - - switch (num) { - case TARGET_FREEBSD_NR_exit: -#ifdef CONFIG_GPROF - _mcleanup(); -#endif - gdb_exit(arg1); - qemu_plugin_user_exit(); - /* XXX: should free thread stack and CPU env */ - _exit(arg1); - ret =3D 0; /* avoid warning */ - break; - case TARGET_FREEBSD_NR_read: - if (!(p =3D lock_user(VERIFY_WRITE, arg2, arg3, 0))) - goto efault; - ret =3D get_errno(read(arg1, p, arg3)); - unlock_user(p, arg2, ret); - break; - case TARGET_FREEBSD_NR_write: - if (!(p =3D lock_user(VERIFY_READ, arg2, arg3, 1))) - goto efault; - ret =3D get_errno(write(arg1, p, arg3)); - unlock_user(p, arg2, 0); - break; - case TARGET_FREEBSD_NR_writev: - { - int count =3D arg3; - struct iovec *vec; - - vec =3D alloca(count * sizeof(struct iovec)); - if (lock_iovec(VERIFY_READ, vec, arg2, count, 1) < 0) - goto efault; - ret =3D get_errno(writev(arg1, vec, count)); - unlock_iovec(vec, arg2, count, 0); - } - break; - case TARGET_FREEBSD_NR_open: - if (!(p =3D lock_user_string(arg1))) - goto efault; - ret =3D get_errno(open(path(p), - target_to_host_bitmask(arg2, fcntl_flags_tbl), - arg3)); - unlock_user(p, arg1, 0); - break; - case TARGET_FREEBSD_NR_mmap: - ret =3D get_errno(target_mmap(arg1, arg2, arg3, - target_to_host_bitmask(arg4, mmap_flag= s_tbl), - arg5, - arg6)); - break; - case TARGET_FREEBSD_NR_mprotect: - ret =3D get_errno(target_mprotect(arg1, arg2, arg3)); - break; - case TARGET_FREEBSD_NR_break: - ret =3D do_obreak(arg1); - break; -#ifdef __FreeBSD__ - case TARGET_FREEBSD_NR___sysctl: - ret =3D do_freebsd_sysctl(arg1, arg2, arg3, arg4, arg5, arg6); - break; -#endif - case TARGET_FREEBSD_NR_sysarch: - ret =3D do_freebsd_sysarch(cpu_env, arg1, arg2); - break; - case TARGET_FREEBSD_NR_syscall: - case TARGET_FREEBSD_NR___syscall: - ret =3D do_freebsd_syscall(cpu_env,arg1 & 0xffff,arg2,arg3,arg4,ar= g5,arg6,arg7,arg8,0); - break; - default: - ret =3D get_errno(syscall(num, arg1, arg2, arg3, arg4, arg5, arg6,= arg7, arg8)); - break; - } - fail: -#ifdef DEBUG - gemu_log(" =3D %ld\n", ret); -#endif - if (do_strace) - print_freebsd_syscall_ret(num, ret); - - record_syscall_return(cpu, num, ret); - return ret; - efault: - ret =3D -TARGET_EFAULT; - goto fail; -} - -abi_long do_netbsd_syscall(void *cpu_env, int num, abi_long arg1, - abi_long arg2, abi_long arg3, abi_long arg4, - abi_long arg5, abi_long arg6) -{ - CPUState *cpu =3D env_cpu(cpu_env); - abi_long ret; - void *p; - -#ifdef DEBUG - gemu_log("netbsd syscall %d\n", num); -#endif - - record_syscall_start(cpu, num, arg1, arg2, arg3, arg4, arg5, arg6, 0, = 0); - - if (do_strace) - print_netbsd_syscall(num, arg1, arg2, arg3, arg4, arg5, arg6); - - switch (num) { - case TARGET_NETBSD_NR_exit: -#ifdef CONFIG_GPROF - _mcleanup(); -#endif - gdb_exit(arg1); - qemu_plugin_user_exit(); - /* XXX: should free thread stack and CPU env */ - _exit(arg1); - ret =3D 0; /* avoid warning */ - break; - case TARGET_NETBSD_NR_read: - if (!(p =3D lock_user(VERIFY_WRITE, arg2, arg3, 0))) - goto efault; - ret =3D get_errno(read(arg1, p, arg3)); - unlock_user(p, arg2, ret); - break; - case TARGET_NETBSD_NR_write: - if (!(p =3D lock_user(VERIFY_READ, arg2, arg3, 1))) - goto efault; - ret =3D get_errno(write(arg1, p, arg3)); - unlock_user(p, arg2, 0); - break; - case TARGET_NETBSD_NR_open: - if (!(p =3D lock_user_string(arg1))) - goto efault; - ret =3D get_errno(open(path(p), - target_to_host_bitmask(arg2, fcntl_flags_tbl), - arg3)); - unlock_user(p, arg1, 0); - break; - case TARGET_NETBSD_NR_mmap: - ret =3D get_errno(target_mmap(arg1, arg2, arg3, - target_to_host_bitmask(arg4, mmap_flag= s_tbl), - arg5, - arg6)); - break; - case TARGET_NETBSD_NR_mprotect: - ret =3D get_errno(target_mprotect(arg1, arg2, arg3)); - break; - case TARGET_NETBSD_NR_syscall: - case TARGET_NETBSD_NR___syscall: - ret =3D do_netbsd_syscall(cpu_env,arg1 & 0xffff,arg2,arg3,arg4,arg= 5,arg6,0); - break; - default: - ret =3D syscall(num, arg1, arg2, arg3, arg4, arg5, arg6); - break; - } - fail: -#ifdef DEBUG - gemu_log(" =3D %ld\n", ret); -#endif - if (do_strace) - print_netbsd_syscall_ret(num, ret); - - record_syscall_return(cpu, num, ret); - return ret; - efault: - ret =3D -TARGET_EFAULT; - goto fail; -} - -abi_long do_openbsd_syscall(void *cpu_env, int num, abi_long arg1, - abi_long arg2, abi_long arg3, abi_long arg4, - abi_long arg5, abi_long arg6) -{ - CPUState *cpu =3D env_cpu(cpu_env); - abi_long ret; - void *p; - -#ifdef DEBUG - gemu_log("openbsd syscall %d\n", num); -#endif - - record_syscall_start(cpu, num, arg1, arg2, arg3, arg4, arg5, arg6, 0, = 0); - - if (do_strace) - print_openbsd_syscall(num, arg1, arg2, arg3, arg4, arg5, arg6); - - switch (num) { - case TARGET_OPENBSD_NR_exit: -#ifdef CONFIG_GPROF - _mcleanup(); -#endif - gdb_exit(arg1); - qemu_plugin_user_exit(); - /* XXX: should free thread stack and CPU env */ - _exit(arg1); - ret =3D 0; /* avoid warning */ - break; - case TARGET_OPENBSD_NR_read: - if (!(p =3D lock_user(VERIFY_WRITE, arg2, arg3, 0))) - goto efault; - ret =3D get_errno(read(arg1, p, arg3)); - unlock_user(p, arg2, ret); - break; - case TARGET_OPENBSD_NR_write: - if (!(p =3D lock_user(VERIFY_READ, arg2, arg3, 1))) - goto efault; - ret =3D get_errno(write(arg1, p, arg3)); - unlock_user(p, arg2, 0); - break; - case TARGET_OPENBSD_NR_open: - if (!(p =3D lock_user_string(arg1))) - goto efault; - ret =3D get_errno(open(path(p), - target_to_host_bitmask(arg2, fcntl_flags_tbl), - arg3)); - unlock_user(p, arg1, 0); - break; - case TARGET_OPENBSD_NR_mmap: - ret =3D get_errno(target_mmap(arg1, arg2, arg3, - target_to_host_bitmask(arg4, mmap_flag= s_tbl), - arg5, - arg6)); - break; - case TARGET_OPENBSD_NR_mprotect: - ret =3D get_errno(target_mprotect(arg1, arg2, arg3)); - break; - case TARGET_OPENBSD_NR_syscall: - case TARGET_OPENBSD_NR___syscall: - ret =3D do_openbsd_syscall(cpu_env,arg1 & 0xffff,arg2,arg3,arg4,ar= g5,arg6,0); - break; - default: - ret =3D syscall(num, arg1, arg2, arg3, arg4, arg5, arg6); - break; - } - fail: -#ifdef DEBUG - gemu_log(" =3D %ld\n", ret); -#endif - if (do_strace) - print_openbsd_syscall_ret(num, ret); - - record_syscall_return(cpu, num, ret); - return ret; - efault: - ret =3D -TARGET_EFAULT; - goto fail; -} - -void syscall_init(void) -{ -} --=20 2.33.1 From nobody Fri May 17 08:39:27 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1643716512961716.208752706131; Tue, 1 Feb 2022 03:55:12 -0800 (PST) Received: from localhost ([::1]:39994 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nErkd-0008FI-LO for importer@patchew.org; Tue, 01 Feb 2022 06:55:11 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57058) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nEr7r-00059v-H9 for qemu-devel@nongnu.org; Tue, 01 Feb 2022 06:15:07 -0500 Received: from [2607:f8b0:4864:20::d2e] (port=41677 helo=mail-io1-xd2e.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nEr7l-0003Xv-ET for qemu-devel@nongnu.org; Tue, 01 Feb 2022 06:15:07 -0500 Received: by mail-io1-xd2e.google.com with SMTP id q204so20678189iod.8 for ; Tue, 01 Feb 2022 03:15:00 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id w5sm13526852ilu.83.2022.02.01.03.14.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Feb 2022 03:14:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LlbdUA9gTxN/MXoEG3GmVMJfP/uIx9CCTaunXLE0kqQ=; b=sXWp4FrhXqvqiMLHtv9dSI5yIDjv/rmDbht4ZlzFijrMeh582FjiOP/wdJHib2wSNa djH3j1MsHIbyq2nmDjHlkWJil3ScWELiIvB4/RchHSo8g2zu/UXnsqJNaLoj3qVkgbUi zinmmYrpiZH7ZvJwki1XoVDPkj++9yHtUUrbq5FimI5CDX1XhAYvk1GCrmjVA9hsfe56 +kYuoTizFc7wqfDxFCWoi9ZM/LZePjwhOkRLjSo+DsY0ZdIXE5QwFhdmRKE+gdRfTF/D MP/WgQQiNYt++UNIXWhbkTYZhR2eztzwXhAi6a3aPqDdh38ZNVdq79r6TJfeBGjuKhXJ 1S5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LlbdUA9gTxN/MXoEG3GmVMJfP/uIx9CCTaunXLE0kqQ=; b=kiA8t5hwCfAsxTP1NLFMZSLFkhHG163OsF7IfK19smDL1FFZGqY3Xt3qM7+qe7iXll yp9DJGTBagCYW46iZA9YyH5kI/aqBHVTOk33Eu0bWDwimcuoS173E9MNS7RrYPot9RPs bVd8vRxouoLSlANemDYVpQK0v5KHazhVD2L1y6vt4snCjbUVDSySKz0+tSBCsVboywJY p7+elq6GxO7uQ3vMFMnDn6TyBLKiyD7lh7Tllyy0EsDe+q4td+aqfbJURjpGFDpvy8CF WvEWrD/wxnw2Awwp1MbqAzTaWU1yRAjFXtWPbEOy5Herphd+HitzWkiaxbkUinfHzUna cvUA== X-Gm-Message-State: AOAM530mvGZe+eZmA24QYVWRVDlx9HkafIq91BOOw4lJHwJN2YPRz1JS SNgNcx4xk6hhRIXAf02e6s2vKnMaNGnj/A== X-Google-Smtp-Source: ABdhPJx9sK8oljhKvucqBvEqze1WnqWI8sox7T221+cYtIY59XQyaUk+RoEF/TW2vsIq6e0Bpb3vZQ== X-Received: by 2002:a05:6602:29d3:: with SMTP id z19mr12835208ioq.116.1643714100078; Tue, 01 Feb 2022 03:15:00 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH 12/22] bsd-user/freebsd/os-syscall.c: Add get_errno and host_to_target_errno Date: Tue, 1 Feb 2022 04:14:45 -0700 Message-Id: <20220201111455.52511-13-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220201111455.52511-1-imp@bsdimp.com> References: <20220201111455.52511-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::d2e (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::d2e; envelope-from=imp@bsdimp.com; helo=mail-io1-xd2e.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , arrowd@FreeBSD.org, Kyle Evans , Richard Henderson , def@FreeBSD.org, jrtc27@FreeBSD.org, Warner Losh , Brad Smith Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1643716515784100001 Content-Type: text/plain; charset="utf-8" Add the helper functions get_errno and host_to_target_errno. get_errno returns either the system call results, or the -errno when system call indicates failure by returning -1. Host_to_target_errno returns errno (since on FreeBSD they are the same on all architectures) along with a comment about why it's the identity. Signed-off-by: Warner Losh Reviewed-by: Kyle Evans Reviewed-by: Richard Henderson --- bsd-user/freebsd/os-syscall.c | 23 +++++++++++++++++++++++ bsd-user/qemu.h | 3 ++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index 7e2bedb918d..2e84cf350b1 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -44,6 +44,29 @@ void target_set_brk(abi_ulong new_brk) { } =20 +/* + * errno conversion. + */ +abi_long get_errno(abi_long ret) +{ + + if (ret =3D=3D -1) { + return -host_to_target_errno(errno); + } else { + return ret; + } +} + +int host_to_target_errno(int err) +{ + /* + * All the BSDs have the property that the error numbers are uniform a= cross + * all architectures for a given BSD, though they may vary between dif= ferent + * BSDs. + */ + return err; +} + bool is_error(abi_long ret) { =20 diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h index e5742bd6c03..56042ddbc5d 100644 --- a/bsd-user/qemu.h +++ b/bsd-user/qemu.h @@ -246,9 +246,10 @@ extern unsigned long target_dflssiz; extern unsigned long target_maxssiz; extern unsigned long target_sgrowsiz; =20 -/* syscall.c */ +/* os-syscall.c */ abi_long get_errno(abi_long ret); bool is_error(abi_long ret); +int host_to_target_errno(int err); =20 /* os-sys.c */ abi_long do_freebsd_sysarch(void *cpu_env, abi_long arg1, abi_long arg2); --=20 2.33.1 From nobody Fri May 17 08:39:27 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1643716470386683.9513772385188; Tue, 1 Feb 2022 03:54:30 -0800 (PST) Received: from localhost ([::1]:37726 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nErjx-0006fH-Ax for importer@patchew.org; Tue, 01 Feb 2022 06:54:29 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57086) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nEr7r-0005BC-Sk for qemu-devel@nongnu.org; Tue, 01 Feb 2022 06:15:07 -0500 Received: from [2607:f8b0:4864:20::d31] (port=35496 helo=mail-io1-xd31.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nEr7m-0003YW-M2 for qemu-devel@nongnu.org; Tue, 01 Feb 2022 06:15:07 -0500 Received: by mail-io1-xd31.google.com with SMTP id 9so20767143iou.2 for ; Tue, 01 Feb 2022 03:15:02 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id w5sm13526852ilu.83.2022.02.01.03.15.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Feb 2022 03:15:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=P+hwpRasrlBwRhMd/TMNJlUBlbRLqHxNn2N1IM+WvmM=; b=n3EHe1t1Auw6xRddKBbo8HxG1Dy4ZJg5RhCF/q4SrF3eto9kOamgNpuwWLy14hWOH9 lulmoJE9OpvxQIY/1rOA1NK0BBtskdpYjL3i6eQ394hQ7yjAWyODJPRniBvXwx6TjUuy K1bgmFCrqvvCIU9szHSUCvWrg+NFDYr6TuuFYuymynV0O3Xz0Ad0SNOWd/1AiLXb1Xi3 EI8J6HSYXi6NNO2vmthaaGP6p0eukKXylEu3FnTRdh3JATt4R6s5wQU3K8uBVhoSPiHk CQZmyu4p5MqV1SynYG9upiamkb8uIsqEm/gQvtH+uNhVBSWuGG5f3RsvTxuFjsVTe38W Jx1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=P+hwpRasrlBwRhMd/TMNJlUBlbRLqHxNn2N1IM+WvmM=; b=QlISaVP+J5sfVcMm1z5pz1dMlDAf1RD12bQVrIxP4tfd3ykaZetwQtj9F0Eck6KSB1 6tKNRtxv1b9CPsLZizutrqCiJv8wO7C6KSVVyxmTvdgKn+1v6J4dvX7SlDld7nEI+Ipq BISuUM2433lri3qSpbBuKJc0C52rgiQRMkz0bFUv0oQ0ZwPKX5UwFe9VWnsqSUOcdGHS /FbzpHyDZ5Rc9kz6fQpthY+r94BT/w27+GJUaqV4Y7s9P3242nZWF2DYhKOkYRmQsmII QVzNDq4L/J2U7kl06c7QO+BwPfQ/kNog4cilpyeWGMkyJvxFpUXiyejPjZWGrFY2CSuT kbow== X-Gm-Message-State: AOAM532+esnbblMeaxsSTFNMJynOoT9ad9amRpONEnwH7Bxg6hRa9zUr mXq8QVDRXKIhjQ2MpXAuoIDJG0giB1exqw== X-Google-Smtp-Source: ABdhPJyTKPOlLTFRF7FT0k1JB0U2Dbbuiz4ZPSPOvNn97F4z2wU0p4a0fZhmRbZxWPRsAyGKQRNCHA== X-Received: by 2002:a05:6602:1345:: with SMTP id i5mr13288894iov.143.1643714101185; Tue, 01 Feb 2022 03:15:01 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH 13/22] bsd-user/bsd-file.h: Implementation details for the filesystem calls Date: Tue, 1 Feb 2022 04:14:46 -0700 Message-Id: <20220201111455.52511-14-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220201111455.52511-1-imp@bsdimp.com> References: <20220201111455.52511-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::d31 (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::d31; envelope-from=imp@bsdimp.com; helo=mail-io1-xd31.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , arrowd@FreeBSD.org, Kyle Evans , Richard Henderson , def@FreeBSD.org, jrtc27@FreeBSD.org, Warner Losh , Brad Smith Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1643716472731100001 Content-Type: text/plain; charset="utf-8" An include file that pulls in all the definitions needed for the file related system calls. This also includes the host definitions to implement the system calls and some helper routines to lock/unlock different aspects of the system call arguments. Signed-off-by: Warner Losh Reviewed-by: Kyle Evans --- bsd-user/bsd-file.h | 39 +++++++++++++++++++++++++++++++++++ bsd-user/freebsd/os-syscall.c | 2 ++ 2 files changed, 41 insertions(+) create mode 100644 bsd-user/bsd-file.h diff --git a/bsd-user/bsd-file.h b/bsd-user/bsd-file.h new file mode 100644 index 00000000000..2f743db38e1 --- /dev/null +++ b/bsd-user/bsd-file.h @@ -0,0 +1,39 @@ +/* + * file related system call shims and definitions + * + * 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 BSD_FILE_H_ +#define BSD_FILE_H_ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "qemu/path.h" + +extern struct iovec *lock_iovec(int type, abi_ulong target_addr, int count, + int copy); +extern void unlock_iovec(struct iovec *vec, abi_ulong target_addr, int cou= nt, + int copy); + +#endif /* !BSD_FILE_H_ */ diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index 2e84cf350b1..060134a9ecd 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -40,6 +40,8 @@ #include "signal-common.h" #include "user/syscall-trace.h" =20 +#include "bsd-file.h" + void target_set_brk(abi_ulong new_brk) { } --=20 2.33.1 From nobody Fri May 17 08:39:27 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1643715147880185.0910387000223; Tue, 1 Feb 2022 03:32:27 -0800 (PST) Received: from localhost ([::1]:53732 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nErOc-0003dl-P6 for importer@patchew.org; Tue, 01 Feb 2022 06:32:26 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57094) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nEr7r-0005BY-Vq for qemu-devel@nongnu.org; Tue, 01 Feb 2022 06:15:11 -0500 Received: from [2607:f8b0:4864:20::d31] (port=42851 helo=mail-io1-xd31.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nEr7n-0003Zm-FH for qemu-devel@nongnu.org; Tue, 01 Feb 2022 06:15:07 -0500 Received: by mail-io1-xd31.google.com with SMTP id r144so20673053iod.9 for ; Tue, 01 Feb 2022 03:15:03 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id w5sm13526852ilu.83.2022.02.01.03.15.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Feb 2022 03:15:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=014KLrrmpCxLSaIFhafJ91o/j0d6EMkAjz6oEw/jXuM=; b=Inpwt/xsqB72GDfJqD4MfEvw/cZe6TPf4GBsjTNkicm6pQJ/M0tAwKRcKZLOtomckA 095I4nZQpRRwGlvJ1QBEy3+K0pcUBgvmZu7VfF8C3M+xAGvLH70n4kTWmtC4x30Ql/BO q+fv0dyzL8fcp4ayNF7WrOuxT92lJATczl+jPJuYy81S5rVjMPfHxM9a6EU8f4pNI55y D4Q6smjvc7MLVhM7c5F1RYUI+yc4m385cqC7+rCHnVRqvdGxJUdt5rcRx1zXq+ZIBE1w QjaghgNjb5YKb6o3rcTofw2nmcaDAyNqUJcvS0W2oSvVcyqiWZ2WNowHZ5A1BfCTubMX f6pg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=014KLrrmpCxLSaIFhafJ91o/j0d6EMkAjz6oEw/jXuM=; b=BKGfN8OuQfj/xMO54pRaZXlhElzsPqA465nLJRvjXJyduw3MfJHdlLoNBu6orI5Deq cMAwtYW4tnbURM+3x+SL0Ab5dEbrHYWfcV0dwipzTKDDtSD3zcjk8lwtjVzCPhPvjofj Ww7tkNxxY6IIw0KMjsZnTD+xy3QSDzB5AMMeDFS/8bcyneDaMyKn/hD41caeQsFJwg3O xsotOkwOmLxeYVPb1mBWaZAMUK9XrhVfBqpd2MW8zQd4KpxzM0EOIxIU2SYW+57T/63Y iIZYbIE06ZtQfxy0vtobP86kayP+yrEGEWP3DlY74Peu9D587ArTZqP8vev0NzJja0Jj MIpg== X-Gm-Message-State: AOAM532p7Tm1cpexDkubKMGWhFyrPM5+7n2vgZoVrNXNzSY3YJrTpm5p B3Cpc5df4DvGkGi237pxd1BSQMFqrabq6w== X-Google-Smtp-Source: ABdhPJz/CS4NVU8FB2xXLkthW8T4rdTnBi9Hlo96TkQr+Z1M3pPdDON09BZY5Ewfj66Rfpr7I0qyrg== X-Received: by 2002:a05:6638:250a:: with SMTP id v10mr8733006jat.56.1643714102191; Tue, 01 Feb 2022 03:15:02 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH 14/22] bsd-user/freebsd/os-syscall.c: lock_iovec Date: Tue, 1 Feb 2022 04:14:47 -0700 Message-Id: <20220201111455.52511-15-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220201111455.52511-1-imp@bsdimp.com> References: <20220201111455.52511-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::d31 (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::d31; envelope-from=imp@bsdimp.com; helo=mail-io1-xd31.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , arrowd@FreeBSD.org, Kyle Evans , Richard Henderson , def@FreeBSD.org, jrtc27@FreeBSD.org, Warner Losh , Brad Smith Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1643715151794100001 Content-Type: text/plain; charset="utf-8" lock_iovec will lock an I/O vec and the memory to which it referrs and create a iovec in the host space that referrs to it, with full error unwinding. Signed-off-by: Warner Losh Reviewed-by: Kyle Evans --- bsd-user/freebsd/os-syscall.c | 92 +++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index 060134a9ecd..c21759ae7ce 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -75,6 +75,98 @@ bool is_error(abi_long ret) return (abi_ulong)ret >=3D (abi_ulong)(-4096); } =20 +struct iovec *lock_iovec(int type, abi_ulong target_addr, + int count, int copy) +{ + struct target_iovec *target_vec; + struct iovec *vec; + abi_ulong total_len, max_len; + int i; + int err =3D 0; + bool bad_address =3D false; + + if (count =3D=3D 0) { + errno =3D 0; + return NULL; + } + if (count < 0 || count > IOV_MAX) { + errno =3D EINVAL; + return NULL; + } + + vec =3D calloc(count, sizeof(struct iovec)); + if (vec =3D=3D NULL) { + errno =3D ENOMEM; + return NULL; + } + + target_vec =3D lock_user(VERIFY_READ, target_addr, + count * sizeof(struct target_iovec), 1); + if (target_vec =3D=3D NULL) { + err =3D EFAULT; + goto fail2; + } + + /* + * ??? If host page size > target page size, this will result in a val= ue + * larger than what we can actually support. + */ + max_len =3D 0x7fffffff & TARGET_PAGE_MASK; + total_len =3D 0; + + for (i =3D 0; i < count; i++) { + abi_ulong base =3D tswapal(target_vec[i].iov_base); + abi_long len =3D tswapal(target_vec[i].iov_len); + + if (len < 0) { + err =3D EINVAL; + goto fail; + } else if (len =3D=3D 0) { + /* Zero length pointer is ignored. */ + vec[i].iov_base =3D 0; + } else { + vec[i].iov_base =3D lock_user(type, base, len, copy); + /* + * If the first buffer pointer is bad, this is a fault. But + * subsequent bad buffers will result in a partial write; this= is + * realized by filling the vector with null pointers and zero + * lengths. + */ + if (!vec[i].iov_base) { + if (i =3D=3D 0) { + err =3D EFAULT; + goto fail; + } else { + bad_address =3D true; + } + } + if (bad_address) { + len =3D 0; + } + if (len > max_len - total_len) { + len =3D max_len - total_len; + } + } + vec[i].iov_len =3D len; + total_len +=3D len; + } + + unlock_user(target_vec, target_addr, 0); + return vec; + + fail: + while (--i >=3D 0) { + if (tswapal(target_vec[i].iov_len) > 0) { + unlock_user(vec[i].iov_base, tswapal(target_vec[i].iov_base), = 0); + } + } + unlock_user(target_vec, target_addr, 0); + fail2: + free(vec); + errno =3D err; + return NULL; +} + /* * do_syscall() should always have a single exit point at the end so that * actions, such as logging of syscall results, can be performed. All err= nos --=20 2.33.1 From nobody Fri May 17 08:39:27 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1643715150392192.29258003986558; Tue, 1 Feb 2022 03:32:30 -0800 (PST) Received: from localhost ([::1]:53972 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nErOf-0003nw-EY for importer@patchew.org; Tue, 01 Feb 2022 06:32:29 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57118) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nEr7s-0005Bz-Hm for qemu-devel@nongnu.org; Tue, 01 Feb 2022 06:15:11 -0500 Received: from [2607:f8b0:4864:20::131] (port=40613 helo=mail-il1-x131.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nEr7o-0003aY-N1 for qemu-devel@nongnu.org; Tue, 01 Feb 2022 06:15:08 -0500 Received: by mail-il1-x131.google.com with SMTP id s1so13949848ilj.7 for ; Tue, 01 Feb 2022 03:15:04 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id w5sm13526852ilu.83.2022.02.01.03.15.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Feb 2022 03:15:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=NIF+VNOgCO38jAUQ1Bkp9EJCrwItP3MwODBXv1s0NcU=; b=b2s2CVgcTgwmwVimrW33vAVvVSHeSYPSerghqonH/h62gafDKGcQVkBZKNv0AkHOLZ iW9xB6CVhe2NhNR10RBNG4HgDywZGSDoI9Fg9saqlTxvrjkZOGYvVrQlFAyC3s5tuHpm 7rIid+Zbv8Rw8tcm4S7omTM9StFGvDu2YM3WckzkULcCA4WmnwLep8hG6j78MTo4uFHc jpeWytb1TUgzCOzH0sZSS6PLr5tDS+jn96YI2/PhYBUw/HvuOx51ELcToLInfjX0IQ9a tZlROa6XgRK3hi5h4b2svnGs/E8JgObK7jCsMCQT40fHQeQG0tAMkoq4BYdTj8k/kygI YfDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NIF+VNOgCO38jAUQ1Bkp9EJCrwItP3MwODBXv1s0NcU=; b=PP/Ut2Lah/3twa24Rb7bHfyN9ozZGsyNjUnefU3CLc7baGdXZ32g58mRjqXbMcNOU6 8DcKBUOz18Gbiqme/A9YsIbJsdECXVIK/j8EwvjUe8plnXagNOOR1If+uQZAH+YWc9wD sGYKgDOh+cdm14k0SuMAJCTUHL2GbRtaR7PYYfVfuQ4FVG0BtOyYxrr9MPeboyWhhSo4 ch7edltarCYDFUlijevBef1tZVkXkNuVlkMhgpp3nT+xnE7LSsa9AXbSX9mVOl6DGkZp 7hGHYKenG3eBOpVtIpnPCTqh7/+lDhaWCLyCvEN/jZ6ow4hoEvted7rGN7bbTZ68KPJt a8tg== X-Gm-Message-State: AOAM532Uxz2eiBjgwKqxmrckcElW6PFYEdyJQ2X97+VBok/t3qtaVruI Pj+eoADteM/lpxtywwkZwVMPxPv7+IWAQA== X-Google-Smtp-Source: ABdhPJzWQbHKji6NYDcB/eUhwBF3j/7x3BkdNkVL6bijCnJRJJDS5vfcEvA0AV/Bf+IVoWXXMqlWYA== X-Received: by 2002:a05:6e02:1605:: with SMTP id t5mr6640974ilu.17.1643714103421; Tue, 01 Feb 2022 03:15:03 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH 15/22] bsd-user/freebsd/os-syscall.c: unlock_iovec Date: Tue, 1 Feb 2022 04:14:48 -0700 Message-Id: <20220201111455.52511-16-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220201111455.52511-1-imp@bsdimp.com> References: <20220201111455.52511-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::131 (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::131; envelope-from=imp@bsdimp.com; helo=mail-il1-x131.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , arrowd@FreeBSD.org, Kyle Evans , Richard Henderson , def@FreeBSD.org, jrtc27@FreeBSD.org, Warner Losh , Brad Smith Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1643715152905100003 Content-Type: text/plain; charset="utf-8" Releases the references to the iovec created by lock_iovec. Signed-off-by: Warner Losh Reviewed-by: Kyle Evans --- bsd-user/freebsd/os-syscall.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index c21759ae7ce..d49945f0fcc 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -167,6 +167,29 @@ struct iovec *lock_iovec(int type, abi_ulong target_ad= dr, return NULL; } =20 +void unlock_iovec(struct iovec *vec, abi_ulong target_addr, + int count, int copy) +{ + struct target_iovec *target_vec; + int i; + + target_vec =3D lock_user(VERIFY_READ, target_addr, + count * sizeof(struct target_iovec), 1); + if (target_vec) { + for (i =3D 0; i < count; i++) { + abi_ulong base =3D tswapal(target_vec[i].iov_base); + abi_long len =3D tswapal(target_vec[i].iov_len); + if (len < 0) { + break; + } + unlock_user(vec[i].iov_base, base, copy ? vec[i].iov_len : 0); + } + unlock_user(target_vec, target_addr, 0); + } + + free(vec); +} + /* * do_syscall() should always have a single exit point at the end so that * actions, such as logging of syscall results, can be performed. All err= nos --=20 2.33.1 From nobody Fri May 17 08:39:27 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 164371734688272.7390151979373; Tue, 1 Feb 2022 04:09:06 -0800 (PST) Received: from localhost ([::1]:50618 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nEry4-0007mr-9S for importer@patchew.org; Tue, 01 Feb 2022 07:09:04 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57124) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nEr7s-0005C0-Iz for qemu-devel@nongnu.org; Tue, 01 Feb 2022 06:15:11 -0500 Received: from [2607:f8b0:4864:20::d36] (port=44954 helo=mail-io1-xd36.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nEr7p-0003bB-LW for qemu-devel@nongnu.org; Tue, 01 Feb 2022 06:15:08 -0500 Received: by mail-io1-xd36.google.com with SMTP id p63so19849326iod.11 for ; Tue, 01 Feb 2022 03:15:05 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id w5sm13526852ilu.83.2022.02.01.03.15.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Feb 2022 03:15:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=G4Vpw/I6iiWTN4s+j93oyFd2/tcBHu47g5sAn9S/ES0=; b=isHEHkKiNNbHew016kZen0+Heg2bYJTdAxx0ILhH3e4noiZquiUMsdG6AwQgBocnjH FtaL68tNyfEWG7LbC5+4mP/RRHEpdBGhkTvDRMO2fVnNSSB+CqJx9TPghEWAmQ0s0ZIQ 7e9QVPHaV9e7vE1GC/Cjmt7CqRSdBebB4Djg2LA6d70MVgtYmNFGKkxgbrkiSh4CbcTj H4FwQL0F5G4axVoFr32qdxrqPmsu2fU2sQYYKoL9/8M0xdVu+cMFrmdizTrQLgvzOhZc zCebBt4r8r74otYM47yU2AOpPCYCESF+86lGNSCVL6Z4fbbIINtFwbx7460CYEzAvXwq 0Opg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=G4Vpw/I6iiWTN4s+j93oyFd2/tcBHu47g5sAn9S/ES0=; b=jN/mGemUGH5VVW0bhftrv1Pt/mHtODKritpbOMBCyRPDJa8HFcpd9iD5C9CguAtep6 dtNVKPC/i47mAclF2HQFTdyt9WeDeHbIg2laW9eYgEX3CeNQI3auLnsnoZpkGIPVVv6n PJAMwYtvo0qmdBP82Nb+veV8cNo4BjqiTrvRtfEamfg7gxJf6onFuZjhF34Tl93V3Rws H4FDsW1tP0PPwuuAAzwGLTEK4Pm8eo/YpU/95er79pjeht6ZgbOUsPTTp2ewBEG6rNuh qgqeUMg5AwxohRGKbQffqFt543es0zTa3ODnnFE4j5dGGoZODx4kfaW5nryWNNqTx4o4 bfuA== X-Gm-Message-State: AOAM533NutajzIEraFoQ1aQSEX4gZCaPojNQ4m39FSHYi6DNWmr5HgmI QWAmZf43ciaQqs4HZ0YRvz6JxoQ4siOyAg== X-Google-Smtp-Source: ABdhPJz20TFEqs3iRwKAEzaVD5lpnAoDmYZIX2S2QddPXiD1ekd5DoSFKoWfHxQpEdam6qzrn/Q2nA== X-Received: by 2002:a05:6602:72f:: with SMTP id g15mr13365435iox.25.1643714104307; Tue, 01 Feb 2022 03:15:04 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH 16/22] bsd-user/freebsd/os-syscall.c: Tracing and error boilerplate Date: Tue, 1 Feb 2022 04:14:49 -0700 Message-Id: <20220201111455.52511-17-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220201111455.52511-1-imp@bsdimp.com> References: <20220201111455.52511-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::d36 (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::d36; envelope-from=imp@bsdimp.com; helo=mail-io1-xd36.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , arrowd@FreeBSD.org, Kyle Evans , Richard Henderson , def@FreeBSD.org, jrtc27@FreeBSD.org, Warner Losh , Brad Smith Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1643717348565100001 Content-Type: text/plain; charset="utf-8" Add in the tracing and this system call not implemented boilerplate. Signed-off-by: Warner Losh --- bsd-user/freebsd/os-syscall.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index d49945f0fcc..fcfa6221182 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -200,7 +200,32 @@ abi_long do_freebsd_syscall(void *cpu_env, int num, ab= i_long arg1, abi_long arg5, abi_long arg6, abi_long arg7, abi_long arg8) { - return 0; + CPUState *cpu =3D env_cpu(cpu_env); + abi_long ret; + +#ifdef DEBUG + gemu_log("freebsd syscall %d\n", num); +#endif + trace_guest_user_syscall(cpu, num, arg1, arg2, arg3, arg4, arg5, arg6,= arg7, arg8); + if (do_strace) { + print_freebsd_syscall(num, arg1, arg2, arg3, arg4, arg5, arg6); + } + + switch (num) { + default: + gemu_log("qemu: unsupported syscall: %d\n", num); + ret =3D -TARGET_ENOSYS; + break; + } + +#ifdef DEBUG + gemu_log(" =3D %ld\n", ret); +#endif + if (do_strace) { + print_freebsd_syscall_ret(num, ret); + } + trace_guest_user_syscall_ret(cpu, num, ret); + return ret; } =20 void syscall_init(void) --=20 2.33.1 From nobody Fri May 17 08:39:27 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1643716822739835.7742023139859; Tue, 1 Feb 2022 04:00:22 -0800 (PST) Received: from localhost ([::1]:46212 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nErpd-0004F7-NW for importer@patchew.org; Tue, 01 Feb 2022 07:00:21 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57156) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nEr7t-0005C2-7L for qemu-devel@nongnu.org; Tue, 01 Feb 2022 06:15:11 -0500 Received: from [2607:f8b0:4864:20::12e] (port=39774 helo=mail-il1-x12e.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nEr7q-0003bp-DL for qemu-devel@nongnu.org; Tue, 01 Feb 2022 06:15:08 -0500 Received: by mail-il1-x12e.google.com with SMTP id z7so13965114ilb.6 for ; Tue, 01 Feb 2022 03:15:06 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id w5sm13526852ilu.83.2022.02.01.03.15.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Feb 2022 03:15:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=RSGQ/GmeXW/IFZq2u0G+wlHtpufwI4M6hwKbZgp8r+Y=; b=EkFYLX68/ZjsPTbHsy4HZV4lKFTYd2s7aFqXUduQl8oGdt64iX/8e/FOp8xEE5OocQ ZmQfhRGjrUvuQ1kAYhtd4hQN0x8IOOngcHq31dKG5Qw5U9Ltvk0Xe7ECQllbTt3Dezg4 5UCAHwdlftgKdxtkgdOTLcv/yf/N0OG+9J/g3fjU5vYQqEHGKaEteP/KWkX3TtOpRvGi NqCaEi+Qk7Mh6ZIO2jhEO9BxTW3cZy4W6ELteRQyDBLQK985xKhP41OdrC1WWZu6u9MM wrlJ58sx9YOBHfNzpmqdGJGRbV7W/NWaBvwxWE66bgYcKwzxh6yqpyjrPJMQps0z9GyC T3QQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RSGQ/GmeXW/IFZq2u0G+wlHtpufwI4M6hwKbZgp8r+Y=; b=Vtpk12Bzg4zklgTuN/g+NtbxB7bRqgU8PfSUFZ31a1MRnvB8u3yXDlCH6R+cRhKiqf 8pVbjYJpZ0lUy77g1AzgNXAk57auQXLxdkzJXBKiO8lwagUd9EAySLMtAsfTBRHyAJ+X NnVTvfCOo2+hFBEv9vHed1o0iILBWezoziOpi6k6xmH5w8fIsRjgotFy2CaIjIX0is2M 0eYbVKlvUKbJ98GBYYA1Q+frxvc6sQZmFlodaJudRAYEUzpPi11aAd4gQmGgeG7ZYP4W gy1fM0ITmegqYVPb2+BKmolUT2vwf5SU7hAClvcFOj9EjcMQZF/4QnsrZg0TFgtWr1QR io/A== X-Gm-Message-State: AOAM533h5vLw8d+yA5FwOPfYqyAvbaR9tsdGh9nI7+aOtXAmKlRtsOsk fEqg+j8HPWJ+vczmcQgJYgzCaQRWOEHZMA== X-Google-Smtp-Source: ABdhPJw9u1D5FjPVrtyZA2NxzflwZ8o48/bjpPFjnbg1sgzPhTVTW3/XxYE07cFNzTlY/Eh8aY6INA== X-Received: by 2002:a05:6e02:17ca:: with SMTP id z10mr7313084ilu.100.1643714105107; Tue, 01 Feb 2022 03:15:05 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH 17/22] bsd-user: introduce target.h Date: Tue, 1 Feb 2022 04:14:50 -0700 Message-Id: <20220201111455.52511-18-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220201111455.52511-1-imp@bsdimp.com> References: <20220201111455.52511-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::12e (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::12e; envelope-from=imp@bsdimp.com; helo=mail-il1-x12e.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , arrowd@FreeBSD.org, Kyle Evans , Richard Henderson , def@FreeBSD.org, jrtc27@FreeBSD.org, Warner Losh , Brad Smith Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1643716826407100001 Content-Type: text/plain; charset="utf-8" Create target.h. This file is intended to be simple and describe basic things about the architecture. If something is a basic feature of the architecture, it belongs here. Should we need something that's per-BSD there will be a target-os.h that will live in the per-bsd directories. Define regpairs_aligned to reflect whether or not registers are 'paired' for 64-bit arguments or not. This will be false for all 64-bit targets, and will be true on those architectures that pair (currently just armv7 and powerpc on FreeBSD 14.x). Signed-off-by: Warner Losh Reviewed-by: Kyle Evans Reviewed-by: Richard Henderson --- bsd-user/arm/target.h | 21 +++++++++++++++++++++ bsd-user/i386/target.h | 21 +++++++++++++++++++++ bsd-user/qemu.h | 1 + bsd-user/x86_64/target.h | 21 +++++++++++++++++++++ 4 files changed, 64 insertions(+) create mode 100644 bsd-user/arm/target.h create mode 100644 bsd-user/i386/target.h create mode 100644 bsd-user/x86_64/target.h diff --git a/bsd-user/arm/target.h b/bsd-user/arm/target.h new file mode 100644 index 00000000000..1f7ee49bfb4 --- /dev/null +++ b/bsd-user/arm/target.h @@ -0,0 +1,21 @@ +/* + * Intel general target stuff that's common to all i386 details + * + * Copyright (c) 2022 M. Warner Losh + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef TARGET_H +#define TARGET_H + +/* + * arm EABI 'lumps' the registers for 64-bit args. + */ +static inline int regpairs_aligned(void *cpu_env) +{ + return 1; +} + +#endif /* ! TARGET_H */ + diff --git a/bsd-user/i386/target.h b/bsd-user/i386/target.h new file mode 100644 index 00000000000..b0ab477d683 --- /dev/null +++ b/bsd-user/i386/target.h @@ -0,0 +1,21 @@ +/* + * Intel general target stuff that's common to all i386 details + * + * Copyright (c) 2022 M. Warner Losh + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef TARGET_ARCH_H +#define TARGET_ARCH_H + +/* + * i386 doesn't 'lump' the registers for 64-bit args. + */ +static inline int regpairs_aligned(void *cpu_env) +{ + return 0; +} + +#endif /* ! TARGET_ARCH_H */ + diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h index 56042ddbc5d..a9efa807b78 100644 --- a/bsd-user/qemu.h +++ b/bsd-user/qemu.h @@ -35,6 +35,7 @@ extern char **environ; #include "target_syscall.h" #include "target_os_vmparam.h" #include "target_os_signal.h" +#include "target.h" #include "exec/gdbstub.h" =20 /* diff --git a/bsd-user/x86_64/target.h b/bsd-user/x86_64/target.h new file mode 100644 index 00000000000..6d3aef8fc49 --- /dev/null +++ b/bsd-user/x86_64/target.h @@ -0,0 +1,21 @@ +/* + * Intel general target stuff that's common to all x86_64 details + * + * Copyright (c) 2022 M. Warner Losh + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef TARGET_H +#define TARGET_H + +/* + * x86 doesn't 'lump' the registers for 64-bit args, all args are 64 bits. + */ +static inline int regpairs_aligned(void *cpu_env) +{ + return 0; +} + +#endif /* ! TARGET_H */ + --=20 2.33.1 From nobody Fri May 17 08:39:27 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1643716738339536.0159664160495; Tue, 1 Feb 2022 03:58:58 -0800 (PST) Received: from localhost ([::1]:44142 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nEroH-0002k9-CX for importer@patchew.org; Tue, 01 Feb 2022 06:58:57 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57202) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nEr7u-0005C7-BV for qemu-devel@nongnu.org; Tue, 01 Feb 2022 06:15:11 -0500 Received: from [2607:f8b0:4864:20::d31] (port=37836 helo=mail-io1-xd31.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nEr7r-0003cS-FS for qemu-devel@nongnu.org; Tue, 01 Feb 2022 06:15:10 -0500 Received: by mail-io1-xd31.google.com with SMTP id n17so20710666iod.4 for ; Tue, 01 Feb 2022 03:15:07 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id w5sm13526852ilu.83.2022.02.01.03.15.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Feb 2022 03:15:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WSgxsk4XZw+x1Q4t0CNi+XkK/sSqSpLeA70Ph+1kBgk=; b=q4NghWYTfcezq/ItKfmY+Ha+mbFb9aMS1NtL1ku3+LVPBSTYHmS81x5p1vWW0sLUdz Ku9Kq7+++1v5wvdUTA3O4vwLQSe47pomTReQY8oooUC6CHMTIvDkDdcF9sAEY8AeuaD6 XtDhxiQ4TtUgZa8uSFJP/0+PgIPY8QLrJqaW8nfg4oa9JLj+jdUc7ABqtkL7Kf0L5/zO fUJyRfDEVRJpd3T0bh+Jhe20euG5f8hmMy34J/FDABhauQWY6SMv1MbqfSdMmqzZS8Vi /3Lw2G05dAjR9SPMq1At8EceJ0nTB8kV1w8drFX6q8HIBttd5vACyJBsbnryOiaV93i0 2A7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WSgxsk4XZw+x1Q4t0CNi+XkK/sSqSpLeA70Ph+1kBgk=; b=3kg5sqp4BkQAR0FBwrlwgIQ3h2y3EuB0nSdo4o/f7NOLj4+gZ6B1i8qvhxst9fWSVM 2FAXFTNhz7zKx69XL6NprzqDEi3sTM8P3mtKLaPVc05fo2ITi0CBWAFr//lPfEOs+xnr m7xk2qqgT5vvO87T9TDbhvLyyrApt5wy5GZeDr4EJLTVCfiInhzydrMl3/MbSxe8dHqX hk0YLnuqAj05o8lS7xH1lVnfBej/3lwMeNnZxVxGfwdM5xYz5rQXB2Mf4hh6kLF+Z8hM T7yHY9gMaNCRZobEJl0LHNLBoKPw7N276eXfE4EHCbmxx1wOKqSL3JiD9LnjKan98PlL J/rg== X-Gm-Message-State: AOAM533QLqqNJmHRffEIDSXlZWWLO6+H1biX41m0sHzF2inO9XQVS4VN 0wTdn7urO2sH0kcVlsRptjT7MjJHRdCbug== X-Google-Smtp-Source: ABdhPJyrIcnoQjf5kydZN7T8n2e9tqZFIeYMfOjy4b0gJltdPsD6cU++gTyeua/YH6CEkbaAShLq3A== X-Received: by 2002:a05:6602:121a:: with SMTP id y26mr13550915iot.1.1643714106230; Tue, 01 Feb 2022 03:15:06 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH 18/22] bsd-user: Define target_arg64 Date: Tue, 1 Feb 2022 04:14:51 -0700 Message-Id: <20220201111455.52511-19-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220201111455.52511-1-imp@bsdimp.com> References: <20220201111455.52511-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::d31 (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::d31; envelope-from=imp@bsdimp.com; helo=mail-io1-xd31.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Stacey Son , arrowd@FreeBSD.org, Kyle Evans , Richard Henderson , def@FreeBSD.org, jrtc27@FreeBSD.org, Warner Losh , Brad Smith Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1643716741362100001 Content-Type: text/plain; charset="utf-8" target_arg64 is a generic way to extract 64-bits from a pair of arguments. On 32-bit platforms, it returns them joined together as appropriate. On 64-bit platforms, it returns the first arg because it's already 64-bits. Signed-off-by: Stacey Son Signed-off-by: Warner Losh Reviewed-by: Kyle Evans Reviewed-by: Richard Henderson --- bsd-user/qemu.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h index a9efa807b78..af272c2a802 100644 --- a/bsd-user/qemu.h +++ b/bsd-user/qemu.h @@ -462,6 +462,19 @@ static inline void *lock_user_string(abi_ulong guest_a= ddr) #define unlock_user_struct(host_ptr, guest_addr, copy) \ unlock_user(host_ptr, guest_addr, (copy) ? sizeof(*host_ptr) : 0) =20 +static inline uint64_t target_arg64(uint32_t word0, uint32_t word1) +{ +#if TARGET_ABI_BITS =3D=3D 32 +#ifdef TARGET_WORDS_BIGENDIAN + return ((uint64_t)word0 << 32) | word1; +#else + return ((uint64_t)word1 << 32) | word0; +#endif +#else /* TARGET_ABI_BITS !=3D 32 */ + return word0; +#endif /* TARGET_ABI_BITS !=3D 32 */ +} + #include =20 #include "user/safe-syscall.h" --=20 2.33.1 From nobody Fri May 17 08:39:27 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1643715291873754.3555108214136; Tue, 1 Feb 2022 03:34:51 -0800 (PST) Received: from localhost ([::1]:34372 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nErQx-0001CD-3w for importer@patchew.org; Tue, 01 Feb 2022 06:34:51 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57218) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nEr7v-0005CA-0E for qemu-devel@nongnu.org; Tue, 01 Feb 2022 06:15:11 -0500 Received: from [2607:f8b0:4864:20::d2c] (port=44945 helo=mail-io1-xd2c.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nEr7s-0003cz-GE for qemu-devel@nongnu.org; Tue, 01 Feb 2022 06:15:10 -0500 Received: by mail-io1-xd2c.google.com with SMTP id p63so19849453iod.11 for ; Tue, 01 Feb 2022 03:15:08 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id w5sm13526852ilu.83.2022.02.01.03.15.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Feb 2022 03:15:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ntv4pxDkMgVkO564UjcMuE1I6QBGZZBPyRo+XkKbtGM=; b=lZx0CY6D8fBmRBvdMQzwBjateIr95BARGypLzQM+UGCsNebmjvn/LvDG98Au+sXv2F F20d1TiD2ArddLzMOlDiVod498ofMgRLxfeSnsjZCYWUpKOCRUW+mb5b5cy0GBU1jLfr 2Lkk48XwSgYn/m8Pf3omBVrXgA0ijZ+CcTseEOTHUD7UfM3r18qxYnWrkPZUWcdCZQtx ykh2d2RymeTKOmKMg8I2qXcafLPcXOYdDCiScwXUoJEDzPcvWafsU8mi1+x8GM7dZ+ue tgy8Wrax8KDyX9KeVzeJRdlqarEuDbc8xefA/H7NGsYjMgFoRx20/nbcRf3oeRHYiNxW yuKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ntv4pxDkMgVkO564UjcMuE1I6QBGZZBPyRo+XkKbtGM=; b=VAbHvTEWvaBb7syFSkHUeVUEd6W6mkF0DIopr/uai3cS/ZVVhZx29dkc7UTGuOA3T8 d2n47qZ7KoeP/6cM/iDcl8bGRDhNZIr36LxDiPXCwmNSl1P79sJZsSncjUKbhgrxjy3J dKA0p5vg4XRXDpS8ekBQA6YPA6gE+/67QbW5yHZ7WcsYeUb1T1dGjWfeSQC2ZDMWZfit vbYlfLSj+I4ba0EKTSu88N2im4bQhHdyiMjWeq2edt5HizuosNNOoUJH6R8+oaoQQJ2K ekuVIue7hHGeeV9cqzVJiLNk7FtVb/SI+R8fJxcUB7fC22M30xozsi1wZG6Qu//2iX3q XouQ== X-Gm-Message-State: AOAM5318+PfiRU4G6GjkBjugAENoIkkk4q3vxsrNx5n9hpQgby9+DQ3S RYaNLEyKnYJkHOXbyvaA1jD2FHL9hRu9Kg== X-Google-Smtp-Source: ABdhPJws+RvRIEOE1xPe9TJoWPZJrkHatixQGM0QVXSZLs7/o4+yeWnnURkjjp+6dns9rynf9RjCEA== X-Received: by 2002:a02:84cd:: with SMTP id f71mr13473908jai.210.1643714107417; Tue, 01 Feb 2022 03:15:07 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH 19/22] bsd-user: Add safe system call macros Date: Tue, 1 Feb 2022 04:14:52 -0700 Message-Id: <20220201111455.52511-20-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220201111455.52511-1-imp@bsdimp.com> References: <20220201111455.52511-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::d2c (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::d2c; envelope-from=imp@bsdimp.com; helo=mail-io1-xd2c.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , arrowd@FreeBSD.org, Kyle Evans , Richard Henderson , def@FreeBSD.org, jrtc27@FreeBSD.org, Warner Losh , Brad Smith Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1643715294336100003 Content-Type: text/plain; charset="utf-8" Add a series of macros to create system call macros that go via the safe_syscall path. Signed-off-by: Kyle Evans Signed-off-by: Warner Losh Reviewed-by: Richard Henderson --- bsd-user/syscall_defs.h | 47 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/bsd-user/syscall_defs.h b/bsd-user/syscall_defs.h index 62b472b990b..c3bf14f38f4 100644 --- a/bsd-user/syscall_defs.h +++ b/bsd-user/syscall_defs.h @@ -179,4 +179,51 @@ struct target_freebsd__wrusage { struct target_freebsd_rusage wru_children; }; =20 +#define safe_syscall0(type, name) \ +type safe_##name(void) \ +{ \ + return safe_syscall(SYS_##name); \ +} + +#define safe_syscall1(type, name, type1, arg1) \ +type safe_##name(type1 arg1) \ +{ \ + return safe_syscall(SYS_##name, arg1); \ +} + +#define safe_syscall2(type, name, type1, arg1, type2, arg2) \ +type safe_##name(type1 arg1, type2 arg2) \ +{ \ + return safe_syscall(SYS_##name, arg1, arg2); \ +} + +#define safe_syscall3(type, name, type1, arg1, type2, arg2, type3, arg3) \ +type safe_##name(type1 arg1, type2 arg2, type3 arg3) \ +{ \ + return safe_syscall(SYS_##name, arg1, arg2, arg3); \ +} + +#define safe_syscall4(type, name, type1, arg1, type2, arg2, type3, arg3, \ + type4, arg4) \ +type safe_##name(type1 arg1, type2 arg2, type3 arg3, type4 arg4) \ +{ \ + return safe_syscall(SYS_##name, arg1, arg2, arg3, arg4); \ +} + +#define safe_syscall5(type, name, type1, arg1, type2, arg2, type3, arg3, \ + type4, arg4, type5, arg5) \ +type safe_##name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ + type5 arg5) \ +{ \ + return safe_syscall(SYS_##name, arg1, arg2, arg3, arg4, arg5); \ +} + +#define safe_syscall6(type, name, type1, arg1, type2, arg2, type3, arg3, \ + type4, arg4, type5, arg5, type6, arg6) \ +type safe_##name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ + type5 arg5, type6 arg6) \ +{ \ + return safe_syscall(SYS_##name, arg1, arg2, arg3, arg4, arg5, arg6); \ +} + #endif /* ! _SYSCALL_DEFS_H_ */ --=20 2.33.1 From nobody Fri May 17 08:39:27 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1643715290911735.9264052602365; Tue, 1 Feb 2022 03:34:50 -0800 (PST) Received: from localhost ([::1]:34258 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nErQv-00017o-Rr for importer@patchew.org; Tue, 01 Feb 2022 06:34:49 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57232) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nEr7v-0005E0-Qd for qemu-devel@nongnu.org; Tue, 01 Feb 2022 06:15:12 -0500 Received: from [2607:f8b0:4864:20::134] (port=34791 helo=mail-il1-x134.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nEr7u-0003dc-4J for qemu-devel@nongnu.org; Tue, 01 Feb 2022 06:15:11 -0500 Received: by mail-il1-x134.google.com with SMTP id y17so13987629ilm.1 for ; Tue, 01 Feb 2022 03:15:09 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id w5sm13526852ilu.83.2022.02.01.03.15.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Feb 2022 03:15:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2gevMLy4NFMvF294+DOz37UAVJBPe4QgKMEGU4fhIos=; b=bVVnzVSPXknbrnr5UmP6qPGaRTPzlBLfz5mPSItqwluJKsB9pPHyAja0KLLNwUREoJ gdWH1QODQBVS+yp53Hh95glJnstQ3gyKXIZ/XDNjjTj5u9XfEF2MvABl/vmXTSKTP5u1 55fzBZNudtwJKbCdJQFg3S6hXbTIIEibwsoU0XbbZjfYsStiJrBbYyWGOs+PBRg/rPHj zFG7Zb/hpxlfDcE/5yVkpWzjoIXeknmZbh1KJitKh5QnrlwAp3Yowyds+2bqre2Bk8J9 17FVUd0yu6J8GaWCtgNGLge+nV5V2cG0582wx6I6Wso+lkD/aSLHMAHfUtPgYKMFvk6g ixtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2gevMLy4NFMvF294+DOz37UAVJBPe4QgKMEGU4fhIos=; b=DgGCaino7oB5LhACqDLb08eS5V3PtwsqJB8vFEKzga/dKGieqCUjTUPvPTvZnaBVKv 33PA+2kLgvu5S+anFaxseKwZ4CFt0ZJVu8ZtaLSzObI/jJEaxr0gdEQAacn82bK3Hima Av6D2KcllSXutne8brOZdMVUxSLC5X3SI9rg5ifb5A2Tw28sdBh4EBKfaSrra6VNDvlG TmeKAFLDF9tYo0HkatqW0rBxRWAPVgxnzVMYHF6yAT3AksEBcXPQNM8p9RtN1YZiSb7l ZOiDnW4x/QJvpliq+WvdUOOKotNFzrXyRU17zwUCeVvNdTZvRnGXKMfxRyq4QYZwKNhs PFNw== X-Gm-Message-State: AOAM533a1xxF5GL5UWwkYSVurvFC8b6cc9zT7JlUe3SD5b0eAvXL9BuO 3DFGQEVFg0eaPectp4dvjXGNHwWSpFaI7w== X-Google-Smtp-Source: ABdhPJyABF+J1Mo/Na+X6jePiCi5GjM3gWySfN7YLb4uY1F3IqMrwu2CGSTUONznieh2j++iTAOHPA== X-Received: by 2002:a05:6e02:1586:: with SMTP id m6mr15626013ilu.233.1643714108889; Tue, 01 Feb 2022 03:15:08 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH 20/22] bsd-user/bsd-file.h: Add implementations for read, pread, readv and preadv Date: Tue, 1 Feb 2022 04:14:53 -0700 Message-Id: <20220201111455.52511-21-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220201111455.52511-1-imp@bsdimp.com> References: <20220201111455.52511-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::134 (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::134; envelope-from=imp@bsdimp.com; helo=mail-il1-x134.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Stacey Son , arrowd@FreeBSD.org, Kyle Evans , Richard Henderson , def@FreeBSD.org, jrtc27@FreeBSD.org, Warner Losh , Brad Smith Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1643715294115100001 Content-Type: text/plain; charset="utf-8" Implement do_bsd_{read,pread,readv,preadv}. Connect them to the system call table. Signed-off-by: Stacey Son Signed-off-by: Kyle Evans Signed-off-by: Warner Losh Reviewed-by: Richard Henderson --- bsd-user/bsd-file.h | 79 +++++++++++++++++++++++++++++++++++ bsd-user/freebsd/os-syscall.c | 24 +++++++++++ 2 files changed, 103 insertions(+) diff --git a/bsd-user/bsd-file.h b/bsd-user/bsd-file.h index 2f743db38e1..5934cbd5612 100644 --- a/bsd-user/bsd-file.h +++ b/bsd-user/bsd-file.h @@ -36,4 +36,83 @@ extern struct iovec *lock_iovec(int type, abi_ulong targ= et_addr, int count, extern void unlock_iovec(struct iovec *vec, abi_ulong target_addr, int cou= nt, int copy); =20 +ssize_t safe_read(int fd, void *buf, size_t nbytes); +ssize_t safe_pread(int fd, void *buf, size_t nbytes, off_t offset); +ssize_t safe_readv(int fd, const struct iovec *iov, int iovcnt); +ssize_t safe_preadv(int fd, const struct iovec *iov, int iovcnt, off_t off= set); + +/* read(2) */ +static inline abi_long do_bsd_read(abi_long arg1, abi_long arg2, abi_long = arg3) +{ + abi_long ret; + void *p; + + p =3D lock_user(VERIFY_WRITE, arg2, arg3, 0); + if (p =3D=3D NULL) { + return -TARGET_EFAULT; + } + ret =3D get_errno(safe_read(arg1, p, arg3)); + unlock_user(p, arg2, ret); + + return ret; +} + +/* pread(2) */ +static inline abi_long do_bsd_pread(void *cpu_env, abi_long arg1, + abi_long arg2, abi_long arg3, abi_long arg4, abi_long arg5, abi_long a= rg6) +{ + abi_long ret; + void *p; + + p =3D lock_user(VERIFY_WRITE, arg2, arg3, 0); + if (p =3D=3D NULL) { + return -TARGET_EFAULT; + } + if (regpairs_aligned(cpu_env) !=3D 0) { + arg4 =3D arg5; + arg5 =3D arg6; + } + ret =3D get_errno(safe_pread(arg1, p, arg3, target_arg64(arg4, arg5))); + unlock_user(p, arg2, ret); + + return ret; +} + +/* readv(2) */ +static inline abi_long do_bsd_readv(abi_long arg1, abi_long arg2, abi_long= arg3) +{ + abi_long ret; + struct iovec *vec =3D lock_iovec(VERIFY_WRITE, arg2, arg3, 0); + + if (vec !=3D NULL) { + ret =3D get_errno(safe_readv(arg1, vec, arg3)); + unlock_iovec(vec, arg2, arg3, 1); + } else { + ret =3D -host_to_target_errno(errno); + } + + return ret; +} + +/* preadv(2) */ +static inline abi_long do_bsd_preadv(void *cpu_env, abi_long arg1, + abi_long arg2, abi_long arg3, abi_long arg4, abi_long arg5, abi_long a= rg6) +{ + abi_long ret; + struct iovec *vec =3D lock_iovec(VERIFY_WRITE, arg2, arg3, 1); + + if (vec !=3D NULL) { + if (regpairs_aligned(cpu_env) !=3D 0) { + arg4 =3D arg5; + arg5 =3D arg6; + } + ret =3D get_errno(safe_preadv(arg1, vec, arg3, target_arg64(arg4, = arg5))); + unlock_iovec(vec, arg2, arg3, 0); + } else { + ret =3D -host_to_target_errno(errno); + } + + return ret; +} + #endif /* !BSD_FILE_H_ */ diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index fcfa6221182..dda79af53de 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -42,6 +42,14 @@ =20 #include "bsd-file.h" =20 +/* I/O */ +safe_syscall3(ssize_t, read, int, fd, void *, buf, size_t, nbytes); +safe_syscall4(ssize_t, pread, int, fd, void *, buf, size_t, nbytes, off_t, + offset); +safe_syscall3(ssize_t, readv, int, fd, const struct iovec *, iov, int, iov= cnt); +safe_syscall4(ssize_t, preadv, int, fd, const struct iovec *, iov, int, io= vcnt, + off_t, offset); + void target_set_brk(abi_ulong new_brk) { } @@ -212,6 +220,22 @@ abi_long do_freebsd_syscall(void *cpu_env, int num, ab= i_long arg1, } =20 switch (num) { + + /* + * File system calls. + */ + case TARGET_FREEBSD_NR_read: /* read(2) */ + ret =3D do_bsd_read(arg1, arg2, arg3); + break; + + case TARGET_FREEBSD_NR_pread: /* pread(2) */ + ret =3D do_bsd_pread(cpu_env, arg1, arg2, arg3, arg4, arg5, arg6); + break; + + case TARGET_FREEBSD_NR_readv: /* readv(2) */ + ret =3D do_bsd_readv(arg1, arg2, arg3); + break; + default: gemu_log("qemu: unsupported syscall: %d\n", num); ret =3D -TARGET_ENOSYS; --=20 2.33.1 From nobody Fri May 17 08:39:27 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1643717782960454.8000761624853; Tue, 1 Feb 2022 04:16:22 -0800 (PST) Received: from localhost ([::1]:58694 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nEs57-00060E-Ni for importer@patchew.org; Tue, 01 Feb 2022 07:16:21 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57270) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nEr7x-0005IK-7c for qemu-devel@nongnu.org; Tue, 01 Feb 2022 06:15:13 -0500 Received: from [2607:f8b0:4864:20::d31] (port=43873 helo=mail-io1-xd31.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nEr7v-0003iP-D7 for qemu-devel@nongnu.org; Tue, 01 Feb 2022 06:15:12 -0500 Received: by mail-io1-xd31.google.com with SMTP id z199so20681715iof.10 for ; Tue, 01 Feb 2022 03:15:10 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id w5sm13526852ilu.83.2022.02.01.03.15.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Feb 2022 03:15:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LZKC0QaOKwxbEUnfj7dWcrcxfW+qKzGj8MUewXGWUGU=; b=WT893l4lDfXwBaIRRgEUFN1gjhD0kkTpC+nrw1ma6oHI0iS3tNuHHpmVS8znKNbchi p8AX6c4V3UBKn+nKNPic9ixDJlO2bBo/4P4//qHVbq6H9ppFt2m4HoIxJDF1dGC1Mxpf 30cchC2D6IcJzExJDesXIun0ee36YVp8/4kg4jCO9F2am6lQP/GMScWwHad4aBW0Cm45 4EaGHjK5msFjAcee7a5nZ4LfFJpqW4aztRQDzVhRHi49TdxiIoy0VPOclt2o/lHlvKKA odKN35gr4BDYtrCzgsmHA+qw2bbyudqp+ITTz+pWrtfLAx8KiBt+flUUFoBaoqEfM828 9k/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LZKC0QaOKwxbEUnfj7dWcrcxfW+qKzGj8MUewXGWUGU=; b=p/QZW7IkYcyq/bwkc3KjZ5fsLo6TkFTRbau137XoO2xFXcdMUTmrVjW04djeS37LYs 7cR5wwwTy/P4FB0dgep5rTY0wg8A5aopyrbmOJLkQTqNQgtGxGEdtapBKii2rdUWlFbo IFT+BHVfyzsBkEcf5bZajNLF32cgXFpvGqF4Tram92dba/YyyG9YSOGUrJpka+K3L8VZ 7irvUFlxS3xCQyVmxMwyE3h0jVn97fVsA18c49j86aBKWQAGet4vQn0Be/gmTd7K+DJ3 qlq/ukW8SU6CVS2aEE9kGcqynA6ssq1NrvtseEEi1o5CSHQgE34HSB2jwD0JMKCsWVDm OTZA== X-Gm-Message-State: AOAM530nDyI0NlYWSKXeTwUWwDMhGlbAmgY5oa/hDkUlboqdwWnbYR91 yzxu8bjSJIh4PkBNWp4+fa9rACty/Ch54g== X-Google-Smtp-Source: ABdhPJxc92OFaR2C3AUQQuJJb8SiRjKLi+cc98cWVsFLBu02yVblff2YhrnOnexNU7sItvOUYgUcPA== X-Received: by 2002:a05:6638:13d1:: with SMTP id i17mr6193658jaj.182.1643714109820; Tue, 01 Feb 2022 03:15:09 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH 21/22] bsd-user/bsd-file.h: Meat of the write system calls Date: Tue, 1 Feb 2022 04:14:54 -0700 Message-Id: <20220201111455.52511-22-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220201111455.52511-1-imp@bsdimp.com> References: <20220201111455.52511-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::d31 (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::d31; envelope-from=imp@bsdimp.com; helo=mail-io1-xd31.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Stacey Son , arrowd@FreeBSD.org, Kyle Evans , Richard Henderson , def@FreeBSD.org, jrtc27@FreeBSD.org, Warner Losh , Brad Smith Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1643717785191100001 Content-Type: text/plain; charset="utf-8" Implement write, writev, pwrite and pwritev and connect them to the system call dispatch routine. Signed-off-by: Stacey Son Signed-off-by: Kyle Evans Signed-off-by: Warner Losh Reviewed-by: Richard Henderson --- bsd-user/bsd-file.h | 85 +++++++++++++++++++++++++++++++++++ bsd-user/freebsd/os-syscall.c | 23 ++++++++++ 2 files changed, 108 insertions(+) diff --git a/bsd-user/bsd-file.h b/bsd-user/bsd-file.h index 5934cbd5612..2047256a555 100644 --- a/bsd-user/bsd-file.h +++ b/bsd-user/bsd-file.h @@ -41,6 +41,11 @@ ssize_t safe_pread(int fd, void *buf, size_t nbytes, off= _t offset); ssize_t safe_readv(int fd, const struct iovec *iov, int iovcnt); ssize_t safe_preadv(int fd, const struct iovec *iov, int iovcnt, off_t off= set); =20 +ssize_t safe_write(int fd, void *buf, size_t nbytes); +ssize_t safe_pwrite(int fd, void *buf, size_t nbytes, off_t offset); +ssize_t safe_writev(int fd, const struct iovec *iov, int iovcnt); +ssize_t safe_pwritev(int fd, const struct iovec *iov, int iovcnt, off_t of= fset); + /* read(2) */ static inline abi_long do_bsd_read(abi_long arg1, abi_long arg2, abi_long = arg3) { @@ -115,4 +120,84 @@ static inline abi_long do_bsd_preadv(void *cpu_env, ab= i_long arg1, return ret; } =20 +/* write(2) */ +static inline abi_long do_bsd_write(abi_long arg1, abi_long arg2, abi_long= arg3) +{ + abi_long nbytes, ret; + void *p; + + /* nbytes < 0 implies that it was larger than SIZE_MAX. */ + nbytes =3D arg3; + if (nbytes < 0) { + return -TARGET_EINVAL; + } + p =3D lock_user(VERIFY_READ, arg2, nbytes, 1); + if (p =3D=3D NULL) { + return -TARGET_EFAULT; + } + ret =3D get_errno(safe_write(arg1, p, arg3)); + unlock_user(p, arg2, 0); + + return ret; +} + +/* pwrite(2) */ +static inline abi_long do_bsd_pwrite(void *cpu_env, abi_long arg1, + abi_long arg2, abi_long arg3, abi_long arg4, abi_long arg5, abi_long a= rg6) +{ + abi_long ret; + void *p; + + p =3D lock_user(VERIFY_READ, arg2, arg3, 1); + if (p =3D=3D NULL) { + return -TARGET_EFAULT; + } + if (regpairs_aligned(cpu_env) !=3D 0) { + arg4 =3D arg5; + arg5 =3D arg6; + } + ret =3D get_errno(safe_pwrite(arg1, p, arg3, target_arg64(arg4, arg5))= ); + unlock_user(p, arg2, 0); + + return ret; +} + +/* writev(2) */ +static inline abi_long do_bsd_writev(abi_long arg1, abi_long arg2, + abi_long arg3) +{ + abi_long ret; + struct iovec *vec =3D lock_iovec(VERIFY_READ, arg2, arg3, 1); + + if (vec !=3D NULL) { + ret =3D get_errno(safe_writev(arg1, vec, arg3)); + unlock_iovec(vec, arg2, arg3, 0); + } else { + ret =3D -host_to_target_errno(errno); + } + + return ret; +} + +/* pwritev(2) */ +static inline abi_long do_bsd_pwritev(void *cpu_env, abi_long arg1, + abi_long arg2, abi_long arg3, abi_long arg4, abi_long arg5, abi_long a= rg6) +{ + abi_long ret; + struct iovec *vec =3D lock_iovec(VERIFY_READ, arg2, arg3, 1); + + if (vec !=3D NULL) { + if (regpairs_aligned(cpu_env) !=3D 0) { + arg4 =3D arg5; + arg5 =3D arg6; + } + ret =3D get_errno(safe_pwritev(arg1, vec, arg3, target_arg64(arg4,= arg5))); + unlock_iovec(vec, arg2, arg3, 0); + } else { + ret =3D -host_to_target_errno(errno); + } + + return ret; +} + #endif /* !BSD_FILE_H_ */ diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index dda79af53de..f52c9e3c306 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -50,6 +50,13 @@ safe_syscall3(ssize_t, readv, int, fd, const struct iove= c *, iov, int, iovcnt); safe_syscall4(ssize_t, preadv, int, fd, const struct iovec *, iov, int, io= vcnt, off_t, offset); =20 +safe_syscall3(ssize_t, write, int, fd, void *, buf, size_t, nbytes); +safe_syscall4(ssize_t, pwrite, int, fd, void *, buf, size_t, nbytes, off_t, + offset); +safe_syscall3(ssize_t, writev, int, fd, const struct iovec *, iov, int, io= vcnt); +safe_syscall4(ssize_t, pwritev, int, fd, const struct iovec *, iov, int, i= ovcnt, + off_t, offset); + void target_set_brk(abi_ulong new_brk) { } @@ -236,6 +243,22 @@ abi_long do_freebsd_syscall(void *cpu_env, int num, ab= i_long arg1, ret =3D do_bsd_readv(arg1, arg2, arg3); break; =20 + case TARGET_FREEBSD_NR_write: /* write(2) */ + ret =3D do_bsd_write(arg1, arg2, arg3); + break; + + case TARGET_FREEBSD_NR_pwrite: /* pwrite(2) */ + ret =3D do_bsd_pwrite(cpu_env, arg1, arg2, arg3, arg4, arg5, arg6); + break; + + case TARGET_FREEBSD_NR_writev: /* writev(2) */ + ret =3D do_bsd_writev(arg1, arg2, arg3); + break; + + case TARGET_FREEBSD_NR_pwritev: /* pwritev(2) */ + ret =3D do_bsd_pwritev(cpu_env, arg1, arg2, arg3, arg4, arg5, arg6= ); + break; + default: gemu_log("qemu: unsupported syscall: %d\n", num); ret =3D -TARGET_ENOSYS; --=20 2.33.1 From nobody Fri May 17 08:39:27 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1643718045195233.3809853994893; Tue, 1 Feb 2022 04:20:45 -0800 (PST) Received: from localhost ([::1]:37230 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nEs9M-0002aZ-BK for importer@patchew.org; Tue, 01 Feb 2022 07:20:44 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57290) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nEr7x-0005Jb-Rj for qemu-devel@nongnu.org; Tue, 01 Feb 2022 06:15:13 -0500 Received: from [2607:f8b0:4864:20::d2b] (port=46941 helo=mail-io1-xd2b.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nEr7w-0003oS-1J for qemu-devel@nongnu.org; Tue, 01 Feb 2022 06:15:13 -0500 Received: by mail-io1-xd2b.google.com with SMTP id e79so20649105iof.13 for ; Tue, 01 Feb 2022 03:15:11 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id w5sm13526852ilu.83.2022.02.01.03.15.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Feb 2022 03:15:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2gLbBpeV4+czyf27Fa2Bgm+gKfkQ9bODAt7Z8w6KPjk=; b=ItEZ5foxFulxLKp/HlQWk77pfqi3x1GUT6DC0G9QinlWh9B8eSCNeFGfDxTkAlLKQU mC9fFC0zozP5yZint7LdRMXL2yyrbAWyZp2HqEN46NdqWwI0EK4WpqWeyxeoDk2zg2/E PjE6FrOZvjoPTqmg1LS/BPEMmKQX+afwKQ6IIrMM0IdVY/tR1MA03RofSpYvCCo3qy78 nm9XijTe7XG3ZuSdi5MekIPTN9uO6wihzRT2k2A7hGh6dbpLwnEeyAKEmP6n3WI2zW1X y/yelNPdUi6Q1XW2f6iCiB5tKQedAlE9WqOqe/W1ePllesKyKj9ZRMCdd+97qDHvUiKK JnRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2gLbBpeV4+czyf27Fa2Bgm+gKfkQ9bODAt7Z8w6KPjk=; b=hZuZ277hPXnZUpiW0GeCNXTdD0VMp1b+dG1GrxlG/LRPtFr9RhS7Zwv6d5Abnxqw5G jcbuFDrltpwUon+C5etcfA/4e7qBjvWmeFk7cMBLQWoJFZ6S2znMBl+tFQTP+2WXXERv 4By5ciMZ52wJwXf3e+b3j0uTAwl24FWjPKiBwatxyxZF6gLmyELz4aaFYKZWGHT3BTQS atkinCjFNuOii/1lxi6777sZlwaHwGq3/qtZkieThmKqo4B+re+xWtXSevfLkgTcE800 PDaUGFM3wRC059P7XKdOlkjGhX1Nw5clPhL7z/WBRCIeSvCk04GTZhswl8M7V16kiEGm ghfg== X-Gm-Message-State: AOAM533KxcbgowB2DBpIj/07xFYuQ9YR5hYcfF5vM/cW1VKC8GCQ/vXU 6+8X57aFJDt04osQGxS19wdeO6fqSyat3g== X-Google-Smtp-Source: ABdhPJyoxrBdwXHZz0ADOLLjTKnj8xtfCc2XT7Kbp5dSQbKscgaoD/WrPajHKhGiyNBB32TMRAj+ng== X-Received: by 2002:a6b:8e89:: with SMTP id q131mr13457264iod.77.1643714110639; Tue, 01 Feb 2022 03:15:10 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH 22/22] bsd-user/freebsd/os-syscall.c: Implement exit Date: Tue, 1 Feb 2022 04:14:55 -0700 Message-Id: <20220201111455.52511-23-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220201111455.52511-1-imp@bsdimp.com> References: <20220201111455.52511-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::d2b (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::d2b; envelope-from=imp@bsdimp.com; helo=mail-io1-xd2b.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Stacey Son , arrowd@FreeBSD.org, Kyle Evans , Richard Henderson , def@FreeBSD.org, jrtc27@FreeBSD.org, Warner Losh , Brad Smith Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1643718048665100001 Content-Type: text/plain; charset="utf-8" Implement the exit system call. Bring in bsd-proc.h to contain all the process system call implementation and helper routines. Signed-off-by: Stacey Son Signed-off-by: Warner Losh Reviewed-by: Kyle Evans Reviewed-by: Richard Henderson --- bsd-user/bsd-proc.h | 43 +++++++++++++++++++++++++++++++++++ bsd-user/freebsd/os-syscall.c | 7 ++++++ 2 files changed, 50 insertions(+) create mode 100644 bsd-user/bsd-proc.h diff --git a/bsd-user/bsd-proc.h b/bsd-user/bsd-proc.h new file mode 100644 index 00000000000..8f0b6990d14 --- /dev/null +++ b/bsd-user/bsd-proc.h @@ -0,0 +1,43 @@ +/* + * process related system call shims and definitions + * + * Copyright (c) 2013-2014 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_PROC_H_ +#define BSD_PROC_H_ + +#include +#include +#include +#include +#include + +/* exit(2) */ +static inline abi_long do_bsd_exit(void *cpu_env, abi_long arg1) +{ +#ifdef TARGET_GPROF + _mcleanup(); +#endif + gdb_exit(arg1); + qemu_plugin_user_exit(); + /* XXX: should free thread stack and CPU env here */ + _exit(arg1); + + return 0; +} + +#endif /* !BSD_PROC_H_ */ diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index f52c9e3c306..f66b6a1b1f5 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -41,6 +41,7 @@ #include "user/syscall-trace.h" =20 #include "bsd-file.h" +#include "bsd-proc.h" =20 /* I/O */ safe_syscall3(ssize_t, read, int, fd, void *, buf, size_t, nbytes); @@ -227,6 +228,12 @@ abi_long do_freebsd_syscall(void *cpu_env, int num, ab= i_long arg1, } =20 switch (num) { + /* + * process system calls + */ + case TARGET_FREEBSD_NR_exit: /* exit(2) */ + ret =3D do_bsd_exit(cpu_env, arg1); + break; =20 /* * File system calls. --=20 2.33.1