From nobody Sat May 4 18:07:34 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1560954136; cv=none; d=zoho.com; s=zohoarc; b=ljDZ6JhVXuHrb11sXNki7vnySrfoT/2uDm+AglMCMomT/lWUeTz52SP582r0Br6N7hJQ2fmYU7c9v1Z7PI/zVs3+5sZWbLb55caaj8jbh0GDpz2B2yvZIEZW1WUYtZc+jBAF5Iz98z9h9eXBCZds4a2ivGTUlx7cEmssIz7Soq8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560954136; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=x6pEdGkw4yUkCXO8P2cLYDUagbEEsaB6h5BtHaoMZLo=; b=CCRK91jYS48cMlEpZzGo19n8DVtoPR+YlLedwXpyDE+Xzqkz7uThAYkk4oN8wW3yKGyP0BMwBBcbE96bh1eOMcAclaNkDK3X8midm+4c/V3Mvqbu+FkS9DGaMHbjGvzYTsu4OIppvNPnRP6EJYlqDhjK62GM5qInjwNYBKckmM8= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560954136909863.2263979059851; Wed, 19 Jun 2019 07:22:16 -0700 (PDT) Received: from localhost ([::1]:38814 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hdbTV-0006mM-M8 for importer@patchew.org; Wed, 19 Jun 2019 10:22:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54879) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hdbPD-0004n7-5E for qemu-devel@nongnu.org; Wed, 19 Jun 2019 10:17:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hdbPB-0000jQ-7w for qemu-devel@nongnu.org; Wed, 19 Jun 2019 10:17:43 -0400 Received: from mx2.rt-rk.com ([89.216.37.149]:50036 helo=mail.rt-rk.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hdbPB-0000iO-1f for qemu-devel@nongnu.org; Wed, 19 Jun 2019 10:17:41 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.rt-rk.com (Postfix) with ESMTP id F3CCE1A2274; Wed, 19 Jun 2019 16:17:38 +0200 (CEST) Received: from rtrkw774-lin.domain.local (rtrkw774-lin.domain.local [10.10.13.43]) by mail.rt-rk.com (Postfix) with ESMTPSA id DAE0B1A1E12; Wed, 19 Jun 2019 16:17:38 +0200 (CEST) X-Virus-Scanned: amavisd-new at rt-rk.com From: Aleksandar Markovic To: qemu-devel@nongnu.org Date: Wed, 19 Jun 2019 16:17:10 +0200 Message-Id: <1560953834-29584-2-git-send-email-aleksandar.markovic@rt-rk.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1560953834-29584-1-git-send-email-aleksandar.markovic@rt-rk.com> References: <1560953834-29584-1-git-send-email-aleksandar.markovic@rt-rk.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 89.216.37.149 Subject: [Qemu-devel] [PATCH v12 1/5] linux-user: Add support for setsockopt() options IPV6__MEMBERSHIP X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Neng Chen , laurent@vivier.eu, amarkovic@wavecomp.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Neng Chen Add support for the option IPV6__MEMBERSHIP of the syscall setsockopt(). This option controls membership in multicast groups. Argument is a pointer to a struct ipv6_mreq. The glibc header defines the ipv6_mreq structure, which includes the following members: struct in6_addr ipv6mr_multiaddr; unsigned int ipv6mr_interface; Whereas the kernel in its header defines following members of the same structure: struct in6_addr ipv6mr_multiaddr; int ipv6mr_ifindex; POSIX defines ipv6mr_interface [1]. __UAPI_DEF_IVP6_MREQ appears in kernel headers with v3.12: cfd280c91253 net: sync some IP headers with glibc Without __UAPI_DEF_IVP6_MREQ, kernel defines ipv6mr_ifindex, and this is explained in cfd280c91253: "If you include the kernel headers first you get those, and if you include the glibc headers first you get those, and the following patch arranges a coordination and synchronization between the two." So before 3.12, a program can't include both and . In linux-user/syscall.c, we only include (glibc) and not (kernel headers), so ipv6mr_interface is the one to use. [1] http://pubs.opengroup.org/onlinepubs/009695399/basedefs/netinet/in.h.ht= ml Signed-off-by: Neng Chen Signed-off-by: Aleksandar Markovic Reviewed-by: Laurent Vivier --- linux-user/syscall.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index b187c12..f267ad0 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -1920,6 +1920,25 @@ static abi_long do_setsockopt(int sockfd, int level,= int optname, &pki, sizeof(pki))); break; } + case IPV6_ADD_MEMBERSHIP: + case IPV6_DROP_MEMBERSHIP: + { + struct ipv6_mreq ipv6mreq; + + if (optlen < sizeof(ipv6mreq)) { + return -TARGET_EINVAL; + } + + if (copy_from_user(&ipv6mreq, optval_addr, sizeof(ipv6mreq))) { + return -TARGET_EFAULT; + } + + ipv6mreq.ipv6mr_interface =3D tswap32(ipv6mreq.ipv6mr_interfac= e); + + ret =3D get_errno(setsockopt(sockfd, level, optname, + &ipv6mreq, sizeof(ipv6mreq))); + break; + } default: goto unimplemented; } --=20 2.7.4 From nobody Sat May 4 18:07:34 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1560954421; cv=none; d=zoho.com; s=zohoarc; b=gnwTKwubLHupqHSfzuyigBGGPsrEnTDR8LzGydnwKoVVptJf83jfojyoC4xdKwnSxI2pWZMyxaWoqnZlLI1jYEvpAvtGrtKoTXNS1i1nT+EYfGEm7XrfOr+cn5bLZiYQqbjU6v6bky37JPLa2bRRa49Z0+N+72qJiSbgOKoqs+A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560954421; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=+75+cXef8U/HkUoi6tB1mF1buO/rh+QjRDXphWHbrHc=; b=a1PZDgD18OCeubxYuL5JNsCe71n9Nqnk4FtrOAtnI6KjyWBY3AQ4M6+XLT5N22Fa0puc1p7l9Vwx2888lMJzjd/uB57hwDx/u2ec5TwO01dmVKipNPNW9D4ROktE6IkG4TMX1SQRKMWfLNMiiZ8F12dPjPH33eFZqxqLhBNF9NA= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560954421360353.10632401042176; Wed, 19 Jun 2019 07:27:01 -0700 (PDT) Received: from localhost ([::1]:38862 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hdbY7-0004k7-Ex for importer@patchew.org; Wed, 19 Jun 2019 10:26:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54910) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hdbPQ-0004oE-BZ for qemu-devel@nongnu.org; Wed, 19 Jun 2019 10:18:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hdbPG-0000nn-Vr for qemu-devel@nongnu.org; Wed, 19 Jun 2019 10:17:48 -0400 Received: from mx2.rt-rk.com ([89.216.37.149]:50216 helo=mail.rt-rk.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hdbPF-0000l9-3i for qemu-devel@nongnu.org; Wed, 19 Jun 2019 10:17:45 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.rt-rk.com (Postfix) with ESMTP id 5184E1A2274; Wed, 19 Jun 2019 16:17:42 +0200 (CEST) Received: from rtrkw774-lin.domain.local (rtrkw774-lin.domain.local [10.10.13.43]) by mail.rt-rk.com (Postfix) with ESMTPSA id 34D7C1A4545; Wed, 19 Jun 2019 16:17:42 +0200 (CEST) X-Virus-Scanned: amavisd-new at rt-rk.com From: Aleksandar Markovic To: qemu-devel@nongnu.org Date: Wed, 19 Jun 2019 16:17:11 +0200 Message-Id: <1560953834-29584-3-git-send-email-aleksandar.markovic@rt-rk.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1560953834-29584-1-git-send-email-aleksandar.markovic@rt-rk.com> References: <1560953834-29584-1-git-send-email-aleksandar.markovic@rt-rk.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 89.216.37.149 Subject: [Qemu-devel] [PATCH v12 2/5] linux-user: Add support for setsockopt() option SOL_ALG X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yunqiang Su , laurent@vivier.eu, amarkovic@wavecomp.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Yunqiang Su Add support for options SOL_ALG of the syscall setsockopt(). This option is used in relation to Linux kernel Crypto API, and allows a user to set additional information for the cipher operation via syscall setsockopt(). The field "optname" must be one of the following: - ALG_SET_KEY =E2=80=93 seting the key - ALG_SET_AEAD_AUTHSIZE =E2=80=93 set the authentication tag size SOL_ALG is relatively newer setsockopt() option. Therefore, the code that handles SOL_ALG is enclosed in "ifdef" so that the build does not fail for older kernels that do not contain support for SOL_ALG. "ifdef" also contains check if ALG_SET_KEY and ALG_SET_AEAD_AUTHSIZE are defined. Signed-off-by: Yunqiang Su Signed-off-by: Aleksandar Markovic Reviewed-by: Laurent Vivier --- linux-user/syscall.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index f267ad0..d116287 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -102,6 +102,7 @@ #include #include #include +#include #include "linux_loop.h" #include "uname.h" =20 @@ -1989,6 +1990,36 @@ static abi_long do_setsockopt(int sockfd, int level,= int optname, goto unimplemented; } break; +#if defined(SOL_ALG) && defined(ALG_SET_KEY) && defined(ALG_SET_AEAD_AUTHS= IZE) + case SOL_ALG: + switch (optname) { + case ALG_SET_KEY: + { + char *alg_key =3D g_malloc(optlen); + + if (!alg_key) { + return -TARGET_ENOMEM; + } + if (copy_from_user(alg_key, optval_addr, optlen)) { + g_free(alg_key); + return -TARGET_EFAULT; + } + ret =3D get_errno(setsockopt(sockfd, level, optname, + alg_key, optlen)); + g_free(alg_key); + break; + } + case ALG_SET_AEAD_AUTHSIZE: + { + ret =3D get_errno(setsockopt(sockfd, level, optname, + NULL, optlen)); + break; + } + default: + goto unimplemented; + } + break; +#endif case TARGET_SOL_SOCKET: switch (optname) { case TARGET_SO_RCVTIMEO: --=20 2.7.4 From nobody Sat May 4 18:07:34 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1560954140; cv=none; d=zoho.com; s=zohoarc; b=fazryVc3+flnV4FCOd3SLe1yFro5eTqZ6c88C1UK2QbyNNiYqmStAyrNlU0BqraixKZq/kvwAAFKjXbfkr74J7Gv8+Zfa0i+20hpg/J4sS+y1r/bbYZK2aVo+3rcgGzayo8bk2yU2GizfVGRkjaAkHa6y74yPtvEChmMpU6jefI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560954140; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=Qdpeu+k+OarhCkWVWJsSSz3Brhak0FtkQtqL719zE+Y=; b=igsvokraYVABX8xbvcXgGMTvtDxEzT1uVRVN8AICBwltcPQWrQoJPG7UxOVkDD2HpwVmeEBRQ0c/+wIRkTssPqPmOdlsRAp34acTAKYvl0xsPHIAlnuQTa+1tZGptTSkyXY158xJwMnZxgBI03IE84R2EEMl5unhvIOQoMjC9j8= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560954140797627.9225579114402; Wed, 19 Jun 2019 07:22:20 -0700 (PDT) Received: from localhost ([::1]:38818 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hdbTf-0007DK-La for importer@patchew.org; Wed, 19 Jun 2019 10:22:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54944) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hdbPW-0004oK-Ek for qemu-devel@nongnu.org; Wed, 19 Jun 2019 10:18:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hdbPS-0000xG-MP for qemu-devel@nongnu.org; Wed, 19 Jun 2019 10:18:01 -0400 Received: from mx2.rt-rk.com ([89.216.37.149]:50433 helo=mail.rt-rk.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hdbPO-0000p1-RL for qemu-devel@nongnu.org; Wed, 19 Jun 2019 10:17:58 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.rt-rk.com (Postfix) with ESMTP id B8B401A2274; Wed, 19 Jun 2019 16:17:46 +0200 (CEST) Received: from rtrkw774-lin.domain.local (rtrkw774-lin.domain.local [10.10.13.43]) by mail.rt-rk.com (Postfix) with ESMTPSA id 9A0181A1E12; Wed, 19 Jun 2019 16:17:46 +0200 (CEST) X-Virus-Scanned: amavisd-new at rt-rk.com From: Aleksandar Markovic To: qemu-devel@nongnu.org Date: Wed, 19 Jun 2019 16:17:12 +0200 Message-Id: <1560953834-29584-4-git-send-email-aleksandar.markovic@rt-rk.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1560953834-29584-1-git-send-email-aleksandar.markovic@rt-rk.com> References: <1560953834-29584-1-git-send-email-aleksandar.markovic@rt-rk.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 89.216.37.149 Subject: [Qemu-devel] [PATCH v12 3/5] linux-user: Add support for translation of statx() syscall X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Aleksandar Rikalo , laurent@vivier.eu, amarkovic@wavecomp.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Aleksandar Rikalo Implement support for translation of system call statx(). The implementation is based on "best effort" approach: if host is capable of executing statx(), host statx() is used. If not, the implementation includes invoking other (more mature) system calls (from the same 'stat' family) on the host side to achieve as close as possible functionality. Support for statx() in kernel and glibc was, however, introduced at different points of time (the difference is more than a year): - kernel: Linux 4.11 (30 April 2017) - glibc: glibc 2.28 (1 Aug 2018) In this patch, the availability of statx() support is established via __NR_statx (if it is defined, statx() is considered available). This coincedes with statx() introduction in kernel. However, the structure statx definition may not be available for hosts with glibc older than 2.28 (it is, by design, to be defined in one of glibc headers), even though the full statx() functionality may be supported in kernel, if the kernel is not older than 4.11. Hence, a structure "target_statx" is defined in this patch, to remove that dependency on glibc headers, and to use statx() functionality as soon as the host kernel is capable of supporting it. Such structure statx definition is used for both target and host structures statx (of course, this doesn't mean the endian arrangement is the same on target and host, and endian conversion is done in all necessary cases). Signed-off-by: Aleksandar Rikalo Signed-off-by: Aleksandar Markovic --- linux-user/syscall.c | 136 ++++++++++++++++++++++++++++++++++++++++++= +++- linux-user/syscall_defs.h | 37 +++++++++++++ 2 files changed, 172 insertions(+), 1 deletion(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index d116287..e68a36c 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -43,6 +43,7 @@ #include #include #include +#include #include #include #include @@ -316,6 +317,14 @@ _syscall5(int, kcmp, pid_t, pid1, pid_t, pid2, int, ty= pe, unsigned long, idx1, unsigned long, idx2) #endif =20 +/* + * It is assumed that struct statx is architecture independent. + */ +#if defined(TARGET_NR_statx) && defined(__NR_statx) +_syscall5(int, statx, int, dirfd, const char *, pathname, int, flags, + unsigned int, mask, struct target_statx *, statxbuf) +#endif + static bitmask_transtbl fcntl_flags_tbl[] =3D { { TARGET_O_ACCMODE, TARGET_O_WRONLY, O_ACCMODE, O_WRONLY, }, { TARGET_O_ACCMODE, TARGET_O_RDWR, O_ACCMODE, O_RDWR, }, @@ -6517,6 +6526,48 @@ static inline abi_long host_to_target_stat64(void *c= pu_env, } #endif =20 +#if defined(TARGET_NR_statx) && defined(__NR_statx) +static inline abi_long host_to_target_statx(struct target_statx *host_stx, + abi_ulong target_addr) +{ + struct target_statx *target_stx; + + if (!lock_user_struct(VERIFY_WRITE, target_stx, target_addr, 0)) { + return -TARGET_EFAULT; + } + memset(target_stx, 0, sizeof(*target_stx)); + + __put_user(host_stx->stx_mask, &target_stx->stx_mask); + __put_user(host_stx->stx_blksize, &target_stx->stx_blksize); + __put_user(host_stx->stx_attributes, &target_stx->stx_attributes); + __put_user(host_stx->stx_nlink, &target_stx->stx_nlink); + __put_user(host_stx->stx_uid, &target_stx->stx_uid); + __put_user(host_stx->stx_gid, &target_stx->stx_gid); + __put_user(host_stx->stx_mode, &target_stx->stx_mode); + __put_user(host_stx->stx_ino, &target_stx->stx_ino); + __put_user(host_stx->stx_size, &target_stx->stx_size); + __put_user(host_stx->stx_blocks, &target_stx->stx_blocks); + __put_user(host_stx->stx_attributes_mask, &target_stx->stx_attributes_= mask); + __put_user(host_stx->stx_atime.tv_sec, &target_stx->stx_atime.tv_sec); + __put_user(host_stx->stx_atime.tv_nsec, &target_stx->stx_atime.tv_nsec= ); + __put_user(host_stx->stx_btime.tv_sec, &target_stx->stx_atime.tv_sec); + __put_user(host_stx->stx_btime.tv_nsec, &target_stx->stx_atime.tv_nsec= ); + __put_user(host_stx->stx_ctime.tv_sec, &target_stx->stx_atime.tv_sec); + __put_user(host_stx->stx_ctime.tv_nsec, &target_stx->stx_atime.tv_nsec= ); + __put_user(host_stx->stx_mtime.tv_sec, &target_stx->stx_atime.tv_sec); + __put_user(host_stx->stx_mtime.tv_nsec, &target_stx->stx_atime.tv_nsec= ); + __put_user(host_stx->stx_rdev_major, &target_stx->stx_rdev_major); + __put_user(host_stx->stx_rdev_minor, &target_stx->stx_rdev_minor); + __put_user(host_stx->stx_dev_major, &target_stx->stx_dev_major); + __put_user(host_stx->stx_dev_minor, &target_stx->stx_dev_minor); + + unlock_user_struct(target_stx, target_addr, 1); + + return 0; +} +#endif + + /* ??? Using host futex calls even when target atomic operations are not really atomic probably breaks things. However implementing futexes locally would make futexes shared between multiple processes @@ -7095,7 +7146,8 @@ static abi_long do_syscall1(void *cpu_env, int num, a= bi_long arg1, abi_long ret; #if defined(TARGET_NR_stat) || defined(TARGET_NR_stat64) \ || defined(TARGET_NR_lstat) || defined(TARGET_NR_lstat64) \ - || defined(TARGET_NR_fstat) || defined(TARGET_NR_fstat64) + || defined(TARGET_NR_fstat) || defined(TARGET_NR_fstat64) \ + || defined(TARGET_NR_statx) struct stat st; #endif #if defined(TARGET_NR_statfs) || defined(TARGET_NR_statfs64) \ @@ -10173,6 +10225,88 @@ static abi_long do_syscall1(void *cpu_env, int num= , abi_long arg1, ret =3D host_to_target_stat64(cpu_env, arg3, &st); return ret; #endif +#if defined(TARGET_NR_statx) + case TARGET_NR_statx: + { + struct target_statx *target_stx; + int dirfd =3D arg1; + int flags =3D arg3; + + p =3D lock_user_string(arg2); + if (p =3D=3D NULL) { + return -TARGET_EFAULT; + } +#if defined(__NR_statx) + { + /* + * It is assumed that struct statx is architecture indepen= dent. + */ + struct target_statx host_stx; + int mask =3D arg4; + + ret =3D get_errno(statx(dirfd, p, flags, mask, &host_stx)); + if (!is_error(ret)) { + if (host_to_target_statx(&host_stx, arg5) !=3D 0) { + unlock_user(p, arg2, 0); + return -TARGET_EFAULT; + } + } + + if (ret !=3D -TARGET_ENOSYS) { + unlock_user(p, arg2, 0); + return ret; + } + } +#endif + if (*((char *)p) =3D=3D 0) { + /* + * By file descriptor + */ + if (flags & AT_EMPTY_PATH) { + unlock_user(p, arg2, 0); + return -TARGET_ENOENT; + } + ret =3D get_errno(fstat(dirfd, &st)); + } else if (*((char *)p) =3D=3D '/') { + /* + * By absolute pathname + */ + ret =3D get_errno(stat(path(p), &st)); + } else { + /* + * By pathname relative to the current working directory + * (if 'dirfd' is AT_FDCWD) or relative to the directory + * referred to by the file descriptor 'dirfd'. + */ + ret =3D get_errno(fstatat(dirfd, path(p), &st, flags)); + } + unlock_user(p, arg2, 0); + + if (!is_error(ret)) { + if (!lock_user_struct(VERIFY_WRITE, target_stx, arg5, 0)) { + return -TARGET_EFAULT; + } + memset(target_stx, 0, sizeof(*target_stx)); + __put_user(major(st.st_dev), &target_stx->stx_dev_major); + __put_user(minor(st.st_dev), &target_stx->stx_dev_minor); + __put_user(st.st_ino, &target_stx->stx_ino); + __put_user(st.st_mode, &target_stx->stx_mode); + __put_user(st.st_uid, &target_stx->stx_uid); + __put_user(st.st_gid, &target_stx->stx_gid); + __put_user(st.st_nlink, &target_stx->stx_nlink); + __put_user(major(st.st_rdev), &target_stx->stx_rdev_major); + __put_user(minor(st.st_rdev), &target_stx->stx_rdev_minor); + __put_user(st.st_size, &target_stx->stx_size); + __put_user(st.st_blksize, &target_stx->stx_blksize); + __put_user(st.st_blocks, &target_stx->stx_blocks); + __put_user(st.st_atime, &target_stx->stx_atime.tv_sec); + __put_user(st.st_mtime, &target_stx->stx_mtime.tv_sec); + __put_user(st.st_ctime, &target_stx->stx_ctime.tv_sec); + unlock_user_struct(target_stx, arg5, 1); + } + } + return ret; +#endif #ifdef TARGET_NR_lchown case TARGET_NR_lchown: if (!(p =3D lock_user_string(arg1))) diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index 7f141f6..170c4dd 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -2536,4 +2536,41 @@ struct target_user_cap_data { /* Return size of the log buffer */ #define TARGET_SYSLOG_ACTION_SIZE_BUFFER 10 =20 +struct target_statx_timestamp { + int64_t tv_sec; + uint32_t tv_nsec; + int32_t __reserved; +}; + +struct target_statx { + /* 0x00 */ + uint32_t stx_mask; /* What results were written [uncond] */ + uint32_t stx_blksize; /* Preferred general I/O size [uncond] */ + uint64_t stx_attributes; /* Flags conveying information about the file = */ + /* 0x10 */ + uint32_t stx_nlink; /* Number of hard links */ + uint32_t stx_uid; /* User ID of owner */ + uint32_t stx_gid; /* Group ID of owner */ + uint16_t stx_mode; /* File mode */ + uint16_t __spare0[1]; + /* 0x20 */ + uint64_t stx_ino; /* Inode number */ + uint64_t stx_size; /* File size */ + uint64_t stx_blocks; /* Number of 512-byte blocks allocated */ + uint64_t stx_attributes_mask; /* Mask to show what is supported */ + /* 0x40 */ + struct target_statx_timestamp stx_atime; /* Last access time */ + struct target_statx_timestamp stx_btime; /* File creation time */ + struct target_statx_timestamp stx_ctime; /* Last attribute change tim= e */ + struct target_statx_timestamp stx_mtime; /* Last data modification ti= me */ + /* 0x80 */ + uint32_t stx_rdev_major; /* Device ID of special file [if bdev/cdev] = */ + uint32_t stx_rdev_minor; + uint32_t stx_dev_major; /* ID of device containing file [uncond] */ + uint32_t stx_dev_minor; + /* 0x90 */ + uint64_t __spare2[14]; /* Spare space for future expansion */ + /* 0x100 */ +}; + #endif --=20 2.7.4 From nobody Sat May 4 18:07:34 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1560954293; cv=none; d=zoho.com; s=zohoarc; b=eNFMsyTi+EfFqYO7DBpZi699IBq3OIUFZcbJ9RKVNChEQHczfCFTSy3ChHtg/Eb1bpgjJFqEvZUdLCNtWdO4U6+xZeMYtY3nUsh1eeCllDyAXI0Gbo11eBGrtr7FB120t8XfA7kgJlKDOSTI1rff9R6GlkDZpqzQRtpsi6mpqGw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560954293; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=IwvNeNtKP+HVrThd8jv0tYn67B5p7gNjFVI2eBg2RKk=; b=elBt2AW7vwhSJ5k96ufBixgz5YJ00CA0OtTXwB6z9IMqn75g+4PEo9hcGeMMjhDVKPWcaX5Ea8EjYvVd5WPOy0/Ax/3I5YX0tMD+yxOhTXHepSoMa50M986FtdbhKMSv2sEYbNS7KLKdBrU3+ppdxKH2WBjbG2Bu2pus+7qrIyc= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560954293779652.8222996342483; Wed, 19 Jun 2019 07:24:53 -0700 (PDT) Received: from localhost ([::1]:38840 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hdbW8-0002Sn-Qg for importer@patchew.org; Wed, 19 Jun 2019 10:24:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54970) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hdbPZ-0004sV-2r for qemu-devel@nongnu.org; Wed, 19 Jun 2019 10:18:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hdbPX-00019a-Re for qemu-devel@nongnu.org; Wed, 19 Jun 2019 10:18:05 -0400 Received: from mx2.rt-rk.com ([89.216.37.149]:50596 helo=mail.rt-rk.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hdbPX-0000qZ-Hu for qemu-devel@nongnu.org; Wed, 19 Jun 2019 10:18:03 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.rt-rk.com (Postfix) with ESMTP id 328FB1A451C; Wed, 19 Jun 2019 16:17:49 +0200 (CEST) Received: from rtrkw774-lin.domain.local (rtrkw774-lin.domain.local [10.10.13.43]) by mail.rt-rk.com (Postfix) with ESMTPSA id 1792D1A4515; Wed, 19 Jun 2019 16:17:49 +0200 (CEST) X-Virus-Scanned: amavisd-new at rt-rk.com From: Aleksandar Markovic To: qemu-devel@nongnu.org Date: Wed, 19 Jun 2019 16:17:13 +0200 Message-Id: <1560953834-29584-5-git-send-email-aleksandar.markovic@rt-rk.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1560953834-29584-1-git-send-email-aleksandar.markovic@rt-rk.com> References: <1560953834-29584-1-git-send-email-aleksandar.markovic@rt-rk.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 89.216.37.149 Subject: [Qemu-devel] [PATCH v12 4/5] linux-user: Add support for strace for statx() syscall X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu, amarkovic@wavecomp.com, Jim Wilson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Jim Wilson All of the flags need to be conditional as old systems don't have statx support. Otherwise it works the same as other stat family syscalls. This requires the pending patch to add statx support. Tested on Ubuntu 16.04 (no host statx) and Ubuntu 19.04 (with host statx) using a riscv32-linux toolchain. Signed-off-by: Jim Wilson Signed-off-by: Aleksandar Markovic Reviewed-by: Laurent Vivier --- linux-user/strace.c | 86 ++++++++++++++++++++++++++++++++++++++++++++++= ++++ linux-user/strace.list | 3 ++ 2 files changed, 89 insertions(+) diff --git a/linux-user/strace.c b/linux-user/strace.c index 6f72a74..c80e93b 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -976,6 +976,76 @@ UNUSED static struct flags msg_flags[] =3D { FLAG_END, }; =20 +UNUSED static struct flags statx_flags[] =3D { +#ifdef AT_EMPTY_PATH + FLAG_GENERIC(AT_EMPTY_PATH), +#endif +#ifdef AT_NO_AUTOMOUNT + FLAG_GENERIC(AT_NO_AUTOMOUNT), +#endif +#ifdef AT_SYMLINK_NOFOLLOW + FLAG_GENERIC(AT_SYMLINK_NOFOLLOW), +#endif +#ifdef AT_STATX_SYNC_AS_STAT + FLAG_GENERIC(AT_STATX_SYNC_AS_STAT), +#endif +#ifdef AT_STATX_FORCE_SYNC + FLAG_GENERIC(AT_STATX_FORCE_SYNC), +#endif +#ifdef AT_STATX_DONT_SYNC + FLAG_GENERIC(AT_STATX_DONT_SYNC), +#endif + FLAG_END, +}; + +UNUSED static struct flags statx_mask[] =3D { +/* This must come first, because it includes everything. */ +#ifdef STATX_ALL + FLAG_GENERIC(STATX_ALL), +#endif +/* This must come second; it includes everything except STATX_BTIME. */ +#ifdef STATX_BASIC_STATS + FLAG_GENERIC(STATX_BASIC_STATS), +#endif +#ifdef STATX_TYPE + FLAG_GENERIC(STATX_TYPE), +#endif +#ifdef STATX_MODE + FLAG_GENERIC(STATX_MODE), +#endif +#ifdef STATX_NLINK + FLAG_GENERIC(STATX_NLINK), +#endif +#ifdef STATX_UID + FLAG_GENERIC(STATX_UID), +#endif +#ifdef STATX_GID + FLAG_GENERIC(STATX_GID), +#endif +#ifdef STATX_ATIME + FLAG_GENERIC(STATX_ATIME), +#endif +#ifdef STATX_MTIME + FLAG_GENERIC(STATX_MTIME), +#endif +#ifdef STATX_CTIME + FLAG_GENERIC(STATX_CTIME), +#endif +#ifdef STATX_INO + FLAG_GENERIC(STATX_INO), +#endif +#ifdef STATX_SIZE + FLAG_GENERIC(STATX_SIZE), +#endif +#ifdef STATX_BLOCKS + FLAG_GENERIC(STATX_BLOCKS), +#endif +#ifdef STATX_BTIME + FLAG_GENERIC(STATX_BTIME), +#endif + FLAG_END, +}; + /* * print_xxx utility functions. These are used to print syscall * parameters in certain format. All of these have parameter @@ -2611,6 +2681,22 @@ print_tgkill(const struct syscallname *name, } #endif =20 +#ifdef TARGET_NR_statx +static void +print_statx(const struct syscallname *name, + abi_long arg0, abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, abi_long arg5) +{ + print_syscall_prologue(name); + print_at_dirfd(arg0, 0); + print_string(arg1, 0); + print_flags(statx_flags, arg2, 0); + print_flags(statx_mask, arg3, 0); + print_pointer(arg4, 1); + print_syscall_epilogue(name); +} +#endif + /* * An array of all of the syscalls we know about */ diff --git a/linux-user/strace.list b/linux-user/strace.list index db21ce4..63a9466 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -1650,3 +1650,6 @@ #ifdef TARGET_NR_atomic_barrier { TARGET_NR_atomic_barrier, "atomic_barrier", NULL, NULL, NULL }, #endif +#ifdef TARGET_NR_statx +{ TARGET_NR_statx, "statx", NULL, print_statx, NULL }, +#endif --=20 2.7.4 From nobody Sat May 4 18:07:34 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1560954237; cv=none; d=zoho.com; s=zohoarc; b=AiyXBr/9TncYPbhvD/YvcCAoLKa07+zVxRtGQO3ylrnijLbrRXPuplJo4e2K3pq1s/Bs16DxYenYkMN6/HyOWrb6GR48cJ+VxbixErB25M54InIsXbOis1Pehu0cKy7kmO2gvrCBLFfB3EzPg8Fc5cBm7Sv3M0rzKEpzbHH0wC0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560954237; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=AiDZ2NgBn8eFvH4ZLbS3qvJ77//7CIRFrwp92gm/ziA=; b=B6L7kPA/5HEhuBbQDkMan5S5EfJ7iXwSq5rOuiuhSoE9/wOKo0XhVulHDV7wdEi1sBh3RFaaLyilZMT8nsfKmrZz8D5q9JKis+ULSui4SnSMTOCi5hjq4GSFFORXHl4sgplP1vcFOWvjrD+Ezo5qW9jVTKXJxoL78TZSj/9VIgo= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560954237081938.6489326386637; Wed, 19 Jun 2019 07:23:57 -0700 (PDT) Received: from localhost ([::1]:38824 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hdbVC-0000BC-2c for importer@patchew.org; Wed, 19 Jun 2019 10:23:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54968) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hdbPY-0004rr-Sl for qemu-devel@nongnu.org; Wed, 19 Jun 2019 10:18:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hdbPX-000195-P1 for qemu-devel@nongnu.org; Wed, 19 Jun 2019 10:18:04 -0400 Received: from mx2.rt-rk.com ([89.216.37.149]:50672 helo=mail.rt-rk.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hdbPX-0000rn-IA for qemu-devel@nongnu.org; Wed, 19 Jun 2019 10:18:03 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.rt-rk.com (Postfix) with ESMTP id 96D541A2255; Wed, 19 Jun 2019 16:17:50 +0200 (CEST) Received: from rtrkw774-lin.domain.local (rtrkw774-lin.domain.local [10.10.13.43]) by mail.rt-rk.com (Postfix) with ESMTPSA id 7D2F51A1FB1; Wed, 19 Jun 2019 16:17:50 +0200 (CEST) X-Virus-Scanned: amavisd-new at rt-rk.com From: Aleksandar Markovic To: qemu-devel@nongnu.org Date: Wed, 19 Jun 2019 16:17:14 +0200 Message-Id: <1560953834-29584-6-git-send-email-aleksandar.markovic@rt-rk.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1560953834-29584-1-git-send-email-aleksandar.markovic@rt-rk.com> References: <1560953834-29584-1-git-send-email-aleksandar.markovic@rt-rk.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 89.216.37.149 Subject: [Qemu-devel] [PATCH v12 5/5] linux-user: Fix flock structure for MIPS O64 ABI X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu, amarkovic@wavecomp.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Aleksandar Markovic Only MIPS O32 and N32 have special (different than other architectures) definition of structure flock in kernel. Bring flock definition for MIPS O64 ABI to the correct state. Reported-by: Dragan Mladjenovic Signed-off-by: Aleksandar Markovic --- linux-user/generic/fcntl.h | 2 +- linux-user/mips/target_fcntl.h | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/linux-user/generic/fcntl.h b/linux-user/generic/fcntl.h index a775a49..1b48dde 100644 --- a/linux-user/generic/fcntl.h +++ b/linux-user/generic/fcntl.h @@ -129,7 +129,7 @@ struct target_flock { short l_whence; abi_long l_start; abi_long l_len; -#if defined(TARGET_MIPS) +#if defined(TARGET_MIPS) && (TARGET_ABI_BITS =3D=3D 32) abi_long l_sysid; #endif int l_pid; diff --git a/linux-user/mips/target_fcntl.h b/linux-user/mips/target_fcntl.h index 000527c..795bba7 100644 --- a/linux-user/mips/target_fcntl.h +++ b/linux-user/mips/target_fcntl.h @@ -27,7 +27,11 @@ #define TARGET_F_SETOWN 24 /* for sockets. */ #define TARGET_F_GETOWN 23 /* for sockets. */ =20 +#if (TARGET_ABI_BITS =3D=3D 32) #define TARGET_ARCH_FLOCK_PAD abi_long pad[4]; +#else +#define TARGET_ARCH_FLOCK_PAD +#endif #define TARGET_ARCH_FLOCK64_PAD =20 #define TARGET_F_GETLK64 33 /* using 'struct flock64' */ --=20 2.7.4