From patchwork Sat Aug 19 09:47:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karim Taha X-Patchwork-Id: 1823268 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=apsaA/t/; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RSYqx5lYgz1yfn for ; Sat, 19 Aug 2023 19:49:49 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qXIZq-000881-Jc; Sat, 19 Aug 2023 05:49:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qXIZK-0007sD-Qv for qemu-devel@nongnu.org; Sat, 19 Aug 2023 05:48:37 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qXIZF-0004FD-93 for qemu-devel@nongnu.org; Sat, 19 Aug 2023 05:48:27 -0400 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-3fe4cdb72b9so16333515e9.0 for ; Sat, 19 Aug 2023 02:48:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692438503; x=1693043303; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=PtWQErPsfmqjBLE2FgdZ3jKytvyM+bVeZHZz4VRAnn0=; b=apsaA/t/TpdL08Ud+WfCRjZe80XZcxARKncOwV09x1iyGsndzw0Ni6lBCzUQxGqDPp HyKwHbUl34HT98tcXQVkPh5S2Llic9NkcvHdeJhrvJl5A+XFei01G+wAI+tLdDNAvXXM toCNK+Ftj5nueOEJHxsXbkKP1iRA964cIR0jVYtI4ebdSLegS3cCt4T0K+BtHT7yczOG lujtfPos6NKq1E340k2s4VJhebVHdXxtDaKIOKwN71x5I1fiZ814WEC29zIQmo4NnR8c AqoOea4O6i2x12v67HDL+/3IlXRMN9PQSLuisYheNcL82PRZywsVWeiIde/yzFK2XC7x VrLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692438503; x=1693043303; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PtWQErPsfmqjBLE2FgdZ3jKytvyM+bVeZHZz4VRAnn0=; b=agYuznJgh8TCErZIgZv5sDViarazGsQJNFq8vJrTCHtK1GNzbQuDfyEbAS1khzMYWN 0UbnZiXpSQFbe9C6KzvoCQjweMkCgbnqX0zXzo4Z51JDFl1XmSvc722Hl0mSy627CDxi GLCf0kT4N5f0MkN88YqkL035vG1WIfdDOfPB92uQAvHgtj72xg+IFDTCKeEAT1we8TT7 i49g/WMjMlDZH34ZIQ4X/t8snpy9PTGqtjYXyGh/ZM9I1SjhsaR0BErm1Ow6zJmz8s6d Gsd5s3Az3EC3QPtl7FVi6QPqj28sTDEyWv2muSzwchU65VdtO8ZnX4+TSACYrt1vzfi4 SiEg== X-Gm-Message-State: AOJu0YwIkxL9hutjoGreInC+BdphDJXWZJTVFlYT4N2PdnoXAyokX49x /c7luNYlk4094HpaYdMKOlnbVGgzZiY= X-Google-Smtp-Source: AGHT+IG6Nc4dGBsz4n09/4MkkHvIbi8KPycChlz0CHJBKvjcyCsSjtVgOsm7vXY26JvN0CBV56BR/A== X-Received: by 2002:a5d:5452:0:b0:317:759a:8ca8 with SMTP id w18-20020a5d5452000000b00317759a8ca8mr1057630wrv.67.1692438503291; Sat, 19 Aug 2023 02:48:23 -0700 (PDT) Received: from karim.my.domain ([197.39.34.171]) by smtp.gmail.com with ESMTPSA id o18-20020adfead2000000b003143b14848dsm5617216wrn.102.2023.08.19.02.48.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Aug 2023 02:48:22 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: imp@bsdimp.com, Stacey Son , Karim Taha Subject: [PATCH 01/22] Implement struct target_ipc_perm Date: Sat, 19 Aug 2023 11:47:45 +0200 Message-Id: <20230819094806.14965-2-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230819094806.14965-1-kariem.taha2.7@gmail.com> References: <20230819094806.14965-1-kariem.taha2.7@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wm1-x331.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Stacey Son Signed-off-by: Stacey Son Signed-off-by: Karim Taha Reviewed-by: Richard Henderson Reviewed-by: Warner Losh --- bsd-user/syscall_defs.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/bsd-user/syscall_defs.h b/bsd-user/syscall_defs.h index e4825f2662..39a9bc8ed7 100644 --- a/bsd-user/syscall_defs.h +++ b/bsd-user/syscall_defs.h @@ -55,6 +55,23 @@ struct target_iovec { abi_long iov_len; /* Number of bytes */ }; +/* + * sys/ipc.h + */ +struct target_ipc_perm { + uint32_t cuid; /* creator user id */ + uint32_t cgid; /* creator group id */ + uint32_t uid; /* user id */ + uint32_t gid; /* group id */ + uint16_t mode; /* r/w permission */ + uint16_t seq; /* sequence # */ + abi_long key; /* user specified msg/sem/shm key */ +}; + +#define TARGET_IPC_RMID 0 /* remove identifier */ +#define TARGET_IPC_SET 1 /* set options */ +#define TARGET_IPC_STAT 2 /* get options */ + /* * sys/mman.h */ From patchwork Sat Aug 19 09:47:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karim Taha X-Patchwork-Id: 1823266 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=b/YF5gwL; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RSYqw6d9Sz1yfn for ; Sat, 19 Aug 2023 19:49:48 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qXIZq-00087k-FF; Sat, 19 Aug 2023 05:49:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qXIZN-0007sN-6B for qemu-devel@nongnu.org; Sat, 19 Aug 2023 05:48:37 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qXIZK-0004Fi-JT for qemu-devel@nongnu.org; Sat, 19 Aug 2023 05:48:32 -0400 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-3fbd33a57b6so15861505e9.2 for ; Sat, 19 Aug 2023 02:48:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692438507; x=1693043307; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=r2sLzJuLOtqRS9NRWS2d6CNXqMRtiVWXEqDSCgmAwRY=; b=b/YF5gwLY+gL4s4XdeyJBjuVyjaK5ge4ww09MBh3FjVGM/KF8UOpq9HIj1QJOMGzZ/ fDDnCjUJ+7oS84JsH9WTzfL8Ryx/GDhoUIa9H0SpBv8wxAOrqTCVtzefVABnyQgN18Gp G3+cmSGY+CMoNIxWbVFdRCPLlsxIyc5NcytzCmVMTi8VAazbC/fAVZ1U8x5/4ZejF8Hu kQnJ34WA2PEn9fDMygZIE8VGG3FICOTB01arUUdoA8WbJCM4uwUvSKKoJBJ0XFxQt65Z mII88j6GKqQiqayUEalZcjPXvOO93kdQQZIoJTJpl2FVYxBEaYiSLRZNeNuiRpPktp7D TkGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692438507; x=1693043307; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=r2sLzJuLOtqRS9NRWS2d6CNXqMRtiVWXEqDSCgmAwRY=; b=ATqacVm0t137CKpP0dUDjaIEas1EgFa6vqPmjcHUvOg0hbu6axwaHBhXSriIWWsKBu Omx9ovoDU3hXI+BVWhx1YhvW1CJxnNC9gsTbg2p1cUhWSXPAZPOkgKTbna35oXWVDmdC BjEkLPiCLFG8ImxDc0vAL5ISNyRr/upC117kYfaO+vr/sL/tNwIEogg3MTIuNOtUhoTN n9x3OmausUGaUTqlvjz9oMQoZmPay3UxA1U0suvKPEEf+eoXxDLrbbE9PXONmZXLacLs ovOQ17RNtPJwtGWasM9dhJkGOlxR5auolfpgMkQtRZBmItHHtWJJOQqB18Q2Vx3shLmT Q92Q== X-Gm-Message-State: AOJu0YzqG6X3YVUuhcyBZqXCEVd+oD3LDySqVBliqMiaLkX/zKW13a6/ aaAWp+vK2d/iKMVBt9+gx0W4yqqhScI= X-Google-Smtp-Source: AGHT+IG5iCRuVL0ICvYvohgJTkJiRCciSkzc6aiiwixtmw9YJ/T+hyr1RPP/ASoW9+Z3Gz/XcDUgOg== X-Received: by 2002:a5d:42cd:0:b0:317:6a07:83a7 with SMTP id t13-20020a5d42cd000000b003176a0783a7mr1233785wrr.38.1692438506989; Sat, 19 Aug 2023 02:48:26 -0700 (PDT) Received: from karim.my.domain ([197.39.34.171]) by smtp.gmail.com with ESMTPSA id o18-20020adfead2000000b003143b14848dsm5617216wrn.102.2023.08.19.02.48.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Aug 2023 02:48:26 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: imp@bsdimp.com, Stacey Son , Karim Taha Subject: [PATCH 02/22] Implement struct target_shmid_ds Date: Sat, 19 Aug 2023 11:47:46 +0200 Message-Id: <20230819094806.14965-3-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230819094806.14965-1-kariem.taha2.7@gmail.com> References: <20230819094806.14965-1-kariem.taha2.7@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wm1-x335.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Stacey Son Signed-off-by: Stacey Son Signed-off-by: Karim Taha Reviewed-by: Richard Henderson Reviewed-by: Warner Losh --- bsd-user/syscall_defs.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/bsd-user/syscall_defs.h b/bsd-user/syscall_defs.h index 39a9bc8ed7..074df7bdd6 100644 --- a/bsd-user/syscall_defs.h +++ b/bsd-user/syscall_defs.h @@ -72,6 +72,26 @@ struct target_ipc_perm { #define TARGET_IPC_SET 1 /* set options */ #define TARGET_IPC_STAT 2 /* get options */ +/* + * sys/shm.h + */ +struct target_shmid_ds { + struct target_ipc_perm shm_perm; /* peration permission structure */ + abi_ulong shm_segsz; /* size of segment in bytes */ + int32_t shm_lpid; /* process ID of last shared memory op */ + int32_t shm_cpid; /* process ID of creator */ + int32_t shm_nattch; /* number of current attaches */ + target_time_t shm_atime; /* time of last shmat() */ + target_time_t shm_dtime; /* time of last shmdt() */ + target_time_t shm_ctime; /* time of last change by shmctl() */ +}; + +#define N_BSD_SHM_REGIONS 32 +struct bsd_shm_regions { + abi_long start; + abi_long size; +}; + /* * sys/mman.h */ From patchwork Sat Aug 19 09:47:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karim Taha X-Patchwork-Id: 1823281 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=pwI1JKJT; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RSYsG6DX0z1yfT for ; Sat, 19 Aug 2023 19:50:58 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qXIZr-0008Au-Lk; Sat, 19 Aug 2023 05:49:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qXIZQ-0007sV-AF for qemu-devel@nongnu.org; Sat, 19 Aug 2023 05:48:43 -0400 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qXIZN-0004GR-SY for qemu-devel@nongnu.org; Sat, 19 Aug 2023 05:48:36 -0400 Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-3179ed1dfbbso1577009f8f.1 for ; Sat, 19 Aug 2023 02:48:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692438512; x=1693043312; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=sy3MH2Hdjio08FhOS5Y/B8VYj6jvphQt1UIdvsQBktQ=; b=pwI1JKJTx/NmuZNo09D5QKoA/rRKmin14XcBMj+GVVY8+HnoeNSiavmCDww5Mwo+w1 yS7HCGmsOPc3/J4ywITOLv7LGvs1EjNkS9rEHQtTONTiKtRE77pr8nAbz6y/67g7ycyF QwXysN6N46MUqS7rQBXegVoPRAaMKGHQ22ECoKLU5zoTbVH59CDzMQBtaaZTAqhjD2RA l6zyEpQj90v3RLY/dJFx9W8290oqzVBMtqcUKIDZduOjIKV9aP2xXvhCBJpTbMi8UI0D W5haP3IfVpQLFincyDsVs5M8Iq68VDedOsPsDhJG1fMUdUTngw34zkg22kx+jFUg/vBu ZxNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692438512; x=1693043312; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sy3MH2Hdjio08FhOS5Y/B8VYj6jvphQt1UIdvsQBktQ=; b=aDZj6hgGQMuodVLp/f82GycFubEwFdawwGGfWDXLBwjlprdQmIeV4Z+u6PSwXaBFaT 22KZYn6yyPBGIZzvy6NX66rRMC4zCmOcMEATcAfyK3/wBkWjXnRYSZjU2vzI6TEfg4aF OX+qDbM09cC5/145RcDt5+gUmGLqsTboVnomklUK9GuVJqlZ9b2HX4XZBS0Y6Uf7SBfD swOabnV92s1Z7y/VRW3iKyYKujPsVWXJT2XF8gbiUN76s/Bws/N1PL09kGvK6pfHrtDU tSIZOL1H2BZaDdAvhZe4+dYeDjd1Q/FynK05uey7GEg2xSqFRpPPnT0/FMApjffgccx9 jQ1w== X-Gm-Message-State: AOJu0YxuaVlNf+PwqFc4Rai/MGu7yEM57y9wAc3krsm892bwIwnX2NZf 3AhJqGL6BerlpRJuri2vXxZ+zsBLzq4= X-Google-Smtp-Source: AGHT+IG7/Q6kKooAwECNHW/f4UIAVzxYB0JSX44r0Mve3oiUSQm40zrWUtXBcPRDAbtrxLVmJlelOg== X-Received: by 2002:a5d:65c5:0:b0:319:76a2:36e9 with SMTP id e5-20020a5d65c5000000b0031976a236e9mr1196856wrw.56.1692438511713; Sat, 19 Aug 2023 02:48:31 -0700 (PDT) Received: from karim.my.domain ([197.39.34.171]) by smtp.gmail.com with ESMTPSA id o18-20020adfead2000000b003143b14848dsm5617216wrn.102.2023.08.19.02.48.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Aug 2023 02:48:31 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: imp@bsdimp.com, Stacey Son , Karim Taha Subject: [PATCH 03/22] Declarations for ipc_perm and shmid_ds conversion functions Date: Sat, 19 Aug 2023 11:47:47 +0200 Message-Id: <20230819094806.14965-4-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230819094806.14965-1-kariem.taha2.7@gmail.com> References: <20230819094806.14965-1-kariem.taha2.7@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::435; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wr1-x435.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Stacey Son Signed-off-by: Stacey Son Signed-off-by: Karim Taha Reviewed-by: Richard Henderson Reviewed-by: Warner Losh --- bsd-user/qemu-bsd.h | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 bsd-user/qemu-bsd.h diff --git a/bsd-user/qemu-bsd.h b/bsd-user/qemu-bsd.h new file mode 100644 index 0000000000..f98942ea91 --- /dev/null +++ b/bsd-user/qemu-bsd.h @@ -0,0 +1,45 @@ +/* + * BSD conversion extern declarations + * + * 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 QEMU_BSD_H +#define QEMU_BSD_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* bsd-mem.c */ +abi_long target_to_host_ipc_perm(struct ipc_perm *host_ip, + abi_ulong target_addr); +abi_long host_to_target_ipc_perm(abi_ulong target_addr, + struct ipc_perm *host_ip); +abi_long target_to_host_shmid_ds(struct shmid_ds *host_sd, + abi_ulong target_addr); +abi_long host_to_target_shmid_ds(abi_ulong target_addr, + struct shmid_ds *host_sd); + +#endif /* QEMU_BSD_H */ From patchwork Sat Aug 19 09:47:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karim Taha X-Patchwork-Id: 1823277 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=ewGnM/vP; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RSYrY4n4nz1yfT for ; Sat, 19 Aug 2023 19:50:21 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qXIZw-0008DB-1T; Sat, 19 Aug 2023 05:49:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qXIZU-0007ut-1D for qemu-devel@nongnu.org; Sat, 19 Aug 2023 05:48:45 -0400 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qXIZR-0004H0-Ay for qemu-devel@nongnu.org; Sat, 19 Aug 2023 05:48:39 -0400 Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-3198d2745feso1477214f8f.1 for ; Sat, 19 Aug 2023 02:48:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692438515; x=1693043315; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=HCSfwfk5J8aV9f6C+8dP8rhVQliK6Ou3TFJHqD6MEtM=; b=ewGnM/vPEBE6AFXNnT09XxqlMfyHCC7LhF7nbqJL6s4fbFO3Yf1JkePnBtmlDiwB1+ tXVvJ/ndie5my1ivIJwTnorfPgPitAlbEx+C+JDCvNs5T3vHdfKHfvxcXTkKX4LRASmf kQ5ZfEaosCM1eyyKx2BPka9u27uIEkW2du9Uy5Ff/DmU7BUo6nG91+d1oaahbvWUtWyR EmaTnTweCTLOENNM04ca1KmTqtrnpiZ14Ha1k81WU9y7tfdWXRrrHr/4e0g6j79+PEQ7 QbZbkkHP8Ml54exm937GqNNa2jI8z3MnOfO9nEdZnMkn46Y+bAGgegYVauSHwEayCNM/ 0+cQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692438515; x=1693043315; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HCSfwfk5J8aV9f6C+8dP8rhVQliK6Ou3TFJHqD6MEtM=; b=O9GA4aLb2O6JTd7iV5zdnSHEjFtC5nVat8c0YxEDiqXsaijkBk3lYIxSbAUmr1eKyH 0r8HCwqwRrOBd59ny4B7Vg1iF8sl9Jkx0kJOelQrwWpQldvvupso98RuYzQQH8lHdSgG p98wQxt6F/5pOEltMr2PJVM/pFSAFjjyP83QszM8/2/KcLpMjJfU5Pq369K5GXiT0Qjx bQSMN/FbvuZLNOQKLNfqxqyvqpt8ls7IkgGy6KKYR9baEjQ71ntsSf/+pbIzq5Zl2bmp q4yLyvK+3KFnCUc3D4Ap9Jvyuz6HrX87mRp+0fqYwHcFfNZBLclhanpgO9JQcZmwA8Jt MrPQ== X-Gm-Message-State: AOJu0YyEFaIUiEheCof2a192Vv4ClqDicEup4qWFDISYTpUi/VErINR0 PoW2AyI9XwsGyzPBQ7QY7VwAgovXdqY= X-Google-Smtp-Source: AGHT+IHIATPMcZRxARaz4kzhFpdzFBkIJoMJH9v2d6wHRQQHMAtkZGQy4K1my7gQgSATNWPfuP0EtA== X-Received: by 2002:a5d:4908:0:b0:314:11fe:c72e with SMTP id x8-20020a5d4908000000b0031411fec72emr1136032wrq.46.1692438515468; Sat, 19 Aug 2023 02:48:35 -0700 (PDT) Received: from karim.my.domain ([197.39.34.171]) by smtp.gmail.com with ESMTPSA id o18-20020adfead2000000b003143b14848dsm5617216wrn.102.2023.08.19.02.48.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Aug 2023 02:48:35 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: imp@bsdimp.com, Stacey Son , Karim Taha Subject: [PATCH 04/22] Introduce freebsd/os-misc.h to the source tree Date: Sat, 19 Aug 2023 11:47:48 +0200 Message-Id: <20230819094806.14965-5-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230819094806.14965-1-kariem.taha2.7@gmail.com> References: <20230819094806.14965-1-kariem.taha2.7@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::431; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wr1-x431.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Stacey Son To preserve the copyright notice and help with the 'Author' info for subsequent changes to the file. Signed-off-by: Stacey Son Signed-off-by: Karim Taha Reviewed-by: Richard Henderson --- bsd-user/freebsd/os-misc.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 bsd-user/freebsd/os-misc.h diff --git a/bsd-user/freebsd/os-misc.h b/bsd-user/freebsd/os-misc.h new file mode 100644 index 0000000000..8436ccb2f7 --- /dev/null +++ b/bsd-user/freebsd/os-misc.h @@ -0,0 +1,28 @@ +/* + * miscellaneous FreeBSD system call shims + * + * Copyright (c) 2013-14 Stacey D. Son + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + */ + +#ifndef OS_MISC_H +#define OS_MISC_H + +#include +#include +#include + + +#endif /* OS_MISC_H */ From patchwork Sat Aug 19 09:47:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karim Taha X-Patchwork-Id: 1823285 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=IH5fns7D; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RSYsR1bhGz1yfT for ; Sat, 19 Aug 2023 19:51:07 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qXIZt-0008Bh-2l; Sat, 19 Aug 2023 05:49:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qXIZZ-000808-CT for qemu-devel@nongnu.org; Sat, 19 Aug 2023 05:48:51 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qXIZU-0004Hd-MT for qemu-devel@nongnu.org; Sat, 19 Aug 2023 05:48:42 -0400 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-3fee06efd6bso3082345e9.0 for ; Sat, 19 Aug 2023 02:48:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692438519; x=1693043319; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+ssWpB1TdSRberSIq+NHyAWC3tlwKWsnTa+/5C/DIew=; b=IH5fns7DEmJIqMNrQC/mBIKSArzlDJw+ncy+MgfhjoD5cbdjMKWFsHi2w81dtuzagc WnXaZCnr5S8EjF71aj9hwkGPrO9usiLf+XOq6n5TiE5rOabVDqYt4gfQ/f5MEKLGjlcQ P2NF8yTEUOl7APRdQtJwiLsr9HOVY5vqMcAd6UtCiGkCHdfmF0yZHPeZAJDDETBAh4iP o4JlIAX0VB5Vl+uz/u+6av6zJP/5k1XUhhVsoF16UVp2hxgjeJIqGOXJjTV3wBxz26VF JmD0fIjQygfdBv+KNaOHkmdv58FOiLm/qLoEgVNN3w58iI4Cgu4Li/tX8aRt4Sx4Ygue cwoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692438519; x=1693043319; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+ssWpB1TdSRberSIq+NHyAWC3tlwKWsnTa+/5C/DIew=; b=ej1FgI33LrJFpXqT4eF05HD+SavN98E3fDLUuNzn/Kxn6HTLOsX3/v+1cyr3MmY9RZ tDt1UUtuHtrfyOmrFfpN31lPwzSA2NJxq3qpIZcAoG5kSBcdX5VTg2tU0QzXktUk6dcH mhkHpr+gSXUAF3Pge4+xjIk6x4dvbEEszXzTbXMDvEIaDd6bOt9UUrn3XOT5ujA31HG/ TQLtafGlygn9GIzBw4CoUF0nvtEJ0excV10MkbkTOYF8tQ3YGqFOIO3WQ3reevg3v/hC QRyIg0ECDqxoK8LJdN6/OnqEi3YuViW2WN/0e8/dzqm+iA8afAsZPQ0vo5bcnJ1AqFQ+ I1Pg== X-Gm-Message-State: AOJu0YzX5jrT2qsIogXmji2o+B7VjghRKCqOQYydSoUzNpY8M10hT81F UtEu6ZpC2Zitxp5jDIOER1gPhu0gsEM= X-Google-Smtp-Source: AGHT+IEdqpPAOVcVMkwpnAPSvNz6ER4gY0v6cBGEGCzA0Dw/+7rhdV+bPZOwvRmMsOH81qLl46qXCw== X-Received: by 2002:adf:dcc1:0:b0:314:1096:6437 with SMTP id x1-20020adfdcc1000000b0031410966437mr3367362wrm.19.1692438519098; Sat, 19 Aug 2023 02:48:39 -0700 (PDT) Received: from karim.my.domain ([197.39.34.171]) by smtp.gmail.com with ESMTPSA id o18-20020adfead2000000b003143b14848dsm5617216wrn.102.2023.08.19.02.48.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Aug 2023 02:48:38 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: imp@bsdimp.com, Kyle Evans , Karim Taha Subject: [PATCH 05/22] Implement shm_open2(2) system call Date: Sat, 19 Aug 2023 11:47:49 +0200 Message-Id: <20230819094806.14965-6-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230819094806.14965-1-kariem.taha2.7@gmail.com> References: <20230819094806.14965-1-kariem.taha2.7@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wm1-x335.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Kyle Evans Signed-off-by: Kyle Evans Signed-off-by: Karim Taha --- bsd-user/freebsd/os-misc.h | 52 +++++++++++++++++++++++++++++++++++ bsd-user/freebsd/os-syscall.c | 13 +++++++++ 2 files changed, 65 insertions(+) diff --git a/bsd-user/freebsd/os-misc.h b/bsd-user/freebsd/os-misc.h index 8436ccb2f7..993e4598f9 100644 --- a/bsd-user/freebsd/os-misc.h +++ b/bsd-user/freebsd/os-misc.h @@ -24,5 +24,57 @@ #include #include +int shm_open2(const char *path, int flags, mode_t mode, int shmflags, + const char *); + +#if defined(__FreeBSD_version) && __FreeBSD_version >= 1300048 +/* shm_open2(2) */ +static inline abi_long do_freebsd_shm_open2(abi_ulong pathptr, abi_ulong flags, + abi_long mode, abi_ulong shmflags, abi_ulong nameptr) +{ + int ret; + void *uname, *upath; + +#ifdef SHM_ANON +#define SHM_PATH(p) (p) == SHM_ANON ? (p) : path(p) + if (pathptr == (uintptr_t)SHM_ANON) { + upath = SHM_ANON; + } else +#else +#define SHM_PATH(p) path(p) +#endif + { + upath = lock_user_string(pathptr); + if (upath == NULL) { + return -TARGET_EFAULT; + } + } + + uname = NULL; + if (nameptr != 0) { + uname = lock_user_string(nameptr); + if (uname == NULL) { + unlock_user(upath, pathptr, 0); + return -TARGET_EFAULT; + } + } + ret = get_errno(shm_open2(SHM_PATH(upath), + target_to_host_bitmask(flags, fcntl_flags_tbl), mode, + target_to_host_bitmask(shmflags, shmflag_flags_tbl), uname)); + +#ifdef SHM_ANON + if (upath != SHM_ANON) +#endif + { + unlock_user(upath, pathptr, 0); + } + if (uname != NULL) { + unlock_user(uname, nameptr, 0); + } + return ret; +} +#undef SHM_PATH +#endif /* __FreeBSD_version >= 1300048 */ + #endif /* OS_MISC_H */ diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index 2224a280ea..b4311db578 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -33,9 +33,13 @@ #include "signal-common.h" #include "user/syscall-trace.h" +/* BSD independent syscall shims */ #include "bsd-file.h" #include "bsd-proc.h" +/* *BSD dependent syscall shims */ +#include "os-misc.h" + /* I/O */ safe_syscall3(int, open, const char *, path, int, flags, mode_t, mode); safe_syscall4(int, openat, int, fd, const char *, path, int, flags, mode_t, @@ -482,6 +486,15 @@ static abi_long freebsd_syscall(void *cpu_env, int num, abi_long arg1, ret = do_bsd_undelete(arg1); break; + /* + * Memory management system calls. + */ +#if defined(__FreeBSD_version) && __FreeBSD_version >= 1300048 + case TARGET_FREEBSD_NR_shm_open2: /* shm_open2(2) */ + ret = do_freebsd_shm_open2(arg1, arg2, arg3, arg4, arg5); + break; +#endif + /* * sys{ctl, arch, call} */ From patchwork Sat Aug 19 09:47:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karim Taha X-Patchwork-Id: 1823275 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=ppg0AjKG; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RSYrV5CP7z1yfT for ; Sat, 19 Aug 2023 19:50:18 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qXIZs-0008BU-Sc; Sat, 19 Aug 2023 05:49:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qXIZd-00080T-0c for qemu-devel@nongnu.org; Sat, 19 Aug 2023 05:48:52 -0400 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qXIZZ-0004IQ-4V for qemu-devel@nongnu.org; Sat, 19 Aug 2023 05:48:47 -0400 Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-31adc5c899fso1581299f8f.2 for ; Sat, 19 Aug 2023 02:48:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692438523; x=1693043323; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=V06ClJXz9CAp1niT/8dYkv4jhP0N6H1ZC3ac1dt4oc8=; b=ppg0AjKGaK9eDuJ8XyuZGG1HnVID9iRxhMrUh8Gcy0lMxSMkj8FXD3fH5zgeGVqkdD 1YQYzwsZK5aceiiZl/hZUaxusWKlfgcqi+jXRVELBFbPf+MWvBYKE5yANB44NptLmnSG Ofbk2ZGz9r4saz++BI5Te/bLG/9NUWFnMIMmVLYI3OylmSkDAPJAEMOa2Ld2zrI3ekQ7 JTJElWx0wM9BUqW1gfqeDVd1+Tdxc0IOempr7NB6GB2bUjAlArbsB5JzQYR0UTot0Nij dW174/Rkbf11OVDLvfN00CkHRVKYbhDLqyCzNCYoU0pwAlKZaciid/6vaBqxjj9pQPr9 3TJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692438523; x=1693043323; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=V06ClJXz9CAp1niT/8dYkv4jhP0N6H1ZC3ac1dt4oc8=; b=YgMwJgaWEX2ugo0+86a/x8aD9cxAIXrmHVY7atpZuOr0XblFcY7fbl63YO/P+G3i9g j+5V4XS4717syHKFCyTmmnaE5TS78O9MPzCfhGyi1izvcrDxPf8edBBYMkGZ7gCnyn8V 2jyJt4SaIpLXKu5cTm16MCa22hBX9lYyPQHu+eKfOZHzgCTav06+CY3F4EYFEdRNWWMU OItmRd8+jOw0O2RNhE3goLEYzNmxo5cKu+4bKkA/oewFgiOeA4BDzy46nJf3W6AI/BSt vWdG0JEh/bYan88KpFgYonjhK/GUKOt330t1ONKTt12G8WawI1kcBOdAE2eZji2ygCug mCyQ== X-Gm-Message-State: AOJu0YyZS5JFoy73YeIQWwb0HXYL7LjfPBReYMz3VlSb2lSZmZyjhfXW t9nPwxQ/rX5uIRjqjayZeM6gEIc/sMQ= X-Google-Smtp-Source: AGHT+IG7QMlesVo2FPcjS2RfQhIiDt+9iZEnkJEyBhqov6n+ass1iIqEZ5N7UJ53WCVCIYlLJJ/fDQ== X-Received: by 2002:adf:f9c4:0:b0:317:6513:da7e with SMTP id w4-20020adff9c4000000b003176513da7emr1253363wrr.36.1692438523107; Sat, 19 Aug 2023 02:48:43 -0700 (PDT) Received: from karim.my.domain ([197.39.34.171]) by smtp.gmail.com with ESMTPSA id o18-20020adfead2000000b003143b14848dsm5617216wrn.102.2023.08.19.02.48.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Aug 2023 02:48:42 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: imp@bsdimp.com, Kyle Evans , Karim Taha Subject: [PATCH 06/22] Implement shm_rename(2) system call Date: Sat, 19 Aug 2023 11:47:50 +0200 Message-Id: <20230819094806.14965-7-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230819094806.14965-1-kariem.taha2.7@gmail.com> References: <20230819094806.14965-1-kariem.taha2.7@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::429; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wr1-x429.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Kyle Evans Signed-off-by: Kyle Evans Signed-off-by: Karim Taha Reviewed-by: Warner Losh Reviewed-by: Richard Henderson --- bsd-user/freebsd/os-misc.h | 24 ++++++++++++++++++++++++ bsd-user/freebsd/os-syscall.c | 6 ++++++ 2 files changed, 30 insertions(+) diff --git a/bsd-user/freebsd/os-misc.h b/bsd-user/freebsd/os-misc.h index 993e4598f9..3509ef026e 100644 --- a/bsd-user/freebsd/os-misc.h +++ b/bsd-user/freebsd/os-misc.h @@ -76,5 +76,29 @@ static inline abi_long do_freebsd_shm_open2(abi_ulong pathptr, abi_ulong flags, #undef SHM_PATH #endif /* __FreeBSD_version >= 1300048 */ +#if defined(__FreeBSD_version) && __FreeBSD_version >= 1300049 +/* shm_rename(2) */ +static inline abi_long do_freebsd_shm_rename(abi_ulong fromptr, abi_ulong toptr, + abi_ulong flags) +{ + int ret; + void *ufrom, *uto; + + ufrom = lock_user_string(fromptr); + if (ufrom == NULL) { + return -TARGET_EFAULT; + } + uto = lock_user_string(toptr); + if (uto == NULL) { + unlock_user(ufrom, fromptr, 0); + return -TARGET_EFAULT; + } + ret = get_errno(shm_rename(ufrom, uto, flags)); + unlock_user(ufrom, fromptr, 0); + unlock_user(uto, toptr, 0); + + return ret; +} +#endif /* __FreeBSD_version >= 1300049 */ #endif /* OS_MISC_H */ diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index b4311db578..2920370ad2 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -495,6 +495,12 @@ static abi_long freebsd_syscall(void *cpu_env, int num, abi_long arg1, break; #endif +#if defined(__FreeBSD_version) && __FreeBSD_version >= 1300049 + case TARGET_FREEBSD_NR_shm_rename: /* shm_rename(2) */ + ret = do_freebsd_shm_rename(arg1, arg2, arg3); + break; +#endif + /* * sys{ctl, arch, call} */ From patchwork Sat Aug 19 09:47:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karim Taha X-Patchwork-Id: 1823276 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=AR3GMnN5; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RSYrV5HK9z1ygW for ; Sat, 19 Aug 2023 19:50:18 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qXIZw-0008DG-NY; Sat, 19 Aug 2023 05:49:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qXIZf-000819-1l for qemu-devel@nongnu.org; Sat, 19 Aug 2023 05:48:52 -0400 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qXIZc-0004JV-Px for qemu-devel@nongnu.org; Sat, 19 Aug 2023 05:48:50 -0400 Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-31ad779e6b3so1485431f8f.2 for ; Sat, 19 Aug 2023 02:48:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692438526; x=1693043326; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=zlGMaK6j2mWq7JaFuFrlpLtB5W9kFdVwVcjMIv6tsic=; b=AR3GMnN5ke/Rb4pCDPgdwemz+cap9Or3qGsGN6HiqNJywOzZAbimzJD5GFjbd9+/B+ I5L6UqiloZbvhxWobi51zaXE4uD1RkZiNzr3e4Bny9d9B4Dis7BwYAn0EwWGoXGuZEwi wBNlDLA71qoYC4+0nmdedNRIRDfpHSxr2/R76kxRkJKi7Rqexb9S65YrCVptRuPOdGjU 5aTjplFDrjrGNeM0qTaJvo8iUv8VOPsbcsYNx6otOobit7EVbz9BCSFruL9WCP7E8Ein GIyaohjMKF6NkEAeGMn1B5KdQGon0VOS0zgEPsHyFmw7Y8n4+7RpO1vW4LDpwLsCaQPL F8mQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692438526; x=1693043326; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zlGMaK6j2mWq7JaFuFrlpLtB5W9kFdVwVcjMIv6tsic=; b=hxARwO1IzBYU6R3/xzMeNEwDwU0XdX8EVD+dXwZurt/bl/AQ7nXzHCqU339GBtMHPg qxZKrNpX9tfkTvV362S+YgxSSe1Th0Hewk4PSnwUaHgqAD/4SCCmZYFhB1ZVdIOqkAib ZLNPlTcqs8TbEU2aD+k0IgLfVUQlSOZe678BQI9+yF7cwpbqNlvNPVvTkuylrMfENXsO 9N8UR4boLK9X5apCEcq8Aa43qAjuxbVIQJCRcEnZyIoaPBPDsk9OXzXTRFI55yqIMw37 0FgYwaEZ/WJ4GKLaH3gBZYj1qr5TTzkhe/NXB6VubLxYAi4Um6VADwfGfydiOj1CANsB a2vw== X-Gm-Message-State: AOJu0YzpQ8ixlExT49W7wKE5+87gagRk1F8ZIUBLbeJVe+QnclIr9Odm NZPTzADa4IouSms16OJUKcX2H622gFw= X-Google-Smtp-Source: AGHT+IFOfOtgLl4rZx8MTegMBYd7Z1LJEWnFGdOSDOWumf7My5GrMWcXhP77tN2ZraNXwZZpFoL4yg== X-Received: by 2002:a5d:684b:0:b0:317:597b:9f92 with SMTP id o11-20020a5d684b000000b00317597b9f92mr1140926wrw.57.1692438526300; Sat, 19 Aug 2023 02:48:46 -0700 (PDT) Received: from karim.my.domain ([197.39.34.171]) by smtp.gmail.com with ESMTPSA id o18-20020adfead2000000b003143b14848dsm5617216wrn.102.2023.08.19.02.48.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Aug 2023 02:48:45 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: imp@bsdimp.com, Karim Taha Subject: [PATCH 07/22] Add bsd-mem.c to meson.build Date: Sat, 19 Aug 2023 11:47:51 +0200 Message-Id: <20230819094806.14965-8-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230819094806.14965-1-kariem.taha2.7@gmail.com> References: <20230819094806.14965-1-kariem.taha2.7@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42f; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wr1-x42f.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org --- bsd-user/bsd-mem.c | 0 bsd-user/meson.build | 1 + 2 files changed, 1 insertion(+) create mode 100644 bsd-user/bsd-mem.c Reviewed-by: Warner Losh Reviewed-by: Richard Henderson diff --git a/bsd-user/bsd-mem.c b/bsd-user/bsd-mem.c new file mode 100644 index 0000000000..e69de29bb2 diff --git a/bsd-user/meson.build b/bsd-user/meson.build index 5243122fc5..6ee68fdfe7 100644 --- a/bsd-user/meson.build +++ b/bsd-user/meson.build @@ -7,6 +7,7 @@ bsd_user_ss = ss.source_set() common_user_inc += include_directories('include') bsd_user_ss.add(files( + 'bsd-mem.c', 'bsdload.c', 'elfload.c', 'main.c', From patchwork Sat Aug 19 09:47:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Karim Taha X-Patchwork-Id: 1823282 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=grVd1FJ6; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RSYsN0P5pz1yfT for ; Sat, 19 Aug 2023 19:51:04 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qXIZu-0008Cd-FC; Sat, 19 Aug 2023 05:49:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qXIZj-00087E-GW for qemu-devel@nongnu.org; Sat, 19 Aug 2023 05:48:56 -0400 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qXIZg-0004KN-EZ for qemu-devel@nongnu.org; Sat, 19 Aug 2023 05:48:55 -0400 Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-319559fd67dso1572214f8f.3 for ; Sat, 19 Aug 2023 02:48:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692438531; x=1693043331; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=hO/8BCsb7ELKSZB3NHN4QJcV1kJINuEog0PQLfxugV0=; b=grVd1FJ6mqsDLruJ6Y/yf71AW14vWj3cHVFedjMMvlc3/dctxopT+6FOGEB+w/UWEJ kry3avODMkou4ZLGntSuNGsiXYmiV+aQCuFqn2n2OOHSnjHRD6PpvplHa5BfvjpNOPtF lBTsHR7qNYRRqlIdPzMZrGvShzKFziIWgBTOhlMtOiU7ltVo8lLya0KoU04ll3hZcd9F UGcsV1HXtPHSMgK0z7GHi7LtDpKN4FXCCmISJ3ElERMnCFcu6oIHn+iD+NIghiQITYvw sXRw4QRA5IH0Ya7CVtaOPgl061snBk5SsiYpRm0hKkNCcNsHY8h3sxQfwLn2RTHK68TI wpUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692438531; x=1693043331; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hO/8BCsb7ELKSZB3NHN4QJcV1kJINuEog0PQLfxugV0=; b=LBb/aZNZ46GNWlu6wV24JGSV+BPj4uDSOjglHobvl8OVtRoDSC52G6N4xv7kPGjR7H IZFJSZKAYL+xMZb1iBGhG4k5q+AcNiA7dO/hLt07cHqtQYUnhvdPbgnlnD0+hG3XcdvY 7E14t4Sa3f9fdWm/b48W7tbaxALXhf224Z8ccRwQZHHW6yJpR3BNPggfIQxzXQmozleg YxLOeKssUaDnmC7/VHj/6VGHicE4jOtOjomchljxfVAWNXv3YmYdKQetXl2LLKZ0epKB DWZ4QdtPB3cx9Zt+F0hC4DrA1D8HewwTgyzxRI/i4aOZ2JhGr7YDJIJdGna4OJa3/K2T FZMg== X-Gm-Message-State: AOJu0Yw7YqIVDJJoVj1vXznGZLjD376THtrR0X4hX6effFw6aSH7cMlp A26KExZtP0wRHRNeNhtcaubdED2mYUY= X-Google-Smtp-Source: AGHT+IFix/aUg+8SRyBPyEsrw2c/nzIZRsMVOj0x2t+GdOhV849QGsy2uefTpG5YWfocEkSh56+R7g== X-Received: by 2002:adf:ef12:0:b0:314:3b1f:8ea2 with SMTP id e18-20020adfef12000000b003143b1f8ea2mr1191691wro.6.1692438530856; Sat, 19 Aug 2023 02:48:50 -0700 (PDT) Received: from karim.my.domain ([197.39.34.171]) by smtp.gmail.com with ESMTPSA id o18-20020adfead2000000b003143b14848dsm5617216wrn.102.2023.08.19.02.48.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Aug 2023 02:48:50 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: imp@bsdimp.com, Stacey Son , =?utf-8?q?Mika=C3=ABl_Ura?= =?utf-8?q?nkar?= , Karim Taha Subject: [PATCH 08/22] Implement target_set_brk function in bsd-mem.c instead of os-syscall.c Date: Sat, 19 Aug 2023 11:47:52 +0200 Message-Id: <20230819094806.14965-9-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230819094806.14965-1-kariem.taha2.7@gmail.com> References: <20230819094806.14965-1-kariem.taha2.7@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42d; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wr1-x42d.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Stacey Son Co-authored-by: Mikaël Urankar Signed-off-by: Mikaël Urankar Signed-off-by: Karim Taha Reviewed-by: Warner Losh Reviewed-by: Richard Henderson --- bsd-user/bsd-mem.c | 38 +++++++++++++++++++++++++++++++++++ bsd-user/freebsd/os-syscall.c | 4 ---- 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/bsd-user/bsd-mem.c b/bsd-user/bsd-mem.c index e69de29bb2..6c123abf04 100644 --- a/bsd-user/bsd-mem.c +++ b/bsd-user/bsd-mem.c @@ -0,0 +1,38 @@ +/* + * memory management system conversion routines + * + * 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 . + */ +#include "qemu/osdep.h" + +#include +#include + +#include "qemu.h" +#include "qemu-bsd.h" + +struct bsd_shm_regions bsd_shm_regions[N_BSD_SHM_REGIONS]; + +abi_ulong bsd_target_brk; +abi_ulong bsd_target_original_brk; +abi_ulong brk_page; + +void target_set_brk(abi_ulong new_brk) +{ + + bsd_target_original_brk = bsd_target_brk = HOST_PAGE_ALIGN(new_brk); + brk_page = HOST_PAGE_ALIGN(bsd_target_brk); +} diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index 2920370ad2..c0a22eb746 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -59,10 +59,6 @@ safe_syscall3(ssize_t, writev, int, fd, const struct iovec *, iov, int, iovcnt); safe_syscall4(ssize_t, pwritev, int, fd, const struct iovec *, iov, int, iovcnt, off_t, offset); -void target_set_brk(abi_ulong new_brk) -{ -} - /* * errno conversion. */ From patchwork Sat Aug 19 09:47:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karim Taha X-Patchwork-Id: 1823265 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=Svr8cV+1; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RSYqn3T7Qz1ygW for ; Sat, 19 Aug 2023 19:49:40 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qXIZw-0008DI-O0; Sat, 19 Aug 2023 05:49:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qXIZo-00088F-TA for qemu-devel@nongnu.org; Sat, 19 Aug 2023 05:49:02 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qXIZm-0004Kv-O0 for qemu-devel@nongnu.org; Sat, 19 Aug 2023 05:49:00 -0400 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-3fee5ddc23eso2195395e9.1 for ; Sat, 19 Aug 2023 02:48:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692438534; x=1693043334; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=LC9QfRGLuG6b7Lw7VS826b9rKt2FAmv6aiZlfH5TGvE=; b=Svr8cV+1ay0HI6RqefiBgsdpiRXT2OC8xhWCOLGEU0cA0kf0ruswpbYlNz3uqtAieI GD9FnDx4Zn/MMjoJO0ZW14YOxEkQPDPiE3wmYL4oxTWn7ibA3EQo4ipYuU5e7g482CkN oJcS+QJJEg70Fc2PTiOi0Ua0fMtDrP7CkHYs2JYJOWafIhzStqp3p5cN303vdRXZLnPQ OAUBMpaII0aDzikzBWHklAt5+zOa9yt44sG+tVznvsw2nSP+lj3c0d+7NeOhK5HH5Jh5 Lhy0Z0nHa0LPzd0XLW63Xi+3Hw7b9f0r0jDGKf90KJ68geKYHtKnjPB5WNFhxxmBAiRp H1EA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692438534; x=1693043334; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LC9QfRGLuG6b7Lw7VS826b9rKt2FAmv6aiZlfH5TGvE=; b=PRJH8uhEM+TZ0/2gqf2PIACoIQ19WG22/axRX8ozRZiv8SW4xm+vc1hNAx7cgX/JAs 6QA3V+vDmkxX5Mm/Dhg3wKtKc//2WKhKybR2jL79gryHwOZKZOAZubve5Sn7wjF0AOXr 1+GcvT0wcYOgGMgPgXdDSybJdlziAyTAll4EU0SzrJ+lSQK1LtlbD/W5Ij1pllLu9tCp i59O3Wb6N3HJmlnFB7de6/R7FcpCC6hcJB3jXN48A76HHEhSKPfnUjvIRGhsCPuy4ReE rhCyuOZsWyNdWl3JyN82LNy1cMRew/NfoJIPEmAwrW+5seuV2jvCwnPW1UEAhx/RR+Yn 26Mw== X-Gm-Message-State: AOJu0Yz39FxQea0nB/pLX2fL/78YMn9Oxp9NrFxXLwZmEyv85UOy3MXY EX0MyS8VA6J05PXbwNkIhUACygf7s4c= X-Google-Smtp-Source: AGHT+IHIDNpKTe/Tku1PvKCzIHgwJD2I+Cf54Bk9i2SRHSVMQp7AdlQopjOUnwr0l32v+vmxlArijA== X-Received: by 2002:a05:600c:28d:b0:3fd:2f8e:2c69 with SMTP id 13-20020a05600c028d00b003fd2f8e2c69mr1206195wmk.32.1692438534537; Sat, 19 Aug 2023 02:48:54 -0700 (PDT) Received: from karim.my.domain ([197.39.34.171]) by smtp.gmail.com with ESMTPSA id o18-20020adfead2000000b003143b14848dsm5617216wrn.102.2023.08.19.02.48.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Aug 2023 02:48:54 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: imp@bsdimp.com, Stacey Son , Karim Taha Subject: [PATCH 09/22] Implement ipc_perm conversion between host and target. Date: Sat, 19 Aug 2023 11:47:53 +0200 Message-Id: <20230819094806.14965-10-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230819094806.14965-1-kariem.taha2.7@gmail.com> References: <20230819094806.14965-1-kariem.taha2.7@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wm1-x32e.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Stacey Son Signed-off-by: Stacey Son Signed-off-by: Karim Taha Reviewed-by: Warner Losh Reviewed-by: Richard Henderson --- bsd-user/bsd-mem.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/bsd-user/bsd-mem.c b/bsd-user/bsd-mem.c index 6c123abf04..e69250cc0d 100644 --- a/bsd-user/bsd-mem.c +++ b/bsd-user/bsd-mem.c @@ -36,3 +36,44 @@ void target_set_brk(abi_ulong new_brk) bsd_target_original_brk = bsd_target_brk = HOST_PAGE_ALIGN(new_brk); brk_page = HOST_PAGE_ALIGN(bsd_target_brk); } + +abi_long target_to_host_ipc_perm(struct ipc_perm *host_ip, + abi_ulong target_addr) +{ + struct target_ipc_perm *target_ip; + + if (!lock_user_struct(VERIFY_READ, target_ip, target_addr, 1)) { + return -TARGET_EFAULT; + } + __get_user(host_ip->cuid, &target_ip->cuid); + __get_user(host_ip->cgid, &target_ip->cgid); + __get_user(host_ip->uid, &target_ip->uid); + __get_user(host_ip->gid, &target_ip->gid); + __get_user(host_ip->mode, &target_ip->mode); + __get_user(host_ip->seq, &target_ip->seq); + __get_user(host_ip->key, &target_ip->key); + unlock_user_struct(target_ip, target_addr, 0); + + return 0; +} + +abi_long host_to_target_ipc_perm(abi_ulong target_addr, + struct ipc_perm *host_ip) +{ + struct target_ipc_perm *target_ip; + + if (!lock_user_struct(VERIFY_WRITE, target_ip, target_addr, 0)) { + return -TARGET_EFAULT; + } + __put_user(host_ip->cuid, &target_ip->cuid); + __put_user(host_ip->cgid, &target_ip->cgid); + __put_user(host_ip->uid, &target_ip->uid); + __put_user(host_ip->gid, &target_ip->gid); + __put_user(host_ip->mode, &target_ip->mode); + __put_user(host_ip->seq, &target_ip->seq); + __put_user(host_ip->key, &target_ip->key); + unlock_user_struct(target_ip, target_addr, 1); + + return 0; +} + From patchwork Sat Aug 19 09:47:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karim Taha X-Patchwork-Id: 1823283 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=ncE+zDEf; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RSYsQ1RHtz1yfT for ; Sat, 19 Aug 2023 19:51:06 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qXIZx-0008Dl-Cs; Sat, 19 Aug 2023 05:49:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qXIZq-000895-Nd for qemu-devel@nongnu.org; Sat, 19 Aug 2023 05:49:03 -0400 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qXIZo-0004Mw-7j for qemu-devel@nongnu.org; Sat, 19 Aug 2023 05:49:02 -0400 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-3fe2ba3e260so16620865e9.2 for ; Sat, 19 Aug 2023 02:48:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692438538; x=1693043338; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=o7/wy2dOrFP6M6dk0v3scBILrw/gLVb9Blae0ntr5oA=; b=ncE+zDEfu7sHQP56suY5yzTZn3fZR3PbM8vMOz+t07GWoJtsQuyZMyQw2T93KjaVAt /sByLQLPZW42yX6OhfTEP5UNT6BZRdfxnMrYzlM/HO0sv2f/yU6Om6CiYw0pUBlqHf18 UOkFrr8BfJY2F68f/jVl83T92BQpd7mN32iyGl9fs32M3qP97I+p27dEaXrV+2ubvaDx zG2R2v7Jc0JsTV50n06hO0aMO8GQY0Vtu41YmU/tXHEfEp/l0wyjY89B8MdpUQEBwdIq iGxQs6qMQXXs46SaywT0U29h7XwlbPKbHJsk7as+wvlUAu27WyI18cRDboDL71z8VqTX +72w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692438538; x=1693043338; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=o7/wy2dOrFP6M6dk0v3scBILrw/gLVb9Blae0ntr5oA=; b=bZyZtwS2fnvB/p0583r91PTbryq4LVXcM1Zu4xRV0agyaH+llnCs4V5ZdeQ2EKrcbx gHXJj1XueppqTZSBprimUmQHzA/3RVcG6BxY5scotnP8ZWDZF49eR4RAufEO3BQLCoA1 WMKdO44hV7Z4tuU8mD01melTBSakoK5FK6toLu4LI2Iqih6E9tF5rZfXU5dsWw9Nhl78 hdWke8VZHBHCTvsCHj8cVbX+c9C/ir8XNz39Gq6q5r7ugxTnh5MilOCdPAMKrZsSYmcp 74oKoiVVpLQw3OhtC/5MkM+b1n6sJ2yFQ1QHJyOUiNMgU5YLlKuWc4lUxD7J+7rxxgg+ UrkA== X-Gm-Message-State: AOJu0YzBNWKmCdNGdU82AFeoD/RmcF3TpKhKeMu5vZXgrKYbOvU8O0RL IaTQ7DmiRygKmD6kEv5htAH5IAPgrrY= X-Google-Smtp-Source: AGHT+IEcsoea8x5RVgjug44bU+BJNKfMRmP65n5XyECXt0orT9CQ4Fc2ta74bWKZp7BSYQhHXSDu+w== X-Received: by 2002:a05:600c:2807:b0:3fd:30f7:2be1 with SMTP id m7-20020a05600c280700b003fd30f72be1mr1060532wmb.39.1692438538320; Sat, 19 Aug 2023 02:48:58 -0700 (PDT) Received: from karim.my.domain ([197.39.34.171]) by smtp.gmail.com with ESMTPSA id o18-20020adfead2000000b003143b14848dsm5617216wrn.102.2023.08.19.02.48.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Aug 2023 02:48:57 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: imp@bsdimp.com, Stacey Son , Karim Taha Subject: [PATCH 10/22] Implement shmid_ds conversion between host and target. Date: Sat, 19 Aug 2023 11:47:54 +0200 Message-Id: <20230819094806.14965-11-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230819094806.14965-1-kariem.taha2.7@gmail.com> References: <20230819094806.14965-1-kariem.taha2.7@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wm1-x32d.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Stacey Son Signed-off-by: Stacey Son Signed-off-by: Karim Taha Reviewed-by: Warner Losh Reviewed-by: Richard Henderson --- bsd-user/bsd-mem.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/bsd-user/bsd-mem.c b/bsd-user/bsd-mem.c index e69250cc0d..4446c94725 100644 --- a/bsd-user/bsd-mem.c +++ b/bsd-user/bsd-mem.c @@ -77,3 +77,49 @@ abi_long host_to_target_ipc_perm(abi_ulong target_addr, return 0; } +abi_long target_to_host_shmid_ds(struct shmid_ds *host_sd, + abi_ulong target_addr) +{ + struct target_shmid_ds *target_sd; + + if (!lock_user_struct(VERIFY_READ, target_sd, target_addr, 1)) { + return -TARGET_EFAULT; + } + if (target_to_host_ipc_perm(&(host_sd->shm_perm), target_addr)) { + return -TARGET_EFAULT; + } + __get_user(host_sd->shm_segsz, &target_sd->shm_segsz); + __get_user(host_sd->shm_lpid, &target_sd->shm_lpid); + __get_user(host_sd->shm_cpid, &target_sd->shm_cpid); + __get_user(host_sd->shm_nattch, &target_sd->shm_nattch); + __get_user(host_sd->shm_atime, &target_sd->shm_atime); + __get_user(host_sd->shm_dtime, &target_sd->shm_dtime); + __get_user(host_sd->shm_ctime, &target_sd->shm_ctime); + unlock_user_struct(target_sd, target_addr, 0); + + return 0; +} + +abi_long host_to_target_shmid_ds(abi_ulong target_addr, + struct shmid_ds *host_sd) +{ + struct target_shmid_ds *target_sd; + + if (!lock_user_struct(VERIFY_WRITE, target_sd, target_addr, 0)) { + return -TARGET_EFAULT; + } + if (host_to_target_ipc_perm(target_addr, &(host_sd->shm_perm))) { + return -TARGET_EFAULT; + } + __put_user(host_sd->shm_segsz, &target_sd->shm_segsz); + __put_user(host_sd->shm_lpid, &target_sd->shm_lpid); + __put_user(host_sd->shm_cpid, &target_sd->shm_cpid); + __put_user(host_sd->shm_nattch, &target_sd->shm_nattch); + __put_user(host_sd->shm_atime, &target_sd->shm_atime); + __put_user(host_sd->shm_dtime, &target_sd->shm_dtime); + __put_user(host_sd->shm_ctime, &target_sd->shm_ctime); + unlock_user_struct(target_sd, target_addr, 1); + + return 0; +} + From patchwork Sat Aug 19 09:47:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karim Taha X-Patchwork-Id: 1823280 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=mJ0iPUjO; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RSYrq6MTqz1yfT for ; Sat, 19 Aug 2023 19:50:35 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qXIZy-0008Ds-Bv; Sat, 19 Aug 2023 05:49:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qXIZv-0008D1-Bk for qemu-devel@nongnu.org; Sat, 19 Aug 2023 05:49:07 -0400 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qXIZs-0004Np-Kb for qemu-devel@nongnu.org; Sat, 19 Aug 2023 05:49:06 -0400 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-3159d5e409dso1817072f8f.0 for ; Sat, 19 Aug 2023 02:49:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692438542; x=1693043342; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3JAfWqMnHgpL9IoIVe+auJYPOPEmTFIAYeHKJ4xSGEk=; b=mJ0iPUjOjLy8EjwDPfR1G3dBM3GbD1R0K2nVsqrcZ2TrVb3WHATR9mXYvMlI7bfHaR WLI0rXTWgvKXi6YNUoFhIiqefZ0ubcZMHIzLg+GNpQkyLACvvnbuVTDZ6xPlkhubtvCK e8hMt73iVM4hGaanpOfPucR4/f98SN/HB1RR/MUJEjpKUYclZCwDA1ilEZB4lz4yETai JXMdJGgvq3vW8Y6o1laZqWaGp9Kwcd5hbGbQXZNjw4jJbOVaYwLBbSrRyt2QG8qaemIr dmJ6QdzQnno+6aFUSP4Vj1SorEFPaz1YC3CxbwckafHXaAwxmVmRu57yLl9ggaFTpyHd MXxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692438542; x=1693043342; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3JAfWqMnHgpL9IoIVe+auJYPOPEmTFIAYeHKJ4xSGEk=; b=R5zC/djOQ5ljbGFtuKyyNZiSGT7sOkCwWG0wIiJSWQb2nXqmvWK+RsO23u95sAanDZ ATUINZAZInDH8b6WVN7JIwHii/WmBo/2PeXAkndreux8XA2w/r2KuTD/hySiuNp9zAoU JcJHiiCrW12yqKzErD8ZkhYodkq3yykl/dwjwWGBZn29UrgI4dn3fRnijdj+43nB1/lD ND8fNKrLHsElycFtgcZ3E6QaVGRHXzNqKXIJBzvvVeo39SrQ+jq3bJNIM6lZe9eodGBB aCuP6hxJhgYtPK33GopR74suVoYrMBPpO6wKQxzhuOFc6jxxT7eb1cWl1SORAv4mCScX iqCw== X-Gm-Message-State: AOJu0YwZ4syOcxW5Y0geGB6ul1zKLTMvO+584VEpcLMBNLAmdze6a2/T 8ajsVV0NaBmeQeLhMB8AJrerh7G2tA4= X-Google-Smtp-Source: AGHT+IHzqmHnqQ0xwuh5wjhmaFMTbjxEB9vtylQox9UDBaZFysUCWYn/zETRvOojbJg4R2zVzuZ9gw== X-Received: by 2002:adf:ec8a:0:b0:317:de66:259b with SMTP id z10-20020adfec8a000000b00317de66259bmr1123791wrn.15.1692438542476; Sat, 19 Aug 2023 02:49:02 -0700 (PDT) Received: from karim.my.domain ([197.39.34.171]) by smtp.gmail.com with ESMTPSA id o18-20020adfead2000000b003143b14848dsm5617216wrn.102.2023.08.19.02.48.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Aug 2023 02:49:02 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: imp@bsdimp.com, Stacey Son , Karim Taha Subject: [PATCH 11/22] Introduce bsd-mem.h to the source tree Date: Sat, 19 Aug 2023 11:47:55 +0200 Message-Id: <20230819094806.14965-12-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230819094806.14965-1-kariem.taha2.7@gmail.com> References: <20230819094806.14965-1-kariem.taha2.7@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::434; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wr1-x434.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Stacey Son To preserve the copyright notice and help with the 'Author' info for subsequent changes to the file. Signed-off-by: Stacey Son Signed-off-by: Karim Taha Reviewed-by: Warner Losh Reviewed-by: Richard Henderson --- bsd-user/bsd-mem.h | 65 +++++++++++++++++++++++++++++++++++ bsd-user/freebsd/os-syscall.c | 1 + 2 files changed, 66 insertions(+) create mode 100644 bsd-user/bsd-mem.h diff --git a/bsd-user/bsd-mem.h b/bsd-user/bsd-mem.h new file mode 100644 index 0000000000..fed7b7cd80 --- /dev/null +++ b/bsd-user/bsd-mem.h @@ -0,0 +1,65 @@ +/* + * memory management system call shims and definitions + * + * Copyright (c) 2013-15 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 . + */ + +/* + * Copyright (c) 1982, 1986, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef BSD_USER_BSD_MEM_H +#define BSD_USER_BSD_MEM_H + +#include +#include +#include +#include +#include + +#include "qemu-bsd.h" + +extern struct bsd_shm_regions bsd_shm_regions[]; +extern abi_ulong bsd_target_brk; +extern abi_ulong bsd_target_original_brk; +extern abi_ulong brk_page; + +#endif /* BSD_USER_BSD_MEM_H */ diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index c0a22eb746..7e2a395e0f 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -35,6 +35,7 @@ /* BSD independent syscall shims */ #include "bsd-file.h" +#include "bsd-mem.h" #include "bsd-proc.h" /* *BSD dependent syscall shims */ From patchwork Sat Aug 19 09:47:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karim Taha X-Patchwork-Id: 1823288 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=KDZ2CVer; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RSYsn42VRz1yfT for ; Sat, 19 Aug 2023 19:51:25 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qXIa0-0008Et-1x; Sat, 19 Aug 2023 05:49:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qXIZy-0008Dv-Mk for qemu-devel@nongnu.org; Sat, 19 Aug 2023 05:49:10 -0400 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qXIZw-0004OV-H9 for qemu-devel@nongnu.org; Sat, 19 Aug 2023 05:49:10 -0400 Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-3197a71a9c0so1805506f8f.1 for ; Sat, 19 Aug 2023 02:49:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692438547; x=1693043347; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=EKLohNJ4jsfkvSt12B7Pqd7PyvArnsguuWML93IEGns=; b=KDZ2CVer4/5IPR3eN3lUPDZtsqLTLDYl4WR51H7/rgHTQYimX5CIPDQcMTf2+k7apM cvaDcEseiMgP3nUlmMBZTkpYyT8LdVj0/hQqkpU/pD+PW6IwbHe2zYYOXKfuntnXPykS oaNXvPo7JNLfSNww2ctHPfiJ9bJjOZokOYNMYQwyNW1b32QnRJmmaY3Jn3jZwwy6pMYN qOpG+QOa+1qBiioUMbN4QbHtH/m72xxfkFIxOcMcVwWetMCMl/yK9U/NEriv8AIgRnyv RkUOfoe8hTG0qcAjkGKMLD1fZ6QlgPhL05JoWRALJbcJwxYiTznA1HX+PfRP0IY/RN+J fwsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692438547; x=1693043347; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EKLohNJ4jsfkvSt12B7Pqd7PyvArnsguuWML93IEGns=; b=j4I9oUobFS7Lhd8qdO+oOXdSfCuVlJO0wzJVFxxqkHKGWWNEfe+HPE8Q3rasl2kIes TJMGJBvKLmz6RQqS5xZo/iZUjMyr1TjNUij4+oQicK62Hws9R/GhGKg6LvPPYfghL/AA NvkIRLRn4IckJXJrfcCj66K32hB6/fCFJ4FHqhxEAG+VBtWk2Ldi9ZhgCr6WLmzWCvdm H05WRFfH6Qn0fkq2kGmWuYf7qMyN8jmF1ch+HVoyXQPsF6+uaWP2yGO/Ra7gRgMbT0L0 F2XDkgQ3ZGSpgTAw4DO7WJZgztTrJTKuQfkr9EAGQalZ/a9vCedlrv+aXToWBhv8lf3V ySww== X-Gm-Message-State: AOJu0Yxv3NZEP1zVYbX6EhLFLrIEXvcdsyUt1x3A5tWQWRhRgwcCb1GR DBb9nuuExUtYUU4nmOPBHiUb0y/rKuk= X-Google-Smtp-Source: AGHT+IH53Wp5SGXIdqYZj2zjQXTTS3rM9bAjU9ZZ1tQPF46XfhnTACXDKhyi81qpas35fQQ1imRmew== X-Received: by 2002:a5d:4ac2:0:b0:319:70c8:6e90 with SMTP id y2-20020a5d4ac2000000b0031970c86e90mr925306wrs.24.1692438546758; Sat, 19 Aug 2023 02:49:06 -0700 (PDT) Received: from karim.my.domain ([197.39.34.171]) by smtp.gmail.com with ESMTPSA id o18-20020adfead2000000b003143b14848dsm5617216wrn.102.2023.08.19.02.49.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Aug 2023 02:49:06 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: imp@bsdimp.com, Stacey Son , Karim Taha Subject: [PATCH 12/22] Implement mmap(2) and munmap(2) Date: Sat, 19 Aug 2023 11:47:56 +0200 Message-Id: <20230819094806.14965-13-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230819094806.14965-1-kariem.taha2.7@gmail.com> References: <20230819094806.14965-1-kariem.taha2.7@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42a; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wr1-x42a.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Stacey Son Signed-off-by: Stacey Son Signed-off-by: Karim Taha Reviewed-by: Warner Losh Reviewed-by: Richard Henderson --- bsd-user/bsd-mem.h | 20 ++++++++++++++++++++ bsd-user/freebsd/os-syscall.c | 9 +++++++++ 2 files changed, 29 insertions(+) diff --git a/bsd-user/bsd-mem.h b/bsd-user/bsd-mem.h index fed7b7cd80..057c995a6e 100644 --- a/bsd-user/bsd-mem.h +++ b/bsd-user/bsd-mem.h @@ -62,4 +62,24 @@ extern abi_ulong bsd_target_brk; extern abi_ulong bsd_target_original_brk; extern abi_ulong brk_page; +/* mmap(2) */ +static inline abi_long do_bsd_mmap(void *cpu_env, abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, abi_long arg5, abi_long arg6, abi_long arg7, + abi_long arg8) +{ + if (regpairs_aligned(cpu_env) != 0) { + arg6 = arg7; + arg7 = arg8; + } + return get_errno(target_mmap(arg1, arg2, arg3, + target_to_host_bitmask(arg4, mmap_flags_tbl), + arg5, target_arg64(arg6, arg7))); +} + +/* munmap(2) */ +static inline abi_long do_bsd_munmap(abi_long arg1, abi_long arg2) +{ + return get_errno(target_munmap(arg1, arg2)); +} + #endif /* BSD_USER_BSD_MEM_H */ diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index 7e2a395e0f..3525d39d7b 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -486,6 +486,15 @@ static abi_long freebsd_syscall(void *cpu_env, int num, abi_long arg1, /* * Memory management system calls. */ + case TARGET_FREEBSD_NR_mmap: /* mmap(2) */ + ret = do_bsd_mmap(cpu_env, arg1, arg2, arg3, arg4, arg5, arg6, arg7, + arg8); + break; + + case TARGET_FREEBSD_NR_munmap: /* munmap(2) */ + ret = do_bsd_munmap(arg1, arg2); + break; + #if defined(__FreeBSD_version) && __FreeBSD_version >= 1300048 case TARGET_FREEBSD_NR_shm_open2: /* shm_open2(2) */ ret = do_freebsd_shm_open2(arg1, arg2, arg3, arg4, arg5); From patchwork Sat Aug 19 09:47:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karim Taha X-Patchwork-Id: 1823287 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=hD5vfcVT; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RSYsf4dKyz1yfT for ; Sat, 19 Aug 2023 19:51:18 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qXIa3-0008FW-Jp; Sat, 19 Aug 2023 05:49:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qXIa1-0008F9-Pc for qemu-devel@nongnu.org; Sat, 19 Aug 2023 05:49:13 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qXIZz-0004PM-IZ for qemu-devel@nongnu.org; Sat, 19 Aug 2023 05:49:13 -0400 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-3fed963273cso5600185e9.1 for ; Sat, 19 Aug 2023 02:49:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692438550; x=1693043350; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=LO8q0y58WgnWuoU0UOPDubyf7LY9zjVTClzFcwjWHJ0=; b=hD5vfcVTkDHeZ77AEg1lzbNajUvkRfh36wB3sNTh2ZPsqLeW0xMWqbEFb+zdK6g1MF gWtUczD0J0hhF2OGxhx/mh6w88HjHmxikvYd8TNARQ4vNKuMtUJpnLJDm4RxowXqhCBf nwwuIzDb3DEcSG+bR8wRph4Yjp8qGTrRecN1wtW0SZvFQQI+s48p+qmtaOcJyr0EpwDo g1qAm6uAi/CAlzi73pNE+eLllV2lxnEpmlTH0x+NEcIN7m3Eke1jbNAXDV34DqWMq6Dl oQ82f4YJgQKGlXNJMDnb7yMY9pEmCDfLYv/K9Y74j55I4a8potJko3HAAS8vBkgBoTaU B7ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692438550; x=1693043350; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LO8q0y58WgnWuoU0UOPDubyf7LY9zjVTClzFcwjWHJ0=; b=P5iw8lsZIrAUddZ9eMHCzbWRZd6PcsIWqcSzBOkUfC5nu7WZqVYEEBS8ZHEKp5pSGh 9/1pXzcMkdOwB3mo9y4kLc0Sl+PCD1qG9mwWGE93Dw8vf4ribRpCsA2+MGXo2tH6M+qD vB2ZH1IsKc2av8649WDG+gNWbcTXiR81r22FQ4iMFgzgi0TbWYwchOaXi4LVR/9MT5xg ecJ+DiqoZvuO9JIi5kWmlk0Opm3LE8nCW6gS80f7sBd6drJ6cCcWnpof49QPNezg1TGm VfSFGiDosdd7SWa5sj1EoQaQi8mR8sEcUcSR5R4qKLBT1diVWAt9GBV0uU6ORVSyd7dg l2vg== X-Gm-Message-State: AOJu0Ywy8VJswOnjeZKQPdNmUMTIxAGe4rowFbBBcVkIpbpOUy+5fpr9 J5rpgmVwaRYiEZ+/M0Fwr1o7odQXIOQ= X-Google-Smtp-Source: AGHT+IEg/mEoTjk2/EYNQptMeoJOytYbfaYjwSH2bYONGvFG1+AIDJnVbyXKxAZklMCIsBQ1JPr2+A== X-Received: by 2002:adf:f8c4:0:b0:319:6ed2:a5c4 with SMTP id f4-20020adff8c4000000b003196ed2a5c4mr1232439wrq.26.1692438550046; Sat, 19 Aug 2023 02:49:10 -0700 (PDT) Received: from karim.my.domain ([197.39.34.171]) by smtp.gmail.com with ESMTPSA id o18-20020adfead2000000b003143b14848dsm5617216wrn.102.2023.08.19.02.49.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Aug 2023 02:49:09 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: imp@bsdimp.com, Stacey Son , Karim Taha Subject: [PATCH 13/22] Implement mprotect(2) Date: Sat, 19 Aug 2023 11:47:57 +0200 Message-Id: <20230819094806.14965-14-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230819094806.14965-1-kariem.taha2.7@gmail.com> References: <20230819094806.14965-1-kariem.taha2.7@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wm1-x331.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Stacey Son Signed-off-by: Stacey Son Signed-off-by: Karim Taha Reviewed-by: Warner Losh Reviewed-by: Richard Henderson --- bsd-user/bsd-mem.h | 7 +++++++ bsd-user/freebsd/os-syscall.c | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/bsd-user/bsd-mem.h b/bsd-user/bsd-mem.h index 057c995a6e..a6446a454c 100644 --- a/bsd-user/bsd-mem.h +++ b/bsd-user/bsd-mem.h @@ -82,4 +82,11 @@ static inline abi_long do_bsd_munmap(abi_long arg1, abi_long arg2) return get_errno(target_munmap(arg1, arg2)); } +/* mprotect(2) */ +static inline abi_long do_bsd_mprotect(abi_long arg1, abi_long arg2, + abi_long arg3) +{ + return get_errno(target_mprotect(arg1, arg2, arg3)); +} + #endif /* BSD_USER_BSD_MEM_H */ diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index 3525d39d7b..aea4e337ff 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -495,6 +495,10 @@ static abi_long freebsd_syscall(void *cpu_env, int num, abi_long arg1, ret = do_bsd_munmap(arg1, arg2); break; + case TARGET_FREEBSD_NR_mprotect: /* mprotect(2) */ + ret = do_bsd_mprotect(arg1, arg2, arg3); + break; + #if defined(__FreeBSD_version) && __FreeBSD_version >= 1300048 case TARGET_FREEBSD_NR_shm_open2: /* shm_open2(2) */ ret = do_freebsd_shm_open2(arg1, arg2, arg3, arg4, arg5); From patchwork Sat Aug 19 09:47:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karim Taha X-Patchwork-Id: 1823269 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=NFF1l15E; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RSYqx62rBz1ygd for ; Sat, 19 Aug 2023 19:49:49 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qXIa9-0008Fv-4R; Sat, 19 Aug 2023 05:49:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qXIa6-0008Fg-S0 for qemu-devel@nongnu.org; Sat, 19 Aug 2023 05:49:18 -0400 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qXIa4-0004QS-Mj for qemu-devel@nongnu.org; Sat, 19 Aug 2023 05:49:18 -0400 Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-31aeef88a55so90367f8f.2 for ; Sat, 19 Aug 2023 02:49:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692438555; x=1693043355; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=n7/IWLVzM+rb7qpxr0YHxCfxEsJwwJSGTfo1cqhcDsM=; b=NFF1l15ELhy7qN+0NWO5MVAtCagxv4byAAf7Xf6kMA28qDX/IMAbNchFriZKTLF1UB 66fawg1NV09aSdsEQfLoBTrfV9wtIrWVJfAsfatk71JRPssHMRvgxd8T72fLAa+clN/x 1K/fGpJViDf7M3x+dVjBvxGR7yNV0SYF+CW6spr6w1UvtKFEaPQCU6bdNlp51TXtiy9a YTDQVzHCVsFBnHiY2FaD5L8MR1DsUZDmEPpSA1x35Pfu0eEhCwLta2ZKFGYlvaTV48Ky AmLEdPwK7cJzRKph6hog4sN2e/vI8oQmEz5/+k0tnKbbk7k5OANNCqW41BE0DAfxXz8z jGrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692438555; x=1693043355; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=n7/IWLVzM+rb7qpxr0YHxCfxEsJwwJSGTfo1cqhcDsM=; b=OgzYyos42eqztkAfvdLBx7f4gxekZsEl0EX2+Fa5g5EsQmwYUeBP9Z1J1WH1khn91m nQ9OswFh1L67GwB9bR8s0urm1XROU1gXV7DuSdY5IgSW8XT35RiMwgVgsUI7InRMb6nu g+TR2pfW1CEo8QA6zZC3xHDf6rhMh7GC5rxgdqJhudaTdviQV9j5HUNqalMtrX2tOskV I11pOzlen/w0Y7nU04CdM01TEFKPsGm107YYfElyDtxKu9II546E2+hXW5FopQcUfzGE 8tBRREOWF5dhGTn8Nn1Eaba4+j2MI0RnsCwo35+CmCNsUN8W6AVYnsyT9lCsa+Rwcle4 W7tQ== X-Gm-Message-State: AOJu0YxlsbWR9ZE/xClxySjz3mRkNiZUSFw2aDja3ZYa+cyC8d3HjIyj urEw1Cq94vK6iljR6DxbIurHXB18tfg= X-Google-Smtp-Source: AGHT+IE1YccK+3w1O6U+NvsELMZrvL8TsyIz/kBFvRpwwoy5GisA5er6jCynBoL/EGIkE3gNw3wvSA== X-Received: by 2002:a5d:4911:0:b0:314:1f6:2c24 with SMTP id x17-20020a5d4911000000b0031401f62c24mr1128215wrq.36.1692438555072; Sat, 19 Aug 2023 02:49:15 -0700 (PDT) Received: from karim.my.domain ([197.39.34.171]) by smtp.gmail.com with ESMTPSA id o18-20020adfead2000000b003143b14848dsm5617216wrn.102.2023.08.19.02.49.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Aug 2023 02:49:14 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: imp@bsdimp.com, Stacey Son , Kyle Evans , Karim Taha Subject: [PATCH 14/22] Implement msync(2) Date: Sat, 19 Aug 2023 11:47:58 +0200 Message-Id: <20230819094806.14965-15-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230819094806.14965-1-kariem.taha2.7@gmail.com> References: <20230819094806.14965-1-kariem.taha2.7@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::433; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wr1-x433.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Stacey Son Co-authored-by: Kyle Evans Signed-off-by: Stacey Son Signed-off-by: Kyle Evans Signed-off-by: Karim Taha Reviewed-by: Warner Losh Reviewed-by: Richard Henderson --- bsd-user/bsd-mem.h | 11 +++++++++++ bsd-user/freebsd/os-syscall.c | 4 ++++ 2 files changed, 15 insertions(+) diff --git a/bsd-user/bsd-mem.h b/bsd-user/bsd-mem.h index a6446a454c..68d79ac080 100644 --- a/bsd-user/bsd-mem.h +++ b/bsd-user/bsd-mem.h @@ -89,4 +89,15 @@ static inline abi_long do_bsd_mprotect(abi_long arg1, abi_long arg2, return get_errno(target_mprotect(arg1, arg2, arg3)); } +/* msync(2) */ +static inline abi_long do_bsd_msync(abi_long addr, abi_long len, abi_long flags) +{ + if (!access_ok(VERIFY_WRITE, addr, len)) { + /* XXX Should be EFAULT, but FreeBSD seems to get this wrong. */ + return -TARGET_ENOMEM; + } + + return get_errno(msync(g2h_untagged(addr), len, flags)); +} + #endif /* BSD_USER_BSD_MEM_H */ diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index aea4e337ff..3871b15309 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -499,6 +499,10 @@ static abi_long freebsd_syscall(void *cpu_env, int num, abi_long arg1, ret = do_bsd_mprotect(arg1, arg2, arg3); break; + case TARGET_FREEBSD_NR_msync: /* msync(2) */ + ret = do_bsd_msync(arg1, arg2, arg3); + break; + #if defined(__FreeBSD_version) && __FreeBSD_version >= 1300048 case TARGET_FREEBSD_NR_shm_open2: /* shm_open2(2) */ ret = do_freebsd_shm_open2(arg1, arg2, arg3, arg4, arg5); From patchwork Sat Aug 19 09:47:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karim Taha X-Patchwork-Id: 1823270 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=JwGoioK7; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RSYr13Rsfz1yfn for ; Sat, 19 Aug 2023 19:49:53 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qXIaC-0008IH-Q4; Sat, 19 Aug 2023 05:49:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qXIaB-0008I1-BF for qemu-devel@nongnu.org; Sat, 19 Aug 2023 05:49:23 -0400 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qXIa9-0004R4-2t for qemu-devel@nongnu.org; Sat, 19 Aug 2023 05:49:23 -0400 Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-3159d5e409dso1817151f8f.0 for ; Sat, 19 Aug 2023 02:49:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692438559; x=1693043359; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=fcEDQVT+54S0bGeOFUY/GJyiJkZ+0XSR0DUTuF9ZCRg=; b=JwGoioK7NjCxYbHNyk5lGM13NnWh86LGVZQljTIgyOH/wvGJr5PgsQEwhSqbXox7ta KjYGFT2moWchUTmV0L4fXbgBjyER/+mZAFTO78p8Dtrfw/il4VsDVKT3mf+U7TagSKxS 71RHxDndyh0YRIhjyxZu7IEn1259ykH16GVF9vezbNfiBQ4uy65XRPqg2btY7v3l49NZ lBYg6xHeXm0toysQF0fQ0Vqgt/TVYtO7KZrVLNQ1QuN1zYKbB5w1PBBDogBpiKPD8RND QNsDjqofKqnEiJNvHYZ160BZM5FzA+fvDO8MiVHe0/aSwgG5iBiVjAcUG83ubLDpto0q SYAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692438559; x=1693043359; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fcEDQVT+54S0bGeOFUY/GJyiJkZ+0XSR0DUTuF9ZCRg=; b=Byw7BkCZp48bU7nG9bIZIr7EAROjfWb0UXNuUkoUqiTfGIuPz+/xfmRt7uUH8rQ3mK IlPdG8rRiH1/bRvBg6FnAWpHVoamX6v8ZsMw2pVQhddjnrVY8XS/48KvZfhDFHJKVOSZ zT4VwKtVRGjOcFhZ5Y1HTPSIGwWnK0A4oMJ2i8ZAioxFsz/0jP36Q9xsLKbuwb4b502n +YxWcTvUUhcG4+spdFxMamoH9H2bNRN/kugxReqZoDtclWmgbLnd9bvW1UnCox1NeD9W vHUP6ow/KCuS0RMW0DAR9+EaIyXA1sccfpMRYBxQxPk/YjT3NKEvS9a7G1g/3KOUGvCF ncWA== X-Gm-Message-State: AOJu0YxhPCJRWsE3iSjSYyZfbzZzkRVX+u68YTpTvZkYShkOm/d6hzWT QtmMbplUp2fDgXAv5ukVhv25gzdt1bU= X-Google-Smtp-Source: AGHT+IHTOCwN9cLCLqLWd3CzN4SrL0orckUuhaxhWXobtI6MjvS0I1uy5orag+rNX0axxfxNpHaOhA== X-Received: by 2002:adf:e584:0:b0:319:7908:cf26 with SMTP id l4-20020adfe584000000b003197908cf26mr3668779wrm.26.1692438559525; Sat, 19 Aug 2023 02:49:19 -0700 (PDT) Received: from karim.my.domain ([197.39.34.171]) by smtp.gmail.com with ESMTPSA id o18-20020adfead2000000b003143b14848dsm5617216wrn.102.2023.08.19.02.49.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Aug 2023 02:49:19 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: imp@bsdimp.com, Stacey Son , Karim Taha Subject: [PATCH 15/22] Implement mlock(2), munlock(2), mlockall(2), munlockall(2), madvise(2), minherit(2) Date: Sat, 19 Aug 2023 11:47:59 +0200 Message-Id: <20230819094806.14965-16-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230819094806.14965-1-kariem.taha2.7@gmail.com> References: <20230819094806.14965-1-kariem.taha2.7@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42c; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wr1-x42c.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Stacey Son Signed-off-by: Stacey Son Signed-off-by: Karim Taha Reviewed-by: Richard Henderson --- bsd-user/bsd-mem.h | 44 +++++++++++++++++++++++++++++++++++ bsd-user/freebsd/os-syscall.c | 24 +++++++++++++++++++ 2 files changed, 68 insertions(+) diff --git a/bsd-user/bsd-mem.h b/bsd-user/bsd-mem.h index 68d79ac080..f76881519c 100644 --- a/bsd-user/bsd-mem.h +++ b/bsd-user/bsd-mem.h @@ -100,4 +100,48 @@ static inline abi_long do_bsd_msync(abi_long addr, abi_long len, abi_long flags) return get_errno(msync(g2h_untagged(addr), len, flags)); } +/* mlock(2) */ +static inline abi_long do_bsd_mlock(abi_long arg1, abi_long arg2) +{ + return get_errno(mlock(g2h_untagged(arg1), arg2)); +} + +/* munlock(2) */ +static inline abi_long do_bsd_munlock(abi_long arg1, abi_long arg2) +{ + return get_errno(munlock(g2h_untagged(arg1), arg2)); +} + +/* mlockall(2) */ +static inline abi_long do_bsd_mlockall(abi_long arg1) +{ + return get_errno(mlockall(arg1)); +} + +/* munlockall(2) */ +static inline abi_long do_bsd_munlockall(void) +{ + return get_errno(munlockall()); +} + +/* madvise(2) */ +static inline abi_long do_bsd_madvise(abi_long arg1, abi_long arg2, + abi_long arg3) +{ + /* + * A straight passthrough may not be safe because qemu sometimes + * turns private file-backed mapping into anonymous mappings. This + * will break MADV_DONTNEED. This is a hint, so ignoring and returing + * success is ok. + */ + return get_errno(0); +} + +/* minherit(2) */ +static inline abi_long do_bsd_minherit(abi_long addr, abi_long len, + abi_long inherit) +{ + return get_errno(minherit(g2h_untagged(addr), len, inherit)); +} + #endif /* BSD_USER_BSD_MEM_H */ diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index 3871b15309..96469f6a63 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -503,6 +503,30 @@ static abi_long freebsd_syscall(void *cpu_env, int num, abi_long arg1, ret = do_bsd_msync(arg1, arg2, arg3); break; + case TARGET_FREEBSD_NR_mlock: /* mlock(2) */ + ret = do_bsd_mlock(arg1, arg2); + break; + + case TARGET_FREEBSD_NR_munlock: /* munlock(2) */ + ret = do_bsd_munlock(arg1, arg2); + break; + + case TARGET_FREEBSD_NR_mlockall: /* mlockall(2) */ + ret = do_bsd_mlockall(arg1); + break; + + case TARGET_FREEBSD_NR_munlockall: /* munlockall(2) */ + ret = do_bsd_munlockall(); + break; + + case TARGET_FREEBSD_NR_madvise: /* madvise(2) */ + ret = do_bsd_madvise(arg1, arg2, arg3); + break; + + case TARGET_FREEBSD_NR_minherit: /* minherit(2) */ + ret = do_bsd_minherit(arg1, arg2, arg3); + break; + #if defined(__FreeBSD_version) && __FreeBSD_version >= 1300048 case TARGET_FREEBSD_NR_shm_open2: /* shm_open2(2) */ ret = do_freebsd_shm_open2(arg1, arg2, arg3, arg4, arg5); From patchwork Sat Aug 19 09:48:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karim Taha X-Patchwork-Id: 1823289 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=Av6vigx+; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RSYt20hbyz1yfT for ; Sat, 19 Aug 2023 19:51:38 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qXIaK-0000Dz-Ef; Sat, 19 Aug 2023 05:49:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qXIaH-0008Ro-Sq for qemu-devel@nongnu.org; Sat, 19 Aug 2023 05:49:30 -0400 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qXIaE-0004Rk-KL for qemu-devel@nongnu.org; Sat, 19 Aug 2023 05:49:28 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-3fee843b44cso29195e9.1 for ; Sat, 19 Aug 2023 02:49:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692438565; x=1693043365; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=B+L871gKAezQf99S6rDk0v5Re5KqfhLUHH5G1ZAfQZk=; b=Av6vigx+KhDMujQLINPh9xBjPQ2ERsN4A/AEaekoKRWRAKFP+n+dm/ZCz5yPUaEujN XJHtown2Uk5KXAo6Jf/xlLZaCk9oTAEiCBwMGhY9aNQPLBAGmbCUWhIe3s9fkrDZe/4z RzQFx4+Id1CuIOBrGGKrbpQ1XE8vmbF/1La1sdWs/uGt7vQZkPYe59ja7+T+/+fzhaHQ h/Qiyo5AoZ17Sqiz2qhg+rek/C2Z9x+IvQkGqni7SiVhCZYGq2RT+TB6EV0hngsTLrMc pCk9FV41BtcOK7MZ8GgS4xxQjoV/vOZsTfCVpR5zxwucm6bhCic7IvN19VMXztBbLg09 sThw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692438565; x=1693043365; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=B+L871gKAezQf99S6rDk0v5Re5KqfhLUHH5G1ZAfQZk=; b=Dvx4nz7eSlOsF9L73jBTeMUdeSf6CU15iYmB0Sza9fl+ka/bYWFTvTvjHjYbcWJYDa 728XR6jryVKshTITYkYKzG0AgRB/e6LvTWMmX/6DIUQR4GGoINoZDfl95u/DMvxTHoYO ozh6n2W7cpzlqU65mxx5Spkb62C+UW11v4OX61JFES5k0BMaXui80AoDVtXc8VrCxG9n 8NDmc2R8XAFrWPRsGLnHq2R6hSCjqVrD0fehiBlVYW3NV6kTzbvbFNCMAoWhI+YCSQFg 5tny0ReP3gZFVc9MyJ7zKKVqzK9YrRNsD0LDcQSExkerFK47CL7ILgts2Ybb6IlLl3n/ /0Zw== X-Gm-Message-State: AOJu0YxpPBKxxAcC0AJPHY77BBT0urLtTxNZ5lpQ072qajHE24zcdIxl KxSNbC5YVjTIi6qVlUYSg91O4/pRavs= X-Google-Smtp-Source: AGHT+IGK0et7uEpkrKTyHHZce2lZIM+rqeC64c4woAvSS1qeK+BBeSiOVgPpZI4M+TG3ZmHS1M5KJQ== X-Received: by 2002:a05:600c:2193:b0:3f7:3991:e12e with SMTP id e19-20020a05600c219300b003f73991e12emr1203551wme.1.1692438564552; Sat, 19 Aug 2023 02:49:24 -0700 (PDT) Received: from karim.my.domain ([197.39.34.171]) by smtp.gmail.com with ESMTPSA id o18-20020adfead2000000b003143b14848dsm5617216wrn.102.2023.08.19.02.49.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Aug 2023 02:49:24 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: imp@bsdimp.com, Stacey Son , Karim Taha Subject: [PATCH 16/22] Implement mincore(2) Date: Sat, 19 Aug 2023 11:48:00 +0200 Message-Id: <20230819094806.14965-17-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230819094806.14965-1-kariem.taha2.7@gmail.com> References: <20230819094806.14965-1-kariem.taha2.7@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wm1-x32c.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Stacey Son Signed-off-by: Stacey Son Signed-off-by: Karim Taha Reviewed-by: Warner Losh --- bsd-user/bsd-mem.h | 23 +++++++++++++++++++++++ bsd-user/freebsd/os-syscall.c | 4 ++++ 2 files changed, 27 insertions(+) diff --git a/bsd-user/bsd-mem.h b/bsd-user/bsd-mem.h index f76881519c..edbccd3111 100644 --- a/bsd-user/bsd-mem.h +++ b/bsd-user/bsd-mem.h @@ -144,4 +144,27 @@ static inline abi_long do_bsd_minherit(abi_long addr, abi_long len, return get_errno(minherit(g2h_untagged(addr), len, inherit)); } +/* mincore(2) */ +static inline abi_long do_bsd_mincore(abi_ulong target_addr, abi_ulong len, + abi_ulong target_vec) +{ + abi_long ret; + void *p, *a; + + a = lock_user(VERIFY_WRITE, target_addr, len, 0); + if (a == NULL) { + return -TARGET_EFAULT; + } + p = lock_user_string(target_vec); + if (p == NULL) { + unlock_user(a, target_addr, 0); + return -TARGET_EFAULT; + } + ret = get_errno(mincore(a, len, p)); + unlock_user(p, target_vec, ret); + unlock_user(a, target_addr, 0); + + return ret; +} + #endif /* BSD_USER_BSD_MEM_H */ diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index 96469f6a63..1db0907504 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -527,6 +527,10 @@ static abi_long freebsd_syscall(void *cpu_env, int num, abi_long arg1, ret = do_bsd_minherit(arg1, arg2, arg3); break; + case TARGET_FREEBSD_NR_mincore: /* mincore(2) */ + ret = do_bsd_mincore(arg1, arg2, arg3); + break; + #if defined(__FreeBSD_version) && __FreeBSD_version >= 1300048 case TARGET_FREEBSD_NR_shm_open2: /* shm_open2(2) */ ret = do_freebsd_shm_open2(arg1, arg2, arg3, arg4, arg5); From patchwork Sat Aug 19 09:48:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Karim Taha X-Patchwork-Id: 1823286 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=RXNpFGkd; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RSYsc2RFfz1yfT for ; Sat, 19 Aug 2023 19:51:16 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qXIaM-0000PU-9h; Sat, 19 Aug 2023 05:49:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qXIaK-0000C5-02 for qemu-devel@nongnu.org; Sat, 19 Aug 2023 05:49:32 -0400 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qXIaH-0004S2-Ll for qemu-devel@nongnu.org; Sat, 19 Aug 2023 05:49:31 -0400 Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-31963263938so1488242f8f.2 for ; Sat, 19 Aug 2023 02:49:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692438567; x=1693043367; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Nv7yMt8dX1c1ZS9qclIo4WY6Lz8Ylr5dRKgu2Ds1pu8=; b=RXNpFGkdU9qWzoY8/9jj53exHwUS4vtoTlrKOBs3BdoGavinQiYZwc0SKAJViM9w5x sEwK12+Q7I3Lh3pfhf0zc6ncb+s7Vnm3aFlZIgU4Q8yriAgZDfoA+RSKzGx8BtH7mum6 E3hLZNZpK0DcLKJN1XbinOn74sEEl4z9U+fnDQ9EZtReBS4s/1nmdKFXj8Xs4EcuFBOy 0+xk7cwbm7O2qBWqhN3nPEGdSE7lTDFmvrFR+4irnFxc/ADKLb70Iq7DI1YDjnrjQxes HXTPbAE14DXiBpWO42+w/4Vv2zkXIssltIYlOkc2Rwar73ELkhoz1iyJCE8+mEvQ6EOG Dabg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692438567; x=1693043367; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Nv7yMt8dX1c1ZS9qclIo4WY6Lz8Ylr5dRKgu2Ds1pu8=; b=D+3dHSj+y6DWXedtmWtATh1mEuP889rS3twWzN7wIkeM8O+kjYFDIlgnzYmQScZWOx 7UXY+kN+PJJ8zNxpJq2xH3aWKtRmasWa/MZHMY0c3I92UEH8Z/7gUna54kfyHk3TtOM0 ZB8qPxCZmqoaSGb6ulE9gefH4qONa1ke8fK/4po9IUJw5BscEWqj60PRQUEDbqOT5fXH A05ckZrkwFojKkkJSex/orBko4apOBcJ1s63QFxXOIr5J86b08WEHqUxXeMRKL7e+eIx VYPSTVGlmjZG+2iJAotTv1qP5JZDLw4GS7nUu6xDxOV/7kjecfcmTixeJKfk4RNJJvso 3LZA== X-Gm-Message-State: AOJu0YzoStZBF8sBxYwZ3SiRnz0lavmqRkIw/FB++EWVRus6F82kTbrH IluzVzhV355ZOQGMaQL3ZMrX9rJIICI= X-Google-Smtp-Source: AGHT+IFCjtGoobcG8JDQrnRyAT/o2IdYM9Py8K+B01t6SVPT7WcCu66ZgbzAJy043fr7aKKIwgIURw== X-Received: by 2002:adf:f184:0:b0:314:1fd7:188b with SMTP id h4-20020adff184000000b003141fd7188bmr1152979wro.17.1692438567283; Sat, 19 Aug 2023 02:49:27 -0700 (PDT) Received: from karim.my.domain ([197.39.34.171]) by smtp.gmail.com with ESMTPSA id o18-20020adfead2000000b003143b14848dsm5617216wrn.102.2023.08.19.02.49.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Aug 2023 02:49:27 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: imp@bsdimp.com, Stacey Son , =?utf-8?q?Mika=C3=ABl_Ura?= =?utf-8?q?nkar?= , Karim Taha Subject: [PATCH 17/22] Implement do_obreak function Date: Sat, 19 Aug 2023 11:48:01 +0200 Message-Id: <20230819094806.14965-18-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230819094806.14965-1-kariem.taha2.7@gmail.com> References: <20230819094806.14965-1-kariem.taha2.7@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42a; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wr1-x42a.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Stacey Son Co-authored-by: Mikaël Urankar Signed-off-by: Mikaël Urankar Signed-off-by: Stacey Son Signed-off-by: Karim Taha --- bsd-user/bsd-mem.h | 85 +++++++++++++++++++++++++++++++++++ bsd-user/freebsd/os-syscall.c | 7 +++ 2 files changed, 92 insertions(+) diff --git a/bsd-user/bsd-mem.h b/bsd-user/bsd-mem.h index edbccd3111..6f33148eb7 100644 --- a/bsd-user/bsd-mem.h +++ b/bsd-user/bsd-mem.h @@ -167,4 +167,89 @@ static inline abi_long do_bsd_mincore(abi_ulong target_addr, abi_ulong len, return ret; } +#ifdef DO_DEBUG +#define DEBUGF_BRK(message, args...) \ + do { fprintf(stderr, (message), ## args); } while (0) +#else +#define DEBUGF_BRK(message, args...) +#endif + +/* do_brk() must return target values and target errnos. */ +static inline abi_long do_obreak(abi_ulong new_brk) +{ + abi_long mapped_addr; + int new_alloc_size; + + DEBUGF_BRK("do_brk(" TARGET_ABI_FMT_lx ") -> ", new_brk); + + if (!new_brk) { + DEBUGF_BRK(TARGET_ABI_FMT_lx " (!new_brk)\n", bsd_target_brk); + return bsd_target_brk; + } + if (new_brk < bsd_target_original_brk) { + DEBUGF_BRK(TARGET_ABI_FMT_lx " (new_brk < bsd_target_original_brk)\n", + bsd_target_brk); + return bsd_target_brk; + } + + /* + * If the new brk is less than the highest page reserved to the target heap + * allocation, set it and we're almost done... + */ + if (new_brk <= brk_page) { + /* + * Heap contents are initialized to zero, as for anonymous mapped pages. + */ + if (new_brk > bsd_target_brk) { + memset(g2h_untagged(bsd_target_brk), 0, new_brk - bsd_target_brk); + } + bsd_target_brk = new_brk; + DEBUGF_BRK(TARGET_ABI_FMT_lx " (new_brk <= brk_page)\n", + bsd_target_brk); + return bsd_target_brk; + } + + /* + * We need to allocate more memory after the brk... Note that we don't use + * MAP_FIXED because that will map over the top of any existing mapping + * (like the one with the host libc or qemu itself); instead we treat + * "mapped but at wrong address" as a failure and unmap again. + */ + new_alloc_size = HOST_PAGE_ALIGN(new_brk - brk_page); + mapped_addr = get_errno(target_mmap(brk_page, new_alloc_size, + PROT_READ | PROT_WRITE, + MAP_ANON | MAP_PRIVATE, -1, 0)); + + if (mapped_addr == brk_page) { + /* + * Heap contents are initialized to zero, as for anonymous mapped pages. + * Technically the new pages are already initialized to zero since they + * *are* anonymous mapped pages, however we have to take care with the + * contents that come from the remaining part of the previous page: it + * may contains garbage data due to a previous heap usage (grown then + * shrunken). + */ + memset(g2h_untagged(bsd_target_brk), 0, brk_page - bsd_target_brk); + + bsd_target_brk = new_brk; + brk_page = HOST_PAGE_ALIGN(bsd_target_brk); + DEBUGF_BRK(TARGET_ABI_FMT_lx " (mapped_addr == brk_page)\n", + bsd_target_brk); + return bsd_target_brk; + } else if (mapped_addr != -1) { + /* + * Mapped but at wrong address, meaning there wasn't actually enough + * space for this brk. + */ + target_munmap(mapped_addr, new_alloc_size); + mapped_addr = -1; + DEBUGF_BRK(TARGET_ABI_FMT_lx " (mapped_addr != -1)\n", bsd_target_brk); + } else { + DEBUGF_BRK(TARGET_ABI_FMT_lx " (otherwise)\n", bsd_target_brk); + } + + /* For everything else, return the previous break. */ + return bsd_target_brk; +} + #endif /* BSD_USER_BSD_MEM_H */ diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index 1db0907504..1b9dca9164 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -543,6 +543,13 @@ static abi_long freebsd_syscall(void *cpu_env, int num, abi_long arg1, break; #endif + /* + * Misc + */ + case TARGET_FREEBSD_NR_break: + ret = do_obreak(arg1); + break; + /* * sys{ctl, arch, call} */ From patchwork Sat Aug 19 09:48:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karim Taha X-Patchwork-Id: 1823273 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=HIgVN+uj; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RSYrF2LjBz1yZd for ; Sat, 19 Aug 2023 19:50:05 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qXIaP-0000XL-Vn; Sat, 19 Aug 2023 05:49:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qXIaO-0000TR-It for qemu-devel@nongnu.org; Sat, 19 Aug 2023 05:49:36 -0400 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qXIaM-0004TM-ET for qemu-devel@nongnu.org; Sat, 19 Aug 2023 05:49:36 -0400 Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-31adc5c899fso1581653f8f.2 for ; Sat, 19 Aug 2023 02:49:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692438573; x=1693043373; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=S6L1tFcBps5w1zt5VqJiuC7jg5RBPQJ0EofpJuqqQ7Q=; b=HIgVN+ujB87pdyUgCvADy/ALvirOe3yHVnhiJBdq2zBLoQIGQ/v2YpmssyaY1U+gr6 i6L59AC3ITOaHYxyPuARCFVjVshwr4EwDj7WAIpdXTS7b77CrefwBxO7sm//ECPUGu+I 5GWBHJN4a3qdb3bwKDdvDz8KSIdb+7vyKrjzE5JkeHV0+ONxrLvIKJkYh+ww5S64X0oi CgZsl4gMdtm4lzpakA7/AtIeHISuaUULBwgABSn/vk9ykbHWZpafcLduqCf+RrkgMBCT O+/xifPrTQVS5+dNvulxVkpH2oMCbVJorH4VcTo3HsqgxT5oKY1G1GHvW9p+CnqoEUDm FgDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692438573; x=1693043373; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=S6L1tFcBps5w1zt5VqJiuC7jg5RBPQJ0EofpJuqqQ7Q=; b=PTHofSMFtWrWCO9fjNi1yi1UgQZZ5p39oHmpg4lbfJpB/lF9spUJVBMmCHMBqUNXIO xZVTCkKC8MPJ6ewNBU6R334J6my3asKuUq/4Dk3e0JPDPJpM1Jl++IEcjWZU2k+5CnfV 1PVai4diJkyVCgqe1l+pJv2Xk5ZoZCpF0PRucf+c1POyqR7IYCoz6+sN4yv24QJLkT4M TxZNRlVyIsDsoUzZJXHt3vYWdTmaJNIHh4AmVALaC/6j1wNciJ3G9D3lS/NHxhIhqBUj +NYNpqWfTMeIM2XuAarjGd59sU/4A9XTQZ7Iyv9Y/14bzTlW8gliGO0K+NAs5VqyvpgY fJiw== X-Gm-Message-State: AOJu0YzTWopvaMKRy5BCoiySUH5jA82mir8rPibooMFQcTZcj37WYNpg Bggd6kp+oZY3zLzr/lEYu9uH+jJxXI4= X-Google-Smtp-Source: AGHT+IERYvLlTEaKUvRexFzMQRNKZZuLVX9DctE8BrTaCMHDugGbkBTUzSQ/hSZt+vCn+qp3O/XCPg== X-Received: by 2002:a5d:6a43:0:b0:317:f7b0:85f with SMTP id t3-20020a5d6a43000000b00317f7b0085fmr1196155wrw.33.1692438572861; Sat, 19 Aug 2023 02:49:32 -0700 (PDT) Received: from karim.my.domain ([197.39.34.171]) by smtp.gmail.com with ESMTPSA id o18-20020adfead2000000b003143b14848dsm5617216wrn.102.2023.08.19.02.49.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Aug 2023 02:49:32 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: imp@bsdimp.com, Stacey Son , Kyle Evans , Karim Taha Subject: [PATCH 18/22] Implement shm_open(2) Date: Sat, 19 Aug 2023 11:48:02 +0200 Message-Id: <20230819094806.14965-19-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230819094806.14965-1-kariem.taha2.7@gmail.com> References: <20230819094806.14965-1-kariem.taha2.7@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::436; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wr1-x436.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Stacey Son Co-authored-by: Kyle Evans Signed-off-by: Stacey Son Signed-off-by: Kyle Evans Signed-off-by: Karim Taha Reviewed-by: Warner Losh --- bsd-user/bsd-mem.h | 27 +++++++++++++++++++++++++++ bsd-user/freebsd/os-syscall.c | 4 ++++ 2 files changed, 31 insertions(+) diff --git a/bsd-user/bsd-mem.h b/bsd-user/bsd-mem.h index 6f33148eb7..013b82f49a 100644 --- a/bsd-user/bsd-mem.h +++ b/bsd-user/bsd-mem.h @@ -252,4 +252,31 @@ static inline abi_long do_obreak(abi_ulong new_brk) return bsd_target_brk; } +/* shm_open(2) */ +static inline abi_long do_bsd_shm_open(abi_ulong arg1, abi_long arg2, + abi_long arg3) +{ + int ret; + void *p; + +#define SHM_PATH(p) ((p) == SHM_ANON ? (p) : path(p)) + if (arg1 == (uintptr_t)SHM_ANON) { + p = SHM_ANON; + } else { + p = lock_user_string(arg1); + if (p == NULL) { + return -TARGET_EFAULT; + } + } + ret = get_errno(shm_open(SHM_PATH(p), + target_to_host_bitmask(arg2, fcntl_flags_tbl), arg3)); + + if (p != SHM_ANON) { + unlock_user(p, arg1, 0); + } + + return ret; +} +#undef SHM_PATH + #endif /* BSD_USER_BSD_MEM_H */ diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index 1b9dca9164..2d15255c20 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -531,6 +531,10 @@ static abi_long freebsd_syscall(void *cpu_env, int num, abi_long arg1, ret = do_bsd_mincore(arg1, arg2, arg3); break; + case TARGET_FREEBSD_NR_freebsd12_shm_open: /* shm_open(2) */ + ret = do_bsd_shm_open(arg1, arg2, arg3); + break; + #if defined(__FreeBSD_version) && __FreeBSD_version >= 1300048 case TARGET_FREEBSD_NR_shm_open2: /* shm_open2(2) */ ret = do_freebsd_shm_open2(arg1, arg2, arg3, arg4, arg5); From patchwork Sat Aug 19 09:48:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karim Taha X-Patchwork-Id: 1823267 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=IYAKsSR5; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RSYqx15hJz1ygW for ; Sat, 19 Aug 2023 19:49:49 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qXIaW-0000sU-PV; Sat, 19 Aug 2023 05:49:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qXIaV-0000h6-E9 for qemu-devel@nongnu.org; Sat, 19 Aug 2023 05:49:43 -0400 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qXIaR-0004UU-R7 for qemu-devel@nongnu.org; Sat, 19 Aug 2023 05:49:42 -0400 Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-31ade53706fso1524293f8f.3 for ; Sat, 19 Aug 2023 02:49:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692438578; x=1693043378; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Ymeuouct4OUpqNX5h4xyNSgJQY9GeX0quaUrsnYgBPg=; b=IYAKsSR57gtDP754c9+91GxabLSoYCx+i7j7juWQO+8JOBSs7l5VxwnAgnJZmEgB8M rEzY9GYB6aIGHKQQ+Dy/ULPKvQmuYE+0UbucGqZtTZHA4d1zMROrjndyfPNS0bzN3Hsb L4f9IKj1RyllFBO+cCVaonTYQFfsuEmB0mKHwcdmLfwp/MqC6UiiKRM6PsHL595yVd6R 5rGEKxTjT9cjXFn4yWIzxO43R04tY7q9xEaOvYOUy65P4aQqAZi2TzElNMj8OWmamiYI UpXjJWyGQhW+wqCUK4HMDvdOjgwkOLCdAQm5ZUOaxjgJNr2vAxCDebkyRq91K+lyuuXe 1S/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692438578; x=1693043378; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Ymeuouct4OUpqNX5h4xyNSgJQY9GeX0quaUrsnYgBPg=; b=WZbkKyH9dVEC/rGo0rgWMtCBoadzE2jtQprbdvmB9N97osCixaw9sXL3fKDlwTm9kL i4RM2ItMGzoIGkTmY+6UX79c0gQ1/FljdjhPcvG1rVaqQgSWieDsxxUrg3v5NEmD5oOx 7Lcc9r2WWIelX0Me8BEmiBkzdY1loxkLSOX5pqIVH76uiHfSTPyyHXmVopl7f9HG3Em8 5JDX5IfIYc5vzeN4zBmy4tneyNSMM8FOpaGSOuY9vJIWfxszE6wnQbEVbF6LIyQi8e1F wj1efVe7ZwZrki3VyV1pI87G1TP85x3z0HBOb2GdxM19JQBn1bHxB3pauxrieKkTijrR +XyA== X-Gm-Message-State: AOJu0YyDs5tdUzPRsCg5goWt7flhkHcpXboPLQ65lPA7ofncTygFOjOw 0dgEw1Jzaq9UZ7m69N9v7lQbZMhcSyE= X-Google-Smtp-Source: AGHT+IFtBTweKmwKrNw2ThYz7l9bKnqK4S+PxnarHvVV4VHFlOCszzURlngy+/QgzoessL4Y3FKMAg== X-Received: by 2002:a5d:6087:0:b0:317:6816:578c with SMTP id w7-20020a5d6087000000b003176816578cmr1154889wrt.5.1692438578104; Sat, 19 Aug 2023 02:49:38 -0700 (PDT) Received: from karim.my.domain ([197.39.34.171]) by smtp.gmail.com with ESMTPSA id o18-20020adfead2000000b003143b14848dsm5617216wrn.102.2023.08.19.02.49.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Aug 2023 02:49:37 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: imp@bsdimp.com, Stacey Son , Karim Taha Subject: [PATCH 19/22] Implement shm_unlink(2) and shmget(2) Date: Sat, 19 Aug 2023 11:48:03 +0200 Message-Id: <20230819094806.14965-20-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230819094806.14965-1-kariem.taha2.7@gmail.com> References: <20230819094806.14965-1-kariem.taha2.7@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::435; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wr1-x435.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Stacey Son Signed-off-by: Stacey Son Signed-off-by: Karim Taha Reviewed-by: Warner Losh Reviewed-by: Richard Henderson Reviewed-by: Richard Henderson --- bsd-user/bsd-mem.h | 23 +++++++++++++++++++++++ bsd-user/freebsd/os-syscall.c | 8 ++++++++ 2 files changed, 31 insertions(+) diff --git a/bsd-user/bsd-mem.h b/bsd-user/bsd-mem.h index 013b82f49a..3d91d3eb30 100644 --- a/bsd-user/bsd-mem.h +++ b/bsd-user/bsd-mem.h @@ -279,4 +279,27 @@ static inline abi_long do_bsd_shm_open(abi_ulong arg1, abi_long arg2, } #undef SHM_PATH +/* shm_unlink(2) */ +static inline abi_long do_bsd_shm_unlink(abi_ulong arg1) +{ + int ret; + void *p; + + p = lock_user_string(arg1); + if (p == NULL) { + return -TARGET_EFAULT; + } + ret = get_errno(shm_unlink(p)); /* XXX path(p)? */ + unlock_user(p, arg1, 0); + + return ret; +} + +/* shmget(2) */ +static inline abi_long do_bsd_shmget(abi_long arg1, abi_ulong arg2, + abi_long arg3) +{ + return get_errno(shmget(arg1, arg2, arg3)); +} + #endif /* BSD_USER_BSD_MEM_H */ diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index 2d15255c20..a7db78b9b4 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -547,6 +547,14 @@ static abi_long freebsd_syscall(void *cpu_env, int num, abi_long arg1, break; #endif + case TARGET_FREEBSD_NR_shm_unlink: /* shm_unlink(2) */ + ret = do_bsd_shm_unlink(arg1); + break; + + case TARGET_FREEBSD_NR_shmget: /* shmget(2) */ + ret = do_bsd_shmget(arg1, arg2, arg3); + break; + /* * Misc */ From patchwork Sat Aug 19 09:48:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karim Taha X-Patchwork-Id: 1823272 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=COXuRg2J; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RSYr66YKWz1yfn for ; Sat, 19 Aug 2023 19:49:58 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qXIaa-0001R6-Lv; Sat, 19 Aug 2023 05:49:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qXIaY-00017i-Fr for qemu-devel@nongnu.org; Sat, 19 Aug 2023 05:49:46 -0400 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qXIaW-0004V4-8C for qemu-devel@nongnu.org; Sat, 19 Aug 2023 05:49:46 -0400 Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-31771bb4869so1527174f8f.0 for ; Sat, 19 Aug 2023 02:49:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692438583; x=1693043383; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8exV3yGEz7WY1shJuX9lY3GrexPeAxEd4BeLNUOtn40=; b=COXuRg2J/O0vzsu4Z02XurXcnBGPID3XEw1524yyMPAWNZ/I1HBOPZ+TVHZc3phsb8 +LRzxIwHIY7UIXYHp/wXx4/RER7yMqR+SPTBbwb77HqgSzpWa2SLatjWhscAD/no7+IX wKw8oZ1TbgYQiDkbqkWxlNGdZrNLDfjNSKLzA42cRZjVSHw3Yf/k6NiottHKeRqmmWrg oN8ab+8dca1VJjXUVFIu5kOiL1P5+p0BUnujG8Jx3YW2jtTFoUmr1gTeP0ifec7Dmcj3 L3Icf2I7+xXrnL7qyce5F/a19ZIsCll1OFnmU114G6VXY1v6vYh5JkJ1F366qTbZV2ED 62IQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692438583; x=1693043383; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8exV3yGEz7WY1shJuX9lY3GrexPeAxEd4BeLNUOtn40=; b=IhLfDmidEI1lqyZVotVuBS+aVPsk45IdJ2xhclZ+9lLcOt6DiH++W6OIPnlj7b0OuE OEV2iI5Hu3MSUx+Mnt4SiiVlTkc/2xwFYne8P5ZH3XLrmyAKxXjAK0Lv0TaXwaD3jnlY /hsjvhs0QfP+7ep7WEffjjK/mfmuwo07rG9ENNvpbcpuUOPzqyivjEGFNimldV0IbJA0 J8yJNqTxNtQrzsuIiGVzwPKTzrRwNRYy95fqZdOTte2s1ZzokZ3AuMIJeDW6j1yYg0Yk 2KUL69pF+KXBnVwiGI1TKj/seElyQ25LhpORshDpdwPjPya9h1fEv+lbTaB21KASdxkl IGbQ== X-Gm-Message-State: AOJu0YyE+Vjs34HMzWt8ssQZu5ueBUvzeqR+v+AyXT/iVQkvSx0DiBLd PGROe0dHcPKj00a/PCVXAJ1BFRRBuZs= X-Google-Smtp-Source: AGHT+IFboCsi42EbFDMZvtnrwzMzMMTEY3JU9GoaF1K2rz11RnVWzDQMY0vguvA+wnLtqsB+RyTbgA== X-Received: by 2002:a05:6000:889:b0:31a:d6cb:7f9e with SMTP id cs9-20020a056000088900b0031ad6cb7f9emr1178952wrb.21.1692438582670; Sat, 19 Aug 2023 02:49:42 -0700 (PDT) Received: from karim.my.domain ([197.39.34.171]) by smtp.gmail.com with ESMTPSA id o18-20020adfead2000000b003143b14848dsm5617216wrn.102.2023.08.19.02.49.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Aug 2023 02:49:42 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: imp@bsdimp.com, Stacey Son , Karim Taha Subject: [PATCH 20/22] Implement shmctl(2) Date: Sat, 19 Aug 2023 11:48:04 +0200 Message-Id: <20230819094806.14965-21-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230819094806.14965-1-kariem.taha2.7@gmail.com> References: <20230819094806.14965-1-kariem.taha2.7@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::433; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wr1-x433.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Stacey Son Signed-off-by: Stacey Son Signed-off-by: Karim Taha Reviewed-by: Warner Losh --- bsd-user/bsd-mem.h | 33 +++++++++++++++++++++++++++++++++ bsd-user/freebsd/os-syscall.c | 4 ++++ 2 files changed, 37 insertions(+) diff --git a/bsd-user/bsd-mem.h b/bsd-user/bsd-mem.h index 3d91d3eb30..221ad76d8c 100644 --- a/bsd-user/bsd-mem.h +++ b/bsd-user/bsd-mem.h @@ -302,4 +302,37 @@ static inline abi_long do_bsd_shmget(abi_long arg1, abi_ulong arg2, return get_errno(shmget(arg1, arg2, arg3)); } +/* shmctl(2) */ +static inline abi_long do_bsd_shmctl(abi_long shmid, abi_long cmd, + abi_ulong buff) +{ + struct shmid_ds dsarg; + abi_long ret = -TARGET_EINVAL; + + cmd &= 0xff; + + switch (cmd) { + case IPC_STAT: + case IPC_SET: + if (target_to_host_shmid_ds(&dsarg, buff)) { + return -TARGET_EFAULT; + } + ret = get_errno(shmctl(shmid, cmd, &dsarg)); + if (host_to_target_shmid_ds(buff, &dsarg)) { + return -TARGET_EFAULT; + } + break; + + case IPC_RMID: + ret = get_errno(shmctl(shmid, cmd, NULL)); + break; + + default: + ret = -TARGET_EINVAL; + break; + } + + return ret; +} + #endif /* BSD_USER_BSD_MEM_H */ diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index a7db78b9b4..9681c65ce9 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -555,6 +555,10 @@ static abi_long freebsd_syscall(void *cpu_env, int num, abi_long arg1, ret = do_bsd_shmget(arg1, arg2, arg3); break; + case TARGET_FREEBSD_NR_shmctl: /* shmctl(2) */ + ret = do_bsd_shmctl(arg1, arg2, arg3); + break; + /* * Misc */ From patchwork Sat Aug 19 09:48:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karim Taha X-Patchwork-Id: 1823278 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=rUl9bcXM; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RSYrb1rvRz1yfT for ; Sat, 19 Aug 2023 19:50:23 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qXIad-0001nX-Oq; Sat, 19 Aug 2023 05:49:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qXIac-0001iD-3D for qemu-devel@nongnu.org; Sat, 19 Aug 2023 05:49:50 -0400 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qXIaZ-0004Vn-QF for qemu-devel@nongnu.org; Sat, 19 Aug 2023 05:49:49 -0400 Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-31781e15a0cso1510130f8f.3 for ; Sat, 19 Aug 2023 02:49:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692438586; x=1693043386; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=c81n0IuPWBObuKho74EdgZfgQ3nDUAJ4UIi37AKURKc=; b=rUl9bcXMWFoXJsW3TjwlV9KVakgFyZ8xwGTlRuKt6Cwc3iFcdX9FhLNJAMKqQrAumA pTyhdZ1P/jg9Ge03KRQeTQW7lIRU19L6sSxnWdHsqX0Qr7vyJ+sAKIMuNJdmErwpNv8H 6T8T6bvp5krIPcpdd0ZOqKPDc/O+3UiZx7jxuw0EiscuCjk4vd/OCnHrPFpQw1a4xAsi eM7u8S078+PWmKWT/a+4XygOIGSq7ypL5GTDmzKeNPzPAyYjF/tkx+r6fD40NUZpFVSc 8yO8E4OcK4RTnKeprSa7ipD3JUevx1OCwthlh6V1G068zRbgi1u7ylCmMEC9tA2APT8Q cbpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692438586; x=1693043386; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=c81n0IuPWBObuKho74EdgZfgQ3nDUAJ4UIi37AKURKc=; b=MF9RBPIAhbMX32lpQU+P10VPFTQDlUQir1+SYC82f5x28IcO/6A3oPcGtfNFwyZj4b cClnH7gFFEUn79pS+WL8xCps51zSMWwPMc7zo5K2hAQZfYWOI2vZyh/TiNSXztIqleRk S8LQwfcqU3zF2Y4hg+Ref36OV7vrnlnJF19dac/1ok5LQjIRspMexZ+KvEDrYBXNgUnp UDPXL21SkP7lirJLBtDQ41qdyYmXUWt6A5lkfV0EtPifUgEdizb22Hy7p4gE4Rx5+KL0 9gS6jUbCvnKeULCV4Q7C5B/vyYe4n7jkgLm2Cr4iR0YUruJpMg8JUI0x0AtVB1oyCVC1 OJxg== X-Gm-Message-State: AOJu0Yyc3WJt8EEAU83iUSUPVAW4ROmAQ1uRrBwUzzG0HRJ+B2iYaWQd SCFDcdwS6wPUleUOg/w/wbZc7xP37/Q= X-Google-Smtp-Source: AGHT+IHJ4NsPVPWpo1tsCP90BMHOCCasqcUc26h0Ln9J4x2CIPe5BkrnkXcloN3JSZwV6UcZdHixAA== X-Received: by 2002:adf:a345:0:b0:318:1535:34fb with SMTP id d5-20020adfa345000000b00318153534fbmr1215984wrb.13.1692438586253; Sat, 19 Aug 2023 02:49:46 -0700 (PDT) Received: from karim.my.domain ([197.39.34.171]) by smtp.gmail.com with ESMTPSA id o18-20020adfead2000000b003143b14848dsm5617216wrn.102.2023.08.19.02.49.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Aug 2023 02:49:45 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: imp@bsdimp.com, Stacey Son , Karim Taha Subject: [PATCH 21/22] Implement shmat(2) and shmdt(2) Date: Sat, 19 Aug 2023 11:48:05 +0200 Message-Id: <20230819094806.14965-22-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230819094806.14965-1-kariem.taha2.7@gmail.com> References: <20230819094806.14965-1-kariem.taha2.7@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::436; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wr1-x436.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Stacey Son Signed-off-by: Stacey Son Signed-off-by: Karim Taha --- bsd-user/bsd-mem.h | 72 +++++++++++++++++++++++++++++++++++ bsd-user/freebsd/os-syscall.c | 8 ++++ 2 files changed, 80 insertions(+) diff --git a/bsd-user/bsd-mem.h b/bsd-user/bsd-mem.h index 221ad76d8c..f737b94885 100644 --- a/bsd-user/bsd-mem.h +++ b/bsd-user/bsd-mem.h @@ -335,4 +335,76 @@ static inline abi_long do_bsd_shmctl(abi_long shmid, abi_long cmd, return ret; } +/* shmat(2) */ +static inline abi_long do_bsd_shmat(int shmid, abi_ulong shmaddr, int shmflg) +{ + abi_ulong raddr; + abi_long ret; + void *host_raddr; + struct shmid_ds shm_info; + int i; + + /* Find out the length of the shared memory segment. */ + ret = get_errno(shmctl(shmid, IPC_STAT, &shm_info)); + if (is_error(ret)) { + /* Can't get the length */ + return ret; + } + + mmap_lock(); + + if (shmaddr) { + host_raddr = shmat(shmid, (void *)g2h_untagged(shmaddr), shmflg); + } else { + abi_ulong mmap_start; + + mmap_start = mmap_find_vma(0, shm_info.shm_segsz); + + if (mmap_start == -1) { + errno = ENOMEM; + host_raddr = (void *)-1; + } else { + host_raddr = shmat(shmid, g2h_untagged(mmap_start), + shmflg); /* | SHM_REMAP XXX WHY? */ + } + } + + if (host_raddr == (void *)-1) { + mmap_unlock(); + return get_errno((long)host_raddr); + } + raddr = h2g((unsigned long)host_raddr); + + page_set_flags(raddr, raddr + shm_info.shm_segsz, + PAGE_VALID | PAGE_READ | ((shmflg & SHM_RDONLY) ? 0 : PAGE_WRITE)); + + for (i = 0; i < N_BSD_SHM_REGIONS; i++) { + if (bsd_shm_regions[i].start == 0) { + bsd_shm_regions[i].start = raddr; + bsd_shm_regions[i].size = shm_info.shm_segsz; + break; + } + } + + mmap_unlock(); + return raddr; +} + +/* shmdt(2) */ +static inline abi_long do_bsd_shmdt(abi_ulong shmaddr) +{ + int i; + + for (i = 0; i < N_BSD_SHM_REGIONS; ++i) { + if (bsd_shm_regions[i].start == shmaddr) { + bsd_shm_regions[i].start = 0; + page_set_flags(shmaddr, + shmaddr + bsd_shm_regions[i].size, 0); + break; + } + } + + return get_errno(shmdt(g2h_untagged(shmaddr))); +} + #endif /* BSD_USER_BSD_MEM_H */ diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index 9681c65ce9..f76bc1eb38 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -559,6 +559,14 @@ static abi_long freebsd_syscall(void *cpu_env, int num, abi_long arg1, ret = do_bsd_shmctl(arg1, arg2, arg3); break; + case TARGET_FREEBSD_NR_shmat: /* shmat(2) */ + ret = do_bsd_shmat(arg1, arg2, arg3); + break; + + case TARGET_FREEBSD_NR_shmdt: /* shmdt(2) */ + ret = do_bsd_shmdt(arg1); + break; + /* * Misc */ From patchwork Sat Aug 19 09:48:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karim Taha X-Patchwork-Id: 1823284 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=eB9rYnXK; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RSYsR1fbDz1ygW for ; Sat, 19 Aug 2023 19:51:07 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qXIag-0001zG-Kw; Sat, 19 Aug 2023 05:49:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qXIaf-0001vV-Lc for qemu-devel@nongnu.org; Sat, 19 Aug 2023 05:49:53 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qXIad-0004Wk-Fk for qemu-devel@nongnu.org; Sat, 19 Aug 2023 05:49:53 -0400 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-3fe32016bc8so15932025e9.1 for ; Sat, 19 Aug 2023 02:49:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692438590; x=1693043390; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=rMb0rESt2U29a5WFBc2T+2BXqQBr9UBe6ZX/BkuOLjo=; b=eB9rYnXKHWzAwpyY+QlczWG0jD4efOMY2NFbVl4r1qrWUBai4+1xKwUeOlPqquN9nV jeioLeNDR3GOxTFBAR710KlcsyWJb/EIOl2n534Bc7oJu+s9BGle5clp6ZmVVco+zJWb Gfs6H89wzD+olAdIuapsV9mydg/uV5hrMBh9vEK7D+lrF4U8N4OQyw8kSiUjWeDErmWz LYCyRK5YLAB+CUGRzsjroD60K8ar5ma4MG0jwPL74wmKiOjFjZMAsUIDoomFniVA+lxT lgLfRkqOfrXL7lvOJ9D6xQoYDjV2i7ZydPaUw4hVJSjbVBYxNl1ypMjKGQMKQuelvYks y5hA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692438590; x=1693043390; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rMb0rESt2U29a5WFBc2T+2BXqQBr9UBe6ZX/BkuOLjo=; b=hfzFUeT9aO+t3SyPfPmgi4STLe+RezSDlY1xJhyu3Y7tAvMgsSRMWx0qNIL3DLF/CK /BGI0+7nmUqNK3z2auX/A8sFNgoy4qIukEIIdqSeOvpg/9WVZh4+Nm14CwNPPdYaoQZh 05/C/ipHOQtFmDoswGNrR4KBg8TcKoDgVSVJStp7sqSsbWX7D6f2z2x+bNPsLxFZE+lj sbgVB2Dj0l7oFUSQyGdE0Yv2yH6art0y+BSce9kW0G2locEgu0Z+iman+nvKCurBDkXe A5Qto9Qi6EU6MeiGkOGBKib7VsLDrXyRMIgQfZPHqWxa0yp3Xp4nPacrrnv2aR0uB+1E wCfg== X-Gm-Message-State: AOJu0Yxumi79UD4z7CYSq8B9U8XvWUU+wT6KH04RV/jwTdOLNBz95u6u vqi0KoiK6uYc9jzHc/Z4cZXZIOAA2rY= X-Google-Smtp-Source: AGHT+IHPaqtP2Lnvp8PdFBXTA/NHw5BxsjTH7anU8/5AVDyuMG1xRgs7uPT3bdK2BV8pLBobGgLalQ== X-Received: by 2002:a5d:4c4a:0:b0:319:7aa5:b880 with SMTP id n10-20020a5d4c4a000000b003197aa5b880mr1059482wrt.48.1692438589993; Sat, 19 Aug 2023 02:49:49 -0700 (PDT) Received: from karim.my.domain ([197.39.34.171]) by smtp.gmail.com with ESMTPSA id o18-20020adfead2000000b003143b14848dsm5617216wrn.102.2023.08.19.02.49.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Aug 2023 02:49:49 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: imp@bsdimp.com, Stacey Son , Karim Taha Subject: [PATCH 22/22] Add stubs for vadvise(), sbrk() and sstk() Date: Sat, 19 Aug 2023 11:48:06 +0200 Message-Id: <20230819094806.14965-23-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230819094806.14965-1-kariem.taha2.7@gmail.com> References: <20230819094806.14965-1-kariem.taha2.7@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wm1-x32e.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Stacey Son The above system calls are not supported by qemu. Signed-off-by: Stacey Son Signed-off-by: Karim Taha Reviewed-by: Warner Losh --- bsd-user/bsd-mem.h | 21 +++++++++++++++++++++ bsd-user/freebsd/os-syscall.c | 12 ++++++++++++ 2 files changed, 33 insertions(+) diff --git a/bsd-user/bsd-mem.h b/bsd-user/bsd-mem.h index f737b94885..274178bef7 100644 --- a/bsd-user/bsd-mem.h +++ b/bsd-user/bsd-mem.h @@ -407,4 +407,25 @@ static inline abi_long do_bsd_shmdt(abi_ulong shmaddr) return get_errno(shmdt(g2h_untagged(shmaddr))); } +static inline abi_long do_bsd_vadvise(void) +{ + /* See sys_ovadvise() in vm_unix.c */ + qemu_log("qemu: Unsupported syscall vadvise()\n"); + return -TARGET_ENOSYS; +} + +static inline abi_long do_bsd_sbrk(void) +{ + /* see sys_sbrk() in vm_mmap.c */ + qemu_log("qemu: Unsupported syscall sbrk()\n"); + return -TARGET_ENOSYS; +} + +static inline abi_long do_bsd_sstk(void) +{ + /* see sys_sstk() in vm_mmap.c */ + qemu_log("qemu: Unsupported syscall sstk()\n"); + return -TARGET_ENOSYS; +} + #endif /* BSD_USER_BSD_MEM_H */ diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index f76bc1eb38..cf4b894fee 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -567,6 +567,18 @@ static abi_long freebsd_syscall(void *cpu_env, int num, abi_long arg1, ret = do_bsd_shmdt(arg1); break; + case TARGET_FREEBSD_NR_freebsd11_vadvise: + ret = do_bsd_vadvise(); + break; + + case TARGET_FREEBSD_NR_sbrk: + ret = do_bsd_sbrk(); + break; + + case TARGET_FREEBSD_NR_sstk: + ret = do_bsd_sstk(); + break; + /* * Misc */