From nobody Thu Nov 28 07:47:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1694234079; cv=none; d=zohomail.com; s=zohoarc; b=Ozv0sCEZOGF4l8d5ZC5UniTPAGSbd/byoRiveVT+PklZmpPEzzpEUFGsR6hbMv3WckUUlUyZ/VNmORPVA0xvLss7mwo+Q2EyVprqcY0btxpQ0JCcLRpOGYkBH4/ztlMct2o7lrIG2sPwW0gXFSi7U3UvvlutHHVK55J3g2wswF4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694234079; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=wJTRK8Tm4oCBWcEts58SyC6/NTwYSAeOzRKwQE1l8qs=; b=llgqVns612p2KebQw6rBcfnj28whwpNcDKKSOaWz6W5JEnRNC2OjCF0yYGlxVfW9vZF3NUMytdxxNAIseFBGiKnpaBSyWNz8XtMWLSTiDC4D+41qxSKF0XMwwWrezd4VgsJbUn0AGnEO3DnbPWWssizYogNZrVdJTJIpc3Z2OSY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16942340797011005.4445137813461; Fri, 8 Sep 2023 21:34:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qepfB-0000y2-Vo; Sat, 09 Sep 2023 00:33:42 -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 1qepf9-0000xP-Gx for qemu-devel@nongnu.org; Sat, 09 Sep 2023 00:33:39 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qepf7-0002v9-Ar for qemu-devel@nongnu.org; Sat, 09 Sep 2023 00:33:39 -0400 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-401d2e11dacso24610105e9.0 for ; Fri, 08 Sep 2023 21:33:36 -0700 (PDT) Received: from karim.my.domain ([197.39.120.250]) by smtp.gmail.com with ESMTPSA id d16-20020adff2d0000000b0031981c500aasm3615102wrp.25.2023.09.08.21.33.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Sep 2023 21:33:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694234015; x=1694838815; darn=nongnu.org; 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=wJTRK8Tm4oCBWcEts58SyC6/NTwYSAeOzRKwQE1l8qs=; b=GKkKDcIsYzOUR4w8nnRN+waNbJ4+wy55gvzWfJyf0mwAA55TKrbPKb2kP+3lPIvQwr Y60pTneZ/+1l948eWE34h15qhlBTS9l4A7GRWd1fs1vh8ZZ4U5PpNecE6nNJNwu1eJNt ph0d4YF+NwIzlIwyfoFph253nOpkgOR5WNDdnB+MMOBmQKWDpDV7glFXaha00/b4nemB roW7tVeUEkv/q32ignYuzEQ88aI+oXfZaUndcxWfP+TpYbjdXhO+/4s8yGK0p5McudZ4 Z41Rnu3D3sz+2WqA8aG/rJGux7+OAmvimQOmqhKA4ZaP+2HZdgF37K2GVlapOSo8cGBg o9KQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694234015; x=1694838815; 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=wJTRK8Tm4oCBWcEts58SyC6/NTwYSAeOzRKwQE1l8qs=; b=Ox3ecU85ykdJis/9NMlOTQmfxw4X8qnBEUXb6gjxiTIZhBgQGqFsb9+H30sRQVlQmK MNJPkKh+KFSPx7n+mq4SnrVGJUj7udV6IzdjaRENwY6oYLO9Jd7vKn9uspPWLyr4R8n+ hVcDZZIpUwYkuLKSEj/UaAqnx+CYkLRANddAOlTajpt462KI0tsR5J2Sz317q6hH0BTJ /EF+mxXsL9XCoesYzpaKjg9Jsg10/d0JtBAu7rM/P3Gm0bQTFKPCipRKRiHfaRb2MXSh VBtNsW82paNVZmqVZxjX2aJJ98adhnrkeoMmaogF1RuxF6QEfRVVm1X2KRTA/J5PkPWk JiuA== X-Gm-Message-State: AOJu0YwY9LjG+Va0BG5aTu47dEzbD4wMIXuj7T0guVidgO1XJP6Kecbt y+XgV/9Avgmuo6aJzRmS6lktgA81d1s= X-Google-Smtp-Source: AGHT+IEZfLO4se87DVRkbAjQuAQtuMSHgJwMznfdsQthsu5cDNUOP9oPIrmLgpbjdAyjHy22ZNCklQ== X-Received: by 2002:a05:600c:20d1:b0:3ff:516b:5c4c with SMTP id y17-20020a05600c20d100b003ff516b5c4cmr2695993wmm.18.1694234015025; Fri, 08 Sep 2023 21:33:35 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: imp@bsdimp.com, Stacey Son , Karim Taha , Richard Henderson Subject: [PATCH v2 01/23] bsd-user: Implement struct target_ipc_perm Date: Thu, 7 Sep 2023 09:42:40 +0200 Message-ID: <20230907074302.79234-2-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230907074302.79234-1-kariem.taha2.7@gmail.com> References: <20230907074302.79234-1-kariem.taha2.7@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wm1-x329.google.com X-Spam_score_int: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_24_48=1.34, 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=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1694234081859100013 Content-Type: text/plain; charset="utf-8" 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 */ }; =20 +/* + * 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 */ --=20 2.42.0 From nobody Thu Nov 28 07:47:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1694234079; cv=none; d=zohomail.com; s=zohoarc; b=HjYdTjesuljuRdsoHVytjvIJ3oLu/LEG3Ebqgod41lagzJ4XNk51r0L1doLFHdgzcQRJLjiEc4xivHeuWPqwY0ZtRTlWv2D06Mb7MdBFvC5aATo8Oi7S9VobCyuo2XfYzF5MmKSd7/zq23sjdSmNROLAyRXeb4YDdMzsxyoYGTQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694234079; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Q9qFiAhNG5T837+Dzxw5csScnLVFwBaQ3hHHc6XeSf8=; b=XsAiAFrISwK1MZ90EvMYS51Zls8wnnaMC2+9ucGzHaOZGf6xm79NuV26lMpejOrckzUyKPhhsMNx6qyuJQWpI5JMz3EztM6AvYUIX2JOeSN/EPg8/d0tCwV7HRgqDQithoo2GigOsfBHAOQ8xc425DuuXx+AzM5dWzzZJcyVpwU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694234079735323.6736896151683; Fri, 8 Sep 2023 21:34:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qepfB-0000xx-Of; Sat, 09 Sep 2023 00:33:41 -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 1qepfA-0000xo-AD for qemu-devel@nongnu.org; Sat, 09 Sep 2023 00:33:40 -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 1qepf8-0002vE-5x for qemu-devel@nongnu.org; Sat, 09 Sep 2023 00:33:40 -0400 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-401c90ed2ecso28586105e9.0 for ; Fri, 08 Sep 2023 21:33:37 -0700 (PDT) Received: from karim.my.domain ([197.39.120.250]) by smtp.gmail.com with ESMTPSA id d16-20020adff2d0000000b0031981c500aasm3615102wrp.25.2023.09.08.21.33.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Sep 2023 21:33:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694234016; x=1694838816; darn=nongnu.org; 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=Q9qFiAhNG5T837+Dzxw5csScnLVFwBaQ3hHHc6XeSf8=; b=dq/yS08X5e349MN5hsOeli1L7RTR8HPpOY5HKT/zmXP/4lVAgvU1Df73lv2IMMmuPi 8l18dw0rRyRzYPi+BudtqKz0Xwd6z5uPf9Tge7NAZh543XpOYww2GvlKpkBaPt1aPF6g TqWK1F8WakMY04p1Lwnvhq8K0Rx3o9G8uoWXjAm0vHgTfCY9QSG07xYkRtyWbwvnAC5D yNR6tydiT6T4hp554ss2hj8zTROlITz49odm1BRKIXvMPKnW5x3tIal2STK9+zeS69Gs zcmWEl9NGAkovcK08SLKsgbvgfMnrt3v+jgk0HCVzz1LHX9MmxYzEZSXfqpKiCeTST/O LKoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694234016; x=1694838816; 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=Q9qFiAhNG5T837+Dzxw5csScnLVFwBaQ3hHHc6XeSf8=; b=VHc4yXgI4lJgxvEqApsMCaITO4G1OmV0m84nEEPMzsRibk2Ughq1Z29+MpIiDAHshH 9JEaW5AyAEedSNXoCHFyqlpteHZ1Lz0yyW5rjP2xZGef3fMS/0mKozo1g6G506Zf5ydN 4nIyl1iaVaG3fwu9rwjnaV1A4Zm9MNPCHZ3+ELmsjL9Yb55WlDu2IKiKyZ4UqeQWfgQq uMTKEraMy7WpBS3uL9pFRFRS8I6BwSvnC+q86mLSFOxWtlMKakaQm8/4lLY5bTk2+KeP N3jwTGmuEC5uP+s2aIiD8neq6x3spRcfJdXi7ERCtxSMTdRF/DPmZ/Tp2fXikj6QefhK Yn9w== X-Gm-Message-State: AOJu0YziImyZC3PTwCGyDpIMGf/8+uNYPpez76H9kFsD2j3uuBf/pzkQ 61GBhCO3IBg8Ddgb1R4rQua0o/NDxqU= X-Google-Smtp-Source: AGHT+IF0/+N4gnyk0kcx+RDWoHTr+2LVVAOdJs1zEnyVqn6rX3K9Zcz3V/sE5wig4b2nu/Xt3QcnYg== X-Received: by 2002:a1c:6a14:0:b0:401:b908:85a2 with SMTP id f20-20020a1c6a14000000b00401b90885a2mr3357112wmc.23.1694234016238; Fri, 08 Sep 2023 21:33:36 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: imp@bsdimp.com, Stacey Son , Karim Taha , Richard Henderson Subject: [PATCH v2 02/23] bsd-user: Implement struct target_shmid_ds Date: Thu, 7 Sep 2023 09:42:41 +0200 Message-ID: <20230907074302.79234-3-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230907074302.79234-1-kariem.taha2.7@gmail.com> References: <20230907074302.79234-1-kariem.taha2.7@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: 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: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_24_48=1.34, 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=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1694234081898100015 Content-Type: text/plain; charset="utf-8" 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 */ =20 +/* + * 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 */ --=20 2.42.0 From nobody Thu Nov 28 07:47:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1694234219; cv=none; d=zohomail.com; s=zohoarc; b=VrPdZjBdCTFqs3U/cOctg+RGGypI1y06W8JSCAjUa+0ylPfFT1fyX49/N9fW+YUcJH8MFjSeXJ3FWauAJ8yvpTKv5YPx7ZAj5eHalstiMaU1AsINCZ+ocYQCGjlRDZaAxL2HYtUrfHhxjiqZk2AbKbuDyZvA59kKi2hsh4jvHi8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694234219; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Gc/mLGUX7ZmbD3sQ6kC2qyMy//ogtwOmV0rb8Xd2gcE=; b=HpNMjNM9kEXX2+ByjU/s16ys19AGseD9gsgajYNF+OW+d1Qmbrfsn9UTUtft3ckoxWY0cPOXMmfhmrCQf/GN/wvRJZCPFSrZIJR8vx1RmWgO7XpztO908Bol5y/j2FCX3FRyv7/Ylmyk/mDGSFUp6MKRTvtMoJ09rT00Fxh9o88= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694234219982484.6398425064924; Fri, 8 Sep 2023 21:36:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qepfC-0000yb-O6; Sat, 09 Sep 2023 00:33:42 -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 1qepfB-0000xy-QR for qemu-devel@nongnu.org; Sat, 09 Sep 2023 00:33:41 -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 1qepf9-0002vP-DH for qemu-devel@nongnu.org; Sat, 09 Sep 2023 00:33:41 -0400 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-3ff1c397405so31491115e9.3 for ; Fri, 08 Sep 2023 21:33:39 -0700 (PDT) Received: from karim.my.domain ([197.39.120.250]) by smtp.gmail.com with ESMTPSA id d16-20020adff2d0000000b0031981c500aasm3615102wrp.25.2023.09.08.21.33.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Sep 2023 21:33:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694234017; x=1694838817; darn=nongnu.org; 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=Gc/mLGUX7ZmbD3sQ6kC2qyMy//ogtwOmV0rb8Xd2gcE=; b=dfr8uBS0CDAuiqE/JRzDUZeP0lJLmz0QgMSFuA+c2KvjxKFAunRNsj0zzOnnSJ694+ bC1KaHw1qWS3+lejUa7jNRg6YgolvpPLFdPMDJ6zzfZRoja27Hr01op5T1mSekiLz4d4 P7dVpM22a6Qjl1+AxBgFigutMKVV4HjC1n+t7vb74tAGYTrB2qBhyW43s8fT2LIsqc+Z CljJHHLtuBHDCqevDlFEPsBYHwAK7Z6UtP+670TA4zkcf99nPDn8JhxVieZySp7TzIJg +CSJjtPJFwlrJ+MRU7Tl58iTjqI+FlJ2G6ab3BSiO6T7cFTlV1jOKMs/uwemW+XIITSA QvmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694234017; x=1694838817; 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=Gc/mLGUX7ZmbD3sQ6kC2qyMy//ogtwOmV0rb8Xd2gcE=; b=Pf/6m/pfnRdIk+okxbEz3CWOJHL/aMUj8LRKnV5VdDB8nBIErlbOjl6P3NK2HAyk32 Te5HwEzFIwAPcJ1Ms4YxxIdbnw8bkZIwYygTp0/AJ8LS/OuECJ9LLUaxvAYiWkTE9PiP Rvkkaf1+I/avmRBlbm+OjyiokEz+kUHOQExMSSWjsezlnfNBdXkJPQVlXR+FLsAOPzyb 0VgrNxabvFDoGBj04SG+lUijScHQrSx6ul/6POPJX0/wcNnGaTh0T5jbemG8lERuLpr2 /Or5ffhrIoKkNHXd6lAo0oggF77TfjMf2TPyDuY8Jt6CLwSARF/4zOL0nHj3WEx3wncg wKvQ== X-Gm-Message-State: AOJu0YxUogDK6rh2URPYijSm2ZshuBG88geaWB0zwx2CaL9G2dKzU3uy 7TxuW2OCJw7gGEpSMx/Bb0iyF0vIYN8= X-Google-Smtp-Source: AGHT+IF37nG4gP9CY5YyxTcLFTZkhBSxdfyCb5p6/0IJUipqLwvx/0IdlY9VyFyOD2nR0bm99mG6gA== X-Received: by 2002:a05:600c:2901:b0:3fc:dd9:91fd with SMTP id i1-20020a05600c290100b003fc0dd991fdmr3375451wmd.40.1694234017384; Fri, 08 Sep 2023 21:33:37 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: imp@bsdimp.com, Stacey Son , Karim Taha , Richard Henderson Subject: [PATCH v2 03/23] bsd-user: Declarations for ipc_perm and shmid_ds conversion functions Date: Thu, 7 Sep 2023 09:42:42 +0200 Message-ID: <20230907074302.79234-4-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230907074302.79234-1-kariem.taha2.7@gmail.com> References: <20230907074302.79234-1-kariem.taha2.7@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: 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: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_24_48=1.34, 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=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1694234222095100003 Content-Type: text/plain; charset="utf-8" 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..46572ece7d --- /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 */ +void target_to_host_ipc_perm__locked(struct ipc_perm *host_ip, + struct target_ipc_perm *target_ip); +void host_to_target_ipc_perm__locked(struct target_ipc_perm *target_ip, + 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 */ --=20 2.42.0 From nobody Thu Nov 28 07:47:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1694234079; cv=none; d=zohomail.com; s=zohoarc; b=Zk/ICLDLVSp5IhIugG3A5CmMJl3DOAe1U5cDJQEgLkJlgRRbx/TRWqjxNzH8OUb9LsdzhgbZfeOOATppQcXQXYwloSMRCEQblWKEPbQwfcnQUmq3Rzww1toephnJPZMQq78G4Rt9+wJ9A/3tkzy5hP8wENqSN7iMkaC8U9dzrtM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694234079; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=cGJohYqrlAeBGqv33iEu2l+2oxUpjbZfEtEhLbQOaQw=; b=mKacJm9N+iPe5RE5/bwbzFFjUyoBaPhLMhTCMxoUtlitSMQ31v6Q6oMaVfjWV3TiOwq5iMYcAtQnumjesJN8HpdUOfA7aG1YOpL37YW3/B40PfZkj4Tng+AFVxVVKRxGj5IDSLCCVXD5HA5oFriIHZX1UVV8Ak4YWGoqPPYR+IY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694234079848556.2616444898642; Fri, 8 Sep 2023 21:34:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qepfE-0000zI-UM; Sat, 09 Sep 2023 00:33:45 -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 1qepfC-0000yc-V3 for qemu-devel@nongnu.org; Sat, 09 Sep 2023 00:33:42 -0400 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qepfA-0002vX-I8 for qemu-devel@nongnu.org; Sat, 09 Sep 2023 00:33:42 -0400 Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-31f615afa52so2778734f8f.3 for ; Fri, 08 Sep 2023 21:33:40 -0700 (PDT) Received: from karim.my.domain ([197.39.120.250]) by smtp.gmail.com with ESMTPSA id d16-20020adff2d0000000b0031981c500aasm3615102wrp.25.2023.09.08.21.33.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Sep 2023 21:33:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694234019; x=1694838819; darn=nongnu.org; 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=cGJohYqrlAeBGqv33iEu2l+2oxUpjbZfEtEhLbQOaQw=; b=RAJMIHfSasOBXvJCIg1nJ+yxEAEPD6v1thNO87A3w4sNf9iJUVO5wPBg3vKg5tYm5U XLY0JB4YkZucX+JXK/eO4Kct2+KJ15rFFRSMd+cUNMbhQ0kP8UsvXIOwUhxi7kezI7pQ Dq59xYRWYRZ3nhOsfw3Av4mmOYwnyy+EMg8J9HrProvuJto8lSwLvbwWi76HDuoS10Qj /znnmKOaf1tu/aPigEZATluopvKFAjMXeYMMkhCbSmSTmynm+Yde+yMd8OrtaKlDWdRl MyobgAtoKJ6Gpu8505yt8T0cRDl7uQgsRHFttTP5rwAfrxIppq8mnTzhzIemywoROtNN Mm2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694234019; x=1694838819; 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=cGJohYqrlAeBGqv33iEu2l+2oxUpjbZfEtEhLbQOaQw=; b=BoyeGEb7kGCJj6KSXShE2anGuUnPsmkBcoaQWZXuoDp5FdbONM3TkGeb+JFedblePL PonM+dBwNiNWPj5iciFakdSk+RCVahxOnXJZur3i+yq/dsceRN6Rq2cMN7II1+DDV4JP 4LyuCcSpKg0uUmvfI8i/cMj6VL1xdIjiLzHBGDX/q3Kbm6Z5hMnuosCDvs28XWdQ4dUa 1ew4DcgvBRxcQRIwbgDcUWcsw/MCXkK+H2vGdF5/rDS4f9DF+qTgFCxE7aSw/Um/b3ao xejKnC4AM6CnjCZnGe5Gz7TbJrY7i0Nj91SgUuvYaVE0Myux0YADGJ3Zu/w7g7CJDQ11 yOmA== X-Gm-Message-State: AOJu0YyDvxk3LuBcpRo6TFNoVyTDgmrfUCcSfNVa2Sqs5Lflx9jFa45o vAjAh67Q28hNi/eZIqTFUf5e7lj+Z6o= X-Google-Smtp-Source: AGHT+IFISqkrKad/tbjOkZQylBTIZGiTUAmS/zs5C80EfUCJQSXptY7J6v1KFTTom+1WjreSWy/qMg== X-Received: by 2002:a5d:658e:0:b0:316:fc86:28ae with SMTP id q14-20020a5d658e000000b00316fc8628aemr3373360wru.15.1694234018687; Fri, 08 Sep 2023 21:33:38 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: imp@bsdimp.com, Stacey Son , Karim Taha , Richard Henderson Subject: [PATCH v2 04/23] bsd-user: Introduce freebsd/os-misc.h to the source tree Date: Thu, 7 Sep 2023 09:42:43 +0200 Message-ID: <20230907074302.79234-5-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230907074302.79234-1-kariem.taha2.7@gmail.com> References: <20230907074302.79234-1-kariem.taha2.7@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42e; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wr1-x42e.google.com X-Spam_score_int: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_24_48=1.34, 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=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1694234081578100011 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Warner Losh --- 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 */ --=20 2.42.0 From nobody Thu Nov 28 07:47:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1694234140; cv=none; d=zohomail.com; s=zohoarc; b=Uvx6casdpWgsvseGLcNnvm8O5fZRIPV+4FfxIP8Lfk5nd2jL/wHTbCyUl/Wd1TIQGjLyJ4voahjvRF/u0P8pz1Zb6PDOM4EYgAOBno8M2gCxqs5h/TZZ8V2MiZOZDZp5YWtz43P7ZfDG+bucnYScxBmhiqP0EyeQqNdzCcgLkR0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694234140; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=7TrfBeMTvldfbKpqmn3rJZFleCngQ8YSqhuAsSyAkaU=; b=HYLLpZhkwJJchec8BAxVMfBJ3i6prEVWFkDaQ/PoqpWVVFqIOYDqJmpc7Px42SvGShx1biwgvx00Bu0by5oubBZMWUQ8omBNztLIB8k6bh2SuGb3kubGHBD7EEefEy4xOemwC4ZlPkbWCj/H9RQjVbWFyaoRLPTptVhQK+Uay6A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694234140338819.130079102924; Fri, 8 Sep 2023 21:35:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qepfF-0000zT-Iu; Sat, 09 Sep 2023 00:33:45 -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 1qepfE-0000yz-3p for qemu-devel@nongnu.org; Sat, 09 Sep 2023 00:33:44 -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 1qepfB-0002vl-Ow for qemu-devel@nongnu.org; Sat, 09 Sep 2023 00:33:43 -0400 Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-31427ddd3fbso2478875f8f.0 for ; Fri, 08 Sep 2023 21:33:41 -0700 (PDT) Received: from karim.my.domain ([197.39.120.250]) by smtp.gmail.com with ESMTPSA id d16-20020adff2d0000000b0031981c500aasm3615102wrp.25.2023.09.08.21.33.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Sep 2023 21:33:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694234020; x=1694838820; darn=nongnu.org; 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=7TrfBeMTvldfbKpqmn3rJZFleCngQ8YSqhuAsSyAkaU=; b=cjK5Zogr9poGLb3qOSf00B9JxFjCeox/Ee5FTPz2Br4zOjlJ1TKiRWe9LvlBFuS4ra ktbbXJw2Il7Zbogn6vhe72jMz9Y4SqWGGvz0oXb3NibZhtbZ1y7C8jGVL8OK2d8TzA5k 5mL+Xk8XE8DDOotr9Mh8zhmW5PyMVrOrC0FZopYBE/yxGgH4VPVnG1u8sCd/1eKxVyXK GX2C4BeabxQIkj4IqHnyraEpWeiSZ7AtnEmhbkPZ9iieZ0Unux3rc7yCSHhHT1tZ3hYm FKLHAoYfrlhDJD/2pVcXzSJdBT5Neh7hjpxUQuyfisFH5rIySnX0zVHdWzxLk6+KlYTE o8kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694234020; x=1694838820; 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=7TrfBeMTvldfbKpqmn3rJZFleCngQ8YSqhuAsSyAkaU=; b=VhgpVHdD+AJXU0dhziO/UZi4apIqTjnPZ/JFsgVh5ymzhMraCKg1cTxmrj3LyMANXC 3psVSSgetVpi40fRYRo9mJ9TAViiLbJmMmEYK/wUEksbyTy2LZ26D3zRDwtSkEDuy8Z1 pSLE+AgCTOhCa6l1gmt7Z4fIDZeVwk8Asx7BUaxXAhRdOagO0HXsNq7sbN7UNxZFaggS M7ECNr45/JHEXYW5cD89LCToW9JFRo1RRGnYhzeAcOtr2pjXveVomKUgvn+RzanzRHH7 EO4BEAUrUs7Un2CG5hsuhgi2v7Ht2zDJZCWEgFLHO1cvXUwFPtj5r5BJ+ZBq2l1sl8pu GDjA== X-Gm-Message-State: AOJu0YwjSmzBf1Qc9u58Yl+I/qC5sVi7sntU/tVPMY6xMG8mrwDKIE7O Dr1bqKzrKNULdJIFixhl/dwr22B7zOA= X-Google-Smtp-Source: AGHT+IHBX8TnxcCuCKvEn1ikpfAEFfPRfDIjI8XNPeo8WulHUWkm4QzPKL03CFZD/IF7ni8yQb2LbA== X-Received: by 2002:adf:e68f:0:b0:31c:8257:2c78 with SMTP id r15-20020adfe68f000000b0031c82572c78mr3615531wrm.52.1694234019900; Fri, 08 Sep 2023 21:33:39 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: imp@bsdimp.com, Kyle Evans , Karim Taha Subject: [PATCH v2 05/23] bsd-user: Implement shm_open2(2) system call Date: Thu, 7 Sep 2023 09:42:44 +0200 Message-ID: <20230907074302.79234-6-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230907074302.79234-1-kariem.taha2.7@gmail.com> References: <20230907074302.79234-1-kariem.taha2.7@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: 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: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_24_48=1.34, 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=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1694234142429100007 Content-Type: text/plain; charset="utf-8" From: Kyle Evans Signed-off-by: Kyle Evans Signed-off-by: Karim Taha --- bsd-user/freebsd/os-misc.h | 42 +++++++++++++++++++++++++++++++++++ bsd-user/freebsd/os-syscall.c | 13 +++++++++++ 2 files changed, 55 insertions(+) diff --git a/bsd-user/freebsd/os-misc.h b/bsd-user/freebsd/os-misc.h index 8436ccb2f7..6b424b7078 100644 --- a/bsd-user/freebsd/os-misc.h +++ b/bsd-user/freebsd/os-misc.h @@ -24,5 +24,47 @@ #include #include =20 +int shm_open2(const char *path, int flags, mode_t mode, int shmflags, + const char *); + +#if defined(__FreeBSD_version) && __FreeBSD_version >=3D 1300048 +/* shm_open2(2) */ +static inline abi_long do_freebsd_shm_open2(abi_ulong pathptr, abi_ulong f= lags, + abi_long mode, abi_ulong shmflags, abi_ulong nameptr) +{ + int ret; + void *uname, *upath; + + if (pathptr =3D=3D (uintptr_t)SHM_ANON) { + upath =3D SHM_ANON; + } else { + upath =3D lock_user_string(pathptr); + if (upath =3D=3D NULL) { + return -TARGET_EFAULT; + } + } + + uname =3D NULL; + if (nameptr !=3D 0) { + uname =3D lock_user_string(nameptr); + if (uname =3D=3D NULL) { + unlock_user(upath, pathptr, 0); + return -TARGET_EFAULT; + } + } + ret =3D get_errno(shm_open2(upath, + target_to_host_bitmask(flags, fcntl_flags_tbl), mode, + target_to_host_bitmask(shmflags, shmflag_flags_tbl), uname= )); + + if (upath !=3D SHM_ANON) { + unlock_user(upath, pathptr, 0); + } + if (uname !=3D NULL) { + unlock_user(uname, nameptr, 0); + } + return ret; +} +#endif /* __FreeBSD_version >=3D 1300048 */ + =20 #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" =20 +/* BSD independent syscall shims */ #include "bsd-file.h" #include "bsd-proc.h" =20 +/* *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 =3D do_bsd_undelete(arg1); break; =20 + /* + * Memory management system calls. + */ +#if defined(__FreeBSD_version) && __FreeBSD_version >=3D 1300048 + case TARGET_FREEBSD_NR_shm_open2: /* shm_open2(2) */ + ret =3D do_freebsd_shm_open2(arg1, arg2, arg3, arg4, arg5); + break; +#endif + /* * sys{ctl, arch, call} */ --=20 2.42.0 From nobody Thu Nov 28 07:47:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1694234119; cv=none; d=zohomail.com; s=zohoarc; b=HQJekO7jyueR1/FdZtbAOO3vlSK5oirY4PK67Vt7jiftcIdFbbK3K4at5qxLZ06dUXX447aKwWRTUCZi5iQtxgTQICudEGuE5sqKErJyv4YJny3O2fb3BiHFIQnJjMyTN/UxIBRLGh7CeG6Exlc3uUHk+VKK98H/XLweodS14B4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694234119; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=NQPQkmqbnFACQIlUwkAtPXqSarrHZNN1zhubxQ6WoBA=; b=GzxkNaL/w+3tJJBzDsd9sqamk6ehSCXInzXejn1ujucpjhvkK7X9L4B7flQ/IGkUclxSmDD5irYQAnBVOCzlERaD6pYWbhPTGYR3z9uJfZdm+5o5bam+T5riT/quTSpYAYgNZISd8VbAfe524Fs4M54vwiTXm7jC9zD9ayfwB9Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694234119189242.41666936218132; Fri, 8 Sep 2023 21:35:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qepfJ-000119-IF; Sat, 09 Sep 2023 00:33:50 -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 1qepfF-0000zQ-7w for qemu-devel@nongnu.org; Sat, 09 Sep 2023 00:33:45 -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 1qepfD-0002vu-2O for qemu-devel@nongnu.org; Sat, 09 Sep 2023 00:33:45 -0400 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-31f7638be6eso1852566f8f.3 for ; Fri, 08 Sep 2023 21:33:42 -0700 (PDT) Received: from karim.my.domain ([197.39.120.250]) by smtp.gmail.com with ESMTPSA id d16-20020adff2d0000000b0031981c500aasm3615102wrp.25.2023.09.08.21.33.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Sep 2023 21:33:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694234021; x=1694838821; darn=nongnu.org; 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=NQPQkmqbnFACQIlUwkAtPXqSarrHZNN1zhubxQ6WoBA=; b=KB5Mg1cnwpYR89z22XtLLOkUHK6vPUohHOX1gujODfYyXKOmAFCWxVzSflBvSFzI99 /gBExeNc5/OMYNr9kfuLinQ78HflYlRiFbRtjnkbQIeP19OyEmTNDO06kvpJDR9ncQJq p8apBkPajGCMWfx6eKlg306uG4ibQB2Ud9PKfTK6xkoAMKZlsD0DIwt/RJfy3nYvt8WR uz8pxezLZn1jkd3q839TmZVH8QWZJxQZBBQrIBjHHD1JKvwzeEcX5Yn4YsJ/OAgOU/jS sH7QKdlHcL++OV48GAVAZRkTO/CsXsHvAwsMTy0AEQb6Q8AgyMv7KXSrdASMBs45334I DwPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694234021; x=1694838821; 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=NQPQkmqbnFACQIlUwkAtPXqSarrHZNN1zhubxQ6WoBA=; b=VBiOfVPc7Y+pO9+Im1RJgkQUf5Z+6s8d1AIWMgoU286ikKcjAe7w2XMS/SaA1jJxBO 6z472VUDCNDvjj2kjHcIWcoggexi1twiebG3wGFiK6XnGwpUXoUzTQipFoHhnQfMwIOE VVMHDdNuF73ll3lKLy/lJcQWypy9GYgtb9K35gWzBSU0h4C82qcRbk9FzDl7DlAVFTCW wRDKTbycgGzy1c3BTK/VIGwivk2HZga49QyRez0Y6s7fetcRhoL1htnNG8D6rVARwn9C sNyslYJ4K8o9kDe97Gg8JzG5tJs82+38y6LtLknosHrYMYI6H5i1PaGIA5ouw0OdiCaZ ZSyA== X-Gm-Message-State: AOJu0Yy4WJllZv/zmp+ljONirnLZM2xXQYs2st/7qdir+eRTGemJGKFP /6SZ3f4cP/2qsFPfe1jatuIxXPzriCc= X-Google-Smtp-Source: AGHT+IG6Hw0IwcyY7A+xgHSGYHWjw2DyFUi9jD8bw10JhsQ/2Q2PgpU4HX6GWiM38aQx8TJu37CF5A== X-Received: by 2002:a05:6000:c8:b0:315:9676:c360 with SMTP id q8-20020a05600000c800b003159676c360mr3735985wrx.25.1694234021098; Fri, 08 Sep 2023 21:33:41 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: imp@bsdimp.com, Kyle Evans , Karim Taha , Richard Henderson Subject: [PATCH v2 06/23] bsd-user: Implement shm_rename(2) system call Date: Thu, 7 Sep 2023 09:42:45 +0200 Message-ID: <20230907074302.79234-7-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230907074302.79234-1-kariem.taha2.7@gmail.com> References: <20230907074302.79234-1-kariem.taha2.7@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: 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: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_24_48=1.34, 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=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1694234119965100007 Content-Type: text/plain; charset="utf-8" From: Kyle Evans Signed-off-by: Kyle Evans Signed-off-by: Karim Taha Reviewed-by: Richard Henderson Reviewed-by: Warner Losh --- 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 6b424b7078..67e450fe7c 100644 --- a/bsd-user/freebsd/os-misc.h +++ b/bsd-user/freebsd/os-misc.h @@ -66,5 +66,29 @@ static inline abi_long do_freebsd_shm_open2(abi_ulong pa= thptr, abi_ulong flags, } #endif /* __FreeBSD_version >=3D 1300048 */ =20 +#if defined(__FreeBSD_version) && __FreeBSD_version >=3D 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 =3D lock_user_string(fromptr); + if (ufrom =3D=3D NULL) { + return -TARGET_EFAULT; + } + uto =3D lock_user_string(toptr); + if (uto =3D=3D NULL) { + unlock_user(ufrom, fromptr, 0); + return -TARGET_EFAULT; + } + ret =3D get_errno(shm_rename(ufrom, uto, flags)); + unlock_user(ufrom, fromptr, 0); + unlock_user(uto, toptr, 0); + + return ret; +} +#endif /* __FreeBSD_version >=3D 1300049 */ =20 #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 =20 +#if defined(__FreeBSD_version) && __FreeBSD_version >=3D 1300049 + case TARGET_FREEBSD_NR_shm_rename: /* shm_rename(2) */ + ret =3D do_freebsd_shm_rename(arg1, arg2, arg3); + break; +#endif + /* * sys{ctl, arch, call} */ --=20 2.42.0 From nobody Thu Nov 28 07:47:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1694234395; cv=none; d=zohomail.com; s=zohoarc; b=k1m3PFOmrWMQPqzXMv3KYSyCCEapho7wqTnwkQpHNCkUPg6IRk+0gVPpYn4D0P6u7GF8phscop4yfslYijCPvfOF+Do6absqQE/fKsUu91f7SeOa1E0rPDNp0DWxm4zzlDY0IuJ3nIYuuJbm3ZZBaXzzbjEImpSo2FIS8uuoEwE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694234395; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=B7l8yTYvF0exPE7Y1/cG6wE7nHKc1Z9FnZqMFX4sgdA=; b=ao7pfEgXbxQGHf0E9BCNtefEYheR+upRgTEl0qTYYrpLG3V6hWmJzgelfdCR6w1vOz/NcryLO0AHBvqX57Qp+FExgy9J9e32ahYjohXZ9Y3aLBECkh4HTu24+PJlCHR9YtSChNOdrfdcw2cWdFFxQOJwqDo7Vb3dB1c2PopP+LA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694234395112890.7201737539132; Fri, 8 Sep 2023 21:39:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qepfH-000100-27; Sat, 09 Sep 2023 00:33:47 -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 1qepfG-0000zq-38 for qemu-devel@nongnu.org; Sat, 09 Sep 2023 00:33:46 -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 1qepfD-0002w8-WA for qemu-devel@nongnu.org; Sat, 09 Sep 2023 00:33:45 -0400 Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-31f6ddb3047so2467150f8f.1 for ; Fri, 08 Sep 2023 21:33:43 -0700 (PDT) Received: from karim.my.domain ([197.39.120.250]) by smtp.gmail.com with ESMTPSA id d16-20020adff2d0000000b0031981c500aasm3615102wrp.25.2023.09.08.21.33.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Sep 2023 21:33:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694234022; x=1694838822; darn=nongnu.org; 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=B7l8yTYvF0exPE7Y1/cG6wE7nHKc1Z9FnZqMFX4sgdA=; b=ngeNLSMLAYvoE5x+vE7mgthHCfYfSbLKaKAfxCxHD6OzZfv0HVpKp+xuCz8v63wrjM fD6wAbafCTmXcJPlXVoA4PqjzgbzoWQ/eu6Fzm5zfTkOfBOPV4ax+tEUGSXnk0dlnqU6 l4unE+gz43jvDphpnTG+s9hhGstjtqkGHIkuCnxPLXJh3Ts6s4BaMAmLiW2PuUYMbFoX El1Pl9K2C5hm9NLXj5n4shBmfGtiQvZv2jNz7fZfM8cYSn/7em9e2Bcn0v9RiDmrC0Dg 1OyL5jjZfuuFmqSrC4RPxMzbWSyrT6y8XxHANTNDw1LEW71Vy96Kbe3dnkLmBu1AN9f6 TtFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694234022; x=1694838822; 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=B7l8yTYvF0exPE7Y1/cG6wE7nHKc1Z9FnZqMFX4sgdA=; b=JjTQPSLviA/ltX+NUrvZQfrBY3Eii++bwhdg9cd9WVVMdDQyvCaXJ3W4Fq9oeGW8vz 89E8iWCOrUDvr35a2pbl15CNTaSOr2P1ZP/3s99WkgyL53ba7gMqyiyzvhg7xMEs2kej pqemMQLRiDkKVPO0nRL2Vr2Wf22iifAqmo7zsXoQ4Zmvb9QMJr2XaBNcasuelOUq0N/M bVC1FX/V0Ick9ZLLhW5WCnQiyICi7fScL8L5+9hrkveWXoLG/WWoREZG+0Oiji72gx5z 2GcwxTr/Qd9vewEl7lhro4narZK4wiqhZnNvySkOMb2EatFrIQvxZgoys7ZWRRckk5Kk O62w== X-Gm-Message-State: AOJu0YyAp5FNxFGVIHq3xmhn9yh+7FeX9t+CwtSD+ii0x4nTg+c7Ml3P jZhfuOR5TzS9rFWLsjC5XOAmMb73Atk= X-Google-Smtp-Source: AGHT+IHQ3YGjtqw5VijP20EpxRkByBU/g+nT91mxphCtgnwTwtNxAviVeWpmDO3Glz15SQ9+UGO+Vw== X-Received: by 2002:adf:cc8a:0:b0:317:67bf:3376 with SMTP id p10-20020adfcc8a000000b0031767bf3376mr3283362wrj.57.1694234022422; Fri, 08 Sep 2023 21:33:42 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: imp@bsdimp.com, Karim Taha , Richard Henderson Subject: [PATCH v2 07/23] bsd-user: Add bsd-mem.c to meson.build Date: Thu, 7 Sep 2023 09:42:46 +0200 Message-ID: <20230907074302.79234-8-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230907074302.79234-1-kariem.taha2.7@gmail.com> References: <20230907074302.79234-1-kariem.taha2.7@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: 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: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_24_48=1.34, 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=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1694234395923100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Karim Taha Reviewed-by: Richard Henderson Reviewed-by: Warner Losh --- bsd-user/bsd-mem.c | 0 bsd-user/meson.build | 1 + 2 files changed, 1 insertion(+) create mode 100644 bsd-user/bsd-mem.c 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 =3D ss.source_set() common_user_inc +=3D include_directories('include') =20 bsd_user_ss.add(files( + 'bsd-mem.c', 'bsdload.c', 'elfload.c', 'main.c', --=20 2.42.0 From nobody Thu Nov 28 07:47:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1694234079; cv=none; d=zohomail.com; s=zohoarc; b=aIg7DXyvnKxtfsmJMx+oW8ubXF96crv5mUaHqdvbyRdQ0gblNvT6iNwkxstDakD9gNkZeNJD1zUW4mzBgPJYMKmL3oZe6uDKUncNdGUd/sc5XCh045GFKejydfjC2+Kbh220XLJ+iSIghWf5iLlKlhBoASc2HA+Ni2bn/ceqDUM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694234079; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=TFf4JunziSOD7sjN6pr2SlP9OXljzV+aLcAeDFfEgaE=; b=bQnHT4BptOqJiKFxcxAckVlg1uXLF5cTzLzkUiJgi/H3H97v+Eiu1axI8NPZt7gYdP7dBsM3/PDrEB1A9P7YrFDo/nDcl5xsobngPwWMBQrL7tExRdGrmNPROynZitLKB+7a0DdOX9JbJQ15azkBftwGfcQ3v2n1FWU2aza4Gx4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694234079869375.0344750134668; Fri, 8 Sep 2023 21:34:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qepfJ-000118-Cy; Sat, 09 Sep 2023 00:33:49 -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 1qepfI-00010T-3K for qemu-devel@nongnu.org; Sat, 09 Sep 2023 00:33:48 -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 1qepfF-0002wK-KG for qemu-devel@nongnu.org; Sat, 09 Sep 2023 00:33:47 -0400 Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-307d20548adso2659627f8f.0 for ; Fri, 08 Sep 2023 21:33:45 -0700 (PDT) Received: from karim.my.domain ([197.39.120.250]) by smtp.gmail.com with ESMTPSA id d16-20020adff2d0000000b0031981c500aasm3615102wrp.25.2023.09.08.21.33.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Sep 2023 21:33:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694234023; x=1694838823; darn=nongnu.org; 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=TFf4JunziSOD7sjN6pr2SlP9OXljzV+aLcAeDFfEgaE=; b=YrvXXuPUV8InD3K71YBcbGtW0ntBxFF+glTcFYWtWSgsitPSEjPbo70M+RteGO8zy5 U9fG3f9f2nnLeft7NnzhPJ8bkNInhZ+XIl/4P/VlniP8/dv9NCql2D2fO4lfRwF4nlQG bcc+XG+7ianLOA48bZRtfuuGsH/gupIgDjHz4UA5UwZw/o31V94ywXAagdMvZtdE1CQL 0aCoss+o2nb+kNYA4uubtf3fYpoI5dWUNysANkP9dHOvTu9b0O8MdjwVjjDW2Ig+r1F+ nXbzXJcXGMTA2BrNNKM3CKSPfSomfA/sxkQaLFBlJbp1xNPZK2Imuhdzobg0nJS8E8eW nAfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694234023; x=1694838823; 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=TFf4JunziSOD7sjN6pr2SlP9OXljzV+aLcAeDFfEgaE=; b=JJLZhCo/p7G/w4C2mkoR3mXrPhZ+ynuBjK7EBpDkrurBl0VyLPMyVBPkOasvm1XTuN P1/sAkGFUum6v0CcpRE54rGzCQIie3oVNtPqzU1MvL9zmP7SKtQ/FF51r0AzCNQ9GCM5 VUPutyCae4hC7/WRlyzHUlaV+WpxyOnJVUem3JzhLignDwEUTIwUW2LyS1uwXC/hkHqS 2YQJ6bDHEN8MG6kBSjoCGELkSRpYTMV/h6wAa2v/cSpFXIh1HW700YMSqW2Pcodd/Cir cSrQIdTjP2/CrkSIKtBzRgDnTEkYZKPoo3upYm9lVsxA5yrjOFW5WZvczpoFS3zt5Tcm Tl0Q== X-Gm-Message-State: AOJu0YxSY+z4fl3RAA7N/krdAT+cnY2zNOUSu/b7H72idUuCoE+b7svR Mgqm2WkDNiC6kcmotN8yjtGcDTJH4HY= X-Google-Smtp-Source: AGHT+IFZwRHMp1efhjo/w5B+yDh1TImdA0XRvMVEBJtPkmoUDRWl+8ccfO6AGNsF9FBactzDL1nvnA== X-Received: by 2002:a5d:456b:0:b0:319:68ba:7c8e with SMTP id a11-20020a5d456b000000b0031968ba7c8emr3537466wrc.38.1694234023633; Fri, 08 Sep 2023 21:33:43 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: imp@bsdimp.com, Stacey Son , =?UTF-8?q?Mika=C3=ABl=20Urankar?= , Karim Taha , Richard Henderson Subject: [PATCH v2 08/23] bsd-user: Implement target_set_brk function in bsd-mem.c instead of os-syscall.c Date: Thu, 7 Sep 2023 09:42:47 +0200 Message-ID: <20230907074302.79234-9-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230907074302.79234-1-kariem.taha2.7@gmail.com> References: <20230907074302.79234-1-kariem.taha2.7@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: 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: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_24_48=1.34, 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=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1694234081506100007 From: Stacey Son The definitions and variables names matches the corresponding ones in linux-user/syscall.c, for making later implementation of do_obreak easier Co-authored-by: Mika=C3=ABl Urankar Signed-off-by: Mika=C3=ABl Urankar Signed-off-by: Karim Taha Reviewed-by: Warner Losh Reviewed-by: Richard Henderson --- bsd-user/bsd-mem.c | 32 ++++++++++++++++++++++++++++++++ bsd-user/freebsd/os-syscall.c | 4 ---- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/bsd-user/bsd-mem.c b/bsd-user/bsd-mem.c index e69de29bb2..8834ab2e58 100644 --- a/bsd-user/bsd-mem.c +++ b/bsd-user/bsd-mem.c @@ -0,0 +1,32 @@ +/* + * 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 "qemu.h" +#include "qemu-bsd.h" + +struct bsd_shm_regions bsd_shm_regions[N_BSD_SHM_REGIONS]; + +abi_ulong target_brk; +abi_ulong initial_target_brk; + +void target_set_brk(abi_ulong new_brk) +{ + target_brk =3D TARGET_PAGE_ALIGN(new_brk); + initial_target_brk =3D 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 iov= ec *, iov, int, iovcnt); safe_syscall4(ssize_t, pwritev, int, fd, const struct iovec *, iov, int, i= ovcnt, off_t, offset); =20 -void target_set_brk(abi_ulong new_brk) -{ -} - /* * errno conversion. */ --=20 2.42.0 From nobody Thu Nov 28 07:47:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1694234117; cv=none; d=zohomail.com; s=zohoarc; b=CwAblu+xsWTrFaL4PM+6Vg4axqfs47RnWe85Z41yAfY6xME35VNZ83B+1xjPzH1w4i2rHgJq+Fr4tLNGJiW0pNZ1B9h51EEZ7BrH4kcRDWNmD4X7p1thUACawrUYiCH7GmDTr+K34oSPVVfJUb8f5PKke1etWg3fUJuLVQqXya0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694234117; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=iussohd3oOsJrjsaObP8RqGbhTo1pjSye6BxeJlFWe4=; b=H9IfkffXXcvyaotZ1pmdHLpGR+QE2W0HLqAkO0P9PYDPhwETh0b1fPilirB56Jg2++pY3iSFDt/IqOsXvKCRpRK4VkDphRix5iK1QLCzM/Hf+O2SUoZOJUokxSsSKeSHzzFPA16eUZkegOZbpyriDHSyAVCRi87OAaAOG0H4+w8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16942341174582.121982641755153; Fri, 8 Sep 2023 21:35:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qepfR-00012P-Jn; Sat, 09 Sep 2023 00:33:57 -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 1qepfI-00010h-Pk for qemu-devel@nongnu.org; Sat, 09 Sep 2023 00:33:48 -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 1qepfG-0002wT-MC for qemu-devel@nongnu.org; Sat, 09 Sep 2023 00:33:48 -0400 Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-31c73c21113so2471541f8f.1 for ; Fri, 08 Sep 2023 21:33:46 -0700 (PDT) Received: from karim.my.domain ([197.39.120.250]) by smtp.gmail.com with ESMTPSA id d16-20020adff2d0000000b0031981c500aasm3615102wrp.25.2023.09.08.21.33.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Sep 2023 21:33:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694234025; x=1694838825; darn=nongnu.org; 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=iussohd3oOsJrjsaObP8RqGbhTo1pjSye6BxeJlFWe4=; b=RQsXmgu8GvA358XYwJNYkX0uAM02RiR48mojE/cXtLZA9cktnAcEdUE6qDWCvetV3N mp698zhIN1LhY4leTlAdKJ4tmFSqL5AOeJAIM6syxvgsMGngJvFU6uk73pafe7KxD555 e2y9U+qAJ7tb1rfssVorIFsDEND1Y0O6rydL56hX4KtZAsZ5B//Ho6zB78fkAQKMJwj7 VF8yFIQpJxHvB/O1DGoy3FCK5yL6IC/MIafIu4bhr2ktCnssORe7/dhXdlGEKmnqnTFY O0YTnZzIKVEEnnE8AKYy4QmHB++Mul6SMspwonlVnELbMHO7pAqnZ/9AeAGEBv6Bqt4h ek/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694234025; x=1694838825; 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=iussohd3oOsJrjsaObP8RqGbhTo1pjSye6BxeJlFWe4=; b=JvMksHX6CId1t+LEd+yxIuEZiksUka6Gw0HAYXO0/l/ygXa7ImjLFEVzeVpr0RDjb0 pbq80SUMNmnQ+zTdO3QWLLpjs2BE5j56XjYUAjIE8xhNvu2KUAtrJbueCFDZcB2iqyOB FuykvYBhHgyrbQ9LOKixjbz3HByrU0B1zJm0ZuKiY5C+JYWStsSvNRPJTJZcDqyGvjOO /JPpq7Ev2jTehp8lWe7IqBfPne91jwizmOKD1J6f12S8SHsciS8Wq7DErKQ+0Uo2fV7Q MujFe5WE4wWUoq1R7K/ugSwGx2zhEEw1eYG+seLIvDjeOnmHR6D4WIiUp2/SEd3n/9E3 KTgw== X-Gm-Message-State: AOJu0Yx93IY50bUYsztC+jM6m+o3IMo7wnBIh5B2VspuQsVgNQ7v9ws+ MIBPS8BEju/W4zu5NafVWjQqxoLoeAM= X-Google-Smtp-Source: AGHT+IFf/n6ipjlOpr4wnyG2l+yMejGay7OWyqnmuQ7Fm2KewRwGgVmdekG49kaqRm0/jxyUpxZeug== X-Received: by 2002:adf:f8d2:0:b0:31c:81ef:f90a with SMTP id f18-20020adff8d2000000b0031c81eff90amr3200647wrq.47.1694234024808; Fri, 08 Sep 2023 21:33:44 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: imp@bsdimp.com, Stacey Son , Karim Taha , Richard Henderson Subject: [PATCH v2 09/23] bsd-user: Implement ipc_perm conversion between host and target. Date: Thu, 7 Sep 2023 09:42:48 +0200 Message-ID: <20230907074302.79234-10-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230907074302.79234-1-kariem.taha2.7@gmail.com> References: <20230907074302.79234-1-kariem.taha2.7@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: 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: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_24_48=1.34, 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=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1694234117959100001 Content-Type: text/plain; charset="utf-8" From: Stacey Son Signed-off-by: Stacey Son Signed-off-by: Karim Taha Reviewed-by: Richard Henderson --- bsd-user/bsd-mem.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/bsd-user/bsd-mem.c b/bsd-user/bsd-mem.c index 8834ab2e58..46cda8eb5c 100644 --- a/bsd-user/bsd-mem.c +++ b/bsd-user/bsd-mem.c @@ -30,3 +30,28 @@ void target_set_brk(abi_ulong new_brk) target_brk =3D TARGET_PAGE_ALIGN(new_brk); initial_target_brk =3D target_brk; } + +void target_to_host_ipc_perm__locked(struct ipc_perm *host_ip, + struct target_ipc_perm *target_ip) +{ + __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); +} + +void host_to_target_ipc_perm__locked(struct target_ipc_perm *target_ip, + struct ipc_perm *host_ip) +{ + __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); +} + --=20 2.42.0 From nobody Thu Nov 28 07:47:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1694234232; cv=none; d=zohomail.com; s=zohoarc; b=m7z6x5K5BgFSHtSAPjG3ic2jPLlpMr+uV/damnJR3yt4HCa54/MZ5DV4m4b6VNO3sghhSbQm6LKPZ2dT9IW0EqK2vMZWR1op6knLYhy7iafOF4Y1Yl75EYpbo5DTEkwdwoKq2qBVcPtV3+sT2dSSvEt8i/HrwFNYkxcOPX0abtE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694234232; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=SzQYgtfeBusD4Se7U5wLMSY61hrlabGlXjvWtWADjxo=; b=TWOTW5hVvRv28l3Sj2J0Kba8NMItRFlU6sCTRd0Ql7ePc4Pp3Y2rbfwmuO4p5dmBy0tGkuvA1WKWO/KPSgIQEj9Hle7PA8zncTm65xaC5pSBwhoUMprGycIS3mHbnlk9XwclDenFva6a3EbSG9ySTYpJqL5TIEXeA/ZK/W7TLHo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694234232542103.26788402949433; Fri, 8 Sep 2023 21:37:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qepfh-000188-Pl; Sat, 09 Sep 2023 00:34:13 -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 1qepfK-00011D-2i for qemu-devel@nongnu.org; Sat, 09 Sep 2023 00:33:51 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qepfH-0002wf-Se for qemu-devel@nongnu.org; Sat, 09 Sep 2023 00:33:49 -0400 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-401bdff4cb4so28285395e9.3 for ; Fri, 08 Sep 2023 21:33:47 -0700 (PDT) Received: from karim.my.domain ([197.39.120.250]) by smtp.gmail.com with ESMTPSA id d16-20020adff2d0000000b0031981c500aasm3615102wrp.25.2023.09.08.21.33.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Sep 2023 21:33:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694234026; x=1694838826; darn=nongnu.org; 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=SzQYgtfeBusD4Se7U5wLMSY61hrlabGlXjvWtWADjxo=; b=UjEl4pkB+wH1NeQe6ldVKOUpyoJLcmPipIWkxvV2/KIMBCdtbGyiqof81LihLzIJkX DDHPQDlS4qWRTpbVCr7xGskUQMMnrhUHvBUkYLLNhRJoeutD4epwMoqM+5cP9H575BEa D33t/dFAsRHFRsXK31ymjywMRWXCdJ0E39PDVe+J5s22SY2xzYEjedsgjP2+gR/Myo3S oYm+ZX2/CnaRFyr0d7iCajU9vN6dUgdLosU13/LgDBt5DvTwkFrKpcQcM91gUwtw8UtH aZj/z53iX4O+kEYTXS4SUYqvMGIhORprtmWGM7rrQVqThQ4fKTmdXlpJ+2iuTlwaneO3 JKRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694234026; x=1694838826; 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=SzQYgtfeBusD4Se7U5wLMSY61hrlabGlXjvWtWADjxo=; b=G1aVE+oKcu69bxpwZLG3kB7fk74WFzvMm1wI1zBkfED+yP0MAQsTUzT4tX91/Ljthk a4Hs6QYULNBcRa2hk2yvNlkW+WIHjZjSSQxiH1x9bpAbpxHFy+F97lrlxFFDY0Sm7Yss gNolKQxuPzVyAVw0Ifw1tQlnwBunoSx7ZRm9ZkFILyjBqVsNNUZGpdm3LtSl0zbi2b2x 8lZcTWxRhZN9/Fwme6HV+rMXIc30KZTrFJ2xvInoy45Tq9jMbMMg4x1lJQC6SI2wHYlL FmSRjyS0rHzuNpFsYOE9tHi8w18K0237IfAx401GGQeiKtUfcHij1/fY198Yggg9CBCh eSqg== X-Gm-Message-State: AOJu0YyT7snPMvlcKO+9QpryPYk2g+dF973/q1m7eaOvZCbQLZeI2Icq 6zseZRrmXi9PtMsvOw8sSRAWgkd6k4M= X-Google-Smtp-Source: AGHT+IE2kHkVeliKAyOLxI+XMv5JoeIIQexO/eakYqK1rFoTYZXVsbRcwMpvltjvCamhiDAYO9SnqQ== X-Received: by 2002:a5d:6607:0:b0:317:54de:9719 with SMTP id n7-20020a5d6607000000b0031754de9719mr2895584wru.70.1694234025978; Fri, 08 Sep 2023 21:33:45 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: imp@bsdimp.com, Stacey Son , Karim Taha Subject: [PATCH v2 10/23] bsd-user: Implement shmid_ds conversion between host and target. Date: Thu, 7 Sep 2023 09:42:49 +0200 Message-ID: <20230907074302.79234-11-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230907074302.79234-1-kariem.taha2.7@gmail.com> References: <20230907074302.79234-1-kariem.taha2.7@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wm1-x32f.google.com X-Spam_score_int: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_24_48=1.34, 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=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1694234233136100003 Content-Type: text/plain; charset="utf-8" From: Stacey Son Signed-off-by: Stacey Son Signed-off-by: Karim Taha --- bsd-user/bsd-mem.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/bsd-user/bsd-mem.c b/bsd-user/bsd-mem.c index 46cda8eb5c..eea499a727 100644 --- a/bsd-user/bsd-mem.c +++ b/bsd-user/bsd-mem.c @@ -43,6 +43,28 @@ void target_to_host_ipc_perm__locked(struct ipc_perm *ho= st_ip, __get_user(host_ip->key, &target_ip->key); } =20 +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; + } + + target_to_host_ipc_perm__locked(&(host_sd->shm_perm), &(target_sd->shm= _perm)); + __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; +} + void host_to_target_ipc_perm__locked(struct target_ipc_perm *target_ip, struct ipc_perm *host_ip) { @@ -55,3 +77,24 @@ void host_to_target_ipc_perm__locked(struct target_ipc_p= erm *target_ip, __put_user(host_ip->key, &target_ip->key); } =20 +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; + } + + host_to_target_ipc_perm__locked(&(target_sd->shm_perm), &(host_sd->shm= _perm)); + __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; +} --=20 2.42.0 From nobody Thu Nov 28 07:47:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1694234255; cv=none; d=zohomail.com; s=zohoarc; b=fZ0rHPsdKz9oyyLuedVAB9sDJggAlWWrN5ioiN649ZbKF0wuZfpro5+C6KgEFovDgK980nFLMHzWqjnhorzNrc/YfbIevdz0rOXqy4iwgm5Bws788XI/xtky32Q7Zj9Vx81NsN6RsL9SX82VcdnpG2CTRxuMKkEg0c2yQ35WWDM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694234255; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=HPqFO7ZnPlB1ymtPBm42Ntj1KqYfMSvTSWzVjhNSsnU=; b=et+pLtgPAuIp4e30VxaH3M6j3b/nFo4NzaFD/JzB2lV7tOe8VNTX2HBwpPJMregnwRkampLpsPt9va5dH5A1as5kLmH41tdBYodFElOCChXtRcvnrlzIcSeTH+nuLT43qGAACoO6OgyoGmuSEIanmcVyYlXiIyJgm20iyN2xSxc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694234255864310.0962866958829; Fri, 8 Sep 2023 21:37:35 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qepfT-00012t-I0; Sat, 09 Sep 2023 00:34:00 -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 1qepfL-00011h-Q1 for qemu-devel@nongnu.org; Sat, 09 Sep 2023 00:33:53 -0400 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qepfI-0002wm-UP for qemu-devel@nongnu.org; Sat, 09 Sep 2023 00:33:51 -0400 Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-31ae6bf91a9so2624173f8f.2 for ; Fri, 08 Sep 2023 21:33:48 -0700 (PDT) Received: from karim.my.domain ([197.39.120.250]) by smtp.gmail.com with ESMTPSA id d16-20020adff2d0000000b0031981c500aasm3615102wrp.25.2023.09.08.21.33.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Sep 2023 21:33:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694234027; x=1694838827; darn=nongnu.org; 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=HPqFO7ZnPlB1ymtPBm42Ntj1KqYfMSvTSWzVjhNSsnU=; b=LKuFfv2XJ/ClrvV3zs5SYVS0llQkkeMf7w+OzIen8zFVhntuiPqy8kuuJnXwlV2CBy tN8QkK9ZSy36VP6RPJeB1hbqiJMHUu2dl8IBdkg1Sy9V+fLjUl2URS/9rV0IYkCwevSh f5/rCQmtOR5vgmhLJ4z1Fq4THIM3y8OFw9+CMOKXHRDl1YBscpdBBq7QizGc7EvdZxD/ LUBU2mCivHypYzlw33Z4Dk0+TcphoCnqhFFlrHeHNJ0U83Lc/fKJddYueIUSiyqYy1ZN GPE/keAUppItJIUi/WeJGs1j5zkM+gb3lQqQ0+tbyJWrqJim31kME7Ae+RNRf7duNfWf eQtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694234027; x=1694838827; 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=HPqFO7ZnPlB1ymtPBm42Ntj1KqYfMSvTSWzVjhNSsnU=; b=UCoUC0vfrl9yWa6PCg40l4Akae7XqxPLCaxCUxXZo4Avm5P9vk3ULxifGoOmYB62Aa CvwYC6EoWxl8uuMaExMR7IfdvBEga9Gvc5YlOlZcQprKik5/1gF6JI2BDDrVFa27SH4B ymiay+7PNvbMs7EYN6M73Huqh3v2B0WtzNYdvAIG0T1y0f4c5wdB9yjeeKzNG5jIKqM+ J9yOEJzw2/+YwcvyBF+S6iZKyfbRNAyNQKIlvrlygVBifmSVAErp9ZxSX5UXoGzPis0J APQGhdWckLBWqcLPoGEiyyK4Ux5CPdJF6rB7nBNAM1lImxEw4XgOkwqJAhEv0P8B4W/h 1HQw== X-Gm-Message-State: AOJu0Yy3eUf3Ku7p1BefUIUauaRAd/gYGrE+j6F6Gu5vazSz2+ufj1ym OJG6nih/DPm6IdNNpcefZC/l090cQ5I= X-Google-Smtp-Source: AGHT+IF/xHegWKjM3olkJC1AbRzIcwC4ViwsvQ26rjXKcf01DkpUZ7F+yLHghRbMJ0mbupH9QhqCVQ== X-Received: by 2002:a5d:674a:0:b0:31a:d78f:1b0b with SMTP id l10-20020a5d674a000000b0031ad78f1b0bmr3268858wrw.18.1694234027150; Fri, 08 Sep 2023 21:33:47 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: imp@bsdimp.com, Stacey Son , Karim Taha , Richard Henderson Subject: [PATCH v2 11/23] bsd-user: Introduce bsd-mem.h to the source tree Date: Thu, 7 Sep 2023 09:42:50 +0200 Message-ID: <20230907074302.79234-12-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230907074302.79234-1-kariem.taha2.7@gmail.com> References: <20230907074302.79234-1-kariem.taha2.7@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::432; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wr1-x432.google.com X-Spam_score_int: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_24_48=1.34, 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=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1694234256923100001 Content-Type: text/plain; charset="utf-8" From: Stacey Son 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 | 64 +++++++++++++++++++++++++++++++++++ bsd-user/freebsd/os-syscall.c | 1 + 2 files changed, 65 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..d865e0807d --- /dev/null +++ b/bsd-user/bsd-mem.h @@ -0,0 +1,64 @@ +/* + * 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 PURP= OSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENT= IAL + * 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, STR= ICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY W= AY + * 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 target_brk; +extern abi_ulong initial_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 c0a22eb746..7e2a395e0f 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -35,6 +35,7 @@ =20 /* BSD independent syscall shims */ #include "bsd-file.h" +#include "bsd-mem.h" #include "bsd-proc.h" =20 /* *BSD dependent syscall shims */ --=20 2.42.0 From nobody Thu Nov 28 07:47:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1694234220; cv=none; d=zohomail.com; s=zohoarc; b=elhDyAFxOXc1tatHUI5hlq5Govqs9YIXF7QCDRgLvDFlCxChaZghaQAQCQI5OWI9yYDzGg4fTYt99aLjXMmlWp/RxE5XUXsH8btrWeg2YPh6POf1BWr1NthR0RFsjgaSOEICXkxl0Z7BG56Ctk4CYCo2HMUAbB7w60p6JNjh8hY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694234220; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=jNK2HNrdMWVVY1+gcX4oM/Wj3OhUzW/K4i4ACmkfmcg=; b=kZnYAgO4G2DTeS1aL4/+oIsm1d0a9th5C0iEWLdinTSouRcf9gWyBNsghJqbrxra6en5OP4n1Gy0m12V4+cnXtXAH8KnQAuDau/DSZ0nbS+kjtlcz0czk9bM/0Sm3jt36OVJnkH9rYBZmpL0z57Rbi1R9MiiiOIKUyGTs6RWoEY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694234220204786.887496176432; Fri, 8 Sep 2023 21:37:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qepfV-000145-S7; Sat, 09 Sep 2023 00:34:01 -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 1qepfN-000122-NM for qemu-devel@nongnu.org; Sat, 09 Sep 2023 00:33:53 -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 1qepfL-0002x3-GB for qemu-devel@nongnu.org; Sat, 09 Sep 2023 00:33:53 -0400 Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-31f853f2f3aso467800f8f.0 for ; Fri, 08 Sep 2023 21:33:49 -0700 (PDT) Received: from karim.my.domain ([197.39.120.250]) by smtp.gmail.com with ESMTPSA id d16-20020adff2d0000000b0031981c500aasm3615102wrp.25.2023.09.08.21.33.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Sep 2023 21:33:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694234028; x=1694838828; darn=nongnu.org; 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=jNK2HNrdMWVVY1+gcX4oM/Wj3OhUzW/K4i4ACmkfmcg=; b=XqF04BzBcaFRZ/Be4wavTa7ACQlcLstK6WR3m3RXfNXdhjsY2PqXvyX1wpK2Avare6 wfl699R6D5wCa2EQ2t0FxpIvmP0Rq6N7cXiEEIZnH4A/aaCW4pjRUV8ZEIETp/4VDSCQ gbtGE7yRh+A/VD+tGvFqepw2YZuvVuEmfnYQ3ObUNGBimcsMrKq6xQhwG3CLianRJWX/ XfoLjllpRD2uBxdsS13qTvUzYkzGSPVYpc+dtvnl0QKhhwPnIGJRXLYgyOW8l3ZTcKPc r3/QOSmIISyUP6wMnt3FVOpCEpGZK23EX+66oTNZdjMJctg8Qk5xqYEYh7nmRfFSjxPk pbYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694234028; x=1694838828; 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=jNK2HNrdMWVVY1+gcX4oM/Wj3OhUzW/K4i4ACmkfmcg=; b=pm3EZ3af3SlOJPHaQYc5m/JmnietNgHH/hgS/8hndZ8yUTihB5DhiGRr9tKPH+FhHQ reKCf7J1nGNYJ3WuXkBu9nO+nFlIK9IDU6VqkEfsNUxP4l2/AH23hLDX03WwyapbwQVr AIJfm9fbNuXJaSGK96px7cwhxPJta3UCVQxn58CHtuHksceOHbmZOoXaxC7VcTWcHWSR 9UEcySyiKFYIwt4Z98n1tpDhn/eh6OCsqT1RWZQl7VzaNbyoLU+FP154CkHmTxtYwcHh mcZf37uflt2V1d1jewse1hF96pWw4lVv+MWjfR3Wa6ULR2OK13X3WWua8vG8gnjPfciV pjZA== X-Gm-Message-State: AOJu0Yy77wH4KBe2D4PgaigpFEXvYfbGJt2PA/RArviEo5nKtcVAr8m9 TsWu/AS+p+hhhfQM8ITADCOLNLcleFI= X-Google-Smtp-Source: AGHT+IGQDhXwLs2I8/rV4WEQtn8xUj1dlYgt1hQXy/C1j/vPpVBSTOaprkF6lDYbkDgKBb/Sau7ybg== X-Received: by 2002:adf:de01:0:b0:31a:e3df:f719 with SMTP id b1-20020adfde01000000b0031ae3dff719mr5549137wrm.17.1694234028331; Fri, 08 Sep 2023 21:33:48 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: imp@bsdimp.com, Stacey Son , Karim Taha , Richard Henderson Subject: [PATCH v2 12/23] bsd-user: Implement mmap(2) and munmap(2) Date: Thu, 7 Sep 2023 09:42:51 +0200 Message-ID: <20230907074302.79234-13-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230907074302.79234-1-kariem.taha2.7@gmail.com> References: <20230907074302.79234-1-kariem.taha2.7@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: 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: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_24_48=1.34, 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=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1694234222414100005 Content-Type: text/plain; charset="utf-8" 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 d865e0807d..76b504f70c 100644 --- a/bsd-user/bsd-mem.h +++ b/bsd-user/bsd-mem.h @@ -61,4 +61,24 @@ extern struct bsd_shm_regions bsd_shm_regions[]; extern abi_ulong target_brk; extern abi_ulong initial_target_brk; =20 +/* 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 a= rg7, + abi_long arg8) +{ + if (regpairs_aligned(cpu_env) !=3D 0) { + arg6 =3D arg7; + arg7 =3D arg8; + } + return get_errno(target_mmap(arg1, arg2, arg3, + target_to_host_bitmask(arg4, mmap_flags_t= bl), + 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..d88f62319b 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 =3D do_bsd_mmap(cpu_env, arg1, arg2, arg3, arg4, arg5, arg6, a= rg7, + arg8); + break; + + case TARGET_FREEBSD_NR_munmap: /* munmap(2) */ + ret =3D do_bsd_munmap(arg1, arg2); + break; + #if defined(__FreeBSD_version) && __FreeBSD_version >=3D 1300048 case TARGET_FREEBSD_NR_shm_open2: /* shm_open2(2) */ ret =3D do_freebsd_shm_open2(arg1, arg2, arg3, arg4, arg5); --=20 2.42.0 From nobody Thu Nov 28 07:47:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1694234369; cv=none; d=zohomail.com; s=zohoarc; b=S2tt/XYCx8p7TUXCXm6SLqhyPbfuvyWly3LR9Zb5PbZWkjjkZCQkWpjtgo5eK1mNpxN22eMZ0rBBUbgSRPcVKp3hTXURQkSo+uKCFRNepz7GMp/28ECmdLQ2251fTDRwO23/J31Cd3ItFJE8bejsybtMcf2KwfvZSAY1zTnEYnQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694234369; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=7eYQSo99m8Jb6VuAKy20SyQjPPkVXbzKZOriqtp/fqQ=; b=Vqndi1ufUIUMBdZm2/S+4xecf7OMzZAxb8feKdd/0Q924o31QIp49mul7Yzd7aXuOdmawWiirSYsnvWYjQGit7h6trD0oVNJsw4s+3hYumpOeGvfPEmVlKHxICRnVztH1OFK2hmjuLrwgi4mGhPwT56qewH4I3oZhPi4cRdgXSU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694234369266597.8332774646714; Fri, 8 Sep 2023 21:39:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qepfW-00015a-VA; Sat, 09 Sep 2023 00:34: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 1qepfN-000123-Nq for qemu-devel@nongnu.org; Sat, 09 Sep 2023 00:33:53 -0400 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qepfL-0002xA-GV for qemu-devel@nongnu.org; Sat, 09 Sep 2023 00:33:53 -0400 Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-31c479ede21so2623669f8f.2 for ; Fri, 08 Sep 2023 21:33:50 -0700 (PDT) Received: from karim.my.domain ([197.39.120.250]) by smtp.gmail.com with ESMTPSA id d16-20020adff2d0000000b0031981c500aasm3615102wrp.25.2023.09.08.21.33.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Sep 2023 21:33:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694234029; x=1694838829; darn=nongnu.org; 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=7eYQSo99m8Jb6VuAKy20SyQjPPkVXbzKZOriqtp/fqQ=; b=OynJdE8x5GHuF1uiFFOhB4J5phKqbAc87cxI8eA3FHE8yyn3R5izaWP0eLfG4U+kQY /QSAoc4PD9LIIy2YnmPyKQ6Cukd4KPyPVvZkx4wKR2D7ipDtSvKx0UxgynZn5HwP/sEd fUum+S43lGOiu0iDqqXqyM+RpxtMfmsw2nwb6apBnfNt4JtJMZqb0mzYk1Y+Td18VLP5 TvRF0IKgHEmTTuPMP1pI/VKopuJ+/1kDAhBl/0OzyVb2LiXxbUPMenOc/G33V4LnAIMi g2AdEU7/2ektdXDgjGKMO91i4yeXey1vpxF0rXZYXTimJT1ujDw5e1V74J/ZINnev4yH jt/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694234029; x=1694838829; 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=7eYQSo99m8Jb6VuAKy20SyQjPPkVXbzKZOriqtp/fqQ=; b=UH2oA10xncID9B0sBTiZKvXxBlQsSXnKM9V0QFB5W1JjBUEcP8S/TYsE6L89sp2Uhq VKUMAK5W3D/6cbYX9nNHiRHmFkD04oFvSdIhqFoh39D7/9rzBfNNPRXXw85dG4onzCHg Z7OItFFRyK0Y90+3KwqlxqHqCQ8gGTSq/pA3QAevJ8lSizLcEIWgfzfbKmU+P7QCHUdB Gnu5wDYzosoBVWVT9+bEcXKsOvG0/1u2LqmOg0R5hP1yTIZ9DHStjLvetVtnhbzc1WZC wi3b8TH2VSHLKn/Way6f9m+zud/z3HnZSoOPL5e/nl8Fx7SQGmXlwv3MlnZjGCHRRX4V DV0g== X-Gm-Message-State: AOJu0Yw5FyHOqo6zYJ/TeFOctzRWo7f7IlHO+dpT6XHuyo719TChoQib zTMVLPcYO4AwaJTAxdO3HdHDMukXxmg= X-Google-Smtp-Source: AGHT+IHcjWJgxGM82i/Im8TPp9wyDkUbhY3utdEI+YaZ9GQLSsfY0dPdx8Q32+TAdIy0TyzUPxDL5Q== X-Received: by 2002:a5d:494f:0:b0:319:8161:ecc6 with SMTP id r15-20020a5d494f000000b003198161ecc6mr3172014wrs.63.1694234029598; Fri, 08 Sep 2023 21:33:49 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: imp@bsdimp.com, Stacey Son , Karim Taha , Richard Henderson Subject: [PATCH v2 13/23] bsd-user: Implement mprotect(2) Date: Thu, 7 Sep 2023 09:42:52 +0200 Message-ID: <20230907074302.79234-14-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230907074302.79234-1-kariem.taha2.7@gmail.com> References: <20230907074302.79234-1-kariem.taha2.7@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42e; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wr1-x42e.google.com X-Spam_score_int: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_24_48=1.34, 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=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1694234371057100003 Content-Type: text/plain; charset="utf-8" From: Stacey Son Signed-off-by: Stacey Son Signed-off-by: Karim Taha Reviewed-by: Richard Henderson Reviewed-by: Warner Losh --- 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 76b504f70c..0f9e4a1d4b 100644 --- a/bsd-user/bsd-mem.h +++ b/bsd-user/bsd-mem.h @@ -81,4 +81,11 @@ static inline abi_long do_bsd_munmap(abi_long arg1, abi_= long arg2) return get_errno(target_munmap(arg1, arg2)); } =20 +/* 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 d88f62319b..127805e079 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 =3D do_bsd_munmap(arg1, arg2); break; =20 + case TARGET_FREEBSD_NR_mprotect: /* mprotect(2) */ + ret =3D do_bsd_mprotect(arg1, arg2, arg3); + break; + #if defined(__FreeBSD_version) && __FreeBSD_version >=3D 1300048 case TARGET_FREEBSD_NR_shm_open2: /* shm_open2(2) */ ret =3D do_freebsd_shm_open2(arg1, arg2, arg3, arg4, arg5); --=20 2.42.0 From nobody Thu Nov 28 07:47:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1694234087; cv=none; d=zohomail.com; s=zohoarc; b=b5sQpKfbn1DHJd+2rtdG6+YqorwSI+ag/FfyI01dHhxkF7nf8tsdpZ66OtFcPOQn7bmvsAabu52bgRKpoMGEO2TqzlJt++3SpRzozFkm+vPv5Ewacaf1lj/sao67Ls9PqmFPu3E4HNlX8ta4fDU4JGww/7sSoEyCIgUjvhjGers= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694234087; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=31oTqmQfxy5Vixb6rYMspPtmbe4ijKJWcWRToEaaBS4=; b=kHIQVBzJfp2UY1WTsfDBrnz47sliWr6WheXIaLsAbXrPR0HnKxrmaRFQ1Q/Im4BpwzMckz4DJeNosuZ9K1wI1MtIg+TSuEW4KWk75UTUo8Ull10Iu1pzrh5Q908Xg0QqgQ9PNnDXQT+vxgAJmxJolEEoTessxT0joPh8IgO1SN4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694234087557510.832448728671; Fri, 8 Sep 2023 21:34:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qepfX-00015c-GN; Sat, 09 Sep 2023 00:34: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 1qepfP-00012M-Nh for qemu-devel@nongnu.org; Sat, 09 Sep 2023 00:33:57 -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 1qepfN-0002xM-Fe for qemu-devel@nongnu.org; Sat, 09 Sep 2023 00:33:55 -0400 Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-31c479ede21so2623679f8f.2 for ; Fri, 08 Sep 2023 21:33:52 -0700 (PDT) Received: from karim.my.domain ([197.39.120.250]) by smtp.gmail.com with ESMTPSA id d16-20020adff2d0000000b0031981c500aasm3615102wrp.25.2023.09.08.21.33.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Sep 2023 21:33:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694234031; x=1694838831; darn=nongnu.org; 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=31oTqmQfxy5Vixb6rYMspPtmbe4ijKJWcWRToEaaBS4=; b=FNbvQqFwZ6H//H7x76ry1/5Soumk8+U5FgKnz/8fs9oTNL74mus+uC1TPmh80JqrlE fcepVsNFUZnDAUgG1B91q5domz9jvB5ojIHWdcN+VtSWU+C1E/UPkHMAQBnSuOz35eov j3HZxW83ulLXphGg8fCPj7LIcAFb8IyORI1P2X5xHrAI2eISZSSkt4Ppuvq3f12XIXUo DcBXoWydbBlIeGNgusiKQKKY78moBkD4SGtdxDaNmzkaGhybcat9J8uckMVKZd5zzCp6 03Fn6OQdLQ/lXvNKKM98DNVeW569f4XrLdD14dzc3vwjB37i6r7EVzF0UdumjAbGE5ii szMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694234031; x=1694838831; 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=31oTqmQfxy5Vixb6rYMspPtmbe4ijKJWcWRToEaaBS4=; b=dPmD2sQRILjQ+6emCBcLPseUt93QsrhjsQE1H6AFUwqh6GvJDk6QfSqweB54PGLHey c93/vHVdjS5MJ1VF3TFbdqKgoYoyTk923nS9MgRX5rz686eIYuJ107MNIklBcauzcfPO OvRxshYdGQulifrshzvPcpQK0iz9IxXWxX8IydQDk5J2KUWGQveziYlDiuSZpTlKEXs9 uvd6JTaFQTtKV21l9YUYzrYKjqAwl3vSWsz9/1p1hl0CcvUnMR05fxTSbG4krzpyNEig S1BR/t4QjRFYqMsZ/mAAlUcYB4tB55eUNzLArjWx4vo3NVtIjhFeCb0Vg7bd4VuFJgJt 8CgA== X-Gm-Message-State: AOJu0YyOQhe1Yr+073B7pt3x5xhnwX+mWqJ89AgD6+hLRC8+l5klmhvI btwCbCk5JSiJH6AjBZvge8/wPKedLLU= X-Google-Smtp-Source: AGHT+IHvlS0rqz8GceEoGA4gmcsGiQuMTXdA5Ou/7t5LoS0uP0nIcf54Kg5ItS9ttSr8AkoAF7rivA== X-Received: by 2002:a5d:4086:0:b0:313:f4e2:901d with SMTP id o6-20020a5d4086000000b00313f4e2901dmr3062427wrp.22.1694234031023; Fri, 08 Sep 2023 21:33:51 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: imp@bsdimp.com, Stacey Son , Kyle Evans , Karim Taha , Richard Henderson Subject: [PATCH v2 14/23] bsd-user: Implement msync(2) Date: Thu, 7 Sep 2023 09:42:53 +0200 Message-ID: <20230907074302.79234-15-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230907074302.79234-1-kariem.taha2.7@gmail.com> References: <20230907074302.79234-1-kariem.taha2.7@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: 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: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_24_48=1.34, 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=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1694234088048100001 Content-Type: text/plain; charset="utf-8" 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 0f9e4a1d4b..5e885823a7 100644 --- a/bsd-user/bsd-mem.h +++ b/bsd-user/bsd-mem.h @@ -88,4 +88,15 @@ static inline abi_long do_bsd_mprotect(abi_long arg1, ab= i_long arg2, return get_errno(target_mprotect(arg1, arg2, arg3)); } =20 +/* msync(2) */ +static inline abi_long do_bsd_msync(abi_long addr, abi_long len, abi_long = flags) +{ + if (!guest_range_valid_untagged(addr, len)) { + /* It seems odd, but POSIX wants this to be ENOMEM */ + 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 127805e079..859492dee7 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 =3D do_bsd_mprotect(arg1, arg2, arg3); break; =20 + case TARGET_FREEBSD_NR_msync: /* msync(2) */ + ret =3D do_bsd_msync(arg1, arg2, arg3); + break; + #if defined(__FreeBSD_version) && __FreeBSD_version >=3D 1300048 case TARGET_FREEBSD_NR_shm_open2: /* shm_open2(2) */ ret =3D do_freebsd_shm_open2(arg1, arg2, arg3, arg4, arg5); --=20 2.42.0 From nobody Thu Nov 28 07:47:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1694234232; cv=none; d=zohomail.com; s=zohoarc; b=hzSIlvVrSiUhjw8QXZ2QYGvURshCYLUy21QzbOn5/F4xMtKqmmWdvvM8T8m32H74LB6eVmhTVRY+M9t7ELIK/r7ha7apkypEhAnDU9U0Ih9jNAwrpqGv2nE8WqA0PRatT3/kYQD0bj/Mv1zJWOYMEb09CD8R4tuxxdJpvKKiE4A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694234232; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=0nAYdR+eSimunrq+5ySm3v4Uk13qn/HpDgGI/X8dRrQ=; b=HdBdZ8rEW+J6UaatdURcgl1HtdhKTuPGGaSh9oy1kAIQ9Jlc+1j90L3VM+RlM+2LfJTFTjfyhOpFbfpYv6IcbqZzHXGLMxvfXmlBTlNrJbxl+LpBbX8nkGCafX5mRDBHC6yvhwh5WUZ2wH3oBhjgLQVyS1VBJkknkd23by6hTgo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694234232211809.3911099372164; Fri, 8 Sep 2023 21:37:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qepfW-00015b-VQ; Sat, 09 Sep 2023 00:34: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 1qepfQ-00012R-KD for qemu-devel@nongnu.org; Sat, 09 Sep 2023 00:33:57 -0400 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qepfO-0002xS-3c for qemu-devel@nongnu.org; Sat, 09 Sep 2023 00:33:56 -0400 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-401b5516104so28926405e9.2 for ; Fri, 08 Sep 2023 21:33:53 -0700 (PDT) Received: from karim.my.domain ([197.39.120.250]) by smtp.gmail.com with ESMTPSA id d16-20020adff2d0000000b0031981c500aasm3615102wrp.25.2023.09.08.21.33.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Sep 2023 21:33:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694234032; x=1694838832; darn=nongnu.org; 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=0nAYdR+eSimunrq+5ySm3v4Uk13qn/HpDgGI/X8dRrQ=; b=QxT8L1rLtjr8N8212QIr84PEYxwxQM+G4+OeA7+bV8X5TS6s4+KWWJHVuTqcRnuRQB wjT6NpkfdpIkzbfTWjqpw3lI2eNRGH3iUn9hf48RDwuzeBS3zuBcE+jlw/zmY6CulnM1 ClxiMcdnnQ1I+fPBpucmtvJde8Un1xyAI5Ef2+jwPU7CckyqeuokEigvdqLL5F8YWpNs eR7WsBb3cp23klK0ZMXJyA/xedpi3u6Uu+rfVaDmWw7SdBKeSe04Jz22t4+KQ8skmPOR AbcFqU1Ywl3njT1cOepwwEi5evExfgbNGlJ323QFpQjQYVnK5bwkLPXXoZhyafesOH7K f6ew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694234032; x=1694838832; 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=0nAYdR+eSimunrq+5ySm3v4Uk13qn/HpDgGI/X8dRrQ=; b=f9dYcf+m82eaTOVVDcdei8SVne3X1JQC8TxmLQZr2S/hRiRZEnp5Gy/yQ2bgXifmlB CnAANvaGWYkA2Giv3ls+2kXi7nb2fLX0oBU1sW6BmuJX0pKFx7GzaIiCagNsZtTs5Zuv SCZNc7PEBbNH00igG3ZahhBlCySVD6QHhCe1UiWMDKIvtRR9O+vtM0yxjs+yL0ZK0r6d miKFLQUtn0st4Xd8855jiS26Tebh1XsUZR8uGrMHyafuZXafubiaz6msw42NUfz0Ij/o a3kWt0QEAkigy9CfM6KY//ITY/udIXY5B8qRZeWisYs2jprRJWZ6tGzrODwEgmOVuPL8 Zl5Q== X-Gm-Message-State: AOJu0YyOUgdEb1SsDG0UwjrCJezCNUKWruvOt5w4WxbI1FrH09FWVMK4 6NfJLtPDDZqdulXlwXLgYTDNRug7GKI= X-Google-Smtp-Source: AGHT+IE+jLnLYskFB1OpGlI7kPhbzFrEeQJC0eDFsLCXv8NQz32d+wH3aseNdeZc/FfsPGXXQ/7vNw== X-Received: by 2002:a5d:4851:0:b0:316:ee7f:f9bb with SMTP id n17-20020a5d4851000000b00316ee7ff9bbmr3367393wrs.65.1694234032377; Fri, 08 Sep 2023 21:33:52 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: imp@bsdimp.com, Stacey Son , Karim Taha , Richard Henderson Subject: [PATCH v2 15/23] bsd-user: Implement mlock(2), munlock(2), mlockall(2), munlockall(2), minherit(2) Date: Thu, 7 Sep 2023 09:42:54 +0200 Message-ID: <20230907074302.79234-16-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230907074302.79234-1-kariem.taha2.7@gmail.com> References: <20230907074302.79234-1-kariem.taha2.7@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wm1-x336.google.com X-Spam_score_int: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_24_48=1.34, 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=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1694234232556100001 Content-Type: text/plain; charset="utf-8" From: Stacey Son Signed-off-by: Stacey Son Signed-off-by: Karim Taha Reviewed-by: Richard Henderson --- bsd-user/bsd-mem.h | 37 +++++++++++++++++++++++++++++++++++ bsd-user/freebsd/os-syscall.c | 20 +++++++++++++++++++ 2 files changed, 57 insertions(+) diff --git a/bsd-user/bsd-mem.h b/bsd-user/bsd-mem.h index 5e885823a7..16c22593bf 100644 --- a/bsd-user/bsd-mem.h +++ b/bsd-user/bsd-mem.h @@ -99,4 +99,41 @@ static inline abi_long do_bsd_msync(abi_long addr, abi_l= ong len, abi_long flags) return get_errno(msync(g2h_untagged(addr), len, flags)); } =20 +/* mlock(2) */ +static inline abi_long do_bsd_mlock(abi_long arg1, abi_long arg2) +{ + if (!guest_range_valid_untagged(arg1, arg2)) { + return -TARGET_EINVAL; + } + return get_errno(mlock(g2h_untagged(arg1), arg2)); +} + +/* munlock(2) */ +static inline abi_long do_bsd_munlock(abi_long arg1, abi_long arg2) +{ + if (!guest_range_valid_untagged(arg1, arg2)) { + return -TARGET_EINVAL; + } + 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()); +} + +/* 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 859492dee7..6eaa705cd3 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -503,6 +503,26 @@ static abi_long freebsd_syscall(void *cpu_env, int num= , abi_long arg1, ret =3D do_bsd_msync(arg1, arg2, arg3); break; =20 + case TARGET_FREEBSD_NR_mlock: /* mlock(2) */ + ret =3D do_bsd_mlock(arg1, arg2); + break; + + case TARGET_FREEBSD_NR_munlock: /* munlock(2) */ + ret =3D do_bsd_munlock(arg1, arg2); + break; + + case TARGET_FREEBSD_NR_mlockall: /* mlockall(2) */ + ret =3D do_bsd_mlockall(arg1); + break; + + case TARGET_FREEBSD_NR_munlockall: /* munlockall(2) */ + ret =3D do_bsd_munlockall(); + break; + + case TARGET_FREEBSD_NR_minherit: /* minherit(2) */ + ret =3D do_bsd_minherit(arg1, arg2, arg3); + break; + #if defined(__FreeBSD_version) && __FreeBSD_version >=3D 1300048 case TARGET_FREEBSD_NR_shm_open2: /* shm_open2(2) */ ret =3D do_freebsd_shm_open2(arg1, arg2, arg3, arg4, arg5); --=20 2.42.0 From nobody Thu Nov 28 07:47:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1694234079; cv=none; d=zohomail.com; s=zohoarc; b=JPgB2TNJtZ4HjhVhpW8eNUpC7kYHJvHPOEczTjuS2MJBQQCe2a6G112PG+y8z24CkIrhqdh57AZ7OYX30mbo5a8YXSd5wp0z5CVBHdCwAzKu5LllQo3x6l+scUD1YstuXMIkUFr+a5Q+WFcKmKHnemSwhtbcaNFbzC6l0bvx+ug= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694234079; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=wVHZ2gTKJUTTUFCrTx1jb9XTLg6fK+kTZHzI2+VVFKw=; b=IPl8R+TeLgqdL6BxEUVLOk5xaD/TJsAXimrPvMBDbBJTf7mqne+tMP9w9VMaq4QNCLqy4pOZWoqXwgwqlOH0ykBwcF3BhSOuT9E9/27bgBbHQ5JiBZ7AGGER7mmePzTYSLj3di0Tae0AXP2jyCVGcW6u5rT3Vn2W6ZKq50/8+cQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694234079767147.72732079477953; Fri, 8 Sep 2023 21:34:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qepfe-00017R-3b; Sat, 09 Sep 2023 00:34:11 -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 1qepfR-00012Z-Kz for qemu-devel@nongnu.org; Sat, 09 Sep 2023 00:33:57 -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 1qepfP-0002xl-7n for qemu-devel@nongnu.org; Sat, 09 Sep 2023 00:33:57 -0400 Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-31c5c06e8bbso2653375f8f.1 for ; Fri, 08 Sep 2023 21:33:54 -0700 (PDT) Received: from karim.my.domain ([197.39.120.250]) by smtp.gmail.com with ESMTPSA id d16-20020adff2d0000000b0031981c500aasm3615102wrp.25.2023.09.08.21.33.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Sep 2023 21:33:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694234033; x=1694838833; darn=nongnu.org; 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=wVHZ2gTKJUTTUFCrTx1jb9XTLg6fK+kTZHzI2+VVFKw=; b=iCqwmeO0EnxnJjr2YY3P6eXuTl9zk2spHceR/WJln6TdviAXPvnHG08qOO8pVnKJH/ PldNsJWuYwNf9C/JVPnRyqv9asTOtSK6OUFbyoUz/golMYIg0DM0GA+P+uRg1hZKUhY9 nJEZt+GpXgkHx/haGaraoQLvZpU8I8LYKLWGpWjy4U40s7pb7seqV7QmdvYg5QizwJFr uCtzZL2TPQ3+rIiZ6VgqDI503TNROcjEWwN6ujffhHOf/WXtR+DRTH+8Ng8XuzyY2KAK e6MybsR3JMx0rN7V4AXYgM/GfoHjLT9RKJm5mlNfdEbWSg8nCxp+qn3FTrjxYUk4Dm2+ Aw/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694234033; x=1694838833; 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=wVHZ2gTKJUTTUFCrTx1jb9XTLg6fK+kTZHzI2+VVFKw=; b=Qag73A6NMZD7MLX7656fk3N1g/HB7pJFBM4DGWGdeMer32gJWR39a7Fv5TB2Et2Nqr Max7k3BhderQMEh+z6mcrd/E5VfY4dMvIy3Gh6qOY4RfYIkCj0Ix+HeQATtgJYlFWM1b +Rc09W/cXm9NJJQO7c6wmvkcVw94ijD5SsgBF+icW2QQrAqTFxvjLbdJiKZhPZg3SUFv NOmSjfepeFkWWWWafXLqfI6zBWRDruNgUjKGyA5c9b4ygKd7cQQI7UxBV2Fpz42CRca4 JIlZM+R4rDE52YzTAz+ANfksNR/MfQx3QulHnVJBY43A7nuN2PHVWRf+uh5Po7ebP8K8 wRpw== X-Gm-Message-State: AOJu0YybIvvQVTIjHbcffJrBDjF8xDqqLspqZGqTDdudBUEQARqaI/I1 uxcqRHynasIxTF0tgOnwhBXVBrcd8Q4= X-Google-Smtp-Source: AGHT+IGnNS0XDqLqyth/1uRrGH+ZcKBRDO4ToiPvlmTFgUKUfnDkLs3at7+S4H03/2d/T90c0vF/xQ== X-Received: by 2002:a5d:5709:0:b0:318:f7a:e3cb with SMTP id a9-20020a5d5709000000b003180f7ae3cbmr3389656wrv.31.1694234033506; Fri, 08 Sep 2023 21:33:53 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: imp@bsdimp.com, Karim Taha Subject: [PATCH v2 16/23] bsd-user: Implment madvise(2) to match the linux-user implementation. Date: Thu, 7 Sep 2023 09:42:55 +0200 Message-ID: <20230907074302.79234-17-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230907074302.79234-1-kariem.taha2.7@gmail.com> References: <20230907074302.79234-1-kariem.taha2.7@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: 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: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_24_48=1.34, 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=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1694234081938100018 Content-Type: text/plain; charset="utf-8" Signed-off-by: Signed-off-by: Karim Taha --- bsd-user/bsd-mem.h | 53 +++++++++++++++++++++++++++++++++++ bsd-user/freebsd/os-syscall.c | 4 +++ bsd-user/syscall_defs.h | 2 ++ 3 files changed, 59 insertions(+) diff --git a/bsd-user/bsd-mem.h b/bsd-user/bsd-mem.h index 16c22593bf..0e16051418 100644 --- a/bsd-user/bsd-mem.h +++ b/bsd-user/bsd-mem.h @@ -129,6 +129,59 @@ static inline abi_long do_bsd_munlockall(void) return get_errno(munlockall()); } =20 +/* madvise(2) */ +static inline abi_long do_bsd_madvise(abi_long arg1, abi_long arg2, + abi_long arg3) +{ + abi_ulong len; + int ret =3D 0; + abi_long start =3D arg1; + abi_long len_in =3D arg2; + abi_long advice =3D arg3; + + if (start & ~TARGET_PAGE_MASK) { + return -TARGET_EINVAL; + } + if (len_in =3D=3D 0) { + return 0; + } + len =3D TARGET_PAGE_ALIGN(len_in); + if (len =3D=3D 0 || !guest_range_valid_untagged(start, len)) { + return -TARGET_EINVAL; + } + + /* + * Most advice values are hints, so ignoring and returning success is = ok. + * + * However, some advice values such as MADV_DONTNEED, are not hints and + * need to be emulated. + * + * A straight passthrough for those may not be safe because qemu somet= imes + * turns private file-backed mappings into anonymous mappings. + * If all guest pages have PAGE_PASSTHROUGH set, mappings have the + * same semantics for the host as for the guest. + * + * MADV_DONTNEED is passed through, if possible. + * If passthrough isn't possible, we nevertheless (wrongly!) return + * success, which is broken but some userspace programs fail to work + * otherwise. Completely implementing such emulation is quite complica= ted + * though. + */ + mmap_lock(); + switch (advice) { + case MADV_DONTNEED: + if (page_check_range(start, len, PAGE_PASSTHROUGH)) { + ret =3D get_errno(madvise(g2h_untagged(start), len, advice)); + if ((advice =3D=3D MADV_DONTNEED) && (ret =3D=3D 0)) { + page_reset_target_data(start, start + len - 1); + } + } + } + mmap_unlock(); + + return ret; +} + /* minherit(2) */ static inline abi_long do_bsd_minherit(abi_long addr, abi_long len, abi_long inherit) diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index 6eaa705cd3..f5d60cf902 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -519,6 +519,10 @@ static abi_long freebsd_syscall(void *cpu_env, int num= , abi_long arg1, ret =3D do_bsd_munlockall(); break; =20 + case TARGET_FREEBSD_NR_madvise: /* madvise(2) */ + ret =3D do_bsd_madvise(arg1, arg2, arg3); + break; + case TARGET_FREEBSD_NR_minherit: /* minherit(2) */ ret =3D do_bsd_minherit(arg1, arg2, arg3); break; diff --git a/bsd-user/syscall_defs.h b/bsd-user/syscall_defs.h index 074df7bdd6..76f4856009 100644 --- a/bsd-user/syscall_defs.h +++ b/bsd-user/syscall_defs.h @@ -95,6 +95,8 @@ struct bsd_shm_regions { /* * sys/mman.h */ +#define TARGET_MADV_DONTNEED 4 /* dont need these pages */ + #define TARGET_FREEBSD_MAP_RESERVED0080 0x0080 /* previously misimplement= ed */ /* MAP_INHERIT */ #define TARGET_FREEBSD_MAP_RESERVED0100 0x0100 /* previously unimplemente= d */ --=20 2.42.0 From nobody Thu Nov 28 07:47:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1694234161; cv=none; d=zohomail.com; s=zohoarc; b=QgGAopK63kkTjv6sgOJOy9QLZyC91pbZont/1zYl91R/o0keZzu6Q8a76KfYCVLopJeylksZ8vP1UtCcGn3erqZqFjQUGpnGiav8WXAmTNYOUFuZCMwHHm5VeXbC1++dzP6QJI5LDtD9O+a3nlChogBDBnoPYTiKQRdZYvjTPO8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694234161; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=PVDg2xAqYdL1qO9Pj5OML28yXvjot1xjk5EVQ6V643o=; b=Xn9Ie8s2dw9XyA8qb1xoZfAYPrWYhvx8HN/xAjP9vKMx6/m7hwLhm9Olb4eMoq43iOWVkMDrtatf61JfZ6zbs5VFicGEWZ6l40EiYM+yuhLTJOoNjU4kwadcchK7fMwHNapcxE0dl98POXgw/17P1g2SdyPTRGsLEOQAQcURFiU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694234161747401.5538331552699; Fri, 8 Sep 2023 21:36:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qepfk-00018f-Ka; Sat, 09 Sep 2023 00:34:16 -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 1qepfT-000138-PJ for qemu-devel@nongnu.org; Sat, 09 Sep 2023 00:34:01 -0400 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qepfQ-0002xu-Ea for qemu-devel@nongnu.org; Sat, 09 Sep 2023 00:33:59 -0400 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-3ff7d73a6feso27972005e9.1 for ; Fri, 08 Sep 2023 21:33:56 -0700 (PDT) Received: from karim.my.domain ([197.39.120.250]) by smtp.gmail.com with ESMTPSA id d16-20020adff2d0000000b0031981c500aasm3615102wrp.25.2023.09.08.21.33.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Sep 2023 21:33:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694234035; x=1694838835; darn=nongnu.org; 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=PVDg2xAqYdL1qO9Pj5OML28yXvjot1xjk5EVQ6V643o=; b=gB5wjVuIk+ob99Ksn9aK2uuYeHC2nuSaHJ7feHr5x5GzehmMAjvDvaeAbJWcNgatT+ SMhtRaE3paWFvTVBq6AieUObnQhxzMfhJYgIPg6nrsNjwBc5Fm7ybrY80+VAEF1HnQzo t3ekc55UYAeE1BJ0uNVUB0ztqn/URqoT93biY5mbcF6jkMMFVYo4N6/HfrkUrgJvH5jo ydrCyyEZReZ24lIPqju+pZc5Bh1cTXJE+00AOVafVDVVbrlm9KqP1BYnsXhzuZm8lDsO WASFthwIWuhuzEmQrXmlk7At9KrkJwjvYiGV0V61RPltN310MRp8ZK8noIddI44uiXIF 09ug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694234035; x=1694838835; 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=PVDg2xAqYdL1qO9Pj5OML28yXvjot1xjk5EVQ6V643o=; b=d1c2gXzj7wkXQZOmD1ZMPHe1J6d7lG16u6T4tWR7YwVkyGQDg50e7iNzP4TwKDoy+r sUY0OwAmDMFQn2k0MdpS24b47QCDtJar21e/hPRBvoNyLFRsihzVQtv3PL5rRObskPKh S+FpEpQHW2ApsdL2KWyf4WGnat0hAJlGA2bcbsru4kWOk5d7rFsKXHfEaV8dC/Y92ySQ ZUyx52+kYMwPbj4bOIqP7vzJRUrh5004fTkq5bSeu7pa/Jv0jHD+Wk+2DqSwO8qZrGyJ GQi15m1Hpopc1/ueM6AR4x//TqdJgbRAShBPcde6IPBB1QBdEMfv9Zuq7CA5iltWxRHU fptg== X-Gm-Message-State: AOJu0Yz4kuyiKd8ARzI0tpWHOyIZwpnwrdjoCL2HORJnHzk2l/ufRvml w9fG2oFp730StQBgkpLNp2dGfuG3ZcI= X-Google-Smtp-Source: AGHT+IE2cbNsP7YFaBbMLwBnvcBGZlf2DWntxGCxmMIyw+W4U1p4NgyQawP9UF+Uzh/qMAEqdZlJfQ== X-Received: by 2002:a05:600c:2943:b0:3fb:feb0:6f40 with SMTP id n3-20020a05600c294300b003fbfeb06f40mr3984904wmd.11.1694234034727; Fri, 08 Sep 2023 21:33:54 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: imp@bsdimp.com, Stacey Son , Karim Taha Subject: [PATCH v2 17/23] bsd-user: Implement mincore(2) Date: Thu, 7 Sep 2023 09:42:56 +0200 Message-ID: <20230907074302.79234-18-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230907074302.79234-1-kariem.taha2.7@gmail.com> References: <20230907074302.79234-1-kariem.taha2.7@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::330; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wm1-x330.google.com X-Spam_score_int: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_24_48=1.34, 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=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1694234163826100003 Content-Type: text/plain; charset="utf-8" From: Stacey Son Signed-off-by: Stacey Son Signed-off-by: Karim Taha --- bsd-user/bsd-mem.h | 22 ++++++++++++++++++++++ bsd-user/freebsd/os-syscall.c | 4 ++++ 2 files changed, 26 insertions(+) diff --git a/bsd-user/bsd-mem.h b/bsd-user/bsd-mem.h index 0e16051418..1dabbe36e6 100644 --- a/bsd-user/bsd-mem.h +++ b/bsd-user/bsd-mem.h @@ -189,4 +189,26 @@ static inline abi_long do_bsd_minherit(abi_long addr, = abi_long len, return get_errno(minherit(g2h_untagged(addr), len, inherit)); } =20 +/* 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; + abi_ulong vec_len =3D DIV_ROUND_UP(len,TARGET_PAGE_SIZE); + + if (!guest_range_valid_untagged(target_addr,len) || !page_check_range(= target_addr, len, PAGE_VALID)) { + return -TARGET_EFAULT; + } + + p =3D lock_user(VERIFY_WRITE, target_vec, vec_len, 0); + if (p =3D=3D NULL) { + return -TARGET_EFAULT; + } + ret =3D get_errno(mincore(g2h_untagged(target_addr), len, p)); + unlock_user(p, target_vec, 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 f5d60cf902..8d1cf3b35c 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 =3D do_bsd_minherit(arg1, arg2, arg3); break; =20 + case TARGET_FREEBSD_NR_mincore: /* mincore(2) */ + ret =3D do_bsd_mincore(arg1, arg2, arg3); + break; + #if defined(__FreeBSD_version) && __FreeBSD_version >=3D 1300048 case TARGET_FREEBSD_NR_shm_open2: /* shm_open2(2) */ ret =3D do_freebsd_shm_open2(arg1, arg2, arg3, arg4, arg5); --=20 2.42.0 From nobody Thu Nov 28 07:47:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1694234212; cv=none; d=zohomail.com; s=zohoarc; b=Tn/Ib7zn+W52OoYLji48AFyrhtQurT3G8Hs4X3KPvRPDUIg4XhR6v+YqI3HUqjARy9N/hudnJjWPeE0ljUyoBotYd/SLI+iF5ORNfmGvLNXZ0YHwlJZsvSD/XEvZdBTBXQ5aBPCwk2tj7Jz3Ggizrl9LsAMHePFAusxDoZonWWI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694234212; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=1Y5YktBwcbxAJZtPbTx4kfRpV78Ai/r3dWCAljOp3c8=; b=FHuDJ3w50FhLBEstnmx4WcIc4R4tyXxfwE01qkIvaCXl2gcpmtaknKvDFHJrt2epGm9LC9FSUYBzwiqSL8Q34B9wbF3ZKHU8ablvTI1+pQuSp/wPgEFrbROyjK+mD8BW6visEF3mIEJYK4yGmWE96iDvvDCQnzcYRvQlnAlZMTA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694234212283344.98911115153703; Fri, 8 Sep 2023 21:36:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qepfa-00016F-Px; Sat, 09 Sep 2023 00:34:07 -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 1qepfW-00014y-1E for qemu-devel@nongnu.org; Sat, 09 Sep 2023 00:34:02 -0400 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qepfT-0002yD-2H for qemu-devel@nongnu.org; Sat, 09 Sep 2023 00:34:01 -0400 Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-31f737b8b69so2124492f8f.3 for ; Fri, 08 Sep 2023 21:33:57 -0700 (PDT) Received: from karim.my.domain ([197.39.120.250]) by smtp.gmail.com with ESMTPSA id d16-20020adff2d0000000b0031981c500aasm3615102wrp.25.2023.09.08.21.33.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Sep 2023 21:33:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694234036; x=1694838836; darn=nongnu.org; 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=1Y5YktBwcbxAJZtPbTx4kfRpV78Ai/r3dWCAljOp3c8=; b=D4ChmKh1Tn9+P/tWdkir9zzoJm27GQY+sO2BEFbx8kSAdrJ7XyJG1zv2jt/sl2E6uf s0+cFKyO20XXbFLPiqgXW5FWd4xNV3ayEyrGd+GrNLFxk2WZwcwhg5pU9/KTFhWi2ihs W6bfkYmn25jhx8RdxkhD2lx5G928ktpega3x0AKYmdLrbVlE+X2LhkZJyXWqX6wIeDWC pzwd/D0UOnWcKyrSIOdUwyDRemNxaG2BjPwoeoz4S/mlmL1WzdI9xRji944Q+uy4bXsL LOkTgafeo3WoYwMD5hU7eV8m0mS30FjDFFjYQPPJVBUvzz6oEhR4TlQ5/or8LXwoSgxg hbKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694234036; x=1694838836; 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=1Y5YktBwcbxAJZtPbTx4kfRpV78Ai/r3dWCAljOp3c8=; b=py9RLsJpLJSeUS6M7Iv/LYXKhGApON+2BJaAYiDmOwY+CzofubHglhL150GBgOktMS 5sdxMADrjGSQtYS9ZCjagwGBdxRdKnPk9hzy4Deb8p6r6p2q31cVquGmEEolqiK6J5cF +0wdSAe6cJiUjJHTwxYuNxKtLU176Us7dNyrKKyNuDbPazxOTI/frRdX+zDKxn8moGUX 6108z79l6tc6EKzfs+mBvAH1q3/C0PF+waSBtvbzqAgifGby3Le0WDtnATUvDInZFuZR Iw83BLGywVK4Qy/b0b72ByBTHAZQVjX2YKqggmDMrZvVZuVaU0pQm/izaWcSbZFWlb0c RzHQ== X-Gm-Message-State: AOJu0YzP/UkTB5m3v1ggZeX6ZQP5dEWse8hPxRKpblgnr8y6WLiUJwjR nJ1/KBap4h7gpoc83PhRUVCyhG9DsNo= X-Google-Smtp-Source: AGHT+IFtDA16hsJcE56Io4kzevCZYBNGr8CvgBbPDKw/VQ/2tLJAlDHcLIL33D/UTbDCh5aU6YMZTA== X-Received: by 2002:a5d:6441:0:b0:317:597b:9f92 with SMTP id d1-20020a5d6441000000b00317597b9f92mr3459857wrw.57.1694234035905; Fri, 08 Sep 2023 21:33:55 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: imp@bsdimp.com, Stacey Son , Karim Taha Subject: [PATCH v2 18/23] bsd-user: Implement do_obreak function Date: Thu, 7 Sep 2023 09:42:57 +0200 Message-ID: <20230907074302.79234-19-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230907074302.79234-1-kariem.taha2.7@gmail.com> References: <20230907074302.79234-1-kariem.taha2.7@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42b; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wr1-x42b.google.com X-Spam_score_int: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_24_48=1.34, 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=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1694234212577100001 Content-Type: text/plain; charset="utf-8" From: Stacey Son Match linux-user, by manually applying the following commits, in order: d28b3c90cfad1a7e211ae2bce36ecb9071086129 linux-user: Make sure initial br= k(0) is page-aligned 15ad98536ad9410fb32ddf1ff09389b677643faa linux-user: Fix qemu brk() to no= t zero bytes on current page dfe49864afb06e7e452a4366051697bc4fcfc1a5 linux-user: Prohibit brk() to to= shrink below initial heap address eac78a4b0b7da4de2c0a297f4d528ca9cc6256a3 linux-user: Fix signed math over= flow in brk() syscall c6cc059eca18d9f6e4e26bb8b6d1135ddb35d81a linux-user: Do not call get_errn= o() in do_brk() e69e032d1a8ee8d754ca119009a3c2c997f8bb30 linux-user: Use MAP_FIXED_NOREPL= ACE for do_brk() cb9d5d1fda0bc2312fc0c779b4ea1d7bf826f31f linux-user: Do nothing if too sm= all brk is specified 2aea137a425a87b930a33590177b04368fd7cc12 linux-user: Do not align brk wit= h host page size Signed-off-by: Stacey Son Signed-off-by: Karim Taha --- bsd-user/bsd-mem.h | 45 +++++++++++++++++++++++++++++++++++ bsd-user/freebsd/os-syscall.c | 7 ++++++ 2 files changed, 52 insertions(+) diff --git a/bsd-user/bsd-mem.h b/bsd-user/bsd-mem.h index 1dabbe36e6..563f82996b 100644 --- a/bsd-user/bsd-mem.h +++ b/bsd-user/bsd-mem.h @@ -211,4 +211,49 @@ static inline abi_long do_bsd_mincore(abi_ulong target= _addr, abi_ulong len, return ret; } =20 +/* do_brk() must return target values and target errnos. */ +static inline abi_long do_obreak(abi_ulong brk_val) +{ + abi_long mapped_addr; + abi_ulong new_brk; + abi_ulong old_brk; + + /* brk pointers are always untagged */ + + /* do not allow to shrink below initial brk value */ + if (brk_val < initial_target_brk) { + return target_brk; + } + + new_brk =3D TARGET_PAGE_ALIGN(brk_val); + old_brk =3D TARGET_PAGE_ALIGN(target_brk); + + /* new and old target_brk might be on the same page */ + if (new_brk =3D=3D old_brk) { + target_brk =3D brk_val; + return target_brk; + } + + /* Release heap if necesary */ + if (new_brk < old_brk) { + target_munmap(new_brk, old_brk - new_brk); + + target_brk =3D brk_val; + return target_brk; + } + + mapped_addr =3D target_mmap(old_brk, new_brk - old_brk, + PROT_READ | PROT_WRITE, + MAP_FIXED | MAP_EXCL | MAP_ANON | MAP_PRIVAT= E, + -1, 0); + + if (mapped_addr =3D=3D old_brk) { + target_brk =3D brk_val; + return target_brk; + } + + /* For everything else, return the previous break. */ + return 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 8d1cf3b35c..8dd29fddde 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 =20 + /* + * Misc + */ + case TARGET_FREEBSD_NR_break: + ret =3D do_obreak(arg1); + break; + /* * sys{ctl, arch, call} */ --=20 2.42.0 From nobody Thu Nov 28 07:47:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1694234121; cv=none; d=zohomail.com; s=zohoarc; b=JHCJ7CsE0fLVZggc/QZEYTZaTmP/FHiFuKBxkfey4uFqyiiKlF5hmj8qf4BJaJ9c/lZizoqUNuVLh/EgQV6fABMH/KwujmnPpLJwRDuSpCJa6RKL8F3mnOb3e+5mY+UvO8qhq25khhuhBUbv6nWey9Hge6CSZXixDTjCvjr/9kw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694234121; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=cX+7Sbgns+rSwompoLBGZfd8MuLrC9uQYC/4gYAWdEU=; b=jbtnS/SUMAA53l27Ioe1lPmMHT+D7d4O/hXws+8QsgMZbxyxuIi6BBsBiBX5c5M/x+C+R4UrxTFv7cyeoaQliwW8Ltro4w6DCBiMVgsGmxShjanp7Y7RGZlC/yrYf20j3LnD+ihogUaOEgZYaXQ3z9w8H6CDhA+1daekM1zW3Og= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694234121204573.8815710565227; Fri, 8 Sep 2023 21:35:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qepfo-000191-Lm; Sat, 09 Sep 2023 00:34:20 -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 1qepfg-000189-Uw for qemu-devel@nongnu.org; Sat, 09 Sep 2023 00:34:12 -0400 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qepfT-0002yU-OX for qemu-devel@nongnu.org; Sat, 09 Sep 2023 00:34:12 -0400 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-401c90ed2ecso28587345e9.0 for ; Fri, 08 Sep 2023 21:33:59 -0700 (PDT) Received: from karim.my.domain ([197.39.120.250]) by smtp.gmail.com with ESMTPSA id d16-20020adff2d0000000b0031981c500aasm3615102wrp.25.2023.09.08.21.33.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Sep 2023 21:33:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694234037; x=1694838837; darn=nongnu.org; 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=cX+7Sbgns+rSwompoLBGZfd8MuLrC9uQYC/4gYAWdEU=; b=LYA/rNFNXzhJRTDHnP/VJxaSaexsM3SHSUXsASn9gXfxdAZ1XTFaOANZQDC3dwq4bu 4OAPY2Vrh+pTUOo4hxYPDGruIHKWquVZih68l2kgIeotZKBP5EFgePafbsfYsIP7KUpm uIPeanMiLb2SppEE9oWTOwRs9RnBgpE+xyHJFfnO2gTbIbqPAjg766YGKVihZouTNqHc L+6piRS3IqNlgYvduLc5A7Uxo3wbLXLwYaGoEsUUqfo9C9kJypb6Ha8eyImUwzzCOdsY /7iVBOn4fraCsfm8lc8ETlaG2FTuJCGCjo8u4DAlDlgaICs+2srMUJMTfuzLt0IqTrja QRuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694234037; x=1694838837; 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=cX+7Sbgns+rSwompoLBGZfd8MuLrC9uQYC/4gYAWdEU=; b=JxaSKyfe9uivjXUlK09TXuboiqHJoZrkofxriTLh0KCA6U3RmjjRF7nEQ9/caHd2CD j77NvprzVQ/jBF63ibXJTTtiKIr4S7cxDzOWGH7gvrTGdHKiuLDbo+MQh/P/33yzvC1C 8ZfrhjVJBmmBZn0lm3YCQkp4H1M03Zbvi+jSKsZffmZH4FWb+w0TXL6krAp1TsAUee5F TSQcshLCuEE4ggitbeMyWOV7tKa5WbR+QNuHTPPrlLNLz8yo691VKbxTZf18XIDeC8Dn 0ny3FoCuirYhkJulU3fb93bC5SxxE7w8Om4hIrvKVQgL36xmOQ+foYl67KhAAxd0CSpe ptoQ== X-Gm-Message-State: AOJu0Yzmyg8MhUSeF0sCc04HxShTExn+JCU/wlRMNPyPIhJGoGbJ+QbM K97Pywp32yWOmoemTA611dqofJOkXfU= X-Google-Smtp-Source: AGHT+IE29SppKtWAP1cO+4FAqCktDotOi8aTc8gXwhUiH+BZvULziqU9qhLN1EPEnaEjOTvGYwCOrQ== X-Received: by 2002:a7b:cb8a:0:b0:401:73b2:f039 with SMTP id m10-20020a7bcb8a000000b0040173b2f039mr3661124wmi.7.1694234037201; Fri, 08 Sep 2023 21:33:57 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: imp@bsdimp.com, Stacey Son , Kyle Evans , Karim Taha Subject: [PATCH v2 19/23] bsd-user: Implement shm_open(2) Date: Thu, 7 Sep 2023 09:42:58 +0200 Message-ID: <20230907074302.79234-20-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230907074302.79234-1-kariem.taha2.7@gmail.com> References: <20230907074302.79234-1-kariem.taha2.7@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32b; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wm1-x32b.google.com X-Spam_score_int: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_24_48=1.34, 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1694234123059100002 Content-Type: text/plain; charset="utf-8" From: Stacey Son Co-authored-by: Kyle Evans Signed-off-by: Stacey Son Signed-off-by: Kyle Evans Signed-off-by: Karim Taha --- bsd-user/bsd-mem.h | 25 +++++++++++++++++++++++++ bsd-user/freebsd/os-syscall.c | 4 ++++ 2 files changed, 29 insertions(+) diff --git a/bsd-user/bsd-mem.h b/bsd-user/bsd-mem.h index 563f82996b..a48f919ff2 100644 --- a/bsd-user/bsd-mem.h +++ b/bsd-user/bsd-mem.h @@ -256,4 +256,29 @@ static inline abi_long do_obreak(abi_ulong brk_val) return target_brk; } =20 +/* shm_open(2) */ +static inline abi_long do_bsd_shm_open(abi_ulong arg1, abi_long arg2, + abi_long arg3) +{ + int ret; + void *p; + + if (arg1 =3D=3D (uintptr_t)SHM_ANON) { + p =3D SHM_ANON; + } else { + p =3D lock_user_string(arg1); + if (p =3D=3D NULL) { + return -TARGET_EFAULT; + } + } + ret =3D get_errno(shm_open(p, target_to_host_bitmask(arg2, fcntl_flags= _tbl), + arg3)); + + if (p !=3D SHM_ANON) { + unlock_user(p, arg1, 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 8dd29fddde..7404b0aa72 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 =3D do_bsd_mincore(arg1, arg2, arg3); break; =20 + case TARGET_FREEBSD_NR_freebsd12_shm_open: /* shm_open(2) */ + ret =3D do_bsd_shm_open(arg1, arg2, arg3); + break; + #if defined(__FreeBSD_version) && __FreeBSD_version >=3D 1300048 case TARGET_FREEBSD_NR_shm_open2: /* shm_open2(2) */ ret =3D do_freebsd_shm_open2(arg1, arg2, arg3, arg4, arg5); --=20 2.42.0 From nobody Thu Nov 28 07:47:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1694234123; cv=none; d=zohomail.com; s=zohoarc; b=eBMDUhVvUoI9x982dMHXddYOpRSXj9f1KIOEiaxLym96GAFYEqMCl0nfzEWtRa3tMWOENN8amIGyxETYMoQezBPEnNbp12hVnSq1s9eAm21qSaT7harNkRTcG+PBuGGG6r9Cz1CSkXHkCvXGKZW1miIIb6XSYoGNSUaDTu9Wk2M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694234123; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=7gLIXJm83In4ehfDWmTTDmbWjCCrqaLS41dVOxq/Wi8=; b=mM6HsFxBPK3mmwIHoNBLAsLkgTzMdWzaRFY09pFzgsVysKioowoLg9oDmaYyoyk/jegQbe5I1bN70DCNNBIkXXoY8nNrACVLXh1uxEdbUhi4R+4FCyohLa7KAFeEooL6ceDsey+A4XDq5Q9Fv41svh0nNPruQTNC5odP9bqd2Yg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694234123095650.3478946161488; Fri, 8 Sep 2023 21:35:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qepfp-00019x-NH; Sat, 09 Sep 2023 00:34: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 1qepfm-00018m-UA for qemu-devel@nongnu.org; Sat, 09 Sep 2023 00:34:18 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qepfX-0002yd-5W for qemu-devel@nongnu.org; Sat, 09 Sep 2023 00:34:17 -0400 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-40078c4855fso28893615e9.3 for ; Fri, 08 Sep 2023 21:34:00 -0700 (PDT) Received: from karim.my.domain ([197.39.120.250]) by smtp.gmail.com with ESMTPSA id d16-20020adff2d0000000b0031981c500aasm3615102wrp.25.2023.09.08.21.33.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Sep 2023 21:33:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694234038; x=1694838838; darn=nongnu.org; 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=7gLIXJm83In4ehfDWmTTDmbWjCCrqaLS41dVOxq/Wi8=; b=AwooZAY5KN6+yvybTYFkO6615XZ+RXeQBs20J21nLGY4WkkR7dwT1IHw83vgcP6T/b j9Xw5DZqoAIj1sirUXccKAV+iDbKp6nqZMi641gNC2hV0t16wGjJ+qCHJEm0p7v3QhWA F6P03CSQXzXJCKzQuKJnceET/FSqJpLpT03OuTz+fF6qYHuWkiykTdk4XeqOGsgbYcTr c8UAyJAJRP5FXBqUyRSarG98LJr25YrG0yUHDeiOZQ9M24uTOO0PNZG3RjEsj5g2FmSr qELinQGx38G5INAYuU/oMnKAtPBaWvXbSFCY8nh1jEru6S5uQeMeHnpzWWzm3U6ljRgs 2Qkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694234038; x=1694838838; 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=7gLIXJm83In4ehfDWmTTDmbWjCCrqaLS41dVOxq/Wi8=; b=JeUmC1n1DqNHav9m3Av3VsGhbzFEO0nQBjQWd+OAFCSPoURGW6m/U8GDtZFFx+kf5K uFG/Fcuouvg/mwkonwihNGZlJEqrNphw4nEo7OhTwGo7V1rR7phUN9BMw8G+kPoY9i6w 2cFPFnHTvFJOmit/lU8BzPcxIvS5CBI2JNyjGi5oM8XNlbvH6a/GAtnQMIXAkoIIOWlS nUnDZTuVTmuP1FQH4Ogv7CyCwa5a9qQZrZLSdFFukkxT0SvIsjFtrHWDlQcnJDKOjTBL egXAgGBZoVLnwgc0W84jgPuJfDfR+gWhavoqYnOy/suC0CsjcuSs/iGNuMthX+nYpwgd e/Mg== X-Gm-Message-State: AOJu0YygBifo72Vh1/rr/WDjS5BYTUsEAQVkYwXnCv/yvvTVl93EhAvl huRZE4RkdN3H5LwwNvbuQuP1VWD/l24= X-Google-Smtp-Source: AGHT+IFYst0OtV655f1J3NPUFBv6Bb3p3bv2jGzkHyH4EiCuZeVVtBOswQ2Upte5+qMSexAMEVIkFQ== X-Received: by 2002:a05:600c:2946:b0:3fc:7eb:1119 with SMTP id n6-20020a05600c294600b003fc07eb1119mr3794466wmd.15.1694234038524; Fri, 08 Sep 2023 21:33:58 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: imp@bsdimp.com, Stacey Son , Karim Taha , Richard Henderson Subject: [PATCH v2 20/23] bsd-user: Implement shm_unlink(2) and shmget(2) Date: Thu, 7 Sep 2023 09:42:59 +0200 Message-ID: <20230907074302.79234-21-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230907074302.79234-1-kariem.taha2.7@gmail.com> References: <20230907074302.79234-1-kariem.taha2.7@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wm1-x32a.google.com X-Spam_score_int: 0 X-Spam_score: -0.1 X-Spam_bar: / X-Spam_report: (-0.1 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_24_48=1.34, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, SPF_HELO_NONE=0.001, T_SPF_TEMPERROR=0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1694234124869100007 Content-Type: text/plain; charset="utf-8" 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 | 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 a48f919ff2..27d4e7f079 100644 --- a/bsd-user/bsd-mem.h +++ b/bsd-user/bsd-mem.h @@ -281,4 +281,27 @@ static inline abi_long do_bsd_shm_open(abi_ulong arg1,= abi_long arg2, return ret; } =20 +/* shm_unlink(2) */ +static inline abi_long do_bsd_shm_unlink(abi_ulong arg1) +{ + int ret; + void *p; + + p =3D lock_user_string(arg1); + if (p =3D=3D NULL) { + return -TARGET_EFAULT; + } + ret =3D 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 7404b0aa72..52cca2300f 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 =20 + case TARGET_FREEBSD_NR_shm_unlink: /* shm_unlink(2) */ + ret =3D do_bsd_shm_unlink(arg1); + break; + + case TARGET_FREEBSD_NR_shmget: /* shmget(2) */ + ret =3D do_bsd_shmget(arg1, arg2, arg3); + break; + /* * Misc */ --=20 2.42.0 From nobody Thu Nov 28 07:47:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1694234163; cv=none; d=zohomail.com; s=zohoarc; b=A+5jAiAiVnj1OmyiP2XY7jC6RKSzs8XmtYrQ1oHBjkK0Sga+iY7UYW2I2rE4V3Z2Pn/GZJk6YcHXYLwkF+YBVx8jLf0WW6ZWPvBxbkv5uS/LbTqeRqDr4rjxTNkddsHrPdq48maGnP6ngxTPAT+Z8EcOYpiD6obDal/hbgDxGME= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694234163; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=km+tj6Z7RbqljDckWlqZ0FNouzbIsgoz91K6vZRTtrU=; b=VcuhUulv3LTwPVrRd6btSvqJaxGMwnDRekBriCo+5/VL7Qj8r9YvfWbzTLEuxhCQv/TBbSIP0vXq2zWq0IvyxhLAgQ+q7W5reHprzXjC/yaM5uVbAdzHhwq0UcLbo9VReX7+guesgZZDR9hMh95frujreixjKDB/+hMEx4vkiog= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694234163867735.921569326691; Fri, 8 Sep 2023 21:36:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qepfq-00019z-FX; Sat, 09 Sep 2023 00:34:22 -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 1qepfn-00018r-GC for qemu-devel@nongnu.org; Sat, 09 Sep 2023 00:34:19 -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 1qepfZ-0002yw-4x for qemu-devel@nongnu.org; Sat, 09 Sep 2023 00:34:18 -0400 Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-307d58b3efbso2434542f8f.0 for ; Fri, 08 Sep 2023 21:34:01 -0700 (PDT) Received: from karim.my.domain ([197.39.120.250]) by smtp.gmail.com with ESMTPSA id d16-20020adff2d0000000b0031981c500aasm3615102wrp.25.2023.09.08.21.33.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Sep 2023 21:33:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694234040; x=1694838840; darn=nongnu.org; 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=km+tj6Z7RbqljDckWlqZ0FNouzbIsgoz91K6vZRTtrU=; b=P08Eq6n2fuRFX03OxJI43JhrYueh+cbopwwq/hzYZPtr5xKu6y/CadAiOyZMjsPBJU 6OZILQs7tCTgiAkPeS50rAQccmjGfqQMP2J1WAK9qPmit2Kw26Iaq3Q8DwweYP8ihhy7 2z7qGQb+DD2sSxAIlh9l4uHHeqp+oZJ9bQIoqLMZ6hCK/pPpyv6691wII5lTq8isK9bu ZUKKSkPlWM0FC7SsUOZuy43yJwTLyRZwq3xLaLLqdK9Ces4tIMoOhiDAvj4GCFs8ORDI O2QkKU710uISIU5uJ1v4rgBYNxyQN5T0IwrkGaZtmHpJspsmuIo8omTvqtCweVQEMCwz Jo0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694234040; x=1694838840; 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=km+tj6Z7RbqljDckWlqZ0FNouzbIsgoz91K6vZRTtrU=; b=sti5DevMbQ0Wqm7kDWarIZDUXkFxZ9nLuQKIprQc42C5Z3SkK49BygJCbeuquPJ9Na ZiculnIn3iUyIbotRaVaeeO5gMl+DhgxSf6GjSmS/OKwKsD+uOGSqwaKp3wa+9j3kV2p QgTCRhwpmZXoDibjZ9ropShyF0QHLTEHmotR+zQ3h2iJD6ynbGCInkFysl/2bffZc8u8 aib7npDlSgEdDNL2cfCKdAXhE/TdcQI56kWEnYJWZppiVAcQVa2gTwziA7VkrGLr8aHk 9MmB35Y6lBtm961/EI/yjQQj1R1Nqs2pbSDNsHQXeQA1olhTzGaSvSw0jj3svzPUdmx1 0QUQ== X-Gm-Message-State: AOJu0Yz0i5nxDIEuV45mLhLAyQPVoxeQ71+KdCR9qAXVRn+fLbUl6gec Sxsc0YyrhQQHxa3g76cvj8zqHeO1E1o= X-Google-Smtp-Source: AGHT+IFz0q3WVo8xVx2Hylr8jZQkNlNOmcFF1vOPbTGn9NnHFQIRf0EoghknCyLeqhFvcITbw6wIeQ== X-Received: by 2002:adf:e491:0:b0:319:6997:942e with SMTP id i17-20020adfe491000000b003196997942emr3370301wrm.8.1694234039738; Fri, 08 Sep 2023 21:33:59 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: imp@bsdimp.com, Stacey Son , Karim Taha Subject: [PATCH v2 21/23] bsd-user: Implement shmctl(2) Date: Thu, 7 Sep 2023 09:43:00 +0200 Message-ID: <20230907074302.79234-22-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230907074302.79234-1-kariem.taha2.7@gmail.com> References: <20230907074302.79234-1-kariem.taha2.7@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: 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: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_24_48=1.34, 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=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1694234165000100007 Content-Type: text/plain; charset="utf-8" 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 27d4e7f079..dd506b8a15 100644 --- a/bsd-user/bsd-mem.h +++ b/bsd-user/bsd-mem.h @@ -304,4 +304,37 @@ static inline abi_long do_bsd_shmget(abi_long arg1, ab= i_ulong arg2, return get_errno(shmget(arg1, arg2, arg3)); } =20 +/* 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 =3D -TARGET_EINVAL; + + cmd &=3D 0xff; + + switch (cmd) { + case IPC_STAT: + case IPC_SET: + if (target_to_host_shmid_ds(&dsarg, buff)) { + return -TARGET_EFAULT; + } + ret =3D get_errno(shmctl(shmid, cmd, &dsarg)); + if (host_to_target_shmid_ds(buff, &dsarg)) { + return -TARGET_EFAULT; + } + break; + + case IPC_RMID: + ret =3D get_errno(shmctl(shmid, cmd, NULL)); + break; + + default: + ret =3D -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 52cca2300f..35f94f51fc 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 =3D do_bsd_shmget(arg1, arg2, arg3); break; =20 + case TARGET_FREEBSD_NR_shmctl: /* shmctl(2) */ + ret =3D do_bsd_shmctl(arg1, arg2, arg3); + break; + /* * Misc */ --=20 2.42.0 From nobody Thu Nov 28 07:47:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1694234140; cv=none; d=zohomail.com; s=zohoarc; b=aV1ACjeQb9y1Z5Kg8Tgs+gkB75/m76G7ZVOeEvgokDaJY0zsW83ohhzJgdaWRcmOXXOrBxCU8bvAb99XYbJmGrJq+5aNlnd3SFQVVvfanjC9VlcKml/MJ7Hyzj+/e2iMQaoy5Z1l9sQ4OfnWlis8yQu/PZRhha7MlUfrbRnl0nk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694234140; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=hvIIhsiuBvf1kndCBMcjJtgubDA4YhP3ZHmk+jfqh6c=; b=PcywkdsJCSJmSqlUczcsHZyKMiEceaKFnnzofNbIn/+O64Upl+N/OokEM8vRkWPh4to0dPRhh3p2r3aOQXXDbQ0erPsWRkwi0cwIqBSefu+r9/yKdtVW1nqAP5Yg8Z4mm31zuM1dUwCyeLqsn1L7hcLZOJTb5yyvoxFe3oPQjq0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694234140388408.4185605065936; Fri, 8 Sep 2023 21:35:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qepfz-0001Aw-PH; Sat, 09 Sep 2023 00:34: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 1qepfu-0001AJ-RN for qemu-devel@nongnu.org; Sat, 09 Sep 2023 00:34:28 -0400 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qepfX-00030M-Df for qemu-devel@nongnu.org; Sat, 09 Sep 2023 00:34:26 -0400 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-400a087b0bfso28349795e9.2 for ; Fri, 08 Sep 2023 21:34:02 -0700 (PDT) Received: from karim.my.domain ([197.39.120.250]) by smtp.gmail.com with ESMTPSA id d16-20020adff2d0000000b0031981c500aasm3615102wrp.25.2023.09.08.21.33.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Sep 2023 21:34:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694234041; x=1694838841; darn=nongnu.org; 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=hvIIhsiuBvf1kndCBMcjJtgubDA4YhP3ZHmk+jfqh6c=; b=A3ObypMhVqpGOoE92M5Wd8u8gLA/A/qok3ZRJdvqaVkfkZDi8SZjlk06vI0KH8Xr6o puPFRJ/2n9NtUAODQ0OkxpmMnAXIcNxQdqrdvXGgbcePAD8I2BTrTOVZaJr7GFKITNnq FW6SZJvTgIUKXGp8eakJdtcIDVxzeq2F489SbxCaCnwZ19C6rPWkSCIRzkRqx8E2Bpyy 2nX0aDtulu6+sDkX8K52XvM+gw36HNFvO/MUk6DztCuRLqZY4hqo+aPuUGwA8K0XQBE7 zn8s4lOEqzvLklbVQBN6GKUwSLik9mXheFWwp8Xla4By6PhY9GXxaOkeZplhxv3urxOQ H9Rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694234041; x=1694838841; 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=hvIIhsiuBvf1kndCBMcjJtgubDA4YhP3ZHmk+jfqh6c=; b=ZMTi9VDefZZfxCO9SZkFManT9XJgiTIX2K53ktLeK0k+LGFJKb7NlSDgyE6kNwnCBe X9dx5YRVQttgEAQU3fv4GOYcNGoEmUpj9b4bu/UdEYCLFhIgoyL8j+Zdec2uYaOvZaP7 JlEt3GY7nBQeV6wmQsvBCJG/G7Kko0/nQ0UmlEus2TEl0mBdwZRYeopd49QI3FYeOPCL oNWl5iCZqclxcWk0mwo2txwxmYGd0BmSHumQEkCoaEH5aQhcFO0cqX6CMdWGTdkxb+7D 1fjjVS0+ACjs+oblhh+oj1Uhq6nDx9ZVY7Q+TEikWns2hj4YqueVIw7+3t2o58CilAHS TnOw== X-Gm-Message-State: AOJu0YwUUzFiAELRrfifMHENfQs75BdqyTKDLZfIoy7Yg1SQAZQ5Ycy/ VjNsQ1UjUPl4Q2SAOmanDL7y74sGiTU= X-Google-Smtp-Source: AGHT+IErZsCrUGciBlUi7O337nWE78kz1j/ssxA2xX4XLYI9hheG8o059gqnoodtVQiSmYbkvqWeUA== X-Received: by 2002:a05:600c:3b8d:b0:403:31a:77b9 with SMTP id n13-20020a05600c3b8d00b00403031a77b9mr444107wms.37.1694234040953; Fri, 08 Sep 2023 21:34:00 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: imp@bsdimp.com, Stacey Son , Karim Taha Subject: [PATCH v2 22/23] bsd-user: Implement shmat(2) and shmdt(2) Date: Thu, 7 Sep 2023 09:43:01 +0200 Message-ID: <20230907074302.79234-23-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230907074302.79234-1-kariem.taha2.7@gmail.com> References: <20230907074302.79234-1-kariem.taha2.7@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::330; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wm1-x330.google.com X-Spam_score_int: 0 X-Spam_score: -0.1 X-Spam_bar: / X-Spam_report: (-0.1 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_24_48=1.34, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1694234141511100001 Content-Type: text/plain; charset="utf-8" From: Stacey Son Signed-off-by: Stacey Son Signed-off-by: Karim Taha --- bsd-user/bsd-mem.h | 76 +++++++++++++++++++++++++++++++++++ bsd-user/freebsd/os-syscall.c | 8 ++++ 2 files changed, 84 insertions(+) diff --git a/bsd-user/bsd-mem.h b/bsd-user/bsd-mem.h index dd506b8a15..c01b009326 100644 --- a/bsd-user/bsd-mem.h +++ b/bsd-user/bsd-mem.h @@ -337,4 +337,80 @@ static inline abi_long do_bsd_shmctl(abi_long shmid, a= bi_long cmd, return ret; } =20 +/* shmat(2) */ +static inline abi_long do_bsd_shmat(int shmid, abi_ulong shmaddr, int shmf= lg) +{ + 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 =3D get_errno(shmctl(shmid, IPC_STAT, &shm_info)); + if (is_error(ret)) { + /* Can't get the length */ + return ret; + } + + if (!guest_range_valid_untagged(shmaddr, shm_info.shm_segsz)) { + return -TARGET_EINVAL; + } + + mmap_lock(); + + if (shmaddr) { + host_raddr =3D shmat(shmid, (void *)g2h_untagged(shmaddr), shmflg); + } else { + abi_ulong mmap_start; + + mmap_start =3D mmap_find_vma(0, shm_info.shm_segsz); + + if (mmap_start =3D=3D -1) { + errno =3D ENOMEM; + host_raddr =3D (void *)-1; + } else { + host_raddr =3D shmat(shmid, g2h_untagged(mmap_start), + shmflg | SHM_REMAP); + } + } + + if (host_raddr =3D=3D (void *)-1) { + mmap_unlock(); + return get_errno((long)host_raddr); + } + raddr =3D 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 =3D 0; i < N_BSD_SHM_REGIONS; i++) { + if (bsd_shm_regions[i].start =3D=3D 0) { + bsd_shm_regions[i].start =3D raddr; + bsd_shm_regions[i].size =3D 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 =3D 0; i < N_BSD_SHM_REGIONS; ++i) { + if (bsd_shm_regions[i].start =3D=3D shmaddr) { + bsd_shm_regions[i].start =3D 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 35f94f51fc..fe0968773e 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 =3D do_bsd_shmctl(arg1, arg2, arg3); break; =20 + case TARGET_FREEBSD_NR_shmat: /* shmat(2) */ + ret =3D do_bsd_shmat(arg1, arg2, arg3); + break; + + case TARGET_FREEBSD_NR_shmdt: /* shmdt(2) */ + ret =3D do_bsd_shmdt(arg1); + break; + /* * Misc */ --=20 2.42.0 From nobody Thu Nov 28 07:47:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1694234164; cv=none; d=zohomail.com; s=zohoarc; b=DOMxsd1YgvzgfDxpD0r713eoZLuCpMAh5eBoEVpHJM3jMyjPDetC52K5JR4SMCsYpdKvymvKyLqt67RQeApvlPmT5k8rJEABqa/h6bwQQjnobBcOP2qtFStPZYUgRo2X3ShUPc8qsb2TUlsU5ErFMEvViFprKyWkmAoWCSPCMDU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694234164; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=iX9h1C28ifZiwlprRugD1/5aAvqn6UBysQeovDlj5zU=; b=RrNeISji8TqyT2ia7et1elzUMEWg9XmZtWKkLiZmpxyR2QZTEUbmfOIYsI++5RQFScXTbDbe5h1qbJDNIWDkd1QHWMW9np/RO1722hPViA92qQGGrtJuUyqq2YXq2D7osw8S41aRiEFftIamkaJMx9nidqyWpoIaqpNGa0+cAKY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694234164888581.0704993571718; Fri, 8 Sep 2023 21:36:04 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qepfy-0001AQ-QG; Sat, 09 Sep 2023 00:34:31 -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 1qepfu-0001AD-KB for qemu-devel@nongnu.org; Sat, 09 Sep 2023 00:34:26 -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 1qepfZ-00030Y-IL for qemu-devel@nongnu.org; Sat, 09 Sep 2023 00:34:25 -0400 Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-31c65820134so2491205f8f.1 for ; Fri, 08 Sep 2023 21:34:03 -0700 (PDT) Received: from karim.my.domain ([197.39.120.250]) by smtp.gmail.com with ESMTPSA id d16-20020adff2d0000000b0031981c500aasm3615102wrp.25.2023.09.08.21.34.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Sep 2023 21:34:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694234042; x=1694838842; darn=nongnu.org; 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=iX9h1C28ifZiwlprRugD1/5aAvqn6UBysQeovDlj5zU=; b=IgPL2rDVmgQB3U5nQmHhdQTyJ+jgO7Gii8h56+NQ4z36lKZh6H1cG5XHt3h1l+sdQV W/YWLEuNZfDrBU1fJQ5tFE5nkGfHNclrIiKs1wUOeBB7Q91w5U4Y+5NhvPTzBrhKXP0I oRMUqdh10YTi5PdeGhlSXhnEXExVXai74Ug4x/aBayfkNLjrsX1WhAeK9JbL52E6py/D 2fnGTOZ+ulhhVpMMnm5zALfES9LJx4HHtLzzhFAWdfg9qtMoWUQZQjeNicNK/6udqGOk OT6MlUyAcWXRw5p8cMCgzEfJL15yU8wLIvE8yvbvynKP1kpsZbgoVjsNOz7fLnLZZoM2 HLEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694234042; x=1694838842; 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=iX9h1C28ifZiwlprRugD1/5aAvqn6UBysQeovDlj5zU=; b=CUtrUCb5JT808YI+48HvY975tTYF/ZjhlU08CZDlLMwcMgXXD2c/WM8wSsOB0bFtqh TpjuARsppWDyYwwIUMjP/m02f9MmTXmO8JDIotQeBwrkSQ4FPAg6Y1WhQbdbrIZYZyrG Q7yyUKyrPPczHeWnHdDcxld04vKho+T1wFEaDIjaqSEcHCL2mF+hx1s/QfKOBxt00xZs cxkxzQix6FlriX43y8ZuKL727x/Unt8xFbuAxJo0O+PLC7+rXeIycHKq3p6QDoXWb9qK WsRGaT6WgesLksMeZmAK0eYdWLhIul0EKuHMzcCPCrhMeiY+tRMro/D88hpHl50tNk9X mWRQ== X-Gm-Message-State: AOJu0YyHuEjS4YwiqTUJSDP38IyeitwAMqwBY4rAFoJV1s4bss10L+Ng I2DFL/bU4HGAae0mrXUqto9NVTNu9Aw= X-Google-Smtp-Source: AGHT+IGinAsuh7hO3fKHK6sD4qZjmI8T42Zwya1+UD4Dfg/GjvRk01+P/79SqNkvqaujiBx0i92Qtw== X-Received: by 2002:a5d:684a:0:b0:314:124f:12be with SMTP id o10-20020a5d684a000000b00314124f12bemr3200954wrw.3.1694234042084; Fri, 08 Sep 2023 21:34:02 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: imp@bsdimp.com, Karim Taha Subject: [PATCH v2 23/23] bsd-user: Add stubs for vadvise(), sbrk() and sstk() Date: Thu, 7 Sep 2023 09:43:02 +0200 Message-ID: <20230907074302.79234-24-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230907074302.79234-1-kariem.taha2.7@gmail.com> References: <20230907074302.79234-1-kariem.taha2.7@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: 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: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_24_48=1.34, 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=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1694234165770100009 Content-Type: text/plain; charset="utf-8" From: Warner Losh The above system calls are not supported by qemu. Signed-off-by: Warner Losh Signed-off-by: Karim Taha --- bsd-user/bsd-mem.h | 18 ++++++++++++++++++ bsd-user/freebsd/os-syscall.c | 12 ++++++++++++ 2 files changed, 30 insertions(+) diff --git a/bsd-user/bsd-mem.h b/bsd-user/bsd-mem.h index c01b009326..aea8d65f15 100644 --- a/bsd-user/bsd-mem.h +++ b/bsd-user/bsd-mem.h @@ -413,4 +413,22 @@ static inline abi_long do_bsd_shmdt(abi_ulong shmaddr) return get_errno(shmdt(g2h_untagged(shmaddr))); } =20 +static inline abi_long do_bsd_vadvise(void) +{ + /* See sys_ovadvise() in vm_unix.c */ + return -TARGET_EINVAL; +} + +static inline abi_long do_bsd_sbrk(void) +{ + /* see sys_sbrk() in vm_mmap.c */ + return -TARGET_EOPNOTSUPP; +} + +static inline abi_long do_bsd_sstk(void) +{ + /* see sys_sstk() in vm_mmap.c */ + return -TARGET_EOPNOTSUPP; +} + #endif /* BSD_USER_BSD_MEM_H */ diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index fe0968773e..9647249e90 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 =3D do_bsd_shmdt(arg1); break; =20 + case TARGET_FREEBSD_NR_freebsd11_vadvise: + ret =3D do_bsd_vadvise(); + break; + + case TARGET_FREEBSD_NR_sbrk: + ret =3D do_bsd_sbrk(); + break; + + case TARGET_FREEBSD_NR_sstk: + ret =3D do_bsd_sstk(); + break; + /* * Misc */ --=20 2.42.0