From nobody Sat Feb 7 05:42:36 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1dmarc=pass fromdomain=syrmia.com) ARC-Seal: i=2; a=rsa-sha256; t=1591635192; cv=pass; d=zohomail.com; s=zohoarc; b=ZVT+4Yh4Ld/BORTtm6gfijTlIPHfNXjOYwDH1WX+n68ndXW6NABrpNewJZipDYOnocD2oYSK7mnuf/MIsgejfiGMCUCJ4AI0ywFhbjIdAGEs69M6VecLr65HisEFS/ctnvlr7SBnjO6NGxKerlbU8XrIaPNKm4lC3Jea8CGzzHE= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591635192; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=OTM2FEi0DCTCyUiXiXAthGGDDJJBNDxBaUN9ck30WCk=; b=OwpMm07oLKu1MSqHYs8h1aVF/vGT+kj1j9UCW149Yz3Epe7dMCq492MLQlkGIiongCVHbQuwc4IgFHv1n/nYCnxAgxxXKM+y4P5oHwfUyeN8dPHH7BVqlRzVpacHP5Jb43sT9A1kPTeCG8yBQoU/oQR4L9mLzfVANVQslu+p9oc= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1dmarc=pass fromdomain=syrmia.com) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591635192233736.8646001831302; Mon, 8 Jun 2020 09:53:12 -0700 (PDT) Received: from localhost ([::1]:54920 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jiL1K-0006gH-VF for importer@patchew.org; Mon, 08 Jun 2020 12:53:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43590) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jiKsy-0003Wn-DT for qemu-devel@nongnu.org; Mon, 08 Jun 2020 12:44:32 -0400 Received: from mail-eopbgr80091.outbound.protection.outlook.com ([40.107.8.91]:62103 helo=EUR04-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jiKsx-0007Fd-9u for qemu-devel@nongnu.org; Mon, 08 Jun 2020 12:44:32 -0400 Received: from AM6PR03MB5233.eurprd03.prod.outlook.com (2603:10a6:20b:d1::19) by AM6PR03MB3798.eurprd03.prod.outlook.com (2603:10a6:20b:1f::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3066.19; Mon, 8 Jun 2020 16:44:13 +0000 Received: from AM6PR03MB5233.eurprd03.prod.outlook.com ([fe80::98f0:b948:78a8:f618]) by AM6PR03MB5233.eurprd03.prod.outlook.com ([fe80::98f0:b948:78a8:f618%7]) with mapi id 15.20.3066.023; Mon, 8 Jun 2020 16:44:13 +0000 Received: from bozuta-ubuntu-18.syrmia.com (46.240.135.226) by ZR0P278CA0016.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:16::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3066.18 via Frontend Transport; Mon, 8 Jun 2020 16:44:13 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ajus1o+YfWIC820IcIMyeG9lvJZf5P2CwQEyHKACEruk+sfZ/vkCIsGSk2ctrXxvMUa4BQ0JlSwV7wupa6/aHyDcfyeJVEp7jWgSQi5dRLsp1Ui06JESTD3CoU1FnhmK3aY2yfjsHotxlyWLh4V3oK1C7SZkQDUDX4WDGAebm9sdaFtM5j8QYq1hX2BRYL5V5jnyn3VV1+JeThJtj+lQk7U8NG73n3NDSuzpGdVvCOOgzVKNV/kreN8LwkEHduIDJcQy/emgAguQ6ZbZBRn0ml83dbyM5D3y3Ox+wtGps14UIUgw2br+Itjm8Zk/52E5DW0uVLl8XwIK9CgSopN/fA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OTM2FEi0DCTCyUiXiXAthGGDDJJBNDxBaUN9ck30WCk=; b=bcP5O8tl/51mQDKRujar5cmts6wFeteaWu0zXyeo20CafJudbKDoSz33GC0GSw9inG0ihj2AhN3VNVq86Q8gPUS/BtiimyzasqJronlnq2dUw8AUkzXLy4l19GTyMBIB7jOk277Crq7+nelNGGWjFO3PWubsyMRrJXBAudg+Cu818z/qbnZAgHnmgLoTPknkxWd6GBM8nureqirgAYhR//Cc6vTP50Ms6DJnd35ViA49C7lJ8tgZjPK+QfDP9EoWNNgM/WGIcjo1jxgyWan2l+ODPLY7w4T6p7cgsOpSQXXK7Tp9FweIlmaZFAVGIERwe1LnzgjbnZ23R2UkhcNPCQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=syrmia.com; dmarc=pass action=none header.from=syrmia.com; dkim=pass header.d=syrmia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=syrmia.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OTM2FEi0DCTCyUiXiXAthGGDDJJBNDxBaUN9ck30WCk=; b=C4isYkX9Ol9QW9Anrk1sWQYX5xnnbKX/XaYAWHcP72jdt2Cd0M0trVNHVlWNo2+SqG3krhuXO67fGYKyQ6BhYeF8ZcAO5oNyrdUxVNrXSKOwKjULoT7AC6b+NFyUKwX6xyIfVTLXh/mODY496JpJgC3QDHTDwQccFL1cfoRGGUw= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=syrmia.com; From: Filip Bozuta To: qemu-devel@nongnu.org Subject: [PATCH v2 6/6] linux-user: Add strace support for printing arguments of fallocate() Date: Mon, 8 Jun 2020 18:43:57 +0200 Message-Id: <20200608164357.25065-7-filip.bozuta@syrmia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200608164357.25065-1-filip.bozuta@syrmia.com> References: <20200608164357.25065-1-filip.bozuta@syrmia.com> X-ClientProxiedBy: ZR0P278CA0016.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:16::26) To AM6PR03MB5233.eurprd03.prod.outlook.com (2603:10a6:20b:d1::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [46.240.135.226] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3943a50a-e9a0-4075-2ad6-08d80bcb2d0b X-MS-TrafficTypeDiagnostic: AM6PR03MB3798: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-Forefront-PRVS: 042857DBB5 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LVAbU/Yd2eKqWUoVGUtUHkg+oSfb4VkhtGhRNGK7MUch6rPHnREhHAuIjPjsMqIJs2BVB5jB7BcJ3FF3u3L172ZKt0oXsVuaCUjDcMo3EXW4le+yajbDiZQaJ7ZUSp4EUQfoQv1yfPy4GvUs+m/gb4hu/2Blq54byylR2WstojRfsKDyNHxGNoBixGnC1xYF83p8Oer1J5FGT7EKjh6m6GiB8uWy1a262AMkym9NCJn+cNo1WTLxC634j5KA/pvyYg64nIWlcO2jOjOun67FH2kHb6tYyUagCXPfwDXGiFh6+ggOnWALGdX1n26kNNEqX1Cy23mtk3URJ63btcooIWrHg6FqyUV/ZWfTWSkmwU8qjGS3/gzLSduuCAQSEwKOMouBB0ldIfj3pfsuuWTKyQrsZlMok6ay8YJADsWFC+dfbke/aB9BjwslX7n8zkVLFPPiHSCLBQGURx/G8FSaRQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR03MB5233.eurprd03.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(39830400003)(376002)(396003)(346002)(136003)(366004)(508600001)(4326008)(8676002)(8936002)(966005)(1076003)(66556008)(6916009)(66476007)(5660300002)(66946007)(86362001)(316002)(36756003)(16526019)(26005)(2906002)(52116002)(83380400001)(2616005)(956004)(44832011)(6486002)(7696005)(186003)(6666004)(21314003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: 07PQ8jdn0AgzqHzzlTIjI1HUTIPxGCYrm9cDvBplcCxZIXOUu0Cl6D5HftgxUtlyphdx5iUNwpH9SOOmxct5VuwxxAOOoroCkJSWQG2MeYbZLQTNP9fJSeNzB3d9xUSSXHsRVjz8IrxzK3Z41d+8iB/3OICxrUqFZ/H8b5IE6ocGTnGqwmf04JA2Tv0/2vX48mjO3QBATtxwEjiaolOSh8burBjqFmGKxS1hvxlLLkdcTI07EFFHoWlIvcKcYpcsbe1CD3/p7Wdq6K2fyg+VWiPk936jIDSQL8X3F4/n4EOHE3CD9Ekei5i3yXwiyjZ8LISi45L+uB0JMqc4m9Q1G45M+2jr7sqHItVmmwLs8QFQp7NLkRr+LdmROPu13P4j7NIx0PKx+traNBrnwFKzDiM26KscWLQ5KHlF+LFv7AREQNcLexSXzL2TtSDbSwpW77YQfQf/mSs9MpQApNruxOkdRABv5RrKONZphB4d/AU= X-OriginatorOrg: syrmia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3943a50a-e9a0-4075-2ad6-08d80bcb2d0b X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jun 2020 16:44:13.6617 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 19214a73-c1ab-4e19-8f59-14bdcb09a66e X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: EMswaa3yEt0zbu279Eh+jrBJQtNJ23QEZJzRg0T+ZJAMYo+J3tJLU+/TKCPxnMEreq0uNzIWqkKBVPlGsLxEwA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR03MB3798 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=40.107.8.91; envelope-from=Filip.Bozuta@syrmia.com; helo=EUR04-VI1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/08 12:44:17 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.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, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action 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 Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @syrmia.com) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Filip Bozuta This patch implements strace argument printing functionality for following = syscall: *fallocate - manipulate file space int fallocate(int fd, int mode, off_t offset, off_t len) man page: https://www.man7.org/linux/man-pages/man2/fallocate.2.html Implementation notes: This syscall's second argument "mode" is composed of predefined values which represent flags that determine the type of operation that is to be performed on the file space. For that reason, a printing function "print_fallocate" was stated in file "strace.list". This print= ing function uses an already existing function "print_flags()" to print fla= gs of the "mode" argument. These flags are stated inside an array "falloc_fla= gs" that contains values of type "struct flags". These values are instantia= ted using an existing macro "FLAG_GENERIC()". Most of these flags are defin= ed after kernel version 3.0 which is why they are enwrapped in an #ifdef directive. The syscall's third ant fourth argument are of type "off_t" which can cause variations between 32/64-bit architectures. To handle this variat= ion, function "target_offset64()" was copied from file "strace.c" and used in "print_fallocate" to print "off_t" arguments for 32-bit architectures. Signed-off-by: Filip Bozuta Reviewed-by: Laurent Vivier --- linux-user/qemu.h | 16 ++++++++++++++++ linux-user/strace.c | 40 ++++++++++++++++++++++++++++++++++++++++ linux-user/strace.list | 2 +- linux-user/syscall.c | 16 ---------------- 4 files changed, 57 insertions(+), 17 deletions(-) diff --git a/linux-user/qemu.h b/linux-user/qemu.h index 8f938b8105..be67391ba4 100644 --- a/linux-user/qemu.h +++ b/linux-user/qemu.h @@ -670,6 +670,22 @@ static inline int is_error(abi_long ret) return (abi_ulong)ret >=3D (abi_ulong)(-4096); } =20 +#if TARGET_ABI_BITS =3D=3D 32 +static inline uint64_t target_offset64(uint32_t word0, uint32_t word1) +{ +#ifdef TARGET_WORDS_BIGENDIAN + return ((uint64_t)word0 << 32) | word1; +#else + return ((uint64_t)word1 << 32) | word0; +#endif +} +#else /* TARGET_ABI_BITS =3D=3D 32 */ +static inline uint64_t target_offset64(uint64_t word0, uint64_t word1) +{ + return word0; +} +#endif /* TARGET_ABI_BITS !=3D 32 */ + /** * preexit_cleanup: housekeeping before the guest exits * diff --git a/linux-user/strace.c b/linux-user/strace.c index cd6a2b8e3f..3ef7f80cd7 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -1144,6 +1144,26 @@ UNUSED static struct flags statx_mask[] =3D { FLAG_END, }; =20 +UNUSED static struct flags falloc_flags[] =3D { + FLAG_GENERIC(FALLOC_FL_KEEP_SIZE), + FLAG_GENERIC(FALLOC_FL_PUNCH_HOLE), +#ifdef FALLOC_FL_NO_HIDE_STALE + FLAG_GENERIC(FALLOC_FL_NO_HIDE_STALE), +#endif +#ifdef FALLOC_FL_COLLAPSE_RANGE + FLAG_GENERIC(FALLOC_FL_COLLAPSE_RANGE), +#endif +#ifdef FALLOC_FL_ZERO_RANGE + FLAG_GENERIC(FALLOC_FL_ZERO_RANGE), +#endif +#ifdef FALLOC_FL_INSERT_RANGE + FLAG_GENERIC(FALLOC_FL_INSERT_RANGE), +#endif +#ifdef FALLOC_FL_UNSHARE_RANGE + FLAG_GENERIC(FALLOC_FL_UNSHARE_RANGE), +#endif +}; + /* * print_xxx utility functions. These are used to print syscall * parameters in certain format. All of these have parameter @@ -1561,6 +1581,26 @@ print_faccessat(const struct syscallname *name, } #endif =20 +#ifdef TARGET_NR_fallocate +static void +print_fallocate(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_raw_param("%d", arg0, 0); + print_flags(falloc_flags, arg1, 0); +#if TARGET_ABI_BITS =3D=3D 32 + print_raw_param("%" PRIu64, target_offset64(arg2, arg3), 0); + print_raw_param("%" PRIu64, target_offset64(arg4, arg5), 1); +#else + print_raw_param(TARGET_ABI_FMT_ld, arg2, 0); + print_raw_param(TARGET_ABI_FMT_ld, arg3, 1); +#endif + print_syscall_epilogue(name); +} +#endif + #ifdef TARGET_NR_fchmodat static void print_fchmodat(const struct syscallname *name, diff --git a/linux-user/strace.list b/linux-user/strace.list index 44eb515ca4..a8d7cbe7a4 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -182,7 +182,7 @@ { TARGET_NR_fadvise64_64, "fadvise64_64" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_fallocate -{ TARGET_NR_fallocate, "fallocate" , NULL, NULL, NULL }, +{ TARGET_NR_fallocate, "fallocate" , NULL, print_fallocate, NULL }, #endif #ifdef TARGET_NR_fanotify_init { TARGET_NR_fanotify_init, "fanotify_init" , NULL, NULL, NULL }, diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 009bb67422..7cc5a65b4f 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -6608,22 +6608,6 @@ void syscall_init(void) } } =20 -#if TARGET_ABI_BITS =3D=3D 32 -static inline uint64_t target_offset64(uint32_t word0, uint32_t word1) -{ -#ifdef TARGET_WORDS_BIGENDIAN - return ((uint64_t)word0 << 32) | word1; -#else - return ((uint64_t)word1 << 32) | word0; -#endif -} -#else /* TARGET_ABI_BITS =3D=3D 32 */ -static inline uint64_t target_offset64(uint64_t word0, uint64_t word1) -{ - return word0; -} -#endif /* TARGET_ABI_BITS !=3D 32 */ - #ifdef TARGET_NR_truncate64 static inline abi_long target_truncate64(void *cpu_env, const char *arg1, abi_long arg2, --=20 2.17.1