From nobody Mon Feb 9 10:28:37 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1654633059; cv=none; d=zohomail.com; s=zohoarc; b=T0Ur9kVrVvAwPyB1aB/Aa4DQZfvK14dNtSPwbzm4xYINIVBeh9+zP+Ne2EQAlIltV6XHMZXFnNZRDDcd0kiotwY/znkP520/3wf58tJvmVLYcDb6AAacKXhAcxmDtRYXXGAPUWR4XkPYVee7QszuJ5Tig0zu/Y3JYLNFoqNU6FM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654633059; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=9VcXAAhXPRGN/o3HNZi64xOmTmhdRIXzGdmeZM9kuwk=; b=XICAC8iGyhPQN39FUUofTc6mAS6pDQZdtXBkug/IyqrmYtjZNtopznIrRbdLmGidUdwec6Iyr30pE5pW7Eegx7UUs32MFf2h0QLHPEqf9ZooxfeC65oic2gpHbrWVsCYLRwhQgiV5i5jejGf/S4yEkBb0+iLUKKpS5JwGbmyt80= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16546330594167.464156908308837; Tue, 7 Jun 2022 13:17:39 -0700 (PDT) Received: from localhost ([::1]:47892 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nyfdx-0001Sp-HM for importer@patchew.org; Tue, 07 Jun 2022 16:17:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57576) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nyfb4-00063c-SF for qemu-devel@nongnu.org; Tue, 07 Jun 2022 16:14:38 -0400 Received: from mail-il1-x129.google.com ([2607:f8b0:4864:20::129]:42883) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nyfb3-0004N8-1r for qemu-devel@nongnu.org; Tue, 07 Jun 2022 16:14:38 -0400 Received: by mail-il1-x129.google.com with SMTP id p1so15065114ilj.9 for ; Tue, 07 Jun 2022 13:14:36 -0700 (PDT) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id cp5-20020a056638480500b0032ea3ba170dsm7053024jab.86.2022.06.07.13.14.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 13:14:34 -0700 (PDT) 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=9VcXAAhXPRGN/o3HNZi64xOmTmhdRIXzGdmeZM9kuwk=; b=SCAmuQu6CHhpeQmEENfapPCOyjA1qLXyDcY23LjJAN2y/3FcOgXuUUOZBknEPHt/bf 5/9/KqJlvWWoEwm5MDtESy/X5hbc0COB5cKr/+599Og+WvESnK0FeeWWmM37JasswcmC bl5Bm7puVn9Q0glXhTfLJR8OHe1VbPGF8iwigBQPoj61y31WXTQyJ9GOwBJdOOEgPlH8 f0AWDvaL1QO2vQMxdDl4lV5Wunlnht5Tk4VVQsPiqa+4402pb2Rb6QPJljA8OAoFF2lK o29i1nqjAD51QOEBnG7QAUw0GyevvJ0BnSx6egliz27v3bdInEp9p30sMM2qvyL7aDWW MKlA== 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=9VcXAAhXPRGN/o3HNZi64xOmTmhdRIXzGdmeZM9kuwk=; b=CtI+E8rS2s24b9y++LuAgUKx5psV9tUz9GwsiDi2IRsslDX3o1ZJOIk6eF0ad1JTAW kfwRh1Mvw6GxfZYOQTHUAymYu36e1tJ2cv2ARV9biRoJqr29OycF/V+FXvFfgTY0qFmm 9toE0Na6HCrw+XV/gdsYAKWtiFs/o5qEXHJipA7XrUrNk3O2Q7eso7i49ReAIX3ILHLp umhs3Un7fMJ/t3FiXPW/oAcvaWv4GwsGq+N1ot9pTlzNr+MlNrrHcPhl+q3hTokNIdGx 8S51UXFtKi4b7CTWw62XtQGMRPlKuMuo55ydvIflrgSonOx2z52C+ShTSzKnAe1ZT9Rz EYdw== X-Gm-Message-State: AOAM533gUACtBpvKi/syVtPaLGXvbXIBchG5sKmCAv4Q+nvD9xfWZyC0 YQ5wcxHSIYoVb9ESjk6krX58hSKAR+wGTw== X-Google-Smtp-Source: ABdhPJw0Z7HlktlqX4qb9W28xW199wGG3Jk/yTL4Eu3e7mPkGgVMHmu2ogSPHdqXGP/pQaMT/rC6Qg== X-Received: by 2002:a05:6e02:8ae:b0:2c7:90a5:90b8 with SMTP id a14-20020a056e0208ae00b002c790a590b8mr18452104ilt.19.1654632875546; Tue, 07 Jun 2022 13:14:35 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: arrowd@freebsd.org, def@freebsd.org, jrtc27@FreeBSD.org, Warner Losh , Kyle Evans Subject: [PATCH 3/6] bsd-user/freebsd/os-syscall.c: Tracing and error boilerplate Date: Tue, 7 Jun 2022 14:14:37 -0600 Message-Id: <20220607201440.41464-4-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220607201440.41464-1-imp@bsdimp.com> References: <20220607201440.41464-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::129; envelope-from=imp@bsdimp.com; helo=mail-il1-x129.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @bsdimp-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1654633060541100001 Content-Type: text/plain; charset="utf-8" Add in the tracing and this system call not implemented boilerplate. Do this by moving the guts of do_freebsd_syscall to freebsd_syscall. Put the tracing in the wrapper function. Since freebsd_syscall is a singleton static function, it will almost certainly be inlined. Fix comments that referred to do_syscall since that was renamed some tie ago. Signed-off-by: Warner Losh Reviewed-by: Richard Henderson --- bsd-user/freebsd/os-syscall.c | 50 ++++++++++++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 4 deletions(-) diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index 510307f29d9..334c573739b 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -201,16 +201,58 @@ void unlock_iovec(struct iovec *vec, abi_ulong target= _addr, } =20 /* - * 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_. + * All errnos that freebsd_syscall() returns must be -TARGET_. + */ +static abi_long freebsd_syscall(void *cpu_env, int num, abi_long arg1, + abi_long arg2, abi_long arg3, abi_long arg= 4, + abi_long arg5, abi_long arg6, abi_long arg= 7, + abi_long arg8) +{ + abi_long ret; + + switch (num) { + default: + gemu_log("qemu: unsupported syscall: %d\n", num); + ret =3D -TARGET_ENOSYS; + break; + } + + return ret; +} + +/* + * do_freebsd_syscall() should always have a single exit point at the end = so + * that actions, such as logging of syscall results, can be performed. This + * as a wrapper around freebsd_syscall() so that actually happens. Since + * that is a singleton, modern compilers will inline it anyway... */ 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; + CPUState *cpu =3D env_cpu(cpu_env); + int 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); + } + + ret =3D freebsd_syscall(cpu_env, num, arg1, arg2, arg3, arg4, arg5, ar= g6, + arg7, arg8); +#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