From patchwork Mon Feb 28 18:11:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Warner Losh X-Patchwork-Id: 12763619 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DB26BC433EF for ; Mon, 28 Feb 2022 18:16:44 +0000 (UTC) Received: from localhost ([::1]:33742 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nOkZf-0001Kx-TK for qemu-devel@archiver.kernel.org; Mon, 28 Feb 2022 13:16:43 -0500 Received: from eggs.gnu.org ([209.51.188.92]:47832) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nOkUr-0007uA-QU for qemu-devel@nongnu.org; Mon, 28 Feb 2022 13:11:46 -0500 Received: from [2607:f8b0:4864:20::d2f] (port=46777 helo=mail-io1-xd2f.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nOkUq-0006XA-AV for qemu-devel@nongnu.org; Mon, 28 Feb 2022 13:11:45 -0500 Received: by mail-io1-xd2f.google.com with SMTP id d62so15629366iog.13 for ; Mon, 28 Feb 2022 10:11:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KqQIGuilfSiZo5D0/DJJljqcgNhY6dZ6uWFUPpHnygI=; b=Iud3rKZ3jXNOjefzGtIiizg0u0Dn2vO/42fUkBazA/Mq9h+2pTHkCcp5wzAAZxRsfc EqY04X4Xb5SB3pv/U5nfxQjaD+PbP23DDzOQ9hlwqFJlRcolHF82cI8DvnjvKy0raJmI md4dAPUYV1PKxJBJsjetKpQNiGCQqNCggajhg+QoaWL8MwHt3IzUTGELNQ5bmnPTnefj gpxEo+mq8PU0a6MCJYxNTlDfIuXnSEvUXDpdvLfZ7ZuWroYmi6/vZVdADxbZ8noob6k2 ZIGX9dvvG32LL781sbpqSTlmZeZCr5ucdRldutmvQzq5q8zu356hmsUWJcvy9DNdC85S /qSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KqQIGuilfSiZo5D0/DJJljqcgNhY6dZ6uWFUPpHnygI=; b=CQTMKs4SzErEwBKZZ0z0zybJUbNgyksBgfL4RplzqZAdZjk1E27HJnwtEzBS2nQYb4 aolFbUrotljBczBi5IQTiwR2+N/hvG+YLQwhw5cXcDd5V91inM9Fbl+CoJQ91MrjGdsP UZROWv7lvQvsOG6JjMB8qW2Z+gDe5J+jdiLsturVg00FYGF1YDTq3IuY8tptlH6cTga6 ZtaFW5lAA4ogYkJPyOpDBeTfj+a1YKM/iH5aNMl3OkzNm3QZOQkUhbWi+ld3qFREc/zt lDyT/1qJ4NoUYt3AKxxie0iW2Jx06BNJBUPlziRFAaQ1qOqf8ZH/gLsNBZFG1o8aACJX LGXQ== X-Gm-Message-State: AOAM531YbDQkFFW3TZxpdYeaBkNgWiwYm5JmQyFzLA75wbBj2jkLY0xM Dw0qxqOCqwAR3kVXgzR9jSoWzvi4ljzhag== X-Google-Smtp-Source: ABdhPJx+rC29UiyO0iH922TdNzlyLPJZ4bZwtnFBhXVWGYDDKDAwf7eLkM6kq7D24VueisOUeogwog== X-Received: by 2002:a02:2725:0:b0:314:44cd:897d with SMTP id g37-20020a022725000000b0031444cd897dmr17582298jaa.135.1646071902419; Mon, 28 Feb 2022 10:11:42 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id s13-20020a6bdc0d000000b006408888551dsm6015396ioc.8.2022.02.28.10.11.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Feb 2022 10:11:42 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PULL 01/16] bsd-user/main.c: Drop syscall flavor arg -bsd Date: Mon, 28 Feb 2022 11:11:59 -0700 Message-Id: <20220228181214.2602-2-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220228181214.2602-1-imp@bsdimp.com> References: <20220228181214.2602-1-imp@bsdimp.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::d2f (failed) Received-SPF: none client-ip=2607:f8b0:4864:20::d2f; envelope-from=imp@bsdimp.com; helo=mail-io1-xd2f.google.com X-Spam_score_int: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , arrowd@FreeBSD.org, Kyle Evans , Richard Henderson , def@FreeBSD.org, jrtc27@FreeBSD.org, Warner Losh , Brad Smith Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" We've not realistically been able to actually run any bsd program on any other bsd program. They are too diverged to do this easily. The current code is setup to do it, but implementing it is hard. Stop pretending that we can do this. Signed-off-by: Warner Losh Reviewed-by: Richard Henderson --- bsd-user/main.c | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/bsd-user/main.c b/bsd-user/main.c index f1d58e905e7..bddb830e99b 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -164,7 +164,6 @@ static void usage(void) "-E var=value sets/modifies targets environment variable(s)\n" "-U var unsets targets environment variable(s)\n" "-B address set guest_base address to address\n" - "-bsd type select emulated BSD type FreeBSD/NetBSD/OpenBSD (default)\n" "\n" "Debug options:\n" "-d item1[,...] enable logging of specified items\n" @@ -392,17 +391,6 @@ int main(int argc, char **argv) have_guest_base = true; } else if (!strcmp(r, "drop-ld-preload")) { (void) envlist_unsetenv(envlist, "LD_PRELOAD"); - } else if (!strcmp(r, "bsd")) { - if (!strcasecmp(argv[optind], "freebsd")) { - bsd_type = target_freebsd; - } else if (!strcasecmp(argv[optind], "netbsd")) { - bsd_type = target_netbsd; - } else if (!strcasecmp(argv[optind], "openbsd")) { - bsd_type = target_openbsd; - } else { - usage(); - } - optind++; } else if (!strcmp(r, "seed")) { seed_optarg = optarg; } else if (!strcmp(r, "singlestep")) { From patchwork Mon Feb 28 18:12:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Warner Losh X-Patchwork-Id: 12763625 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A2AFBC433F5 for ; Mon, 28 Feb 2022 18:19:41 +0000 (UTC) Received: from localhost ([::1]:40282 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nOkcW-0005jL-J5 for qemu-devel@archiver.kernel.org; Mon, 28 Feb 2022 13:19:40 -0500 Received: from eggs.gnu.org ([209.51.188.92]:47862) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nOkUs-0007yP-Vv for qemu-devel@nongnu.org; Mon, 28 Feb 2022 13:11:47 -0500 Received: from [2607:f8b0:4864:20::130] (port=44979 helo=mail-il1-x130.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nOkUq-0006Xb-QV for qemu-devel@nongnu.org; Mon, 28 Feb 2022 13:11:46 -0500 Received: by mail-il1-x130.google.com with SMTP id 9so10621640ily.11 for ; Mon, 28 Feb 2022 10:11:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Ogh2FUndj4MIrU/iCsiac6cM3XenhFOByuX1UWjQajU=; b=1hMCN8hgSH+0KUpzsV/qTmjlSqzHljBW7Bdp7EMcRxsyuwa3sBEFSIbala+VIbhbHZ f/tRDWzi7hFBu6VughJ+pohNZ3Y4cJodHMxIuZQHv6b3praO/vnsY3VLmZKwIrcI39bZ H92NqnI5GT3shHqsXh1DtIb3CzPtPx4SvbflTCYaBHrXulra58PyXXOIr3bpqSCWAIgT Ng5WBzy+XWFSFSYVYM8/24eIVfWI9kMnkXkBihUA/Fx4zpKFEq4fnS9uRxiQYjnJhwSJ vgGDI4WjiXYAp26J2iR1R4sSWiYMpTw1H99amZT5guxkZuBt3chhTOzAj8hnWCMdLArd XOKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Ogh2FUndj4MIrU/iCsiac6cM3XenhFOByuX1UWjQajU=; b=47ZfEVqQJUtoSTHEuu0ZCzmpEXfsl7cXbnO1Iynn/S+MHj+2RkzgnYNQLKhwUkxcag ntM16bUsMn4pejV5ZL87kA0qPWeXDkm379BwKp3mZPRZsk3Il+FFoeOSC0jjGCtTOgYQ MgHz8aD/dxDhFK5lBIW7oE9m2rHW2sTo2/ivmu6AyR7Ti0bH5ogNMAjn0d7vDEFs88hY 1hCI3ySCje+xzQrEh2ib1meQb1tVSyjXucxgy8ZTnz4AigLlab5ovcxhxj4oM2SditPx OTxAo2FAqbgrlfn7lopP9iZAPKwj4jscqpflmoKE/NcX0vWC7pruh9IVKgLJx2Cc1Nt8 zrbg== X-Gm-Message-State: AOAM533Q5FDNSyNzwoxCxVghnd5lCXEJv4EfNZh2pNucdoKqVTX8jIXj nKr9L7PGkHgB7YjycOdv+hKQGezgFqLMkw== X-Google-Smtp-Source: ABdhPJyrP2lp5GsnU8TFKXdY6c057sAh8xbJx78eqQNxWAHb7u2EnqsuaiXhl+1IcD6y9Li22VKraw== X-Received: by 2002:a92:ca47:0:b0:2c2:8ecc:aac8 with SMTP id q7-20020a92ca47000000b002c28eccaac8mr19540837ilo.306.1646071903427; Mon, 28 Feb 2022 10:11:43 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id s13-20020a6bdc0d000000b006408888551dsm6015396ioc.8.2022.02.28.10.11.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Feb 2022 10:11:43 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PULL 02/16] bsd-user/x86_64/target_arch_cpu.h: int $80 never was a BSD system call on amd64 Date: Mon, 28 Feb 2022 11:12:00 -0700 Message-Id: <20220228181214.2602-3-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220228181214.2602-1-imp@bsdimp.com> References: <20220228181214.2602-1-imp@bsdimp.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::130 (failed) Received-SPF: none client-ip=2607:f8b0:4864:20::130; envelope-from=imp@bsdimp.com; helo=mail-il1-x130.google.com X-Spam_score_int: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , arrowd@FreeBSD.org, Kyle Evans , Richard Henderson , def@FreeBSD.org, jrtc27@FreeBSD.org, Warner Losh , Brad Smith Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Although initial versions of NetBSD did use int $80, it was replaced by syscall before any releases. OpenBSD and FreeBSD always did syscall. Signed-off-by: Warner Losh Reviewed-by: Kyle Evans Reviewed-by: Richard Henderson --- bsd-user/x86_64/target_arch_cpu.h | 58 ------------------------------- 1 file changed, 58 deletions(-) diff --git a/bsd-user/x86_64/target_arch_cpu.h b/bsd-user/x86_64/target_arch_cpu.h index 0a9c0f08946..9dc52d5afc4 100644 --- a/bsd-user/x86_64/target_arch_cpu.h +++ b/bsd-user/x86_64/target_arch_cpu.h @@ -124,64 +124,6 @@ static inline void target_cpu_loop(CPUX86State *env) process_queued_cpu_work(cs); switch (trapnr) { - case 0x80: - /* syscall from int $0x80 */ - if (bsd_type == target_freebsd) { - abi_ulong params = (abi_ulong) env->regs[R_ESP] + - sizeof(int32_t); - int32_t syscall_nr = env->regs[R_EAX]; - int32_t arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8; - - if (syscall_nr == TARGET_FREEBSD_NR_syscall) { - get_user_s32(syscall_nr, params); - params += sizeof(int32_t); - } else if (syscall_nr == TARGET_FREEBSD_NR___syscall) { - get_user_s32(syscall_nr, params); - params += sizeof(int64_t); - } - get_user_s32(arg1, params); - params += sizeof(int32_t); - get_user_s32(arg2, params); - params += sizeof(int32_t); - get_user_s32(arg3, params); - params += sizeof(int32_t); - get_user_s32(arg4, params); - params += sizeof(int32_t); - get_user_s32(arg5, params); - params += sizeof(int32_t); - get_user_s32(arg6, params); - params += sizeof(int32_t); - get_user_s32(arg7, params); - params += sizeof(int32_t); - get_user_s32(arg8, params); - env->regs[R_EAX] = do_freebsd_syscall(env, - syscall_nr, - arg1, - arg2, - arg3, - arg4, - arg5, - arg6, - arg7, - arg8); - } else { /* if (bsd_type == target_openbsd) */ - env->regs[R_EAX] = do_openbsd_syscall(env, - env->regs[R_EAX], - env->regs[R_EBX], - env->regs[R_ECX], - env->regs[R_EDX], - env->regs[R_ESI], - env->regs[R_EDI], - env->regs[R_EBP]); - } - if (((abi_ulong)env->regs[R_EAX]) >= (abi_ulong)(-515)) { - env->regs[R_EAX] = -env->regs[R_EAX]; - env->eflags |= CC_C; - } else { - env->eflags &= ~CC_C; - } - break; - case EXCP_SYSCALL: /* syscall from syscall instruction */ if (bsd_type == target_freebsd) { From patchwork Mon Feb 28 18:12:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Warner Losh X-Patchwork-Id: 12763617 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 178CCC433EF for ; Mon, 28 Feb 2022 18:14:35 +0000 (UTC) Received: from localhost ([::1]:56658 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nOkXa-000620-9P for qemu-devel@archiver.kernel.org; Mon, 28 Feb 2022 13:14:34 -0500 Received: from eggs.gnu.org ([209.51.188.92]:47868) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nOkUt-0007zX-Fn for qemu-devel@nongnu.org; Mon, 28 Feb 2022 13:11:47 -0500 Received: from [2607:f8b0:4864:20::133] (port=45603 helo=mail-il1-x133.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nOkUr-0006Xh-VK for qemu-devel@nongnu.org; Mon, 28 Feb 2022 13:11:47 -0500 Received: by mail-il1-x133.google.com with SMTP id x14so5521704ill.12 for ; Mon, 28 Feb 2022 10:11:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LQyY9HazAmIIQN0Qysba5tizaG3itH2sn2cAotRVJ2c=; b=6mbHD7ny/CcDrDTfCHyP9KnvtHwg46ppTSF5YbGwtWTIaDzEX8Q9nhjjd6QKwYNg5O d+mS6C/xu2lD4C0nQu/n/VgF5VAGoA8R0koo3Os/9xANScreKSj4SnWUbVQuzuDVjYd8 gdXPLjAyc1tOt8HBClMyeNOnlHuiG4/RGoM/hdKh4tnAJYp1Ka027Jk2Kt9048xbAtOD +cDpf5XdsbQipjStE/g3MLY4l4r3924MSaW/yBApat/3zoFOkdUDsMmPHN+yRnZVuHB9 9Zn7keGAB+fzisL5f3KGDF49BFYYAIEmSfDt2sQC7NIfnr2Ex7sifhoV6n5rCNOdNScG gskw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LQyY9HazAmIIQN0Qysba5tizaG3itH2sn2cAotRVJ2c=; b=NEW6JNOjtLNlkc2bClEYQcLMZ6PnW32wk1xe9US0wx0JjD0C1DSgyFbYHhEVNkNdul XHBcp6IcA8ldiyufu6pe+rMCBlydnqq/FVCezcZpPLlI3RTEQbrwDwjUKMgJ7FRe5OIK vMqNc4/4+Hh1V0m/jLQCW60zYBoj7pGuxHDmQWpA2vQ96o2cXQizIW0rtZc7bMUduwVN GxOX6oEEhNWGeYjeif+VfAi6U7qOeamjufp3cnq/g0ipYpZh3lfW5p6EEUhAmOvESe3z L5o/y7iIJ4V11FSgXMGU4st394LUlRl20kn0GaUGDSSR9XEnta2HpktBzeIFZsoRaT6X AUlw== X-Gm-Message-State: AOAM533jW3soLA8t6wuzOG6myFZlSM1+bf3U6vLMTgZLUK0tFhHprTkR rpKkow9qWHAO0/vHMnZqaUQCr5EwhHn53w== X-Google-Smtp-Source: ABdhPJyhw+suBefyaEzZGZuGI330iDJMSKYJB/J5yoU6T+jLMx6aqPpulT7ThxKdKjxTn22yEBRUzg== X-Received: by 2002:a05:6e02:164a:b0:2bd:2120:3c05 with SMTP id v10-20020a056e02164a00b002bd21203c05mr20855595ilu.253.1646071904641; Mon, 28 Feb 2022 10:11:44 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id s13-20020a6bdc0d000000b006408888551dsm6015396ioc.8.2022.02.28.10.11.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Feb 2022 10:11:44 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PULL 03/16] bsd-user/x86_64/target_arch_cpu.h: Remove openbsd syscall Date: Mon, 28 Feb 2022 11:12:01 -0700 Message-Id: <20220228181214.2602-4-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220228181214.2602-1-imp@bsdimp.com> References: <20220228181214.2602-1-imp@bsdimp.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::133 (failed) 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: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , arrowd@FreeBSD.org, Kyle Evans , Richard Henderson , def@FreeBSD.org, jrtc27@FreeBSD.org, Warner Losh , Brad Smith Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" This doesn't build on openbsd at the moment, and this could should arguably be in bsd-user/*bsd/x86_64 somewhere. Until we refactor to support OpenBSD/NetBSD again, drop it here. Signed-off-by: Warner Losh Reviewed-by: Richard Henderson Reviewed-by: Kyle Evans --- bsd-user/x86_64/target_arch_cpu.h | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/bsd-user/x86_64/target_arch_cpu.h b/bsd-user/x86_64/target_arch_cpu.h index 9dc52d5afc4..5be2f02416e 100644 --- a/bsd-user/x86_64/target_arch_cpu.h +++ b/bsd-user/x86_64/target_arch_cpu.h @@ -126,25 +126,14 @@ static inline void target_cpu_loop(CPUX86State *env) switch (trapnr) { case EXCP_SYSCALL: /* syscall from syscall instruction */ - if (bsd_type == target_freebsd) { - env->regs[R_EAX] = do_freebsd_syscall(env, - env->regs[R_EAX], - env->regs[R_EDI], - env->regs[R_ESI], - env->regs[R_EDX], - env->regs[R_ECX], - env->regs[8], - env->regs[9], 0, 0); - } else { /* if (bsd_type == target_openbsd) */ - env->regs[R_EAX] = do_openbsd_syscall(env, - env->regs[R_EAX], - env->regs[R_EDI], - env->regs[R_ESI], - env->regs[R_EDX], - env->regs[10], - env->regs[8], - env->regs[9]); - } + env->regs[R_EAX] = do_freebsd_syscall(env, + env->regs[R_EAX], + env->regs[R_EDI], + env->regs[R_ESI], + env->regs[R_EDX], + env->regs[R_ECX], + env->regs[8], + env->regs[9], 0, 0); env->eip = env->exception_next_eip; if (((abi_ulong)env->regs[R_EAX]) >= (abi_ulong)(-515)) { env->regs[R_EAX] = -env->regs[R_EAX]; From patchwork Mon Feb 28 18:12:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Warner Losh X-Patchwork-Id: 12763620 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 345FAC433EF for ; Mon, 28 Feb 2022 18:17:44 +0000 (UTC) Received: from localhost ([::1]:36082 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nOkad-0002ta-4l for qemu-devel@archiver.kernel.org; Mon, 28 Feb 2022 13:17:43 -0500 Received: from eggs.gnu.org ([209.51.188.92]:47898) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nOkUu-00083S-JS for qemu-devel@nongnu.org; Mon, 28 Feb 2022 13:11:48 -0500 Received: from [2607:f8b0:4864:20::12f] (port=36634 helo=mail-il1-x12f.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nOkUs-0006Xs-UY for qemu-devel@nongnu.org; Mon, 28 Feb 2022 13:11:48 -0500 Received: by mail-il1-x12f.google.com with SMTP id e11so10669076ils.3 for ; Mon, 28 Feb 2022 10:11:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=DXLZp7GVZK+yie4WHT/uqpry+qSSGTFKOqK8kpW5rAI=; b=Rf5qF6jR1iNQSvif4/hq9sAgwPMpZvWyrR20NB4NW25GBQttnLkCF2iRADn/eumG+3 /wIl77PV5wALPKU5dslr6Mc1JcumZ3l7UMvAIDuGdUWpmwEDWVuwIv6ViDJuGKoUTNFt aLCMixjmIh3kIwiYTUh95yieUhVBqUMPEBkiBwkNlGSebzdx3h9q7czwW/YJaLAgAvH0 YHT1Qxf0gsd9IP3z8hMwn2WqmAiO1GrQeCTTOXzaJBcMWHh3yfLN/kI2M7FV4mmU7eGj HQ+SFUwu47oa2FttscUThlQoaNm+yyNZATxgTzt662prJVqN4UrOpxIZ3GYWSiyjxUN9 9/0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=DXLZp7GVZK+yie4WHT/uqpry+qSSGTFKOqK8kpW5rAI=; b=WalFNVMcsvEa1IFHkozkFlaJIjGO8ydpssjdbnPs9+xfMY3BK3GcBk2BjaeDXDRo7V /40QjWhzzBkxvF/tQUwfAHw60dzx098h7KmgupE1DjQOEngicAToOVHZBAUK9KEpe4Db BPdLEpY4IzPvJX1Fd/KCnO8hIZ8qmNFk0X4agVcNyGd/LM3yqVl9ENTSHLKV2QIJEQsH fzXkdUrP5lMpqpjCgMgOIUDZoGlQPb/xJXT6eY7lbpWl0X/bjmtgWlU5uzTZpMR5K1OT A90JH0A0vSmGokdlKz8RYePRBNt4A/LvcDZ2xWQQjQHpI6KB4u6mXoSG12BQ/PDOMGqt MHlg== X-Gm-Message-State: AOAM533yz6GkSYAK1yG4w/P3vaS4DufnJHvyBR0nkrNMdwJEqlYRwy61 J5QcQkcUHzAU+Jtq1CkZ4jSiGo2NR6npDg== X-Google-Smtp-Source: ABdhPJx+tLADwaCPgsGdm8ly3poOY48Y3r70GPvRNOp4xXzqCv6lfkBX34nP/1hUXFNi3wTNA4tRpQ== X-Received: by 2002:a92:4b0c:0:b0:2c2:b31f:f7ac with SMTP id m12-20020a924b0c000000b002c2b31ff7acmr13996669ilg.300.1646071905553; Mon, 28 Feb 2022 10:11:45 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id s13-20020a6bdc0d000000b006408888551dsm6015396ioc.8.2022.02.28.10.11.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Feb 2022 10:11:45 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PULL 04/16] bsd-user/i386/target_arch_cpu.h: Remove openbsd syscall Date: Mon, 28 Feb 2022 11:12:02 -0700 Message-Id: <20220228181214.2602-5-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220228181214.2602-1-imp@bsdimp.com> References: <20220228181214.2602-1-imp@bsdimp.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::12f (failed) 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: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , arrowd@FreeBSD.org, Kyle Evans , Richard Henderson , def@FreeBSD.org, jrtc27@FreeBSD.org, Warner Losh , Brad Smith Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" This doesn't build on openbsd at the moment, and this could should arguably be in bsd-user/*bsd/i386 somewhere. Until we refactor to support OpenBSD/NetBSD again, drop it here. Signed-off-by: Warner Losh Reviewed-by: Kyle Evans Reviewed-by: Richard Henderson --- bsd-user/i386/target_arch_cpu.h | 84 +++++++++++++++------------------ 1 file changed, 37 insertions(+), 47 deletions(-) diff --git a/bsd-user/i386/target_arch_cpu.h b/bsd-user/i386/target_arch_cpu.h index 3cbf69d8af2..9da22202d48 100644 --- a/bsd-user/i386/target_arch_cpu.h +++ b/bsd-user/i386/target_arch_cpu.h @@ -116,55 +116,45 @@ static inline void target_cpu_loop(CPUX86State *env) process_queued_cpu_work(cs); switch (trapnr) { - case 0x80: + case 0x80: { /* syscall from int $0x80 */ - if (bsd_type == target_freebsd) { - abi_ulong params = (abi_ulong) env->regs[R_ESP] + - sizeof(int32_t); - int32_t syscall_nr = env->regs[R_EAX]; - int32_t arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8; - - if (syscall_nr == TARGET_FREEBSD_NR_syscall) { - get_user_s32(syscall_nr, params); - params += sizeof(int32_t); - } else if (syscall_nr == TARGET_FREEBSD_NR___syscall) { - get_user_s32(syscall_nr, params); - params += sizeof(int64_t); - } - get_user_s32(arg1, params); - params += sizeof(int32_t); - get_user_s32(arg2, params); - params += sizeof(int32_t); - get_user_s32(arg3, params); - params += sizeof(int32_t); - get_user_s32(arg4, params); - params += sizeof(int32_t); - get_user_s32(arg5, params); - params += sizeof(int32_t); - get_user_s32(arg6, params); - params += sizeof(int32_t); - get_user_s32(arg7, params); + abi_ulong params = (abi_ulong) env->regs[R_ESP] + + sizeof(int32_t); + int32_t syscall_nr = env->regs[R_EAX]; + int32_t arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8; + + if (syscall_nr == TARGET_FREEBSD_NR_syscall) { + get_user_s32(syscall_nr, params); params += sizeof(int32_t); - get_user_s32(arg8, params); - env->regs[R_EAX] = do_freebsd_syscall(env, - syscall_nr, - arg1, - arg2, - arg3, - arg4, - arg5, - arg6, - arg7, - arg8); - } else { /* if (bsd_type == target_openbsd) */ - env->regs[R_EAX] = do_openbsd_syscall(env, - env->regs[R_EAX], - env->regs[R_EBX], - env->regs[R_ECX], - env->regs[R_EDX], - env->regs[R_ESI], - env->regs[R_EDI], - env->regs[R_EBP]); + } else if (syscall_nr == TARGET_FREEBSD_NR___syscall) { + get_user_s32(syscall_nr, params); + params += sizeof(int64_t); + } + get_user_s32(arg1, params); + params += sizeof(int32_t); + get_user_s32(arg2, params); + params += sizeof(int32_t); + get_user_s32(arg3, params); + params += sizeof(int32_t); + get_user_s32(arg4, params); + params += sizeof(int32_t); + get_user_s32(arg5, params); + params += sizeof(int32_t); + get_user_s32(arg6, params); + params += sizeof(int32_t); + get_user_s32(arg7, params); + params += sizeof(int32_t); + get_user_s32(arg8, params); + env->regs[R_EAX] = do_freebsd_syscall(env, + syscall_nr, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8); } if (((abi_ulong)env->regs[R_EAX]) >= (abi_ulong)(-515)) { env->regs[R_EAX] = -env->regs[R_EAX]; From patchwork Mon Feb 28 18:12:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Warner Losh X-Patchwork-Id: 12763626 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 648E1C433EF for ; Mon, 28 Feb 2022 18:20:17 +0000 (UTC) Received: from localhost ([::1]:42530 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nOkd6-0007Fp-Dh for qemu-devel@archiver.kernel.org; Mon, 28 Feb 2022 13:20:16 -0500 Received: from eggs.gnu.org ([209.51.188.92]:47934) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nOkUw-00089X-4O for qemu-devel@nongnu.org; Mon, 28 Feb 2022 13:11:50 -0500 Received: from [2607:f8b0:4864:20::d2c] (port=46020 helo=mail-io1-xd2c.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nOkUt-0006Y7-OP for qemu-devel@nongnu.org; Mon, 28 Feb 2022 13:11:49 -0500 Received: by mail-io1-xd2c.google.com with SMTP id c14so15629927ioa.12 for ; Mon, 28 Feb 2022 10:11:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/0Ungf5BAlJNkh7LvFfAMnGaakju4aH7gQ1ep4PqQIo=; b=bE579lmLgWyOAyxWY9Z2WcHCtkrjPvgcIVRNRdlYJx4s3COyPsjtnWJ8CIKmmHKFWw vibQ47U+PO/vHlf1iMH2o1EUbqI//FpNg+sO6/9SaDXeG32p8PUE7EGsbv++067wMzVu ZziXmUphTG1JSGqIHqBWZXV2sbGuhiJ/cTdVxP0Is10+zICESMsJD4E0192L0cwpNymb k6oyP05crgI97a7NU/Ju6V84FbUNco/4WjrvAHJiFtk7r3PH9EogsWpGeNAxqTHz3UDj kp81zhmL3dcnqamzXL0ZOWnscPxxZOJqUt0dcqaGYol4oyMi4QtfG7fIcXdAay2r1r3n 49kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/0Ungf5BAlJNkh7LvFfAMnGaakju4aH7gQ1ep4PqQIo=; b=rYA/WZzEPfLD3DjADNL3ocezEuQIAY219ziPoutWCPQy36V70NGjs9iHRCkjFmNvCP cLCD/zmNK4RvDW0gD/hA3x4jSabBEuwEdRBvztbW/0V3/ADGwsob3xgzW2OvPAFWxCzf 5QJJ5E/qCzrbRAhmcxMT2IwJ2qSb8Q4Anw1yJRo1c8Fgws72zPgazldEdIo2/4VvvK5n k9AKajParwY2Fm8iZUaRJtpObcs2scgLMzE6FOAoDq0xfeOOujLh0aSm1aM646LReDhI V4zzsADmN1uI68GexxNm7cZv7aerpFSskJ42f9aft4SUvk7NcNVgd0iHkBamXKm9H1y5 RmJw== X-Gm-Message-State: AOAM533KqmD8Eqvo8ZbwB0iHFaFfeU2hVDnRw1XP01ezzqRJKB8InsIf 8EdYWCD2NCU1GsJjKVd8kEeEhRrKYMehbw== X-Google-Smtp-Source: ABdhPJwMslT+ZSVEwGk21XsApocEg1bws0CuXEGxvk7txE1XiLbKNRKfpJQyhvzxJNBk5eBcIaB9Tg== X-Received: by 2002:a05:6602:14cd:b0:644:dde8:394 with SMTP id b13-20020a05660214cd00b00644dde80394mr5725979iow.181.1646071906420; Mon, 28 Feb 2022 10:11:46 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id s13-20020a6bdc0d000000b006408888551dsm6015396ioc.8.2022.02.28.10.11.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Feb 2022 10:11:46 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PULL 05/16] bsd-user/arm/target_arch_cpu.h: Only support FreeBSD sys calls Date: Mon, 28 Feb 2022 11:12:03 -0700 Message-Id: <20220228181214.2602-6-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220228181214.2602-1-imp@bsdimp.com> References: <20220228181214.2602-1-imp@bsdimp.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::d2c (failed) Received-SPF: none client-ip=2607:f8b0:4864:20::d2c; envelope-from=imp@bsdimp.com; helo=mail-io1-xd2c.google.com X-Spam_score_int: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , arrowd@FreeBSD.org, Kyle Evans , Richard Henderson , def@FreeBSD.org, jrtc27@FreeBSD.org, Warner Losh , Brad Smith Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Since we don't build on OpenBSD, only do FreeBSD system calls here. In the future, we'll need to move this to some place like bsd-user/freebsd/arm/mumble.h, but until then just leave this inline. This reflects changes to the upstream. Signed-off-by: Warner Losh Reviewed-by: Kyle Evans Reviewed-by: Richard Henderson --- bsd-user/arm/target_arch_cpu.h | 139 ++++++++++++++++----------------- 1 file changed, 66 insertions(+), 73 deletions(-) diff --git a/bsd-user/arm/target_arch_cpu.h b/bsd-user/arm/target_arch_cpu.h index b087db48fa4..afb7814a8d1 100644 --- a/bsd-user/arm/target_arch_cpu.h +++ b/bsd-user/arm/target_arch_cpu.h @@ -40,7 +40,6 @@ static inline void target_cpu_init(CPUARMState *env, static inline void target_cpu_loop(CPUARMState *env) { int trapnr, si_signo, si_code; - unsigned int n; CPUState *cs = env_cpu(env); for (;;) { @@ -66,82 +65,76 @@ static inline void target_cpu_loop(CPUARMState *env) break; case EXCP_SWI: { - n = env->regs[7]; - if (bsd_type == target_freebsd) { - int ret; - abi_ulong params = get_sp_from_cpustate(env); - int32_t syscall_nr = n; - int32_t arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8; + int ret; + abi_ulong params = get_sp_from_cpustate(env); + int32_t syscall_nr = env->regs[7]; + int32_t arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8; - /* See arm/arm/syscall.c cpu_fetch_syscall_args() */ - if (syscall_nr == TARGET_FREEBSD_NR_syscall) { - syscall_nr = env->regs[0]; - arg1 = env->regs[1]; - arg2 = env->regs[2]; - arg3 = env->regs[3]; - get_user_s32(arg4, params); - params += sizeof(int32_t); - get_user_s32(arg5, params); - params += sizeof(int32_t); - get_user_s32(arg6, params); - params += sizeof(int32_t); - get_user_s32(arg7, params); - arg8 = 0; - } else if (syscall_nr == TARGET_FREEBSD_NR___syscall) { - syscall_nr = env->regs[0]; - arg1 = env->regs[2]; - arg2 = env->regs[3]; - get_user_s32(arg3, params); - params += sizeof(int32_t); - get_user_s32(arg4, params); - params += sizeof(int32_t); - get_user_s32(arg5, params); - params += sizeof(int32_t); - get_user_s32(arg6, params); - arg7 = 0; - arg8 = 0; - } else { - arg1 = env->regs[0]; - arg2 = env->regs[1]; - arg3 = env->regs[2]; - arg4 = env->regs[3]; - get_user_s32(arg5, params); - params += sizeof(int32_t); - get_user_s32(arg6, params); - params += sizeof(int32_t); - get_user_s32(arg7, params); - params += sizeof(int32_t); - get_user_s32(arg8, params); - } - ret = do_freebsd_syscall(env, syscall_nr, arg1, arg2, arg3, - arg4, arg5, arg6, arg7, arg8); + /* See arm/arm/syscall.c cpu_fetch_syscall_args() */ + if (syscall_nr == TARGET_FREEBSD_NR_syscall) { + syscall_nr = env->regs[0]; + arg1 = env->regs[1]; + arg2 = env->regs[2]; + arg3 = env->regs[3]; + get_user_s32(arg4, params); + params += sizeof(int32_t); + get_user_s32(arg5, params); + params += sizeof(int32_t); + get_user_s32(arg6, params); + params += sizeof(int32_t); + get_user_s32(arg7, params); + arg8 = 0; + } else if (syscall_nr == TARGET_FREEBSD_NR___syscall) { + syscall_nr = env->regs[0]; + arg1 = env->regs[2]; + arg2 = env->regs[3]; + get_user_s32(arg3, params); + params += sizeof(int32_t); + get_user_s32(arg4, params); + params += sizeof(int32_t); + get_user_s32(arg5, params); + params += sizeof(int32_t); + get_user_s32(arg6, params); + arg7 = 0; + arg8 = 0; + } else { + arg1 = env->regs[0]; + arg2 = env->regs[1]; + arg3 = env->regs[2]; + arg4 = env->regs[3]; + get_user_s32(arg5, params); + params += sizeof(int32_t); + get_user_s32(arg6, params); + params += sizeof(int32_t); + get_user_s32(arg7, params); + params += sizeof(int32_t); + get_user_s32(arg8, params); + } + ret = do_freebsd_syscall(env, syscall_nr, arg1, arg2, arg3, + arg4, arg5, arg6, arg7, arg8); + /* + * Compare to arm/arm/vm_machdep.c + * cpu_set_syscall_retval() + */ + if (-TARGET_EJUSTRETURN == ret) { /* - * Compare to arm/arm/vm_machdep.c - * cpu_set_syscall_retval() + * Returning from a successful sigreturn syscall. + * Avoid clobbering register state. */ - if (-TARGET_EJUSTRETURN == ret) { - /* - * Returning from a successful sigreturn syscall. - * Avoid clobbering register state. - */ - break; - } - if (-TARGET_ERESTART == ret) { - env->regs[15] -= env->thumb ? 2 : 4; - break; - } - if ((unsigned int)ret >= (unsigned int)(-515)) { - ret = -ret; - cpsr_write(env, CPSR_C, CPSR_C, CPSRWriteByInstr); - env->regs[0] = ret; - } else { - cpsr_write(env, 0, CPSR_C, CPSRWriteByInstr); - env->regs[0] = ret; /* XXX need to handle lseek()? */ - /* env->regs[1] = 0; */ - } + break; + } + if (-TARGET_ERESTART == ret) { + env->regs[15] -= env->thumb ? 2 : 4; + break; + } + if ((unsigned int)ret >= (unsigned int)(-515)) { + ret = -ret; + cpsr_write(env, CPSR_C, CPSR_C, CPSRWriteByInstr); + env->regs[0] = ret; } else { - fprintf(stderr, "qemu: bsd_type (= %d) syscall " - "not supported\n", bsd_type); + cpsr_write(env, 0, CPSR_C, CPSRWriteByInstr); + env->regs[0] = ret; /* XXX need to handle lseek()? */ + /* env->regs[1] = 0; */ } } break; From patchwork Mon Feb 28 18:12:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Warner Losh X-Patchwork-Id: 12763615 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B3430C433F5 for ; Mon, 28 Feb 2022 18:13:28 +0000 (UTC) Received: from localhost ([::1]:51682 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nOkWV-0002cN-Sm for qemu-devel@archiver.kernel.org; Mon, 28 Feb 2022 13:13:27 -0500 Received: from eggs.gnu.org ([209.51.188.92]:47936) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nOkUw-0008AF-94 for qemu-devel@nongnu.org; Mon, 28 Feb 2022 13:11:50 -0500 Received: from [2607:f8b0:4864:20::d36] (port=42679 helo=mail-io1-xd36.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nOkUu-0006YI-R7 for qemu-devel@nongnu.org; Mon, 28 Feb 2022 13:11:49 -0500 Received: by mail-io1-xd36.google.com with SMTP id r8so2089141ioj.9 for ; Mon, 28 Feb 2022 10:11:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ofnHKkN8PdXzijWUIHfVMI1oGobWCqOzmD9JyEB/pSk=; b=3qpHrYLweCoHCrtGv6oO8qm8Uq94v2y93Py29lKDT9UhJMuIZyxdl+6HtThc+ZG/wy q4K00kEzun9v04k8/D4rjENt1ve/TTQFUky/DNHkkMmQKFlYo+mm4aEGMr8a3wREMCxc FMUShZfxXM4YSyXxpNzf/HM37DHZxPD0309prXXP0OJTx/y6SSynEs08Z5Y9rT7m2371 5e+pMtJNQ60D2gl7odq/VEEAj+LzOCF2kNtpIjW1rsES7saCxh+37AChb87/5a5Neath ikTiIE7xXyh6nHjvFkpljxW/jlaucSlVEFvH/V/mcpm5AlKu1ox7Y/+g4SnB7u65DlE9 IjMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ofnHKkN8PdXzijWUIHfVMI1oGobWCqOzmD9JyEB/pSk=; b=7JzUtJ6sRuaZQWBjWD7iOHsShNQRru4GL3dOhn/QkkLQDBjT+Lk+iYXuYYhOOEAUm0 LskEf+lpkokGxhSUWywlD+L2sGZFlgwbcDAm0/xyVww7KiqwW9Vhk3EXTlE5pif4Zxsc r1Fk+DHDLFN3LLpkXC3+gWEJfWkarGW7DIMz1KfSAD7QGL/6y2RhQGL4vrkbbK0k+PZj HoKLRh3zC5ivIkHYQwyDjnyLoBiYLe8Kx749BWiAWmnVB/iyPxzfdLpQpTDtSTztJb6Z scXJ5sAl/yIMcU8VTA2kUnfIKMT3otsGl6YKF60sJNGYDEuZWkxdf+zCycT/1xVtpgbV 5HSg== X-Gm-Message-State: AOAM533nZMcQJcgCOqFIfjAPPewetd+yy4jUG6/yB+NIlPHiPIXQhhJC DDrovB2cDlwoLFXEBDOdKPeUziLkUW5DAA== X-Google-Smtp-Source: ABdhPJwfsBhEzIG5ihiUbPu2NhjZtwlog2QlqXLQFDJGkL1t44FTGSk6jmHbGY82sCK14lmpM3dsXw== X-Received: by 2002:a5d:8d03:0:b0:612:608:9a67 with SMTP id p3-20020a5d8d03000000b0061206089a67mr16096101ioj.19.1646071907541; Mon, 28 Feb 2022 10:11:47 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id s13-20020a6bdc0d000000b006408888551dsm6015396ioc.8.2022.02.28.10.11.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Feb 2022 10:11:47 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PULL 06/16] bsd-user/arm/target_arch_thread.h: Assume a FreeBSD target Date: Mon, 28 Feb 2022 11:12:04 -0700 Message-Id: <20220228181214.2602-7-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220228181214.2602-1-imp@bsdimp.com> References: <20220228181214.2602-1-imp@bsdimp.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::d36 (failed) Received-SPF: none client-ip=2607:f8b0:4864:20::d36; envelope-from=imp@bsdimp.com; helo=mail-io1-xd36.google.com X-Spam_score_int: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , arrowd@FreeBSD.org, Kyle Evans , Richard Henderson , def@FreeBSD.org, jrtc27@FreeBSD.org, Warner Losh , Brad Smith Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Since we can't run on anything else, assume for the moment that this is a FreeBSD target. In the future, we'll need to handle this properly via some include file in bsd-user/*bsd/arm/mumble.h. There's a number of other diffs that would be needed to make things work on OtherBSD, so it doesn't make sense to preseve this one detail today. Signed-off-by: Warner Losh Reviewed-by: Kyle Evans Reviewed-by: Richard Henderson --- bsd-user/arm/target_arch_thread.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/bsd-user/arm/target_arch_thread.h b/bsd-user/arm/target_arch_thread.h index 11c7f765838..fcafca2408c 100644 --- a/bsd-user/arm/target_arch_thread.h +++ b/bsd-user/arm/target_arch_thread.h @@ -62,9 +62,7 @@ static inline void target_thread_init(struct target_pt_regs *regs, } regs->ARM_pc = infop->entry & 0xfffffffe; regs->ARM_sp = stack; - if (bsd_type == target_freebsd) { - regs->ARM_lr = infop->entry & 0xfffffffe; - } + regs->ARM_lr = infop->entry & 0xfffffffe; /* * FreeBSD kernel passes the ps_strings pointer in r0. This is used by some * programs to set status messages that we see in ps. bsd-user doesn't From patchwork Mon Feb 28 18:12:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Warner Losh X-Patchwork-Id: 12763618 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 215BEC433F5 for ; Mon, 28 Feb 2022 18:16:04 +0000 (UTC) Received: from localhost ([::1]:60044 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nOkYz-0008L8-Kn for qemu-devel@archiver.kernel.org; Mon, 28 Feb 2022 13:16:02 -0500 Received: from eggs.gnu.org ([209.51.188.92]:47956) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nOkUx-0008El-Iv for qemu-devel@nongnu.org; Mon, 28 Feb 2022 13:11:51 -0500 Received: from [2607:f8b0:4864:20::d31] (port=33747 helo=mail-io1-xd31.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nOkUw-0006Yo-5K for qemu-devel@nongnu.org; Mon, 28 Feb 2022 13:11:51 -0500 Received: by mail-io1-xd31.google.com with SMTP id 195so15738656iou.0 for ; Mon, 28 Feb 2022 10:11:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0W7CyGd+wltyjsV4bxtaXkJoEqxgaZms/OXr5iQpEmE=; b=QL+ENtqp/3MYN6XKbdICnJW+ABAbW6iCRFgjPcpwVkL1lVr1lhugLzYG+tLSwqkmbp MrjP0tLWXUrZfFJeGJZL55+HTQlwUYGua0YIQ14k5sFfH+yAvAK1XoOCfIeMzdeUA6hV e6BTf3Ce/sLHMLYgRTIExEBpxA7akEIspObvQ7KgByR17nsmRaeD88WeMFI64LVlbt/f ND0f6mnWG22zCrvLIGDwhK0iJkYFcjoqIXbWw56bQ5fwm6eW4+oSdO/rRdelfUCHKldN wXlvfj/36+F+E5Oaj/V+jZjnLZImIBs1AuFpJjuD4Zen49FTzxpMKkhWmhYDUAvNHcq6 0yGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0W7CyGd+wltyjsV4bxtaXkJoEqxgaZms/OXr5iQpEmE=; b=l6544xrr6n3qydCP2xvJsN1khW7Uqv6K4GLOKsocjt2kyClu1XGcGjAAKuH90hPLSK nC22N3TDnArQLZQtEu2bFTrHeimKhKJkKshq6RvVqwRgTewWOBtiZL5Xa+hSdANT+4hf hVyUlefp/8Mx0y5yktx72iQ2CpgI4D8X1pXpKuqRBlMLBNra98A/Ys6eT5vxtYpFdXP5 tRimVuK2+FcKIgq4PxlJfdaTvaBy44fPhYne+YtGacDm0tDGg04QqWeGs4J9JGQ48AOp M7uNIxV4iHr+wECVy/hHpCH+koeG7NbWBOY3Qx5Ma9sZrjUWcxohcKlGRZ/L89D2HdU0 kEbg== X-Gm-Message-State: AOAM533VIV/7rHrpkrRENP99bVs3eGroz+l2P/6r8XlSVI8LyqgPkhc6 x+2kgxAZOfL4KlE3Bnf6uEUbAHna8H7QYw== X-Google-Smtp-Source: ABdhPJwLIoyYvE9+MS8kq1AfFjMdLq5oPW73iHqdZKl7n0JdQiEcbQn5W7ceiNxX3VLCqpxI3vP0fg== X-Received: by 2002:a05:6602:134f:b0:63c:a7ba:e8d with SMTP id i15-20020a056602134f00b0063ca7ba0e8dmr16402890iov.180.1646071908882; Mon, 28 Feb 2022 10:11:48 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id s13-20020a6bdc0d000000b006408888551dsm6015396ioc.8.2022.02.28.10.11.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Feb 2022 10:11:48 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PULL 07/16] bsd-user/x86_64/target_arch_thread.h: Assume a FreeBSD target Date: Mon, 28 Feb 2022 11:12:05 -0700 Message-Id: <20220228181214.2602-8-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220228181214.2602-1-imp@bsdimp.com> References: <20220228181214.2602-1-imp@bsdimp.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::d31 (failed) Received-SPF: none client-ip=2607:f8b0:4864:20::d31; envelope-from=imp@bsdimp.com; helo=mail-io1-xd31.google.com X-Spam_score_int: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , arrowd@FreeBSD.org, Kyle Evans , Richard Henderson , def@FreeBSD.org, jrtc27@FreeBSD.org, Warner Losh , Brad Smith Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Since we can't run on anything else, assume for the moment that this is a FreeBSD target. In the future, we'll need to handle this properly via some include file in bsd-user/*bsd/x86_64/mumble.h. There's a number of other diffs that would be needed to make things work on OtherBSD, so it doesn't make sense to preseve this one detail today. Signed-off-by: Warner Losh Reviewed-by: Kyle Evans Reviewed-by: Richard Henderson --- bsd-user/x86_64/target_arch_thread.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/bsd-user/x86_64/target_arch_thread.h b/bsd-user/x86_64/target_arch_thread.h index d105e43fd35..b745d7ffeb7 100644 --- a/bsd-user/x86_64/target_arch_thread.h +++ b/bsd-user/x86_64/target_arch_thread.h @@ -32,9 +32,7 @@ static inline void target_thread_init(struct target_pt_regs *regs, regs->rax = 0; regs->rsp = infop->start_stack; regs->rip = infop->entry; - if (bsd_type == target_freebsd) { - regs->rdi = infop->start_stack; - } + regs->rdi = infop->start_stack; } #endif /* !_TARGET_ARCH_THREAD_H_ */ From patchwork Mon Feb 28 18:12:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Warner Losh X-Patchwork-Id: 12763629 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EF869C433EF for ; Mon, 28 Feb 2022 18:22:53 +0000 (UTC) Received: from localhost ([::1]:48934 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nOkfd-0003BZ-3s for qemu-devel@archiver.kernel.org; Mon, 28 Feb 2022 13:22:53 -0500 Received: from eggs.gnu.org ([209.51.188.92]:47968) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nOkUy-0008If-Id for qemu-devel@nongnu.org; Mon, 28 Feb 2022 13:11:52 -0500 Received: from [2607:f8b0:4864:20::12d] (port=44977 helo=mail-il1-x12d.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nOkUx-0006aD-3R for qemu-devel@nongnu.org; Mon, 28 Feb 2022 13:11:52 -0500 Received: by mail-il1-x12d.google.com with SMTP id 9so10621911ily.11 for ; Mon, 28 Feb 2022 10:11:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TkBhosKWDfacU7putxgRWL5fb9CqDgt1oqt0mYy2nvk=; b=YUeuatqdsuzl28UADvUu7KgYi1D6B34H5xVb1a/pohSk3Z1uenphHGj1WvFbV92z1W Mqmqc7TVa6N9DkN3TxDtV39eHEbdPx6sQLv7gQgj26mLfd7uxiR+ySPZUFeOk2cffkXs kHm2k+veg62C2e6yCaAPEojCtS98mNHnmTyiM82XoM6+T7tT41Jz80Qldfrj2HQUoUrq 5HmphSWVAbfJnbxHrNb4aaLzT22coOo8eHMA8BB9Mr1QFPRaf/FIHYHMsFLBnFzgWiO7 4xXNjLkX1RkcMDIEfFvRM2InXdtb1MC+hs1ij8+3Z+wDHGnAS8us8z8o8QHlQzWBOxUy gU2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TkBhosKWDfacU7putxgRWL5fb9CqDgt1oqt0mYy2nvk=; b=AaydptwF7c1u47C/rZox2LAsYdHZy19qesdKu7I1g2EAg6TrUScoHzD96NkoPA2ump QnT3rTmsYo5nZJPyPAfs7q7zZFzYeaZQWuek5e3C6WkNWESCXCltBB7Y9yJ6maRM5MoW BhFwQABBBvOz++302PGxVhEvQnGSERvNih1nRiiFTQDqbsgBniTCPv876E36UWvDvCVJ 0yWbbcIUIuo2rcxgUyvxflVc3xxPR7sWgmnKI94g+mObfrJzsdig0oUWiz+0GbqhiYQb rU3QgUsVpyrvDZ89CilL7GGoqTyK/9P09sevwpoFjrcinyiX8hck77wgv0QoPA1ItEPt z2vg== X-Gm-Message-State: AOAM533/JSFC6CdwTXCy95W+gFK5wnS8sYIvm0N6qgSdE1J/3bODqVDr xQKKD9ffwZxpd2F4IP5UXvq336ptuF3OLw== X-Google-Smtp-Source: ABdhPJyaOu3UOy7KJxzlPHe/G1hKS13AGOnBLy/x8X/GRzWYP0CY+4CSs1M3O4DQM8KAj3KKXrRIOQ== X-Received: by 2002:a92:ddc7:0:b0:2c2:91f5:146b with SMTP id d7-20020a92ddc7000000b002c291f5146bmr20354020ilr.21.1646071909890; Mon, 28 Feb 2022 10:11:49 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id s13-20020a6bdc0d000000b006408888551dsm6015396ioc.8.2022.02.28.10.11.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Feb 2022 10:11:49 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PULL 08/16] bsd-user: Remove bsd_type Date: Mon, 28 Feb 2022 11:12:06 -0700 Message-Id: <20220228181214.2602-9-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220228181214.2602-1-imp@bsdimp.com> References: <20220228181214.2602-1-imp@bsdimp.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::12d (failed) Received-SPF: none client-ip=2607:f8b0:4864:20::12d; envelope-from=imp@bsdimp.com; helo=mail-il1-x12d.google.com X-Spam_score_int: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , arrowd@FreeBSD.org, Kyle Evans , Richard Henderson , def@FreeBSD.org, jrtc27@FreeBSD.org, Warner Losh , Brad Smith Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Remove keeping track of which type of bsd we're running on. It's no longer referenced in the code. Building bsd-user on NetBSD or OpenBSD isn't possible, let alone running that code. Stop pretending that we can do the cross BSD thing since there's been a large divergence since 2000 that makes this nearly impossible between FreeBSD and {Net,Open}BSD and at least quite difficult between NetBSD and OpenBSD. Signed-off-by: Warner Losh Reviewed-by: Kyle Evans Reviewed-by: Richard Henderson --- bsd-user/main.c | 2 -- bsd-user/qemu.h | 7 ------- 2 files changed, 9 deletions(-) diff --git a/bsd-user/main.c b/bsd-user/main.c index bddb830e99b..88d347d05eb 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -96,7 +96,6 @@ unsigned long reserved_va; static const char *interp_prefix = CONFIG_QEMU_INTERP_PREFIX; const char *qemu_uname_release; -enum BSDType bsd_type; char qemu_proc_pathname[PATH_MAX]; /* full path to exeutable */ unsigned long target_maxtsiz = TARGET_MAXTSIZ; /* max text size */ @@ -284,7 +283,6 @@ int main(int argc, char **argv) const char *gdbstub = NULL; char **target_environ, **wrk; envlist_t *envlist = NULL; - bsd_type = HOST_DEFAULT_BSD_TYPE; char *argv0 = NULL; adjust_ssize(); diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h index 02921ac8b3b..e5742bd6c03 100644 --- a/bsd-user/qemu.h +++ b/bsd-user/qemu.h @@ -29,13 +29,6 @@ extern char **environ; -enum BSDType { - target_freebsd, - target_netbsd, - target_openbsd, -}; -extern enum BSDType bsd_type; - #include "exec/user/thunk.h" #include "target_arch.h" #include "syscall_defs.h" From patchwork Mon Feb 28 18:12:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Warner Losh X-Patchwork-Id: 12763624 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1231DC433EF for ; Mon, 28 Feb 2022 18:18:59 +0000 (UTC) Received: from localhost ([::1]:38662 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nOkbq-0004cq-75 for qemu-devel@archiver.kernel.org; Mon, 28 Feb 2022 13:18:58 -0500 Received: from eggs.gnu.org ([209.51.188.92]:47994) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nOkUz-0008Nk-Pe for qemu-devel@nongnu.org; Mon, 28 Feb 2022 13:11:53 -0500 Received: from [2607:f8b0:4864:20::d2a] (port=37839 helo=mail-io1-xd2a.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nOkUy-0006aL-32 for qemu-devel@nongnu.org; Mon, 28 Feb 2022 13:11:53 -0500 Received: by mail-io1-xd2a.google.com with SMTP id c23so15692005ioi.4 for ; Mon, 28 Feb 2022 10:11:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=78KW/flWB6MtajWHw9g+3hzlOLi0kgwH7sG/RnsAKPw=; b=yG7mj5zIKkck7BRxmJv3pmplTLgMhna06l5l0jb62wNBtLp6GlUUcipDvSnnXicpnY K3CrNtE6VH8Fo6Zelj8vos2Y3UAw3/HH1lyksgyQkdIFB4RFO3WKirCN0Gc+aAvkrlLu v4MlIxuLLqKkMot2CisP2/Kws2hvkPsY4RGZN25txuevhmk55gfYmZ/ZuWd559jxFn1t HdUeJWT5yRn3wryFVJI1ds+qZHORVgoez1es3MEm90BtrOFvIsamXcyzu1u3bsYfNeGp +h3XXo2c2QI4MOByVw7VYnTNxKQoTe1s9EyfmEW9YUANWrpGXsq9H4vI0d0zGVTs8lj5 tCzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=78KW/flWB6MtajWHw9g+3hzlOLi0kgwH7sG/RnsAKPw=; b=Yw2+a1fzsdLKM7X/Uqj6TJUJIReO5KbA+jGkGXBujSqCadtolLsu3VOiC/rzv5nl65 kHPGRcCufLw3LfBYLxtN3v/qIrHdhEFw+aXE9mALYGGF3q/3VM7ss6zBYNJ3a91IDSMQ 9OZMKnqWhcuFb+AvphWqhpsp+9w0l6ig+E45pamgoVoBQ61a1x4o33bzGuRMpeEyzibk AXRWWAj1+efVoYqbLoJMDeO9rJDZhUzV3W0Vr2TebXqTPUuXXsMP0tQkxYa924uc5mvH DWIkR8bOwOfD5uG5remBI2ibxeMUK680TeyqDn2oH0wegnT8aCQxoo9JowynOobKDBlA tjpA== X-Gm-Message-State: AOAM530FVu7nIebU6MU9E97Gkq4yZ7OfnZJbkSNYVs3KyA4EAQcVmXIg aBD7u/gPf3OwdzhXDNVGKMUDxeQPvWfCJQ== X-Google-Smtp-Source: ABdhPJw41qwzJMjUQLN+yusnDHPPTMU+kRJoDXxFE19Hqwb797K1hDgXsFp8AlHGN7gVZEQoQREUsA== X-Received: by 2002:a5d:9c4a:0:b0:641:346:5a91 with SMTP id 10-20020a5d9c4a000000b0064103465a91mr16047083iof.217.1646071910742; Mon, 28 Feb 2022 10:11:50 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id s13-20020a6bdc0d000000b006408888551dsm6015396ioc.8.2022.02.28.10.11.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Feb 2022 10:11:50 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PULL 09/16] bsd-user/freebsd/os-syscall.c: Move syscall processing here Date: Mon, 28 Feb 2022 11:12:07 -0700 Message-Id: <20220228181214.2602-10-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220228181214.2602-1-imp@bsdimp.com> References: <20220228181214.2602-1-imp@bsdimp.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::d2a (failed) 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: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , arrowd@FreeBSD.org, Kyle Evans , Richard Henderson , def@FreeBSD.org, jrtc27@FreeBSD.org, Warner Losh , Brad Smith Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" While there is some commonality between *BSD syscall processing, there's a number of differences and the system call numbers and ABIs have been independent since the late 90s. Move FreeBSD's proessing here and delete it. The upstream implementation is somewhat different than the current implementation. It will be much easier to upstream these from scratch, justifying the final result, rather than working out the diffs and justifying the changes. Also tweak a comment to qemu standard form. Signed-off-by: Warner Losh Reviewed-by: Kyle Evans Reviewed-by: Richard Henderson --- bsd-user/freebsd/os-syscall.c | 69 +++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 bsd-user/freebsd/os-syscall.c diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c new file mode 100644 index 00000000000..fc57e324173 --- /dev/null +++ b/bsd-user/freebsd/os-syscall.c @@ -0,0 +1,69 @@ +/* + * BSD syscalls + * + * Copyright (c) 2003-2008 Fabrice Bellard + * Copyright (c) 2013-2014 Stacey D. Son + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + */ + +/* + * We need the FreeBSD "legacy" definitions. Rust needs the FreeBSD 11 system + * calls since it doesn't use libc at all, so we have to emulate that despite + * FreeBSD 11 being EOL'd. + */ +#define _WANT_FREEBSD11_STAT +#define _WANT_FREEBSD11_STATFS +#define _WANT_FREEBSD11_DIRENT +#define _WANT_KERNEL_ERRNO +#define _WANT_SEMUN +#include "qemu/osdep.h" +#include "qemu/cutils.h" +#include "qemu/path.h" +#include +#include +#include +#include + +#include "qemu.h" +#include "qemu-common.h" +#include "signal-common.h" +#include "user/syscall-trace.h" + +void target_set_brk(abi_ulong new_brk) +{ +} + +bool is_error(abi_long ret) +{ + + return (abi_ulong)ret >= (abi_ulong)(-4096); +} + +/* + * do_syscall() should always have a single exit point at the end so that + * actions, such as logging of syscall results, can be performed. All errnos + * that do_syscall() returns must be -TARGET_. + */ +abi_long do_freebsd_syscall(void *cpu_env, int num, abi_long arg1, + abi_long arg2, abi_long arg3, abi_long arg4, + abi_long arg5, abi_long arg6, abi_long arg7, + abi_long arg8) +{ + return 0; +} + +void syscall_init(void) +{ +} From patchwork Mon Feb 28 18:12:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Warner Losh X-Patchwork-Id: 12763631 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 33014C433EF for ; Mon, 28 Feb 2022 18:24:12 +0000 (UTC) Received: from localhost ([::1]:53104 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nOkgt-0005zP-8u for qemu-devel@archiver.kernel.org; Mon, 28 Feb 2022 13:24:11 -0500 Received: from eggs.gnu.org ([209.51.188.92]:48006) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nOkV0-0008Pb-8k for qemu-devel@nongnu.org; Mon, 28 Feb 2022 13:11:54 -0500 Received: from [2607:f8b0:4864:20::131] (port=45602 helo=mail-il1-x131.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nOkUy-0006aU-Q5 for qemu-devel@nongnu.org; Mon, 28 Feb 2022 13:11:53 -0500 Received: by mail-il1-x131.google.com with SMTP id x14so5521988ill.12 for ; Mon, 28 Feb 2022 10:11:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=hy2bdjFp84wHHa+MT23SEu6EAim31NmTv5svUlwzfpY=; b=pdjDWR0fAl5AkIHlaP4FRIXu4adlhUbCej6k/5yBIOsugsbTSXp2stxJN8b0UvdV/j 3I7WvNsovpP1rrXQbkm9kQMITN1bywaFgJxhdA++NlZgtLEsg9ttCazjUPucT0SXfCBh F7p7HupNl9yqK2T7CLUBVCh97BjLOJC3JxAIgcJhVGfG8JokS1mIdHn5fxz+TFOjafjp FZiAog7BId9SxtUgf85jSSPo/FTRyrYku3+dg6/kOUcozNyWr0dXH9wuI5Khg3nUCzXa CYZLJ/R71q1duBgKUOv19czcrQ6/jlP4QP9Jpclapt+M5ZteAvlAQESXNUvR26dhOI/c kYQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=hy2bdjFp84wHHa+MT23SEu6EAim31NmTv5svUlwzfpY=; b=M0T8poygUGlhXQZYsul/VvQx6QrnH0ObVAnVNv6F6AicgxmiV1wsNdW7YEA5LQJ7nl abI7ulMfFRxb+u3kP6/c1nlZ2qvK4tQJZuiwsRjl9xfvpjMlMh3AmoqggF2aXnTlhErQ xv/nKkK/ICBoCCwl1yANBjCxOOvnM0/FUCZALN5gxcyCfwnhvyy7O2OwLwQ9dqM3fafS eWxTAPaTIsRTlBv7E0e7XTF94Ag27GegxH5bB5hj0LTBkvdNPdNQorQIKwDNKmGZKFuH pgegbtvVYZdgZTbkHsG3xyHUrS56khtXZ38IpdhTVrXBmLp4igu+NopIQ/6wbbS0uI3I 5jiQ== X-Gm-Message-State: AOAM533W+tOpbsHGdjaC9vMQPe49i5GUBQnaNMXAmjg7YTR2A33gm5UP +NwfjbD4cVVAO9NNN9kKjUakb0k8hN/r6A== X-Google-Smtp-Source: ABdhPJyekrIvbPBIkuBoG920SUXlWCbMsawArl9VyQKAXLGSPdIRIaoBV4S7V4RLffrIrziRy5l+jA== X-Received: by 2002:a05:6e02:b29:b0:2c1:a90c:ea6b with SMTP id e9-20020a056e020b2900b002c1a90cea6bmr19513262ilu.175.1646071911562; Mon, 28 Feb 2022 10:11:51 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id s13-20020a6bdc0d000000b006408888551dsm6015396ioc.8.2022.02.28.10.11.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Feb 2022 10:11:51 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PULL 10/16] bsd-user: Move system call building to os-syscall.c Date: Mon, 28 Feb 2022 11:12:08 -0700 Message-Id: <20220228181214.2602-11-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220228181214.2602-1-imp@bsdimp.com> References: <20220228181214.2602-1-imp@bsdimp.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::131 (failed) 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: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , arrowd@FreeBSD.org, Kyle Evans , Richard Henderson , def@FreeBSD.org, jrtc27@FreeBSD.org, Warner Losh , Brad Smith Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Warner Losh Reviewed-by: Richard Henderson --- bsd-user/freebsd/meson.build | 1 + bsd-user/meson.build | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/bsd-user/freebsd/meson.build b/bsd-user/freebsd/meson.build index 4b69cca7b90..f87c788e846 100644 --- a/bsd-user/freebsd/meson.build +++ b/bsd-user/freebsd/meson.build @@ -1,3 +1,4 @@ bsd_user_ss.add(files( 'os-sys.c', + 'os-syscall.c', )) diff --git a/bsd-user/meson.build b/bsd-user/meson.build index 8380fa44c25..5243122fc56 100644 --- a/bsd-user/meson.build +++ b/bsd-user/meson.build @@ -13,7 +13,6 @@ bsd_user_ss.add(files( 'mmap.c', 'signal.c', 'strace.c', - 'syscall.c', 'uaccess.c', )) From patchwork Mon Feb 28 18:12:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Warner Losh X-Patchwork-Id: 12763632 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D3B3EC433F5 for ; Mon, 28 Feb 2022 18:24:55 +0000 (UTC) Received: from localhost ([::1]:55472 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nOkha-0007Xn-NQ for qemu-devel@archiver.kernel.org; Mon, 28 Feb 2022 13:24:54 -0500 Received: from eggs.gnu.org ([209.51.188.92]:48054) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nOkV2-0008WD-Az for qemu-devel@nongnu.org; Mon, 28 Feb 2022 13:11:56 -0500 Received: from [2607:f8b0:4864:20::12b] (port=36631 helo=mail-il1-x12b.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nOkV0-0006al-0P for qemu-devel@nongnu.org; Mon, 28 Feb 2022 13:11:56 -0500 Received: by mail-il1-x12b.google.com with SMTP id e11so10669356ils.3 for ; Mon, 28 Feb 2022 10:11:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=HIQRCpKDC1DawVWcpCJ93ZH5gff2VvNr1ZGmkk/0YIk=; b=HofPnkVU2Qcxz7BdwdWp8nsp73W6RYmkAZTYRtId8xo2ubXsQTmCn9kJeZkWiHcOYg 3ne773U5tfOYMWsKkt3XfXg4Tn0i8cx2Eam3CgMNLuW85xIx72eOiiiPS2rvBrK5rvGa 5V698p+CSU9aU3tl8aF0+dSqXVqChBOUSkZDYsf0+yt7m6OKptVH+gntOjwGG7bGaUym xpSaPQRkucciWEj0RM2ZdtbYTfnLI8By0vRFpH95WlSBSNuKpux+MsxznlhyAExOYfEl xC/k4ksWbO9e7vQuIYJXDPPdZyTlS9WIZQQhw2hNp4t01ktL5Xmw9rpScrqtPb0KOkit IOEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HIQRCpKDC1DawVWcpCJ93ZH5gff2VvNr1ZGmkk/0YIk=; b=I3VGjUZ+/dADVBgUcWnpMvSFsOo6yHpzY7NPPk/S3RzzbFPxduiZdMZSneaEn3+Ut+ 3liqSp7TwxsOjUsyHUBlHURgFh2nR9PGp0xhSzlzdToAdR2aNi3ixa333Kq9HWbR8krK O+hzmSqtNyxE3hv/keUFOmxFvOjkBXTSKL8gJ1Ymmlk5+q2bFAjg++QfFjmbU4VwuWjc kTUDBS3bCT9ezpDOMCWWbko+CoVoBOgDv39zSatrURGN6+C8MNgt5LdygX74U3X804Z3 RzTy1AUIOCdqkAB1cLjp4xuURCFlFKIKKqe1f9zMgT767veTxB6diTAUK6DXzcbSyidh Ri8g== X-Gm-Message-State: AOAM5309sPr3OhWvsl+CsstyzmbWH78KYrPpkLNgn81+MhBzX9d5JhEQ DeD1/52xzf5bzONyAd5B2t7MPAdjPLPT6Q== X-Google-Smtp-Source: ABdhPJzEnWHw+TTtKJOZyN7dYdLUo9A/Qm7m3G5ssIkCA7ci/uA7GrT2caoKicQ0Cz5Lo6HigM/uSw== X-Received: by 2002:a92:d208:0:b0:2c1:1a3c:7b01 with SMTP id y8-20020a92d208000000b002c11a3c7b01mr19023015ily.71.1646071912504; Mon, 28 Feb 2022 10:11:52 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id s13-20020a6bdc0d000000b006408888551dsm6015396ioc.8.2022.02.28.10.11.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Feb 2022 10:11:52 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PULL 11/16] bsd-user/sycall.c: Now obsolete, remove Date: Mon, 28 Feb 2022 11:12:09 -0700 Message-Id: <20220228181214.2602-12-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220228181214.2602-1-imp@bsdimp.com> References: <20220228181214.2602-1-imp@bsdimp.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::12b (failed) Received-SPF: none client-ip=2607:f8b0:4864:20::12b; envelope-from=imp@bsdimp.com; helo=mail-il1-x12b.google.com X-Spam_score_int: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , arrowd@FreeBSD.org, Kyle Evans , Richard Henderson , def@FreeBSD.org, jrtc27@FreeBSD.org, Warner Losh , Brad Smith Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Warner Losh Reviewed-by: Kyle Evans Reviewed-by: Richard Henderson --- bsd-user/syscall.c | 516 --------------------------------------------- 1 file changed, 516 deletions(-) delete mode 100644 bsd-user/syscall.c diff --git a/bsd-user/syscall.c b/bsd-user/syscall.c deleted file mode 100644 index d3322760f43..00000000000 --- a/bsd-user/syscall.c +++ /dev/null @@ -1,516 +0,0 @@ -/* - * BSD syscalls - * - * Copyright (c) 2003 - 2008 Fabrice Bellard - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - */ -#include "qemu/osdep.h" -#include "qemu/cutils.h" -#include "qemu/path.h" -#include -#include -#include -#include - -#include "qemu.h" -#include "qemu-common.h" -#include "user/syscall-trace.h" - -//#define DEBUG - -static abi_ulong target_brk; -static abi_ulong target_original_brk; - -abi_long get_errno(abi_long ret) -{ - if (ret == -1) { - /* XXX need to translate host -> target errnos here */ - return -(errno); - } - return ret; -} - -#define target_to_host_bitmask(x, tbl) (x) - -bool is_error(abi_long ret) -{ - return (abi_ulong)ret >= (abi_ulong)(-4096); -} - -void target_set_brk(abi_ulong new_brk) -{ - target_original_brk = target_brk = HOST_PAGE_ALIGN(new_brk); -} - -/* do_obreak() must return target errnos. */ -static abi_long do_obreak(abi_ulong new_brk) -{ - abi_ulong brk_page; - abi_long mapped_addr; - int new_alloc_size; - - if (!new_brk) - return 0; - if (new_brk < target_original_brk) - return -TARGET_EINVAL; - - brk_page = HOST_PAGE_ALIGN(target_brk); - - /* If the new brk is less than this, set it and we're done... */ - if (new_brk < brk_page) { - target_brk = new_brk; - return 0; - } - - /* We need to allocate more memory after the brk... */ - new_alloc_size = HOST_PAGE_ALIGN(new_brk - brk_page + 1); - mapped_addr = get_errno(target_mmap(brk_page, new_alloc_size, - PROT_READ|PROT_WRITE, - MAP_ANON|MAP_FIXED|MAP_PRIVATE, -1, 0)); - - if (!is_error(mapped_addr)) - target_brk = new_brk; - else - return mapped_addr; - - return 0; -} - -#ifdef __FreeBSD__ -/* - * XXX this uses the undocumented oidfmt interface to find the kind of - * a requested sysctl, see /sys/kern/kern_sysctl.c:sysctl_sysctl_oidfmt() - * (this is mostly copied from src/sbin/sysctl/sysctl.c) - */ -static int -oidfmt(int *oid, int len, char *fmt, uint32_t *kind) -{ - int qoid[CTL_MAXNAME+2]; - uint8_t buf[BUFSIZ]; - int i; - size_t j; - - qoid[0] = 0; - qoid[1] = 4; - memcpy(qoid + 2, oid, len * sizeof(int)); - - j = sizeof(buf); - i = sysctl(qoid, len + 2, buf, &j, 0, 0); - if (i) - return i; - - if (kind) - *kind = *(uint32_t *)buf; - - if (fmt) - strcpy(fmt, (char *)(buf + sizeof(uint32_t))); - return (0); -} - -/* - * try and convert sysctl return data for the target. - * XXX doesn't handle CTLTYPE_OPAQUE and CTLTYPE_STRUCT. - */ -static int sysctl_oldcvt(void *holdp, size_t holdlen, uint32_t kind) -{ - switch (kind & CTLTYPE) { - case CTLTYPE_INT: - case CTLTYPE_UINT: - *(uint32_t *)holdp = tswap32(*(uint32_t *)holdp); - break; -#ifdef TARGET_ABI32 - case CTLTYPE_LONG: - case CTLTYPE_ULONG: - *(uint32_t *)holdp = tswap32(*(long *)holdp); - break; -#else - case CTLTYPE_LONG: - *(uint64_t *)holdp = tswap64(*(long *)holdp); - break; - case CTLTYPE_ULONG: - *(uint64_t *)holdp = tswap64(*(unsigned long *)holdp); - break; -#endif -#ifdef CTLTYPE_U64 - case CTLTYPE_S64: - case CTLTYPE_U64: -#else - case CTLTYPE_QUAD: -#endif - *(uint64_t *)holdp = tswap64(*(uint64_t *)holdp); - break; - case CTLTYPE_STRING: - break; - default: - /* XXX unhandled */ - return -1; - } - return 0; -} - -/* XXX this needs to be emulated on non-FreeBSD hosts... */ -static abi_long do_freebsd_sysctl(abi_ulong namep, int32_t namelen, abi_ulong oldp, - abi_ulong oldlenp, abi_ulong newp, abi_ulong newlen) -{ - abi_long ret; - void *hnamep, *holdp, *hnewp = NULL; - size_t holdlen; - abi_ulong oldlen = 0; - int32_t *snamep = g_malloc(sizeof(int32_t) * namelen), *p, *q, i; - uint32_t kind = 0; - - if (oldlenp) - get_user_ual(oldlen, oldlenp); - if (!(hnamep = lock_user(VERIFY_READ, namep, namelen, 1))) - return -TARGET_EFAULT; - if (newp && !(hnewp = lock_user(VERIFY_READ, newp, newlen, 1))) - return -TARGET_EFAULT; - if (!(holdp = lock_user(VERIFY_WRITE, oldp, oldlen, 0))) - return -TARGET_EFAULT; - holdlen = oldlen; - for (p = hnamep, q = snamep, i = 0; i < namelen; p++, i++) - *q++ = tswap32(*p); - oidfmt(snamep, namelen, NULL, &kind); - /* XXX swap hnewp */ - ret = get_errno(sysctl(snamep, namelen, holdp, &holdlen, hnewp, newlen)); - if (!ret) - sysctl_oldcvt(holdp, holdlen, kind); - put_user_ual(holdlen, oldlenp); - unlock_user(hnamep, namep, 0); - unlock_user(holdp, oldp, holdlen); - if (hnewp) - unlock_user(hnewp, newp, 0); - g_free(snamep); - return ret; -} -#endif - -/* FIXME - * lock_iovec()/unlock_iovec() have a return code of 0 for success where - * other lock functions have a return code of 0 for failure. - */ -static abi_long lock_iovec(int type, struct iovec *vec, abi_ulong target_addr, - int count, int copy) -{ - struct target_iovec *target_vec; - abi_ulong base; - int i; - - target_vec = lock_user(VERIFY_READ, target_addr, count * sizeof(struct target_iovec), 1); - if (!target_vec) - return -TARGET_EFAULT; - for (i = 0;i < count; i++) { - base = tswapl(target_vec[i].iov_base); - vec[i].iov_len = tswapl(target_vec[i].iov_len); - if (vec[i].iov_len != 0) { - vec[i].iov_base = lock_user(type, base, vec[i].iov_len, copy); - /* Don't check lock_user return value. We must call writev even - if a element has invalid base address. */ - } else { - /* zero length pointer is ignored */ - vec[i].iov_base = NULL; - } - } - unlock_user (target_vec, target_addr, 0); - return 0; -} - -static abi_long unlock_iovec(struct iovec *vec, abi_ulong target_addr, - int count, int copy) -{ - struct target_iovec *target_vec; - abi_ulong base; - int i; - - target_vec = lock_user(VERIFY_READ, target_addr, count * sizeof(struct target_iovec), 1); - if (!target_vec) - return -TARGET_EFAULT; - for (i = 0;i < count; i++) { - if (target_vec[i].iov_base) { - base = tswapl(target_vec[i].iov_base); - unlock_user(vec[i].iov_base, base, copy ? vec[i].iov_len : 0); - } - } - unlock_user (target_vec, target_addr, 0); - - return 0; -} - -/* do_syscall() should always have a single exit point at the end so - that actions, such as logging of syscall results, can be performed. - All errnos that do_syscall() returns must be -TARGET_. */ -abi_long do_freebsd_syscall(void *cpu_env, int num, abi_long arg1, - abi_long arg2, abi_long arg3, abi_long arg4, - abi_long arg5, abi_long arg6, abi_long arg7, - abi_long arg8) -{ - CPUState *cpu = env_cpu(cpu_env); - abi_long ret; - void *p; - -#ifdef DEBUG - gemu_log("freebsd syscall %d\n", num); -#endif - record_syscall_start(cpu, num, arg1, arg2, arg3, arg4, arg5, arg6, 0, 0); - - if (do_strace) - print_freebsd_syscall(num, arg1, arg2, arg3, arg4, arg5, arg6); - - switch (num) { - case TARGET_FREEBSD_NR_exit: -#ifdef CONFIG_GPROF - _mcleanup(); -#endif - gdb_exit(arg1); - qemu_plugin_user_exit(); - /* XXX: should free thread stack and CPU env */ - _exit(arg1); - ret = 0; /* avoid warning */ - break; - case TARGET_FREEBSD_NR_read: - if (!(p = lock_user(VERIFY_WRITE, arg2, arg3, 0))) - goto efault; - ret = get_errno(read(arg1, p, arg3)); - unlock_user(p, arg2, ret); - break; - case TARGET_FREEBSD_NR_write: - if (!(p = lock_user(VERIFY_READ, arg2, arg3, 1))) - goto efault; - ret = get_errno(write(arg1, p, arg3)); - unlock_user(p, arg2, 0); - break; - case TARGET_FREEBSD_NR_writev: - { - int count = arg3; - struct iovec *vec; - - vec = alloca(count * sizeof(struct iovec)); - if (lock_iovec(VERIFY_READ, vec, arg2, count, 1) < 0) - goto efault; - ret = get_errno(writev(arg1, vec, count)); - unlock_iovec(vec, arg2, count, 0); - } - break; - case TARGET_FREEBSD_NR_open: - if (!(p = lock_user_string(arg1))) - goto efault; - ret = get_errno(open(path(p), - target_to_host_bitmask(arg2, fcntl_flags_tbl), - arg3)); - unlock_user(p, arg1, 0); - break; - case TARGET_FREEBSD_NR_mmap: - ret = get_errno(target_mmap(arg1, arg2, arg3, - target_to_host_bitmask(arg4, mmap_flags_tbl), - arg5, - arg6)); - break; - case TARGET_FREEBSD_NR_mprotect: - ret = get_errno(target_mprotect(arg1, arg2, arg3)); - break; - case TARGET_FREEBSD_NR_break: - ret = do_obreak(arg1); - break; -#ifdef __FreeBSD__ - case TARGET_FREEBSD_NR___sysctl: - ret = do_freebsd_sysctl(arg1, arg2, arg3, arg4, arg5, arg6); - break; -#endif - case TARGET_FREEBSD_NR_sysarch: - ret = do_freebsd_sysarch(cpu_env, arg1, arg2); - break; - case TARGET_FREEBSD_NR_syscall: - case TARGET_FREEBSD_NR___syscall: - ret = do_freebsd_syscall(cpu_env,arg1 & 0xffff,arg2,arg3,arg4,arg5,arg6,arg7,arg8,0); - break; - default: - ret = get_errno(syscall(num, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)); - break; - } - fail: -#ifdef DEBUG - gemu_log(" = %ld\n", ret); -#endif - if (do_strace) - print_freebsd_syscall_ret(num, ret); - - record_syscall_return(cpu, num, ret); - return ret; - efault: - ret = -TARGET_EFAULT; - goto fail; -} - -abi_long do_netbsd_syscall(void *cpu_env, int num, abi_long arg1, - abi_long arg2, abi_long arg3, abi_long arg4, - abi_long arg5, abi_long arg6) -{ - CPUState *cpu = env_cpu(cpu_env); - abi_long ret; - void *p; - -#ifdef DEBUG - gemu_log("netbsd syscall %d\n", num); -#endif - - record_syscall_start(cpu, num, arg1, arg2, arg3, arg4, arg5, arg6, 0, 0); - - if (do_strace) - print_netbsd_syscall(num, arg1, arg2, arg3, arg4, arg5, arg6); - - switch (num) { - case TARGET_NETBSD_NR_exit: -#ifdef CONFIG_GPROF - _mcleanup(); -#endif - gdb_exit(arg1); - qemu_plugin_user_exit(); - /* XXX: should free thread stack and CPU env */ - _exit(arg1); - ret = 0; /* avoid warning */ - break; - case TARGET_NETBSD_NR_read: - if (!(p = lock_user(VERIFY_WRITE, arg2, arg3, 0))) - goto efault; - ret = get_errno(read(arg1, p, arg3)); - unlock_user(p, arg2, ret); - break; - case TARGET_NETBSD_NR_write: - if (!(p = lock_user(VERIFY_READ, arg2, arg3, 1))) - goto efault; - ret = get_errno(write(arg1, p, arg3)); - unlock_user(p, arg2, 0); - break; - case TARGET_NETBSD_NR_open: - if (!(p = lock_user_string(arg1))) - goto efault; - ret = get_errno(open(path(p), - target_to_host_bitmask(arg2, fcntl_flags_tbl), - arg3)); - unlock_user(p, arg1, 0); - break; - case TARGET_NETBSD_NR_mmap: - ret = get_errno(target_mmap(arg1, arg2, arg3, - target_to_host_bitmask(arg4, mmap_flags_tbl), - arg5, - arg6)); - break; - case TARGET_NETBSD_NR_mprotect: - ret = get_errno(target_mprotect(arg1, arg2, arg3)); - break; - case TARGET_NETBSD_NR_syscall: - case TARGET_NETBSD_NR___syscall: - ret = do_netbsd_syscall(cpu_env,arg1 & 0xffff,arg2,arg3,arg4,arg5,arg6,0); - break; - default: - ret = syscall(num, arg1, arg2, arg3, arg4, arg5, arg6); - break; - } - fail: -#ifdef DEBUG - gemu_log(" = %ld\n", ret); -#endif - if (do_strace) - print_netbsd_syscall_ret(num, ret); - - record_syscall_return(cpu, num, ret); - return ret; - efault: - ret = -TARGET_EFAULT; - goto fail; -} - -abi_long do_openbsd_syscall(void *cpu_env, int num, abi_long arg1, - abi_long arg2, abi_long arg3, abi_long arg4, - abi_long arg5, abi_long arg6) -{ - CPUState *cpu = env_cpu(cpu_env); - abi_long ret; - void *p; - -#ifdef DEBUG - gemu_log("openbsd syscall %d\n", num); -#endif - - record_syscall_start(cpu, num, arg1, arg2, arg3, arg4, arg5, arg6, 0, 0); - - if (do_strace) - print_openbsd_syscall(num, arg1, arg2, arg3, arg4, arg5, arg6); - - switch (num) { - case TARGET_OPENBSD_NR_exit: -#ifdef CONFIG_GPROF - _mcleanup(); -#endif - gdb_exit(arg1); - qemu_plugin_user_exit(); - /* XXX: should free thread stack and CPU env */ - _exit(arg1); - ret = 0; /* avoid warning */ - break; - case TARGET_OPENBSD_NR_read: - if (!(p = lock_user(VERIFY_WRITE, arg2, arg3, 0))) - goto efault; - ret = get_errno(read(arg1, p, arg3)); - unlock_user(p, arg2, ret); - break; - case TARGET_OPENBSD_NR_write: - if (!(p = lock_user(VERIFY_READ, arg2, arg3, 1))) - goto efault; - ret = get_errno(write(arg1, p, arg3)); - unlock_user(p, arg2, 0); - break; - case TARGET_OPENBSD_NR_open: - if (!(p = lock_user_string(arg1))) - goto efault; - ret = get_errno(open(path(p), - target_to_host_bitmask(arg2, fcntl_flags_tbl), - arg3)); - unlock_user(p, arg1, 0); - break; - case TARGET_OPENBSD_NR_mmap: - ret = get_errno(target_mmap(arg1, arg2, arg3, - target_to_host_bitmask(arg4, mmap_flags_tbl), - arg5, - arg6)); - break; - case TARGET_OPENBSD_NR_mprotect: - ret = get_errno(target_mprotect(arg1, arg2, arg3)); - break; - case TARGET_OPENBSD_NR_syscall: - case TARGET_OPENBSD_NR___syscall: - ret = do_openbsd_syscall(cpu_env,arg1 & 0xffff,arg2,arg3,arg4,arg5,arg6,0); - break; - default: - ret = syscall(num, arg1, arg2, arg3, arg4, arg5, arg6); - break; - } - fail: -#ifdef DEBUG - gemu_log(" = %ld\n", ret); -#endif - if (do_strace) - print_openbsd_syscall_ret(num, ret); - - record_syscall_return(cpu, num, ret); - return ret; - efault: - ret = -TARGET_EFAULT; - goto fail; -} - -void syscall_init(void) -{ -} From patchwork Mon Feb 28 18:12:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Warner Losh X-Patchwork-Id: 12763634 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8FDBEC433F5 for ; Mon, 28 Feb 2022 18:26:51 +0000 (UTC) Received: from localhost ([::1]:33858 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nOkjS-0003ac-K0 for qemu-devel@archiver.kernel.org; Mon, 28 Feb 2022 13:26:50 -0500 Received: from eggs.gnu.org ([209.51.188.92]:48084) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nOkV4-0000Ah-DR for qemu-devel@nongnu.org; Mon, 28 Feb 2022 13:11:58 -0500 Received: from [2607:f8b0:4864:20::132] (port=40803 helo=mail-il1-x132.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nOkV1-0006b7-Uk for qemu-devel@nongnu.org; Mon, 28 Feb 2022 13:11:58 -0500 Received: by mail-il1-x132.google.com with SMTP id i1so10653387ila.7 for ; Mon, 28 Feb 2022 10:11:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VjL7Mev6xqaa0v+8+i8B7VWCn7P7IPzcwixzN9m4rZc=; b=YGQAX0/b0az4qwLv9k10bhyViMyWDiKT89fqINlh7UFR6ZFgPBajuXif4h6pjliwYQ SpwJ9fp3PBC0yKG7CA9aMsCCPukUvKiIB9Ca7cGjNItbjWQ5VWy9tcUAH0uOCg2NgSAL xcwu1QGsx5p1HiTNq1LAGF5eB1q+4cyx/d5w6DdL+jKPoKdajmhNEl3rxVNTxpIy7oEI F2GPQ329pZ/OgUFHo8d9TyoMovYxITtPSrDVgM/0wNUt//w4eYmiNMpX8J9l37wA0pwE cL23KUF9EGMShLQGXlsKvol2Cd2/PRJ1EZIC7rtSYLEiTG79QgXJIL/7IySenk+IiV4S g1tA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VjL7Mev6xqaa0v+8+i8B7VWCn7P7IPzcwixzN9m4rZc=; b=3P1ipW5vI2CVuN2+wWC4Jz5uMs6DgYenwdre0bDA3inzh+UeSnXcMOqh/iKskZAhxT 9RYuD4XRDuOnhPo2ZVk1s/9AJzaNmwLY5F+8NZsonCGx4Omxbg+GbH1ktcEIjQhXdkCH kvaS4qfGLMHfMspBIg3jtwDRsmb09oui7UAQfpJ6rVgGNJBIuwH1RfKOhRGKbRGCqxUk EEMv4YJ0XvnmP2b3kIvkLyW3CXvmm/LqU3FcyfiB9AFh+iC1UAcDogTfB+IoZ0nkiu9N Ml6OxXVoGxE4w6/CTli3fn2ROhSn9r+XXtTwu+gqsv0kI7CcwB+UC2f+Wmn/M5bi1o/b 4EQQ== X-Gm-Message-State: AOAM530ivwCJhsL8qRN0SRDLahwzP5cwH+3FqXk1v/Zy2pA2yxPy3h6x jjt09ZbPtfMVCzB0lB8+aHIJp0OA9o+e7g== X-Google-Smtp-Source: ABdhPJxl3UjLErD8hVC8ymiw9FxwD/YEiG6bOq6nThDAtTIbRfner+KyEiEl7qqH1nrXLvPA/NLTUA== X-Received: by 2002:a92:8e4a:0:b0:2bc:1a0d:ed41 with SMTP id k10-20020a928e4a000000b002bc1a0ded41mr20067781ilh.96.1646071913636; Mon, 28 Feb 2022 10:11:53 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id s13-20020a6bdc0d000000b006408888551dsm6015396ioc.8.2022.02.28.10.11.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Feb 2022 10:11:53 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PULL 12/16] bsd-user/freebsd/os-syscall.c: Add get_errno and host_to_target_errno Date: Mon, 28 Feb 2022 11:12:10 -0700 Message-Id: <20220228181214.2602-13-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220228181214.2602-1-imp@bsdimp.com> References: <20220228181214.2602-1-imp@bsdimp.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::132 (failed) 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: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , arrowd@FreeBSD.org, Kyle Evans , Richard Henderson , def@FreeBSD.org, jrtc27@FreeBSD.org, Warner Losh , Brad Smith Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Add the helper functions get_errno and host_to_target_errno. get_errno returns either the system call results, or the -errno when system call indicates failure by returning -1. Host_to_target_errno returns errno (since on FreeBSD they are the same on all architectures) along with a comment about why it's the identity. Signed-off-by: Warner Losh Reviewed-by: Kyle Evans Reviewed-by: Richard Henderson --- bsd-user/freebsd/os-syscall.c | 23 ++++++++++++++++++++++- bsd-user/qemu.h | 3 ++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index fc57e324173..597a41c2f50 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -45,9 +45,30 @@ void target_set_brk(abi_ulong new_brk) { } -bool is_error(abi_long ret) +/* + * errno conversion. + */ +abi_long get_errno(abi_long ret) { + if (ret == -1) { + return -host_to_target_errno(errno); + } else { + return ret; + } +} +int host_to_target_errno(int err) +{ + /* + * All the BSDs have the property that the error numbers are uniform across + * all architectures for a given BSD, though they may vary between different + * BSDs. + */ + return err; +} + +bool is_error(abi_long ret) +{ return (abi_ulong)ret >= (abi_ulong)(-4096); } diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h index e5742bd6c03..56042ddbc5d 100644 --- a/bsd-user/qemu.h +++ b/bsd-user/qemu.h @@ -246,9 +246,10 @@ extern unsigned long target_dflssiz; extern unsigned long target_maxssiz; extern unsigned long target_sgrowsiz; -/* syscall.c */ +/* os-syscall.c */ abi_long get_errno(abi_long ret); bool is_error(abi_long ret); +int host_to_target_errno(int err); /* os-sys.c */ abi_long do_freebsd_sysarch(void *cpu_env, abi_long arg1, abi_long arg2); From patchwork Mon Feb 28 18:12:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Warner Losh X-Patchwork-Id: 12763633 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E7E1BC433F5 for ; Mon, 28 Feb 2022 18:25:53 +0000 (UTC) Received: from localhost ([::1]:59652 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nOkiX-0001y5-1K for qemu-devel@archiver.kernel.org; Mon, 28 Feb 2022 13:25:53 -0500 Received: from eggs.gnu.org ([209.51.188.92]:48074) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nOkV3-00008x-K0 for qemu-devel@nongnu.org; Mon, 28 Feb 2022 13:11:57 -0500 Received: from [2607:f8b0:4864:20::d2f] (port=46024 helo=mail-io1-xd2f.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nOkV2-0006bA-3B for qemu-devel@nongnu.org; Mon, 28 Feb 2022 13:11:57 -0500 Received: by mail-io1-xd2f.google.com with SMTP id c14so15630356ioa.12 for ; Mon, 28 Feb 2022 10:11:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=fn4/rm/OJxkJxNYI+SpIvqX9qWLZWvAB3WmoXDOuRIk=; b=rKDLlwDkGojBhTI4vaTj+Rx7EDqtL6Kd6YahAtgjzjjifpm/mEL8/rYSwM1pRUKnty bSsdhbbgWmhcbIMU3ESUAZ3RMbVaiXxc2qpYw8LUzcC3zdkr31UwMKRhpc320JMhA2li /iPiprWp4n4oDwMIJHsiaPId1Tp6Rw9JSsTu/LM4VGd3uCB/QOmqyj9hTnssqXkN+PU3 Cv6insmAth0ZfX/d3HJv4/8ljasnINGAiAqmvmJ/1hPt+ZG769GZspyLacsrI+uk/S5U Hu67JHV42R9iKkM5b/EvT0uNM+dFVR1AuXPTQnHxu0ngZkmjeVNRj3Z18sNBL6yfpshK plDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=fn4/rm/OJxkJxNYI+SpIvqX9qWLZWvAB3WmoXDOuRIk=; b=CaC9lgBrvIL0dFIdPSQtiECGwLXVmLk4vop7//Paw+8lgsJ0PGb7mD8fMMwa3Oj/qu 6bSXdyna95uHNe7aRecoI+7SHIxh9Z6iWcinaWYOicxXzFLzSYO+Y0BeL9IAMbS1NDQg MNpT++hbEVmJG8og+XHq9CLrtiuxJAd4YUeQJcb0OgTvUbwSbAqNrn1FN1IxL9OlcNdH xPPTdWfN/I89fnn38C1FUgzrdC6PPcLjsyyHrNgVIGslvTJDQ5iL2mkWIfRhPSdDUo2H sxKATkg/q+iTnMhpNOZVWIxZI1vdI4Z5DZFqn6OF0rVRE8xr5kJkhoiepTuR2dimvDvV 48sg== X-Gm-Message-State: AOAM530FeUZSWVIta6+juUf7FcebyVVJa7MJqQGR4+D8eBxWrSzFjTB7 J8DnUAARZNkLAfcHYxxFymcG76pRvUWYIQ== X-Google-Smtp-Source: ABdhPJxmDUThMFtL20g6vrmm3mIeJVwQf/4ryIFrKIWIjJ39t2FA7cyWk8cJFkjnT8IsMGK5SjfUgA== X-Received: by 2002:a6b:8e17:0:b0:60d:c43a:6992 with SMTP id q23-20020a6b8e17000000b0060dc43a6992mr16450968iod.24.1646071914805; Mon, 28 Feb 2022 10:11:54 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id s13-20020a6bdc0d000000b006408888551dsm6015396ioc.8.2022.02.28.10.11.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Feb 2022 10:11:54 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PULL 13/16] bsd-user/bsd-file.h: Implementation details for the filesystem calls Date: Mon, 28 Feb 2022 11:12:11 -0700 Message-Id: <20220228181214.2602-14-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220228181214.2602-1-imp@bsdimp.com> References: <20220228181214.2602-1-imp@bsdimp.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::d2f (failed) Received-SPF: none client-ip=2607:f8b0:4864:20::d2f; envelope-from=imp@bsdimp.com; helo=mail-io1-xd2f.google.com X-Spam_score_int: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , arrowd@FreeBSD.org, Kyle Evans , Richard Henderson , def@FreeBSD.org, jrtc27@FreeBSD.org, Warner Losh , Brad Smith Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" An include file that pulls in all the definitions needed for the file related system calls. This also includes the host definitions to implement the system calls and some helper routines to lock/unlock different aspects of the system call arguments. Signed-off-by: Warner Losh Reviewed-by: Richard Henderson --- bsd-user/bsd-file.h | 30 ++++++++++++++++++++++++++++++ bsd-user/freebsd/os-syscall.c | 2 ++ 2 files changed, 32 insertions(+) create mode 100644 bsd-user/bsd-file.h diff --git a/bsd-user/bsd-file.h b/bsd-user/bsd-file.h new file mode 100644 index 00000000000..f0c3f347ec0 --- /dev/null +++ b/bsd-user/bsd-file.h @@ -0,0 +1,30 @@ +/* + * file related system call shims and definitions + * + * Copyright (c) 2013 Stacey D. Son + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + */ + +#ifndef BSD_FILE_H_ +#define BSD_FILE_H_ + +#include "qemu/path.h" + +extern struct iovec *lock_iovec(int type, abi_ulong target_addr, int count, + int copy); +extern void unlock_iovec(struct iovec *vec, abi_ulong target_addr, int count, + int copy); + +#endif /* !BSD_FILE_H_ */ diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index 597a41c2f50..a17ff9f6ecc 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -41,6 +41,8 @@ #include "signal-common.h" #include "user/syscall-trace.h" +#include "bsd-file.h" + void target_set_brk(abi_ulong new_brk) { } From patchwork Mon Feb 28 18:12:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Warner Losh X-Patchwork-Id: 12763627 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9B18BC433F5 for ; Mon, 28 Feb 2022 18:21:26 +0000 (UTC) Received: from localhost ([::1]:45122 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nOkeD-0000bM-PD for qemu-devel@archiver.kernel.org; Mon, 28 Feb 2022 13:21:25 -0500 Received: from eggs.gnu.org ([209.51.188.92]:48190) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nOkVI-0000zA-DF for qemu-devel@nongnu.org; Mon, 28 Feb 2022 13:12:12 -0500 Received: from [2607:f8b0:4864:20::d32] (port=37847 helo=mail-io1-xd32.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nOkV3-0006bb-Vm for qemu-devel@nongnu.org; Mon, 28 Feb 2022 13:12:12 -0500 Received: by mail-io1-xd32.google.com with SMTP id c23so15692275ioi.4 for ; Mon, 28 Feb 2022 10:11:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=g2a4iUrTub2nz3g1lIS5iV9/jqK5TM3KXVGIVjpt/k4=; b=kWavE4RsO/SmqlKVhbX/5I71z9TcvJ4VB1kJoXVwo9m9vISk6KZbMcGmJ6V6RwR004 03XwBYma5ODpfTx8KOmoZ9kHjxBVn7XDu0qe0gXNcEWUsg3jAmY2Ra3v6jpFCwP/jdqo XijSBNbjPrpsJCxlW8b2Q+0kW6H7qSrZN0vMpUR/SjhtqQC44nXMVVqaw+e+7xBYoPmk xGDDANcgJVkmcQSK8YvFYoXXd0qXJewQXbso1JpuHEgtvQVK8LPTglH97dZd1yyW+FSR pBhhklSJO+QIh5NFsMyhUKajIdR9x9BQw2/DYKlkAgGeYG+StEB7bcmVPe8G6kfYN5Gy Utgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=g2a4iUrTub2nz3g1lIS5iV9/jqK5TM3KXVGIVjpt/k4=; b=eeHSXuwE+twmtTsAnhz/RqMojO0A5ZZNhFEhT1Drz0jmLKxaGkdB9LNx/sSVil/hkX CG6VmDczQVV/wupcRY+uKPqU/xaarPtWiogrnxAJVfKptI9r5Osb0dNgi7i/gC5LUw6J N5ADFt7QSuW37c4u0aTnV6iOgIbLHOXAXBFEteaXk06vs6OcVLoGQASShQ+9pH0/MZ2E fhXrEweOHVfnLXyMaayx2BiZCpJSPRJLnJ9FYik0oQPR2GYU5LMHsAfYXaj50947WTDe dadL6oAE0wJhL81Ggd42rNFSXhUr0hMzGJxvQysPHXR6VsmY9hPBN79mxo6vk1XaMHcs Xagw== X-Gm-Message-State: AOAM531uZes8Q3EGWMd7jX+u8wjRAt+fDBQdAIqqaDAWXZkCfEwovWZm fkipD05GuP1oXBUulsNK/gf1+DQpR+PRZg== X-Google-Smtp-Source: ABdhPJy4J3YhbqsmrND0CDov7xcep5j1fkY3PLB0IUklPhcBcWVLLXCP2lwXwqXdUEpOzgVezoxEaw== X-Received: by 2002:a05:6638:1453:b0:308:eafa:41c with SMTP id l19-20020a056638145300b00308eafa041cmr18289626jad.30.1646071915780; Mon, 28 Feb 2022 10:11:55 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id s13-20020a6bdc0d000000b006408888551dsm6015396ioc.8.2022.02.28.10.11.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Feb 2022 10:11:55 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PULL 14/16] bsd-user: introduce target.h Date: Mon, 28 Feb 2022 11:12:12 -0700 Message-Id: <20220228181214.2602-15-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220228181214.2602-1-imp@bsdimp.com> References: <20220228181214.2602-1-imp@bsdimp.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::d32 (failed) Received-SPF: none client-ip=2607:f8b0:4864:20::d32; envelope-from=imp@bsdimp.com; helo=mail-io1-xd32.google.com X-Spam_score_int: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, PDS_HP_HELO_NORDNS=0.659, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , arrowd@FreeBSD.org, Kyle Evans , Richard Henderson , def@FreeBSD.org, jrtc27@FreeBSD.org, Warner Losh , Brad Smith Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Create target.h. This file is intended to be simple and describe basic things about the architecture. If something is a basic feature of the architecture, it belongs here. Should we need something that's per-BSD there will be a target-os.h that will live in the per-bsd directories. Define regpairs_aligned to reflect whether or not registers are 'paired' for 64-bit arguments or not. This will be false for all 64-bit targets, and will be true on those architectures that pair (currently just armv7 and powerpc on FreeBSD 14.x). Signed-off-by: Warner Losh Reviewed-by: Kyle Evans Reviewed-by: Richard Henderson --- bsd-user/arm/target.h | 21 +++++++++++++++++++++ bsd-user/i386/target.h | 21 +++++++++++++++++++++ bsd-user/qemu.h | 1 + bsd-user/x86_64/target.h | 21 +++++++++++++++++++++ 4 files changed, 64 insertions(+) create mode 100644 bsd-user/arm/target.h create mode 100644 bsd-user/i386/target.h create mode 100644 bsd-user/x86_64/target.h diff --git a/bsd-user/arm/target.h b/bsd-user/arm/target.h new file mode 100644 index 00000000000..419c039b68e --- /dev/null +++ b/bsd-user/arm/target.h @@ -0,0 +1,21 @@ +/* + * Intel general target stuff that's common to all i386 details + * + * Copyright (c) 2022 M. Warner Losh + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef TARGET_H +#define TARGET_H + +/* + * arm EABI 'lumps' the registers for 64-bit args. + */ +static inline bool regpairs_aligned(void *cpu_env) +{ + return true; +} + +#endif /* ! TARGET_H */ + diff --git a/bsd-user/i386/target.h b/bsd-user/i386/target.h new file mode 100644 index 00000000000..9b9df047a3b --- /dev/null +++ b/bsd-user/i386/target.h @@ -0,0 +1,21 @@ +/* + * Intel general target stuff that's common to all i386 details + * + * Copyright (c) 2022 M. Warner Losh + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef TARGET_ARCH_H +#define TARGET_ARCH_H + +/* + * i386 doesn't 'lump' the registers for 64-bit args. + */ +static inline bool regpairs_aligned(void *cpu_env) +{ + return false; +} + +#endif /* ! TARGET_ARCH_H */ + diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h index 56042ddbc5d..a9efa807b78 100644 --- a/bsd-user/qemu.h +++ b/bsd-user/qemu.h @@ -35,6 +35,7 @@ extern char **environ; #include "target_syscall.h" #include "target_os_vmparam.h" #include "target_os_signal.h" +#include "target.h" #include "exec/gdbstub.h" /* diff --git a/bsd-user/x86_64/target.h b/bsd-user/x86_64/target.h new file mode 100644 index 00000000000..8956631db1d --- /dev/null +++ b/bsd-user/x86_64/target.h @@ -0,0 +1,21 @@ +/* + * Intel general target stuff that's common to all x86_64 details + * + * Copyright (c) 2022 M. Warner Losh + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef TARGET_H +#define TARGET_H + +/* + * x86 doesn't 'lump' the registers for 64-bit args, all args are 64 bits. + */ +static inline bool regpairs_aligned(void *cpu_env) +{ + return false; +} + +#endif /* ! TARGET_H */ + From patchwork Mon Feb 28 18:12:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Warner Losh X-Patchwork-Id: 12763638 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 89B54C433EF for ; Mon, 28 Feb 2022 18:29:05 +0000 (UTC) Received: from localhost ([::1]:38136 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nOklc-0006VL-O0 for qemu-devel@archiver.kernel.org; Mon, 28 Feb 2022 13:29:04 -0500 Received: from eggs.gnu.org ([209.51.188.92]:48132) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nOkVF-0000ob-RV for qemu-devel@nongnu.org; Mon, 28 Feb 2022 13:12:09 -0500 Received: from [2607:f8b0:4864:20::d35] (port=35446 helo=mail-io1-xd35.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nOkV4-0006bj-39 for qemu-devel@nongnu.org; Mon, 28 Feb 2022 13:12:09 -0500 Received: by mail-io1-xd35.google.com with SMTP id q8so15687264iod.2 for ; Mon, 28 Feb 2022 10:11:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7Y45btB372BUYpl0DMg2V5qSfR8CjjH9rCY8SnGr7hw=; b=GFvWjw/0JzPK1OwVfjy4Zy9hHyNkHdm2CAJ7Z933gv+cZBtWBOtLhrzfylAjcewops RIcp+87MWOOFOf5pmcXMrbITHq+qxVN9GzsTz5fXx0RMlyjhJ6BTKa7aOdBCBD44LGLT XkMdYmZQ/8xSWK5ZyW0/DS/UAhdqmxWScwDJ/vg+CDQzDLv8tusvUSZtmPsrBZ0mskvX j7ORo3kYSPLRC83eIuf1VvbaOMZSEXXj7Z4YtvdOhzDzDhf7HJdfcLyVnRjaSz+n6a3Q 5i7L8g0O26djCnv2NhaFkndWbTwY/MtSKeADUV/FerN0qKjCSwtBYzIkSJtPw4yFqt20 18RA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7Y45btB372BUYpl0DMg2V5qSfR8CjjH9rCY8SnGr7hw=; b=vQnWIr4HPgCqi2ddt8GS4MYI0wE1Cbpt9HYwV4xZOlpjV1PiYeVGGsAr0XpmmvfCWx tibNWVA/PZ98gQwPRKc5l7z/4ybi6uEatkTJikdsIhuMgUUpLUycyKgar+DZWAlebWqf 7wk51+75s2g5UkDGhZuvFhuLBFiT6CNZStN8D8h5D1Tm3F9itGjJIYD2T8D+u45NlWnf tzrKNjcdG5SmGA464/43+o0SDAE3cIt0jYlXo/J1MGy1XQTWcVoRwGfakaBFdxiWtTCb jVOm/tAModSAdCaj8ANLDg8OoHOyyrTrVyANYuMo+QdTamSXidOdJ3MjHnTg9ZMtCs02 ETew== X-Gm-Message-State: AOAM530KdA9JK9Xn3Xuh+td5f0YmgnGlNf3oGDaIWF8p/5coobzRRk9X glIQXumMeJ8jGycAypKTfXQ+vtXfnaoUmA== X-Google-Smtp-Source: ABdhPJz8KNkpxydAyxGgb4+aVdAqJY1Z8L/ku9EhI5+AaS3F8pvlU4Knolwq1YtQPceqFwTsWMfTYQ== X-Received: by 2002:a05:6638:378c:b0:313:f08c:e4df with SMTP id w12-20020a056638378c00b00313f08ce4dfmr18112321jal.192.1646071916793; Mon, 28 Feb 2022 10:11:56 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id s13-20020a6bdc0d000000b006408888551dsm6015396ioc.8.2022.02.28.10.11.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Feb 2022 10:11:56 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PULL 15/16] bsd-user: Define target_arg64 Date: Mon, 28 Feb 2022 11:12:13 -0700 Message-Id: <20220228181214.2602-16-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220228181214.2602-1-imp@bsdimp.com> References: <20220228181214.2602-1-imp@bsdimp.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::d35 (failed) Received-SPF: none client-ip=2607:f8b0:4864:20::d35; envelope-from=imp@bsdimp.com; helo=mail-io1-xd35.google.com X-Spam_score_int: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Stacey Son , arrowd@FreeBSD.org, Kyle Evans , Richard Henderson , def@FreeBSD.org, jrtc27@FreeBSD.org, Warner Losh , Brad Smith Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" target_arg64 is a generic way to extract 64-bits from a pair of arguments. On 32-bit platforms, it returns them joined together as appropriate. On 64-bit platforms, it returns the first arg because it's already 64-bits. Signed-off-by: Stacey Son Signed-off-by: Warner Losh Reviewed-by: Kyle Evans Reviewed-by: Richard Henderson --- bsd-user/qemu.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h index a9efa807b78..af272c2a802 100644 --- a/bsd-user/qemu.h +++ b/bsd-user/qemu.h @@ -462,6 +462,19 @@ static inline void *lock_user_string(abi_ulong guest_addr) #define unlock_user_struct(host_ptr, guest_addr, copy) \ unlock_user(host_ptr, guest_addr, (copy) ? sizeof(*host_ptr) : 0) +static inline uint64_t target_arg64(uint32_t word0, uint32_t word1) +{ +#if TARGET_ABI_BITS == 32 +#ifdef TARGET_WORDS_BIGENDIAN + return ((uint64_t)word0 << 32) | word1; +#else + return ((uint64_t)word1 << 32) | word0; +#endif +#else /* TARGET_ABI_BITS != 32 */ + return word0; +#endif /* TARGET_ABI_BITS != 32 */ +} + #include #include "user/safe-syscall.h" From patchwork Mon Feb 28 18:12:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Warner Losh X-Patchwork-Id: 12763635 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 34FFEC433EF for ; Mon, 28 Feb 2022 18:28:41 +0000 (UTC) Received: from localhost ([::1]:36492 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nOklE-0005Oe-5f for qemu-devel@archiver.kernel.org; Mon, 28 Feb 2022 13:28:40 -0500 Received: from eggs.gnu.org ([209.51.188.92]:48160) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nOkVH-0000tA-51 for qemu-devel@nongnu.org; Mon, 28 Feb 2022 13:12:11 -0500 Received: from [2607:f8b0:4864:20::d34] (port=42678 helo=mail-io1-xd34.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nOkV5-0006by-AK for qemu-devel@nongnu.org; Mon, 28 Feb 2022 13:12:10 -0500 Received: by mail-io1-xd34.google.com with SMTP id r8so2089659ioj.9 for ; Mon, 28 Feb 2022 10:11:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=rjqNkZos8HcanC51tcv3i0kE1ONfZDlQEksCXgwLEAI=; b=28UW+7ofLUKsqtYxfpUHOs7o0ChRSa8wvGh3V8AZ8Rj79GFejKwjmGElfLQvqKI77Y iq/5Nn5b4czBdqStomVmNSbazeJrCR8BQuQJ1hXrbq7WAg408hs/pTkS8CIEKnJQThJ4 c8Frm9X/6/0dkg4RB4rv6UVOFR2mH8kL8xHh9XImX6qI8nV5k4d3g+3t65FIgtpg4Idr D6Jdgp6vKfBGN2v//ydxlL+YiTPgVsf4G1nXzLJwJEPFhBkm4Ka1sNjT2rXLpLCjCekL 4WMey7jHxKTt+iDHJNNHpCJCDeOd0+PR/PK5kLL9XvGK//DQ6ms9tpqBCBY3voO8GOpx 11gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rjqNkZos8HcanC51tcv3i0kE1ONfZDlQEksCXgwLEAI=; b=8GmlmdHwCudBTWoOOKUIiCoYDX4dy0x+zHxfN9hGv3EuShAyXiloIYak4OAY0ywWVs jSMjCuarNFuH27h5k/Zst3XPB4PljTn5icBV3yQCsU+zlzrGfGBinflT9HhsOmPY73Xa XqHEFnJx9XG1MCdch/HEXOxlFe5DuKklNa4pv0i94q2ezRmYHRD2qRgxwoF0GT4gnkVz PzmHsD7e4qj3CWop/qHxS5NGWp0fYOmruEyySUlpThDdo54F2n4UbeTVC9pVBUPaJgLn Z3QbeLRY2xY2/vgXtPUqZksDiJUHSQNTWA2Bd+fra+zGV2/U3mIorB1DSOiaBQ+pLZ9p YtGA== X-Gm-Message-State: AOAM532QyEcucLNKCZcZYQ1KOUR7QRcG8zYaXuhQzLeEvksQz0O7HiXn qMfi051WB+hSaDscH4jl2z18DG+jUgv+8w== X-Google-Smtp-Source: ABdhPJw28kvRSo3JdB0B+ea5eNG38Fk7InzwKWhvh4BS0RwTl9O211sARbk0dS2OrVGUfyIB/jB+yA== X-Received: by 2002:a05:6602:124a:b0:641:2c16:32de with SMTP id o10-20020a056602124a00b006412c1632demr16487751iou.149.1646071917959; Mon, 28 Feb 2022 10:11:57 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id s13-20020a6bdc0d000000b006408888551dsm6015396ioc.8.2022.02.28.10.11.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Feb 2022 10:11:57 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PULL 16/16] bsd-user: Add safe system call macros Date: Mon, 28 Feb 2022 11:12:14 -0700 Message-Id: <20220228181214.2602-17-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220228181214.2602-1-imp@bsdimp.com> References: <20220228181214.2602-1-imp@bsdimp.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::d34 (failed) 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: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , arrowd@FreeBSD.org, Kyle Evans , Richard Henderson , def@FreeBSD.org, jrtc27@FreeBSD.org, Warner Losh , Brad Smith Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Add a series of macros to create system call macros that go via the safe_syscall path. Signed-off-by: Kyle Evans Signed-off-by: Warner Losh Reviewed-by: Richard Henderson --- bsd-user/syscall_defs.h | 47 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/bsd-user/syscall_defs.h b/bsd-user/syscall_defs.h index 62b472b990b..c3bf14f38f4 100644 --- a/bsd-user/syscall_defs.h +++ b/bsd-user/syscall_defs.h @@ -179,4 +179,51 @@ struct target_freebsd__wrusage { struct target_freebsd_rusage wru_children; }; +#define safe_syscall0(type, name) \ +type safe_##name(void) \ +{ \ + return safe_syscall(SYS_##name); \ +} + +#define safe_syscall1(type, name, type1, arg1) \ +type safe_##name(type1 arg1) \ +{ \ + return safe_syscall(SYS_##name, arg1); \ +} + +#define safe_syscall2(type, name, type1, arg1, type2, arg2) \ +type safe_##name(type1 arg1, type2 arg2) \ +{ \ + return safe_syscall(SYS_##name, arg1, arg2); \ +} + +#define safe_syscall3(type, name, type1, arg1, type2, arg2, type3, arg3) \ +type safe_##name(type1 arg1, type2 arg2, type3 arg3) \ +{ \ + return safe_syscall(SYS_##name, arg1, arg2, arg3); \ +} + +#define safe_syscall4(type, name, type1, arg1, type2, arg2, type3, arg3, \ + type4, arg4) \ +type safe_##name(type1 arg1, type2 arg2, type3 arg3, type4 arg4) \ +{ \ + return safe_syscall(SYS_##name, arg1, arg2, arg3, arg4); \ +} + +#define safe_syscall5(type, name, type1, arg1, type2, arg2, type3, arg3, \ + type4, arg4, type5, arg5) \ +type safe_##name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ + type5 arg5) \ +{ \ + return safe_syscall(SYS_##name, arg1, arg2, arg3, arg4, arg5); \ +} + +#define safe_syscall6(type, name, type1, arg1, type2, arg2, type3, arg3, \ + type4, arg4, type5, arg5, type6, arg6) \ +type safe_##name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ + type5 arg5, type6 arg6) \ +{ \ + return safe_syscall(SYS_##name, arg1, arg2, arg3, arg4, arg5, arg6); \ +} + #endif /* ! _SYSCALL_DEFS_H_ */