From patchwork Thu Sep 14 20:40:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karim Taha X-Patchwork-Id: 1834481 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=LnhmnhJ5; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Rmq5s6t4Lz1yh0 for ; Fri, 15 Sep 2023 06:43:13 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qgtAb-00038X-L2; Thu, 14 Sep 2023 16:42:37 -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 1qgtAX-00037G-72 for qemu-devel@nongnu.org; Thu, 14 Sep 2023 16:42:33 -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 1qgtAU-0006GD-RH for qemu-devel@nongnu.org; Thu, 14 Sep 2023 16:42:32 -0400 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-404314388ceso13012355e9.2 for ; Thu, 14 Sep 2023 13:42:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694724149; x=1695328949; 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=B7uKJtjQDxrpcslNDuL3FuFOFPTPw3U7VbY8diH7n9M=; b=LnhmnhJ5pycdWo8MSzy2ToPCF9RyFryisLk9A39YT2iFcMEh8/joSXApYFOtNPZUeA BR6LDBEG0Mwqsx8NggmzFIXhwe9QfPKTjQLMbEIne8j7IpO5Vv18DKxX7Y1T66oDYKuL 90ivaPr2EY1zr0Ut8U+nRNpzCsnTrxx6JT2BeOr0s4g9UVmzdBjiAI/fIxmIwh8W4T+/ mswDKUKJN3DGjGahtpmUOGl37JpP3QA0/36vPwriH9KE5qkbewj7HvbZsJpmSzUjz2Sf 4Il/RoM4G+2AD+gwka8+X161WDwy6f/88083+wJm1Fzgg3ZvqeloyYWlXnwsZV0ciSlb j2oQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694724149; x=1695328949; 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=B7uKJtjQDxrpcslNDuL3FuFOFPTPw3U7VbY8diH7n9M=; b=FubMIYbdSghRufJOeTTZH1Ltgv3Ip2PJu2Lc146nxDjTfovDBGtAVbdVlvFHV/f5/I tOV80O9ODwA5/TIBGDEaJh/rH21Mg7U4Vjd+q8LZ4gqHRuQqWZRg8VYPDBYbSFWiyq0a fg0Z6rYKX515168lRxxtz2fExAqfZaf8/bKTpxllQxvJoOiHg1uPz44Uwve6Smp5/9EG YVeJIlnRGhqxNRqd+nUzBy99C/LuKoDs4Ava0HHS/b4Gygo0oi6nq0uIUc+YHBDut68q CMTP+z83ObDuwj0gK+GmWnnZfueTJTAyOwevKkKar+APipiggQtFIbWoj+xD/BgpZiMM iLNA== X-Gm-Message-State: AOJu0YxPEZMc0jbhRPq1regTrQNl0M0WoFtE0Ke7gjl7f1b+NX/hcIC5 i6yiijfahPpKDqa/Fh2jA/wRQjs5K8o= X-Google-Smtp-Source: AGHT+IE+5iUwBb3ADsDLgtqV4y98973Ta+plaxrSmUifQhtcm29UpY4AdwX705DmA1nazQ4YU6dnWg== X-Received: by 2002:adf:e283:0:b0:317:6a07:83a7 with SMTP id v3-20020adfe283000000b003176a0783a7mr5060874wri.38.1694724148750; Thu, 14 Sep 2023 13:42:28 -0700 (PDT) Received: from karim.my.domain ([197.39.44.105]) by smtp.gmail.com with ESMTPSA id j3-20020a056000124300b0031f34a395e7sm2661880wrx.45.2023.09.14.13.42.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 13:42:28 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: Richard Henderson , imp@bsdimp.com, Stacey Son , Karim Taha Subject: [PATCH v5 01/23] bsd-user: Implement struct target_ipc_perm Date: Thu, 14 Sep 2023 23:40:45 +0300 Message-ID: <20230914204107.23778-2-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230914204107.23778-1-kariem.taha2.7@gmail.com> References: <20230914204107.23778-1-kariem.taha2.7@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wm1-x32d.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Stacey Son Signed-off-by: Stacey Son Signed-off-by: Karim Taha Reviewed-by: 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 9c90616baa..4deb4fed35 100644 --- a/bsd-user/syscall_defs.h +++ b/bsd-user/syscall_defs.h @@ -55,6 +55,23 @@ struct target_iovec { abi_long iov_len; /* Number of bytes */ }; +/* + * sys/ipc.h + */ +struct target_ipc_perm { + uint32_t cuid; /* creator user id */ + uint32_t cgid; /* creator group id */ + uint32_t uid; /* user id */ + uint32_t gid; /* group id */ + uint16_t mode; /* r/w permission */ + uint16_t seq; /* sequence # */ + abi_long key; /* user specified msg/sem/shm key */ +}; + +#define TARGET_IPC_RMID 0 /* remove identifier */ +#define TARGET_IPC_SET 1 /* set options */ +#define TARGET_IPC_STAT 2 /* get options */ + /* * sys/mman.h */ From patchwork Thu Sep 14 20:40:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karim Taha X-Patchwork-Id: 1834482 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=dIqJfjPB; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Rmq5t5jqmz1ypL for ; Fri, 15 Sep 2023 06:43:14 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qgtAj-0003HE-Qf; Thu, 14 Sep 2023 16:42:46 -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 1qgtAa-00037p-9B for qemu-devel@nongnu.org; Thu, 14 Sep 2023 16:42:36 -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 1qgtAW-0006Hd-FW for qemu-devel@nongnu.org; Thu, 14 Sep 2023 16:42:34 -0400 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-31fa15f4cc6so1305372f8f.2 for ; Thu, 14 Sep 2023 13:42:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694724150; x=1695328950; 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=gRkHnja7nexQbKWQ5sBDhgIEYNSvl8qtBM9POpCGcAI=; b=dIqJfjPBgH1bF8K/uE14lhVIxICyXvCHAyKAcwF4Q2pNwGVtP4rrDIXNuw956Z0Li5 JdKhM+ua6t/4qWAlpLTJk+e+Tvy3nzRN4854p0Cda4TpSVYBMdCR9raDH/u2Pcz8qCKm emqVv8BS4zOFwo1C4jfsMXhOGxpVrMjjnLp+T+GCXf/zZv2nyn6hfFGihNZOm0ibq6qW dQNakBR2cOvhwyhlO3fdWMdxDW476i3qy48ny3zk6YFbPoSB/BomU0IenNQ9WM7wRP9f fdEt+giSv+zxn+E4VyZEMc/sWIBi/uTqUYfh/+5aDf1mplD/1EslwGDVs3VWBLPu3ETk HubA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694724150; x=1695328950; 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=gRkHnja7nexQbKWQ5sBDhgIEYNSvl8qtBM9POpCGcAI=; b=W5xJk4YN+kw2QwVqzDXNW+oE68PbNAREt6YVBd5t6iDbCm/NSK/5F0L91TLxCdm97d 9WjYe3MstcT78EpYoInISb+SaQZOwSZ6q7KqmlmwkgJ+J6HskO3XW4kiFCOkumaaBa7t Uv9QmbjI6TW7Qm5aVrJx6GVmVhMhxrNJ+b6jesVUrMyd/Wwz617i6nUESo4+l2c5mtba 0vBkB2OE1PaME6Czw32UY8odoRAMkuqP7lMjefiXsuULOAPcCvnrjpsigWVnOP7UROYg 5+fHTxbH7C18PCCD5uNo7l3XUHcfyqQfjPDiDZnTB/TH46ZeHE5s/aoEGOokG6h/EqiR P63Q== X-Gm-Message-State: AOJu0YyLaYGdWy3XQF169GvbpoBqW8CUo2LCEeoOUNehefOq2MPvzNpC en/8UQXrqeonKESljd+agChZKgvh/Jo= X-Google-Smtp-Source: AGHT+IEFEkYVh/o/6hyNZnDsVU9uovnJyyOwT8/CAQP6Aym6LKhanVWNfyCgOAO6lhBfNd0yglvQsg== X-Received: by 2002:adf:f84c:0:b0:31f:8999:c3fe with SMTP id d12-20020adff84c000000b0031f8999c3femr5840502wrq.69.1694724150127; Thu, 14 Sep 2023 13:42:30 -0700 (PDT) Received: from karim.my.domain ([197.39.44.105]) by smtp.gmail.com with ESMTPSA id j3-20020a056000124300b0031f34a395e7sm2661880wrx.45.2023.09.14.13.42.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 13:42:29 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: Richard Henderson , imp@bsdimp.com, Stacey Son , Karim Taha Subject: [PATCH v5 02/23] bsd-user: Implement struct target_shmid_ds Date: Thu, 14 Sep 2023 23:40:46 +0300 Message-ID: <20230914204107.23778-3-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230914204107.23778-1-kariem.taha2.7@gmail.com> References: <20230914204107.23778-1-kariem.taha2.7@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::434; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wr1-x434.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Stacey Son 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 4deb4fed35..f4a5ae2a12 100644 --- a/bsd-user/syscall_defs.h +++ b/bsd-user/syscall_defs.h @@ -72,6 +72,26 @@ struct target_ipc_perm { #define TARGET_IPC_SET 1 /* set options */ #define TARGET_IPC_STAT 2 /* get options */ +/* + * sys/shm.h + */ +struct target_shmid_ds { + struct target_ipc_perm shm_perm; /* peration permission structure */ + abi_ulong shm_segsz; /* size of segment in bytes */ + int32_t shm_lpid; /* process ID of last shared memory op */ + int32_t shm_cpid; /* process ID of creator */ + int32_t shm_nattch; /* number of current attaches */ + target_time_t shm_atime; /* time of last shmat() */ + target_time_t shm_dtime; /* time of last shmdt() */ + target_time_t shm_ctime; /* time of last change by shmctl() */ +}; + +#define N_BSD_SHM_REGIONS 32 +struct bsd_shm_regions { + abi_long start; + abi_long size; +}; + /* * sys/mman.h */ From patchwork Thu Sep 14 20:40:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karim Taha X-Patchwork-Id: 1834484 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=jwNHZpkJ; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Rmq5w4WGNz1ypL for ; Fri, 15 Sep 2023 06:43:16 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qgtAe-00038k-Pr; Thu, 14 Sep 2023 16:42:40 -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 1qgtAa-00037q-F5 for qemu-devel@nongnu.org; Thu, 14 Sep 2023 16:42:36 -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 1qgtAW-0006IW-Vn for qemu-devel@nongnu.org; Thu, 14 Sep 2023 16:42:36 -0400 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-40472f9db24so10683005e9.2 for ; Thu, 14 Sep 2023 13:42:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694724151; x=1695328951; 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=kVq1uGHM9oV6angmlbXbZLjFliHdEcoHMR8Uy2q0vLA=; b=jwNHZpkJfosNz5xOeyuFP7W96mfDviETPAzudqcSdlyHFWoKXUhPO3bOjaSc/7kcUE C5HgZZr+49wLaByjIbs3PgE0Wl8nICDaicVYoqnKMKSHdBJnjTQKpMMFfh1O/KMv0nwR LdwTngDyoxHgD9FqRZo0QRFk2/kIugtNL++MblM7xCJJY65dKCkuPcTYwClmRJWTuOIN hW3tsp+AsztgpEpH3+QtPMpLb0S5fAtEqN62NnBZxHFLqgmt2kcGdXyZC9Rs8gvXLKu/ c1seL+9BIgjaxasEemTJ7P/d1TaCT218ILVye4vTqTsfObmuwWdUsgNyTdINj1yqlYSM drKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694724151; x=1695328951; 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=kVq1uGHM9oV6angmlbXbZLjFliHdEcoHMR8Uy2q0vLA=; b=KdR+/fHK/VCxrb8bPStfR61g4ojj0IsDFOjf424gQTOhsb+tv1oq6e399IcbtjOyuT 6xnPr+njPLHhDLXOiUOFQmpfVaHt0YjqEgqlpl6tXwqbXPlv/6QLDpvyqI12PwqcJ/wG S6f05jVGZrOP0NRDh17fdOoIb3ujBOvRzK7GURzUedIwi7XqnTVJiiaVcduPVEZYX68/ mNxBigSj8lgdo3iYEoh+ifT7X7gYNJL5Fu0/nv9AtCIsYIMzIctCpguA/4xRxSsr1jLs vWAbLielaVyTuNNiLJDYbiXZ8du7E+byAm3wRSjlaNDhRwXN8Zom6B5y1TE3kPAlu/lY 8kxw== X-Gm-Message-State: AOJu0Yyn6Ioe6c4Mmbpmk1zLTkNB9gPGiTkoolUiTBk2ziZebVcugsLc t8Fdu357Y0SUi0t5XNYO26Z83UPq6SM= X-Google-Smtp-Source: AGHT+IH45ePvhxLS4ku0+R4Dw4OYQfEmX/Aj7WB3FiuU4GCfQ7cBJP5Z6LhoO7JK+I1tWTYRpQLnmQ== X-Received: by 2002:adf:fe8f:0:b0:31f:82eb:8a70 with SMTP id l15-20020adffe8f000000b0031f82eb8a70mr5623298wrr.37.1694724151369; Thu, 14 Sep 2023 13:42:31 -0700 (PDT) Received: from karim.my.domain ([197.39.44.105]) by smtp.gmail.com with ESMTPSA id j3-20020a056000124300b0031f34a395e7sm2661880wrx.45.2023.09.14.13.42.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 13:42:30 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: Richard Henderson , imp@bsdimp.com, Stacey Son , Karim Taha Subject: [PATCH v5 03/23] bsd-user: Declarations for ipc_perm and shmid_ds conversion functions Date: Thu, 14 Sep 2023 23:40:47 +0300 Message-ID: <20230914204107.23778-4-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230914204107.23778-1-kariem.taha2.7@gmail.com> References: <20230914204107.23778-1-kariem.taha2.7@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wm1-x32d.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Stacey Son Signed-off-by: Stacey Son Signed-off-by: Karim Taha Reviewed-by: 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 */ From patchwork Thu Sep 14 20:40:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karim Taha X-Patchwork-Id: 1834490 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=jdpRb/JV; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Rmq8J1Pbqz1yhd for ; Fri, 15 Sep 2023 06:45:20 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qgtAp-0003KV-44; Thu, 14 Sep 2023 16:42:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qgtAb-00038g-Nt for qemu-devel@nongnu.org; Thu, 14 Sep 2023 16:42:38 -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 1qgtAZ-0006Is-1Z for qemu-devel@nongnu.org; Thu, 14 Sep 2023 16:42:37 -0400 Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-31c7912416bso1263762f8f.1 for ; Thu, 14 Sep 2023 13:42:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694724153; x=1695328953; 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=KK7hmPDkvNZ7gao1BckcXOde8JB8Py+cCsJYB29LOaU=; b=jdpRb/JVRfdxTIsVnLRVxu94zZWEvEmIo1u5rUezDArGV0AwbaJFWyBdlQFD2LpCTh FetHwhIk7zAnbMhdaq7n8+O2yJ6Nv43emLeYemALWhZU0wuErE23mc3jgRZQOEht5Pn6 dvZ7ow3UiDGjlXuGBBANugQihuMWswnnlyzpRSPaLivK31UCbCnytN+BjY349sdgR1w/ jMxwFn485S35zmZrzBGwt0/c4iFScgpfY06MIy8YEG+0H3YNGh/P+yxqCQhuoJkqJ8eM 7vwe+EQH3+yPFX8NpuBGjGRwDDcmAKm2i9QUxCbT6yy+DAaoRNrZih63HrT5gZd/a7G/ 38xA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694724153; x=1695328953; 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=KK7hmPDkvNZ7gao1BckcXOde8JB8Py+cCsJYB29LOaU=; b=K2vRMGaKd8SjGJkcPHt/LhjJtT1tYI5a9d7q9tuIjEC+KbSPuaW8Qomll4eZIvqmiq 1CRta4rpAR3whKzF8rpVsnjWTnpKq5QwqM/ivugVIzvtHVWCNPGuKpIOyyE5e9WAVuED CA3OXRFaEWmOBlq7XFfg/5+7nl4oSlNiibXwN+zY0Ip6+K1VkLQnd3x8SsLXMA3/40h/ f9xI7gwwzWdNL/pJg+Q7oviKgI8C/BbTKeo6CdFaVAmAVoDpYMgLDWZSQ0pi2wPHAp2D wnoOI1rIbyOzbuNWSgQR5ZSEmTC1Zskwbz236gaszuMCckT0QRLmrbeUfmBIaSIqKG0q taHQ== X-Gm-Message-State: AOJu0YwLCSDCy2EVDaI7ZJ9BsYwiuEa00Tq8X7qR2CyPABKlCiUbVJTL Vn/8HpDvlcARUjYI2tdUfRo+lc5rL5g= X-Google-Smtp-Source: AGHT+IFiQqiPI+KA6gvcCXbXm8goGXx5dQBgCDAeRN7yBcviTume8V21sbhJjtNsDojZAuAn12oDhQ== X-Received: by 2002:adf:ee4e:0:b0:319:6001:978c with SMTP id w14-20020adfee4e000000b003196001978cmr5497016wro.53.1694724152611; Thu, 14 Sep 2023 13:42:32 -0700 (PDT) Received: from karim.my.domain ([197.39.44.105]) by smtp.gmail.com with ESMTPSA id j3-20020a056000124300b0031f34a395e7sm2661880wrx.45.2023.09.14.13.42.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 13:42:32 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: Richard Henderson , imp@bsdimp.com, Stacey Son , Karim Taha Subject: [PATCH v5 04/23] bsd-user: Introduce freebsd/os-misc.h to the source tree Date: Thu, 14 Sep 2023 23:40:48 +0300 Message-ID: <20230914204107.23778-5-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230914204107.23778-1-kariem.taha2.7@gmail.com> References: <20230914204107.23778-1-kariem.taha2.7@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42c; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wr1-x42c.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Stacey Son 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 */ From patchwork Thu Sep 14 20:40:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karim Taha X-Patchwork-Id: 1834495 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=coZ1dppT; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RmqBm6Y37z1yhd for ; Fri, 15 Sep 2023 06:47:28 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qgtAh-0003Fn-Gi; Thu, 14 Sep 2023 16:42:43 -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 1qgtAc-00038l-8Z for qemu-devel@nongnu.org; Thu, 14 Sep 2023 16:42:40 -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 1qgtAa-0006Ji-L9 for qemu-devel@nongnu.org; Thu, 14 Sep 2023 16:42:38 -0400 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-401d6f6b2e0so16374875e9.1 for ; Thu, 14 Sep 2023 13:42:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694724154; x=1695328954; 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=A4cB5XU1wHkue/WY2K/nTLg+N/2Q1Zd6Xjuos7I4bgs=; b=coZ1dppTgfXqlXL8QOtoHAGR7EgkQ9wNev39r3HtUXPUkvlXFRiOJnHy8OkPtJnKHQ Dt7as5vv088aQkmPiPXDHh+Etpt32NyIwr66KWwn7UNMj/aNv05fBgRxXcapQ5udLud1 Mw5BuDLdn8WAci2b2HNJYeoU5yl4ym7nAL4xCvXAzFzOCspHzCb1eR9sns9zRt1zov1D lC0ffKl3ISTMYqDMDk6i3Dh+/ilx8CieG0D4ELd1KcMNsBzwskwUIew/otMaTALaPB2X GulV7gdaXKE9v196b00PCsAqGwPQKGtsCpSV3CakTQIjQLbvXrAgOqP0K7OhWv9AjspT tnFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694724154; x=1695328954; 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=A4cB5XU1wHkue/WY2K/nTLg+N/2Q1Zd6Xjuos7I4bgs=; b=vU6KHFSCznq0xCp6FKJ3mlu6YLRrGOtzDVxKv95MoOxa+FVssDI6FRtL4FVlrP+Q4i QgpZEdhTYv4LoMUA6f0CTHUEsEKDxyW9GjCLL3P34a0jyLAUqKAgRDpdVaDNB7tkmpn3 J4w46XhDYq/bHfBNoiVMGBa1AyAwxIkbKSM2nt+A2c9WFb2huqL08mgS3getHr+h7eQ5 ypcMPKFYMWj88zan8CccUwald4beyoObTWh4/rxP6mOtnldOa4K9duP2RZa2dmHZ0nG0 Ug7UiMUuT7B2egDYRg/LjL10cYpq9KSoGPXx4lzAc34wmiQvt7kNrtkVOuOWscXgZbbb AZ+g== X-Gm-Message-State: AOJu0YyfnF8QVuXA0y5Oavdv9yWk+6dxaWUdtmtff+FjABn53Awb/8JW fQKk4BX9idlme95Gye/dGoAm0+QfuHU= X-Google-Smtp-Source: AGHT+IH3vJAXq/MUxfyNyRqn4ko9TbB1IaNJ6cTSHv2YfF0rDoDrSuIg1vq9l3Z4n621NjxdbWSjJQ== X-Received: by 2002:adf:fe10:0:b0:31a:cca0:2f3a with SMTP id n16-20020adffe10000000b0031acca02f3amr2424326wrr.0.1694724154115; Thu, 14 Sep 2023 13:42:34 -0700 (PDT) Received: from karim.my.domain ([197.39.44.105]) by smtp.gmail.com with ESMTPSA id j3-20020a056000124300b0031f34a395e7sm2661880wrx.45.2023.09.14.13.42.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 13:42:33 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: Richard Henderson , imp@bsdimp.com, Karim Taha , Kyle Evans Subject: [PATCH v5 05/23] bsd-user: Implement shm_open2(2) system call Date: Thu, 14 Sep 2023 23:40:49 +0300 Message-ID: <20230914204107.23778-6-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230914204107.23778-1-kariem.taha2.7@gmail.com> References: <20230914204107.23778-1-kariem.taha2.7@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wm1-x32d.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Kyle Evans Signed-off-by: Karim Taha Reviewed-by: Richard Henderson Reviewed-by: Warner Losh --- bsd-user/freebsd/os-misc.h | 42 +++++++++++++++++++++++++++++++++++ bsd-user/freebsd/os-syscall.c | 10 +++++++++ 2 files changed, 52 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 +int shm_open2(const char *path, int flags, mode_t mode, int shmflags, + const char *); + +#if defined(__FreeBSD_version) && __FreeBSD_version >= 1300048 +/* shm_open2(2) */ +static inline abi_long do_freebsd_shm_open2(abi_ulong pathptr, abi_ulong flags, + abi_long mode, abi_ulong shmflags, abi_ulong nameptr) +{ + int ret; + void *uname, *upath; + + if (pathptr == (uintptr_t)SHM_ANON) { + upath = SHM_ANON; + } else { + upath = lock_user_string(pathptr); + if (upath == NULL) { + return -TARGET_EFAULT; + } + } + + uname = NULL; + if (nameptr != 0) { + uname = lock_user_string(nameptr); + if (uname == NULL) { + unlock_user(upath, pathptr, 0); + return -TARGET_EFAULT; + } + } + ret = get_errno(shm_open2(upath, + target_to_host_bitmask(flags, fcntl_flags_tbl), mode, + target_to_host_bitmask(shmflags, shmflag_flags_tbl), uname)); + + if (upath != SHM_ANON) { + unlock_user(upath, pathptr, 0); + } + if (uname != NULL) { + unlock_user(uname, nameptr, 0); + } + return ret; +} +#endif /* __FreeBSD_version >= 1300048 */ + #endif /* OS_MISC_H */ diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index fa60df529e..74146d8c72 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -33,11 +33,13 @@ #include "signal-common.h" #include "user/syscall-trace.h" +/* BSD independent syscall shims */ #include "bsd-file.h" #include "bsd-proc.h" /* *BSD dependent syscall shims */ #include "os-stat.h" +#include "os-misc.h" /* I/O */ safe_syscall3(int, open, const char *, path, int, flags, mode_t, mode); @@ -592,6 +594,14 @@ static abi_long freebsd_syscall(void *cpu_env, int num, abi_long arg1, ret = do_freebsd_fcntl(arg1, arg2, arg3); break; + /* + * Memory management system calls. + */ +#if defined(__FreeBSD_version) && __FreeBSD_version >= 1300048 + case TARGET_FREEBSD_NR_shm_open2: /* shm_open2(2) */ + ret = do_freebsd_shm_open2(arg1, arg2, arg3, arg4, arg5); + break; +#endif /* * sys{ctl, arch, call} From patchwork Thu Sep 14 20:40:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karim Taha X-Patchwork-Id: 1834497 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=VlKMAYan; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RmqBp090nz1ypW for ; Fri, 15 Sep 2023 06:47:30 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qgtAh-0003Fa-Di; Thu, 14 Sep 2023 16:42:43 -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 1qgtAd-0003As-CG for qemu-devel@nongnu.org; Thu, 14 Sep 2023 16:42:40 -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 1qgtAb-0006Jw-DN for qemu-devel@nongnu.org; Thu, 14 Sep 2023 16:42:38 -0400 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-40434d284f7so12771915e9.3 for ; Thu, 14 Sep 2023 13:42:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694724155; x=1695328955; 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=QZEj0PmQKtrSTSS1pylbPvyIf7jZoRzyI7RzMk4h4sk=; b=VlKMAYanjTDgl3WwRMJELgQXUwTKyELVVYwBcaYRXWSFBFkIbkkQLSmrw3uqjbuxip vVwGnMeqE9KUGM/yDnPVfVg1+2WaBMA904QoiUIG71eZ+FQNs/JntMYGd3RUD0TG+eDb UPIEZeSkCKVpe9C75/WZ0y+iirJCdu77MKjUpo04QBykR4z5SZB1gX2pMcVU4PCHkD2x aSjIaSO7xfKwyKMGR9pc0rYUHaIeZ1ZVFuKzaeR2gJ0kmit3gFW35yUdfME3vrQTSamJ NaFa83B8rxhRWCyVhbnwgvp6B7+8wf7bFJzeKhgXndD/KmJKNGgqmCZ8TKPk0Ow8WJkL +2ag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694724155; x=1695328955; 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=QZEj0PmQKtrSTSS1pylbPvyIf7jZoRzyI7RzMk4h4sk=; b=QT05EZBLqDtn85CmkT8t1Y7XC0NuYe+B2SrnuaOJoNd3S/gR8Ovoy6CP6tU5ckoOJ5 O192g3oyeR+Tty6DE6ABuKV1voq4O3tClUJc+OZHR6uEIfbkibyezVRYaiWYOcQoPQWe W+tUKkqAScXd4fD4E8TW7m5e3Nnu+boC70KKb5QlCkmun0Yc/ClVUKq/BuXko6tbj9oV DTxfnV9N/NK8wrM+Lg87Z4+dPzWtGA1VZD+V8m6mUBA264SsRu1wzuLmuuyZYbytXE5z mk974xOMItpNaJTEsDk+2zZEdLQFHnDx6ea+BxSbD6xtE08g53a7srjCZZeN8GTE9z+/ rCoA== X-Gm-Message-State: AOJu0YyB568APomvAOoygTse1O0owyjyjd+peEUn+lee1xW8KPK48hWT f9mCEj9Llt1HoKbtz1tYDplUaCt5pTU= X-Google-Smtp-Source: AGHT+IH5DOY7De5C/jJNoV6F6BJedkha8rI7y+IyzQ+qLYHceeD6zX7ksjxOxjByQtbtaadcMyjE1w== X-Received: by 2002:a5d:5107:0:b0:319:6966:f20e with SMTP id s7-20020a5d5107000000b003196966f20emr5239543wrt.71.1694724155383; Thu, 14 Sep 2023 13:42:35 -0700 (PDT) Received: from karim.my.domain ([197.39.44.105]) by smtp.gmail.com with ESMTPSA id j3-20020a056000124300b0031f34a395e7sm2661880wrx.45.2023.09.14.13.42.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 13:42:35 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: Richard Henderson , imp@bsdimp.com, Kyle Evans , Karim Taha Subject: [PATCH v5 06/23] bsd-user: Implement shm_rename(2) system call Date: Thu, 14 Sep 2023 23:40:50 +0300 Message-ID: <20230914204107.23778-7-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230914204107.23778-1-kariem.taha2.7@gmail.com> References: <20230914204107.23778-1-kariem.taha2.7@gmail.com> MIME-Version: 1.0 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: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Kyle Evans Signed-off-by: Kyle Evans Signed-off-by: Karim Taha Reviewed-by: 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 pathptr, abi_ulong flags, } #endif /* __FreeBSD_version >= 1300048 */ +#if defined(__FreeBSD_version) && __FreeBSD_version >= 1300049 +/* shm_rename(2) */ +static inline abi_long do_freebsd_shm_rename(abi_ulong fromptr, abi_ulong toptr, + abi_ulong flags) +{ + int ret; + void *ufrom, *uto; + + ufrom = lock_user_string(fromptr); + if (ufrom == NULL) { + return -TARGET_EFAULT; + } + uto = lock_user_string(toptr); + if (uto == NULL) { + unlock_user(ufrom, fromptr, 0); + return -TARGET_EFAULT; + } + ret = get_errno(shm_rename(ufrom, uto, flags)); + unlock_user(ufrom, fromptr, 0); + unlock_user(uto, toptr, 0); + + return ret; +} +#endif /* __FreeBSD_version >= 1300049 */ #endif /* OS_MISC_H */ diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index 74146d8c72..ae92a2314c 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -603,6 +603,12 @@ static abi_long freebsd_syscall(void *cpu_env, int num, abi_long arg1, break; #endif +#if defined(__FreeBSD_version) && __FreeBSD_version >= 1300049 + case TARGET_FREEBSD_NR_shm_rename: /* shm_rename(2) */ + ret = do_freebsd_shm_rename(arg1, arg2, arg3); + break; +#endif + /* * sys{ctl, arch, call} */ From patchwork Thu Sep 14 20:40:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karim Taha X-Patchwork-Id: 1834489 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=FNqw5/Zt; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Rmq7t0NwKz1yh0 for ; Fri, 15 Sep 2023 06:44:58 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qgtAj-0003HB-QN; Thu, 14 Sep 2023 16:42:46 -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 1qgtAe-0003Bs-Kk for qemu-devel@nongnu.org; Thu, 14 Sep 2023 16:42:40 -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 1qgtAd-0006KN-4l for qemu-devel@nongnu.org; Thu, 14 Sep 2023 16:42:40 -0400 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-40413ccdd4cso7535585e9.0 for ; Thu, 14 Sep 2023 13:42:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694724156; x=1695328956; 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=tWanWC67jhmn9FXRwvcRc23eY0xLvKm6663P3+ePW3g=; b=FNqw5/ZtT4aFN3BMvqUh9PbSD7pzpq/sy0oyQ/1loh3uSBI0WY6XS26nhgGABG4BUn lXzcZNI/TYootDyvsVq48ktJbryJemzzwjjbsIf/6xH+S60yzX4JEQeH526dcqqvzr/P ucYKywwIAOjmAZQj/fgHyYKs1sx6MaUske5CwKonHCequgTpqdPKG47OQIV/ldfovkzn Zg03Y/ovMZ2BZ/vis17c7/5PpNSS5+enADHTe5woVYWHlz4HGx6ZmhOwsFPr0IToMwbZ Kt7niGPKqblN5mns4uhyyDFFEQyjm7YbZRNjBez6sYxUjsw4z6/v6cNSmJB2u77/ZM1g oX3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694724156; x=1695328956; 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=tWanWC67jhmn9FXRwvcRc23eY0xLvKm6663P3+ePW3g=; b=cxZXI+N53J3qhmWhjEayBKLQK6m/xTCNU1O355KIn1YQYo+zTIgaYAPI0lUBCqsYae nRI6t6fCU2MP17MrInqb5SXZLQ+/JJxKVCbsEG5Ub9oyjOfyBYOh4rHGg/18xnt0DTUE 9Fu2RgIyWyvfQgRQf8olFpMlUK3qAXJ8ImGBN9eaGIELsrlhZ9eFHrsJU2oCs2m+9pR+ ZRbczFPps+5NvVb0iV+WIdkS5zZKsBTcloZulevbKtKAVgQ7pXl0UScabCNKYYL8DIsz TLgZ2OmRZlueeJU4Jq82YcnKK5EJEoodk6s0DqeyUczDvvtk5Zcxy5R1XQIX8h2/yLcn 7llw== X-Gm-Message-State: AOJu0YxGxGKdcnCtEMCdM4KGcgubV0ZA0FkDCq3K4P8g1ykUI3MQAte0 wsC6b6DeLqCSqr6wpO0gRr0jypt3DOE= X-Google-Smtp-Source: AGHT+IGT+WdJtUHy1xxf3raWiXrULDlhBZQQ2fwAkBnMDQDgRYNZ2HgcnQ61XwEH7DVfRhwS9jyEcg== X-Received: by 2002:a5d:4d48:0:b0:317:59a6:6f68 with SMTP id a8-20020a5d4d48000000b0031759a66f68mr2424982wru.0.1694724156662; Thu, 14 Sep 2023 13:42:36 -0700 (PDT) Received: from karim.my.domain ([197.39.44.105]) by smtp.gmail.com with ESMTPSA id j3-20020a056000124300b0031f34a395e7sm2661880wrx.45.2023.09.14.13.42.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 13:42:36 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: Richard Henderson , imp@bsdimp.com, Karim Taha Subject: [PATCH v5 07/23] bsd-user: Add bsd-mem.c to meson.build Date: Thu, 14 Sep 2023 23:40:51 +0300 Message-ID: <20230914204107.23778-8-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230914204107.23778-1-kariem.taha2.7@gmail.com> References: <20230914204107.23778-1-kariem.taha2.7@gmail.com> MIME-Version: 1.0 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: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 = ss.source_set() common_user_inc += include_directories('include') bsd_user_ss.add(files( + 'bsd-mem.c', 'bsdload.c', 'elfload.c', 'main.c', From patchwork Thu Sep 14 20:40:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Karim Taha X-Patchwork-Id: 1834503 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=fif4YFci; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RmqC31B8vz1yhd for ; Fri, 15 Sep 2023 06:47:43 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qgtAq-0003NQ-Li; Thu, 14 Sep 2023 16:42:52 -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 1qgtAf-0003Ct-Sw for qemu-devel@nongnu.org; Thu, 14 Sep 2023 16:42:42 -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 1qgtAe-0006Kr-2J for qemu-devel@nongnu.org; Thu, 14 Sep 2023 16:42:41 -0400 Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-307d58b3efbso1280201f8f.0 for ; Thu, 14 Sep 2023 13:42:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694724158; x=1695328958; 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=Zuun86h4+Ki7eEXQiRwiN35p7fie3LoCiJTVqacEJnk=; b=fif4YFciEZshgIk6GV4FdVMiZ9dP+zVYslbvp8o24fj3C2NKU+w2VWD5JnDLr2ybNA 7tNbEC7HKKE72ps4y1ZBsfN+S148fsoPBCdre3BNBpNMCcmucoHbdV6yUthBjrnqBPse 8DWewfHcaYSkd67/6rqqYtjWFNOyeLAZmN7H24HFKvQInGk7SbztWLoWmnbDw2LRwfgi JgghbOGSMmky4TWbTc3rQl2V2aIXt2h9IAbLQhWDh5DiugUvHlAh42BtiIyIXu7QXjdd WSvMiUFMkJHs0M3W05UWJfhehxd5ndFKX+TINHmnREacf3ZMgjfnvAvBd3eXDmf+lOhv eiyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694724158; x=1695328958; 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=Zuun86h4+Ki7eEXQiRwiN35p7fie3LoCiJTVqacEJnk=; b=Tgx8rUCNpO8JchGRujzwvyS2vAbibpV4tprjmXg2o3aVNZzOCE2d3asZ8ZlO9/WbtE sywKbC/ZdEFELO4dX7LT68fBqdy1g0aGVfElzJuYvmguC2m1eue38C40MlOI6KW9Xmfu ymBUoIDDXWVS67nkecwIcfybZPg1FtRDkuHoXmFZ+v4+jYcDkdCUYzuyik679fnpKSD8 SJjOns12sr39nD1j+qXp3/nKKSz0NcEuMn1bvRynpCResydF0NZ/idGuK3+D1ksH4Vtb IwKMY/zVKjIFLw2aN0acCY7gP0b+GuRRwOltxmBcV6HnppjlGTWX9FUBmpzj7QYV8HDt Uygg== X-Gm-Message-State: AOJu0YwulqCdNvs+gLx5n+ZB48KINPSKrIKzDJPF+iWb0Q7nwb/a0x6o CNLyDfbsvBxvnfoy/A4YFi+wL/Y7eCo= X-Google-Smtp-Source: AGHT+IH8PM6sXMRAIzIVBf7a/tGjf13xaSSf0DU9fFPwMRxoc/1cWn315Vpqd3WT93hZoq1OQEddOw== X-Received: by 2002:a5d:538f:0:b0:319:67da:ed68 with SMTP id d15-20020a5d538f000000b0031967daed68mr5548894wrv.7.1694724158068; Thu, 14 Sep 2023 13:42:38 -0700 (PDT) Received: from karim.my.domain ([197.39.44.105]) by smtp.gmail.com with ESMTPSA id j3-20020a056000124300b0031f34a395e7sm2661880wrx.45.2023.09.14.13.42.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 13:42:37 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: Richard Henderson , imp@bsdimp.com, Stacey Son , =?utf-8?q?Mika=C3=ABl_Urankar?= , Karim Taha Subject: [PATCH v5 08/23] bsd-user: Implement target_set_brk function in bsd-mem.c instead of os-syscall.c Date: Thu, 14 Sep 2023 23:40:52 +0300 Message-ID: <20230914204107.23778-9-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230914204107.23778-1-kariem.taha2.7@gmail.com> References: <20230914204107.23778-1-kariem.taha2.7@gmail.com> MIME-Version: 1.0 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: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Stacey Son The 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ël Urankar Signed-off-by: Mikaël Urankar Signed-off-by: Karim Taha Reviewed-by: Warner Losh Reviewed-by: Richard Henderson --- bsd-user/bsd-mem.c | 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 = TARGET_PAGE_ALIGN(new_brk); + initial_target_brk = target_brk; +} diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index ae92a2314c..4c99760a21 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -60,10 +60,6 @@ safe_syscall3(ssize_t, writev, int, fd, const struct iovec *, iov, int, iovcnt); safe_syscall4(ssize_t, pwritev, int, fd, const struct iovec *, iov, int, iovcnt, off_t, offset); -void target_set_brk(abi_ulong new_brk) -{ -} - /* * errno conversion. */ From patchwork Thu Sep 14 20:40:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karim Taha X-Patchwork-Id: 1834493 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=JHVBPNql; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Rmq9l0t59z1yhd for ; Fri, 15 Sep 2023 06:46:35 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qgtAz-0003XB-2w; Thu, 14 Sep 2023 16:43: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 1qgtAs-0003OK-De for qemu-devel@nongnu.org; Thu, 14 Sep 2023 16:42:54 -0400 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qgtAf-0006LA-LY for qemu-devel@nongnu.org; Thu, 14 Sep 2023 16:42:54 -0400 Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-31aeedbb264so1273994f8f.0 for ; Thu, 14 Sep 2023 13:42:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694724159; x=1695328959; 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=6kOFVD7x0CWlInCOpBq7W9+nfPWQu2AwCNVWCQ27xk4=; b=JHVBPNql/KEdrE6wc55G1lkVSglrj/yDs1OZuDNwlyT/UJsqJ/kINlEVnUcCRiwZRF p4RE83NEbv62zzFU89xUH+OWM4sT2MtGnblNvDV9jZPp+rlih5+FDNvSXQjyWi1fXYkV /D4E7t09kP8kShhUorsb9uGCzlBfhbceqeexdgYWvkbq/cD7irzxIMKlcJ2KAsVCC/8P IFojh81f0j/OMsTY6rIeZvrUV4HRqwB+atDrK0yhgACaXOgrVjd2ZyyagMLbwzt0TFib pn8ptU9s5XJvRMFr6/6bgXh3VFEpxWrOih/rwl6Lkpeogn6mSsZa2TA/G97qPWmGMTdW bwAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694724159; x=1695328959; 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=6kOFVD7x0CWlInCOpBq7W9+nfPWQu2AwCNVWCQ27xk4=; b=O2C8WB6iBk43cVCDPE2SJmkmez1Hz+Lq579MpDXAS0e2ajkyQuYPLhTVzb3L6HCUYF RC/sgVYY9b6vrntAT2q538kb1N30xhjp4dUpNg3w5iro6OnvSNpMTYI1T78i2oJhCxnb j/bVtLqRSe+LstIg/u3QLcg1Oi5g86VIFPWYw90OgdVh9QV7L70UKmiCN8a2fuBIPMu+ 8L7nBgqYquX9vAsdMMafqK+J64GWh9D2fDtI3nNkQwtaNxzebbhSmcc6vriHVW/ojPQe 30f3KpTV9hoLpWPWFoTwMuls+NZZZ1EbUrlTBaS7jYNCbU03x+clRMiTLdGuAvdKpWcp ITNA== X-Gm-Message-State: AOJu0Yw1X930XHmaZvpkKIfkRkGZjvtqhLNo+XeuVGArIMLs+jADn5iQ sEPZwcWepmq9qhzwQ35HWp1qz2Lal5k= X-Google-Smtp-Source: AGHT+IHn7Em2SF5Q6WdTIMI+MGwi7sWNCQ7xGoef7gTIZAjbPgn7R3SKTnzGNBK7MAma32ASq0bpbw== X-Received: by 2002:a5d:658e:0:b0:319:7a72:5d82 with SMTP id q14-20020a5d658e000000b003197a725d82mr5638059wru.21.1694724159562; Thu, 14 Sep 2023 13:42:39 -0700 (PDT) Received: from karim.my.domain ([197.39.44.105]) by smtp.gmail.com with ESMTPSA id j3-20020a056000124300b0031f34a395e7sm2661880wrx.45.2023.09.14.13.42.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 13:42:38 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: Richard Henderson , imp@bsdimp.com, Stacey Son , Karim Taha Subject: [PATCH v5 09/23] bsd-user: Implement ipc_perm conversion between host and target. Date: Thu, 14 Sep 2023 23:40:53 +0300 Message-ID: <20230914204107.23778-10-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230914204107.23778-1-kariem.taha2.7@gmail.com> References: <20230914204107.23778-1-kariem.taha2.7@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42a; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wr1-x42a.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Stacey Son Signed-off-by: Stacey Son Signed-off-by: Karim Taha Reviewed-by: Richard Henderson Reviewed-by: Warner Losh --- bsd-user/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 = TARGET_PAGE_ALIGN(new_brk); initial_target_brk = 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); +} + From patchwork Thu Sep 14 20:40:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karim Taha X-Patchwork-Id: 1834487 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=DD9Rc4F3; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Rmq6l71sPz1yh0 for ; Fri, 15 Sep 2023 06:43:59 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qgtAs-0003OW-RR; Thu, 14 Sep 2023 16:42:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qgtAn-0003Jp-KS for qemu-devel@nongnu.org; Thu, 14 Sep 2023 16:42:50 -0400 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qgtAh-0006N0-1q for qemu-devel@nongnu.org; Thu, 14 Sep 2023 16:42:49 -0400 Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-31c7912416bso1263887f8f.1 for ; Thu, 14 Sep 2023 13:42:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694724161; x=1695328961; 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=xTuAkybq2jfJV9OdRT1tDzyr/5NPWRVF8sB4olFps3M=; b=DD9Rc4F3rQhuhO0QW8VupBsU6jeyZVi3XL6gRB0/QOYfxPdt4KiHGzCXdzHDkofKXm /4hthjEoQFaf/FniTieRdUUffQOiCxKYKi6z9Of9K/vBeosiDEHQ7FQkXSFlw3SXFgeO TSx4zok61OspBW4jYp8CEBQwqp3adULevq4RwT66BvfscIQWzOFjbHNA+cZ4SdsfqaNc QwbmUTMPjog3HcEAftxS4RFb3pQI9z11G2+1dRjttYMJwEH1UFLhBu8wMQ3yNNrYyC+y 81t/9KeVaygr4xki4IrskHD6LwvMD/BW6bOEfmkp2SqFqyFja9RIy9FGHuwx6Kw37M87 Y89A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694724161; x=1695328961; 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=xTuAkybq2jfJV9OdRT1tDzyr/5NPWRVF8sB4olFps3M=; b=QT1ltTT5W1OZPJQT/V3sK/BNf4AQ2w8u5+QfSaGRhLy2gYsIxUmvEx45NFYJswJKYc D8LJ/fv0uPkQX2i9omaWAe1ZL04oJzHgDzcJYpUxkT7lzN21rKHS0TupyahpKYIMc2q5 0lFTNJ4F+dlQj07HdYYfnXenUuPh0jQ3+3bJFaAvf7eeJ1V+2eNYNC1XKF+Fuo3IDyED LQV8ce3x+OP3e1YHVifFzxjIAof2m8uoJQm1FWyjn82p3MqajToluT4I7VrwcpxYoKLD ePI/sa+eFGOOzqPMg5TYu/tVyWcJUqSvEDxNa84gOOCMo2w1eYbb2K6NSeqHLB8teDhB Mtcw== X-Gm-Message-State: AOJu0Yziy8EN0DE7z1JZAIKhDPGdZk3z+GKkig0rO5l3d3WJJqJy+yac UeUpKeBhD48prx+k/nq/eoDVp3ucCRs= X-Google-Smtp-Source: AGHT+IF++thn8FgbMGBD6WsHrg/ymPILWv55N4sVuG3aNEWmfvPYyV3nOo8rA9+ShToSHJAvlUZraA== X-Received: by 2002:a5d:4d0c:0:b0:315:99be:6fe4 with SMTP id z12-20020a5d4d0c000000b0031599be6fe4mr5853797wrt.69.1694724161197; Thu, 14 Sep 2023 13:42:41 -0700 (PDT) Received: from karim.my.domain ([197.39.44.105]) by smtp.gmail.com with ESMTPSA id j3-20020a056000124300b0031f34a395e7sm2661880wrx.45.2023.09.14.13.42.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 13:42:40 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: Richard Henderson , imp@bsdimp.com, Stacey Son , Karim Taha Subject: [PATCH v5 10/23] bsd-user: Implement shmid_ds conversion between host and target. Date: Thu, 14 Sep 2023 23:40:54 +0300 Message-ID: <20230914204107.23778-11-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230914204107.23778-1-kariem.taha2.7@gmail.com> References: <20230914204107.23778-1-kariem.taha2.7@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::433; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wr1-x433.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Stacey Son Signed-off-by: Stacey Son Signed-off-by: Karim Taha Reviewed-by: Richard Henderson Reviewed-by: Warner Losh --- bsd-user/bsd-mem.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/bsd-user/bsd-mem.c b/bsd-user/bsd-mem.c index 46cda8eb5c..2ab1334b70 100644 --- a/bsd-user/bsd-mem.c +++ b/bsd-user/bsd-mem.c @@ -43,6 +43,30 @@ void target_to_host_ipc_perm__locked(struct ipc_perm *host_ip, __get_user(host_ip->key, &target_ip->key); } +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 +79,26 @@ void host_to_target_ipc_perm__locked(struct target_ipc_perm *target_ip, __put_user(host_ip->key, &target_ip->key); } +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; +} From patchwork Thu Sep 14 20:40:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karim Taha X-Patchwork-Id: 1834504 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=UECPSfBl; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RmqCB2TXgz1yhd for ; Fri, 15 Sep 2023 06:47:50 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qgtAs-0003OQ-Ph; Thu, 14 Sep 2023 16:42:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qgtAo-0003K8-GU for qemu-devel@nongnu.org; Thu, 14 Sep 2023 16:42:50 -0400 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qgtAi-0006NG-IJ for qemu-devel@nongnu.org; Thu, 14 Sep 2023 16:42:49 -0400 Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-31f7638be6eso1300692f8f.3 for ; Thu, 14 Sep 2023 13:42:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694724163; x=1695328963; 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=K19uu8/17P76Q44mQCDZAyL1sOi2UHp67TYKWHLTGQs=; b=UECPSfBl8Fr3H0iTrQ5DqcSmPgIewr0h8VDGrJIRKppjgvKXirIWXWYlKCIsw95t0T XEFwJczmyfZvQMX4ouwX3UGhV5mLcCJiSwBzFQeqGPtR4FAeQS/ybctfkitNWGx4F14M HqMMV7F4TpFUXE+qRf6GOqdKOF6p9+VsC04+51rP6+wxU9eVtXZ3zXDavFDY/mzLfq6B DKYwK2Fm/bIqx6hEM+U0Sfr4L1//eMj5KdRr82FnbluYJXj+OmEB/9nZksY5cORhW9I/ 4rp3JxI8AkHlSpwXn89PSSCs0L8gaRw+vQJ5V054TEIl/rgypxaHpHY9rLqYB4aeN3Gn 4x+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694724163; x=1695328963; 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=K19uu8/17P76Q44mQCDZAyL1sOi2UHp67TYKWHLTGQs=; b=oTJl/5Wuazh7Q26BBpIcDPrkTuW2fxLC+grr3ep+z0E4AESCl8jfbNq+M8Vops1cRZ /a51CWt2kHXiHz2KjmNoJ6fYBMEde5MZBdFyou0NxNIEHX5pJnHpSpruKOYksGswu6YO X1Kzn/QpyUiA7hvdrMhGFyH9DUtvUYj34jwwHHfQm3O8cnccELnq+tDeQKB/4mNwvOQR 4SofQVTwE4vbpndy/ecnEsa/ZB9G/WCJ8x66ebRf+TiXLuOL+G0zUzc4vrEyUJRc9nzw aCWQ6E9UKE0pvWJ37GB0xFS6MkpjPhCtIzBPlMkYWr+5HZW1VM9i7P1SaJJjvyAanO7T AbTw== X-Gm-Message-State: AOJu0YyduDTqXUnYoUdpCUqm1A2EdLRg/LJibCgwgAam57t4wYIOTUJ5 jsqSlgdOwZLNbV3vRl7gdX3ACD9rULY= X-Google-Smtp-Source: AGHT+IGvClaumgiL4vDjmJkeUqzBtQjedNyGCSEg1cw3YTwIfuj6rB2m8L4OpkmW+HiOaa72xiOYkQ== X-Received: by 2002:a5d:67c8:0:b0:317:5a99:4549 with SMTP id n8-20020a5d67c8000000b003175a994549mr5701313wrw.0.1694724162658; Thu, 14 Sep 2023 13:42:42 -0700 (PDT) Received: from karim.my.domain ([197.39.44.105]) by smtp.gmail.com with ESMTPSA id j3-20020a056000124300b0031f34a395e7sm2661880wrx.45.2023.09.14.13.42.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 13:42:42 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: Richard Henderson , imp@bsdimp.com, Stacey Son , Karim Taha Subject: [PATCH v5 11/23] bsd-user: Introduce bsd-mem.h to the source tree Date: Thu, 14 Sep 2023 23:40:55 +0300 Message-ID: <20230914204107.23778-12-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230914204107.23778-1-kariem.taha2.7@gmail.com> References: <20230914204107.23778-1-kariem.taha2.7@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42a; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wr1-x42a.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Stacey Son 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 PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef BSD_USER_BSD_MEM_H +#define BSD_USER_BSD_MEM_H + +#include +#include +#include +#include +#include + +#include "qemu-bsd.h" + +extern struct bsd_shm_regions bsd_shm_regions[]; +extern abi_ulong 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 4c99760a21..42cd52a406 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -35,6 +35,7 @@ /* BSD independent syscall shims */ #include "bsd-file.h" +#include "bsd-mem.h" #include "bsd-proc.h" /* *BSD dependent syscall shims */ From patchwork Thu Sep 14 20:40:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karim Taha X-Patchwork-Id: 1834496 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=SFAtbsY/; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RmqBn34tZz1ypL for ; Fri, 15 Sep 2023 06:47:29 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qgtAq-0003NR-Ld; Thu, 14 Sep 2023 16:42:52 -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 1qgtAp-0003Kn-0j for qemu-devel@nongnu.org; Thu, 14 Sep 2023 16:42:51 -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 1qgtAl-0006Ne-GX for qemu-devel@nongnu.org; Thu, 14 Sep 2023 16:42:50 -0400 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-401b0d97850so14445285e9.2 for ; Thu, 14 Sep 2023 13:42:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694724164; x=1695328964; 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=kz+23oIf5l7ES1zwv+zlawDrL/8dIy3f1vjxlJaYUac=; b=SFAtbsY/FUUa0qycDs+sh3REk6Ii8RIIMJjZ8Sbgjs2nVOfbXn4Bl99dtqx40BnyP8 Ms6jqHVR1feVMWvqekmUEkp+Gr/yGTbwb4+u++3XbghVd5qWtntzOyLrEZdxzTIeohl+ oBtjnhQ306DW5juzes6BfaDCFii2EWuBEGrdqH0st1h3iPrkCh7huRXQg/iwAP7nBAft A0pobBYl5IccaiiMCmHL/LR0rFAzOX4Oc+f3cfmVc0t2b0vnLdqVphmu4AShsFVO+WsT nNEOJm9Kn4mV8+JZVf+iSVbHtlO3N+Ghn1kuvmh1FJmkpURkgy/ScUoGjj4VtLo8AB/A z6WA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694724164; x=1695328964; 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=kz+23oIf5l7ES1zwv+zlawDrL/8dIy3f1vjxlJaYUac=; b=ZQCMIJoAtpck7VldfVIVYT5j3rWX2cZ4eK8hqGKcn2/po+M583xouFuy/jwFzviLDl eqpn0K9w03WT5GF8rNAaCxzn1mviwDmRN5U2SYoIr9WsGFuI7fo4Lu/WAuK7Davb5zmO VRSLqasB5bsffkjsyQ3juRcXC9L32frQrm8fH49AgmLYiNKohut1f+6neqt8w8TfIpDe JKdTLnZ3J0bmOnEFoZ1R5iEuJqWTEoJwFptGGffeBTJxlweRWz9WPHGX5HfaLW3BWqRX a1rVUKyb2c+vfukvewc6bxMwc54kbYqwb0DVsYG2xc47ZJd3jmyoRayXYIVLsiskT2m9 qUOA== X-Gm-Message-State: AOJu0Yz6DEORos8T7ahSn9rm9N+ffdMbr+qLTyyRl7a10XwtkPy8xkSc uDSX4Si5CNWS3UBlyPid1Yrp8DQQqlA= X-Google-Smtp-Source: AGHT+IHd6Bi9n+rQLRhkvQDVxOvkOyfc3Sd/1qKmbx06Nc7KUU7WlAGXy5wtQEo4E+/3Of3kfQ01wg== X-Received: by 2002:a1c:7c0e:0:b0:401:b204:3b84 with SMTP id x14-20020a1c7c0e000000b00401b2043b84mr5543398wmc.40.1694724164160; Thu, 14 Sep 2023 13:42:44 -0700 (PDT) Received: from karim.my.domain ([197.39.44.105]) by smtp.gmail.com with ESMTPSA id j3-20020a056000124300b0031f34a395e7sm2661880wrx.45.2023.09.14.13.42.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 13:42:43 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: Richard Henderson , imp@bsdimp.com, Stacey Son , Karim Taha Subject: [PATCH v5 12/23] bsd-user: Implement mmap(2) and munmap(2) Date: Thu, 14 Sep 2023 23:40:56 +0300 Message-ID: <20230914204107.23778-13-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230914204107.23778-1-kariem.taha2.7@gmail.com> References: <20230914204107.23778-1-kariem.taha2.7@gmail.com> MIME-Version: 1.0 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: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Stacey Son Signed-off-by: Stacey Son Signed-off-by: Karim Taha Reviewed-by: Warner Losh Reviewed-by: Richard Henderson --- bsd-user/bsd-mem.h | 20 ++++++++++++++++++++ bsd-user/freebsd/os-syscall.c | 9 +++++++++ 2 files changed, 29 insertions(+) diff --git a/bsd-user/bsd-mem.h b/bsd-user/bsd-mem.h index 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; +/* mmap(2) */ +static inline abi_long do_bsd_mmap(void *cpu_env, abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, abi_long arg5, abi_long arg6, abi_long arg7, + abi_long arg8) +{ + if (regpairs_aligned(cpu_env) != 0) { + arg6 = arg7; + arg7 = arg8; + } + return get_errno(target_mmap(arg1, arg2, arg3, + target_to_host_bitmask(arg4, mmap_flags_tbl), + arg5, target_arg64(arg6, arg7))); +} + +/* munmap(2) */ +static inline abi_long do_bsd_munmap(abi_long arg1, abi_long arg2) +{ + return get_errno(target_munmap(arg1, arg2)); +} + #endif /* BSD_USER_BSD_MEM_H */ diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index 42cd52a406..893881c179 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -594,6 +594,15 @@ static abi_long freebsd_syscall(void *cpu_env, int num, abi_long arg1, /* * Memory management system calls. */ + case TARGET_FREEBSD_NR_mmap: /* mmap(2) */ + ret = do_bsd_mmap(cpu_env, arg1, arg2, arg3, arg4, arg5, arg6, arg7, + arg8); + break; + + case TARGET_FREEBSD_NR_munmap: /* munmap(2) */ + ret = do_bsd_munmap(arg1, arg2); + break; + #if defined(__FreeBSD_version) && __FreeBSD_version >= 1300048 case TARGET_FREEBSD_NR_shm_open2: /* shm_open2(2) */ ret = do_freebsd_shm_open2(arg1, arg2, arg3, arg4, arg5); From patchwork Thu Sep 14 20:40:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karim Taha X-Patchwork-Id: 1834488 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=Mct7NGQi; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Rmq7M5fHGz1yh0 for ; Fri, 15 Sep 2023 06:44:31 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qgtAu-0003Rb-Es; Thu, 14 Sep 2023 16:42:56 -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 1qgtAo-0003Km-UO for qemu-devel@nongnu.org; Thu, 14 Sep 2023 16:42:51 -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 1qgtAl-0006Nu-GO for qemu-devel@nongnu.org; Thu, 14 Sep 2023 16:42:50 -0400 Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-31f71b25a99so1317696f8f.2 for ; Thu, 14 Sep 2023 13:42:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694724165; x=1695328965; 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=QZeOll8BQ09ocoWniNo5vad8KtAP6sMIVNw1ThVgqlQ=; b=Mct7NGQi4+OXQBGOnJSAvh0H4Q7Avq6a/PlwxUH5upnoETwmlRI5hns+cmtVrjbtzl 13ecnE1ZMylAk0o9IFca84oQBfM6VQJZE7HFGmyyE+vm/UiT0/T4lb3xjgeJfcbz6SZv QZvCshdVyWTpO8lT/UtXDkKhK5yrKLFETvdjZiD/JoGtJIn5aoCIXj6JGNv9gJSC34yd 2pHhH4hgZM8l/+E0GVUfFvbGyp+IamnMy8WAzo5GMtnnnZMHgu8VP159fII/b7sTbtKc zl11S+L8qwREsOXYRR94Aswm6jY6p4ppTpiCnmbxDdMWGpkLz3+vkE8y6eiyBMTI2bSy dxtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694724165; x=1695328965; 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=QZeOll8BQ09ocoWniNo5vad8KtAP6sMIVNw1ThVgqlQ=; b=PwrB0+tA6Tl+o9ccpuYbXbiI/LRT5P08tMNlBDMNOa5VPa5rwbxFBqVXYU19AMo2n2 PSK3cAkD5u7MOyBbYA04M+oJ5QeH7+fNo305ylGCkPC85ZZDHeCdmJl34h3AQYv4APLX 1O4glgwug7oInjobUR+vlzpj9Ud4rlUVm4E8pyXSD18jhslkZPvR6W8ZCDHyE0dbw4tW A4E5gYU06IkQHWHGF0klQIJj/hRmtnmYKVipuabLmn99eReqefWliNTWt24PASdJz5Rz 1UQ/RVgvUNPhLc+c1Sn+7L0j5IiF9wix/5PW9WMrjv7N/WM81IdVRJXja2GUOEqdA6qK s4vw== X-Gm-Message-State: AOJu0Yx4uaEA5RXSR4WVmNcR0jUh8VTNZKOaPUa/JLN6QsCBNsXPknu7 J7snPd16j5P2BoLgNDz4Z2Cd97ipK2M= X-Google-Smtp-Source: AGHT+IFaj+4TkrNrhipQidXKeODron/993PKARDJTC1KBkYQRKn+I5gooRh5hCwik8wd6Tdil3LKdQ== X-Received: by 2002:a5d:42ca:0:b0:31f:b6eb:2a9f with SMTP id t10-20020a5d42ca000000b0031fb6eb2a9fmr6189379wrr.7.1694724165496; Thu, 14 Sep 2023 13:42:45 -0700 (PDT) Received: from karim.my.domain ([197.39.44.105]) by smtp.gmail.com with ESMTPSA id j3-20020a056000124300b0031f34a395e7sm2661880wrx.45.2023.09.14.13.42.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 13:42:45 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: Richard Henderson , imp@bsdimp.com, Stacey Son , Karim Taha Subject: [PATCH v5 13/23] bsd-user: Implement mprotect(2) Date: Thu, 14 Sep 2023 23:40:57 +0300 Message-ID: <20230914204107.23778-14-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230914204107.23778-1-kariem.taha2.7@gmail.com> References: <20230914204107.23778-1-kariem.taha2.7@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::431; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wr1-x431.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Stacey Son 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)); } +/* 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 893881c179..74c0624637 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -603,6 +603,10 @@ static abi_long freebsd_syscall(void *cpu_env, int num, abi_long arg1, ret = do_bsd_munmap(arg1, arg2); break; + case TARGET_FREEBSD_NR_mprotect: /* mprotect(2) */ + ret = do_bsd_mprotect(arg1, arg2, arg3); + break; + #if defined(__FreeBSD_version) && __FreeBSD_version >= 1300048 case TARGET_FREEBSD_NR_shm_open2: /* shm_open2(2) */ ret = do_freebsd_shm_open2(arg1, arg2, arg3, arg4, arg5); From patchwork Thu Sep 14 20:40:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karim Taha X-Patchwork-Id: 1834500 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=BVj6KyYt; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RmqBy009yz1yhd for ; Fri, 15 Sep 2023 06:47:37 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qgtAs-0003P0-Uq; Thu, 14 Sep 2023 16:42:55 -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 1qgtAp-0003L6-6u for qemu-devel@nongnu.org; Thu, 14 Sep 2023 16:42:51 -0400 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qgtAm-0006O4-A3 for qemu-devel@nongnu.org; Thu, 14 Sep 2023 16:42:50 -0400 Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-31ad779e6b3so1307216f8f.2 for ; Thu, 14 Sep 2023 13:42:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694724167; x=1695328967; 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=gIuhrcV4QbDTEzQ4pUfV3QzwLu3vit3RoCqbf+B/PKA=; b=BVj6KyYtk5gf+UsdGpqQLGH9m6U84AtJOix8ZmzNkxecbzVenuDqfzMxtNAFleL/eI 7YG45DL8Cgi0yu8FP83P5XBqtIZFHQ4A70liH+Z36lIK9ggeB76oLFDbGtFaeiC8X2SR XZlQftvtcKRtbbSxsAPMFutf+KpjrD0+xSE5w4Y+4yZWY0rkG6NVlr3j/Q5fLkOkaQ31 loMT0SA43wuZOUFxpveAe1NEeY4+LkH1OIveVU05QlJ6I93lcj0DKdudkg2DpAR6z2Mf i4g77YzLRTqJVK59x4+kaDLGgM4kBNK3q+SgOwJEF0Moi4DLaF5mG+ECBcqr6AMVM2/f fMrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694724167; x=1695328967; 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=gIuhrcV4QbDTEzQ4pUfV3QzwLu3vit3RoCqbf+B/PKA=; b=s+sY5gPsmjzzz5RcmdaUwhUBOLjrfOfmg/vOR5eQ1swywxlFhb2WpnG1H9QtD9bid4 hQgf2y/LGakqbmNIBFFT8qSFtdbAA0WYMwwSmfHXVREWXRJtW2C+pREdrptXVfoAsgVH A8gobAYt1aexyoxXJQGay7d3b2nh6jx6HvCjnSaXHj8j0PxKlfKLYPsF8nopAj5pokbw mhBvdOicQmZFmk5ptnNCL75Y1L9SEfX2b3GZHkrKPInOO4ncmKk+cnpv1ywowJww9wYt uvhuWhkW4Ivh1ct9BEIofYQxvScu0j9DB1DpePORlVxpFLBMw/Ab93HIJpkY0hWYw3P0 jWCA== X-Gm-Message-State: AOJu0Yyf2L/+OUKcb++6dLgbFXxasPXLosMDlnFqQBO+evLMXJzPnZoY EGIlQ5B0ES2tXy/Ud7kl1E9X3bWjDKA= X-Google-Smtp-Source: AGHT+IH6TtQcZrQ2gltMGp8WcKm0ils8JrlnBFvhM2FYpL4hKWpbkejY7mfZIFR+1jaaqp6ORqSC8w== X-Received: by 2002:a05:6000:180b:b0:31a:d450:c513 with SMTP id m11-20020a056000180b00b0031ad450c513mr5911869wrh.26.1694724166782; Thu, 14 Sep 2023 13:42:46 -0700 (PDT) Received: from karim.my.domain ([197.39.44.105]) by smtp.gmail.com with ESMTPSA id j3-20020a056000124300b0031f34a395e7sm2661880wrx.45.2023.09.14.13.42.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 13:42:46 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: Richard Henderson , imp@bsdimp.com, Stacey Son , Kyle Evans , Karim Taha Subject: [PATCH v5 14/23] bsd-user: Implement msync(2) Date: Thu, 14 Sep 2023 23:40:58 +0300 Message-ID: <20230914204107.23778-15-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230914204107.23778-1-kariem.taha2.7@gmail.com> References: <20230914204107.23778-1-kariem.taha2.7@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::433; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wr1-x433.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Stacey Son Co-authored-by: Kyle Evans Signed-off-by: Stacey Son Signed-off-by: Kyle Evans Signed-off-by: Karim Taha Reviewed-by: Warner Losh Reviewed-by: Richard Henderson --- bsd-user/bsd-mem.h | 11 +++++++++++ bsd-user/freebsd/os-syscall.c | 4 ++++ 2 files changed, 15 insertions(+) diff --git a/bsd-user/bsd-mem.h b/bsd-user/bsd-mem.h index 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, abi_long arg2, return get_errno(target_mprotect(arg1, arg2, arg3)); } +/* msync(2) */ +static inline abi_long do_bsd_msync(abi_long addr, abi_long len, abi_long flags) +{ + if (!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 74c0624637..5aebb18805 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -607,6 +607,10 @@ static abi_long freebsd_syscall(void *cpu_env, int num, abi_long arg1, ret = do_bsd_mprotect(arg1, arg2, arg3); break; + case TARGET_FREEBSD_NR_msync: /* msync(2) */ + ret = do_bsd_msync(arg1, arg2, arg3); + break; + #if defined(__FreeBSD_version) && __FreeBSD_version >= 1300048 case TARGET_FREEBSD_NR_shm_open2: /* shm_open2(2) */ ret = do_freebsd_shm_open2(arg1, arg2, arg3, arg4, arg5); From patchwork Thu Sep 14 20:40:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karim Taha X-Patchwork-Id: 1834499 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=YgP4J+sx; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RmqBw2wpqz1yhd for ; Fri, 15 Sep 2023 06:47:36 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qgtB0-0003Yb-5L; Thu, 14 Sep 2023 16:43:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qgtAq-0003M1-VS for qemu-devel@nongnu.org; Thu, 14 Sep 2023 16:42:52 -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 1qgtAo-0006OL-8r for qemu-devel@nongnu.org; Thu, 14 Sep 2023 16:42:51 -0400 Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-31427ddd3fbso1220107f8f.0 for ; Thu, 14 Sep 2023 13:42:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694724168; x=1695328968; 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=1y3QJ3NO1OpevaAaEL6gS3rKqXE25lyRwf0WEycZtJA=; b=YgP4J+sxoeaonFjv+/VjbGZKf9CovZACCK9QJe1hzHR78nNMm6t9Z/+QNTxc2IbNL+ 0EMzt+rCx1WSxX3/5pgmMvXknGaj2cYh3EoVIG3UdVCEFLXOZRo84ceiT4nn+R55wCll /cqi4t6ExufOLIjw48ajTYMBJJoqpZWcxme105/3Dg2NdyF/Zd7bZGU4K+BIEUZylDVe 9nzHVmm1RZi1YGEdDX/PElzjPGmhfbxlv0I9+jkLAUYyXGwnfvsS9U5Dpqg9fL/J2Tmz b5yIsjvbT5TxwjUTjLyi/QXtox82axTCAz5kkdsJOocZk+qnqGdcmTXXOh2PT/IPhMof cstA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694724168; x=1695328968; 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=1y3QJ3NO1OpevaAaEL6gS3rKqXE25lyRwf0WEycZtJA=; b=cHWNL2J3GMdV38QuX30OfQePTGMpEG+Zql+2M/LIvW847RkiWdSz3nHXvxgWGQsXxg z6+0sycgDgnGcA0K6TQd+6KBleYKmqnrt3rRnjQa9Oa0MaHNx44JcNGHmgNWaOM4VTuY 86/+zobosg7VqXjxT6Oo4sbv2iPuhJjFsdoeYVCF/MquMy8ej7mVm5IYcDKMZvh7/NgK Ifdl9u1HvXmLkjluyjRT3a04wuSIm+ExdAkqmcwsxHIcBSUvt5zD7USuw/X3yZBQtRN9 LfVyoJPjBECW+HSEqs+eWB40rg3AxvjSvLozlNGG3buA0eOh5gyRll0zoyDd5gIbiVok 4Vzw== X-Gm-Message-State: AOJu0Yz9nau/InOIlYQv4o0fcCsCIn5A2m6F3TQVNq5WdoE5GfPiBdLf Yv/x2WX/4/hoSuGZrl50jWDG45mZDq0= X-Google-Smtp-Source: AGHT+IHAX17EPH7hp2FS1tBf7QpWDoUVTXZtPrWRo1vqEAgtbyhQCQqCKVM7/M00cG0xvyHQUko27Q== X-Received: by 2002:adf:f78b:0:b0:317:636b:fcb1 with SMTP id q11-20020adff78b000000b00317636bfcb1mr5977598wrp.27.1694724168239; Thu, 14 Sep 2023 13:42:48 -0700 (PDT) Received: from karim.my.domain ([197.39.44.105]) by smtp.gmail.com with ESMTPSA id j3-20020a056000124300b0031f34a395e7sm2661880wrx.45.2023.09.14.13.42.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 13:42:47 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: Richard Henderson , imp@bsdimp.com, Stacey Son , Karim Taha Subject: [PATCH v5 15/23] bsd-user: Implement mlock(2), munlock(2), mlockall(2), munlockall(2), minherit(2) Date: Thu, 14 Sep 2023 23:40:59 +0300 Message-ID: <20230914204107.23778-16-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230914204107.23778-1-kariem.taha2.7@gmail.com> References: <20230914204107.23778-1-kariem.taha2.7@gmail.com> MIME-Version: 1.0 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: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Stacey Son Signed-off-by: Stacey Son Signed-off-by: Karim Taha Reviewed-by: Richard Henderson --- bsd-user/bsd-mem.h | 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_long len, abi_long flags) return get_errno(msync(g2h_untagged(addr), len, flags)); } +/* mlock(2) */ +static inline abi_long do_bsd_mlock(abi_long arg1, abi_long arg2) +{ + 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 5aebb18805..553578708b 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -611,6 +611,26 @@ static abi_long freebsd_syscall(void *cpu_env, int num, abi_long arg1, ret = do_bsd_msync(arg1, arg2, arg3); break; + case TARGET_FREEBSD_NR_mlock: /* mlock(2) */ + ret = do_bsd_mlock(arg1, arg2); + break; + + case TARGET_FREEBSD_NR_munlock: /* munlock(2) */ + ret = do_bsd_munlock(arg1, arg2); + break; + + case TARGET_FREEBSD_NR_mlockall: /* mlockall(2) */ + ret = do_bsd_mlockall(arg1); + break; + + case TARGET_FREEBSD_NR_munlockall: /* munlockall(2) */ + ret = do_bsd_munlockall(); + break; + + case TARGET_FREEBSD_NR_minherit: /* minherit(2) */ + ret = do_bsd_minherit(arg1, arg2, arg3); + break; + #if defined(__FreeBSD_version) && __FreeBSD_version >= 1300048 case TARGET_FREEBSD_NR_shm_open2: /* shm_open2(2) */ ret = do_freebsd_shm_open2(arg1, arg2, arg3, arg4, arg5); From patchwork Thu Sep 14 20:41:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karim Taha X-Patchwork-Id: 1834494 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=PdaFDpud; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RmqB34zQSz1yhd for ; Fri, 15 Sep 2023 06:46:51 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qgtB0-0003ZE-PQ; Thu, 14 Sep 2023 16:43:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qgtAr-0003Nh-7k for qemu-devel@nongnu.org; Thu, 14 Sep 2023 16:42:54 -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 1qgtAp-0006Oq-GM for qemu-devel@nongnu.org; Thu, 14 Sep 2023 16:42:52 -0400 Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-31adc5c899fso1253568f8f.2 for ; Thu, 14 Sep 2023 13:42:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694724169; x=1695328969; 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=FYIaVv5fzpG/4IW8/3zE5TeazHpFYJhJio5PGpCXaJY=; b=PdaFDpudHUPolAmDMs2Jm0e8YNAwRyaQoztNgmtoErhnS/VF5KNvLxLKpyEETLLHON tIi71qs/kQKzUsSieDNJgDA9NRGhCNVrlLzyoXRJNY1TF3wzxqfJw9ju+dbDLCDPNOrt IOox3/O3sDgwI/bo/Ftov0Is8gil6TxH5JOxYJdikvvEfQP+8OudIkBz4jP51IpY3Qna OAIFVSHPORI/T57oAzvpf6QhWSFmSkTBodmD/JQ/mTVJxh3UVJVYvUcB6lL9JInmFW8t LbE8BUje3M6ho5Zl/Hm38sjSugfB0ao5UDL4afE/nPmjqTizlU5Au+33MOu8zYi8EmIF 74NA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694724169; x=1695328969; 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=FYIaVv5fzpG/4IW8/3zE5TeazHpFYJhJio5PGpCXaJY=; b=OUbUrnha/BPrawRFqBImbqQyAzRX4bDrVYlKLPxWGT5ztVgK1UL8xgZVNkCzQc7hbR HVyJQ6Z0Jum1EGGjivWb9JtsSFp9rCXguLAa+0LvXMqZ2vDJ5F4Sng1xJvlWH/mQ/cOl j+Vn69i20XjmAtpJ/XDhAAxQjpBd0tJkKWrBtE7/bXZhOotDzqg61Yyvp3KsJQda627T kjz2HgxiGs8e3KJytT8NKB5TytF3xyi5SOsv2mQdURjUm0ybZB68xXRjOnR0hkJKA1Sj /a8iiWO9iI1xKDPPDj6rP4fId8hHinI8AE0cN8s2zJ3RPq7yEEiQImcWo1ohB5uX8xkT 6uGw== X-Gm-Message-State: AOJu0YyEm/BHPyAZ0HSKcfNu4VYerRyVJS6bQjaWLcLVUBMLjFIqPv8I UlbhF0XfqK7M+xee/oSFB/VmPaE2los= X-Google-Smtp-Source: AGHT+IFEcnZtvQe1SwmlWk9AqxBTHYW0b6unqCbhOArNdqykcZU4XDufM9DcxhcA76reBuWRgVSQww== X-Received: by 2002:a05:6000:1a54:b0:317:6470:3271 with SMTP id t20-20020a0560001a5400b0031764703271mr5444213wry.45.1694724169563; Thu, 14 Sep 2023 13:42:49 -0700 (PDT) Received: from karim.my.domain ([197.39.44.105]) by smtp.gmail.com with ESMTPSA id j3-20020a056000124300b0031f34a395e7sm2661880wrx.45.2023.09.14.13.42.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 13:42:49 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: Richard Henderson , imp@bsdimp.com, Karim Taha Subject: [PATCH v5 16/23] bsd-user: Implment madvise(2) to match the linux-user implementation. Date: Thu, 14 Sep 2023 23:41:00 +0300 Message-ID: <20230914204107.23778-17-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230914204107.23778-1-kariem.taha2.7@gmail.com> References: <20230914204107.23778-1-kariem.taha2.7@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::429; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wr1-x429.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Karim Taha Reviewed-by: Richard Henderson Reviewed-by: Warner Losh --- 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..b00ab3aed8 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()); } +/* madvise(2) */ +static inline abi_long do_bsd_madvise(abi_long arg1, abi_long arg2, + abi_long arg3) +{ + abi_ulong len; + int ret = 0; + abi_long start = arg1; + abi_long len_in = arg2; + abi_long advice = arg3; + + if (start & ~TARGET_PAGE_MASK) { + return -TARGET_EINVAL; + } + if (len_in == 0) { + return 0; + } + len = TARGET_PAGE_ALIGN(len_in); + if (len == 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 sometimes + * 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 complicated + * though. + */ + mmap_lock(); + switch (advice) { + case MADV_DONTNEED: + if (page_check_range(start, len, PAGE_PASSTHROUGH)) { + ret = get_errno(madvise(g2h_untagged(start), len, advice)); + if (ret == 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 553578708b..600d048120 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -627,6 +627,10 @@ static abi_long freebsd_syscall(void *cpu_env, int num, abi_long arg1, ret = do_bsd_munlockall(); break; + case TARGET_FREEBSD_NR_madvise: /* madvise(2) */ + ret = do_bsd_madvise(arg1, arg2, arg3); + break; + case TARGET_FREEBSD_NR_minherit: /* minherit(2) */ ret = do_bsd_minherit(arg1, arg2, arg3); break; diff --git a/bsd-user/syscall_defs.h b/bsd-user/syscall_defs.h index f4a5ae2a12..929b155b10 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 misimplemented */ /* MAP_INHERIT */ #define TARGET_FREEBSD_MAP_RESERVED0100 0x0100 /* previously unimplemented */ From patchwork Thu Sep 14 20:41:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karim Taha X-Patchwork-Id: 1834498 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=fnb3fwne; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RmqBr0k2Nz1yhd for ; Fri, 15 Sep 2023 06:47:32 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qgtB3-0003eC-Pe; Thu, 14 Sep 2023 16:43:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qgtAs-0003OS-Kh for qemu-devel@nongnu.org; Thu, 14 Sep 2023 16:42:54 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qgtAr-0006PR-35 for qemu-devel@nongnu.org; Thu, 14 Sep 2023 16:42:54 -0400 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-40476ce8b2fso5234485e9.3 for ; Thu, 14 Sep 2023 13:42:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694724171; x=1695328971; 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=/iih9dJ+hepR7tg2MJ1JLAU9zFKmgRDnfWByt62B4ZM=; b=fnb3fwnewEHbAP0taik0zwXYXyCLFcFZmhCktbPDUpHQGhhVT0or5IVjHywGT/JNFa XJreUt7NX5hVAAH9tnNZfPIvKNyW52kW5+JroSIdfyfOg5bcHDChKZKMlMLXupZMve+0 qsueZBtg9XyuJMVArW+rMneIGCyu8N57qk3tnjuWHpSKlHqALDGd73KWvOihrGwuQbYR ytWADBHbNZ5afR0tp5y0Dig0AWHwerQT+0/n7CqzD9L1yBldThd4fkQ9IbbxQ10zQTqj sxbCifS8CtdLfwhQ/qq5nmVJGy8+dtmxiztIeQ1E0jFRkgNWo8fQkf7Q0PlXEddKFTHX JJoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694724171; x=1695328971; 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=/iih9dJ+hepR7tg2MJ1JLAU9zFKmgRDnfWByt62B4ZM=; b=wM5YRhUQVTErUU6agUYhr09lPCCuvYIakB+KAGOsiC5KR4wspMyl7NdTOflzbsT8do o+J7rgWDn4+NOZjvtU+l6JdeqMO9XZy2sFDcAIY7vNbgGd/QQ12VHKZa3shlFDJNVO/A i2tQm6PGSx6ObCW7zo3720RGvqIeaXqr55D9v5f6+YIOBd44hasXxPbXCmulm3UEMTs7 3hw3dE+aZFagyACmUMUVdSGRMWiYWiLgTDnVW1jtNI7CWQqM8qYO2wjlg4tU3dXL6Cln ZOzgu0D8S1IhB/2fbjopSiv2WHYGP98PWJqAf4EALULURdxGU+8NK6JnyuwlE6m5RHwf hTLQ== X-Gm-Message-State: AOJu0YwNHh17xjeTkbaU4Wjlku4kBFsS48TiYGuzwyIp9y2EsJ+7k2VC AdsQQvp1tWNYKik+kffO6ZIBbK5anS8= X-Google-Smtp-Source: AGHT+IGcuxNGZmwdz3CmrQelEc2gX1Nj1Bq/UqSyAm3aYqa223Ov2g+pfJPA62z4W63DTlec8XDpGA== X-Received: by 2002:a5d:4941:0:b0:31a:d650:4b72 with SMTP id r1-20020a5d4941000000b0031ad6504b72mr5969875wrs.7.1694724171313; Thu, 14 Sep 2023 13:42:51 -0700 (PDT) Received: from karim.my.domain ([197.39.44.105]) by smtp.gmail.com with ESMTPSA id j3-20020a056000124300b0031f34a395e7sm2661880wrx.45.2023.09.14.13.42.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 13:42:50 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: Richard Henderson , imp@bsdimp.com, Stacey Son , Karim Taha Subject: [PATCH v5 17/23] bsd-user: Implement mincore(2) Date: Thu, 14 Sep 2023 23:41:01 +0300 Message-ID: <20230914204107.23778-18-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230914204107.23778-1-kariem.taha2.7@gmail.com> References: <20230914204107.23778-1-kariem.taha2.7@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wm1-x335.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Stacey Son Signed-off-by: Stacey Son Signed-off-by: Karim Taha Reviewed-by: Richard Henderson Reviewed-by: Warner Losh --- bsd-user/bsd-mem.h | 23 +++++++++++++++++++++++ bsd-user/freebsd/os-syscall.c | 4 ++++ 2 files changed, 27 insertions(+) diff --git a/bsd-user/bsd-mem.h b/bsd-user/bsd-mem.h index b00ab3aed8..0c8d96d9a4 100644 --- a/bsd-user/bsd-mem.h +++ b/bsd-user/bsd-mem.h @@ -189,4 +189,27 @@ static inline abi_long do_bsd_minherit(abi_long addr, abi_long len, return get_errno(minherit(g2h_untagged(addr), len, inherit)); } +/* mincore(2) */ +static inline abi_long do_bsd_mincore(abi_ulong target_addr, abi_ulong len, + abi_ulong target_vec) +{ + abi_long ret; + void *p; + abi_ulong vec_len = 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 = lock_user(VERIFY_WRITE, target_vec, vec_len, 0); + if (p == NULL) { + return -TARGET_EFAULT; + } + ret = get_errno(mincore(g2h_untagged(target_addr), len, p)); + unlock_user(p, target_vec, vec_len); + + 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 600d048120..8ba5fcc6ca 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -635,6 +635,10 @@ static abi_long freebsd_syscall(void *cpu_env, int num, abi_long arg1, ret = do_bsd_minherit(arg1, arg2, arg3); break; + case TARGET_FREEBSD_NR_mincore: /* mincore(2) */ + ret = do_bsd_mincore(arg1, arg2, arg3); + break; + #if defined(__FreeBSD_version) && __FreeBSD_version >= 1300048 case TARGET_FREEBSD_NR_shm_open2: /* shm_open2(2) */ ret = do_freebsd_shm_open2(arg1, arg2, arg3, arg4, arg5); From patchwork Thu Sep 14 20:41:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karim Taha X-Patchwork-Id: 1834505 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=EyXkDM8s; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RmqCF03Q8z1yhd for ; Fri, 15 Sep 2023 06:47:53 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qgtAx-0003Vr-7x; Thu, 14 Sep 2023 16:42:59 -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 1qgtAu-0003Re-Et for qemu-devel@nongnu.org; Thu, 14 Sep 2023 16:42:56 -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 1qgtAs-0006Pr-Qh for qemu-devel@nongnu.org; Thu, 14 Sep 2023 16:42:56 -0400 Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-31ad779e6b3so1307304f8f.2 for ; Thu, 14 Sep 2023 13:42:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694724173; x=1695328973; 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=Im10dMwtttdz40+pDpdw7Pjq0vbvB2AOAUIvjrDwia8=; b=EyXkDM8syb+P/Y7kdnd6D22n7Ap30HpYbHd3cZEsGR5Mvp4Aeu//wG3HoHuC/nL0Vo wkJHGwrTjwifeTJwghcDmaM4Wah4S4hVugBahCq9QHevWZyb1rNrJF6VX8aqDmQEsGDl 9ZYbd1Bnut/rrZbTajUav4gFL04rkEFZGTcY6jVnqYWqF7yTi2SKxmOeNNUxzdjZ+8jL cgxtCQYWTMbpsqPFdxJ98cEx5XWhKoYPa5CSg3i1TTNrYWW4Rdyuuk2/B9JWZ7Z4lbTd OrClrT6njV1YPmfVbH3pgfWdXvjvUhJ1hEw0vUYFwzzTXpYK+CG1jBaNpAj2QULuBx0F BI+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694724173; x=1695328973; 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=Im10dMwtttdz40+pDpdw7Pjq0vbvB2AOAUIvjrDwia8=; b=qsOCBnls0+e+p1CLDb3S8uG+6xugXR8NS9rHd/SucYctQLnpbJnPKSY62HJZqRXHZU 5x7hcErtyBRrKnKftbHBhFD4gD6w+nnnf9F4Xlx43shNVtdPZcMYz8nXIBINaxd6buvp 6YWxs+ZJ78uWMQkNZuD9NjrzUNNmyIPKS6ajQBOgDoz1OeoRGDKCl+XfOWXRn8VlWrjK 6J1QL7c4VwI11fadLEJvo9LHb/79p+rz/v8UHC86q5h6afdl1ecp6G0DqWN4zZM9pcTR muMbJQ+zr7K4bacltJqTKr7uGGhzLGCCYnyhtHGHS37BT/MirTvJ3kGsmzt2l+vESbQk HTrg== X-Gm-Message-State: AOJu0YzIaoFsVchWUobT3EaCspulBUGOwk6tKB/qGco/qsQ68zm1+E9n 0Dc1DG9hsEllH6eYYQHjVcmEufeaAnQ= X-Google-Smtp-Source: AGHT+IFJ5UdnO90b5qpCgVj/8ZJ9QEZ5NjJfAvmG49dPmBTx17Lk18Or2Qf8IFH+3ot1kmeYJsm+rA== X-Received: by 2002:adf:d4cf:0:b0:311:3fdc:109d with SMTP id w15-20020adfd4cf000000b003113fdc109dmr6174301wrk.1.1694724173081; Thu, 14 Sep 2023 13:42:53 -0700 (PDT) Received: from karim.my.domain ([197.39.44.105]) by smtp.gmail.com with ESMTPSA id j3-20020a056000124300b0031f34a395e7sm2661880wrx.45.2023.09.14.13.42.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 13:42:52 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: Richard Henderson , imp@bsdimp.com, Stacey Son , Karim Taha Subject: [PATCH v5 18/23] bsd-user: Implement do_obreak function Date: Thu, 14 Sep 2023 23:41:02 +0300 Message-ID: <20230914204107.23778-19-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230914204107.23778-1-kariem.taha2.7@gmail.com> References: <20230914204107.23778-1-kariem.taha2.7@gmail.com> MIME-Version: 1.0 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: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Stacey Son Match linux-user, by manually applying the following commits, in order: d28b3c90cfad1a7e211ae2bce36ecb9071086129 linux-user: Make sure initial brk(0) is page-aligned 15ad98536ad9410fb32ddf1ff09389b677643faa linux-user: Fix qemu brk() to not zero bytes on current page dfe49864afb06e7e452a4366051697bc4fcfc1a5 linux-user: Prohibit brk() to to shrink below initial heap address eac78a4b0b7da4de2c0a297f4d528ca9cc6256a3 linux-user: Fix signed math overflow in brk() syscall c6cc059eca18d9f6e4e26bb8b6d1135ddb35d81a linux-user: Do not call get_errno() in do_brk() e69e032d1a8ee8d754ca119009a3c2c997f8bb30 linux-user: Use MAP_FIXED_NOREPLACE for do_brk() cb9d5d1fda0bc2312fc0c779b4ea1d7bf826f31f linux-user: Do nothing if too small brk is specified 2aea137a425a87b930a33590177b04368fd7cc12 linux-user: Do not align brk with host page size Signed-off-by: Stacey Son Signed-off-by: Karim Taha Reviewed-by: Richard Henderson Reviewed-by: Warner Losh --- 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 0c8d96d9a4..b296c5c6f0 100644 --- a/bsd-user/bsd-mem.h +++ b/bsd-user/bsd-mem.h @@ -212,4 +212,49 @@ static inline abi_long do_bsd_mincore(abi_ulong target_addr, abi_ulong len, return ret; } +/* 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 = TARGET_PAGE_ALIGN(brk_val); + old_brk = TARGET_PAGE_ALIGN(target_brk); + + /* new and old target_brk might be on the same page */ + if (new_brk == old_brk) { + target_brk = brk_val; + return target_brk; + } + + /* Release heap if necesary */ + if (new_brk < old_brk) { + target_munmap(new_brk, old_brk - new_brk); + + target_brk = brk_val; + return target_brk; + } + + mapped_addr = target_mmap(old_brk, new_brk - old_brk, + PROT_READ | PROT_WRITE, + MAP_FIXED | MAP_EXCL | MAP_ANON | MAP_PRIVATE, + -1, 0); + + if (mapped_addr == old_brk) { + target_brk = 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 8ba5fcc6ca..5cd60fc272 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -651,6 +651,13 @@ static abi_long freebsd_syscall(void *cpu_env, int num, abi_long arg1, break; #endif + /* + * Misc + */ + case TARGET_FREEBSD_NR_break: + ret = do_obreak(arg1); + break; + /* * sys{ctl, arch, call} */ From patchwork Thu Sep 14 20:41:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karim Taha X-Patchwork-Id: 1834486 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=nSXTLAO6; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Rmq6c68YGz1yh0 for ; Fri, 15 Sep 2023 06:43:52 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qgtB0-0003Yi-Bc; Thu, 14 Sep 2023 16:43:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qgtAx-0003WT-QT for qemu-devel@nongnu.org; Thu, 14 Sep 2023 16:42:59 -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 1qgtAv-0006RA-P9 for qemu-devel@nongnu.org; Thu, 14 Sep 2023 16:42:59 -0400 Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-31fa666000dso1248084f8f.2 for ; Thu, 14 Sep 2023 13:42:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694724175; x=1695328975; 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=Qn9zg45BrccDib3QRpTj6K0GvYzGUuL7OgrnPd2bB1A=; b=nSXTLAO6/EHEMPOgSRqCK3X4+/Mo064eny0fg6ftmyHP8z1hEUBa17NeYIIsz6GL1Q n0XffjaYIH12EJ1gzFacihvtpXGz3Wp/t6bAQI68aVspKpvTzZKC1eKVgn7lAoESuhyE mzAUDLGY/n3Mi9tni95/J6MX/fmjOYfbDNq2x3cp6BXAEGtlXxzQf6Ww0dC0EhwBS5Yd eNwuJrH6+7GUn7CX7HvRW1k54Xc7V6emMd0q4ZlnYnowAiLj7qeyFkQnJoilA5MapXBj LnXHyZJJVKEoEgncc6JrdUzc1CinP61uVIow7mXsmMav10ROJUcWk6cRrwSMfmS/CTg1 IKzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694724175; x=1695328975; 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=Qn9zg45BrccDib3QRpTj6K0GvYzGUuL7OgrnPd2bB1A=; b=mbvKfx00FQhjcIwcNGBfN4/iXbMgrP9EvY0moq+S6kuZIKRPKJTurowJRP71KprKZn GGAnBu+BY3KNibaqcpqq2iz9DabC22l9w69DnFeDGIZAfqrq3TGt+cfgixZDMWnXsaj0 G1VLP4u/ngNpxszupRLj9lzucRDXJNa3sHyA5ia54QpcEFOUQsDS8VSQrP7fl6+Hbg22 OLhE83pVqDjLASXkhynk56ytUHo4n/d5sXud0g+jkxx7iJTmVj0gpyj0cwUANreHIiPR R8I9t2fiK49MvpBAii4+Ra5ICLnr/MUNkYwzdZRtGBLWybNFqjk8U0wrb8sBsfg+pfIT fXtw== X-Gm-Message-State: AOJu0YzOIfcN0FjbQm8teVyd76teTnttF5SQzqQaoodBd2YEsGVfJ1zn zM2OyTa6lfdWvwxaNei6nC467F9jSR0= X-Google-Smtp-Source: AGHT+IGQSZ5zJxDNeJMjPhcrNpD/QB6tJLQC7IPL4twcFcbjTGZ8Y+0r94fMjEKLxXXRb/+63HzeKw== X-Received: by 2002:a5d:4086:0:b0:31f:e418:223d with SMTP id o6-20020a5d4086000000b0031fe418223dmr1918413wrp.7.1694724174661; Thu, 14 Sep 2023 13:42:54 -0700 (PDT) Received: from karim.my.domain ([197.39.44.105]) by smtp.gmail.com with ESMTPSA id j3-20020a056000124300b0031f34a395e7sm2661880wrx.45.2023.09.14.13.42.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 13:42:54 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: Richard Henderson , imp@bsdimp.com, Stacey Son , Kyle Evans , Karim Taha Subject: [PATCH v5 19/23] bsd-user: Implement shm_open(2) Date: Thu, 14 Sep 2023 23:41:03 +0300 Message-ID: <20230914204107.23778-20-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230914204107.23778-1-kariem.taha2.7@gmail.com> References: <20230914204107.23778-1-kariem.taha2.7@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42c; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wr1-x42c.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Stacey Son Co-authored-by: Kyle Evans Signed-off-by: Stacey Son Signed-off-by: Kyle Evans Signed-off-by: Karim Taha Reviewed-by: Richard Henderson Reviewed-by: Warner Losh --- 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 b296c5c6f0..f8dc943c23 100644 --- a/bsd-user/bsd-mem.h +++ b/bsd-user/bsd-mem.h @@ -257,4 +257,29 @@ static inline abi_long do_obreak(abi_ulong brk_val) return target_brk; } +/* shm_open(2) */ +static inline abi_long do_bsd_shm_open(abi_ulong arg1, abi_long arg2, + abi_long arg3) +{ + int ret; + void *p; + + if (arg1 == (uintptr_t)SHM_ANON) { + p = SHM_ANON; + } else { + p = lock_user_string(arg1); + if (p == NULL) { + return -TARGET_EFAULT; + } + } + ret = get_errno(shm_open(p, target_to_host_bitmask(arg2, fcntl_flags_tbl), + arg3)); + + if (p != 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 5cd60fc272..effa6dac54 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -639,6 +639,10 @@ static abi_long freebsd_syscall(void *cpu_env, int num, abi_long arg1, ret = do_bsd_mincore(arg1, arg2, arg3); break; + case TARGET_FREEBSD_NR_freebsd12_shm_open: /* shm_open(2) */ + ret = do_bsd_shm_open(arg1, arg2, arg3); + break; + #if defined(__FreeBSD_version) && __FreeBSD_version >= 1300048 case TARGET_FREEBSD_NR_shm_open2: /* shm_open2(2) */ ret = do_freebsd_shm_open2(arg1, arg2, arg3, arg4, arg5); From patchwork Thu Sep 14 20:41:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karim Taha X-Patchwork-Id: 1834492 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=ViUiuZdb; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Rmq8J3930z1ypW for ; Fri, 15 Sep 2023 06:45:20 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qgtB0-0003YY-4J; Thu, 14 Sep 2023 16:43:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qgtAx-0003WS-QH for qemu-devel@nongnu.org; Thu, 14 Sep 2023 16:42:59 -0400 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qgtAv-0006Rh-PG for qemu-devel@nongnu.org; Thu, 14 Sep 2023 16:42:59 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-404571cbb8dso12249925e9.3 for ; Thu, 14 Sep 2023 13:42:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694724176; x=1695328976; 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=6EwEtIsp5qS7pkISguftTlvIQuUZ+Ff4kRu6nEkFX1U=; b=ViUiuZdbHRc5fi4m45yRcPJudfCKvmizwBk0X/iu3V/7M97PGzdu+v5GKC9KEt0IsZ C8f7MncABQx4Mbp3gUTeIglxHe+ZmGf0Oe5zaITY+fJp6/gw/WuCQ4sAIlx2rYyp1NqS a4B53OKDp1w3TJB+BpVawW19csbk7jandro8817KfnZUhwhylD0BzKStdOQNWAFF1QS2 Wi+oN3yUiSBOcVM1FNNdHRx2v+tF2NcVJINg49Z4z8T6I0pZ2Ni3cJScwjXNMrzE6VzF Xp5zmj2SJ3UQBAcfdBydONCgnuo3JwRuwE1SwzkxZXNopdGon9Jpr4aNOWN7Y3Wo7IWm ByTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694724176; x=1695328976; 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=6EwEtIsp5qS7pkISguftTlvIQuUZ+Ff4kRu6nEkFX1U=; b=HYPSRtteKMDoI3EP3w46jgxsHsXiDgnsqMMxSPZmlfKkn0pCfpXR7E5pUpeyJPLyUI +pWdG0TcVKiern8BFKGOp32wXYlsfvAHEFl2uFtD7S5Ku87xt6dC/CK4i5aChLtKxZ4H m4q0di09JGkGCCYt4swT9WzI8iro6ZSzNecUs/qiP0OGmTHtSBYFprOWp8wPgXhLOsyC YHUTJRU04acYVMJROWV+4Y4HMvfkHvX4fKxL+ydGITHUQYUpFhxkr6oMCiYPFjAwNg2j m+0fPX3UIjoELhB+RULwsaPsSlEpeoG1NbajP+i3vDplbNH9sXLyOn1CnUG1T0s+QStE ZHyA== X-Gm-Message-State: AOJu0Yyrw9/O2JJuwi4eUP/1oib2olQTE6qUasiJq3+jF3//mu5T6yuA //8lCDszfzSdpKiVSMqgYqIC557F1gc= X-Google-Smtp-Source: AGHT+IHgqXdpQlw4X14EsLMT9TmQZFcj7LCXbCttavMZrq+4rh6fMfFMdhEw+w+UWWVpcy1DrC3JAg== X-Received: by 2002:a05:600c:221a:b0:401:d3dd:c3c with SMTP id z26-20020a05600c221a00b00401d3dd0c3cmr5346668wml.39.1694724176063; Thu, 14 Sep 2023 13:42:56 -0700 (PDT) Received: from karim.my.domain ([197.39.44.105]) by smtp.gmail.com with ESMTPSA id j3-20020a056000124300b0031f34a395e7sm2661880wrx.45.2023.09.14.13.42.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 13:42:55 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: Richard Henderson , imp@bsdimp.com, Stacey Son , Karim Taha Subject: [PATCH v5 20/23] bsd-user: Implement shm_unlink(2) and shmget(2) Date: Thu, 14 Sep 2023 23:41:04 +0300 Message-ID: <20230914204107.23778-21-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230914204107.23778-1-kariem.taha2.7@gmail.com> References: <20230914204107.23778-1-kariem.taha2.7@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wm1-x32c.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Stacey Son Signed-off-by: Stacey Son Signed-off-by: Karim Taha Reviewed-by: Warner Losh 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 f8dc943c23..c362cc07a3 100644 --- a/bsd-user/bsd-mem.h +++ b/bsd-user/bsd-mem.h @@ -282,4 +282,27 @@ static inline abi_long do_bsd_shm_open(abi_ulong arg1, abi_long arg2, return ret; } +/* shm_unlink(2) */ +static inline abi_long do_bsd_shm_unlink(abi_ulong arg1) +{ + int ret; + void *p; + + p = lock_user_string(arg1); + if (p == NULL) { + return -TARGET_EFAULT; + } + ret = get_errno(shm_unlink(p)); /* XXX path(p)? */ + unlock_user(p, arg1, 0); + + return ret; +} + +/* shmget(2) */ +static inline abi_long do_bsd_shmget(abi_long arg1, abi_ulong arg2, + abi_long arg3) +{ + return get_errno(shmget(arg1, arg2, arg3)); +} + #endif /* BSD_USER_BSD_MEM_H */ diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index effa6dac54..f0ccd787e5 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -655,6 +655,14 @@ static abi_long freebsd_syscall(void *cpu_env, int num, abi_long arg1, break; #endif + case TARGET_FREEBSD_NR_shm_unlink: /* shm_unlink(2) */ + ret = do_bsd_shm_unlink(arg1); + break; + + case TARGET_FREEBSD_NR_shmget: /* shmget(2) */ + ret = do_bsd_shmget(arg1, arg2, arg3); + break; + /* * Misc */ From patchwork Thu Sep 14 20:41:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karim Taha X-Patchwork-Id: 1834502 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=skUURppC; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RmqC14PRYz1ypL for ; Fri, 15 Sep 2023 06:47:41 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qgtB4-0003k6-F5; Thu, 14 Sep 2023 16:43: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 1qgtAz-0003Xb-7Y for qemu-devel@nongnu.org; Thu, 14 Sep 2023 16:43:01 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qgtAx-0006T2-6s for qemu-devel@nongnu.org; Thu, 14 Sep 2023 16:43:00 -0400 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-40078c4855fso14907475e9.3 for ; Thu, 14 Sep 2023 13:42:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694724177; x=1695328977; 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=OlFBXfrUelyZD113NpgkyEi3DkcrK5mWFFpJAPBaArs=; b=skUURppCpu2PrGXYCfF42x4e+dcBwaoLELKFK+PBfpsxLAylMPCcLmpEScd17o3E7d +K+zE7ijE6QDRiXZnMrXVYW5nkkSStHPHIq2yY+bCvml+bSPe5jPW3FcYdUakuBpKRoX Y4s/m4Gq28oGduDbPYpN19SVXpUv3Dcm6hixpiCUT0n1Csu7k88lkS3Vx2rV76uDZhcE WbxLUt2ZL06zHaVA5DP5O4shM1kDzpZG/e5DsSM6jnKthcriF72ESH4Rn3gRIQCuZN1O 8vrYfd7Z3HKlH04DFjdo7BJ+WhQg6/ZIFkNrJj6CyPegtqyPGCtRUFiDFsmln7xhwBm7 bYeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694724177; x=1695328977; 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=OlFBXfrUelyZD113NpgkyEi3DkcrK5mWFFpJAPBaArs=; b=oeV7jurRT5uSLw9cI512sQh4C091UoQxZDyUcnuu1E9FFhnNx63Brlm9o7b1lZJXI1 CzmVP+RKyNegouvnIttpfSWVz4v+N3xp0CQ5JLcZlJjpmtMeJkt/k+6gC15QkCMm/bQN OImeQKaKoUcs3mjRs68aGagJVf351AusIq8+su+2Iq83q0ASl0zVByjWcZxX7EfCa2cB 48uYEHLR6TTJsvz2NCOIZETLfWuFMyFyCbCRyIFVKUXEe4VqZ3KLckwew4e8i5M9oxpW dL5cpN+ZB31royiykBHrhjkbm0mpBLYmihS7bJClPwV9KPma7xse3tnPZ7Ym/lQIs8Cg SsOw== X-Gm-Message-State: AOJu0YxEgXamqPa0LstYGL7fX1sP56R5M0omeLDTFNdmOwP8lMHWgnyh OYAQLJlwo6WHxntzM4E71IRkGyxoqFU= X-Google-Smtp-Source: AGHT+IH1a+vYG1ClGLjlv2hvVHnwgE/bwbbHvRKUyQuFNHGfxqwxWU4ltmE1ujgcaE+Aet6krU8nOg== X-Received: by 2002:a05:600c:364b:b0:401:b2c7:34a8 with SMTP id y11-20020a05600c364b00b00401b2c734a8mr5797241wmq.7.1694724177366; Thu, 14 Sep 2023 13:42:57 -0700 (PDT) Received: from karim.my.domain ([197.39.44.105]) by smtp.gmail.com with ESMTPSA id j3-20020a056000124300b0031f34a395e7sm2661880wrx.45.2023.09.14.13.42.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 13:42:56 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: Richard Henderson , imp@bsdimp.com, Stacey Son , Karim Taha Subject: [PATCH v5 21/23] bsd-user: Implement shmctl(2) Date: Thu, 14 Sep 2023 23:41:05 +0300 Message-ID: <20230914204107.23778-22-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230914204107.23778-1-kariem.taha2.7@gmail.com> References: <20230914204107.23778-1-kariem.taha2.7@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::332; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wm1-x332.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Stacey Son Signed-off-by: Stacey Son Signed-off-by: Karim Taha Reviewed-by: Richard Henderson Reviewed-by: Warner Losh --- bsd-user/bsd-mem.h | 39 +++++++++++++++++++++++++++++++++++ bsd-user/freebsd/os-syscall.c | 4 ++++ 2 files changed, 43 insertions(+) diff --git a/bsd-user/bsd-mem.h b/bsd-user/bsd-mem.h index c362cc07a3..b82f3eaa25 100644 --- a/bsd-user/bsd-mem.h +++ b/bsd-user/bsd-mem.h @@ -305,4 +305,43 @@ static inline abi_long do_bsd_shmget(abi_long arg1, abi_ulong arg2, return get_errno(shmget(arg1, arg2, arg3)); } +/* shmctl(2) */ +static inline abi_long do_bsd_shmctl(abi_long shmid, abi_long cmd, + abi_ulong buff) +{ + struct shmid_ds dsarg; + abi_long ret = -TARGET_EINVAL; + + cmd &= 0xff; + + switch (cmd) { + case IPC_STAT: + if (target_to_host_shmid_ds(&dsarg, buff)) { + return -TARGET_EFAULT; + } + ret = get_errno(shmctl(shmid, cmd, &dsarg)); + if (host_to_target_shmid_ds(buff, &dsarg)) { + return -TARGET_EFAULT; + } + break; + + case IPC_SET: + if (target_to_host_shmid_ds(&dsarg, buff)) { + return -TARGET_EFAULT; + } + ret = get_errno(shmctl(shmid, cmd, &dsarg)); + break; + + case IPC_RMID: + ret = get_errno(shmctl(shmid, cmd, NULL)); + break; + + default: + ret = -TARGET_EINVAL; + break; + } + + return ret; +} + #endif /* BSD_USER_BSD_MEM_H */ diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c index f0ccd787e5..664b8de104 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -663,6 +663,10 @@ static abi_long freebsd_syscall(void *cpu_env, int num, abi_long arg1, ret = do_bsd_shmget(arg1, arg2, arg3); break; + case TARGET_FREEBSD_NR_shmctl: /* shmctl(2) */ + ret = do_bsd_shmctl(arg1, arg2, arg3); + break; + /* * Misc */ From patchwork Thu Sep 14 20:41:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karim Taha X-Patchwork-Id: 1834501 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=Oo9C+ECq; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RmqBz1934z1ypL for ; Fri, 15 Sep 2023 06:47:39 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qgtB3-0003eF-Q4; Thu, 14 Sep 2023 16:43:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qgtB0-0003Z3-NX for qemu-devel@nongnu.org; Thu, 14 Sep 2023 16:43:02 -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 1qgtAy-0006To-W4 for qemu-devel@nongnu.org; Thu, 14 Sep 2023 16:43:02 -0400 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-400a087b0bfso15000185e9.2 for ; Thu, 14 Sep 2023 13:43:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694724179; x=1695328979; 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=0qCnBrmq8ElzL12pKuzE5cbfgMq8tTx5nwbXwHsBGr8=; b=Oo9C+ECqUuAtfwWxpvcRaaB07JtrcvUH9UjSbi7wfdo1B2MOTaWWM+FE4sTQcD1cNI 8w9ZMd8cTX07xJ7jUl7L2HDZk8W/ekvwJs5ngEijnQKG50ocicYYqejVdvAZ47UAAI4g gizwHPvK/WYURMFbfJalXW6nTnvqoxPuv0/BvQgpia/0XzMO9W9wi/utn6RKYxkrepqQ LPjb7vktvvb5UaWDe7hdMpGGB5lJY9KzgWoyyot0XjazmICbAyu1wkKRrYau1oucti1t afQEkSG9zoemwKK+TJHZAA+ozxfCzb7jz6gFyKiSA9p+GEZmPFog1OeWoGT1XNQ60Ro/ dReg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694724179; x=1695328979; 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=0qCnBrmq8ElzL12pKuzE5cbfgMq8tTx5nwbXwHsBGr8=; b=plHX3GtR3lyM30KlT+DbpF51DXE5aIXVGOXsUtG65lcAufU0ymPKVQy28INcgysK8D YCjpVq1h0jWS9wk76Od+b5lDtoMqYDNxCuiIk4JVaJnauW0Y/jqIamQeNg/9/Eo9URWr HVeBlK5fFnNPhrPx8zEWu53xFCehRPQCWkV92umozFupDdmDtghMNRUsDRmQY/9BEF/v gIsUR9Qa/DLKfFX4ix+1E6vQe+pixHGkl/WSsad8sUO0ayLZUmA4gLrETxc575fMILi7 6C9MjrXZfnJRTNt5Xi6DDFr1o478BSScai1p4W2n/9L7GbtSwQfQfnJJJJsit2Ldg87C lDWw== X-Gm-Message-State: AOJu0YzFZ/JTtlQmrX+4KSQZ00m/MplcbWd9r+HQml3+NEuK2zi33Ni1 axZx51k6XhdpXHb9gQC0anGwYUGzduI= X-Google-Smtp-Source: AGHT+IFUvegifWG0mzXzleoU+GQ2/BTr6pHVUl8cV5h9oZAoxYxikU8714TDdiQubHMX5eBPcJ4Xzg== X-Received: by 2002:a5d:648c:0:b0:31f:ddf2:d6fe with SMTP id o12-20020a5d648c000000b0031fddf2d6femr3040769wri.32.1694724178768; Thu, 14 Sep 2023 13:42:58 -0700 (PDT) Received: from karim.my.domain ([197.39.44.105]) by smtp.gmail.com with ESMTPSA id j3-20020a056000124300b0031f34a395e7sm2661880wrx.45.2023.09.14.13.42.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 13:42:58 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: Richard Henderson , imp@bsdimp.com, Stacey Son , Karim Taha Subject: [PATCH v5 22/23] bsd-user: Implement shmat(2) and shmdt(2) Date: Thu, 14 Sep 2023 23:41:06 +0300 Message-ID: <20230914204107.23778-23-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230914204107.23778-1-kariem.taha2.7@gmail.com> References: <20230914204107.23778-1-kariem.taha2.7@gmail.com> MIME-Version: 1.0 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: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Stacey Son Use `WITH_MMAP_LOCK_GUARD` instead of mmap_lock() and mmap_unlock(), to match linux-user implementation, according to the following commits: 69fa2708a216df715ba5102a0f98468b540a464e linux-user: Use WITH_MMAP_LOCK_GUARD in target_{shmat,shmdt} ceda5688b650646248f269a992c06b11148c5759 linux-user: Fix shmdt Signed-off-by: Stacey Son Signed-off-by: Karim Taha Reviewed-by: Richard Henderson --- bsd-user/bsd-mem.h | 87 +++++++++++++++++++++++++++++++++++ bsd-user/freebsd/os-syscall.c | 8 ++++ bsd-user/mmap.c | 2 +- bsd-user/qemu.h | 1 + 4 files changed, 97 insertions(+), 1 deletion(-) diff --git a/bsd-user/bsd-mem.h b/bsd-user/bsd-mem.h index b82f3eaa25..c512a4e375 100644 --- a/bsd-user/bsd-mem.h +++ b/bsd-user/bsd-mem.h @@ -344,4 +344,91 @@ static inline abi_long do_bsd_shmctl(abi_long shmid, abi_long cmd, return ret; } +/* shmat(2) */ +static inline abi_long do_bsd_shmat(int shmid, abi_ulong shmaddr, int shmflg) +{ + abi_ulong raddr; + abi_long ret; + struct shmid_ds shm_info; + + /* Find out the length of the shared memory segment. */ + ret = get_errno(shmctl(shmid, IPC_STAT, &shm_info)); + if (is_error(ret)) { + /* Can't get the length */ + return ret; + } + + if (!guest_range_valid_untagged(shmaddr, shm_info.shm_segsz)) { + return -TARGET_EINVAL; + } + + WITH_MMAP_LOCK_GUARD() { + void *host_raddr; + + if (shmaddr) { + host_raddr = shmat(shmid, (void *)g2h_untagged(shmaddr), shmflg); + } else { + abi_ulong mmap_start; + + mmap_start = mmap_find_vma(0, shm_info.shm_segsz); + + if (mmap_start == -1) { + return -TARGET_ENOMEM; + } + host_raddr = shmat(shmid, g2h_untagged(mmap_start), + shmflg | SHM_REMAP); + } + + if (host_raddr == (void *)-1) { + return get_errno(-1); + } + raddr = h2g(host_raddr); + + page_set_flags(raddr, raddr + shm_info.shm_segsz - 1, + PAGE_VALID | PAGE_RESET | PAGE_READ | + (shmflg & SHM_RDONLY ? 0 : PAGE_WRITE)); + + for (int i = 0; i < N_BSD_SHM_REGIONS; i++) { + if (bsd_shm_regions[i].start == 0) { + bsd_shm_regions[i].start = raddr; + bsd_shm_regions[i].size = shm_info.shm_segsz; + break; + } + } + } + + return raddr; +} + +/* shmdt(2) */ +static inline abi_long do_bsd_shmdt(abi_ulong shmaddr) +{ + abi_long ret; + + WITH_MMAP_LOCK_GUARD() { + int i; + + for (i = 0; i < N_BSD_SHM_REGIONS; ++i) { + if (bsd_shm_regions[i].start == shmaddr) { + break; + } + } + + if (i == N_BSD_SHM_REGIONS) { + return -TARGET_EINVAL; + } + + ret = get_errno(shmdt(g2h_untagged(shmaddr))); + if (ret == 0) { + abi_ulong size = bsd_shm_regions[i].size; + + bsd_shm_regions[i].start = 0; + page_set_flags(shmaddr, shmaddr + size - 1, 0); + mmap_reserve(shmaddr, size); + } + } + + 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 664b8de104..6b32d4df68 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -667,6 +667,14 @@ static abi_long freebsd_syscall(void *cpu_env, int num, abi_long arg1, ret = do_bsd_shmctl(arg1, arg2, arg3); break; + case TARGET_FREEBSD_NR_shmat: /* shmat(2) */ + ret = do_bsd_shmat(arg1, arg2, arg3); + break; + + case TARGET_FREEBSD_NR_shmdt: /* shmdt(2) */ + ret = do_bsd_shmdt(arg1); + break; + /* * Misc */ diff --git a/bsd-user/mmap.c b/bsd-user/mmap.c index 8e148a2ea3..3ef11b2807 100644 --- a/bsd-user/mmap.c +++ b/bsd-user/mmap.c @@ -636,7 +636,7 @@ fail: return -1; } -static void mmap_reserve(abi_ulong start, abi_ulong size) +void mmap_reserve(abi_ulong start, abi_ulong size) { abi_ulong real_start; abi_ulong real_end; diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h index d3158bc2ed..09a8f9aed4 100644 --- a/bsd-user/qemu.h +++ b/bsd-user/qemu.h @@ -232,6 +232,7 @@ abi_long target_mremap(abi_ulong old_addr, abi_ulong old_size, int target_msync(abi_ulong start, abi_ulong len, int flags); extern abi_ulong mmap_next_start; abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size); +void mmap_reserve(abi_ulong start, abi_ulong size); void TSA_NO_TSA mmap_fork_start(void); void TSA_NO_TSA mmap_fork_end(int child); From patchwork Thu Sep 14 20:41:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karim Taha X-Patchwork-Id: 1834485 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=CNj5JNOy; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Rmq611F3Nz1yh0 for ; Fri, 15 Sep 2023 06:43:20 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qgtB7-0003wB-Am; Thu, 14 Sep 2023 16:43:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qgtB1-0003dV-OK for qemu-devel@nongnu.org; Thu, 14 Sep 2023 16:43:03 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qgtB0-0006Uk-4d for qemu-devel@nongnu.org; Thu, 14 Sep 2023 16:43:03 -0400 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-401c90ed2ecso15991795e9.0 for ; Thu, 14 Sep 2023 13:43:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694724180; x=1695328980; 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=X4SdHGLTzFQ8VoHFc5maZ2DOZP9CSCnNto04LyR/4Aw=; b=CNj5JNOyrfyLnWF0VT5jc04q/nowbLpN3wOFvxNNDTnUdzxxcR1XrsZSFvYZU/vI8P qOqn1qY1DrHOMESN60FrartcIqFgqftYzsFOYK/7FndHjVwP1dc4wR0vArZWvnTnLube ivsJZogdl961xtIajzedVoZOLt2LibZa1hgb/AU5TlQhGuOQYqe65H1f9VM1t/D0g2D2 9UqV9Jw+QCOmBVHi6GI2qlocMc68+BdavmDQpBWaKvElsF14Wi0GoNTe1JuXnz/wv1pg BrO4hmekJ+KFoKyin1OhvP2dJ7caoonFNDuquIojmCE1hFnfOfOuwdoPVyR+5iJyxCeK Zing== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694724180; x=1695328980; 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=X4SdHGLTzFQ8VoHFc5maZ2DOZP9CSCnNto04LyR/4Aw=; b=xBnt8fULknUOVOg8fSVF7+HYmXCGtbYlQH35oRC1F3BW1jDcYAc6y0dXO7sum6fCm4 bpT76ZTm3YHPD8IK9Wim9I67nD7C/kWxheLdjduMRufOqqd9AHhOcGQX8T7v65hHgt9q ZhV1pE4xdqSev7NRXQJ0UutKX/uFjMsi8IJkIeiTngOlBGDs9gSEZY7d2JoPT2HAkxGz Op7JZvifkdT69ATd1QsVBL8eTzLzjnj8W7ehqcsqwleUIZkWWOPEvX1fNGo2Y+pEmoRB RYgIDBamwReHZJVQhh9H6wQ9Y3qaVuWR281ZCtjB+2QMoqXtd/bWhi89NY8Iv9ydCcNw cfNg== X-Gm-Message-State: AOJu0YyGm6vNknHNdLmp6V0xa92BWXoS0TgbXYb56pZTDHSkbV+wtSJz zTmeWR0tWUnGOnMz+IzqUwF75KDbCBY= X-Google-Smtp-Source: AGHT+IGL5BUXaTSbCszuEDkxb54qhNvylPyKQQ50nzsBUdXJI+TaxVtlMaGY+G8HxI5Pz/Djfh+ndQ== X-Received: by 2002:a05:600c:ad7:b0:3fe:ba7:f200 with SMTP id c23-20020a05600c0ad700b003fe0ba7f200mr5964195wmr.20.1694724180121; Thu, 14 Sep 2023 13:43:00 -0700 (PDT) Received: from karim.my.domain ([197.39.44.105]) by smtp.gmail.com with ESMTPSA id j3-20020a056000124300b0031f34a395e7sm2661880wrx.45.2023.09.14.13.42.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 13:42:59 -0700 (PDT) From: Karim Taha To: qemu-devel@nongnu.org Cc: Richard Henderson , imp@bsdimp.com, Karim Taha Subject: [PATCH v5 23/23] bsd-user: Add stubs for vadvise(), sbrk() and sstk() Date: Thu, 14 Sep 2023 23:41:07 +0300 Message-ID: <20230914204107.23778-24-kariem.taha2.7@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230914204107.23778-1-kariem.taha2.7@gmail.com> References: <20230914204107.23778-1-kariem.taha2.7@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=kariem.taha2.7@gmail.com; helo=mail-wm1-x335.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Warner Losh The above system calls are not supported by qemu. Signed-off-by: Warner Losh Signed-off-by: Karim Taha Reviewed-by: Richard Henderson --- 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 c512a4e375..c3e72e3b86 100644 --- a/bsd-user/bsd-mem.h +++ b/bsd-user/bsd-mem.h @@ -431,4 +431,22 @@ static inline abi_long do_bsd_shmdt(abi_ulong shmaddr) return ret; } +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 6b32d4df68..ce2a6bc29e 100644 --- a/bsd-user/freebsd/os-syscall.c +++ b/bsd-user/freebsd/os-syscall.c @@ -675,6 +675,18 @@ static abi_long freebsd_syscall(void *cpu_env, int num, abi_long arg1, ret = do_bsd_shmdt(arg1); break; + case TARGET_FREEBSD_NR_freebsd11_vadvise: + ret = do_bsd_vadvise(); + break; + + case TARGET_FREEBSD_NR_sbrk: + ret = do_bsd_sbrk(); + break; + + case TARGET_FREEBSD_NR_sstk: + ret = do_bsd_sstk(); + break; + /* * Misc */