From patchwork Tue Oct 3 23:32:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Warner Losh X-Patchwork-Id: 1842941 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=bsdimp-com.20230601.gappssmtp.com header.i=@bsdimp-com.20230601.gappssmtp.com header.a=rsa-sha256 header.s=20230601 header.b=rClnTB0/; 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 4S0Z6d6tZqz1yng for ; Wed, 4 Oct 2023 10:39:36 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qnovw-0004Z2-41; Tue, 03 Oct 2023 19:36:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qnovm-0004Pd-Jh for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:58 -0400 Received: from mail-io1-xd33.google.com ([2607:f8b0:4864:20::d33]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qnovX-0007R2-0j for qemu-devel@nongnu.org; Tue, 03 Oct 2023 19:35:58 -0400 Received: by mail-io1-xd33.google.com with SMTP id ca18e2360f4ac-79faba5fe12so57774439f.3 for ; Tue, 03 Oct 2023 16:35:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1696376141; x=1696980941; 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=Gu7LXH0KtqoAmWr0NOHNKS6NC88NWxHbhJG+bHoQChE=; b=rClnTB0/dqFgMyRzNKcDHMjwD1cWcCo3rX97qVlL8Q0d8EwdFcFHWl3JU6l9S/VASL NsE6bZOM4eKGjwXfe640RG+pZaA7N8SF6BVOQmYDClvax52PYXDYBxL87T668HqS+uEL k2O1Aitqn7aCIk6TFER/cRqrwdZCluulJ6skjI6EIAPZArHV0trOZOJs3QQVtBai0sh3 xBcasPbUhvnU+i/zT1Xom3DVeW3NWrGFdbljDl+6qM2MNTQlsazUGpdRqnJl9JN9UETP bG9unRyUbFyF/YPZFTsvI6Nm9gkaS1HZEITRd0Ha336T4Bz4qyESXR4A2hrTv8BTYa2W lahQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696376141; x=1696980941; 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=Gu7LXH0KtqoAmWr0NOHNKS6NC88NWxHbhJG+bHoQChE=; b=Q7fqahNV8i9JarTbJcmSSGwQFu+dirEpGBC/cKbxvjtDxlO/sl0u3POocAVl0Ily3o zpIQRAvLmnmmveJVBUXJzX0hBNQ8tU5zyi3HBn3PVTYG4d+WKgVV9hTl8fX76DxbpmD7 RTa2tnu49IdAVOxQDoPvTjWZoRLdGjQzED7xHDKd6CufO3BkSJdWa+879GMeKA+iDJy0 SbBueK6OOO0fNrHE/hRFcgSTFLfeEKzAKmP82tEWzr67PLcg/dsBKdwMr4KCCnMvJJRS kncKCAEPhBlClh+DdNI7njeAR9gBK/OINAuVHGh+L3/KZjBdiOhvozxTrOnxxvjkVC48 ODsw== X-Gm-Message-State: AOJu0Yz+cr/pi+E3DQPne7bLRLFNz6JpdkzrhdbPE2sOtDWUgtKw0ziK yYKJyQuWIusIdbWNJc6r7lwbRhfnDl/WOU3T/QfMVg== X-Google-Smtp-Source: AGHT+IFw9EtrHE1xzilxHySckHYty5OkfbUttYYQ1PHJJOTMfig8QHD+OXPkVpns8NVYJUbC1JJZQA== X-Received: by 2002:a05:6602:22d8:b0:794:c9a2:5fe3 with SMTP id e24-20020a05660222d800b00794c9a25fe3mr977403ioe.4.1696376141497; Tue, 03 Oct 2023 16:35:41 -0700 (PDT) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id w25-20020a6b4a19000000b0079fa1a7cd36sm593596iob.30.2023.10.03.16.35.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 16:35:41 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Thomas Huth , Laurent Vivier , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?Alex?= =?utf-8?q?_Benn=C3=A9e?= , Wainer dos Santos Moschetta , Beraldo Leal , Warner Losh , Kyle Evans , Stacey Son , Karim Taha , Richard Henderson Subject: [PULL 38/51] bsd-user: Implement shmid_ds conversion between host and target. Date: Tue, 3 Oct 2023 17:32:02 -0600 Message-ID: <20231003233215.95557-39-imp@bsdimp.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231003233215.95557-1-imp@bsdimp.com> References: <20231003233215.95557-1-imp@bsdimp.com> MIME-Version: 1.0 Received-SPF: none client-ip=2607:f8b0:4864:20::d33; envelope-from=imp@bsdimp.com; helo=mail-io1-xd33.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+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 Message-Id: <20230925182709.4834-11-kariem.taha2.7@gmail.com> --- 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 46cda8eb5ce..2ab1334b700 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; +}