From nobody Fri May 17 07:47:25 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1676334520; cv=none; d=zohomail.com; s=zohoarc; b=QqtWXtcwH1OY9zK3DljAZTaVsCXIzRp7TRDUO8Lb8FsFrQjcKQIiFPyj4v0fScyFNrKj86AcEAPu2O3fBgwpIaldsDtqSdMsnUPJuxq5Bdl1Teijm/At700CwwSwOvSPYKIRAXtZIpe6TESOtW6xBkaKMI+GPdKUmFGOiiE5fb4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676334520; 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=v82U4AeojucC3DQqhT5F05E7FmGdLYXG/H9YwykhwGc=; b=aUdN+SNWXO1FpMpF2prnzPb3G/F/Pp8jB0gRoLH0d2BPKvG7Tz4oEO0zKXVux3Mp1PfWKiwYb3XPWhyXSBtKwNdD+nnBCrUzjEWwu/tV1w3FDvjSRp7c2+vvM+ZZrHzhTmdXUN83hefiixQStaeF0iDfCXeUenV4zpvMZlq9nog= 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 1676334519992704.8926643018806; Mon, 13 Feb 2023 16:28:39 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pRjB0-0007Md-OD; Mon, 13 Feb 2023 19:28:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pRjAz-0007MF-Ge for qemu-devel@nongnu.org; Mon, 13 Feb 2023 19:28:05 -0500 Received: from mail-io1-xd34.google.com ([2607:f8b0:4864:20::d34]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pRjAx-0005yV-9v for qemu-devel@nongnu.org; Mon, 13 Feb 2023 19:28:04 -0500 Received: by mail-io1-xd34.google.com with SMTP id j17so5166953ioa.9 for ; Mon, 13 Feb 2023 16:28:02 -0800 (PST) Received: from dune.bsdimp.com (c-71-237-47-177.hsd1.co.comcast.net. [71.237.47.177]) by smtp.gmail.com with ESMTPSA id r17-20020a028811000000b003af4300d670sm4500923jai.27.2023.02.13.16.28.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Feb 2023 16:28:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=v82U4AeojucC3DQqhT5F05E7FmGdLYXG/H9YwykhwGc=; b=G9f82TVBnS8C8IYlQ6i1v7CLsB/lkOXnmH9ZYOme/UdqLotS2CoRDtUcxiMEDhdhPq UziTqt8yac02lvn+bgbUWDRQxvyPL6XhSG3LDob5SRQLQxyJK08Gym4AKkJHZUQpKQqv jJHKkmUkLSsoIrB4MoXU3HN7kBk38Q21v77BBb7lY1ewZmYy7/YxWqe6Q0h2dFW+k+Kw WwIovcCaX6YZn2nexVDtgdYEJOJs7lwfr4DSPzbYee+rXtchmYNxhsbbpbyOSZ58yjfk bK3bDHI/L/x8vIyPIiSaoXZD/e0RlnywO4QQEg0rmToLuoMfk0uz/8yGLNOhOFSo5mxk hCdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=v82U4AeojucC3DQqhT5F05E7FmGdLYXG/H9YwykhwGc=; b=aKYxgmvtMDrjHnDq0PW+c/wMJvDLZWR8JWHydouz0CVqatbzPh0o/PkXxNUQNGodPx JNJvYpp8eYzmJkXSJfLM1EEUy8vRavkSbO9DPoqCo8A1flVmBiF1iMmyeLXGz6EOWTSp yIi3fWXPeMiM44hnZrlf5XB/2j+pfQgkkBNCC/ZA4qf/Ab0hI7cMkXvUipW5dtXht1eY yoAGQQag3ETb7l3VtPm6JNHNwfdkmewXDbEdSg31NkFlxpJ+SDXzaGxirWLwgpz6sWU5 c0JNO/LVSl0JSfs1d18uO7MU2t1uSomRhfMnRAz62ESr2MZoX6GP5sWQexpHePYlZmg8 or1A== X-Gm-Message-State: AO0yUKWd/Oozvhgqu1SjUVKBMeDCkVaxLRhKy/05AMUcB8zYKPvnZ52V ts0ux7xbJbLYPYLPmhvd6Mn19tslatBCleG0 X-Google-Smtp-Source: AK7set99Ybnb06IanBJXuVgq/vw5r1IaAenrXthhJRxTuFiaRIL0u8BAgBanGbpLDKgPGgV++/05uQ== X-Received: by 2002:a5e:a80b:0:b0:715:ba8c:3b14 with SMTP id c11-20020a5ea80b000000b00715ba8c3b14mr292304ioa.12.1676334481582; Mon, 13 Feb 2023 16:28:01 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Warner Losh , richard.henderson@linaro.org, Paolo Bonzini , kevans@freebsd.org, f4bug@amsat.org, Thomas Huth , Doug Rabson Subject: [PATCH v2 01/12] bsd-user: Don't truncate the return value from freebsd_syscall Date: Mon, 13 Feb 2023 17:27:46 -0700 Message-Id: <20230214002757.99240-2-imp@bsdimp.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230214002757.99240-1-imp@bsdimp.com> References: <20230214002757.99240-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::d34; envelope-from=imp@bsdimp.com; helo=mail-io1-xd34.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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @bsdimp-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1676334521222100007 Content-Type: text/plain; charset="utf-8" From: Doug Rabson System call return values on FreeBSD are in a register (which is spelled abi_long in qemu). This was being assigned into an int variable which causes problems for 64bit targets. Resolves: https://github.com/qemu-bsd-user/qemu-bsd-user/issues/40 Signed-off-by: Doug Rabson Reviewed-by: Warner Losh [ Edited commit message for upstreaming into qemu-project ] Signed-off-by: Warner Losh Reviewed-by: Richard Henderson --- bsd-user/freebsd/os-syscall.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index 57996cad8ae..b4a663fc021 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -512,7 +512,7 @@ abi_long do_freebsd_syscall(void *cpu_env, int num, abi= _long arg1, abi_long arg8) { CPUState *cpu =3D env_cpu(cpu_env); - int ret; + abi_long ret; =20 trace_guest_user_syscall(cpu, num, arg1, arg2, arg3, arg4, arg5, arg6,= arg7, arg8); if (do_strace) { --=20 2.39.1 From nobody Fri May 17 07:47:25 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1676334600; cv=none; d=zohomail.com; s=zohoarc; b=EMf0bMqeBn6UH4koxlC1RY22ruLluBGfSL1YlSzuRwBoOdiBUjIW8Gsfxzyb89H++T0cZZN6VI3SWAAY1qZDpJjPfEcIbNAJwxR+ohnkFJcco+uG4+FLRQ0f9ZR1+dM9XbxPm90lIbt441/eZKKmN9OnRgC6YJ5Pdeyp/Ejn8Jc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676334600; 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=i/ho+o97t3oUvsCX6/tWPXAhBUu89VuwLZO+3r6EySU=; b=j01PwDGXxByeDn3q7YaQETRcazt4E7P7EUpPbAcP9qlFH9AP46CnZAHqEmfngeFb3gqbEy+e+Ukl87aZhZD2MdrV4KDU0kHs158QPzNNu6Ogx19GDIEOT+JpaR1Iwrg3Us3pD0f57q2ESh05OMbTotLPyyt1iKKhTeIXrVPwGQ8= 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 1676334600141427.05868520369654; Mon, 13 Feb 2023 16:30:00 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pRjB1-0007NN-Fx; Mon, 13 Feb 2023 19:28:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pRjB0-0007MV-5m for qemu-devel@nongnu.org; Mon, 13 Feb 2023 19:28:06 -0500 Received: from mail-io1-xd29.google.com ([2607:f8b0:4864:20::d29]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pRjAx-0005ye-TW for qemu-devel@nongnu.org; Mon, 13 Feb 2023 19:28:05 -0500 Received: by mail-io1-xd29.google.com with SMTP id y69so1871950iof.11 for ; Mon, 13 Feb 2023 16:28:03 -0800 (PST) Received: from dune.bsdimp.com (c-71-237-47-177.hsd1.co.comcast.net. [71.237.47.177]) by smtp.gmail.com with ESMTPSA id r17-20020a028811000000b003af4300d670sm4500923jai.27.2023.02.13.16.28.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Feb 2023 16:28:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=i/ho+o97t3oUvsCX6/tWPXAhBUu89VuwLZO+3r6EySU=; b=vOgRgkplx1/kNidtcE/bUUWayRPabmhs2XiKD5JZVtSOm8lWGpwtxtHhRChMSXfMCg fGZpMe0xo6MMVvqgnbhLpsB6iNzf35SuLPn1la8yILRJtNemaPMYUBt1FhcZuq4Jacj8 1aoncb71Xi1nqU3uN25yWTXPTUGUtgUBFNeMX4qdoiKd0wg5po/mKoV3W8S1HD7cHJIh FCbE5X83G8nWy/Djra1yQtKMonbQ94+XTFDodvWUiyGUHzHYI7EO7sPhtUMUJDT+jfTL EVXeyC8U2+UIjNPkS+Q75oBXkdeY6lnM0UwhU9cwxpkKJCUQRhI7AM4puBAoE7lA5QBb 3vVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=i/ho+o97t3oUvsCX6/tWPXAhBUu89VuwLZO+3r6EySU=; b=OCAk1p/u0dsgbGLaEgklYBcTnE3umQ1R4ISqV235ReCz61wBEFrPfLT3V3Eq/Vly1N 1gCikBq4HL5qsqto3i7ZI4tLbM6pio6ZZt3bvGFngzEwiy4uCDkOmjjBoddV2g3cSnvl g/Hhlg0lBay0kEQBounruFYKTxzKtv2FGQR9z3czIyjkgNMxT4XjLmNxBgHuO+q2vDO8 rUKmzBG39vz1wNHXYlD1Oh8f+7BhPGmSDGrkK8gelokLLMRZx5KDqLlg6RYn3HgnbT5x EQYVXMmMXEbf+uSW6a0VJ8Z4R/yQfpTOI2nn39/7C4e9UZcSwmIs2TrfzaCUB7W/6Xj8 Xjyw== X-Gm-Message-State: AO0yUKUASYB1X5XB7n60gQ4hh82wq/zei57+r7B+ynMM2/yU9q7Xt+/D dPJkY069JDJ2WrKAJYE0jZbT0GEGhRO1jLzM X-Google-Smtp-Source: AK7set8oZvbj/RPCA0O6mXMFYkdWlSAumpKuaf8UHaGgBrO8mBdpROo2zoDuKxihBygb774fWxs4Qw== X-Received: by 2002:a05:6602:11:b0:73a:4169:1178 with SMTP id b17-20020a056602001100b0073a41691178mr285667ioa.14.1676334482512; Mon, 13 Feb 2023 16:28:02 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Warner Losh , richard.henderson@linaro.org, Paolo Bonzini , kevans@freebsd.org, f4bug@amsat.org, Thomas Huth Subject: [PATCH v2 02/12] build: Don't specify -no-pie for --static user-mode programs Date: Mon, 13 Feb 2023 17:27:47 -0700 Message-Id: <20230214002757.99240-3-imp@bsdimp.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230214002757.99240-1-imp@bsdimp.com> References: <20230214002757.99240-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::d29; envelope-from=imp@bsdimp.com; helo=mail-io1-xd29.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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @bsdimp-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1676334601217100003 Content-Type: text/plain; charset="utf-8" When building with clang, -no-pie gives a warning on every single build, so remove it. Signed-off-by: Warner Losh --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index 64960c6000f..eb284ccf308 100755 --- a/configure +++ b/configure @@ -1313,7 +1313,7 @@ if test "$static" =3D "yes"; then error_exit "-static-pie not available due to missing toolchain support" else pie=3D"no" - QEMU_CFLAGS=3D"-fno-pie -no-pie $QEMU_CFLAGS" + QEMU_CFLAGS=3D"-fno-pie $QEMU_CFLAGS" fi elif test "$pie" =3D "no"; then if compile_prog "-Werror -fno-pie" "-no-pie"; then --=20 2.39.1 From nobody Fri May 17 07:47:25 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1676334583; cv=none; d=zohomail.com; s=zohoarc; b=aFcx9VYA5w2SLYEbfPIjNgFd0CuHM1G+MV36pt+x4rtMoJFDpxi9v6L4cwvysrJ5kASr8gN+SZX/A/vnlgM8HoPxXVhVIHRD/kOCxFholZph7QeiKvEFc87BHSUtN3eDHvZ6M4GQI1VGyK1qHdp6cbqx4GTN7j430d+V0VI9aVk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676334583; 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=UDKo+pEqLr25ECZFRWghhYmC5CZ9G4l3ZCThpSQaZZ4=; b=jMJoyMYkooNuOloJf767Z8U/R10Qnx2htdmcIFpbRarDMD3fIVzip+h0vraSGf8Pgb43ZzmJCVOYNvFvJx/U6AVHD05rOgOR3sl8ydMNGwlt6d5pOot0qCjeNnH5H5H355k3qVSun/yYgsJAW4ejDHOkwpIBDUr1UhkEKCV1c6k= 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 1676334583490225.16805155823624; Mon, 13 Feb 2023 16:29:43 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pRjB2-0007Nk-Dc; Mon, 13 Feb 2023 19:28:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pRjB0-0007N9-SO for qemu-devel@nongnu.org; Mon, 13 Feb 2023 19:28:06 -0500 Received: from mail-io1-xd2a.google.com ([2607:f8b0:4864:20::d2a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pRjAz-0005ym-Ah for qemu-devel@nongnu.org; Mon, 13 Feb 2023 19:28:06 -0500 Received: by mail-io1-xd2a.google.com with SMTP id z5so2474340iow.1 for ; Mon, 13 Feb 2023 16:28:05 -0800 (PST) Received: from dune.bsdimp.com (c-71-237-47-177.hsd1.co.comcast.net. [71.237.47.177]) by smtp.gmail.com with ESMTPSA id r17-20020a028811000000b003af4300d670sm4500923jai.27.2023.02.13.16.28.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Feb 2023 16:28:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=UDKo+pEqLr25ECZFRWghhYmC5CZ9G4l3ZCThpSQaZZ4=; b=HgZdSEPf5Jr0RZKiV3bQOAPEdiCXdjZKhDOiK4TMGMs+1cxNWEpcjud0jN13yaa5QW 4kuHtKhNmFweDoMoTASZpWJRG+5f5xnT897lxm9eZXwi6nVdVaSgq4bD7vsFXqO5d5wt QsJUGpbOTgTm8VvaQJ6vQcEcBG4DM/ElXeDLh61USEYQJuPMvcYrj15qoNlzgLgxXq/o rSTtLvyNOTg31pLsMU6IZRjHKD0XHUk0kjHpBtc7HJVuoJNiFYryP1wNJVa/sImqMY+H zfB8tTrwKKBfHIjGTSrw65gwAS4Ght6GaBcRhX74rtbZPKqBoDXk/A+5jzNup5htjrPB Ae0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UDKo+pEqLr25ECZFRWghhYmC5CZ9G4l3ZCThpSQaZZ4=; b=t81aHhEi2+I7VwKgvVFq5meWxEJEKgQR7RET7xtOpg3QzqwX4W0++5+b9hKd7OXprt FHge4GwMu7zHLBqmqC97EFiR7CgfNmVjuIr22d6vFIwVnbRVF/QyAf0A0ghJ9pSKAm6l 9FFv9DnGvga8Ug0LuGr5Q7X5jN1Hv0dqNGMzkR29A6/wZyeBdoVC5KEWqxXqfs3CvKaz 5lwK6JHEKD0brHi21LCoAsJ6LunKCVMCq5vSDVfhOa0y0KE8gpAXbmLDIQkIcKxmkWat xJPFPgEBqOkKS7fADKDsG2TV6QRFp86rDgErrauOwDV2wPviSoLrRkC3WATQmzX4Kg4B kDBA== X-Gm-Message-State: AO0yUKVPsoyIMjcU3ypauFWhKGsVBe8YOEHZ8UzdB55su8EYNs+8aHgM 91bA2uO+plHGstJRxRozwpyjA2njsqh9ydGP X-Google-Smtp-Source: AK7set9W4Hc90g8iFa8+u8EV6BsHjEh4nOFribD1bqRt4aI+4VmQYo91XyuUEmoPqImaAc0g8lfKHg== X-Received: by 2002:a5e:c816:0:b0:73a:69e3:64c8 with SMTP id y22-20020a5ec816000000b0073a69e364c8mr316640iol.9.1676334483786; Mon, 13 Feb 2023 16:28:03 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Warner Losh , richard.henderson@linaro.org, Paolo Bonzini , kevans@freebsd.org, f4bug@amsat.org, Thomas Huth , Stacey Son , Juergen Lock Subject: [PATCH v2 03/12] bsd-user: Add sysarch syscall Date: Mon, 13 Feb 2023 17:27:48 -0700 Message-Id: <20230214002757.99240-4-imp@bsdimp.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230214002757.99240-1-imp@bsdimp.com> References: <20230214002757.99240-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::d2a; envelope-from=imp@bsdimp.com; helo=mail-io1-xd2a.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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @bsdimp-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1676334585208100003 Content-Type: text/plain; charset="utf-8" From: Stacey Son Connect up the sysarch system call. Signed-off-by: Juergen Lock Co-authored-by: Juergen Lock Signed-off-by: Stacey Son Reviewed-by: Warner Losh Signed-off-by: Warner Losh Reviewed-by: Richard Henderson --- bsd-user/freebsd/os-syscall.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index b4a663fc021..e00997a818c 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -491,6 +491,13 @@ static abi_long freebsd_syscall(void *cpu_env, int num= , abi_long arg1, ret =3D do_bsd_undelete(arg1); break; =20 + /* + * sys{ctl, arch, call} + */ + case TARGET_FREEBSD_NR_sysarch: /* sysarch(2) */ + ret =3D do_freebsd_sysarch(cpu_env, arg1, arg2); + break; + default: qemu_log_mask(LOG_UNIMP, "Unsupported syscall: %d\n", num); ret =3D -TARGET_ENOSYS; --=20 2.39.1 From nobody Fri May 17 07:47:25 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1676334541; cv=none; d=zohomail.com; s=zohoarc; b=JzcJZw4alUePrpu6ro40Abx5lnghl+GUXg1r1FDwO8qs4NFwMMw1cOnPnfXyTZ8ouBCfpZvNZOMoOPoXpbA2Xyuk6QY/WHPgM9J1uD7AqA25O+r/9hP2Hy6xwAVjacFYS/2dWGeLTB09sNUnBkHQ1qvGkjrlDAHJLshvkKgfZd4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676334541; 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=E52lvXAV4jnwfoAfchHD4x98Su75UpFmWttI3qxLtLo=; b=hvVVHwP5KTo7gNeRTaf6oSw2P6THl0JYzmr+svg+4Easiiss0sxL8Lgx+6Nr6b6Phb+97figg5mhXkdvfqFQXsTg7RmUHRek/RtBTiRdV+Ni+o9sPLiqwagXJM+lpoPLxBKD5t7m5AKkZzZ708DbiLWCRKueziSI3s2Gl1IG42g= 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 1676334541557244.16779208124342; Mon, 13 Feb 2023 16:29:01 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pRjB4-0007PD-4u; Mon, 13 Feb 2023 19:28:10 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pRjB2-0007Nc-3Q for qemu-devel@nongnu.org; Mon, 13 Feb 2023 19:28:08 -0500 Received: from mail-il1-x131.google.com ([2607:f8b0:4864:20::131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pRjB0-0005z7-BG for qemu-devel@nongnu.org; Mon, 13 Feb 2023 19:28:07 -0500 Received: by mail-il1-x131.google.com with SMTP id v13so4271526iln.4 for ; Mon, 13 Feb 2023 16:28:05 -0800 (PST) Received: from dune.bsdimp.com (c-71-237-47-177.hsd1.co.comcast.net. [71.237.47.177]) by smtp.gmail.com with ESMTPSA id r17-20020a028811000000b003af4300d670sm4500923jai.27.2023.02.13.16.28.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Feb 2023 16:28:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=E52lvXAV4jnwfoAfchHD4x98Su75UpFmWttI3qxLtLo=; b=DCyI9q6pqmi6cmGnlY+UyuMxUfjpu0dq9YMpCDxW0iU3/OJnYsu5JCMnBy7AAZcuE/ 1TdB4oOv7qNHkNBsGjUQ2qqvgnL5uC2xMcp0wihE0KRyIeVmLX1plJsbLditJFKT1FzZ jNSLnRMR/UiIDDgvA4D3eibj0FyCXYsWbQJRtn2R+os0EaJmow0Tx3yNQG8ceH1GdgO7 cEiYmSrbuQif2aCTfUIwEzULhLwhQ7m2guyE2oxky3eZfrLhUmAheeq96YV1xKvCd5jV dHbsGiIAfmUosPXEZClxbiRJH2d0BjYaK6P1UqoEgOQ2vAQCt7fNN88lCEjyMSPitFT5 C+fA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=E52lvXAV4jnwfoAfchHD4x98Su75UpFmWttI3qxLtLo=; b=1hboE+CpT8uZttsWihL1OA9DG04Le8HUfdZRUSh3+bck8h40+e1Gx+DT4WBA4e/eBS nvtTrp8iPZykiixao3VxLSVI+suHIxZ+XErSzLPS7BB15D01WB1QXMEjXtefkCN3r0Ps cQWgMaXlvSYVDmy6Tp2cwUx2YZaeiEqBBlBKdKfLT+51sMMZ7DcDok4GGFJls9mEWGt3 d4/yc/qr3diOKwNQRjVIl/Ylv6DIYtYKQvO/OjhqafJ+v2yt0Ud/YfnM3TxV3hYhumw2 N1YExk5DLFiQ/Xn5xrauWN9jl31RmxH8C6UWmk/Axm2izypsG7B2+KpuI1xOHUdjCQ9/ 9oag== X-Gm-Message-State: AO0yUKWsAUnjbhJlABJmRE2YPwyboMpoxSV5/YS5Fz3frhD02Tr1uYYi VbfV0L9wBqy6YZ8IWtTssVov/nBqeMB5fm9X X-Google-Smtp-Source: AK7set/1cCT2of1ilRyYrvjO66yLSU/c3FPH1vnfhr/+h8MCeN9inuSvizeiNJ9Qj3Z8A5EefLP3aw== X-Received: by 2002:a05:6e02:144b:b0:313:e126:180 with SMTP id p11-20020a056e02144b00b00313e1260180mr804597ilo.0.1676334484845; Mon, 13 Feb 2023 16:28:04 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Warner Losh , richard.henderson@linaro.org, Paolo Bonzini , kevans@freebsd.org, f4bug@amsat.org, Thomas Huth Subject: [PATCH v2 04/12] bsd-user: various helper routines for sysctl Date: Mon, 13 Feb 2023 17:27:49 -0700 Message-Id: <20230214002757.99240-5-imp@bsdimp.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230214002757.99240-1-imp@bsdimp.com> References: <20230214002757.99240-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::131; envelope-from=imp@bsdimp.com; helo=mail-il1-x131.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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @bsdimp-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1676334543238100003 Content-Type: text/plain; charset="utf-8" cap_memory - Caps the memory to just below MAXINT scale_to_target_pages - Account for difference in host / targe page size h2t_long_sat - converts a int64_t to a int32_t, saturating at max / min val= ues h2t_ulong_sat - converts a uint64_t to a uint32_t, saturating at max value Signed-off-by: Warner Losh --- bsd-user/freebsd/os-sys.c | 100 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) diff --git a/bsd-user/freebsd/os-sys.c b/bsd-user/freebsd/os-sys.c index 1676ec10f83..cfbc4148a5c 100644 --- a/bsd-user/freebsd/os-sys.c +++ b/bsd-user/freebsd/os-sys.c @@ -21,6 +21,106 @@ #include "qemu.h" #include "target_arch_sysarch.h" =20 +#include + +/* + * Length for the fixed length types. + * 0 means variable length for strings and structures + * Compare with sys/kern_sysctl.c ctl_size + * Note: Not all types appear to be used in-tree. + */ +static const int G_GNUC_UNUSED target_ctl_size[CTLTYPE+1] =3D { + [CTLTYPE_INT] =3D sizeof(abi_int), + [CTLTYPE_UINT] =3D sizeof(abi_uint), + [CTLTYPE_LONG] =3D sizeof(abi_long), + [CTLTYPE_ULONG] =3D sizeof(abi_ulong), + [CTLTYPE_S8] =3D sizeof(int8_t), + [CTLTYPE_S16] =3D sizeof(int16_t), + [CTLTYPE_S32] =3D sizeof(int32_t), + [CTLTYPE_S64] =3D sizeof(int64_t), + [CTLTYPE_U8] =3D sizeof(uint8_t), + [CTLTYPE_U16] =3D sizeof(uint16_t), + [CTLTYPE_U32] =3D sizeof(uint32_t), + [CTLTYPE_U64] =3D sizeof(uint64_t), +}; + +static const int G_GNUC_UNUSED host_ctl_size[CTLTYPE+1] =3D { + [CTLTYPE_INT] =3D sizeof(int), + [CTLTYPE_UINT] =3D sizeof(u_int), + [CTLTYPE_LONG] =3D sizeof(long), + [CTLTYPE_ULONG] =3D sizeof(u_long), + [CTLTYPE_S8] =3D sizeof(int8_t), + [CTLTYPE_S16] =3D sizeof(int16_t), + [CTLTYPE_S32] =3D sizeof(int32_t), + [CTLTYPE_S64] =3D sizeof(int64_t), + [CTLTYPE_U8] =3D sizeof(uint8_t), + [CTLTYPE_U16] =3D sizeof(uint16_t), + [CTLTYPE_U32] =3D sizeof(uint32_t), + [CTLTYPE_U64] =3D sizeof(uint64_t), +}; + +#ifdef TARGET_ABI32 +/* + * Limit the amount of available memory to be most of the 32-bit address + * space. 0x100c000 was arrived at through trial and error as a good + * definition of 'most'. + */ +static const abi_ulong target_max_mem =3D UINT32_MAX - 0x100c000 + 1; + +static abi_ulong G_GNUC_UNUSED cap_memory(uint64_t mem) +{ + if (((unsigned long)target_max_mem) < mem) { + mem =3D target_max_mem; + } + + return mem; +} +#endif + +static unsigned long host_page_size; + +static abi_ulong G_GNUC_UNUSED scale_to_target_pages(uint64_t pages) +{ + if (host_page_size =3D=3D 0) { + host_page_size =3D getpagesize(); + } + + pages =3D muldiv64(pages, host_page_size, TARGET_PAGE_SIZE); +#ifdef TARGET_ABI32 + abi_ulong maxpages =3D target_max_mem / (abi_ulong)TARGET_PAGE_SIZE; + + if (((unsigned long)maxpages) < pages) { + pages =3D maxpages; + } +#endif + return pages; +} + +#ifdef TARGET_ABI32 +static abi_long G_GNUC_UNUSED h2t_long_sat(long l) +{ + if (l > INT32_MAX) { + l =3D INT32_MAX; + } else if (l < INT32_MIN) { + l =3D INT32_MIN; + } + return l; +} + +static abi_ulong G_GNUC_UNUSED h2t_ulong_sat(u_long ul) +{ + if (ul > UINT32_MAX) { + ul =3D UINT32_MAX; + } + return ul; +} +#endif + +/* + * placeholder until bsd-user downstream upstreams this with its thread su= pport + */ +#define bsd_get_ncpu() 1 + /* sysarch() is architecture dependent. */ abi_long do_freebsd_sysarch(void *cpu_env, abi_long arg1, abi_long arg2) { --=20 2.39.1 From nobody Fri May 17 07:47:25 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1676334519; cv=none; d=zohomail.com; s=zohoarc; b=ZMONxQg7X/z0yvxzcS2iGa6kh9ngVQa2nME1xBRTtdzROX1yxKyMfMhCvVToM5q9frA78DLqt2JNk4PRj5TT+Y/b9R4G1mjHWEyPZ633IF/bZYf6eD8bqEACZdD1JmwNBhiJPexkHLj1BsGUNB5kfZvFxJsbzjAOfXIHUWc21o8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676334519; 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=Tpsd+qPEZMPPulUs11wAtZGcRw5OGIAw6bgvDX5oXa0=; b=iwVKX7vp+4GFR8qtRUQ1QNJnFy6emXzzd5GmjaCUmvTISJFtiOSpsYQmNUmjU3M+lSvaeSxEo4zgxlZM0Pxk9I2K3cvaZn2VUf+gXMOfqLgILNBGDeNe84KcS9wA8zSOPZplBjAJN9QMUAxzvUyv0yPQsEH8PILVgvSMTyBMkBI= 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 1676334519877503.3422353887487; Mon, 13 Feb 2023 16:28:39 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pRjB4-0007QE-Cb; Mon, 13 Feb 2023 19:28:10 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pRjB2-0007No-SR for qemu-devel@nongnu.org; Mon, 13 Feb 2023 19:28:08 -0500 Received: from mail-il1-x12f.google.com ([2607:f8b0:4864:20::12f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pRjB1-0005zK-9b for qemu-devel@nongnu.org; Mon, 13 Feb 2023 19:28:08 -0500 Received: by mail-il1-x12f.google.com with SMTP id t7so4158663ilq.2 for ; Mon, 13 Feb 2023 16:28:06 -0800 (PST) Received: from dune.bsdimp.com (c-71-237-47-177.hsd1.co.comcast.net. [71.237.47.177]) by smtp.gmail.com with ESMTPSA id r17-20020a028811000000b003af4300d670sm4500923jai.27.2023.02.13.16.28.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Feb 2023 16:28:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Tpsd+qPEZMPPulUs11wAtZGcRw5OGIAw6bgvDX5oXa0=; b=OV0YxNb70V056H3ba24MdQ5SD47PKxSH+k4JUemLA2PCYFt3k/I87IVrIYEHQD3RDH skhZPbqK8Fb4Z6Z2GFtFnN1uvH2aFyW6SYhYmJTuEe7zi52xGwV8kuyuhMSjth923L3e LwwHLAAW9han377jk7Q4cqP0B1/PvgRt2re7aTXzJLSNZiFwsConWe61g1ctOwVFeRFF wRYmsmeTOs0UuW5Yq5CKqh4nSlQF3foXI/Aoqd3UcM9TphkBFZPUBaPT0jXjtrOzQr5R Z7sIwrMN3YB23OorsjNfIM1PuB8pg2z4Qxz8qVT49GCRtJNx3KmkiNKBuIZADiblFjq/ Ao1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Tpsd+qPEZMPPulUs11wAtZGcRw5OGIAw6bgvDX5oXa0=; b=DbEdh75JdYRrFja51ni/RWcR+j1tEixsy+HyrC0cRcaAheazSUSjsU2aCpc1znuaum 1MbMuheJx7GOtWzqk2Wbanyj3wTVaza4kvSMpImPTGSMxIrHFRztIp4cK9yE4f5eEs8T ATJpR6F20P3JSGE6n6WKYMO5FsDToSCNMHQ4E1evg3z/SLKeSMDPbpLAH+SzoXPYvZzM VRYhNskR3ksWdXW/GpXbcCCx9mc6DrLQlynXNHld63kTTjtNPsgDl0KAJZ/LDdVZhIUt lHYyLigJsAJdYmqgZTrIyoFeX0aoJ5PDe7CrX31hJhmdoaPXKsEhgJ2T2RMN4UUI5Fx8 Dlng== X-Gm-Message-State: AO0yUKX2WHHZP06vit8CYMM04dcqt2kV0rDIoWJ8x/uNR6Qp/tLQPnPg 1XK5gWqDwfAhi9DfSvYS1RzXhO0cJOCpqc17 X-Google-Smtp-Source: AK7set/tjzIu6OvArRxeYiFvDltnZOUw+OT6PT/gFwq4CVC1S4QKTNyosLTpNuhd1jpEOhDzCIerzw== X-Received: by 2002:a92:ca4d:0:b0:315:3d25:231b with SMTP id q13-20020a92ca4d000000b003153d25231bmr786309ilo.9.1676334485947; Mon, 13 Feb 2023 16:28:05 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Warner Losh , richard.henderson@linaro.org, Paolo Bonzini , kevans@freebsd.org, f4bug@amsat.org, Thomas Huth , Stacey Son , Sean Bruno , Juergen Lock , Raphael Kubo da Costa Subject: [PATCH v2 05/12] bsd-user: Helper routines oidfmt Date: Mon, 13 Feb 2023 17:27:50 -0700 Message-Id: <20230214002757.99240-6-imp@bsdimp.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230214002757.99240-1-imp@bsdimp.com> References: <20230214002757.99240-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::12f; envelope-from=imp@bsdimp.com; helo=mail-il1-x12f.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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @bsdimp-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1676334521225100008 Content-Type: text/plain; charset="utf-8" From: Stacey Son oidfmt uses undocumented system call to get the type of the sysctl. Co-Authored-by: Sean Bruno Signed-off-by: Sean Bruno Co-Authored-by: Juergen Lock Signed-off-by: Juergen Lock Co-Authored-by: Raphael Kubo da Costa Signed-off-by: Raphael Kubo da Costa Signed-off-by: Stacey Son Reviewed-by: Warner Losh Signed-off-by: Warner Losh Acked-by: Richard Henderson --- bsd-user/freebsd/os-sys.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/bsd-user/freebsd/os-sys.c b/bsd-user/freebsd/os-sys.c index cfbc4148a5c..1df53a3e53b 100644 --- a/bsd-user/freebsd/os-sys.c +++ b/bsd-user/freebsd/os-sys.c @@ -121,6 +121,38 @@ static abi_ulong G_GNUC_UNUSED h2t_ulong_sat(u_long ul) */ #define bsd_get_ncpu() 1 =20 +/* + * This uses the undocumented oidfmt interface to find the kind of a reque= sted + * sysctl, see /sys/kern/kern_sysctl.c:sysctl_sysctl_oidfmt() (compare to + * src/sbin/sysctl/sysctl.c) + */ +static int G_GNUC_UNUSED oidfmt(int *oid, int len, char *fmt, uint32_t *ki= nd) +{ + int qoid[CTL_MAXNAME + 2]; + uint8_t buf[BUFSIZ]; + int i; + size_t j; + + qoid[0] =3D CTL_SYSCTL; + qoid[1] =3D CTL_SYSCTL_OIDFMT; + 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; +} + /* sysarch() is architecture dependent. */ abi_long do_freebsd_sysarch(void *cpu_env, abi_long arg1, abi_long arg2) { --=20 2.39.1 From nobody Fri May 17 07:47:25 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1676334545; cv=none; d=zohomail.com; s=zohoarc; b=NP0zc3xCd4LFrLS62waLlZaozfJ6cHvFIK0jm1Ohol6YzerWJPhhP9w4mojoNWDarljg3pdpCsFqFS18RPXzASpYSTnBOLLnZUeXDQIHl4iJj0XRuH/frnvCDpRMKwVGRFKU2w12VSxQH1hyJdfdDpemjxVubvyEfl6B1tOG5zU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676334545; 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=oFq1eRvbniaQzSLu1dNAxUhkDZddT5JGCoR/msUAj9s=; b=UOQGRHkzOzioOEJ0RzXcVArOh2t9G3NbhCkt/XSJKlMeczsOK73RpeEW3Aild47M6/aNE74iFsmvTHsSMK27ZgaXTzhZhePzEQGuLUg13JhAV7rdWQ0cvN7Y4jF/1DmyCcrICyxuh7VrhSFMsTzzGeDhwee9vh/dFwJ6tzV2Kcw= 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 1676334545789768.8642797101503; Mon, 13 Feb 2023 16:29:05 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pRjBH-0007T2-Fn; Mon, 13 Feb 2023 19:28:23 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pRjB8-0007Rp-OA for qemu-devel@nongnu.org; Mon, 13 Feb 2023 19:28:14 -0500 Received: from mail-il1-x136.google.com ([2607:f8b0:4864:20::136]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pRjB6-000603-Sx for qemu-devel@nongnu.org; Mon, 13 Feb 2023 19:28:14 -0500 Received: by mail-il1-x136.google.com with SMTP id h29so4011135ila.8 for ; Mon, 13 Feb 2023 16:28:12 -0800 (PST) Received: from dune.bsdimp.com (c-71-237-47-177.hsd1.co.comcast.net. [71.237.47.177]) by smtp.gmail.com with ESMTPSA id r17-20020a028811000000b003af4300d670sm4500923jai.27.2023.02.13.16.28.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Feb 2023 16:28:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=oFq1eRvbniaQzSLu1dNAxUhkDZddT5JGCoR/msUAj9s=; b=f/b1E0eHKuM51WiWl/7D/yDGvSo3lApuDOEfXVhgZEUYLWKpJIyS1gNyMo/ulDJDF+ +Hkgeb01WMO5PgD4ClXPvK6NDd57pUiqkReXn0FN0wfOpmTuBqLhQYaXsvQ+EzNSlmNP RdTiSffrLW5GHkTN2mGWUnJIbETAgLcqSwtfsKMbLEnix/+OSSuLiKV9CZZBfZAzOQKx 60Q7mBah+gjnWUpSlBmIhtTekb6qQEDFy+JVlLm/xJFjyxQNqJxdgzaUreAMBJujJvwW DE5mMDKG32nwrXDYQNbrPdO4Pe4pvGcMK4Zskd+SRSlsjFp5pWer4aEq6jhQ6TpI6Si3 aeBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oFq1eRvbniaQzSLu1dNAxUhkDZddT5JGCoR/msUAj9s=; b=nUKKk4PR1LRNZT2FKuQDEVG+d24brR80hgvtOa//MoqgWxaIxlRyA6posoV3LkAoqK LILk2k/7gOzkJ1R+8O3/8xWMUzT3HBEBMMV405hD7TFRAc8jtVjZQv9qFS1mXGIvABi3 ir0GKMzjx2BbJCeCBJU0E+s0RtqV7mKglrZjPBtrXKTjfIsUIip70ksBxPn3scTbC37o D8RX8oweJGYZr8wcUrWW9bo2uT/n9aZfyV48WlAhphFExT+oClvMPeuuo/cUFXtfDyqO UNk+9PiIxPVlI255NXc/qXLd+nrvpalnN/q3r7P5R7UPrMCeUATLzisK/BKb2B4AVB+R RwHw== X-Gm-Message-State: AO0yUKVHVYqxVjdsF+ox7ALuKtQYGf/vq0QI2hkvouh43UqQhk2fH4Bl rGyW76slDtBcrlrEJMuCdVdDSQedKcXn+jpo X-Google-Smtp-Source: AK7set8+ZY7lv/eWaZfxCcdsDRGPgx1hbpRVWXePBk/iHegQY+SngEj+7QjzTyuZKhgc3JM5s81ung== X-Received: by 2002:a05:6e02:b4c:b0:311:66d:47aa with SMTP id f12-20020a056e020b4c00b00311066d47aamr510465ilu.26.1676334486989; Mon, 13 Feb 2023 16:28:06 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Warner Losh , richard.henderson@linaro.org, Paolo Bonzini , kevans@freebsd.org, f4bug@amsat.org, Thomas Huth , Sean Bruno , Juergen Lock , Raphael Kubo da Costa , Stacey Son Subject: [PATCH v2 06/12] bsd-user: Helper routines h2t_old_sysctl Date: Mon, 13 Feb 2023 17:27:51 -0700 Message-Id: <20230214002757.99240-7-imp@bsdimp.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230214002757.99240-1-imp@bsdimp.com> References: <20230214002757.99240-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::136; envelope-from=imp@bsdimp.com; helo=mail-il1-x136.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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @bsdimp-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1676334547275100003 Content-Type: text/plain; charset="utf-8" h2t_old_sysctl does the byte swapping in the data to return it to the target for the 'well known' types. Co-Authored-by: Sean Bruno Signed-off-by: Sean Bruno Co-Authored-by: Juergen Lock Signed-off-by: Juergen Lock Co-Authored-by: Raphael Kubo da Costa Signed-off-by: Raphael Kubo da Costa Co-Authored-by: Stacey Son Signed-off-by: Stacey Son Signed-off-by: Warner Losh --- bsd-user/freebsd/os-sys.c | 95 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 91 insertions(+), 4 deletions(-) diff --git a/bsd-user/freebsd/os-sys.c b/bsd-user/freebsd/os-sys.c index 1df53a3e53b..457e61f5b36 100644 --- a/bsd-user/freebsd/os-sys.c +++ b/bsd-user/freebsd/os-sys.c @@ -29,7 +29,7 @@ * Compare with sys/kern_sysctl.c ctl_size * Note: Not all types appear to be used in-tree. */ -static const int G_GNUC_UNUSED target_ctl_size[CTLTYPE+1] =3D { +static const int target_ctl_size[CTLTYPE+1] =3D { [CTLTYPE_INT] =3D sizeof(abi_int), [CTLTYPE_UINT] =3D sizeof(abi_uint), [CTLTYPE_LONG] =3D sizeof(abi_long), @@ -44,7 +44,7 @@ static const int G_GNUC_UNUSED target_ctl_size[CTLTYPE+1]= =3D { [CTLTYPE_U64] =3D sizeof(uint64_t), }; =20 -static const int G_GNUC_UNUSED host_ctl_size[CTLTYPE+1] =3D { +static const int host_ctl_size[CTLTYPE+1] =3D { [CTLTYPE_INT] =3D sizeof(int), [CTLTYPE_UINT] =3D sizeof(u_int), [CTLTYPE_LONG] =3D sizeof(long), @@ -97,7 +97,7 @@ static abi_ulong G_GNUC_UNUSED scale_to_target_pages(uint= 64_t pages) } =20 #ifdef TARGET_ABI32 -static abi_long G_GNUC_UNUSED h2t_long_sat(long l) +static abi_long h2t_long_sat(long l) { if (l > INT32_MAX) { l =3D INT32_MAX; @@ -107,7 +107,7 @@ static abi_long G_GNUC_UNUSED h2t_long_sat(long l) return l; } =20 -static abi_ulong G_GNUC_UNUSED h2t_ulong_sat(u_long ul) +static abi_ulong h2t_ulong_sat(u_long ul) { if (ul > UINT32_MAX) { ul =3D UINT32_MAX; @@ -153,6 +153,93 @@ static int G_GNUC_UNUSED oidfmt(int *oid, int len, cha= r *fmt, uint32_t *kind) return 0; } =20 +/* + * Convert the old value from host to target. + * + * For LONG and ULONG on ABI32, we need to 'down convert' the 8 byte quant= ities + * to 4 bytes. The caller setup a buffer in host memory to get this data f= rom + * the kernel and pass it to us. We do the down conversion and adjust the = length + * so the caller knows what to write as the returned length into the targe= t when + * it copies the down converted values into the target. + * + * For normal integral types, we just need to byte swap. No size changes. + * + * For strings and node data, there's no conversion needed. + * + * For opaque data, per sysctl OID converts take care of it. + */ +static void G_GNUC_UNUSED h2t_old_sysctl(void *holdp, size_t *holdlen, uin= t32_t kind) +{ + size_t len; + int hlen, tlen; + uint8_t *hp, *tp; + + /* + * Although rare, we can have arrays of sysctl. Both sysctl_old_ddb in + * kern_sysctl.c and show_var in sbin/sysctl/sysctl.c have code that l= oops + * this way. *holdlen has been set by the kernel to the host's length. + * Only LONG and ULONG on ABI32 have different sizes: see below. + */ + hp =3D (uint8_t *)holdp; + tp =3D hp; + len =3D 0; + hlen =3D host_ctl_size[kind & CTLTYPE]; + tlen =3D target_ctl_size[kind & CTLTYPE]; + + /* + * hlen =3D=3D 0 for CTLTYPE_STRING and CTLTYPE_NODE, which need no co= nversion + * as well as CTLTYPE_OPAQUE, which needs special converters. + */ + if (hlen =3D=3D 0) { + return; + } + + while (len < *holdlen) { + if (hlen =3D=3D tlen) { + switch (hlen) { + case 1: + /* Nothing needed: no byteswapping and assigning in place = */ + break; + case 2: + *(uint16_t *)tp =3D tswap16(*(uint16_t *)hp); + break; + case 4: + *(uint32_t *)tp =3D tswap32(*(uint32_t *)hp); + break; + case 8: + *(uint64_t *)tp =3D tswap64(*(uint64_t *)hp); + break; + } + } +#ifdef TARGET_ABI32 + else { + /* + * Saturating assignment for the only two types that differ be= tween + * 32-bit and 64-bit machines. All other integral types have t= he + * same, fixed size and will be converted w/o loss of precision + * in the above switch. + */ + switch (kind & CTLTYPE) { + case CTLTYPE_LONG: + *(abi_long *)tp =3D tswap32(h2t_long_sat(*(long *)hp)); + break; + case CTLTYPE_ULONG: + *(abi_ulong *)tp =3D tswap32(h2t_ulong_sat(*(u_long *)hp)); + break; + } + } +#endif + tp +=3D tlen; + hp +=3D hlen; + len +=3D hlen; + } +#ifdef TARGET_ABI32 + if (hlen !=3D tlen) { + *holdlen =3D (*holdlen / hlen) * tlen; + } +#endif +} + /* sysarch() is architecture dependent. */ abi_long do_freebsd_sysarch(void *cpu_env, abi_long arg1, abi_long arg2) { --=20 2.39.1 From nobody Fri May 17 07:47:25 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1676334566; cv=none; d=zohomail.com; s=zohoarc; b=gbueTmCKVUs0uZuhPI+1HQmOWENqT+JTQg09ex3Sw77aVAnSM4r0WSNFGoTCpd+EhTKV4u0lQ1Q8+GD6wOZir6eQdR3pEcyyzYwhMOPHkFm7uA+j3afPpMZebg2PWCbB++m/pfphZxb9jARW6jXBtGEbbvDPS4dA+U/RYseQfRU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676334566; 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=Nlarf8gbmXe3dOGgCl6RSBM/Zj3jkzTFCbZJ2mz6zDo=; b=jSGJrujH5CSyc9MN6/2BWf1PoW/13wFGVxmWEdSQTIj6dlNPsakSfgYlKb5+2OGjS6PX4WkSlr5UyrP5kQsF1hQHBoaic08prGW47Zkv+szD8FfT0Y+vg55QbO6A8+Tu/6EwkOlbuf1IOvu6inj3zrJr/sTJI1NKt3kCHZFJmjo= 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 1676334566615713.8869825531931; Mon, 13 Feb 2023 16:29:26 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pRjB6-0007Qz-Nq; Mon, 13 Feb 2023 19:28:12 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pRjB5-0007QY-H4 for qemu-devel@nongnu.org; Mon, 13 Feb 2023 19:28:11 -0500 Received: from mail-il1-x12e.google.com ([2607:f8b0:4864:20::12e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pRjB3-0005zu-Q0 for qemu-devel@nongnu.org; Mon, 13 Feb 2023 19:28:11 -0500 Received: by mail-il1-x12e.google.com with SMTP id h4so2408590ile.5 for ; Mon, 13 Feb 2023 16:28:09 -0800 (PST) Received: from dune.bsdimp.com (c-71-237-47-177.hsd1.co.comcast.net. [71.237.47.177]) by smtp.gmail.com with ESMTPSA id r17-20020a028811000000b003af4300d670sm4500923jai.27.2023.02.13.16.28.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Feb 2023 16:28:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Nlarf8gbmXe3dOGgCl6RSBM/Zj3jkzTFCbZJ2mz6zDo=; b=U3k0fAoe+H5DZIiNpXDZDxIfN0srPytOAJgeovUFn2wuGWroCfExWXVhSr5k8iLVMR ColIcgbGJUdPWY1+M2ARQUB3DFqJD+Qww94K8a6Zh/gRcE2WeHSeE683MN8fLwBZzavQ Vtn7x4FRD1l7+lKgXGN0NZkJ8h8EPMtJ/Rcn/dJX03L112KfbRFuIQxdl7NarBzmbWFI YD4r4aMX0d7TnA+OpLFv3/K7HRI4a8S8qEXxKoPAStwGWv2RL3gGqxjjL2NlmEHYP61g InEN+cp2/UbGRAHbDW2PuYSFnIPiNn3CzCVxeuqmzM1KgK/m5jTS+s8ZM15GIWy4UKGQ EhKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Nlarf8gbmXe3dOGgCl6RSBM/Zj3jkzTFCbZJ2mz6zDo=; b=WvTH9t/JWUSDCMXeezTwT91BcwUd4wDaQiM5s6xbrMjm0yNrtNcLG3taK9RlJNqXCK G8QGufRWrSa61RVT0hjGALeIK5UDO7rJrW6xLMJ1LxgK1cClICCX1KralnstAm+JE+Ll 8aAJ6Ty76BnLjuso6eBGh5N5N3NydG44SspRG0Oj1k+aKl5GMxUNv1Fg3jYQVyG2l1J0 r/KKKYXA6YjiIB10BhDTkFcqJyUhjrrwam8Z9uRbZ0WdZnNcov5JpAWDulhNiB2Yk+/I 9+qrt4sFuziUUZ8VHClJ8ZN2rw2AN9eg+GlWnwDQJkVJCYEzUYdC749xLcN+OO3LT5bY /BNg== X-Gm-Message-State: AO0yUKV/O+FXwxEGlsOLzwqlsIdpQFusB8Xle1Wz0hHwhRjokT2futYW 8fLSMTzwvXTSf9AAu3r+oFdOr6j7izofmP+L X-Google-Smtp-Source: AK7set/mJoxLS2Op18xFrvCON9pT+JB9HbqxJ4TqElgFL+WN9HEM87bKzFZ9xaf6ka7MmsHcEzYbFg== X-Received: by 2002:a05:6e02:1561:b0:313:df83:3bed with SMTP id k1-20020a056e02156100b00313df833bedmr599080ilu.26.1676334487926; Mon, 13 Feb 2023 16:28:07 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Warner Losh , richard.henderson@linaro.org, Paolo Bonzini , kevans@freebsd.org, f4bug@amsat.org, Thomas Huth , Juergen Lock Subject: [PATCH v2 07/12] bsd-user: sysctl helper funtions: sysctl_name2oid and sysctl_oidfmt Date: Mon, 13 Feb 2023 17:27:52 -0700 Message-Id: <20230214002757.99240-8-imp@bsdimp.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230214002757.99240-1-imp@bsdimp.com> References: <20230214002757.99240-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::12e; envelope-from=imp@bsdimp.com; helo=mail-il1-x12e.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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @bsdimp-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1676334567131100003 Content-Type: text/plain; charset="utf-8" From: Juergen Lock Helper functions for sysctl implementations. sysctl_name2oid and sysctl_oidfmt convert oids between host and targets Signed-off-by: Juergen Lock Reviewed-by: Warner Losh Signed-off-by: Warner Losh Reviewed-by: Richard Henderson --- bsd-user/freebsd/os-sys.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/bsd-user/freebsd/os-sys.c b/bsd-user/freebsd/os-sys.c index 457e61f5b36..084d53c16f6 100644 --- a/bsd-user/freebsd/os-sys.c +++ b/bsd-user/freebsd/os-sys.c @@ -240,6 +240,24 @@ static void G_GNUC_UNUSED h2t_old_sysctl(void *holdp, = size_t *holdlen, uint32_t #endif } =20 +/* + * Convert the undocmented name2oid sysctl data for the target. + */ +static inline void G_GNUC_UNUSED sysctl_name2oid(uint32_t *holdp, size_t h= oldlen) +{ + size_t i, num =3D holdlen / sizeof(uint32_t); + + for (i =3D 0; i < num; i++) { + holdp[i] =3D tswap32(holdp[i]); + } +} + +static inline void G_GNUC_UNUSED sysctl_oidfmt(uint32_t *holdp) +{ + /* byte swap the kind */ + holdp[0] =3D tswap32(holdp[0]); +} + /* sysarch() is architecture dependent. */ abi_long do_freebsd_sysarch(void *cpu_env, abi_long arg1, abi_long arg2) { --=20 2.39.1 From nobody Fri May 17 07:47:25 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1676334569; cv=none; d=zohomail.com; s=zohoarc; b=hMj+yuFvq9PI3hsIx3r3aUStJW7uyi1FqmLFUiExHbhWHv5f8wref75bmMb8QW8VrPx2ujuoI3gJ83dvUy+nV1W9g5YzIaH7EMYjAtONaMiNvrhGYAZfkp+Z97KsoIi0OA0mOdGJt3OR1q1oMjQFAF4TkNvYa5TEc8FOoeHqbFk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676334569; 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=44euG2MYwKiDmmIiT6djpZ4qT+JKtKjHtQycLoy9kbw=; b=ToirvTQNYBPAov3Xf4Deyy1jE7pdpVYdKySjuvlJu0IdSN5F2jtEsHk5WzOP67MTqxg2fKhKQSxp9ou//py7JNBLk86D0zslQ4Wn+58Moq8tBX/zBLjw9E67DXZjS0DVqykOzpzPpPfWx6s8/e+iU+5KZjx/dEJagSpMR2ip6DI= 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 1676334569197742.2701899045951; Mon, 13 Feb 2023 16:29:29 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pRjB7-0007RK-5w; Mon, 13 Feb 2023 19:28:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pRjB6-0007Qn-2O for qemu-devel@nongnu.org; Mon, 13 Feb 2023 19:28:12 -0500 Received: from mail-il1-x136.google.com ([2607:f8b0:4864:20::136]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pRjB4-000603-Ax for qemu-devel@nongnu.org; Mon, 13 Feb 2023 19:28:11 -0500 Received: by mail-il1-x136.google.com with SMTP id h29so4011111ila.8 for ; Mon, 13 Feb 2023 16:28:10 -0800 (PST) Received: from dune.bsdimp.com (c-71-237-47-177.hsd1.co.comcast.net. [71.237.47.177]) by smtp.gmail.com with ESMTPSA id r17-20020a028811000000b003af4300d670sm4500923jai.27.2023.02.13.16.28.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Feb 2023 16:28:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=44euG2MYwKiDmmIiT6djpZ4qT+JKtKjHtQycLoy9kbw=; b=j0cPHM2yZluMahyPlrkYiCEY6qvfpCeIRNAUAjWUmJzWTZJdiJRo6izpsmJXo4/qRJ bcHfAlGXkW8lia61Gv5HeFQI9MCQTG+BIQuu30XKSqdY8zI5+Eru1GTJnVMIqBVk9JsF FbXFaiDatKgI26VKswdhdv73bfRKyXAQEf+icBPLHRcV0HwTTf2dD/q9OO6NHUe4bdII vB7nTRJf99woPTjvqrcUns7fUoKG32W4B1mpo/eLsZ96abcJPukxwXzpUYsKLBi/hu4D 8wxmCTQDgAcMY42xtZPvkOrIGlaPLXv3uWMsEn8yO6XItj2jU6vJV+cHXoNuovfsh8j7 TYxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=44euG2MYwKiDmmIiT6djpZ4qT+JKtKjHtQycLoy9kbw=; b=ZEap3WGR1P0Q+Ghl8tkQtZYnWQ8JoK1wIWRGeONiDEIjzoKjt73EMFhWRtYzhd6Mfc Sz08KPLYolQm83Vr5KlhwrWlXci4IoGqHAlJf3IxBOHKY8WkoaclzEvjW7PdRaY1HawB 6bSok3hsYfkqtVtSZIqOetcCPL9MpMCImoeqjk/8qsw5fYizPEDz7ebdhiRnStKZBuZE 9K8rRiAczudxbaUmf/AnR2d+e991Xw2gdG+GTj9jn1W8aRSt/6Zb7s3wBNeD6Kng9AxV 5dBDZoBCf7eco3M7HsJ37gtk3ZUKfsw1Y69mcmmovUBv95EYLx6EhJrGQFt7kmWrPUFv csFQ== X-Gm-Message-State: AO0yUKUWjlCj7m2ds8qbTHvAvkrg3T/nlbqyar2EHT9jSEvUCQBPoBed RP2yu7NwxNKsc4DFzG0G3hNaXsXawD64kMp+ X-Google-Smtp-Source: AK7set9LWJHv5y9Kag7/oIknMU6TXd1mFMFkDOui+OvQeFq9jGhdq5CNY8P73nJe7vr9QU2O8zRnmw== X-Received: by 2002:a05:6e02:1c89:b0:315:36f5:fb3f with SMTP id w9-20020a056e021c8900b0031536f5fb3fmr499578ill.23.1676334488896; Mon, 13 Feb 2023 16:28:08 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Warner Losh , richard.henderson@linaro.org, Paolo Bonzini , kevans@freebsd.org, f4bug@amsat.org, Thomas Huth , Juergen Lock , Stacey Son Subject: [PATCH v2 08/12] bsd-user: common routine do_freebsd_sysctl_oid for all sysctl variants Date: Mon, 13 Feb 2023 17:27:53 -0700 Message-Id: <20230214002757.99240-9-imp@bsdimp.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230214002757.99240-1-imp@bsdimp.com> References: <20230214002757.99240-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::136; envelope-from=imp@bsdimp.com; helo=mail-il1-x136.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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @bsdimp-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1676334571159100003 Content-Type: text/plain; charset="utf-8" From: Juergen Lock do_freebsd_sysctl_oid filters out some of the binary and special sysctls where host !=3D target. None of the sysctls that have to be translated from host to target are handled here. Signed-off-by: Juergen Lock Co-Authored-by: Stacey Son Signed-off-by: Stacey Son Co-Authored-by: Warner Losh Signed-off-by: Warner Losh Reviewed-by: Richard Henderson --- bsd-user/freebsd/os-sys.c | 90 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 86 insertions(+), 4 deletions(-) diff --git a/bsd-user/freebsd/os-sys.c b/bsd-user/freebsd/os-sys.c index 084d53c16f6..e847404af66 100644 --- a/bsd-user/freebsd/os-sys.c +++ b/bsd-user/freebsd/os-sys.c @@ -126,7 +126,7 @@ static abi_ulong h2t_ulong_sat(u_long ul) * sysctl, see /sys/kern/kern_sysctl.c:sysctl_sysctl_oidfmt() (compare to * src/sbin/sysctl/sysctl.c) */ -static int G_GNUC_UNUSED oidfmt(int *oid, int len, char *fmt, uint32_t *ki= nd) +static int oidfmt(int *oid, int len, char *fmt, uint32_t *kind) { int qoid[CTL_MAXNAME + 2]; uint8_t buf[BUFSIZ]; @@ -168,7 +168,7 @@ static int G_GNUC_UNUSED oidfmt(int *oid, int len, char= *fmt, uint32_t *kind) * * For opaque data, per sysctl OID converts take care of it. */ -static void G_GNUC_UNUSED h2t_old_sysctl(void *holdp, size_t *holdlen, uin= t32_t kind) +static void h2t_old_sysctl(void *holdp, size_t *holdlen, uint32_t kind) { size_t len; int hlen, tlen; @@ -243,7 +243,7 @@ static void G_GNUC_UNUSED h2t_old_sysctl(void *holdp, s= ize_t *holdlen, uint32_t /* * Convert the undocmented name2oid sysctl data for the target. */ -static inline void G_GNUC_UNUSED sysctl_name2oid(uint32_t *holdp, size_t h= oldlen) +static inline void sysctl_name2oid(uint32_t *holdp, size_t holdlen) { size_t i, num =3D holdlen / sizeof(uint32_t); =20 @@ -252,12 +252,94 @@ static inline void G_GNUC_UNUSED sysctl_name2oid(uint= 32_t *holdp, size_t holdlen } } =20 -static inline void G_GNUC_UNUSED sysctl_oidfmt(uint32_t *holdp) +static inline void sysctl_oidfmt(uint32_t *holdp) { /* byte swap the kind */ holdp[0] =3D tswap32(holdp[0]); } =20 +static abi_long G_GNUC_UNUSED do_freebsd_sysctl_oid(CPUArchState *env, int= 32_t *snamep, + int32_t namelen, void *holdp, size_t *holdlenp, void *hnewp, + size_t newlen) +{ + uint32_t kind =3D 0; + abi_long ret; + size_t holdlen, oldlen; +#ifdef TARGET_ABI32 + void *old_holdp; +#endif + + holdlen =3D oldlen =3D *holdlenp; + oidfmt(snamep, namelen, NULL, &kind); + + /* Handle some arch/emulator dependent sysctl()'s here. */ + +#ifdef TARGET_ABI32 + /* + * For long and ulong with a 64-bit host and a 32-bit target we have t= o do + * special things. holdlen here is the length provided by the target t= o the + * system call. So we allocate a buffer twice as large because longs a= re twice + * as big on the host which will be writing them. In h2t_old_sysctl we= 'll adjust + * them and adjust the length. + */ + if (kind =3D=3D CTLTYPE_LONG || kind =3D=3D CTLTYPE_ULONG) { + old_holdp =3D holdp; + holdlen =3D holdlen * 2; + holdp =3D g_malloc(holdlen); + } +#endif + + ret =3D get_errno(sysctl(snamep, namelen, holdp, &holdlen, hnewp, newl= en)); + if (!ret && (holdp !=3D 0)) { + + if (snamep[0] =3D=3D CTL_SYSCTL) { + switch (snamep[1]) { + case CTL_SYSCTL_NEXT: + case CTL_SYSCTL_NAME2OID: + case CTL_SYSCTL_NEXTNOSKIP: + /* + * All of these return an OID array, so we need to convert= to + * target. + */ + sysctl_name2oid(holdp, holdlen); + break; + + case CTL_SYSCTL_OIDFMT: + /* Handle oidfmt */ + sysctl_oidfmt(holdp); + break; + case CTL_SYSCTL_OIDDESCR: + case CTL_SYSCTL_OIDLABEL: + default: + /* Handle it based on the type */ + h2t_old_sysctl(holdp, &holdlen, kind); + /* NB: None of these are LONG or ULONG */ + break; + } + } else { + /* + * Need to convert from host to target. All the weird special = cases + * are handled above. + */ + h2t_old_sysctl(holdp, &holdlen, kind); +#ifdef TARGET_ABI32 + /* + * For the 32-bit on 64-bit case, for longs we need to copy the + * now-converted buffer to the target and free the buffer. + */ + if (kind =3D=3D CTLTYPE_LONG || kind =3D=3D CTLTYPE_ULONG) { + memcpy(old_holdp, holdp, holdlen); + g_free(holdp); + holdp =3D old_holdp; + } +#endif + } + } + + *holdlenp =3D holdlen; + return ret; +} + /* sysarch() is architecture dependent. */ abi_long do_freebsd_sysarch(void *cpu_env, abi_long arg1, abi_long arg2) { --=20 2.39.1 From nobody Fri May 17 07:47:25 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1676334519; cv=none; d=zohomail.com; s=zohoarc; b=iqcHv1507gHdBLtMRW+p9f8YBMqXf/PksIERSWjQ3MR41dyD1k7K3Qx0ylB/iDtdS9mPPwDExfUMHzLUgTO6xIbMA4z5PHcfP2JNsUSk0B/2BfMw0EMw7P28N/d5Y/wabM7fK0tQbfXfOqTmizjtQG/RyNuPALr8MbgIJAtA6uQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676334519; 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=XQOYBxgR23EvKF+EuGnmtn+Ceb+bOBIn7DIZLpdNiBw=; b=EwvLpocxZpgJGzEdi3YRqgksFwFZ1wKnKzZr949Rt8tCw8ISAcQZchxx96ZuCw9p0N0g9m+RTq2LJEG3uYJcs5RUC4gqyix0cF4n2i1J0I4yV04g0Ct58SbulTasY9FPTA3VqslrqSktoKzDv8rW+H3ruKV1jeukPs3Z7xzx03s= 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 167633451972868.36923654461259; Mon, 13 Feb 2023 16:28:39 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pRjB9-0007Ry-Ef; Mon, 13 Feb 2023 19:28:15 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pRjB7-0007RN-6m for qemu-devel@nongnu.org; Mon, 13 Feb 2023 19:28:13 -0500 Received: from mail-il1-x132.google.com ([2607:f8b0:4864:20::132]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pRjB5-00060B-FE for qemu-devel@nongnu.org; Mon, 13 Feb 2023 19:28:12 -0500 Received: by mail-il1-x132.google.com with SMTP id v6so876309ilc.10 for ; Mon, 13 Feb 2023 16:28:11 -0800 (PST) Received: from dune.bsdimp.com (c-71-237-47-177.hsd1.co.comcast.net. [71.237.47.177]) by smtp.gmail.com with ESMTPSA id r17-20020a028811000000b003af4300d670sm4500923jai.27.2023.02.13.16.28.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Feb 2023 16:28:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=XQOYBxgR23EvKF+EuGnmtn+Ceb+bOBIn7DIZLpdNiBw=; b=EUCQW19vk4UVvuv4EIv/YOLM0S9wcHJFDAoD3Ox2in/+tVBKNyiUz7e2YH9J3cjknE fXJJRyjN6pPywYJz5R0gKztDMfOl/ZvpAgM3xYiShkrWKno/48aQ0sLHTk9tf9TRyJmF mfWN2EyzTWdHco+uPHeWawoqtCSJJJBd4jiYXaq4HviLwGQIsaNDv7AOsgCvIP57ep20 8EXQ8j/xxBK+BJtbN8aL8HzqBFqXf9cUIiLZkoOSEEwI1w4gt19kR+wbjVDtuRYJovxA 4qg2IVUoCsN6/7eTI4H0YthfnqXhfJ1Q5ALipSqE9ifbL5cNPuc5A4wTOcyRRcSsUdis oCvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XQOYBxgR23EvKF+EuGnmtn+Ceb+bOBIn7DIZLpdNiBw=; b=u1hDdn8tBO9td3Qx8/CLMxeBkQOB6ch+JdqMpsNhKBadI8PVGzmV3HOIT5LLNIcLq9 URRS+/ARpaBL6LE2JtS1zWON4bm6rSIosdqTw8V5H6TXhRgimEJcLiq1L/guPo2ORtg3 BIc/EiQADHiGlZkAUCctFu0xbV4SSMXxlRewJwU4OI3t1C5QC/QJeLPgqo/jsm2+5gT0 3zHp/YAtEZjPpb2Sv2lwoIPMfoQREdd1AgJCgcrOnmSUgzzvVaIGpm+HcdUOrGjqlmRB S4PsTa6gEGSfPeck2rC2Dq9YS+0itVdpGqBzGea5q19cNSbbTvgmJU8+iVN4STmTLvcH wIPg== X-Gm-Message-State: AO0yUKW0aHeuCJEujLAMdUkCntbxlCAKHXMyHzZ0DKhOQLQWet3Z/Cqq f52qRE0yAEEvLjhEEmCi8BVZWSC9HD7ZTvJS X-Google-Smtp-Source: AK7set9ADxJjgp9jrxEHmCokWNZsuj0U6WBYs9Z0gf7xA5SqRbFTfJIDbXSZSxeA1iVVJn3wD6gNug== X-Received: by 2002:a05:6e02:b4c:b0:315:564b:f3da with SMTP id f12-20020a056e020b4c00b00315564bf3damr571217ilu.8.1676334490042; Mon, 13 Feb 2023 16:28:10 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Warner Losh , richard.henderson@linaro.org, Paolo Bonzini , kevans@freebsd.org, f4bug@amsat.org, Thomas Huth , Juergen Lock , Stacey Son Subject: [PATCH v2 09/12] bsd-user: Start translation of arch-specific sysctls Date: Mon, 13 Feb 2023 17:27:54 -0700 Message-Id: <20230214002757.99240-10-imp@bsdimp.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230214002757.99240-1-imp@bsdimp.com> References: <20230214002757.99240-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::132; envelope-from=imp@bsdimp.com; helo=mail-il1-x132.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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @bsdimp-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1676334521238100009 Content-Type: text/plain; charset="utf-8" From: Juergen Lock Intercept some syscalls that we need to translate (like the archiecture we're running on) and translate them. These are only the simplest ones so far. Signed-off-by: Juergen Lock Co-Authored-by: Stacey Son Signed-off-by: Stacey Son Co-Authored-by: Warner Losh Signed-off-by: Warner Losh Reviewed-by: Richard Henderson --- bsd-user/freebsd/os-sys.c | 145 +++++++++++++++++++++++++++++++++++++- 1 file changed, 143 insertions(+), 2 deletions(-) diff --git a/bsd-user/freebsd/os-sys.c b/bsd-user/freebsd/os-sys.c index e847404af66..cbaa70958b9 100644 --- a/bsd-user/freebsd/os-sys.c +++ b/bsd-user/freebsd/os-sys.c @@ -67,7 +67,7 @@ static const int host_ctl_size[CTLTYPE+1] =3D { */ static const abi_ulong target_max_mem =3D UINT32_MAX - 0x100c000 + 1; =20 -static abi_ulong G_GNUC_UNUSED cap_memory(uint64_t mem) +static abi_ulong cap_memory(uint64_t mem) { if (((unsigned long)target_max_mem) < mem) { mem =3D target_max_mem; @@ -79,7 +79,7 @@ static abi_ulong G_GNUC_UNUSED cap_memory(uint64_t mem) =20 static unsigned long host_page_size; =20 -static abi_ulong G_GNUC_UNUSED scale_to_target_pages(uint64_t pages) +static abi_ulong scale_to_target_pages(uint64_t pages) { if (host_page_size =3D=3D 0) { host_page_size =3D getpagesize(); @@ -273,6 +273,146 @@ static abi_long G_GNUC_UNUSED do_freebsd_sysctl_oid(C= PUArchState *env, int32_t * oidfmt(snamep, namelen, NULL, &kind); =20 /* Handle some arch/emulator dependent sysctl()'s here. */ + switch (snamep[0]) { + case CTL_KERN: + switch (snamep[1]) { + case KERN_USRSTACK: + if (oldlen) { + (*(abi_ulong *)holdp) =3D tswapal(TARGET_USRSTACK); + } + holdlen =3D sizeof(abi_ulong); + ret =3D 0; + goto out; + + case KERN_PS_STRINGS: + if (oldlen) { + (*(abi_ulong *)holdp) =3D tswapal(TARGET_PS_STRINGS); + } + holdlen =3D sizeof(abi_ulong); + ret =3D 0; + goto out; + + default: + break; + } + break; + + case CTL_HW: + switch (snamep[1]) { + case HW_MACHINE: + holdlen =3D sizeof(TARGET_HW_MACHINE); + if (holdp) { + strlcpy(holdp, TARGET_HW_MACHINE, oldlen); + } + ret =3D 0; + goto out; + + case HW_MACHINE_ARCH: + { + holdlen =3D sizeof(TARGET_HW_MACHINE_ARCH); + if (holdp) { + strlcpy(holdp, TARGET_HW_MACHINE_ARCH, oldlen); + } + ret =3D 0; + goto out; + } + case HW_NCPU: + if (oldlen) { + (*(int32_t *)holdp) =3D tswap32(bsd_get_ncpu()); + } + holdlen =3D sizeof(int32_t); + ret =3D 0; + goto out; +#if defined(TARGET_ARM) + case HW_FLOATINGPT: + if (oldlen) { + ARMCPU *cpu =3D env_archcpu(env); + *(abi_int *)holdp =3D cpu_isar_feature(aa32_vfp, cpu); + } + holdlen =3D sizeof(int32_t); + ret =3D 0; + goto out; +#endif + + +#ifdef TARGET_ABI32 + case HW_PHYSMEM: + case HW_USERMEM: + case HW_REALMEM: + holdlen =3D sizeof(abi_ulong); + ret =3D 0; + + if (oldlen) { + int mib[2] =3D {snamep[0], snamep[1]}; + unsigned long lvalue; + size_t len =3D sizeof(lvalue); + + if (sysctl(mib, 2, &lvalue, &len, NULL, 0) =3D=3D -1) { + ret =3D -1; + } else { + lvalue =3D cap_memory(lvalue); + (*(abi_ulong *)holdp) =3D tswapal((abi_ulong)lvalue); + } + } + goto out; +#endif + + default: + { + static int oid_hw_availpages; + static int oid_hw_pagesizes; + + if (!oid_hw_availpages) { + int real_oid[CTL_MAXNAME + 2]; + size_t len =3D sizeof(real_oid) / sizeof(int); + + if (sysctlnametomib("hw.availpages", real_oid, &len) >=3D = 0) { + oid_hw_availpages =3D real_oid[1]; + } + } + if (!oid_hw_pagesizes) { + int real_oid[CTL_MAXNAME + 2]; + size_t len =3D sizeof(real_oid) / sizeof(int); + + if (sysctlnametomib("hw.pagesizes", real_oid, &len) >=3D 0= ) { + oid_hw_pagesizes =3D real_oid[1]; + } + } + + if (oid_hw_availpages && snamep[1] =3D=3D oid_hw_availpages) { + long lvalue; + size_t len =3D sizeof(lvalue); + + if (sysctlbyname("hw.availpages", &lvalue, &len, NULL, 0) = =3D=3D -1) { + ret =3D -1; + } else { + if (oldlen) { + lvalue =3D scale_to_target_pages(lvalue); + (*(abi_ulong *)holdp) =3D tswapal((abi_ulong)lvalu= e); + } + holdlen =3D sizeof(abi_ulong); + ret =3D 0; + } + goto out; + } + + if (oid_hw_pagesizes && snamep[1] =3D=3D oid_hw_pagesizes) { + if (oldlen) { + (*(abi_ulong *)holdp) =3D tswapal((abi_ulong)getpagesi= ze()); + ((abi_ulong *)holdp)[1] =3D 0; + } + holdlen =3D sizeof(abi_ulong) * 2; + ret =3D 0; + goto out; + } + break; + } + } + break; + + default: + break; + } =20 #ifdef TARGET_ABI32 /* @@ -336,6 +476,7 @@ static abi_long G_GNUC_UNUSED do_freebsd_sysctl_oid(CPU= ArchState *env, int32_t * } } =20 +out: *holdlenp =3D holdlen; return ret; } --=20 2.39.1 From nobody Fri May 17 07:47:25 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1676334555; cv=none; d=zohomail.com; s=zohoarc; b=lPOSLvLYbwXyYK1wjWxpTW1UXyENgF048M+/crgw9FHWzW0r2oHUn6fQFxIpHuqgfroAIxZN9ZkCduCJ9dvfWWEpJL6PGkfMOBINmbCNxxrJSqqbzxnZSWNJJSvVCaJU1B13KIg0QzFQKI/ZgP1DQEx+or3StyXp4LEqC3/9scg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676334555; 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=xPed9Hmei9C8C938impO73nLqRfwKXEcgeKH5shVNaI=; b=Fewyszvic6MVaUfCzFMIpVozBA9YUXFLvPhlSOSZrTSBohv+awmEffS9jCdS0TQ0k7dfgt+m/tEg3MzezLX2PWkppZUldPemJhUVgjIC67eEUjPPgvi6QuMSrNDZWa6eDz4XlKIONcuqz8lV8tYYsPNkWUGVBfC6RfmkouYa+dA= 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 1676334555285728.6777543427285; Mon, 13 Feb 2023 16:29:15 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pRjBA-0007S0-OA; Mon, 13 Feb 2023 19:28:17 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pRjB8-0007Rg-6Q for qemu-devel@nongnu.org; Mon, 13 Feb 2023 19:28:14 -0500 Received: from mail-il1-x134.google.com ([2607:f8b0:4864:20::134]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pRjB6-00060S-Iu for qemu-devel@nongnu.org; Mon, 13 Feb 2023 19:28:13 -0500 Received: by mail-il1-x134.google.com with SMTP id a5so5835941ilk.6 for ; Mon, 13 Feb 2023 16:28:12 -0800 (PST) Received: from dune.bsdimp.com (c-71-237-47-177.hsd1.co.comcast.net. [71.237.47.177]) by smtp.gmail.com with ESMTPSA id r17-20020a028811000000b003af4300d670sm4500923jai.27.2023.02.13.16.28.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Feb 2023 16:28:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=xPed9Hmei9C8C938impO73nLqRfwKXEcgeKH5shVNaI=; b=GNW7CnJncjsDQCR858RWB0rF5qJy594MfcCTeZ4mGG0HLL/S+4d2G9tzvttVTrNfQo oXHN/MWfRNXpB/0dTft019ZvLQoOIBaB2oQ357vu4kPeBe26vHiw/B1JICdJeFq48lvM Pr3dBUYv1bgMbg60Q1kBlf38UZJ7W8uEM4d/FQPRg9/EqY9Jmg/EKw6caMwJJHwp8X0o Cf9ZKUU/a7X+W07Suv14TbetHte8pznIBJkU6OX5PIRry/Nr5RNDPZAPz8Zgo0FsWYHE ECh2o9KU8K+jkbHEoaMCgJDP1cpBGpEShZTyzhKQUWeZKeowwgDhmvOpZPyUUTx6N0Vl iBsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xPed9Hmei9C8C938impO73nLqRfwKXEcgeKH5shVNaI=; b=pqjAriutkDf9zgRvuwIGWK4EctT7cU0Y3zFYbvPqFKUC/Hwhv0FEHm9xN/sBAIHmQx 4P+HgEVzHpxZI/u7+ednnC8VhxJmPaCU5S2j3KgnWOsTj6t3/Y9YGkqf7y7bjd2sMLyI sX1sLkynb1TjS84ds0V6EzuN1w4dMHMNEIq6zSAyQiyJysJEbfhG0bM2MUe3wPRLdloI XGhoL25cYUUI/7MwlCbJIrXmwJp3eyjMxxb9JUATcQSC+JstTl0xWkTArKMl+BGeDJP3 O3OdgE3QVija1/d6XpVDmkW46943D31991rkAT2+X9gMmtPWmdSfzkpB3zfVIVtD20t6 T3fg== X-Gm-Message-State: AO0yUKU+j6hsHN5rE5gRoKq0XrRtWv6htDDkq0ybYHb9QCeucumoXpKx hnBkta6xSeMrY0jk1TQdP2ALN8qFYdDzW4D4 X-Google-Smtp-Source: AK7set/KX04VEi5Ywe9hBYIDgXCXx4Fm+dqmxBbtnRvqC7dT/NbXEc7CR0MBB8dgqhVkqNgjVlmeFw== X-Received: by 2002:a05:6e02:1a88:b0:313:bbf8:29e9 with SMTP id k8-20020a056e021a8800b00313bbf829e9mr780212ilv.29.1676334491113; Mon, 13 Feb 2023 16:28:11 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Warner Losh , richard.henderson@linaro.org, Paolo Bonzini , kevans@freebsd.org, f4bug@amsat.org, Thomas Huth , Kyle Evans , Juergen Lock , Stacey Son Subject: [PATCH v2 10/12] bsd-user: do_freebsd_sysctl helper for sysctl(2) Date: Mon, 13 Feb 2023 17:27:55 -0700 Message-Id: <20230214002757.99240-11-imp@bsdimp.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230214002757.99240-1-imp@bsdimp.com> References: <20230214002757.99240-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::134; envelope-from=imp@bsdimp.com; helo=mail-il1-x134.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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @bsdimp-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1676334557052100009 Content-Type: text/plain; charset="utf-8" From: Kyle Evans Implement the wrapper function for sysctl(2). This puts the oid arguments into a standard form and calls the common do_freebsd_sysctl_oid. Signed-off-by: Kyle Evans Co-Authored-by: Juergen Lock Signed-off-by: Juergen Lock Co-Authored-by: Stacey Son Signed-off-by: Stacey Son Reviewed-by: Warner Losh Signed-off-by: Warner Losh Reviewed-by: Richard Henderson --- bsd-user/freebsd/os-sys.c | 57 ++++++++++++++++++++++++++++++++++- bsd-user/freebsd/os-syscall.c | 4 +++ bsd-user/qemu.h | 2 ++ 3 files changed, 62 insertions(+), 1 deletion(-) diff --git a/bsd-user/freebsd/os-sys.c b/bsd-user/freebsd/os-sys.c index cbaa70958b9..e70f8f21c52 100644 --- a/bsd-user/freebsd/os-sys.c +++ b/bsd-user/freebsd/os-sys.c @@ -258,7 +258,7 @@ static inline void sysctl_oidfmt(uint32_t *holdp) holdp[0] =3D tswap32(holdp[0]); } =20 -static abi_long G_GNUC_UNUSED do_freebsd_sysctl_oid(CPUArchState *env, int= 32_t *snamep, +static abi_long do_freebsd_sysctl_oid(CPUArchState *env, int32_t *snamep, int32_t namelen, void *holdp, size_t *holdlenp, void *hnewp, size_t newlen) { @@ -481,6 +481,61 @@ out: return ret; } =20 +abi_long do_freebsd_sysctl(CPUArchState *env, abi_ulong namep, int32_t nam= elen, + abi_ulong oldp, abi_ulong oldlenp, abi_ulong newp, abi_ulong newle= n) +{ + abi_long ret =3D -TARGET_EFAULT; + void *hnamep, *holdp =3D NULL, *hnewp =3D NULL; + size_t holdlen; + abi_ulong oldlen =3D 0; + int32_t *snamep =3D g_malloc(sizeof(int32_t) * namelen), *p, *q, i; + + /* oldlenp is read/write, pre-check here for write */ + if (oldlenp) { + if (!access_ok(VERIFY_WRITE, oldlenp, sizeof(abi_ulong)) || + get_user_ual(oldlen, oldlenp)) { + goto out; + } + } + hnamep =3D lock_user(VERIFY_READ, namep, namelen, 1); + if (hnamep =3D=3D NULL) { + goto out; + } + if (newp) { + hnewp =3D lock_user(VERIFY_READ, newp, newlen, 1); + if (hnewp =3D=3D NULL) { + goto out; + } + } + if (oldp) { + holdp =3D lock_user(VERIFY_WRITE, oldp, oldlen, 0); + if (holdp =3D=3D NULL) { + goto out; + } + } + holdlen =3D oldlen; + for (p =3D hnamep, q =3D snamep, i =3D 0; i < namelen; p++, i++, q++) { + *q =3D tswap32(*p); + } + + ret =3D do_freebsd_sysctl_oid(env, snamep, namelen, holdp, &holdlen, h= newp, + newlen); + + /* + * writeability pre-checked above. __sysctl(2) returns ENOMEM and upda= tes + * oldlenp for the proper size to use. + */ + if (oldlenp && (ret =3D=3D 0 || ret =3D=3D -TARGET_ENOMEM)) { + put_user_ual(holdlen, oldlenp); + } + unlock_user(hnamep, namep, 0); + unlock_user(holdp, oldp, holdlen); + unlock_user(holdp, oldp, ret =3D=3D 0 ? holdlen : 0); +out: + g_free(snamep); + return ret; +} + /* sysarch() is architecture dependent. */ abi_long do_freebsd_sysarch(void *cpu_env, abi_long arg1, abi_long arg2) { diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index e00997a818c..20ab3d4d9a1 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -494,6 +494,10 @@ static abi_long freebsd_syscall(void *cpu_env, int num= , abi_long arg1, /* * sys{ctl, arch, call} */ + case TARGET_FREEBSD_NR___sysctl: /* sysctl(3) */ + ret =3D do_freebsd_sysctl(cpu_env, arg1, arg2, arg3, arg4, arg5, a= rg6); + break; + case TARGET_FREEBSD_NR_sysarch: /* sysarch(2) */ ret =3D do_freebsd_sysarch(cpu_env, arg1, arg2); break; diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h index 0ceecfb6dfa..c7248cfde6f 100644 --- a/bsd-user/qemu.h +++ b/bsd-user/qemu.h @@ -252,6 +252,8 @@ bool is_error(abi_long ret); int host_to_target_errno(int err); =20 /* os-sys.c */ +abi_long do_freebsd_sysctl(CPUArchState *env, abi_ulong namep, int32_t nam= elen, + abi_ulong oldp, abi_ulong oldlenp, abi_ulong newp, abi_ulong newle= n); abi_long do_freebsd_sysarch(void *cpu_env, abi_long arg1, abi_long arg2); =20 /* user access */ --=20 2.39.1 From nobody Fri May 17 07:47:25 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1676334556; cv=none; d=zohomail.com; s=zohoarc; b=FHMOgqkX8aCmEBcwl+XfwWU75zz5RAObeC0DbNm0UfbqmBWGPV98qgABmwrfn0y27I8OMzsXE2HuiLsDHegCa1Fx43xgpeiIEpwczUeS6MTo0sp+Iq5Hov6b1tpdYFE37mIMoM/D3j0/bc7EaGiPGz2Gl4IwFBkYsDIOQu1K/NU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676334556; 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=dwPHE1FXflVhMkzlH4zIuKp10+3mi6EDvmobdXFkcL8=; b=gmLORL5VEvTgL+JJGQ41kRkWqBEbKIVmBPzfJD97L3GUvMmP+StGgd2rJXXD1L9BqdyKYlV85c/WxU69nCLzRid54aod3Bx1rOUsnDrjrFt7rIemZTS0niEyitggLc6mSodL8SuYFrntQwAU4LGvUyiAX1D3IYSBkyzrVAijPbc= 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 1676334556426191.6709900080358; Mon, 13 Feb 2023 16:29:16 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pRjBK-0007U9-Ns; Mon, 13 Feb 2023 19:28:26 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pRjB9-0007Rz-Qu for qemu-devel@nongnu.org; Mon, 13 Feb 2023 19:28:16 -0500 Received: from mail-il1-x133.google.com ([2607:f8b0:4864:20::133]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pRjB7-00060k-TH for qemu-devel@nongnu.org; Mon, 13 Feb 2023 19:28:15 -0500 Received: by mail-il1-x133.google.com with SMTP id u8so5819403ilq.13 for ; Mon, 13 Feb 2023 16:28:13 -0800 (PST) Received: from dune.bsdimp.com (c-71-237-47-177.hsd1.co.comcast.net. [71.237.47.177]) by smtp.gmail.com with ESMTPSA id r17-20020a028811000000b003af4300d670sm4500923jai.27.2023.02.13.16.28.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Feb 2023 16:28:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=dwPHE1FXflVhMkzlH4zIuKp10+3mi6EDvmobdXFkcL8=; b=MZmZMX/bhHIxgNojzAjOAFViaG7RPva/b4DhO3XUpuLq405B8qyiARThlQZGjp7D/Z c2QIlfoT0DTILwJL9I4dRAdokWHkgbiDD+njjgeFl0G10SlHEixTS00wMBf4FKcb6Km5 8fDy38siV9dLWLLJ/ag/bd07etgjRlrSobWZCtZqv02JMsmYQxTAyPbzfmPesEXmQszK Uy5wxGqJG5Supw/1ynANGBTle0aepCjjBVkIzZ3S/k4MA5BnRGvh83KWyfrIiobVHb5/ VGe04F9GHX0fi3tUOzUaRaNReRW5OTygMCYJMGbTuVSmacKT/2M23aRcEq5wZwoiqVPt dbzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dwPHE1FXflVhMkzlH4zIuKp10+3mi6EDvmobdXFkcL8=; b=L5My+l6xfDRySl/v1DNtd17ekihC1idZc1MX1iGsoqJBhsfhq/gjV5HuNIW8kUR+lr qsCHUwstJXqx2uAE1GHJMCHH2J1BQFeVyQeiAAw51jLUt0vxbLrCP6uBJfKTk0x/y1Cu 8zDbJ7lkzqEmmiN+/OEqViVJsn64RvEqZ8QvpBWuy01MIVieSrHC4RIIo++oCS20mGVq b9BaqOIiltAJQfjJliMjXSOjq5KkjlO4mxf8EDZdIunGZJhTYqDyzRIXmOfUWbkXy4Oc rCMrSvErm4D3tNlHDnQGKS+kfljMc2ZpOAHdfwX/2YzjEsqYCAU+UJooOBYoBUKyFb6D v0AA== X-Gm-Message-State: AO0yUKUQU81vOUM6b4X4438J/0c+c1S48EVvcEVe36XbsD7gE+xMtAxS G7EKnFdQNQf7A/+9VqvbMi75AwdLXOMqg6vq X-Google-Smtp-Source: AK7set+28Hn/7XQevFVLps3N6+KJPLSnqJeifeXaxXEaa8RweQxClAJvGfHROc6RsIE5Ex7ZyJRS7g== X-Received: by 2002:a05:6e02:2147:b0:30f:36c4:8c6b with SMTP id d7-20020a056e02214700b0030f36c48c6bmr762918ilv.6.1676334492369; Mon, 13 Feb 2023 16:28:12 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Warner Losh , richard.henderson@linaro.org, Paolo Bonzini , kevans@freebsd.org, f4bug@amsat.org, Thomas Huth , Kyle Evans Subject: [PATCH v2 11/12] bsd-user: implement sysctlbyname(2) Date: Mon, 13 Feb 2023 17:27:56 -0700 Message-Id: <20230214002757.99240-12-imp@bsdimp.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230214002757.99240-1-imp@bsdimp.com> References: <20230214002757.99240-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::133; envelope-from=imp@bsdimp.com; helo=mail-il1-x133.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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @bsdimp-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1676334557033100007 Content-Type: text/plain; charset="utf-8" From: Kyle Evans do_freebsd_sysctlbyname needs to translate the 'name' back down to a OID so we can intercept the special ones. Do that and call the common wrapper do_freebsd_sysctl_oid. Signed-off-by: Kyle Evans Reviewed-by: Warner Losh Signed-off-by: Warner Losh Reviewed-by: Richard Henderson --- bsd-user/freebsd/os-sys.c | 67 +++++++++++++++++++++++++++++++++++ bsd-user/freebsd/os-syscall.c | 4 +++ bsd-user/qemu.h | 3 ++ 3 files changed, 74 insertions(+) diff --git a/bsd-user/freebsd/os-sys.c b/bsd-user/freebsd/os-sys.c index e70f8f21c52..33720ddbb38 100644 --- a/bsd-user/freebsd/os-sys.c +++ b/bsd-user/freebsd/os-sys.c @@ -481,6 +481,73 @@ out: return ret; } =20 +/* + * This syscall was created to make sysctlbyname(3) more efficient, but we= can't + * really provide it in bsd-user. Notably, we must always translate the n= ames + * independently since some sysctl values have to be faked for the target + * environment, so it still has to break down to two syscalls for the unde= rlying + * implementation. + */ +abi_long do_freebsd_sysctlbyname(CPUArchState *env, abi_ulong namep, + int32_t namelen, abi_ulong oldp, abi_ulong oldlenp, abi_ulong newp, + abi_ulong newlen) +{ + abi_long ret =3D -TARGET_EFAULT; + void *holdp =3D NULL, *hnewp =3D NULL; + char *snamep =3D NULL; + int oid[CTL_MAXNAME + 2]; + size_t holdlen, oidplen; + abi_ulong oldlen =3D 0; + + /* oldlenp is read/write, pre-check here for write */ + if (oldlenp) { + if (!access_ok(VERIFY_WRITE, oldlenp, sizeof(abi_ulong)) || + get_user_ual(oldlen, oldlenp)) { + goto out; + } + } + snamep =3D lock_user_string(namep); + if (snamep =3D=3D NULL) { + goto out; + } + if (newp) { + hnewp =3D lock_user(VERIFY_READ, newp, newlen, 1); + if (hnewp =3D=3D NULL) { + goto out; + } + } + if (oldp) { + holdp =3D lock_user(VERIFY_WRITE, oldp, oldlen, 0); + if (holdp =3D=3D NULL) { + goto out; + } + } + holdlen =3D oldlen; + + oidplen =3D sizeof(oid) / sizeof(int); + if (sysctlnametomib(snamep, oid, &oidplen) !=3D 0) { + ret =3D -TARGET_EINVAL; + goto out; + } + + ret =3D do_freebsd_sysctl_oid(env, oid, oidplen, holdp, &holdlen, hnew= p, + newlen); + + /* + * writeability pre-checked above. __sysctl(2) returns ENOMEM and upda= tes + * oldlenp for the proper size to use. + */ + if (oldlenp && (ret =3D=3D 0 || ret =3D=3D -TARGET_ENOMEM)) { + put_user_ual(holdlen, oldlenp); + } +out: + unlock_user(snamep, namep, 0); + unlock_user(holdp, oldp, ret =3D=3D 0 ? holdlen : 0); + unlock_user(hnewp, newp, 0); + + return ret; +} + abi_long do_freebsd_sysctl(CPUArchState *env, abi_ulong namep, int32_t nam= elen, abi_ulong oldp, abi_ulong oldlenp, abi_ulong newp, abi_ulong newle= n) { diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index 20ab3d4d9a1..179a20c304b 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -498,6 +498,10 @@ static abi_long freebsd_syscall(void *cpu_env, int num= , abi_long arg1, ret =3D do_freebsd_sysctl(cpu_env, arg1, arg2, arg3, arg4, arg5, a= rg6); break; =20 + case TARGET_FREEBSD_NR___sysctlbyname: /* sysctlbyname(2) */ + ret =3D do_freebsd_sysctlbyname(cpu_env, arg1, arg2, arg3, arg4, a= rg5, arg6); + break; + case TARGET_FREEBSD_NR_sysarch: /* sysarch(2) */ ret =3D do_freebsd_sysarch(cpu_env, arg1, arg2); break; diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h index c7248cfde6f..e24a8cfcfb1 100644 --- a/bsd-user/qemu.h +++ b/bsd-user/qemu.h @@ -254,6 +254,9 @@ int host_to_target_errno(int err); /* os-sys.c */ abi_long do_freebsd_sysctl(CPUArchState *env, abi_ulong namep, int32_t nam= elen, abi_ulong oldp, abi_ulong oldlenp, abi_ulong newp, abi_ulong newle= n); +abi_long do_freebsd_sysctlbyname(CPUArchState *env, abi_ulong namep, + int32_t namelen, abi_ulong oldp, abi_ulong oldlenp, abi_ulong newp, + abi_ulong newlen); abi_long do_freebsd_sysarch(void *cpu_env, abi_long arg1, abi_long arg2); =20 /* user access */ --=20 2.39.1 From nobody Fri May 17 07:47:25 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1676334555; cv=none; d=zohomail.com; s=zohoarc; b=MlnYZcnTofLGOjx55cr/XDoxnyEpA2/3u8h9mXyGRQeT6+69WPrL3eOT+hjCGXKfWfGjcMkBBpNomwHUyEnoHv2EhZ881Cewx31DywiTcc3Hg8Kji9poqe8uWcNvV/sSimZod8G3inkaTQ9Q5UnNqzh1xS/6NdW9Hl6OlnsyVQI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676334555; 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=bp7wIC67rxl3rARTv1dR7WnW/q65KWMxrGAohWha+/s=; b=lvZg2YhY/z0I+b7gy2/2Xn7m+gqe59XWaZOcbtETJ6YKAEpqqTN/Ns2SM9dt5GY1glpt3Da5a6j4/5MMXt2zkw5AMJECUJDSJBO2fuV2U07Y4+0gD4ISdvrAQppAR7klRsYtRisKz/iwvYHK1zH0fxm7mS+Xs+rAxRQ6mJgIEis= 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 1676334555193246.5747350418851; Mon, 13 Feb 2023 16:29:15 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pRjBJ-0007Tt-Nt; Mon, 13 Feb 2023 19:28:25 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pRjBA-0007S1-MI for qemu-devel@nongnu.org; Mon, 13 Feb 2023 19:28:16 -0500 Received: from mail-io1-xd29.google.com ([2607:f8b0:4864:20::d29]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pRjB8-00060v-PG for qemu-devel@nongnu.org; Mon, 13 Feb 2023 19:28:16 -0500 Received: by mail-io1-xd29.google.com with SMTP id j4so5178669iog.8 for ; Mon, 13 Feb 2023 16:28:14 -0800 (PST) Received: from dune.bsdimp.com (c-71-237-47-177.hsd1.co.comcast.net. [71.237.47.177]) by smtp.gmail.com with ESMTPSA id r17-20020a028811000000b003af4300d670sm4500923jai.27.2023.02.13.16.28.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Feb 2023 16:28:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=bp7wIC67rxl3rARTv1dR7WnW/q65KWMxrGAohWha+/s=; b=WSWE+Z0YBVZGakSomcooMCJPg+Y+fcJzNvMobVfGicLMGFyxkuWU7aopySJmMoPZcc Yct12/AJrAQd7NyH5/jFHK3cniuCc7EtRV6DLjs1SIFCDvvc/tiRsqKeQKnq+W8B9O2r xhqwRLuWZG737/2pZUAK09BalLLrEfrK+4TbWCYIhZYWdWKIfolVxxCB7j4Sjez6YWuB EtaVR+6KRx5iGtlRcuiksn13FxweCQYBLFDXTH7BP7E/MkeHRJNUERkZLuXWdMVIVOJD /yY0n4dSkaX6ZVS6Y5AotwvZGvRC3L3mTkTBYWVq/PS4IB8hI8pxQh1Pu0cSZSXbiKiq xz2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bp7wIC67rxl3rARTv1dR7WnW/q65KWMxrGAohWha+/s=; b=1AvoQSoMQr1kIBzXPVRxGItsNP87LgQhZuCvodOHiJ07hixrzWkqMLyY7ycy0uXLi+ n3L+Qbn0dcsPiDBtHP3xyK9WW2ifGQOX5rTsaCeUBm+T0iaNdF/Z2Yp46y87jIhcAUa5 cgoi50Zc72xiR/PGKko7YbYlkKB4iRmrkTDSDOsp8THong5VI9lsKkslE5w5ArRYMN7P JVhC1JnnXM9IT/2Y3oJUcdJXt68UtGzC5mP/XHySRG1pOg+HGaiaP0MAc3okNpiEVm80 Rxqi4HM2uv8LEp/X5OwS7om4aUSgk/BBS1fdbWjuNrs20vkD27UdraRiMIq6gwsunCGL rNxg== X-Gm-Message-State: AO0yUKU9vYSCm+vY+NtNPmBvq0ROR0JGFijH70NtGZyIUBbNPZfw7+X3 3Oo/z1vD2pFxKkKMT1GFwg/zLv9qROSABgXr X-Google-Smtp-Source: AK7set8xebSWWZc22AtOllnwGD8vdaOGmt5GsX0RncnDak/amnDYKv5TiYHKhsyu7vPtOjL7VdtUEw== X-Received: by 2002:a5d:9516:0:b0:734:6b18:3ee3 with SMTP id d22-20020a5d9516000000b007346b183ee3mr255294iom.13.1676334493448; Mon, 13 Feb 2023 16:28:13 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Warner Losh , richard.henderson@linaro.org, Paolo Bonzini , kevans@freebsd.org, f4bug@amsat.org, Thomas Huth Subject: [PATCH v2 12/12] bsd-user: Add -strict Date: Mon, 13 Feb 2023 17:27:57 -0700 Message-Id: <20230214002757.99240-13-imp@bsdimp.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230214002757.99240-1-imp@bsdimp.com> References: <20230214002757.99240-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::d29; envelope-from=imp@bsdimp.com; helo=mail-io1-xd29.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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @bsdimp-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1676334557052100008 Content-Type: text/plain; charset="utf-8" Most of the time, it's useful to make our best effort, but sometimes we want to know right away when we don't implement something. First place we use it is for unknown syscalls. Signed-off-by: Warner Losh --- bsd-user/freebsd/os-syscall.c | 4 ++++ bsd-user/main.c | 5 ++++- bsd-user/qemu.h | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index 179a20c304b..e2b26ecb8dd 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -508,6 +508,10 @@ static abi_long freebsd_syscall(void *cpu_env, int num= , abi_long arg1, =20 default: qemu_log_mask(LOG_UNIMP, "Unsupported syscall: %d\n", num); + if (bsd_user_strict) { + printf("Unimplemented system call %d\n", num); + abort(); + } ret =3D -TARGET_ENOSYS; break; } diff --git a/bsd-user/main.c b/bsd-user/main.c index 41290e16f98..ba0ad86ad28 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -91,9 +91,10 @@ unsigned long reserved_va =3D MAX_RESERVED_VA; unsigned long reserved_va; #endif =20 -static const char *interp_prefix =3D CONFIG_QEMU_INTERP_PREFIX; +const char *interp_prefix =3D CONFIG_QEMU_INTERP_PREFIX; const char *qemu_uname_release; char qemu_proc_pathname[PATH_MAX]; /* full path to exeutable */ +bool bsd_user_strict =3D false; /* Abort for unimplemned things */ =20 unsigned long target_maxtsiz =3D TARGET_MAXTSIZ; /* max text size */ unsigned long target_dfldsiz =3D TARGET_DFLDSIZ; /* initial data size li= mit */ @@ -396,6 +397,8 @@ int main(int argc, char **argv) trace_opt_parse(optarg); } else if (!strcmp(r, "0")) { argv0 =3D argv[optind++]; + } else if (!strcmp(r, "strict")) { + bsd_user_strict =3D true; } else { usage(); } diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h index e24a8cfcfb1..22bd5a3df42 100644 --- a/bsd-user/qemu.h +++ b/bsd-user/qemu.h @@ -113,6 +113,7 @@ typedef struct TaskState { =20 void stop_all_tasks(void); extern const char *qemu_uname_release; +extern bool bsd_user_strict; =20 /* * TARGET_ARG_MAX defines the number of bytes allocated for arguments --=20 2.39.1