From nobody Sun May 19 04:34:58 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1dmarc=pass fromdomain=syrmia.com) ARC-Seal: i=2; a=rsa-sha256; t=1592570969; cv=pass; d=zohomail.com; s=zohoarc; b=jTKqK+bXdhZVs2zAz5Kw4qdU1Du1rcAuUyJsgt/9CDgQFZMzqq5VzE0xgXaPemzGaowgwW7ixiBLBIrf7dM5yKbcVhQfQljgyLxLpHm+aVYG7gESns9hrbrHERhwPJCrNmuhQmNz1Mc2WwfGLAZUZtQ4xDuE8Gmnmw0PQg6MHfE= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592570969; 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=TcYdOMbhAVIq4VN6SOXjgOGgI9gyNwmg6z+yTTxu9ZU=; b=ezgvuygdpsy7k2NpwA+Xgxs3srCK7MfvSm8iNYN0RE5xY89QKO/QlVy2KKCrcAGW4U77/7itnaUnWgD8zG4WCKCoywx1yBMcCCz7PvH4r6e9Hqi5nxqzqKEMNqyQfYER4d9RLFZxPqyjHGoxI3PrH7r1glnrrIH3VPKdTYAEpKQ= 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 1592570969083741.1376367134355; Fri, 19 Jun 2020 05:49:29 -0700 (PDT) Received: from localhost ([::1]:48758 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmGSV-0000FM-Pj for importer@patchew.org; Fri, 19 Jun 2020 08:49:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37226) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmGQu-0007A1-50 for qemu-devel@nongnu.org; Fri, 19 Jun 2020 08:47:48 -0400 Received: from mail-eopbgr130117.outbound.protection.outlook.com ([40.107.13.117]:41591 helo=EUR01-HE1-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 1jmGQs-0006QN-9k for qemu-devel@nongnu.org; Fri, 19 Jun 2020 08:47:47 -0400 Received: from AM6PR03MB5233.eurprd03.prod.outlook.com (2603:10a6:20b:d1::19) by AM6PR03MB5094.eurprd03.prod.outlook.com (2603:10a6:20b:80::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.23; Fri, 19 Jun 2020 12:47:41 +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.3109.023; Fri, 19 Jun 2020 12:47:41 +0000 Received: from bozuta-ubuntu-18.syrmia.com (46.240.135.226) by ZRAP278CA0018.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:10::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22 via Frontend Transport; Fri, 19 Jun 2020 12:47:40 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JgCGO5LlOyd8RWvi06Dohe+3tUM3WF64MQYDepQZPbdHJrGsKaiUNEhgPNKZVBbxuQP12ZtRvyBS6pfKfAxhdpsZUYpwizkNOxAfhZlw7dTD0kCaMJVdRlEizHQ4mk18PU8eRxq0grOukmFSzGcztbuVseNlrLEbW3MQSsPUD0P1ixN1csYO+mr0wen6+Ygli+vQRydwb3SgyVXoHaQkWdWogGYT45D6J3h1l2+bdpbQO2HpBKe2KimHdjX175GmCb5IFVRQ7XHP0/LPZQ3mQNBZHJMUnTfLVXJZyScGjlMySrDqrcHsSPa/q171X1Zd4Y3ezoziRtqYbjPZEsg5Zg== 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=TcYdOMbhAVIq4VN6SOXjgOGgI9gyNwmg6z+yTTxu9ZU=; b=TTJIS1TizbvO6vQBz+JHLPatvzC8dGK/Xgu47Tp87E7tRFvzkyTwerP/8mLKUsFImx0cGhXPf5aPrPj0VtOPpctYwlwH53oTgO0f6AacYhBMkmkpexl7+5D4VFSZkh1FSFdwV98a/W3OMNIV2aN20WsG5Eo7o6TrM+BurtC0vYzQ5eVfcpjsdJjcn2b2sS7niQSr1qP3FoOt3/K/x9OPdCiJg2OkFu8SSbRCskj/nCbsJ29v0OWtXcae0eDYU7qr7I4bMLZ3GSy8U84lsMj0YZCko7XhzUxMbPFFMr8W9mtcu97Jr3hXkc7eywo8JAi2jrtRPkoxTZSkXgju3WBCog== 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=TcYdOMbhAVIq4VN6SOXjgOGgI9gyNwmg6z+yTTxu9ZU=; b=dIw2g0n60cUyRC9J9B4TaTQ9rv9nKApz9ZIhTjzZ42rmmNPZb/itfc/RzrHyf0uWfaxo1iltpBe4evBvVVD+b+pXimg4qj021fI8FBPonfNzaekJN83IfdEEjqvrnED5V1jnD4OpRUY3jaCVfWU2YQ9Gllhp2EHApp9S3ZasV5o= 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 v3 1/2] linux-user: Add thunk argument types for SIOCGSTAMP and SIOCGSTAMPNS Date: Fri, 19 Jun 2020 14:47:26 +0200 Message-Id: <20200619124727.18080-2-filip.bozuta@syrmia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200619124727.18080-1-filip.bozuta@syrmia.com> References: <20200619124727.18080-1-filip.bozuta@syrmia.com> X-ClientProxiedBy: ZRAP278CA0018.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:10::28) 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: ad0d41d0-3486-44b2-6fdc-08d8144ef452 X-MS-TrafficTypeDiagnostic: AM6PR03MB5094: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6108; X-Forefront-PRVS: 0439571D1D X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9Dt4TB9B2NyYP9U+15KWdQykYw7tioPO3YO2iKGDpkcwX8B8CcgrltYg2sNh/0I3N1thltz0wjDAlac1gJM4spAE3z/6dhOb8OgJT1s26xTwugh8GG/VVOFZJIab1ar5yBEXvBmkkIV6gMoJB2aj6OaWr2s3ADmsEoMG2/HAEKT7etlYX3gZl8orBUbo6cYyuZA6KQGC/kAbeNHz++VLEBHtY7Svc7OAkRXA2zlrg54g1CP3VaMKWk3tFoWzAZqQXkGPIpSDj2IAd9IfB2PPeRfEd5M4O+YZVZ3aAKx6g81kYbYzk3Ub+DHqNf/m6PplwK04xc+QI9/wYJJGLpFhrg== 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:(376002)(346002)(136003)(366004)(396003)(39830400003)(8676002)(36756003)(8936002)(5660300002)(83380400001)(186003)(16526019)(1076003)(86362001)(66556008)(6916009)(44832011)(2906002)(4326008)(6666004)(316002)(956004)(508600001)(6486002)(52116002)(66946007)(7696005)(26005)(2616005)(66476007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: yZticbx3FZQE3AugiLlMLeLS3JJzq2h0Vvyb1RJ3JpNL3eB7AAEUqIp2VG9FN9lMVoy7QiH5oaaSXccOtIMplNAGCogQWJQwCjoiFeiq3TkegwpH0y0Mp0+kpSka7M0vPo+R0CGVPxTTWOmvT21UAOkfgi3SsKoa1jaKjx+jCORebyfbW+VvgMJhfYp3c4YLCc1LjKSKCw3LqyuIWz/sUqaZtjFA/UUnkRYAm9/lWNkY2wnxpLNhs/ieh2ikXjNBMBuTiMi/pTvUTgrSH+DPntKR5iAAzvUvm7nITEe/exEuGxHhxkhcgb4PFi8jcwdu0/7mq2sx+5fJYQ/MCtwrycxtYkZ2xOiwgS6542VXIs80LfCNZgUxCmbF4oYOcmgBGnSsiDt2WqkI1A0GZM24mQ9HmU3vCnuGMtsWQo4St+NtgM/Vv+DIUkz//6XO6kwu9KGVP5pyEBKdXPD7H9lnLbNUMHatfKpLHtDHMOZxFLw= X-OriginatorOrg: syrmia.com X-MS-Exchange-CrossTenant-Network-Message-Id: ad0d41d0-3486-44b2-6fdc-08d8144ef452 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jun 2020 12:47:41.3472 (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: BJfYTSOIeol0BjSsMk7/vFpdQ2CKU1jlUTx4jAlZM728Uo84+wUHlOjNtnXGv+ox1M1JwVQF6E/tuf0Bm4RdOQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR03MB5094 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.13.117; envelope-from=Filip.Bozuta@syrmia.com; helo=EUR01-HE1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/19 08:47:41 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -37 X-Spam_score: -3.8 X-Spam_bar: --- X-Spam_report: (-3.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=-1, 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: riku.voipio@iki.fi, 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 Socket ioctls SIOCGSTAMP and SIOCGSTAMPNS, used for timestamping the socket connection, are defined in file "ioctls.h" differently from other ioctls. The reason for this difference is explained in the comments above their def= inition. These ioctls didn't have defined thunk argument types before changes from t= his patch. They have special handling functions ("do_ioctl_SIOCGSTAMP" and "do_ioctl_SIOCGSTAMPNS") that take care of setting values for approppriate = argument types (struct timeval and struct timespec) and thus no thunk argument types= were needed for their implementation. But this patch adds those argument type de= finitions in file "syscall_types.h" and "ioctls.h" as it is needed for printing argum= ents of these ioctls with strace. Implementation notes: There are two variants of these ioctls: SIOCGSTAMP_OLD/SIOCGSTAM_NEW and SIOCGSTAMPNS_OLD/SIOCGSTAMPNS_NEW. One is the old existing definition a= nd the other is the 2038 safe variant used for 32-bit architectures. Correspon= ding structure definitions STRUCT_timespec/STRUCT__kernel_timespec and STRUCT_timeval/STRUCT__kernel_sock_timeval were added for these variant= s. STRUCT_timeval definition was already inside the file as it is used by another implemented ioctl. Two cases were added for definitions STRUCT_timeval/STRUCT__kernel_sock_timeval to manage the case when the "u_sec" field of the timeval structure is of type int. Signed-off-by: Filip Bozuta Reviewed-by: Laurent Vivier --- linux-user/ioctls.h | 12 ++++++++---- linux-user/syscall_types.h | 22 ++++++++++++++++++++++ 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h index 0defa1d8c1..edb7172207 100644 --- a/linux-user/ioctls.h +++ b/linux-user/ioctls.h @@ -279,13 +279,17 @@ * FIXME: create a macro to define this kind of entry */ { TARGET_SIOCGSTAMP_OLD, TARGET_SIOCGSTAMP_OLD, - "SIOCGSTAMP_OLD", IOC_R, do_ioctl_SIOCGSTAMP }, + "SIOCGSTAMP_OLD", IOC_R, do_ioctl_SIOCGSTAMP, + { MK_PTR(MK_STRUCT(STRUCT_timeval)) } }, { TARGET_SIOCGSTAMPNS_OLD, TARGET_SIOCGSTAMPNS_OLD, - "SIOCGSTAMPNS_OLD", IOC_R, do_ioctl_SIOCGSTAMPNS }, + "SIOCGSTAMPNS_OLD", IOC_R, do_ioctl_SIOCGSTAMPNS, + { MK_PTR(MK_STRUCT(STRUCT_timespec)) } }, { TARGET_SIOCGSTAMP_NEW, TARGET_SIOCGSTAMP_NEW, - "SIOCGSTAMP_NEW", IOC_R, do_ioctl_SIOCGSTAMP }, + "SIOCGSTAMP_NEW", IOC_R, do_ioctl_SIOCGSTAMP, + { MK_PTR(MK_STRUCT(STRUCT__kernel_sock_timeval)) } }, { TARGET_SIOCGSTAMPNS_NEW, TARGET_SIOCGSTAMPNS_NEW, - "SIOCGSTAMPNS_NEW", IOC_R, do_ioctl_SIOCGSTAMPNS }, + "SIOCGSTAMPNS_NEW", IOC_R, do_ioctl_SIOCGSTAMPNS, + { MK_PTR(MK_STRUCT(STRUCT__kernel_timespec)) } }, =20 IOCTL(RNDGETENTCNT, IOC_R, MK_PTR(TYPE_INT)) IOCTL(RNDADDTOENTCNT, IOC_W, MK_PTR(TYPE_INT)) diff --git a/linux-user/syscall_types.h b/linux-user/syscall_types.h index 4e12c1661e..d636561bf4 100644 --- a/linux-user/syscall_types.h +++ b/linux-user/syscall_types.h @@ -137,10 +137,32 @@ STRUCT(snd_timer_params, TYPE_INT, /* filter */ MK_ARRAY(TYPE_CHAR, 60)) /* reserved */ =20 +#if defined(TARGET_SPARC64) && !defined(TARGET_ABI32) +STRUCT(timeval, + TYPE_LONG, /* tv_sec */ + TYPE_INT) /* tv_usec */ + +STRUCT(_kernel_sock_timeval, + TYPE_LONG, /* tv_sec */ + TYPE_INT) /* tv_usec */ +#else +STRUCT(timeval, + TYPE_LONG, /* tv_sec */ + TYPE_LONG) /* tv_usec */ + +STRUCT(_kernel_sock_timeval, + TYPE_LONGLONG, /* tv_sec */ + TYPE_LONGLONG) /* tv_usec */ +#endif + STRUCT(timespec, TYPE_LONG, /* tv_sec */ TYPE_LONG) /* tv_nsec */ =20 +STRUCT(_kernel_timespec, + TYPE_LONGLONG, /* tv_sec */ + TYPE_LONGLONG) /* tv_nsec */ + STRUCT(snd_timer_status, MK_STRUCT(STRUCT_timespec), /* tstamp */ TYPE_INT, /* resolution */ --=20 2.17.1 From nobody Sun May 19 04:34:58 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1dmarc=pass fromdomain=syrmia.com) ARC-Seal: i=2; a=rsa-sha256; t=1592570972; cv=pass; d=zohomail.com; s=zohoarc; b=MPOnPmu6dVJ11TWJvh/I61kmhLr2KOCccnSHOFZjLPxLbRpUbzuOOlywvCRBSYg23q7RAMMl6LC/tcjxkIJw1skjA9u/SLd4850H3PnHzHijPUMT8VJW1a2mgrTCRZ49W4imL1Kdw3sosbHMI7dWwEFbwtPhzeMDbs4tNFvU5TI= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592570972; 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=96hMC23mxW1jCr+hp8tB75gkoduv3Qt8PpigaoBYJC0=; b=Ibf4Z2ZPH0SIPCneq22lPrAVithGmg7/nAqkdMYfy3jLPtHGcY4ljMmU5wAgosHUSvkfkamcRN8qGkIvrkUv7nLSdadoyBCCeG+cLK7qNe/BKK1ulEzDn1WXLq+Xc4+Y8KJPqsgKZqbuBnSwldm9+1TO10exaB5Z5ESGpaQvdwM= 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 1592570972295533.9333312993933; Fri, 19 Jun 2020 05:49:32 -0700 (PDT) Received: from localhost ([::1]:49018 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmGSY-0000O3-Rc for importer@patchew.org; Fri, 19 Jun 2020 08:49:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37238) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmGQw-0007Cr-NH for qemu-devel@nongnu.org; Fri, 19 Jun 2020 08:47:50 -0400 Received: from mail-eopbgr130117.outbound.protection.outlook.com ([40.107.13.117]:41591 helo=EUR01-HE1-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 1jmGQu-0006QN-E3 for qemu-devel@nongnu.org; Fri, 19 Jun 2020 08:47:50 -0400 Received: from AM6PR03MB5233.eurprd03.prod.outlook.com (2603:10a6:20b:d1::19) by AM6PR03MB5094.eurprd03.prod.outlook.com (2603:10a6:20b:80::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.23; Fri, 19 Jun 2020 12:47:42 +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.3109.023; Fri, 19 Jun 2020 12:47:41 +0000 Received: from bozuta-ubuntu-18.syrmia.com (46.240.135.226) by ZRAP278CA0018.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:10::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22 via Frontend Transport; Fri, 19 Jun 2020 12:47:41 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hxdbvGhAzPBHyZUQ6ZT8I2p75RUlz/0zJWnKW1e/r9VbDIGKRu5Pwcbv/0vuh1ixR0EBnTy2ZDWt3Mem3vJYacfqnjfdFvI0JpxHCoIAnKve0KO+mNZazeeQ6PW1F49o0jMVyxoC+svUrtHuuIP8+9BPugFbIMrYwemmX9jdqgAaVFh2pIFn3xI+PlpArmKo3j1xxKqgz1kzPf8RLcQgPqau0nWdu8XtIwpwaES53RKpJkneGuoyBNh7yszD2pvEFsf6KWvQIwO2ROH2mwz6ChiorPFhxy+o4Pcr4NqV8WZH499s9WN7oRWl8BT22NuQcPpGKejiAWhKAf80lAxzZA== 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=96hMC23mxW1jCr+hp8tB75gkoduv3Qt8PpigaoBYJC0=; b=Q7HhC4XWEA811aWPqE2BCPv6qy1som/1QVR4pM+LFV3GKrrMSaHgsTQxDlzJZ8fGaMRhSBDlVLMZiimEvoM6aKb0PG08raVjBMBFqCIZsfxnpogUuBIpE5LIERnZaoG3c5BBcYgj89RTw+ijNlu4wnUelJAVhYFXjH/yrZdjh1p+ktBGOHyuWQ4OTK4We4MTMe6CeO6mmW9IEsZlCpQFLlZxnX6T71NxvRf65cTMphZ4U0u5bs6r51uAob7frKVHrfQOAJ1Dbjz1SHLgmDjRJcVPUX4f/J0cjhVxShw2quxW4RN3SfAl7sq1ixuMzxarjxm6z4zPOGjIhprCOG3azA== 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=96hMC23mxW1jCr+hp8tB75gkoduv3Qt8PpigaoBYJC0=; b=zDuNDSyt6mJyYohHOsCSSAorIYAovRWjn+vpH169ZosUrZpmLXgr21sab30JVKWliNRdDd8UuEC30r+6XFGwe89KSsWrLx51XOuW3FtP+W62AF/mkpKICCaQFvTgxxmwOz2C/6MHrDDWZHyZjGL38PRanLsDmncFcRWZLfFya4c= 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 v3 2/2] linux-user: Add strace support for printing arguments of ioctl() Date: Fri, 19 Jun 2020 14:47:27 +0200 Message-Id: <20200619124727.18080-3-filip.bozuta@syrmia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200619124727.18080-1-filip.bozuta@syrmia.com> References: <20200619124727.18080-1-filip.bozuta@syrmia.com> X-ClientProxiedBy: ZRAP278CA0018.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:10::28) 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: 10a30403-068e-4c3b-3f0f-08d8144ef4a5 X-MS-TrafficTypeDiagnostic: AM6PR03MB5094: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:660; X-Forefront-PRVS: 0439571D1D X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3Sy+vUYvz9Tt5WncVAFvLiEeVyamnbIXB1LT3ZHt9sgALhuQMY30LCRZDzn9nKJXizcza2HAwruZtEbNVT1UHBe9r1C9diCPe9hZZYItmyGNSfECd01+K/LHcwP0T0zYfLNWE/M9eF8/90NqxNG5mAGmLsI3YQYN7pIgCKTSdpjJm2EbTj5nBSeBs/ofmP/mkJ0FzEN3FuXG4glAmTXezTSd3dSH+TiRhBVomdAiiTfE6hZHSZLe4+w2VYqvIGNVgs2i/RF/sROn/0he11H3I0a+PHnA+PhNaa3cg88zWoudwy2gCcmZG95dDkrbeNQxXdXHJMSU0ZL3P8rNKAbRgA== 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:(376002)(346002)(136003)(366004)(396003)(39830400003)(8676002)(36756003)(8936002)(5660300002)(83380400001)(186003)(16526019)(30864003)(1076003)(86362001)(66556008)(6916009)(44832011)(2906002)(4326008)(6666004)(316002)(956004)(508600001)(6486002)(52116002)(66946007)(7696005)(26005)(2616005)(66476007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: +f6HoxTdRbbXGw+AVvzh0QF/TjCetRs4B4vk2kSwRZyJquI+G7HFtIRGchlBSu8kZ5pG6IN8t2IEcKJnh1jIekayWOUQsWUxvzxUrxMslH6gRmcy1Df3mIS7JyrBQECx3gEi5bnlCGLU4MME/MVA5i+lSrt9TVX9OIYdf5SvywmtJRFzPjyx4t1PlnSVDEJCp7ucHWy3syWU33Gtx6MjZ7r36ZzsTrgPwQKemJ9mPCseQwqGhkwD3BlQSxATnFWE3WsZupygQeWln6pP7+zbK7mxMXX/ogdRTaIaJszuEJgIDhBCJqGpEqQlijppUyFi64aFMJsJfIzEoi8n4b1y5CrKDPHglzgkvGIR9UFWlerKlpoUKas0VWNgW+NKPg+vSZtdKOs97KeJYo9nQQMskWnZWn7IU08fhfwsa/Mj0Mzh4mup3Sls+yFm1QtEBg/ZodGS3TqS+yyUKv9KOOMw+bq6SSdRPkmcfc9AP9YJ/sI= X-OriginatorOrg: syrmia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 10a30403-068e-4c3b-3f0f-08d8144ef4a5 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jun 2020 12:47:41.9039 (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: X3dpV2FqhK0zI3WEAvxF5RlrX/THAm/+tWkH/8y2Wzung1iEBZ5UhaluDjsxscoZauPsbJO38A6jt0ewxwQPvg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR03MB5094 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.13.117; envelope-from=Filip.Bozuta@syrmia.com; helo=EUR01-HE1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/19 08:47:41 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -37 X-Spam_score: -3.8 X-Spam_bar: --- X-Spam_report: (-3.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=-1, 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: riku.voipio@iki.fi, 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 functionality for strace argument printing for ioctls. When running ioctls through qemu with "-strace", they get printed in format: "ioctl(fd_num,0x*,0x*) =3D ret_value" where the request code an the ioctl's third argument get printed in a hexad= icemal format. This patch changes that by enabling strace to print both the reques= t code name and the contents of the third argument. For example, when running ioctl RTC_SET_TIME with "-strace", with changes from this patch, it gets printed = in this way: "ioctl(3,RTC_SET_TIME,{12,13,15,20,10,119,0,0,0}) =3D 0" In case of IOC_R type ioctls, the contents of the third argument get printed after the return value, and the argument inside the ioctl call gets printed as pointer in hexadecimal format. For example, when running RTC_RD_TIME with "-strace", with changes from this patch, it gets printed in this way: "ioctl(3,RTC_RD_TIME,0x40800374) =3D 0 ({22,9,13,11,5,120,0,0,0})" In case of IOC_RW type ioctls, the contents of the third argument get print= ed both inside the ioctl call and after the return value. Implementation notes: Functions "print_ioctl()" and "print_syscall_ret_ioctl()", that are def= ined in "strace.c", are listed in file "strace.list" as "call" and "result" value for ioctl. Structure definition "IOCTLEntry" as well as predefined values for IOC_R, IOC_W and IOC_RW were cut and pasted from file "sysca= ll.c" to file "qemu.h" so that they can be used by these functions to print t= he contents of the third ioctl argument. Also, the "static" identifier for= array "ioctl_entries[]" was removed and this array was declared as "extern" i= n "qemu.h" so that it can also be used by these functions. To decode the structure= type of the ioctl third argument, function "thunk_print()" was defined in fi= le "thunk.c" and its definition is somewhat simillar to that of function "thunk_convert()". Signed-off-by: Filip Bozuta Reviewed-by: Laurent Vivier --- include/exec/user/thunk.h | 1 + linux-user/qemu.h | 20 +++++ linux-user/strace.c | 107 ++++++++++++++++++++++++++ linux-user/strace.list | 3 +- linux-user/syscall.c | 20 +---- thunk.c | 154 ++++++++++++++++++++++++++++++++++++++ 6 files changed, 285 insertions(+), 20 deletions(-) diff --git a/include/exec/user/thunk.h b/include/exec/user/thunk.h index eae2c27f99..7992475c9f 100644 --- a/include/exec/user/thunk.h +++ b/include/exec/user/thunk.h @@ -73,6 +73,7 @@ void thunk_register_struct_direct(int id, const char *nam= e, const StructEntry *se1); const argtype *thunk_convert(void *dst, const void *src, const argtype *type_ptr, int to_host); +const argtype *thunk_print(void *arg, const argtype *type_ptr); =20 extern StructEntry *struct_entries; =20 diff --git a/linux-user/qemu.h b/linux-user/qemu.h index be67391ba4..5c964389c1 100644 --- a/linux-user/qemu.h +++ b/linux-user/qemu.h @@ -184,6 +184,26 @@ struct linux_binprm { int (*core_dump)(int, const CPUArchState *); /* coredump routine */ }; =20 +typedef struct IOCTLEntry IOCTLEntry; + +typedef abi_long do_ioctl_fn(const IOCTLEntry *ie, uint8_t *buf_temp, + int fd, int cmd, abi_long arg); + +struct IOCTLEntry { + int target_cmd; + unsigned int host_cmd; + const char *name; + int access; + do_ioctl_fn *do_ioctl; + const argtype arg_type[5]; +}; + +extern IOCTLEntry ioctl_entries[]; + +#define IOC_R 0x0001 +#define IOC_W 0x0002 +#define IOC_RW (IOC_R | IOC_W) + void do_init_thread(struct target_pt_regs *regs, struct image_info *infop); abi_ulong loader_build_argptr(int envc, int argc, abi_ulong sp, abi_ulong stringp, int push_ptr); diff --git a/linux-user/strace.c b/linux-user/strace.c index 6044c66954..6671711e7b 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -866,6 +866,44 @@ print_syscall_ret_listxattr(const struct syscallname *= name, abi_long ret, #define print_syscall_ret_flistxattr print_syscall_ret_listxattr #endif =20 +#ifdef TARGET_NR_ioctl +static void +print_syscall_ret_ioctl(const struct syscallname *name, abi_long ret, + abi_long arg0, abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, abi_long arg5) +{ + print_syscall_err(ret); + + if (ret >=3D 0) { + qemu_log(TARGET_ABI_FMT_ld, ret); + + const IOCTLEntry *ie; + const argtype *arg_type; + void *argptr; + int target_size; + + for (ie =3D ioctl_entries; ie->target_cmd !=3D 0; ie++) { + if (ie->target_cmd =3D=3D arg1) { + break; + } + } + + if (ie->target_cmd =3D=3D arg1 && + (ie->access =3D=3D IOC_R || ie->access =3D=3D IOC_RW)) { + arg_type =3D ie->arg_type; + qemu_log(" ("); + arg_type++; + target_size =3D thunk_type_size(arg_type, 0); + argptr =3D lock_user(VERIFY_READ, arg2, target_size, 1); + thunk_print(argptr, arg_type); + unlock_user(argptr, arg2, target_size); + qemu_log(")"); + } + } + qemu_log("\n"); +} +#endif + UNUSED static struct flags access_flags[] =3D { FLAG_GENERIC(F_OK), FLAG_GENERIC(R_OK), @@ -3032,6 +3070,75 @@ print_statx(const struct syscallname *name, } #endif =20 +#ifdef TARGET_NR_ioctl +static void +print_ioctl(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); + + const IOCTLEntry *ie; + const argtype *arg_type; + void *argptr; + int target_size; + + for (ie =3D ioctl_entries; ie->target_cmd !=3D 0; ie++) { + if (ie->target_cmd =3D=3D arg1) { + break; + } + } + + if (ie->target_cmd =3D=3D 0) { + print_raw_param("%#x", arg1, 0); + print_raw_param("%#x", arg2, 1); + } else { + qemu_log("%s", ie->name); + arg_type =3D ie->arg_type; + + if (arg_type[0] !=3D TYPE_NULL) { + qemu_log(","); + + switch (arg_type[0]) { + case TYPE_PTRVOID: + print_pointer(arg2, 1); + break; + case TYPE_CHAR: + case TYPE_SHORT: + case TYPE_INT: + print_raw_param("%d", arg2, 1); + break; + case TYPE_LONG: + print_raw_param(TARGET_ABI_FMT_ld, arg2, 1); + break; + case TYPE_ULONG: + print_raw_param(TARGET_ABI_FMT_lu, arg2, 1); + break; + case TYPE_PTR: + switch (ie->access) { + case IOC_R: + print_pointer(arg2, 1); + break; + case IOC_W: + case IOC_RW: + arg_type++; + target_size =3D thunk_type_size(arg_type, 0); + argptr =3D lock_user(VERIFY_READ, arg2, target_size, 1= ); + thunk_print(argptr, arg_type); + unlock_user(argptr, arg2, target_size); + break; + } + break; + default: + g_assert_not_reached(); + } + } + } + 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 10e3e4a814..2dd2c9df42 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -433,7 +433,8 @@ { TARGET_NR_io_cancel, "io_cancel" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_ioctl -{ TARGET_NR_ioctl, "ioctl" , "%s(%d,%#x,%#x)", NULL, NULL }, +{ TARGET_NR_ioctl, "ioctl" , NULL, print_ioctl, + print_syscall_ret_ioctl}, #endif #ifdef TARGET_NR_io_destroy { TARGET_NR_io_destroy, "io_destroy" , NULL, NULL, NULL }, diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 7cc5a65b4f..007febed08 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -4478,24 +4478,6 @@ STRUCT_MAX #undef STRUCT #undef STRUCT_SPECIAL =20 -typedef struct IOCTLEntry IOCTLEntry; - -typedef abi_long do_ioctl_fn(const IOCTLEntry *ie, uint8_t *buf_temp, - int fd, int cmd, abi_long arg); - -struct IOCTLEntry { - int target_cmd; - unsigned int host_cmd; - const char *name; - int access; - do_ioctl_fn *do_ioctl; - const argtype arg_type[5]; -}; - -#define IOC_R 0x0001 -#define IOC_W 0x0002 -#define IOC_RW (IOC_R | IOC_W) - #define MAX_STRUCT_SIZE 4096 =20 #ifdef CONFIG_FIEMAP @@ -5276,7 +5258,7 @@ static abi_long do_ioctl_tiocgptpeer(const IOCTLEntry= *ie, uint8_t *buf_temp, } #endif =20 -static IOCTLEntry ioctl_entries[] =3D { +IOCTLEntry ioctl_entries[] =3D { #define IOCTL(cmd, access, ...) \ { TARGET_ ## cmd, cmd, #cmd, access, 0, { __VA_ARGS__ } }, #define IOCTL_SPECIAL(cmd, access, dofn, ...) \ diff --git a/thunk.c b/thunk.c index 7f31cffe09..992a19b1c9 100644 --- a/thunk.c +++ b/thunk.c @@ -271,6 +271,160 @@ const argtype *thunk_convert(void *dst, const void *s= rc, return type_ptr; } =20 +const argtype *thunk_print(void *arg, const argtype *type_ptr) +{ + int type; + + type =3D *type_ptr++; + + switch (type) { + case TYPE_CHAR: + qemu_log("%c", *(uint8_t *)arg); + break; + case TYPE_SHORT: + qemu_log("%" PRId16, tswap16(*(uint16_t *)arg)); + break; + case TYPE_INT: + qemu_log("%" PRId32, tswap32(*(uint32_t *)arg)); + break; + case TYPE_LONGLONG: + qemu_log("%" PRId64, tswap64(*(uint64_t *)arg)); + break; + case TYPE_ULONGLONG: + qemu_log("%" PRIu64, tswap64(*(uint64_t *)arg)); + break; +#if HOST_LONG_BITS =3D=3D 32 && TARGET_ABI_BITS =3D=3D 32 + case TYPE_PTRVOID: + qemu_log("0x%" PRIx32, tswap32(*(uint32_t *)arg)); + break; + case TYPE_LONG: + qemu_log("%" PRId32, tswap32(*(uint32_t *)arg)); + break; + case TYPE_ULONG: + qemu_log("%" PRIu32, tswap32(*(uint32_t *))arg); + break; +#elif HOST_LONG_BITS =3D=3D 64 && TARGET_ABI_BITS =3D=3D 32 + case TYPE_PTRVOID: + qemu_log("0x%" PRIx32, tswap32(*(uint64_t *)arg & 0xffffffff)); + break; + case TYPE_LONG: + qemu_log("%" PRId32, tswap32(*(uint64_t *)arg & 0xffffffff)); + break; + case TYPE_ULONG: + qemu_log("%" PRIu32, tswap32(*(uint64_t *)arg & 0xffffffff)); + break; +#elif HOST_LONG_BITS =3D=3D 64 && TARGET_ABI_BITS =3D=3D 64 + case TYPE_PTRVOID: + qemu_log("0x%" PRIx64, tswap64(*(uint64_t *)arg)); + break; + case TYPE_LONG: + qemu_log("%" PRId64, tswap64(*(uint64_t *)arg)); + break; + case TYPE_ULONG: + qemu_log("%" PRIu64, tswap64(*(uint64_t *)arg)); + break; +#else + case TYPE_PTRVOID: + qemu_log("0x%" PRIx64, tswap64(*(uint64_t *)arg)); + break; + case TYPE_LONG: + qemu_log("%" PRId64, tswap64(*(uint64_t *)arg)); + break; + case TYPE_ULONG: + qemu_log("%" PRIu64, tswap64(*(uint64_t *)arg)); + break; +#endif + case TYPE_OLDDEVT: + { + uint64_t val =3D 0; + switch (thunk_type_size(type_ptr - 1, 1)) { + case 2: + val =3D *(uint16_t *)arg; + break; + case 4: + val =3D *(uint32_t *)arg; + break; + case 8: + val =3D *(uint64_t *)arg; + break; + } + switch (thunk_type_size(type_ptr - 1, 0)) { + case 2: + qemu_log("%" PRIu16, tswap16(val)); + break; + case 4: + qemu_log("%" PRIu32, tswap32(val)); + break; + case 8: + qemu_log("%" PRIu64, tswap64(val)); + break; + } + } + break; + case TYPE_ARRAY: + { + int i, array_length, arg_size; + uint8_t *a; + int is_string =3D 0; + + array_length =3D *type_ptr++; + arg_size =3D thunk_type_size(type_ptr, 0); + a =3D arg; + + if (*type_ptr =3D=3D TYPE_CHAR) { + qemu_log("\""); + is_string =3D 1; + } else { + qemu_log("["); + } + + for (i =3D 0; i < array_length; i++) { + if (i > 0 && !is_string) { + qemu_log(","); + } + thunk_print(a, type_ptr); + a +=3D arg_size; + } + + if (is_string) { + qemu_log("\""); + } else { + qemu_log("]"); + } + + type_ptr =3D thunk_type_next(type_ptr); + } + break; + case TYPE_STRUCT: + { + int i; + const StructEntry *se; + uint8_t *a; + const argtype *field_types; + const int *arg_offsets; + + se =3D struct_entries + *type_ptr++; + a =3D arg; + + field_types =3D se->field_types; + arg_offsets =3D se->field_offsets[0]; + + qemu_log("{"); + for (i =3D 0; i < se->nb_fields; i++) { + if (i > 0) { + qemu_log(","); + } + field_types =3D thunk_print(a + arg_offsets[i], field_type= s); + } + qemu_log("}"); + } + break; + default: + g_assert_not_reached(); + } + return type_ptr; +} + /* from em86 */ =20 /* Utility function: Table-driven functions to translate bitmasks --=20 2.17.1