From patchwork Thu Aug 27 19:20:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 11741435 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A67E214E5 for ; Thu, 27 Aug 2020 19:21:20 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7C269207CD for ; Thu, 27 Aug 2020 19:21:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7C269207CD Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=vivier.eu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:59374 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kBNSZ-0005CX-LK for patchwork-qemu-devel@patchwork.kernel.org; Thu, 27 Aug 2020 15:21:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33292) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kBNRp-0003hm-4q for qemu-devel@nongnu.org; Thu, 27 Aug 2020 15:20:33 -0400 Received: from mout.kundenserver.de ([217.72.192.73]:60077) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kBNRn-000092-5A for qemu-devel@nongnu.org; Thu, 27 Aug 2020 15:20:32 -0400 Received: from localhost.localdomain ([82.252.135.186]) by mrelayeu.kundenserver.de (mreue109 [212.227.15.183]) with ESMTPSA (Nemesis) id 1Mt6x5-1kRGV71Vt3-00tPp9; Thu, 27 Aug 2020 21:20:24 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 01/18] linux-user: Fix 'semop()' and 'semtimedop()' implementation Date: Thu, 27 Aug 2020 21:20:01 +0200 Message-Id: <20200827192018.2442099-2-laurent@vivier.eu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200827192018.2442099-1-laurent@vivier.eu> References: <20200827192018.2442099-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:/HRRcOuhczjHgzZbLLSklhEjqNLzfAOG9DXUgU8oxc+rjK0Fgdt gmqY5YLLNGV6RBc0VnaXdJ/1UGoFkovVqhPmoWWDWOcwWBrMaqLnifRHgnrJmQ2RNKGBc1E gDfV+2Acn6717S80KHd161upAQMhdV/2f3V5YErHrCrfNuZu5tFnkU/vcF/az3+k5O9ttKV Q4LHmYN1Dk4FsjN0bykwg== X-UI-Out-Filterresults: notjunk:1;V03:K0:WuFA+C8fl50=:f5wmrMsMqROf4Q2A+XGEL1 BLGE75OL4ZiYRbvwH5r/74OkIgaUB8DN+DcjUZyIkES0IqA9HaGTix+WCVIXrl9UdQedn6fUY T25TRqp8hwQuIxHKR+/3DjbTJpCT1Vz6UWfJLUPphKF2t2wiMafgJ02rigcB4Oy/7uEGmT2W8 NMJb6tBwIEofzqJnBrgVi/NLd4BTH+bXr+OVCaC5pHOPzx3c5l1DeTtmI3L4xJKSAuhPhHwyA j+sKHzhTzRJ3R3IWQUV9xwJhWa/pMP3hwiNDHt5IUqjmLWXMjmtQLOa6dFm2uQBTATyNoTnGc anruVWDV+leR2PZNtW8XmcNpKwruk/Vlv0d/qHA4pQdv1Kirtr44xDFbYIAj5NuXjdizWO3li oMz7fxw8nCNNtrAOTPWEk6XTv3z22CRG8m/JFnR7HerxHD4+rSnCVSbcKmus9585sP9+b3ixW F1ygaR4W4aHUNmg3QdvQzawkuAMafTDSmsETZLTNe47Yx74bb5dNUmvxtYW/aPXQPl+lC2SdV KY5tDevQp36eKuvqzNT3ia4nIhd0St0FYUQHkP9CRcbiTNAZKGr2OFSH7KDHUR9/np7XLEwV+ D7R2EV2Ebew1EO+GwZ6veYCu7kF/xJ5XgLLtdgIViqO1POmA+0zzyQ85PF90brqyNrAITt8nA 23+oQgFVjohpNrbPDhml4sItALu0C5dXEKgDYCYvWRaffiKtnccoRMWZ41CzQgyCOnU+hOzkN RMvKLrJr9A5UQhiXQiePJhdhI+8cgWWIIuNv10eTbjB0OkQ/0OGLMG8RGdQpFXkobQXuNXrsI ibH8fKwASoG3d4Yi6YKVbCr9opdnbQiBvUjyfoYnfUsGgIx5wWUnV8XMRqL185kjMxBmHTk Received-SPF: none client-ip=217.72.192.73; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/27 15:20:29 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] 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, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Riku Voipio , Laurent Vivier , Filip Bozuta Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Filip Bozuta The implementations of syscalls 'semop()' and 'semtimedop()' in file 'syscall.c' use function 'target_to_host_sembuf()' to convert values of 'struct sembuf' from host to target. However, before this conversion it should be check whether the number of semaphore operations 'nsops' is not bigger than maximum allowed semaphor operations per syscall: 'SEMOPM'. In these cases, errno 'E2BIG' ("Arg list too long") should be set. But the implementation will set errno 'EFAULT' ("Bad address") in this case since the conversion from target to host in this case fails. This was confirmed with the LTP test for 'semop()' ('ipc/semop/semop02') in test case where 'nsops' is greater than SEMOPM with unaproppriate errno EFAULT: semop02.c:130: FAIL: semop failed unexpectedly; expected: E2BIG: EFAULT (14) This patch changes this by adding a check whether 'nsops' is bigger than 'SEMOPM' before the conversion function 'target_to_host_sembuf()' is called. After the changes from this patch, the test works fine along with the other LTP testcases for 'semop()'): semop02.c:126: PASS: semop failed as expected: E2BIG (7) Implementation notes: A target value ('TARGET_SEMOPM') was added for 'SEMOPM' as to be sure in case the value is not available for some targets. Signed-off-by: Filip Bozuta Reviewed-by: Laurent Vivier Message-Id: <20200818180722.45089-1-Filip.Bozuta@syrmia.com> Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 13 +++++++++++-- linux-user/syscall_defs.h | 2 ++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index b4a7b605f3d4..5b3fce3dc0cb 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -3901,7 +3901,7 @@ static inline abi_long do_semtimedop(int semid, unsigned nsops, abi_long timeout) { - struct sembuf sops[nsops]; + struct sembuf *sops; struct timespec ts, *pts = NULL; abi_long ret; @@ -3912,8 +3912,16 @@ static inline abi_long do_semtimedop(int semid, } } - if (target_to_host_sembuf(sops, ptr, nsops)) + if (nsops > TARGET_SEMOPM) { + return -TARGET_E2BIG; + } + + sops = g_new(struct sembuf, nsops); + + if (target_to_host_sembuf(sops, ptr, nsops)) { + g_free(sops); return -TARGET_EFAULT; + } ret = -TARGET_ENOSYS; #ifdef __NR_semtimedop @@ -3925,6 +3933,7 @@ static inline abi_long do_semtimedop(int semid, SEMTIMEDOP_IPC_ARGS(nsops, sops, (long)pts))); } #endif + g_free(sops); return ret; } #endif diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index 427a25f5bce5..9aa3bd724f0c 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -46,6 +46,8 @@ #define IPCOP_shmget 23 #define IPCOP_shmctl 24 +#define TARGET_SEMOPM 500 + /* * The following is for compatibility across the various Linux * platforms. The i386 ioctl numbering scheme doesn't really enforce From patchwork Thu Aug 27 19:20:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 11741437 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EB74A14E5 for ; Thu, 27 Aug 2020 19:21:24 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C9615207CD for ; Thu, 27 Aug 2020 19:21:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C9615207CD Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=vivier.eu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:59936 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kBNSd-0005QE-VP for patchwork-qemu-devel@patchwork.kernel.org; Thu, 27 Aug 2020 15:21:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33364) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kBNRt-0003nM-NO for qemu-devel@nongnu.org; Thu, 27 Aug 2020 15:20:37 -0400 Received: from mout.kundenserver.de ([212.227.17.24]:56107) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kBNRr-00009i-Ht for qemu-devel@nongnu.org; Thu, 27 Aug 2020 15:20:37 -0400 Received: from localhost.localdomain ([82.252.135.186]) by mrelayeu.kundenserver.de (mreue109 [212.227.15.183]) with ESMTPSA (Nemesis) id 1M1HmG-1k9jYB3AWw-002p4O; Thu, 27 Aug 2020 21:20:25 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 02/18] linux-user: Fix 'clock_nanosleep()' implementation Date: Thu, 27 Aug 2020 21:20:02 +0200 Message-Id: <20200827192018.2442099-3-laurent@vivier.eu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200827192018.2442099-1-laurent@vivier.eu> References: <20200827192018.2442099-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:gVJJqO4UfM0NVrnQSTRoplZEqH3X65aSH2sPjICx5FnPh3l4m/k kdqU7ChqTDqXPYvZ2yeZI3/TLc9afqKp8pmpJ8aWQNyKoHbvXpeOmdN7t6ARbnUkN9Is2vg 6JclEb0CXIP7mF37xtlcIMkJ851erhVgT6DWDPmVGjAWfF7l0kitCYoLoIrZ9zw8qtgcZ9i rSAnIdA+VIbfYoZMaYRdw== X-UI-Out-Filterresults: notjunk:1;V03:K0:KI4mpl7U7vU=:QBTjR1DmnMbkPyb2rwAT5I TeJw0mefJw5m2K2ykXw1x62Y/n5d0jR5F9lhItWgrF/gUFpn+gmRcBI8Z6gfGl7ZVNhVAiUjM ch6V3THqngqOqCMUGGHxMBnWsCVgqfe7+Y+mMrh0t94Q2A7ioDdx/TX5JRRjQ5gR7rnsG+EhU /L+tBpg6/MV+L96hC0F+LBCaR3kMFdjfueq71baeNqs50Wsvv5uSMJBILt//cpDOZXfPcPvoV XF2r7Mtkl9p4rajNXoQQaLITn4QRscs5gNPTuWZfzNBEMs6+kP2/Tiyuw1V7qEo0kqD1e5HEK VU+N7gbwCHxIn3G1Lcyh870t7Az5h3TYcLu5M8ritDXOa0arKkDoYktb2bOmPhc0uZ/NDRWD3 UQVWGHmweRnPM2RtsdApSDzJRZxrlFv/KFhLOpoI2j/mFm1QrKI9hM0XJ+UgO23x3Az8p1zdP a8jxtT2e3QGzivD4mGLl9LjfkdKGUZCFoxXJVkv3VTvR17if4r/N1uI6kdpeMBXK8FPAoT2EN qOYxL4KhD/U+ZRgoxj1cxr9oFodLe3MP5gxGJHSxE96511RxGBb3QLs7QaYIb4YKhTb0YTov5 JDDZMpsOlL/1YKWwOZeu0oyvbDYwpFdVbs2euXaKic1SzKwKmcECK5kyEv3lST4OWjG/bOWqf WSNgNJO0mgQo8FYLwh3ICA6LjwcKrx7zBK6M9b0fpxX2WlF8UfjAAoe8wBR0xgfXRTP+tUKZj SgApOujeUPU6eXY6RX4WqmaHRhLlk6Qiet7fEO2lVllVHChYAo4asCp9lWHZiLSfH9U9FpBO8 Tk1byBLZlWpgyx8Wswlk2WfpYHKLnA38gr78+O6xH9vcSP4t3q7EcTZN2ZGiw90p4pAxHSU Received-SPF: none client-ip=212.227.17.24; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/27 15:20:34 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] 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, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Riku Voipio , Laurent Vivier , Filip Bozuta Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Filip Bozuta Implementation of syscall 'clock_nanosleep()' in 'syscall.c' uses functions 'target_to_host_timespec()' and 'host_to_target_timespec()' to transfer the value of 'struct timespec' between target and host. However, the implementation doesn't check whether this conversion succeeds and thus can return an unaproppriate error instead of 'EFAULT' that is expected. This was confirmed with the modified LTP test suite where testcases with bad 'struct timespec' adress for 'clock_nanosleep()' were added. This modified LTP suite can be found at: https://github.com/bozutaf/ltp (Patch with this new test case will be sent to LTP mailing list soon) Signed-off-by: Filip Bozuta Reviewed-by: Laurent Vivier Message-Id: <20200727201326.401519-1-Filip.Bozuta@syrmia.com> Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 5b3fce3dc0cb..e387246d7196 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -11875,7 +11875,9 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, case TARGET_NR_clock_nanosleep: { struct timespec ts; - target_to_host_timespec(&ts, arg3); + if (target_to_host_timespec(&ts, arg3)) { + return -TARGET_EFAULT; + } ret = get_errno(safe_clock_nanosleep(arg1, arg2, &ts, arg4 ? &ts : NULL)); /* @@ -11883,8 +11885,9 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, * with error -TARGET_EINTR and if arg4 is not NULL and arg2 is not * TIMER_ABSTIME, it returns the remaining unslept time in arg4. */ - if (ret == -TARGET_EINTR && arg4 && arg2 != TIMER_ABSTIME) { - host_to_target_timespec(arg4, &ts); + if (ret == -TARGET_EINTR && arg4 && arg2 != TIMER_ABSTIME && + host_to_target_timespec(arg4, &ts)) { + return -TARGET_EFAULT; } return ret; From patchwork Thu Aug 27 19:20:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 11741455 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A53F714E5 for ; Thu, 27 Aug 2020 19:23:15 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 866C6207CD for ; Thu, 27 Aug 2020 19:23:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 866C6207CD Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=vivier.eu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:39984 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kBNUQ-0000X7-Qb for patchwork-qemu-devel@patchwork.kernel.org; Thu, 27 Aug 2020 15:23:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33408) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kBNRv-0003qf-MR for qemu-devel@nongnu.org; Thu, 27 Aug 2020 15:20:39 -0400 Received: from mout.kundenserver.de ([217.72.192.75]:56617) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kBNRt-0000A9-Q8 for qemu-devel@nongnu.org; Thu, 27 Aug 2020 15:20:39 -0400 Received: from localhost.localdomain ([82.252.135.186]) by mrelayeu.kundenserver.de (mreue109 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MSbp1-1k0lN72dir-00SumF; Thu, 27 Aug 2020 21:20:28 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 03/18] linux-user: syscall: ioctls: support DRM_IOCTL_I915_GETPARAM Date: Thu, 27 Aug 2020 21:20:03 +0200 Message-Id: <20200827192018.2442099-4-laurent@vivier.eu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200827192018.2442099-1-laurent@vivier.eu> References: <20200827192018.2442099-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:MXn0zVzwswKtcIarZsDaSOLtnC8aow9SWx4mBc5EyTfuO+ALaqa 13cd+SlYJJemq1+Ea1H1feBZ17vwccj++5yIRuL7oyxNbMgCRnD2hLEu81nCnyh53gneCKN dwlPU1fL9s+2BK9JaCbQ2W7vr+GD9touPtTp6nkT+pWtbhKVFgXOMQGUbdUuk5fWnLSR0g7 wk3enMTlTp7/8napEaL3w== X-UI-Out-Filterresults: notjunk:1;V03:K0:ezbO9ETbV40=:wuJoyiAXLNRNU07JUOr12i y4URvqmRtzytEShS58gUCQWrso5H4ebKNyQF5BnRMs+zewTCYujhiyJ6/kmVfsOxRsmJ6AySm CEY2hVJFizczdhEnk4nDjoAmG7AY/peO5HCEEGXc1BTsT90ukBI/k0l6JzztMigVQJfOJhko8 CNib7qYA5UDZLF09TYnPwc1OEjTKKgjyN2JGi78icqT5RoyFxdeE9pe9pJNoWaQWxq3QkJ+Y9 w+lIRSK5RUMqV9eLMCf7LIb1L8HjLB2L9BnCOjedgfUbKouPCwYDmBOfleunexKF5sz02xOqB 6Hc0nokKNkNso8Ya2e58s3gi1uDm+0dTffUPFHw4er74UJjnrEDRwWSIScdL6+OFIglCWfLUV VgHQhC0izHRpWtvDOVKongmVk1XUED+F8GNKBQIdTYwCT4NuSXx8X+CNF4pGIjr6RdRFFBwcm I60pzYm6vGsjPqDpllorYw5DOjBFAW4BDPMdp1cNPEBwNkmcfAEioj8qSkihzVM02vZgOTr9i ZaQhZNlErC/1rSfSUGyACvu4yxjwiBsDY8nT7710XKmMgt5qR7B3yMYdl5ARAPeA0cYvq9roh N8s5jEXC58W2jlR1JqWy46mhDIwmv89E5ucxb7/hZIC/ErOrh2AXKp89vIfxudyIGT2isF+tz KYisXr9OqnuO0MwBAslZokugHsehpWojXowiWfluDX3QiIkQNZV8Exl29OEhhm3Pmf+pXcbLy wJWBQuPYdfBGA3in7w1qUFQYB45SMmi9Z8QTNO4/Tbb2I9fvt2dEVYM8rC+E6rLIgwYLFmRGL bk42opoDxjK8hKwj5A2G6DB/oShxk03qhm3f5ngR6gua7sWXbd3zZUDbtFPPmM1CcNZ1VOk Received-SPF: none client-ip=217.72.192.75; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/27 15:20:36 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] 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, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Chen Gang , Riku Voipio , Laurent Vivier Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Chen Gang Another DRM_IOCTL_I915 patches will be sent next. Signed-off-by: Chen Gang Reviewed-by: Laurent Vivier Message-Id: <20200802133938.12055-1-chengang@emindsoft.com.cn> Signed-off-by: Laurent Vivier --- linux-user/ioctls.h | 3 +++ linux-user/syscall.c | 35 +++++++++++++++++++++++++++++++++++ linux-user/syscall_defs.h | 8 ++++++++ linux-user/syscall_types.h | 4 ++++ 4 files changed, 50 insertions(+) diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h index 0713ae131162..e2fc09b5a5ee 100644 --- a/linux-user/ioctls.h +++ b/linux-user/ioctls.h @@ -581,6 +581,9 @@ #ifdef HAVE_DRM_H IOCTL_SPECIAL(DRM_IOCTL_VERSION, IOC_RW, do_ioctl_drm, MK_PTR(MK_STRUCT(STRUCT_drm_version))) + + IOCTL_SPECIAL(DRM_IOCTL_I915_GETPARAM, IOC_RW, do_ioctl_drm_i915, + MK_PTR(MK_STRUCT(STRUCT_drm_i915_getparam))) #endif #ifdef TARGET_TIOCSTART diff --git a/linux-user/syscall.c b/linux-user/syscall.c index e387246d7196..efaa0a7b8365 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -114,6 +114,7 @@ #include #ifdef HAVE_DRM_H #include +#include #endif #include "linux_loop.h" #include "uname.h" @@ -5426,6 +5427,40 @@ static abi_long do_ioctl_drm(const IOCTLEntry *ie, uint8_t *buf_temp, return -TARGET_ENOSYS; } +static abi_long do_ioctl_drm_i915_getparam(const IOCTLEntry *ie, + struct drm_i915_getparam *gparam, + int fd, abi_long arg) +{ + abi_long ret; + int value; + struct target_drm_i915_getparam *target_gparam; + + if (!lock_user_struct(VERIFY_READ, target_gparam, arg, 0)) { + return -TARGET_EFAULT; + } + + __get_user(gparam->param, &target_gparam->param); + gparam->value = &value; + ret = get_errno(safe_ioctl(fd, ie->host_cmd, gparam)); + put_user_s32(value, target_gparam->value); + + unlock_user_struct(target_gparam, arg, 0); + return ret; +} + +static abi_long do_ioctl_drm_i915(const IOCTLEntry *ie, uint8_t *buf_temp, + int fd, int cmd, abi_long arg) +{ + switch (ie->host_cmd) { + case DRM_IOCTL_I915_GETPARAM: + return do_ioctl_drm_i915_getparam(ie, + (struct drm_i915_getparam *)buf_temp, + fd, arg); + default: + return -TARGET_ENOSYS; + } +} + #endif IOCTLEntry ioctl_entries[] = { diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index 9aa3bd724f0c..a6abc7e70be8 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -1177,6 +1177,9 @@ struct target_rtc_pll_info { /* drm ioctls */ #define TARGET_DRM_IOCTL_VERSION TARGET_IOWRU('d', 0x00) +/* drm i915 ioctls */ +#define TARGET_DRM_IOCTL_I915_GETPARAM TARGET_IOWRU('d', 0x46) + /* from asm/termbits.h */ #define TARGET_NCC 8 @@ -2620,6 +2623,11 @@ struct target_drm_version { abi_ulong desc; }; +struct target_drm_i915_getparam { + int param; + abi_ulong value; +}; + #include "socket.h" #include "errno_defs.h" diff --git a/linux-user/syscall_types.h b/linux-user/syscall_types.h index 3f1f0334649b..12bf3484e2bd 100644 --- a/linux-user/syscall_types.h +++ b/linux-user/syscall_types.h @@ -325,6 +325,10 @@ STRUCT(drm_version, TYPE_ULONG, /* desc_len */ TYPE_PTRVOID) /* desc */ +STRUCT(drm_i915_getparam, + TYPE_INT, /* param */ + TYPE_PTRVOID) /* value */ + STRUCT(file_clone_range, TYPE_LONGLONG, /* src_fd */ TYPE_ULONGLONG, /* src_offset */ From patchwork Thu Aug 27 19:20:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 11741461 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 381CF16B1 for ; Thu, 27 Aug 2020 19:24:40 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id ECF79207CD for ; Thu, 27 Aug 2020 19:24:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org ECF79207CD Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=vivier.eu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:48178 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kBNVn-0003qn-60 for patchwork-qemu-devel@patchwork.kernel.org; Thu, 27 Aug 2020 15:24:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33420) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kBNRw-0003ss-Ah for qemu-devel@nongnu.org; Thu, 27 Aug 2020 15:20:40 -0400 Received: from mout.kundenserver.de ([217.72.192.74]:54985) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kBNRr-00009Y-Bq for qemu-devel@nongnu.org; Thu, 27 Aug 2020 15:20:39 -0400 Received: from localhost.localdomain ([82.252.135.186]) by mrelayeu.kundenserver.de (mreue109 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MpDRp-1kxgoM0szX-00qmQD; Thu, 27 Aug 2020 21:20:30 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 04/18] linux-user: Make cpu_env accessible in strace.c Date: Thu, 27 Aug 2020 21:20:04 +0200 Message-Id: <20200827192018.2442099-5-laurent@vivier.eu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200827192018.2442099-1-laurent@vivier.eu> References: <20200827192018.2442099-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:rNsfzhWKFNkQtRLFXcqaw4rdAImCMb3xjtDHrSlicSGjGjI2ZT0 kOP+fhPV8DZR2kVcEXOkYkEi3G2NfCHbj5PHA4BO13s+5KDk6ORzZAf0bKVi+7d56xKdSKQ o94fus2edeq+bCPFhMYLN+I/69OBymj/kaKtroZLn3EM1P3aGKqzpMcqX6lFpv+rufgt6KS xOMAYCBMyPo6fEB5SKA+Q== X-UI-Out-Filterresults: notjunk:1;V03:K0:XXry08dqHAo=:Wr1y9nB1/uYTQHcUdSM6uP 8jcjSP7CCmAISAvfd8x0125JCW28e4cN2FLY1yaIBi1bzUt4132cbJqj+SRuBOHErge4bnzu7 zt5KndrhQUcZHz1wkNdNGs4kK4cNrQTIh68CTL8WdF+TM+sDV+pSZeuY1OTDnusMtro6DvsUl GZJF9IxGa/hdDI5j8GuuIe0XYICJO30ajClPv+XWh2NFxeTjOin7NZ+cIWq5OCj22zm/DxVWa xYhwHzONIaTW/xolyB1jf9ofoEoMAHIgJrULNvL/StxmCcD8ln1CVMmya1SnkbFKslTslstH8 672fBTCwNTC7Csv0hLWAL4FXflsW4yAZli5IAVHHtQJv3sjI5C1JXZMgy+UQbMr+VQA8qQJBP RTsTWzoBuNK+IRm5Vqr7OkAh8NLDcGPFqQcxWcRBdqcK0S842r2jmlOrwKLAHGW6e0H7acZh+ IpnuQrjemGT3c8dlGW0np7j2Tqi5zUkznoUQA6zBJeIxMGQK5rszsjM7hzjMx1pclc3E5JKbr OanjMCqDxXeIpFDKLDZfkx9vU48BTxn4NqxQAd1z8YhNNn1IA7gOt7p5MB1Kz+FFEAIAjUM5w jRPrI1NQupQ5XXuje1FSpbIczKowZu5wLiHmVcvPla5o1IQANCCSY9Mrkbz0AAKYNTbrqAfcj p+QfCagRcMmzWrvhJUpY3mF90xWFHA/+8trFyIbnGlUKWCuAmUcu6UkuP8XRpGnGcX66MOF42 ntDDAMfkPZNiMb+byVlcfNz9H335UuRz2TLE4aVA8wSnk9WyDA4lw0A5Kr+uk8dUtkiVW052h NGoZI8EGabjoCQN+NXQ2AruFOGOGDcdEQPcQnp9FjAFtOU9mf8Qe5Dsv9yYDCb6/BPlbIFQ Received-SPF: none client-ip=217.72.192.74; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/27 15:20:33 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] 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, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Riku Voipio , Laurent Vivier , Filip Bozuta Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Filip Bozuta Variable "cpu_env" is used in file "syscall.c" to store the information about the cpu environment. This variable is used because values of some syscalls can vary between cpu architectures. This patch makes the "cpu_env" accessible in "strace.c" so it can enable aproppriate "-strace" argument printing for these syscalls. This will be a useful addition for future "-strace" implementation in QEMU. Implementation notes: Functions "print_syscall()" and "print_syscall_ret()" which are stated and defined in "qemu.h" and "strace.c" respectively are used to print syscall arguments before and after syscall execution. These functions were changed with addition of a new argument "void *cpu_env". Strucute "struct syscallname" in "strace.c" is used to store the information about syscalls. Fields "call" and "result" represent pointers to functions which are used to print syscall arguments before and after execution. These fields were also changed with addition of a new "void *" argumetn. Also, all defined "print_*" and "print_syscall_ret*" functions in "strace.c" were changed to have the new "void *cpu_env". This was done to not cause build errors (even though none of these functions use this argument). Signed-off-by: Filip Bozuta Reviewed-by: Laurent Vivier Message-Id: <20200811164553.27713-2-Filip.Bozuta@syrmia.com> Signed-off-by: Laurent Vivier --- linux-user/qemu.h | 4 +- linux-user/strace.c | 479 ++++++++++++++++++++++--------------------- linux-user/syscall.c | 5 +- 3 files changed, 247 insertions(+), 241 deletions(-) diff --git a/linux-user/qemu.h b/linux-user/qemu.h index 5c964389c101..63ddfe86fd8b 100644 --- a/linux-user/qemu.h +++ b/linux-user/qemu.h @@ -400,10 +400,10 @@ extern long safe_syscall_base(int *pending, long number, ...); int host_to_target_waitstatus(int status); /* strace.c */ -void print_syscall(int num, +void print_syscall(void *cpu_env, int num, abi_long arg1, abi_long arg2, abi_long arg3, abi_long arg4, abi_long arg5, abi_long arg6); -void print_syscall_ret(int num, abi_long ret, +void print_syscall_ret(void *cpu_env, int num, abi_long ret, abi_long arg1, abi_long arg2, abi_long arg3, abi_long arg4, abi_long arg5, abi_long arg6); /** diff --git a/linux-user/strace.c b/linux-user/strace.c index 5e380486433c..2dcc15496a6a 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -16,10 +16,10 @@ struct syscallname { int nr; const char *name; const char *format; - void (*call)(const struct syscallname *, + void (*call)(void *, const struct syscallname *, abi_long, abi_long, abi_long, abi_long, abi_long, abi_long); - void (*result)(const struct syscallname *, abi_long, + void (*result)(void *, const struct syscallname *, abi_long, abi_long, abi_long, abi_long, abi_long, abi_long, abi_long); }; @@ -638,7 +638,7 @@ print_clockid(int clockid, int last) /* select */ #ifdef TARGET_NR__newselect static void -print_newselect(const struct syscallname *name, +print_newselect(void *cpu_env, const struct syscallname *name, abi_long arg1, abi_long arg2, abi_long arg3, abi_long arg4, abi_long arg5, abi_long arg6) { @@ -656,7 +656,7 @@ print_newselect(const struct syscallname *name, #ifdef TARGET_NR_semctl static void -print_semctl(const struct syscallname *name, +print_semctl(void *cpu_env, const struct syscallname *name, abi_long arg1, abi_long arg2, abi_long arg3, abi_long arg4, abi_long arg5, abi_long arg6) { @@ -668,7 +668,7 @@ print_semctl(const struct syscallname *name, #endif static void -print_execve(const struct syscallname *name, +print_execve(void *cpu_env, const struct syscallname *name, abi_long arg1, abi_long arg2, abi_long arg3, abi_long arg4, abi_long arg5, abi_long arg6) { @@ -701,7 +701,7 @@ print_execve(const struct syscallname *name, #ifdef TARGET_NR_ipc static void -print_ipc(const struct syscallname *name, +print_ipc(void *cpu_env, const struct syscallname *name, abi_long arg1, abi_long arg2, abi_long arg3, abi_long arg4, abi_long arg5, abi_long arg6) { @@ -745,9 +745,10 @@ print_syscall_err(abi_long ret) } static void -print_syscall_ret_addr(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_ret_addr(void *cpu_env, 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) { if (!print_syscall_err(ret)) { qemu_log("0x" TARGET_ABI_FMT_lx, ret); @@ -765,9 +766,10 @@ print_syscall_ret_raw(struct syscallname *name, abi_long ret) #ifdef TARGET_NR__newselect static void -print_syscall_ret_newselect(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_ret_newselect(void *cpu_env, 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) { if (!print_syscall_err(ret)) { qemu_log(" = 0x" TARGET_ABI_FMT_lx " (", ret); @@ -794,9 +796,10 @@ print_syscall_ret_newselect(const struct syscallname *name, abi_long ret, #define TARGET_TIME_ERROR 5 /* clock not synchronized */ #ifdef TARGET_NR_adjtimex static void -print_syscall_ret_adjtimex(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_ret_adjtimex(void *cpu_env, 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) { if (!print_syscall_err(ret)) { qemu_log(TARGET_ABI_FMT_ld, ret); @@ -829,9 +832,10 @@ print_syscall_ret_adjtimex(const struct syscallname *name, abi_long ret, #if defined(TARGET_NR_listxattr) || defined(TARGET_NR_llistxattr) \ || defined(TARGGET_NR_flistxattr) static void -print_syscall_ret_listxattr(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_ret_listxattr(void *cpu_env, 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) { if (!print_syscall_err(ret)) { qemu_log(TARGET_ABI_FMT_ld, ret); @@ -860,9 +864,10 @@ print_syscall_ret_listxattr(const struct syscallname *name, abi_long ret, #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_ret_ioctl(void *cpu_env, 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) { if (!print_syscall_err(ret)) { qemu_log(TARGET_ABI_FMT_ld, ret); @@ -1424,9 +1429,9 @@ print_timezone(abi_ulong tz_addr, int last) #ifdef TARGET_NR_accept static void -print_accept(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) +print_accept(void *cpu_env, 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); @@ -1438,9 +1443,9 @@ print_accept(const struct syscallname *name, #ifdef TARGET_NR_access static void -print_access(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) +print_access(void *cpu_env, 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_string(arg0, 0); @@ -1451,9 +1456,9 @@ print_access(const struct syscallname *name, #ifdef TARGET_NR_acct static void -print_acct(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) +print_acct(void *cpu_env, 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_string(arg0, 1); @@ -1463,9 +1468,9 @@ print_acct(const struct syscallname *name, #ifdef TARGET_NR_brk static void -print_brk(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) +print_brk(void *cpu_env, 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_pointer(arg0, 1); @@ -1475,9 +1480,9 @@ print_brk(const struct syscallname *name, #ifdef TARGET_NR_chdir static void -print_chdir(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) +print_chdir(void *cpu_env, 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_string(arg0, 1); @@ -1487,9 +1492,9 @@ print_chdir(const struct syscallname *name, #ifdef TARGET_NR_chroot static void -print_chroot(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) +print_chroot(void *cpu_env, 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_string(arg0, 1); @@ -1499,9 +1504,9 @@ print_chroot(const struct syscallname *name, #ifdef TARGET_NR_chmod static void -print_chmod(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) +print_chmod(void *cpu_env, 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_string(arg0, 0); @@ -1512,9 +1517,9 @@ print_chmod(const struct syscallname *name, #if defined(TARGET_NR_chown) || defined(TARGET_NR_lchown) static void -print_chown(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) +print_chown(void *cpu_env, 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_string(arg0, 0); @@ -1527,9 +1532,9 @@ print_chown(const struct syscallname *name, #ifdef TARGET_NR_clock_adjtime static void -print_clock_adjtime(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) +print_clock_adjtime(void *cpu_env, 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_clockid(arg0, 0); @@ -1551,9 +1556,9 @@ static void do_print_clone(unsigned int flags, abi_ulong newsp, } static void -print_clone(const struct syscallname *name, - abi_long arg1, abi_long arg2, abi_long arg3, - abi_long arg4, abi_long arg5, abi_long arg6) +print_clone(void *cpu_env, const struct syscallname *name, + abi_long arg1, abi_long arg2, abi_long arg3, + abi_long arg4, abi_long arg5, abi_long arg6) { print_syscall_prologue(name); #if defined(TARGET_MICROBLAZE) @@ -1571,9 +1576,9 @@ print_clone(const struct syscallname *name, #ifdef TARGET_NR_creat static void -print_creat(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) +print_creat(void *cpu_env, 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_string(arg0, 0); @@ -1584,9 +1589,9 @@ print_creat(const struct syscallname *name, #ifdef TARGET_NR_execv static void -print_execv(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) +print_execv(void *cpu_env, 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_string(arg0, 0); @@ -1597,9 +1602,9 @@ print_execv(const struct syscallname *name, #ifdef TARGET_NR_faccessat static void -print_faccessat(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) +print_faccessat(void *cpu_env, 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); @@ -1612,9 +1617,9 @@ print_faccessat(const struct syscallname *name, #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_fallocate(void *cpu_env, 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); @@ -1632,9 +1637,9 @@ print_fallocate(const struct syscallname *name, #ifdef TARGET_NR_fchmodat static void -print_fchmodat(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) +print_fchmodat(void *cpu_env, 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); @@ -1647,9 +1652,9 @@ print_fchmodat(const struct syscallname *name, #ifdef TARGET_NR_fchownat static void -print_fchownat(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) +print_fchownat(void *cpu_env, 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); @@ -1663,9 +1668,9 @@ print_fchownat(const struct syscallname *name, #if defined(TARGET_NR_fcntl) || defined(TARGET_NR_fcntl64) static void -print_fcntl(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) +print_fcntl(void *cpu_env, 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); @@ -1762,9 +1767,9 @@ print_fcntl(const struct syscallname *name, #ifdef TARGET_NR_fgetxattr static void -print_fgetxattr(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) +print_fgetxattr(void *cpu_env, 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); @@ -1777,9 +1782,9 @@ print_fgetxattr(const struct syscallname *name, #ifdef TARGET_NR_flistxattr static void -print_flistxattr(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) +print_flistxattr(void *cpu_env, 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); @@ -1791,9 +1796,9 @@ print_flistxattr(const struct syscallname *name, #if defined(TARGET_NR_getxattr) || defined(TARGET_NR_lgetxattr) static void -print_getxattr(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) +print_getxattr(void *cpu_env, 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_string(arg0, 0); @@ -1807,9 +1812,9 @@ print_getxattr(const struct syscallname *name, #if defined(TARGET_NR_listxattr) || defined(TARGET_NR_llistxattr) static void -print_listxattr(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) +print_listxattr(void *cpu_env, 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_string(arg0, 0); @@ -1822,9 +1827,9 @@ print_listxattr(const struct syscallname *name, #if defined(TARGET_NR_fremovexattr) static void -print_fremovexattr(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) +print_fremovexattr(void *cpu_env, 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); @@ -1835,9 +1840,9 @@ print_fremovexattr(const struct syscallname *name, #if defined(TARGET_NR_removexattr) || defined(TARGET_NR_lremovexattr) static void -print_removexattr(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) +print_removexattr(void *cpu_env, 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_string(arg0, 0); @@ -1849,9 +1854,9 @@ print_removexattr(const struct syscallname *name, #ifdef TARGET_NR_futimesat static void -print_futimesat(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) +print_futimesat(void *cpu_env, 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); @@ -1864,9 +1869,9 @@ print_futimesat(const struct syscallname *name, #ifdef TARGET_NR_settimeofday static void -print_settimeofday(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) +print_settimeofday(void *cpu_env, 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_timeval(arg0, 0); @@ -1877,9 +1882,9 @@ print_settimeofday(const struct syscallname *name, #ifdef TARGET_NR_link static void -print_link(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) +print_link(void *cpu_env, 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_string(arg0, 0); @@ -1890,9 +1895,9 @@ print_link(const struct syscallname *name, #ifdef TARGET_NR_linkat static void -print_linkat(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) +print_linkat(void *cpu_env, 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); @@ -1906,9 +1911,9 @@ print_linkat(const struct syscallname *name, #ifdef TARGET_NR__llseek static void -print__llseek(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) +print__llseek(void *cpu_env, const struct syscallname *name, + abi_long arg0, abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, abi_long arg5) { const char *whence = "UNKNOWN"; print_syscall_prologue(name); @@ -1928,9 +1933,9 @@ print__llseek(const struct syscallname *name, #ifdef TARGET_NR_lseek static void -print_lseek(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) +print_lseek(void *cpu_env, 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); @@ -1959,7 +1964,7 @@ print_lseek(const struct syscallname *name, #if defined(TARGET_NR_socket) static void -print_socket(const struct syscallname *name, +print_socket(void *cpu_env, const struct syscallname *name, abi_long arg0, abi_long arg1, abi_long arg2, abi_long arg3, abi_long arg4, abi_long arg5) { @@ -2308,7 +2313,7 @@ static struct { }; static void -print_socketcall(const struct syscallname *name, +print_socketcall(void *cpu_env, const struct syscallname *name, abi_long arg0, abi_long arg1, abi_long arg2, abi_long arg3, abi_long arg4, abi_long arg5) { @@ -2329,7 +2334,7 @@ print_socketcall(const struct syscallname *name, #if defined(TARGET_NR_bind) static void -print_bind(const struct syscallname *name, +print_bind(void *cpu_env, const struct syscallname *name, abi_long arg0, abi_long arg1, abi_long arg2, abi_long arg3, abi_long arg4, abi_long arg5) { @@ -2343,9 +2348,9 @@ print_bind(const struct syscallname *name, #if defined(TARGET_NR_stat) || defined(TARGET_NR_stat64) || \ defined(TARGET_NR_lstat) || defined(TARGET_NR_lstat64) static void -print_stat(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) +print_stat(void *cpu_env, 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_string(arg0, 0); @@ -2359,9 +2364,9 @@ print_stat(const struct syscallname *name, #if defined(TARGET_NR_fstat) || defined(TARGET_NR_fstat64) static void -print_fstat(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) +print_fstat(void *cpu_env, 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); @@ -2373,9 +2378,9 @@ print_fstat(const struct syscallname *name, #ifdef TARGET_NR_mkdir static void -print_mkdir(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) +print_mkdir(void *cpu_env, 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_string(arg0, 0); @@ -2386,9 +2391,9 @@ print_mkdir(const struct syscallname *name, #ifdef TARGET_NR_mkdirat static void -print_mkdirat(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) +print_mkdirat(void *cpu_env, 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); @@ -2400,9 +2405,9 @@ print_mkdirat(const struct syscallname *name, #ifdef TARGET_NR_rmdir static void -print_rmdir(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) +print_rmdir(void *cpu_env, 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_string(arg0, 0); @@ -2412,9 +2417,9 @@ print_rmdir(const struct syscallname *name, #ifdef TARGET_NR_rt_sigaction static void -print_rt_sigaction(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) +print_rt_sigaction(void *cpu_env, 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_signal(arg0, 0); @@ -2426,9 +2431,9 @@ print_rt_sigaction(const struct syscallname *name, #ifdef TARGET_NR_rt_sigprocmask static void -print_rt_sigprocmask(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) +print_rt_sigprocmask(void *cpu_env, const struct syscallname *name, + abi_long arg0, abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, abi_long arg5) { const char *how = "UNKNOWN"; print_syscall_prologue(name); @@ -2446,9 +2451,9 @@ print_rt_sigprocmask(const struct syscallname *name, #ifdef TARGET_NR_rt_sigqueueinfo static void -print_rt_sigqueueinfo(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) +print_rt_sigqueueinfo(void *cpu_env, const struct syscallname *name, + abi_long arg0, abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, abi_long arg5) { void *p; target_siginfo_t uinfo; @@ -2471,9 +2476,9 @@ print_rt_sigqueueinfo(const struct syscallname *name, #ifdef TARGET_NR_rt_tgsigqueueinfo static void -print_rt_tgsigqueueinfo(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) +print_rt_tgsigqueueinfo(void *cpu_env, const struct syscallname *name, + abi_long arg0, abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, abi_long arg5) { void *p; target_siginfo_t uinfo; @@ -2555,9 +2560,9 @@ print_syslog_action(abi_ulong arg, int last) } static void -print_syslog(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) +print_syslog(void *cpu_env, 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_syslog_action(arg0, 0); @@ -2569,9 +2574,9 @@ print_syslog(const struct syscallname *name, #ifdef TARGET_NR_mknod static void -print_mknod(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) +print_mknod(void *cpu_env, const struct syscallname *name, + abi_long arg0, abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, abi_long arg5) { int hasdev = (arg1 & (S_IFCHR|S_IFBLK)); @@ -2588,9 +2593,9 @@ print_mknod(const struct syscallname *name, #ifdef TARGET_NR_mknodat static void -print_mknodat(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) +print_mknodat(void *cpu_env, const struct syscallname *name, + abi_long arg0, abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, abi_long arg5) { int hasdev = (arg2 & (S_IFCHR|S_IFBLK)); @@ -2608,9 +2613,9 @@ print_mknodat(const struct syscallname *name, #ifdef TARGET_NR_mq_open static void -print_mq_open(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) +print_mq_open(void *cpu_env, const struct syscallname *name, + abi_long arg0, abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, abi_long arg5) { int is_creat = (arg1 & TARGET_O_CREAT); @@ -2627,9 +2632,9 @@ print_mq_open(const struct syscallname *name, #ifdef TARGET_NR_open static void -print_open(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) +print_open(void *cpu_env, const struct syscallname *name, + abi_long arg0, abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, abi_long arg5) { int is_creat = (arg1 & TARGET_O_CREAT); @@ -2644,9 +2649,9 @@ print_open(const struct syscallname *name, #ifdef TARGET_NR_openat static void -print_openat(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) +print_openat(void *cpu_env, const struct syscallname *name, + abi_long arg0, abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, abi_long arg5) { int is_creat = (arg2 & TARGET_O_CREAT); @@ -2662,9 +2667,9 @@ print_openat(const struct syscallname *name, #ifdef TARGET_NR_mq_unlink static void -print_mq_unlink(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) +print_mq_unlink(void *cpu_env, 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_string(arg0, 1); @@ -2674,9 +2679,9 @@ print_mq_unlink(const struct syscallname *name, #if defined(TARGET_NR_fstatat64) || defined(TARGET_NR_newfstatat) static void -print_fstatat64(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) +print_fstatat64(void *cpu_env, 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); @@ -2690,9 +2695,9 @@ print_fstatat64(const struct syscallname *name, #ifdef TARGET_NR_readlink static void -print_readlink(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) +print_readlink(void *cpu_env, 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_string(arg0, 0); @@ -2704,9 +2709,9 @@ print_readlink(const struct syscallname *name, #ifdef TARGET_NR_readlinkat static void -print_readlinkat(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) +print_readlinkat(void *cpu_env, 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); @@ -2719,9 +2724,9 @@ print_readlinkat(const struct syscallname *name, #ifdef TARGET_NR_rename static void -print_rename(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) +print_rename(void *cpu_env, 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_string(arg0, 0); @@ -2732,9 +2737,9 @@ print_rename(const struct syscallname *name, #ifdef TARGET_NR_renameat static void -print_renameat(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) +print_renameat(void *cpu_env, 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); @@ -2747,9 +2752,9 @@ print_renameat(const struct syscallname *name, #ifdef TARGET_NR_statfs static void -print_statfs(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) +print_statfs(void *cpu_env, 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_string(arg0, 0); @@ -2760,9 +2765,9 @@ print_statfs(const struct syscallname *name, #ifdef TARGET_NR_statfs64 static void -print_statfs64(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) +print_statfs64(void *cpu_env, 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_string(arg0, 0); @@ -2773,9 +2778,9 @@ print_statfs64(const struct syscallname *name, #ifdef TARGET_NR_symlink static void -print_symlink(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) +print_symlink(void *cpu_env, 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_string(arg0, 0); @@ -2786,9 +2791,9 @@ print_symlink(const struct syscallname *name, #ifdef TARGET_NR_symlinkat static void -print_symlinkat(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) +print_symlinkat(void *cpu_env, 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_string(arg0, 0); @@ -2800,9 +2805,9 @@ print_symlinkat(const struct syscallname *name, #ifdef TARGET_NR_mount static void -print_mount(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) +print_mount(void *cpu_env, 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_string(arg0, 0); @@ -2816,9 +2821,9 @@ print_mount(const struct syscallname *name, #ifdef TARGET_NR_umount static void -print_umount(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) +print_umount(void *cpu_env, 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_string(arg0, 1); @@ -2828,9 +2833,9 @@ print_umount(const struct syscallname *name, #ifdef TARGET_NR_umount2 static void -print_umount2(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) +print_umount2(void *cpu_env, 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_string(arg0, 0); @@ -2841,9 +2846,9 @@ print_umount2(const struct syscallname *name, #ifdef TARGET_NR_unlink static void -print_unlink(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) +print_unlink(void *cpu_env, 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_string(arg0, 1); @@ -2853,9 +2858,9 @@ print_unlink(const struct syscallname *name, #ifdef TARGET_NR_unlinkat static void -print_unlinkat(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) +print_unlinkat(void *cpu_env, 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); @@ -2867,9 +2872,9 @@ print_unlinkat(const struct syscallname *name, #ifdef TARGET_NR_utime static void -print_utime(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) +print_utime(void *cpu_env, 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_string(arg0, 0); @@ -2880,9 +2885,9 @@ print_utime(const struct syscallname *name, #ifdef TARGET_NR_utimes static void -print_utimes(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) +print_utimes(void *cpu_env, 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_string(arg0, 0); @@ -2893,9 +2898,9 @@ print_utimes(const struct syscallname *name, #ifdef TARGET_NR_utimensat static void -print_utimensat(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) +print_utimensat(void *cpu_env, 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); @@ -2908,9 +2913,9 @@ print_utimensat(const struct syscallname *name, #if defined(TARGET_NR_mmap) || defined(TARGET_NR_mmap2) static void -print_mmap(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) +print_mmap(void *cpu_env, 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_pointer(arg0, 0); @@ -2926,9 +2931,9 @@ print_mmap(const struct syscallname *name, #ifdef TARGET_NR_mprotect static void -print_mprotect(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) +print_mprotect(void *cpu_env, 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_pointer(arg0, 0); @@ -2940,9 +2945,9 @@ print_mprotect(const struct syscallname *name, #ifdef TARGET_NR_munmap static void -print_munmap(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) +print_munmap(void *cpu_env, 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_pointer(arg0, 0); @@ -2993,9 +2998,9 @@ if( cmd == val ) { \ } static void -print_futex(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) +print_futex(void *cpu_env, 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_pointer(arg0, 0); @@ -3010,9 +3015,9 @@ print_futex(const struct syscallname *name, #ifdef TARGET_NR_kill static void -print_kill(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) +print_kill(void *cpu_env, 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); @@ -3023,9 +3028,9 @@ print_kill(const struct syscallname *name, #ifdef TARGET_NR_tkill static void -print_tkill(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) +print_tkill(void *cpu_env, 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); @@ -3036,9 +3041,9 @@ print_tkill(const struct syscallname *name, #ifdef TARGET_NR_tgkill static void -print_tgkill(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) +print_tgkill(void *cpu_env, 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); @@ -3050,7 +3055,7 @@ print_tgkill(const struct syscallname *name, #ifdef TARGET_NR_statx static void -print_statx(const struct syscallname *name, +print_statx(void *cpu_env, const struct syscallname *name, abi_long arg0, abi_long arg1, abi_long arg2, abi_long arg3, abi_long arg4, abi_long arg5) { @@ -3066,7 +3071,7 @@ print_statx(const struct syscallname *name, #ifdef TARGET_NR_ioctl static void -print_ioctl(const struct syscallname *name, +print_ioctl(void *cpu_env, const struct syscallname *name, abi_long arg0, abi_long arg1, abi_long arg2, abi_long arg3, abi_long arg4, abi_long arg5) { @@ -3151,7 +3156,7 @@ static int nsyscalls = ARRAY_SIZE(scnames); * The public interface to this module. */ void -print_syscall(int num, +print_syscall(void *cpu_env, int num, abi_long arg1, abi_long arg2, abi_long arg3, abi_long arg4, abi_long arg5, abi_long arg6) { @@ -3164,7 +3169,7 @@ print_syscall(int num, if( scnames[i].nr == num ) { if( scnames[i].call != NULL ) { scnames[i].call( - &scnames[i], arg1, arg2, arg3, arg4, arg5, arg6); + cpu_env, &scnames[i], arg1, arg2, arg3, arg4, arg5, arg6); } else { /* XXX: this format system is broken because it uses host types and host pointers for strings */ @@ -3180,7 +3185,7 @@ print_syscall(int num, void -print_syscall_ret(int num, abi_long ret, +print_syscall_ret(void *cpu_env, int num, abi_long ret, abi_long arg1, abi_long arg2, abi_long arg3, abi_long arg4, abi_long arg5, abi_long arg6) { @@ -3189,7 +3194,7 @@ print_syscall_ret(int num, abi_long ret, for(i=0;i X-Patchwork-Id: 11741457 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 983E014E5 for ; Thu, 27 Aug 2020 19:23:17 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 79DFE207CD for ; Thu, 27 Aug 2020 19:23:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 79DFE207CD Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=vivier.eu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:40114 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kBNUS-0000aV-My for patchwork-qemu-devel@patchwork.kernel.org; Thu, 27 Aug 2020 15:23:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33438) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kBNRy-0003zX-ME for qemu-devel@nongnu.org; Thu, 27 Aug 2020 15:20:42 -0400 Received: from mout.kundenserver.de ([212.227.17.24]:55707) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kBNRw-0000Cj-9W for qemu-devel@nongnu.org; Thu, 27 Aug 2020 15:20:42 -0400 Received: from localhost.localdomain ([82.252.135.186]) by mrelayeu.kundenserver.de (mreue109 [212.227.15.183]) with ESMTPSA (Nemesis) id 1M1pk6-1k9BaR0PZg-002H6c; Thu, 27 Aug 2020 21:20:31 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 05/18] linux-user: Add strace support for printing arguments of truncate()/ftruncate() and getsid() Date: Thu, 27 Aug 2020 21:20:05 +0200 Message-Id: <20200827192018.2442099-6-laurent@vivier.eu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200827192018.2442099-1-laurent@vivier.eu> References: <20200827192018.2442099-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:AC9QzEiU3l5K7Y84OMrSLLlg1eupkhANdkWxJkdNf3NHRtFln7M DuQym0UzeBlKpjTAxACsoXYIxEeNGNVEeg3PdEmNEKtyZcStYOnoeAp53VZhP8EkKq+zOMs 4XiFysvuo3UWETSFfyzRITibSnojD66CM3Lhxl8CUXshC3aUgUDTdXt8xzDku0+aLJUiGks q37/Ts3Cni9+GYpSmntwQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:WFEFUMwL2Yc=:Y2sBk66PPQVyFSqgHnAinX RKbM5O3Ub8M0pCGKAixI5NWa8mL2DaJuKemljx2b2q/MrMYSLqHybCgi4/9iNEDwlJhhaloLu XLRW1V6jQAAyTIl61mKEiV5PdvcpsXTS9Tr38w7AILDs9VCYylqtEwUZanml5HYYbOwYIfvbh K+8znLHonKzRnP/SWYy2XIcKF696YWVSHeJX/fI3RcLh3n8/0zEMI3pCKATXLcPcO7N+0m9RG e6xIaWWr8U44zNA2xtYJXUZ1movPraZbTetE6/6CxMQnrp9cob4bJZDUnUM6VxqjjJ3fMRiNM 4JDFFMoRrqtYWVoyuVhYpoaWwInLbYejZnO7rCBawjUa8U9zFG+GhDAlpNZgV0yqTZLSyspjh RqxZZwtF8xFndAJBiY+ozpoOSqBJOT8q1l70dGkSG5VswnNJbkwpKoFl1HWZj7/FdC4HIkQCz +4IgA8GUhWbIM8MHu27zaC027ZgZAwhdSQuqjRWP0WueSP3icMbzwQNUhNbP0PIlxjWt40lbi hkl9tFy8HlEyY8ISG/u2LUG49hr4F0Vq7xaQkw0nByuJ94JnasUirUh27vdpQgFSaL0uKEtPj HC5sDDgStUQgybYn4Gdi2XObeRhBTcpn72SESX4aT/AeW+kqfZbN9txfRPtLSHRH4hiEXyEeV sAbGjqksO8XXuYRt73ojlsoJz0EALdKJ4lz1U1uxMpk6KtGOvXxqg+VeHWAESbuPMvG00aUKC XvDr7u8MYt6n2nEMqjz07g4UYobnnHAvt76W9oiqdVnnR26nMNF+WPC4u2uwasqfL0XU2gMop spIk4r362GcSVg9hJbFUhzgHxAvXlRO4ljZ+KU/Jpv3oZEpj7gdwgS2XTvR34kxc7WnQbK4 Received-SPF: none client-ip=212.227.17.24; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/27 15:20:34 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] 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, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Riku Voipio , Laurent Vivier , Filip Bozuta Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Filip Bozuta This patch implements strace argument printing functionality for following syscalls: * truncate, ftruncate - truncate a file to a specified length int truncate/truncate64(const char *path, off_t length) int ftruncate/ftruncate64(int fd, off_t length) man page: https://man7.org/linux/man-pages/man2/truncate.2.html * getsid - get session ID pid_t getsid(pid_t pid) man page: https://man7.org/linux/man-pages/man2/getsid.2.html Implementation notes: Syscalls truncate/truncate64 take string argument types and thus a separate print function "print_truncate/print_truncate64" is stated in file "strace.list". This function is defined and implemented in "strace.c" by using an existing function used to print string arguments: "print_string()". For syscall ftruncate64, a separate printing function was also stated in "strace.c" as it requires a special kind of handling. The other syscalls have only primitive argument types, so the rest of the implementation was handled by stating an appropriate printing format in file "strace.list". Function "regpairs_aligned()" was cut & pasted from "syscall.c" to "qemu.h" as it is used by functions "print_truncate64()" and "print_ftruncate64()" to print the offset arguments of "truncate64()" and "ftruncate64()". Signed-off-by: Filip Bozuta Reviewed-by: Laurent Vivier Message-Id: <20200811164553.27713-3-Filip.Bozuta@syrmia.com> Signed-off-by: Laurent Vivier --- linux-user/qemu.h | 35 +++++++++++++++++++++++++++++++ linux-user/strace.c | 47 ++++++++++++++++++++++++++++++++++++++++++ linux-user/strace.list | 10 ++++----- linux-user/syscall.c | 32 ---------------------------- 4 files changed, 87 insertions(+), 37 deletions(-) diff --git a/linux-user/qemu.h b/linux-user/qemu.h index 63ddfe86fd8b..f431805e573f 100644 --- a/linux-user/qemu.h +++ b/linux-user/qemu.h @@ -706,6 +706,41 @@ static inline uint64_t target_offset64(uint64_t word0, uint64_t word1) } #endif /* TARGET_ABI_BITS != 32 */ + +/* ARM EABI and MIPS expect 64bit types aligned even on pairs or registers */ +#ifdef TARGET_ARM +static inline int regpairs_aligned(void *cpu_env, int num) +{ + return ((((CPUARMState *)cpu_env)->eabi) == 1) ; +} +#elif defined(TARGET_MIPS) && (TARGET_ABI_BITS == 32) +static inline int regpairs_aligned(void *cpu_env, int num) { return 1; } +#elif defined(TARGET_PPC) && !defined(TARGET_PPC64) +/* + * SysV AVI for PPC32 expects 64bit parameters to be passed on odd/even pairs + * of registers which translates to the same as ARM/MIPS, because we start with + * r3 as arg1 + */ +static inline int regpairs_aligned(void *cpu_env, int num) { return 1; } +#elif defined(TARGET_SH4) +/* SH4 doesn't align register pairs, except for p{read,write}64 */ +static inline int regpairs_aligned(void *cpu_env, int num) +{ + switch (num) { + case TARGET_NR_pread64: + case TARGET_NR_pwrite64: + return 1; + + default: + return 0; + } +} +#elif defined(TARGET_XTENSA) +static inline int regpairs_aligned(void *cpu_env, int num) { return 1; } +#else +static inline int regpairs_aligned(void *cpu_env, int num) { return 0; } +#endif + /** * preexit_cleanup: housekeeping before the guest exits * diff --git a/linux-user/strace.c b/linux-user/strace.c index 2dcc15496a6a..31c7be24ebfd 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -1962,6 +1962,53 @@ print_lseek(void *cpu_env, const struct syscallname *name, } #endif +#ifdef TARGET_NR_truncate +static void +print_truncate(void *cpu_env, 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_string(arg0, 0); + print_raw_param(TARGET_ABI_FMT_ld, arg1, 1); + print_syscall_epilogue(name); +} +#endif + +#ifdef TARGET_NR_truncate64 +static void +print_truncate64(void *cpu_env, 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_string(arg0, 0); + if (regpairs_aligned(cpu_env, TARGET_NR_truncate64)) { + arg1 = arg2; + arg2 = arg3; + } + print_raw_param("%" PRIu64, target_offset64(arg1, arg2), 1); + print_syscall_epilogue(name); +} +#endif + +#ifdef TARGET_NR_ftruncate64 +static void +print_ftruncate64(void *cpu_env, 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); + if (regpairs_aligned(cpu_env, TARGET_NR_ftruncate64)) { + arg1 = arg2; + arg2 = arg3; + } + print_raw_param("%" PRIu64, target_offset64(arg1, arg2), 1); + print_syscall_epilogue(name); +} +#endif + #if defined(TARGET_NR_socket) static void print_socket(void *cpu_env, const struct syscallname *name, diff --git a/linux-user/strace.list b/linux-user/strace.list index a04706a524ae..8e5303d03500 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -258,10 +258,10 @@ { TARGET_NR_ftime, "ftime" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_ftruncate -{ TARGET_NR_ftruncate, "ftruncate" , NULL, NULL, NULL }, +{ TARGET_NR_ftruncate, "ftruncate" , "%s(%d," TARGET_ABI_FMT_ld ")", NULL, NULL }, #endif #ifdef TARGET_NR_ftruncate64 -{ TARGET_NR_ftruncate64, "ftruncate64" , NULL, NULL, NULL }, +{ TARGET_NR_ftruncate64, "ftruncate64" , NULL, print_ftruncate64, NULL }, #endif #ifdef TARGET_NR_futex { TARGET_NR_futex, "futex" , NULL, print_futex, NULL }, @@ -372,7 +372,7 @@ { TARGET_NR_getrusage, "getrusage" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_getsid -{ TARGET_NR_getsid, "getsid" , NULL, NULL, NULL }, +{ TARGET_NR_getsid, "getsid" , "%s(%d)", NULL, NULL }, #endif #ifdef TARGET_NR_getsockname { TARGET_NR_getsockname, "getsockname" , NULL, NULL, NULL }, @@ -1535,10 +1535,10 @@ { TARGET_NR_tkill, "tkill" , NULL, print_tkill, NULL }, #endif #ifdef TARGET_NR_truncate -{ TARGET_NR_truncate, "truncate" , NULL, NULL, NULL }, +{ TARGET_NR_truncate, "truncate" , NULL, print_truncate, NULL }, #endif #ifdef TARGET_NR_truncate64 -{ TARGET_NR_truncate64, "truncate64" , NULL, NULL, NULL }, +{ TARGET_NR_truncate64, "truncate64" , NULL, print_truncate64, NULL }, #endif #ifdef TARGET_NR_tuxcall { TARGET_NR_tuxcall, "tuxcall" , NULL, NULL, NULL }, diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 42107f37e397..ec7192112e9d 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -495,38 +495,6 @@ static inline int next_free_host_timer(void) } #endif -/* ARM EABI and MIPS expect 64bit types aligned even on pairs or registers */ -#ifdef TARGET_ARM -static inline int regpairs_aligned(void *cpu_env, int num) -{ - return ((((CPUARMState *)cpu_env)->eabi) == 1) ; -} -#elif defined(TARGET_MIPS) && (TARGET_ABI_BITS == 32) -static inline int regpairs_aligned(void *cpu_env, int num) { return 1; } -#elif defined(TARGET_PPC) && !defined(TARGET_PPC64) -/* SysV AVI for PPC32 expects 64bit parameters to be passed on odd/even pairs - * of registers which translates to the same as ARM/MIPS, because we start with - * r3 as arg1 */ -static inline int regpairs_aligned(void *cpu_env, int num) { return 1; } -#elif defined(TARGET_SH4) -/* SH4 doesn't align register pairs, except for p{read,write}64 */ -static inline int regpairs_aligned(void *cpu_env, int num) -{ - switch (num) { - case TARGET_NR_pread64: - case TARGET_NR_pwrite64: - return 1; - - default: - return 0; - } -} -#elif defined(TARGET_XTENSA) -static inline int regpairs_aligned(void *cpu_env, int num) { return 1; } -#else -static inline int regpairs_aligned(void *cpu_env, int num) { return 0; } -#endif - #define ERRNO_TABLE_SIZE 1200 /* target_to_host_errno_table[] is initialized from From patchwork Thu Aug 27 19:20:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 11741467 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AADAF14F6 for ; Thu, 27 Aug 2020 19:25:12 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 765E6207CD for ; Thu, 27 Aug 2020 19:25:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 765E6207CD Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=vivier.eu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:51640 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kBNWJ-0005EE-LZ for patchwork-qemu-devel@patchwork.kernel.org; Thu, 27 Aug 2020 15:25:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33482) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kBNS1-00047B-S9 for qemu-devel@nongnu.org; Thu, 27 Aug 2020 15:20:45 -0400 Received: from mout.kundenserver.de ([217.72.192.75]:58907) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kBNRy-0000ER-SA for qemu-devel@nongnu.org; Thu, 27 Aug 2020 15:20:45 -0400 Received: from localhost.localdomain ([82.252.135.186]) by mrelayeu.kundenserver.de (mreue109 [212.227.15.183]) with ESMTPSA (Nemesis) id 1M9Frd-1kHiAK2vwt-006Q6b; Thu, 27 Aug 2020 21:20:32 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 06/18] linux-user: Add strace support for printing arguments of syscalls used to lock and unlock memory Date: Thu, 27 Aug 2020 21:20:06 +0200 Message-Id: <20200827192018.2442099-7-laurent@vivier.eu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200827192018.2442099-1-laurent@vivier.eu> References: <20200827192018.2442099-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:f0nRlCcWTzGwn9gK0ez3eLTyeo0HG0H/6rbwmTiga1TleANHppN PvaeZe2jFg6jR/IC9CtXiHMfylpyy0NSKbH4/TuN7Htbf3GFKTeNHMwU1Df/WP/UDlmdc8G TAKoYvpmsPJ0TFpsJqp1QczTEjXlZjvkCYsxmh9Ce7pUWWsc8KpPRxkqzBdDGWPtpz0USyO YJ7KmrT/m3A3hrnJat4rg== X-UI-Out-Filterresults: notjunk:1;V03:K0:fAcFz1Py0+A=:yOz1fVyDwnsQlP1x8xH9Nr 13mI+910JosTNv7qdqzkuXKNBwNEaMoU1yBcMOhxxg9S2Woxww2Qtg6/ARhb7cX1xLg1xsSgP UvTYRV1IkyisV0AJ4MrUfAwC0R7hkpatCNeNZf4Pab306+5EX6pdtvEXJ95VXY7uuP4ZROyav a9OqOYnaepFENRdvEcY/mP6ALLYktbeONgxUhe+wEw5aaDLNVdV+KgguKN7hSmtANxbAf7F/R 4wvO8MQrhgsDu70YT7vDdPlfgj4KLSzv+6++xyR1bL7y6+f+SQTnQwbpqTsP2JQrAuVvIde1/ JHcqTANyjnn5121oPT4XmAbt2PkB6Mk7yDVRTc+lCghmBz3msgH6nNUIYdiVPM09pX50o9Lhq dmhVd0TKHyPOKE5E6FgtprOaz4kg1sU9crGkEMNTKpZzZZs6Xgt2ZVTFM/NH+3xWed5fBCYGK LQXDOQgXNH2F4QczHiSIzdNyUsJWmv5YYG3KODEpBuNFgf/Q03CUuDraYhoG6j5G3/i+X+r2a 3SFXRVtyvLj4KvrvW8LnY6C6f8/bB1ihj5qfbff+Zax3CsyXRoZjf9K4OXMTFJBOrjfSMcoBe 0zT8+9wvkzhiaMMJF500czIo/p9grICb1Q+dZ7JqPExK6A+lOQspj46kQItGKmCt/SVNLa9cG Exn9qw6pAhaM6peP1xDRn45elaDDlFNZRSfJX2pMCY7yuBwOCXZWUScCJ1yCTzUitnFJ3n/+Z jhhtA80wjLV2W1DnRzGbIh0nQiIa8oWErie5hhtKr0KRab67a4ZZx8r3ulGr8EWR37QpRW49r NaHXQq6t2/shtM9Y1s8lPJCuNOlQHhGnvsRgXj+b66sCu4Wg7DWRn8aL4dONnYiI91e2As5 Received-SPF: none client-ip=217.72.192.75; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/27 15:20:36 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] 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, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Riku Voipio , Laurent Vivier , Filip Bozuta Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Filip Bozuta This patch implements strace argument printing functionality for following syscalls: * mlock, munlock, mlockall, munlockall - lock and unlock memory int mlock(const void *addr, size_t len) int munlock(const void *addr, size_t len) int mlockall(int flags) int munlockall(void) man page: https://man7.org/linux/man-pages/man2/mlock.2.html Implementation notes: Syscall mlockall() takes an argument that is composed of predefined values which represent flags that determine the type of locking operation that is to be performed. For that reason, a printing function "print_mlockall" was stated in file "strace.list". This printing function uses an already existing function "print_flags()" to print the "flags" argument. These flags are stated inside an array "mlockall_flags" that contains values of type "struct flags". These values are instantiated using an existing macro "FLAG_TARGET()" that crates aproppriate target flag values based on those defined in files '/target_syscall.h'. These target flag values were changed from "TARGET_MLOCKALL_MCL*" to "TARGET_MCL_*" so that they can be aproppriately set and recognised in "strace.c" with "FLAG_TARGET()". Value for "MCL_ONFAULT" was added in this patch. This value was also added in "syscall.c" in function "target_to_host_mlockall_arg()". Because this flag value was added in kernel version 4.4, it is enwrapped in an #ifdef directive (both in "syscall.c" and in "strace.c") as to support older kernel versions. The other syscalls have only primitive argument types, so the rest of the implementation was handled by stating an appropriate printing format in file "strace.list". Syscall mlock2() is not implemented in "syscall.c" and thus it's argument printing is not implemented in this patch. Signed-off-by: Filip Bozuta Reviewed-by: Laurent Vivier Message-Id: <20200811164553.27713-4-Filip.Bozuta@syrmia.com> Signed-off-by: Laurent Vivier --- linux-user/aarch64/target_syscall.h | 5 +++-- linux-user/alpha/target_syscall.h | 5 +++-- linux-user/arm/target_syscall.h | 6 ++++-- linux-user/cris/target_syscall.h | 5 +++-- linux-user/hppa/target_syscall.h | 5 +++-- linux-user/i386/target_syscall.h | 5 +++-- linux-user/m68k/target_syscall.h | 6 +++--- linux-user/microblaze/target_syscall.h | 5 +++-- linux-user/mips/target_syscall.h | 5 +++-- linux-user/mips64/target_syscall.h | 5 +++-- linux-user/nios2/target_syscall.h | 5 +++-- linux-user/openrisc/target_syscall.h | 5 +++-- linux-user/ppc/target_syscall.h | 5 +++-- linux-user/riscv/target_syscall.h | 5 +++-- linux-user/s390x/target_syscall.h | 5 +++-- linux-user/sh4/target_syscall.h | 5 +++-- linux-user/sparc/target_syscall.h | 5 +++-- linux-user/sparc64/target_syscall.h | 5 +++-- linux-user/strace.c | 21 +++++++++++++++++++++ linux-user/strace.list | 8 ++++---- linux-user/syscall.c | 10 ++++++++-- linux-user/tilegx/target_syscall.h | 5 +++-- linux-user/x86_64/target_syscall.h | 5 +++-- linux-user/xtensa/target_syscall.h | 5 +++-- 24 files changed, 97 insertions(+), 49 deletions(-) diff --git a/linux-user/aarch64/target_syscall.h b/linux-user/aarch64/target_syscall.h index 995e475c73f8..3194e6b0093c 100644 --- a/linux-user/aarch64/target_syscall.h +++ b/linux-user/aarch64/target_syscall.h @@ -16,8 +16,9 @@ struct target_pt_regs { #define UNAME_MINIMUM_RELEASE "3.8.0" #define TARGET_CLONE_BACKWARDS #define TARGET_MINSIGSTKSZ 2048 -#define TARGET_MLOCKALL_MCL_CURRENT 1 -#define TARGET_MLOCKALL_MCL_FUTURE 2 +#define TARGET_MCL_CURRENT 1 +#define TARGET_MCL_FUTURE 2 +#define TARGET_MCL_ONFAULT 4 #define TARGET_PR_SVE_SET_VL 50 #define TARGET_PR_SVE_GET_VL 51 diff --git a/linux-user/alpha/target_syscall.h b/linux-user/alpha/target_syscall.h index 3426cc5b4e4f..fd389422e31e 100644 --- a/linux-user/alpha/target_syscall.h +++ b/linux-user/alpha/target_syscall.h @@ -258,7 +258,8 @@ struct target_pt_regs { #define TARGET_UAC_NOFIX 2 #define TARGET_UAC_SIGBUS 4 #define TARGET_MINSIGSTKSZ 4096 -#define TARGET_MLOCKALL_MCL_CURRENT 0x2000 -#define TARGET_MLOCKALL_MCL_FUTURE 0x4000 +#define TARGET_MCL_CURRENT 0x2000 +#define TARGET_MCL_FUTURE 0x4000 +#define TARGET_MCL_ONFAULT 0x8000 #endif /* ALPHA_TARGET_SYSCALL_H */ diff --git a/linux-user/arm/target_syscall.h b/linux-user/arm/target_syscall.h index f85cbdaf56ff..e870ed7a5468 100644 --- a/linux-user/arm/target_syscall.h +++ b/linux-user/arm/target_syscall.h @@ -28,8 +28,10 @@ struct target_pt_regs { #define TARGET_CLONE_BACKWARDS #define TARGET_MINSIGSTKSZ 2048 -#define TARGET_MLOCKALL_MCL_CURRENT 1 -#define TARGET_MLOCKALL_MCL_FUTURE 2 +#define TARGET_MCL_CURRENT 1 +#define TARGET_MCL_FUTURE 2 +#define TARGET_MCL_ONFAULT 4 + #define TARGET_WANT_OLD_SYS_SELECT #define TARGET_FORCE_SHMLBA diff --git a/linux-user/cris/target_syscall.h b/linux-user/cris/target_syscall.h index 29d69009ffe8..d109a6b42a35 100644 --- a/linux-user/cris/target_syscall.h +++ b/linux-user/cris/target_syscall.h @@ -40,7 +40,8 @@ struct target_pt_regs { #define TARGET_CLONE_BACKWARDS2 #define TARGET_MINSIGSTKSZ 2048 -#define TARGET_MLOCKALL_MCL_CURRENT 1 -#define TARGET_MLOCKALL_MCL_FUTURE 2 +#define TARGET_MCL_CURRENT 1 +#define TARGET_MCL_FUTURE 2 +#define TARGET_MCL_ONFAULT 4 #endif diff --git a/linux-user/hppa/target_syscall.h b/linux-user/hppa/target_syscall.h index e2f366839d80..f34e05edb57b 100644 --- a/linux-user/hppa/target_syscall.h +++ b/linux-user/hppa/target_syscall.h @@ -23,8 +23,9 @@ struct target_pt_regs { #define UNAME_MINIMUM_RELEASE "2.6.32" #define TARGET_CLONE_BACKWARDS #define TARGET_MINSIGSTKSZ 2048 -#define TARGET_MLOCKALL_MCL_CURRENT 1 -#define TARGET_MLOCKALL_MCL_FUTURE 2 +#define TARGET_MCL_CURRENT 1 +#define TARGET_MCL_FUTURE 2 +#define TARGET_MCL_ONFAULT 4 #undef TARGET_ENOMSG #define TARGET_ENOMSG 35 diff --git a/linux-user/i386/target_syscall.h b/linux-user/i386/target_syscall.h index 2854758134d7..ed356b3908dc 100644 --- a/linux-user/i386/target_syscall.h +++ b/linux-user/i386/target_syscall.h @@ -151,8 +151,9 @@ struct target_vm86plus_struct { #define TARGET_CLONE_BACKWARDS #define TARGET_MINSIGSTKSZ 2048 -#define TARGET_MLOCKALL_MCL_CURRENT 1 -#define TARGET_MLOCKALL_MCL_FUTURE 2 +#define TARGET_MCL_CURRENT 1 +#define TARGET_MCL_FUTURE 2 +#define TARGET_MCL_ONFAULT 4 #define TARGET_WANT_OLD_SYS_SELECT #endif /* I386_TARGET_SYSCALL_H */ diff --git a/linux-user/m68k/target_syscall.h b/linux-user/m68k/target_syscall.h index c0366b1c622d..23359a6299dd 100644 --- a/linux-user/m68k/target_syscall.h +++ b/linux-user/m68k/target_syscall.h @@ -21,9 +21,9 @@ struct target_pt_regs { #define UNAME_MINIMUM_RELEASE "2.6.32" #define TARGET_MINSIGSTKSZ 2048 -#define TARGET_MLOCKALL_MCL_CURRENT 1 -#define TARGET_MLOCKALL_MCL_FUTURE 2 - +#define TARGET_MCL_CURRENT 1 +#define TARGET_MCL_FUTURE 2 +#define TARGET_MCL_ONFAULT 4 #define TARGET_WANT_OLD_SYS_SELECT #endif /* M68K_TARGET_SYSCALL_H */ diff --git a/linux-user/microblaze/target_syscall.h b/linux-user/microblaze/target_syscall.h index 4141cbaa5ec2..7f653db34f87 100644 --- a/linux-user/microblaze/target_syscall.h +++ b/linux-user/microblaze/target_syscall.h @@ -50,8 +50,9 @@ struct target_pt_regs { #define TARGET_CLONE_BACKWARDS #define TARGET_MINSIGSTKSZ 2048 -#define TARGET_MLOCKALL_MCL_CURRENT 1 -#define TARGET_MLOCKALL_MCL_FUTURE 2 +#define TARGET_MCL_CURRENT 1 +#define TARGET_MCL_FUTURE 2 +#define TARGET_MCL_ONFAULT 4 #define TARGET_WANT_NI_OLD_SELECT diff --git a/linux-user/mips/target_syscall.h b/linux-user/mips/target_syscall.h index d5509a34a7e2..dd6fd7af8eac 100644 --- a/linux-user/mips/target_syscall.h +++ b/linux-user/mips/target_syscall.h @@ -234,8 +234,9 @@ struct target_pt_regs { #define TARGET_CLONE_BACKWARDS #define TARGET_MINSIGSTKSZ 2048 -#define TARGET_MLOCKALL_MCL_CURRENT 1 -#define TARGET_MLOCKALL_MCL_FUTURE 2 +#define TARGET_MCL_CURRENT 1 +#define TARGET_MCL_FUTURE 2 +#define TARGET_MCL_ONFAULT 4 #define TARGET_FORCE_SHMLBA diff --git a/linux-user/mips64/target_syscall.h b/linux-user/mips64/target_syscall.h index 8ccc46822c11..8594955eec26 100644 --- a/linux-user/mips64/target_syscall.h +++ b/linux-user/mips64/target_syscall.h @@ -231,8 +231,9 @@ struct target_pt_regs { #define TARGET_CLONE_BACKWARDS #define TARGET_MINSIGSTKSZ 2048 -#define TARGET_MLOCKALL_MCL_CURRENT 1 -#define TARGET_MLOCKALL_MCL_FUTURE 2 +#define TARGET_MCL_CURRENT 1 +#define TARGET_MCL_FUTURE 2 +#define TARGET_MCL_ONFAULT 4 #define TARGET_FORCE_SHMLBA diff --git a/linux-user/nios2/target_syscall.h b/linux-user/nios2/target_syscall.h index f3b2a500f430..78006c24d479 100644 --- a/linux-user/nios2/target_syscall.h +++ b/linux-user/nios2/target_syscall.h @@ -31,7 +31,8 @@ struct target_pt_regs { }; #define TARGET_MINSIGSTKSZ 2048 -#define TARGET_MLOCKALL_MCL_CURRENT 1 -#define TARGET_MLOCKALL_MCL_FUTURE 2 +#define TARGET_MCL_CURRENT 1 +#define TARGET_MCL_FUTURE 2 +#define TARGET_MCL_ONFAULT 4 #endif /* NIOS2_TARGET_SYSCALL_H */ diff --git a/linux-user/openrisc/target_syscall.h b/linux-user/openrisc/target_syscall.h index d586d2a018a5..ef0d89a551d5 100644 --- a/linux-user/openrisc/target_syscall.h +++ b/linux-user/openrisc/target_syscall.h @@ -16,8 +16,9 @@ struct target_pt_regs { #define UNAME_MINIMUM_RELEASE "2.6.32" #define TARGET_MINSIGSTKSZ 2048 -#define TARGET_MLOCKALL_MCL_CURRENT 1 -#define TARGET_MLOCKALL_MCL_FUTURE 2 +#define TARGET_MCL_CURRENT 1 +#define TARGET_MCL_FUTURE 2 +#define TARGET_MCL_ONFAULT 4 #define MMAP_SHIFT TARGET_PAGE_BITS diff --git a/linux-user/ppc/target_syscall.h b/linux-user/ppc/target_syscall.h index afc0570410d8..c461f878f2d6 100644 --- a/linux-user/ppc/target_syscall.h +++ b/linux-user/ppc/target_syscall.h @@ -72,8 +72,9 @@ struct target_revectored_struct { #define TARGET_CLONE_BACKWARDS #define TARGET_MINSIGSTKSZ 2048 -#define TARGET_MLOCKALL_MCL_CURRENT 0x2000 -#define TARGET_MLOCKALL_MCL_FUTURE 0x4000 +#define TARGET_MCL_CURRENT 0x2000 +#define TARGET_MCL_FUTURE 0x4000 +#define TARGET_MCL_ONFAULT 0x8000 #define TARGET_WANT_NI_OLD_SELECT #endif /* PPC_TARGET_SYSCALL_H */ diff --git a/linux-user/riscv/target_syscall.h b/linux-user/riscv/target_syscall.h index a88e821f733d..dc597c897222 100644 --- a/linux-user/riscv/target_syscall.h +++ b/linux-user/riscv/target_syscall.h @@ -51,8 +51,9 @@ struct target_pt_regs { #define UNAME_MINIMUM_RELEASE "4.15.0" #define TARGET_MINSIGSTKSZ 2048 -#define TARGET_MLOCKALL_MCL_CURRENT 1 -#define TARGET_MLOCKALL_MCL_FUTURE 2 +#define TARGET_MCL_CURRENT 1 +#define TARGET_MCL_FUTURE 2 +#define TARGET_MCL_ONFAULT 4 /* clone(flags, newsp, ptidptr, tls, ctidptr) for RISC-V */ /* This comes from linux/kernel/fork.c, CONFIG_CLONE_BACKWARDS */ diff --git a/linux-user/s390x/target_syscall.h b/linux-user/s390x/target_syscall.h index 8d4f609eaa5d..94f84178db79 100644 --- a/linux-user/s390x/target_syscall.h +++ b/linux-user/s390x/target_syscall.h @@ -28,7 +28,8 @@ struct target_pt_regs { #define TARGET_CLONE_BACKWARDS2 #define TARGET_MINSIGSTKSZ 2048 -#define TARGET_MLOCKALL_MCL_CURRENT 1 -#define TARGET_MLOCKALL_MCL_FUTURE 2 +#define TARGET_MCL_CURRENT 1 +#define TARGET_MCL_FUTURE 2 +#define TARGET_MCL_ONFAULT 4 #endif /* S390X_TARGET_SYSCALL_H */ diff --git a/linux-user/sh4/target_syscall.h b/linux-user/sh4/target_syscall.h index 2b5f75be13d6..c1437adafefa 100644 --- a/linux-user/sh4/target_syscall.h +++ b/linux-user/sh4/target_syscall.h @@ -16,8 +16,9 @@ struct target_pt_regs { #define UNAME_MINIMUM_RELEASE "2.6.32" #define TARGET_MINSIGSTKSZ 2048 -#define TARGET_MLOCKALL_MCL_CURRENT 1 -#define TARGET_MLOCKALL_MCL_FUTURE 2 +#define TARGET_MCL_CURRENT 1 +#define TARGET_MCL_FUTURE 2 +#define TARGET_MCL_ONFAULT 4 #define TARGET_FORCE_SHMLBA diff --git a/linux-user/sparc/target_syscall.h b/linux-user/sparc/target_syscall.h index b9160a771baa..d8ea04ea837a 100644 --- a/linux-user/sparc/target_syscall.h +++ b/linux-user/sparc/target_syscall.h @@ -21,8 +21,9 @@ struct target_pt_regs { */ #define TARGET_CLONE_BACKWARDS #define TARGET_MINSIGSTKSZ 4096 -#define TARGET_MLOCKALL_MCL_CURRENT 0x2000 -#define TARGET_MLOCKALL_MCL_FUTURE 0x4000 +#define TARGET_MCL_CURRENT 0x2000 +#define TARGET_MCL_FUTURE 0x4000 +#define TARGET_MCL_ONFAULT 0x8000 /* For SPARC SHMLBA is determined at runtime in the kernel, and * libc has to runtime-detect it using the hwcaps (see glibc diff --git a/linux-user/sparc64/target_syscall.h b/linux-user/sparc64/target_syscall.h index 3073a23e03ae..696a68b1ed4e 100644 --- a/linux-user/sparc64/target_syscall.h +++ b/linux-user/sparc64/target_syscall.h @@ -22,8 +22,9 @@ struct target_pt_regs { */ #define TARGET_CLONE_BACKWARDS #define TARGET_MINSIGSTKSZ 4096 -#define TARGET_MLOCKALL_MCL_CURRENT 0x2000 -#define TARGET_MLOCKALL_MCL_FUTURE 0x4000 +#define TARGET_MCL_CURRENT 0x2000 +#define TARGET_MCL_FUTURE 0x4000 +#define TARGET_MCL_ONFAULT 0x8000 #define TARGET_FORCE_SHMLBA diff --git a/linux-user/strace.c b/linux-user/strace.c index 31c7be24ebfd..4ac54ecffe9c 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -1198,6 +1198,15 @@ UNUSED static struct flags falloc_flags[] = { #endif }; +UNUSED static struct flags mlockall_flags[] = { + FLAG_TARGET(MCL_CURRENT), + FLAG_TARGET(MCL_FUTURE), +#ifdef MCL_ONFAULT + FLAG_TARGET(MCL_ONFAULT), +#endif + FLAG_END, +}; + /* * print_xxx utility functions. These are used to print syscall * parameters in certain format. All of these have parameter @@ -2009,6 +2018,18 @@ print_ftruncate64(void *cpu_env, const struct syscallname *name, } #endif +#ifdef TARGET_NR_mlockall +static void +print_mlockall(void *cpu_env, 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_flags(mlockall_flags, arg0, 1); + print_syscall_epilogue(name); +} +#endif + #if defined(TARGET_NR_socket) static void print_socket(void *cpu_env, const struct syscallname *name, diff --git a/linux-user/strace.list b/linux-user/strace.list index 8e5303d03500..d0ea7f3464b8 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -568,13 +568,13 @@ { TARGET_NR_mknodat, "mknodat" , NULL, print_mknodat, NULL }, #endif #ifdef TARGET_NR_mlock -{ TARGET_NR_mlock, "mlock" , NULL, NULL, NULL }, +{ TARGET_NR_mlock, "mlock" , "%s(%p," TARGET_FMT_lu ")", NULL, NULL }, #endif #ifdef TARGET_NR_mlock2 { TARGET_NR_mlock2, "mlock2" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_mlockall -{ TARGET_NR_mlockall, "mlockall" , NULL, NULL, NULL }, +{ TARGET_NR_mlockall, "mlockall" , NULL, print_mlockall, NULL }, #endif #ifdef TARGET_NR_mmap { TARGET_NR_mmap, "mmap" , NULL, print_mmap, print_syscall_ret_addr }, @@ -637,10 +637,10 @@ { TARGET_NR_multiplexer, "multiplexer" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_munlock -{ TARGET_NR_munlock, "munlock" , NULL, NULL, NULL }, +{ TARGET_NR_munlock, "munlock" , "%s(%p," TARGET_FMT_lu ")", NULL, NULL }, #endif #ifdef TARGET_NR_munlockall -{ TARGET_NR_munlockall, "munlockall" , NULL, NULL, NULL }, +{ TARGET_NR_munlockall, "munlockall" , "%s()", NULL, NULL }, #endif #ifdef TARGET_NR_munmap { TARGET_NR_munmap, "munmap" , NULL, print_munmap, NULL }, diff --git a/linux-user/syscall.c b/linux-user/syscall.c index ec7192112e9d..027dea35af41 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -6975,12 +6975,18 @@ static inline int target_to_host_mlockall_arg(int arg) { int result = 0; - if (arg & TARGET_MLOCKALL_MCL_CURRENT) { + if (arg & TARGET_MCL_CURRENT) { result |= MCL_CURRENT; } - if (arg & TARGET_MLOCKALL_MCL_FUTURE) { + if (arg & TARGET_MCL_FUTURE) { result |= MCL_FUTURE; } +#ifdef MCL_ONFAULT + if (arg & TARGET_MCL_ONFAULT) { + result |= MCL_ONFAULT; + } +#endif + return result; } #endif diff --git a/linux-user/tilegx/target_syscall.h b/linux-user/tilegx/target_syscall.h index d731acdafaa0..8e9db734b88b 100644 --- a/linux-user/tilegx/target_syscall.h +++ b/linux-user/tilegx/target_syscall.h @@ -34,8 +34,9 @@ struct target_pt_regs { tilegx_reg_t pad[2]; }; -#define TARGET_MLOCKALL_MCL_CURRENT 1 -#define TARGET_MLOCKALL_MCL_FUTURE 2 +#define TARGET_MCL_CURRENT 1 +#define TARGET_MCL_FUTURE 2 +#define TARGET_MCL_ONFAULT 4 /* For faultnum */ #define TARGET_INT_SWINT_1 14 diff --git a/linux-user/x86_64/target_syscall.h b/linux-user/x86_64/target_syscall.h index 5e221e1d9ddc..3ecccb72be2d 100644 --- a/linux-user/x86_64/target_syscall.h +++ b/linux-user/x86_64/target_syscall.h @@ -101,7 +101,8 @@ struct target_msqid64_ds { #define TARGET_ARCH_GET_FS 0x1003 #define TARGET_ARCH_GET_GS 0x1004 #define TARGET_MINSIGSTKSZ 2048 -#define TARGET_MLOCKALL_MCL_CURRENT 1 -#define TARGET_MLOCKALL_MCL_FUTURE 2 +#define TARGET_MCL_CURRENT 1 +#define TARGET_MCL_FUTURE 2 +#define TARGET_MCL_ONFAULT 4 #endif /* X86_64_TARGET_SYSCALL_H */ diff --git a/linux-user/xtensa/target_syscall.h b/linux-user/xtensa/target_syscall.h index 3866dad84930..afc86a153fc0 100644 --- a/linux-user/xtensa/target_syscall.h +++ b/linux-user/xtensa/target_syscall.h @@ -43,7 +43,8 @@ struct target_pt_regs { xtensa_reg_t areg[16]; }; -#define TARGET_MLOCKALL_MCL_CURRENT 1 -#define TARGET_MLOCKALL_MCL_FUTURE 2 +#define TARGET_MCL_CURRENT 1 +#define TARGET_MCL_FUTURE 2 +#define TARGET_MCL_ONFAULT 4 #endif From patchwork Thu Aug 27 19:20:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 11741439 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D3B5C14E5 for ; Thu, 27 Aug 2020 19:21:25 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B1A1C207CD for ; Thu, 27 Aug 2020 19:21:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B1A1C207CD Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=vivier.eu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:59918 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kBNSe-0005Pr-PT for patchwork-qemu-devel@patchwork.kernel.org; Thu, 27 Aug 2020 15:21:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33372) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kBNRu-0003nl-11 for qemu-devel@nongnu.org; Thu, 27 Aug 2020 15:20:38 -0400 Received: from mout.kundenserver.de ([212.227.17.13]:60575) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kBNRs-00009t-4I for qemu-devel@nongnu.org; Thu, 27 Aug 2020 15:20:37 -0400 Received: from localhost.localdomain ([82.252.135.186]) by mrelayeu.kundenserver.de (mreue109 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MjjGX-1ksAzj22B9-00lGdp; Thu, 27 Aug 2020 21:20:32 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 07/18] linux-user: Add an api to print enumareted argument values with strace Date: Thu, 27 Aug 2020 21:20:07 +0200 Message-Id: <20200827192018.2442099-8-laurent@vivier.eu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200827192018.2442099-1-laurent@vivier.eu> References: <20200827192018.2442099-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:jqQMqOhtuR1A/Ay/ViJsseUcs9HDX+M+aq/wRRm2b7oNcoo5RUp 7VwYdPfef6idsPuniy6ussWApKpvx12z50IuCwR4/I0GOnDHfCYbbxtppDkdlN61ue4EO6A VscrwklMYMt/FV1uqAS9e8BCjmYSZsIliKjdIcrokFuK6PREoWh2IWSG1dw+88txJ0IhVXP x4EbSxaUCKzyLSBr6WhBQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:vDy07wQdTt8=:LJFdc7Cr1LvZvocuP5OsH1 zP9Fq3pkZiZpRbRBYm/R/gmsOtYKAFtILhlYC1RGbsJORG54xCFvfIYscUnhQXjhxfw/vm8F+ 38hVeayenUYODUWDXADQR/yWeb9lAStwfw5urH0a/nxgqITikSFM3EjIZG5UDY8fHsPaSz240 f2P4VluBoTh5/JM6SLbO2Xqxfx2Cou1FosIABSMg3F/vvNoBzuySYhWFSNTz2d5uBOAYyLRHd 5D80zHhVT7gfDn4ZOl1VJAoWo2CQW0G64+h+1QKSgU20F8p9i9yOTUPwxczIBEyR4XpgWg7Jr VXP6Tkrp9JzoMB7IYvXgOsH1/QCOPLNhcaU199vYThR30k6Q1kd/rMHthNTXYPm20d1t0RDIp HOUPOnVitzHHgQYLBpvJarypqly77o69IFQGuoR6YZa8/mzGL6Qma1PIJDkPLwrL0RACbd91h vYmIZ5TRy6nInvxLUStYiljCgesQsn1lVH2VDyLCxYDYOwcSLBlhT70ckZlI23qrHLA3uMGy4 +cvdRJXsDve0Soet1XaEjSaSl2Ye1X86O16Xk5IQZdJyinV7q/bGBDuBKNR8V0fkPJhMsgFB9 yEQIaLEBWcJ8n7FBeO+FKzDdA4pivKq/6/x5fk2fNNRGNVGfnAMaaw+5nIhTBQ+XmSo14Kbpn Kflsm/irUHKktNYd363EENGFomTVTcNQ7bnG1X4UweEtJMRbxA15VRdq14deSTInGpuzvt+KW sRtblsIJFNa58wr7Q9a9d2iH6y1OP9FfYCRhMbuTq75NmQ0yE4qPJXTN9Bw0JedM0vOKuzMDg +KhA2Xcr4dPXvBEEpdHJMRRkkOYP/xgEDRzHl0DsXThpEkdmpmL31spewGeGyQlplkfFV36 Received-SPF: none client-ip=212.227.17.13; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/27 15:20:34 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] 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, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Riku Voipio , Laurent Vivier , Filip Bozuta Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Filip Bozuta This patch introduces a type 'struct enums' and function 'print_enums()' that can be used to print enumerated argument values of some syscalls in strace. This can be used in future strace implementations. Also, macros 'ENUM_GENERIC()', 'ENUM_TARGET()' and 'ENUM_END', are introduced to enable automatic generation of aproppriate enumarated values and their repsective string representations (these macros are exactly the same as 'FLAG_GENERIC()', 'FLAG_TARGET()' and 'FLAG_END'). Future patches are planned to modify all existing print functions in 'strace.c' that print arguments of syscalls with enumerated values to use this new api. Signed-off-by: Filip Bozuta Reviewed-by: Laurent Vivier Message-Id: <20200811164553.27713-5-Filip.Bozuta@syrmia.com> Signed-off-by: Laurent Vivier --- linux-user/strace.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/linux-user/strace.c b/linux-user/strace.c index 4ac54ecffe9c..d0731b888d29 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -52,9 +52,23 @@ struct flags { /* end of flags array */ #define FLAG_END { 0, NULL } +/* Structure used to translate enumerated values into strings */ +struct enums { + abi_long e_value; /* enum value */ + const char *e_string; /* stringified enum */ +}; + +/* common enums for all architectures */ +#define ENUM_GENERIC(name) { name, #name } +/* target specific enums */ +#define ENUM_TARGET(name) { TARGET_ ## name, #name } +/* end of enums array */ +#define ENUM_END { 0, NULL } + UNUSED static const char *get_comma(int); UNUSED static void print_pointer(abi_long, int); UNUSED static void print_flags(const struct flags *, abi_long, int); +UNUSED static void print_enums(const struct enums *, abi_long, int); UNUSED static void print_at_dirfd(abi_long, int); UNUSED static void print_file_mode(abi_long, int); UNUSED static void print_open_flags(abi_long, int); @@ -1252,6 +1266,23 @@ print_flags(const struct flags *f, abi_long flags, int last) } } +static void +print_enums(const struct enums *e, abi_long enum_arg, int last) +{ + for (; e->e_string != NULL; e++) { + if (e->e_value == enum_arg) { + qemu_log("%s", e->e_string); + break; + } + } + + if (e->e_string == NULL) { + qemu_log("%#x", (unsigned int)enum_arg); + } + + qemu_log("%s", get_comma(last)); +} + static void print_at_dirfd(abi_long dirfd, int last) { From patchwork Thu Aug 27 19:20:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 11741473 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8EF9514F6 for ; Thu, 27 Aug 2020 19:26:57 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5D134207CD for ; Thu, 27 Aug 2020 19:26:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5D134207CD Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=vivier.eu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:59688 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kBNY0-00008d-JG for patchwork-qemu-devel@patchwork.kernel.org; Thu, 27 Aug 2020 15:26:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33486) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kBNS2-00049B-Ly for qemu-devel@nongnu.org; Thu, 27 Aug 2020 15:20:46 -0400 Received: from mout.kundenserver.de ([217.72.192.75]:49831) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kBNRz-0000EV-5c for qemu-devel@nongnu.org; Thu, 27 Aug 2020 15:20:46 -0400 Received: from localhost.localdomain ([82.252.135.186]) by mrelayeu.kundenserver.de (mreue109 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MWRZt-1k5jFC2c3v-00Xsar; Thu, 27 Aug 2020 21:20:34 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 08/18] linux-user: Add strace support for printing arguments of some clock and time functions Date: Thu, 27 Aug 2020 21:20:08 +0200 Message-Id: <20200827192018.2442099-9-laurent@vivier.eu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200827192018.2442099-1-laurent@vivier.eu> References: <20200827192018.2442099-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:NB9938P+5opmnSzFZMuNXxDKGGhWCw6l5FGZtDqM5ZSbPCAW559 3FnRcJGlKwt2cZHDrEkTtdsNLw+ZzLbmvI8eRWhe96Mojn+zUOlMWv8vXhSE+I/P7t+G91B 9y7PWpWOd/p/xV+VQSrkQf77d6J2FXxmmRVNhXlRAXSCfUGGCrJ2IxpNPD2b/qQhW7dd0tA A1sqjTjolCreJ6Dtvst7A== X-UI-Out-Filterresults: notjunk:1;V03:K0:ZQX412ckV8k=:o9DBYbd/avRQ2Cdacs7nug /OqYFE5LUbnRbGUOrl+VPakdMc8YVCXG445Or1vO0xWAfLN06qs9j8N/bagy/gUtJBFY/opOD Rtpw1wezpEYDbFOGkkDFZc2tlr2GJ/dj+JSDzxH7bZ584eNRX6cAMwT2ejOWfy2w20BnJ4bGv w1GWCHRlB/sHAyuWfczTR7oLLTCPdJkWM2xbbal+8bH8kBWb4ichj6SiJ9nDxpghl5khfpV2e xYefPb6vTcLMEcb58GXzl6AKL2uz1nWVsk6CxZKcFWmX2CsC1FHkYwnmCoaSkPrWUn4Gcx48s akOYR+jqyhq6TwTDrTHD5FRD1UKLyUzgzwiF7ZBWYUvduREcndbtxUuo3j4SWmgiGmqeT/c3C KT9KbBhs545gDWYxqv116TRUROJzmON+Q6yKvLcnuCvy5PsuXHIjxlpuveLQw1O3TOB2F1YrH 5haaxfnFHWfNhJVKFTqLq8IVOAWW6Iq5SJwqZPtebPPOpAxyodN6ML8OBejJ4do8CTEGATLnH fADa63VVjv7SGyOP8T9GixCC1k8Z5PaLpC4XU+QzTmP/ZMO/DUoX/E5Tb8S9X2WhGbvXzjhWy nSNSl4uybzXNAh+QGUb+PHRBESAn0R77Z3cQtaf0QFo7Ai84mXnbyTMwwbpVFP9KtrEYvPGYI Q+GEyHem+g7XHugGNFJQz+bOAmq8BjsY5iDknbn3W6Ehc6FH1A+Q716gvA1GDDED6Usb4YA1r tQ7NO5dPOdYUh3VmyfAbL2imvQpv/UUO3wTr7pxOwe76/tDgdvKtqFjkBCcHPglfr9BO32sWi ZGVu1pSr1xAffWolRJKD0wMUgMI3E9X7yHBSV+D679zAyAz4xL6xTze6YQotINqhrUopCSJ Received-SPF: none client-ip=217.72.192.75; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/27 15:20:36 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] 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, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Riku Voipio , Laurent Vivier , Filip Bozuta Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Filip Bozuta This patch implements strace argument printing functionality for following syscalls: * clock_getres, clock_gettime, clock_settime - clock and time functions int clock_getres(clockid_t clockid, struct timespec *res) int clock_gettime(clockid_t clockid, struct timespec *tp) int clock_settime(clockid_t clockid, const struct timespec *tp) man page: https://man7.org/linux/man-pages/man2/clock_getres.2.html * gettimeofday - get time int gettimeofday(struct timeval *tv, struct timezone *tz) man page: https://man7.org/linux/man-pages/man2/gettimeofday.2.html * getitimer, setitimer - get or set value of an interval timer int getitimer(int which, struct itimerval *curr_value) int setitimer(int which, const struct itimerval *new_value, struct itimerval *old_value) man page: https://man7.org/linux/man-pages/man2/getitimer.2.html Implementation notes: All of the syscalls have some structue types as argument types and thus a separate printing function was stated in file "strace.list" for each of them. All of these functions use existing functions for their appropriate structure types ("print_timeval()" and "print_timezone()"). Functions "print_timespec()" and "print_itimerval()" were added in this patch so that they can be used to print types "struct timespec" and "struct itimerval" used by some of the syscalls. Function "print_itimerval()" uses the existing function "print_timeval()" to print fields of the structure "struct itimerval" that are of type "struct timeval". Function "print_enums()", which was introduced in the previous patch, is used to print the interval timer type which is the first argument of "getitimer()" and "setitimer()". Also, this function is used to print the clock id which is the first argument of "clock_getres()" and "clock_gettime()". For that reason, the existing function "print_clockid()" was removed in this patch. Existing function "print_clock_adjtime()" was also changed for this reason to use "print_enums()". The existing function "print_timeval()" was changed a little so that it prints the field names beside the values. Syscalls "clock_getres()" and "clock_gettime()" have the same number and types of arguments and thus their print functions "print_clock_getres" and "print_clock_gettime" share a common definition in file "strace.c". Signed-off-by: Filip Bozuta Reviewed-by: Laurent Vivier Message-Id: <20200811164553.27713-6-Filip.Bozuta@syrmia.com> Signed-off-by: Laurent Vivier --- linux-user/strace.c | 287 +++++++++++++++++++++++++++++++---------- linux-user/strace.list | 17 ++- 2 files changed, 232 insertions(+), 72 deletions(-) diff --git a/linux-user/strace.c b/linux-user/strace.c index d0731b888d29..c7ef948b9451 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -78,7 +78,9 @@ UNUSED static void print_string(abi_long, int); UNUSED static void print_buf(abi_long addr, abi_long len, int last); UNUSED static void print_raw_param(const char *, abi_long, int); UNUSED static void print_timeval(abi_ulong, int); +UNUSED static void print_timespec(abi_ulong, int); UNUSED static void print_timezone(abi_ulong, int); +UNUSED static void print_itimerval(abi_ulong, int); UNUSED static void print_number(abi_long, int); UNUSED static void print_signal(abi_ulong, int); UNUSED static void print_sockaddr(abi_ulong, abi_long, int); @@ -582,69 +584,6 @@ print_fdset(int n, abi_ulong target_fds_addr) } #endif -#ifdef TARGET_NR_clock_adjtime -/* IDs of the various system clocks */ -#define TARGET_CLOCK_REALTIME 0 -#define TARGET_CLOCK_MONOTONIC 1 -#define TARGET_CLOCK_PROCESS_CPUTIME_ID 2 -#define TARGET_CLOCK_THREAD_CPUTIME_ID 3 -#define TARGET_CLOCK_MONOTONIC_RAW 4 -#define TARGET_CLOCK_REALTIME_COARSE 5 -#define TARGET_CLOCK_MONOTONIC_COARSE 6 -#define TARGET_CLOCK_BOOTTIME 7 -#define TARGET_CLOCK_REALTIME_ALARM 8 -#define TARGET_CLOCK_BOOTTIME_ALARM 9 -#define TARGET_CLOCK_SGI_CYCLE 10 -#define TARGET_CLOCK_TAI 11 - -static void -print_clockid(int clockid, int last) -{ - switch (clockid) { - case TARGET_CLOCK_REALTIME: - qemu_log("CLOCK_REALTIME"); - break; - case TARGET_CLOCK_MONOTONIC: - qemu_log("CLOCK_MONOTONIC"); - break; - case TARGET_CLOCK_PROCESS_CPUTIME_ID: - qemu_log("CLOCK_PROCESS_CPUTIME_ID"); - break; - case TARGET_CLOCK_THREAD_CPUTIME_ID: - qemu_log("CLOCK_THREAD_CPUTIME_ID"); - break; - case TARGET_CLOCK_MONOTONIC_RAW: - qemu_log("CLOCK_MONOTONIC_RAW"); - break; - case TARGET_CLOCK_REALTIME_COARSE: - qemu_log("CLOCK_REALTIME_COARSE"); - break; - case TARGET_CLOCK_MONOTONIC_COARSE: - qemu_log("CLOCK_MONOTONIC_COARSE"); - break; - case TARGET_CLOCK_BOOTTIME: - qemu_log("CLOCK_BOOTTIME"); - break; - case TARGET_CLOCK_REALTIME_ALARM: - qemu_log("CLOCK_REALTIME_ALARM"); - break; - case TARGET_CLOCK_BOOTTIME_ALARM: - qemu_log("CLOCK_BOOTTIME_ALARM"); - break; - case TARGET_CLOCK_SGI_CYCLE: - qemu_log("CLOCK_SGI_CYCLE"); - break; - case TARGET_CLOCK_TAI: - qemu_log("CLOCK_TAI"); - break; - default: - qemu_log("%d", clockid); - break; - } - qemu_log("%s", get_comma(last)); -} -#endif - /* * Sysycall specific output functions */ @@ -843,6 +782,81 @@ print_syscall_ret_adjtimex(void *cpu_env, const struct syscallname *name, } #endif +#if defined(TARGET_NR_clock_gettime) || defined(TARGET_NR_clock_getres) +static void +print_syscall_ret_clock_gettime(void *cpu_env, 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) +{ + if (!print_syscall_err(ret)) { + qemu_log(TARGET_ABI_FMT_ld, ret); + qemu_log(" ("); + print_timespec(arg1, 1); + qemu_log(")"); + } + + qemu_log("\n"); +} +#define print_syscall_ret_clock_getres print_syscall_ret_clock_gettime +#endif + +#ifdef TARGET_NR_gettimeofday +static void +print_syscall_ret_gettimeofday(void *cpu_env, 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) +{ + if (!print_syscall_err(ret)) { + qemu_log(TARGET_ABI_FMT_ld, ret); + qemu_log(" ("); + print_timeval(arg0, 0); + print_timezone(arg1, 1); + qemu_log(")"); + } + + qemu_log("\n"); +} +#endif + +#ifdef TARGET_NR_getitimer +static void +print_syscall_ret_getitimer(void *cpu_env, 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) +{ + if (!print_syscall_err(ret)) { + qemu_log(TARGET_ABI_FMT_ld, ret); + qemu_log(" ("); + print_itimerval(arg1, 1); + qemu_log(")"); + } + + qemu_log("\n"); +} +#endif + + +#ifdef TARGET_NR_getitimer +static void +print_syscall_ret_setitimer(void *cpu_env, 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) +{ + if (!print_syscall_err(ret)) { + qemu_log(TARGET_ABI_FMT_ld, ret); + qemu_log(" (old_value = "); + print_itimerval(arg2, 1); + qemu_log(")"); + } + + qemu_log("\n"); +} +#endif + #if defined(TARGET_NR_listxattr) || defined(TARGET_NR_llistxattr) \ || defined(TARGGET_NR_flistxattr) static void @@ -1221,6 +1235,43 @@ UNUSED static struct flags mlockall_flags[] = { FLAG_END, }; +/* IDs of the various system clocks */ +#define TARGET_CLOCK_REALTIME 0 +#define TARGET_CLOCK_MONOTONIC 1 +#define TARGET_CLOCK_PROCESS_CPUTIME_ID 2 +#define TARGET_CLOCK_THREAD_CPUTIME_ID 3 +#define TARGET_CLOCK_MONOTONIC_RAW 4 +#define TARGET_CLOCK_REALTIME_COARSE 5 +#define TARGET_CLOCK_MONOTONIC_COARSE 6 +#define TARGET_CLOCK_BOOTTIME 7 +#define TARGET_CLOCK_REALTIME_ALARM 8 +#define TARGET_CLOCK_BOOTTIME_ALARM 9 +#define TARGET_CLOCK_SGI_CYCLE 10 +#define TARGET_CLOCK_TAI 11 + +UNUSED static struct enums clockids[] = { + ENUM_TARGET(CLOCK_REALTIME), + ENUM_TARGET(CLOCK_MONOTONIC), + ENUM_TARGET(CLOCK_PROCESS_CPUTIME_ID), + ENUM_TARGET(CLOCK_THREAD_CPUTIME_ID), + ENUM_TARGET(CLOCK_MONOTONIC_RAW), + ENUM_TARGET(CLOCK_REALTIME_COARSE), + ENUM_TARGET(CLOCK_MONOTONIC_COARSE), + ENUM_TARGET(CLOCK_BOOTTIME), + ENUM_TARGET(CLOCK_REALTIME_ALARM), + ENUM_TARGET(CLOCK_BOOTTIME_ALARM), + ENUM_TARGET(CLOCK_SGI_CYCLE), + ENUM_TARGET(CLOCK_TAI), + ENUM_END, +}; + +UNUSED static struct enums itimer_types[] = { + ENUM_GENERIC(ITIMER_REAL), + ENUM_GENERIC(ITIMER_VIRTUAL), + ENUM_GENERIC(ITIMER_PROF), + ENUM_END, +}; + /* * print_xxx utility functions. These are used to print syscall * parameters in certain format. All of these have parameter @@ -1439,13 +1490,34 @@ print_timeval(abi_ulong tv_addr, int last) print_pointer(tv_addr, last); return; } - qemu_log("{" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld "}%s", - tswapal(tv->tv_sec), tswapal(tv->tv_usec), get_comma(last)); + qemu_log("{tv_sec = " TARGET_ABI_FMT_ld + ",tv_usec = " TARGET_ABI_FMT_ld "}%s", + tswapal(tv->tv_sec), tswapal(tv->tv_usec), get_comma(last)); unlock_user(tv, tv_addr, 0); } else qemu_log("NULL%s", get_comma(last)); } +static void +print_timespec(abi_ulong ts_addr, int last) +{ + if (ts_addr) { + struct target_timespec *ts; + + ts = lock_user(VERIFY_READ, ts_addr, sizeof(*ts), 1); + if (!ts) { + print_pointer(ts_addr, last); + return; + } + qemu_log("{tv_sec = " TARGET_ABI_FMT_ld + ",tv_nsec = " TARGET_ABI_FMT_ld "}%s", + tswapal(ts->tv_sec), tswapal(ts->tv_nsec), get_comma(last)); + unlock_user(ts, ts_addr, 0); + } else { + qemu_log("NULL%s", get_comma(last)); + } +} + static void print_timezone(abi_ulong tz_addr, int last) { @@ -1465,6 +1537,22 @@ print_timezone(abi_ulong tz_addr, int last) } } +static void +print_itimerval(abi_ulong it_addr, int last) +{ + if (it_addr) { + qemu_log("{it_interval="); + print_timeval(it_addr + + offsetof(struct target_itimerval, it_interval), 0); + qemu_log("it_value="); + print_timeval(it_addr + + offsetof(struct target_itimerval, it_value), 0); + qemu_log("}%s", get_comma(last)); + } else { + qemu_log("NULL%s", get_comma(last)); + } +} + #undef UNUSED #ifdef TARGET_NR_accept @@ -1577,7 +1665,7 @@ print_clock_adjtime(void *cpu_env, const struct syscallname *name, abi_long arg3, abi_long arg4, abi_long arg5) { print_syscall_prologue(name); - print_clockid(arg0, 0); + print_enums(clockids, arg0, 0); print_pointer(arg1, 1); print_syscall_epilogue(name); } @@ -1907,6 +1995,19 @@ print_futimesat(void *cpu_env, const struct syscallname *name, } #endif +#ifdef TARGET_NR_gettimeofday +static void +print_gettimeofday(void *cpu_env, 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_pointer(arg0, 0); + print_pointer(arg1, 1); + print_syscall_epilogue(name); +} +#endif + #ifdef TARGET_NR_settimeofday static void print_settimeofday(void *cpu_env, const struct syscallname *name, @@ -1920,6 +2021,60 @@ print_settimeofday(void *cpu_env, const struct syscallname *name, } #endif +#if defined(TARGET_NR_clock_gettime) || defined(TARGET_NR_clock_getres) +static void +print_clock_gettime(void *cpu_env, 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_enums(clockids, arg0, 0); + print_pointer(arg1, 1); + print_syscall_epilogue(name); +} +#define print_clock_getres print_clock_gettime +#endif + +#ifdef TARGET_NR_clock_settime +static void +print_clock_settime(void *cpu_env, 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_enums(clockids, arg0, 0); + print_timespec(arg1, 1); + print_syscall_epilogue(name); +} +#endif + +#ifdef TARGET_NR_getitimer +static void +print_getitimer(void *cpu_env, 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_enums(itimer_types, arg0, 0); + print_pointer(arg1, 1); + print_syscall_epilogue(name); +} +#endif + +#ifdef TARGET_NR_setitimer +static void +print_setitimer(void *cpu_env, 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_enums(itimer_types, arg0, 0); + print_itimerval(arg1, 0); + print_pointer(arg2, 1); + print_syscall_epilogue(name); +} +#endif + #ifdef TARGET_NR_link static void print_link(void *cpu_env, const struct syscallname *name, diff --git a/linux-user/strace.list b/linux-user/strace.list index d0ea7f3464b8..084048ab96dd 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -83,16 +83,18 @@ { TARGET_NR_clock_adjtime, "clock_adjtime" , NULL, print_clock_adjtime, NULL }, #endif #ifdef TARGET_NR_clock_getres -{ TARGET_NR_clock_getres, "clock_getres" , NULL, NULL, NULL }, +{ TARGET_NR_clock_getres, "clock_getres" , NULL, print_clock_getres, + print_syscall_ret_clock_getres }, #endif #ifdef TARGET_NR_clock_gettime -{ TARGET_NR_clock_gettime, "clock_gettime" , NULL, NULL, NULL }, +{ TARGET_NR_clock_gettime, "clock_gettime" , NULL, print_clock_gettime, + print_syscall_ret_clock_gettime }, #endif #ifdef TARGET_NR_clock_nanosleep { TARGET_NR_clock_nanosleep, "clock_nanosleep" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_clock_settime -{ TARGET_NR_clock_settime, "clock_settime" , NULL, NULL, NULL }, +{ TARGET_NR_clock_settime, "clock_settime" , NULL, print_clock_settime, NULL }, #endif #ifdef TARGET_NR_clone { TARGET_NR_clone, "clone" , NULL, print_clone, NULL }, @@ -315,7 +317,8 @@ { TARGET_NR_gethostname, "gethostname" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_getitimer -{ TARGET_NR_getitimer, "getitimer" , NULL, NULL, NULL }, +{ TARGET_NR_getitimer, "getitimer" , NULL, print_getitimer, + print_syscall_ret_getitimer }, #endif #ifdef TARGET_NR_get_kernel_syms { TARGET_NR_get_kernel_syms, "get_kernel_syms" , NULL, NULL, NULL }, @@ -388,7 +391,8 @@ { TARGET_NR_gettid, "gettid" , "%s()", NULL, NULL }, #endif #ifdef TARGET_NR_gettimeofday -{ TARGET_NR_gettimeofday, "gettimeofday" , NULL, NULL, NULL }, +{ TARGET_NR_gettimeofday, "gettimeofday" , NULL, print_gettimeofday, + print_syscall_ret_gettimeofday }, #endif #ifdef TARGET_NR_getuid { TARGET_NR_getuid, "getuid" , "%s()", NULL, NULL }, @@ -1291,7 +1295,8 @@ { TARGET_NR_sethostname, "sethostname" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_setitimer -{ TARGET_NR_setitimer, "setitimer" , NULL, NULL, NULL }, +{ TARGET_NR_setitimer, "setitimer" , NULL, print_setitimer, + print_syscall_ret_setitimer }, #endif #ifdef TARGET_NR_set_mempolicy { TARGET_NR_set_mempolicy, "set_mempolicy" , NULL, NULL, NULL }, From patchwork Thu Aug 27 19:20:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 11741465 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ED39614F6 for ; Thu, 27 Aug 2020 19:25:09 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9A583207CD for ; Thu, 27 Aug 2020 19:25:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9A583207CD Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=vivier.eu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:51324 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kBNWG-00056X-Ox for patchwork-qemu-devel@patchwork.kernel.org; Thu, 27 Aug 2020 15:25:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33462) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kBNS0-00044C-Jg for qemu-devel@nongnu.org; Thu, 27 Aug 2020 15:20:44 -0400 Received: from mout.kundenserver.de ([217.72.192.75]:33051) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kBNRv-0000Bk-Ij for qemu-devel@nongnu.org; Thu, 27 Aug 2020 15:20:44 -0400 Received: from localhost.localdomain ([82.252.135.186]) by mrelayeu.kundenserver.de (mreue109 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MMGZM-1jvUUW1fJG-00JFzM; Thu, 27 Aug 2020 21:20:36 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 09/18] linux-user: Add generic 'termbits.h' for some archs Date: Thu, 27 Aug 2020 21:20:09 +0200 Message-Id: <20200827192018.2442099-10-laurent@vivier.eu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200827192018.2442099-1-laurent@vivier.eu> References: <20200827192018.2442099-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:BvCxYqimqDBWiFFj01f1pvoV7PvJ2d7BJxJUzCwqb48AW66gFEN jk8pmo5H8b+r7qQaM48bthztsRnsaRD+5MRlzxurpSR0lDiRqn02vmsxEVM1NvtM6m2gSk3 H8Xfi+9S5/5b2XCvYHwNAO95oMYEOVFb0Mb+HC2gRZgRXIB2/ov6iolvRCd+lA5enJA8003 TIJDKDDRxjde+WR7srNDA== X-UI-Out-Filterresults: notjunk:1;V03:K0:Vam/Sq+HGoo=:7lP1h2zmN9PXa/dKhAjYu9 BezZnFGs9ftO1vOSPKi+TpvifY9OdWhVr6W1EZsBn7QqoLfQjDgeGd4dDWIbw/TrrxN9nqf5H 2IWx7g0qi6/b7GveQJDWVIgQkn8dRPwIVmaA5iz4WoXOkYvAvDmpxqeihaGBBIlILeW0ki6gy 4DlPbKfyriobHgJ2bZa0yu9FbhIWYzhhSEukjaVdE5PjsmUTJYRT31e5GP9wknfcdnzIoHZFC 5oegeXmTsSGEYHgmoosTP/z6vjlZXk2tDO2OvFsSeoBb+wMAtZOZG18B0LBPFGisGwwSCrcfZ AlAsQaEGwLLMrzqCOU70pd2RqZzaPM9ts6Qsz66p6okXX0MfpJt8ldAvC7MrM58x5ytfvUTAE qjNXIgNSccwn5u//ramqrlSQ5QiACLKe09imFxjpRWwqvRg5H2FzRvymtxnKoIsvyEglHpowz oKodMkWRP2eMxEDUovzx6Yyy9809YPBrxEpXk5JSZ8vtrzXShNVKVIsqaH0JQCE1R3aqxXSz0 M/rIAXmLfvvnNv3vMJDjCB9CoaIzOauPAyHjA4Pz9JBq7ZfcJhR4ZeVTGa3EStRoLwbWDlUGV cxrtoUGPasWoVf+A93jV79v7nw7uIMh1gqOqTFWpGdq0MIxwdl2hIrrGZRBt+0KQS36MoIJ2u Wf15/EWcs5QYGNSECdNKsFOtuWdKjDf3crAKJUzihLX9mtzmsWosY6i/6Vv9QmXPERrZoZStv GMY7wHhPlondZltMJCmfWVCFkotf7NtMyrtFe8F/ZcD9zqRDRv+xRmupSXvdQcYQvoWRxsUE+ B29KlUa3r7wH/CYGOzKldUPgv7WTxcIPbz6agH2Qcy8PdvhkYIjgbpEUu+8wAAy2lfCV3+H Received-SPF: none client-ip=217.72.192.75; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/27 15:20:36 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] 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, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Riku Voipio , Laurent Vivier , Filip Bozuta Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Filip Bozuta This patch introduces a generic 'termbits.h' file for following archs: 'aarch64', 'arm', 'i386, 'm68k', 'microblaze', 'nios2', 'openrisc', 'riscv', 's390x', 'x86_64'. Since all of these archs have the same termios flag values and same ioctl_tty numbers, there is no need for a separate 'termbits.h' file for each one of them. For that reason one generic 'termbits.h' file was added for all of them and an '#include' directive was added for this generic file in every arch 'termbits.h' file. Also, some of the flag values that were missing were added in this generic file so that it matches the generic 'termibts.h' and 'ioctls.h' files from the kernel: 'asm-generic/termbits.h' and 'asm-generic/ioctls.h'. Signed-off-by: Filip Bozuta Reviewed-by: Laurent Vivier Message-Id: <20200723210233.349690-2-Filip.Bozuta@syrmia.com> Signed-off-by: Laurent Vivier --- linux-user/aarch64/termbits.h | 228 +--------------------- linux-user/arm/termbits.h | 223 +--------------------- linux-user/generic/termbits.h | 318 +++++++++++++++++++++++++++++++ linux-user/i386/termbits.h | 233 +--------------------- linux-user/m68k/termbits.h | 234 +---------------------- linux-user/microblaze/termbits.h | 220 +-------------------- linux-user/nios2/termbits.h | 228 +--------------------- linux-user/openrisc/termbits.h | 302 +---------------------------- linux-user/riscv/termbits.h | 228 +--------------------- linux-user/s390x/termbits.h | 289 +--------------------------- linux-user/tilegx/termbits.h | 276 +-------------------------- linux-user/x86_64/termbits.h | 254 +----------------------- 12 files changed, 329 insertions(+), 2704 deletions(-) create mode 100644 linux-user/generic/termbits.h diff --git a/linux-user/aarch64/termbits.h b/linux-user/aarch64/termbits.h index 0ab448d090e7..b1d4f4fedbcb 100644 --- a/linux-user/aarch64/termbits.h +++ b/linux-user/aarch64/termbits.h @@ -1,227 +1 @@ -/* from asm/termbits.h */ -/* NOTE: exactly the same as i386 */ - -#ifndef LINUX_USER_AARCH64_TERMBITS_H -#define LINUX_USER_AARCH64_TERMBITS_H - -#define TARGET_NCCS 19 - -struct target_termios { - unsigned int c_iflag; /* input mode flags */ - unsigned int c_oflag; /* output mode flags */ - unsigned int c_cflag; /* control mode flags */ - unsigned int c_lflag; /* local mode flags */ - unsigned char c_line; /* line discipline */ - unsigned char c_cc[TARGET_NCCS]; /* control characters */ -}; - -/* c_iflag bits */ -#define TARGET_IGNBRK 0000001 -#define TARGET_BRKINT 0000002 -#define TARGET_IGNPAR 0000004 -#define TARGET_PARMRK 0000010 -#define TARGET_INPCK 0000020 -#define TARGET_ISTRIP 0000040 -#define TARGET_INLCR 0000100 -#define TARGET_IGNCR 0000200 -#define TARGET_ICRNL 0000400 -#define TARGET_IUCLC 0001000 -#define TARGET_IXON 0002000 -#define TARGET_IXANY 0004000 -#define TARGET_IXOFF 0010000 -#define TARGET_IMAXBEL 0020000 -#define TARGET_IUTF8 0040000 - -/* c_oflag bits */ -#define TARGET_OPOST 0000001 -#define TARGET_OLCUC 0000002 -#define TARGET_ONLCR 0000004 -#define TARGET_OCRNL 0000010 -#define TARGET_ONOCR 0000020 -#define TARGET_ONLRET 0000040 -#define TARGET_OFILL 0000100 -#define TARGET_OFDEL 0000200 -#define TARGET_NLDLY 0000400 -#define TARGET_NL0 0000000 -#define TARGET_NL1 0000400 -#define TARGET_CRDLY 0003000 -#define TARGET_CR0 0000000 -#define TARGET_CR1 0001000 -#define TARGET_CR2 0002000 -#define TARGET_CR3 0003000 -#define TARGET_TABDLY 0014000 -#define TARGET_TAB0 0000000 -#define TARGET_TAB1 0004000 -#define TARGET_TAB2 0010000 -#define TARGET_TAB3 0014000 -#define TARGET_XTABS 0014000 -#define TARGET_BSDLY 0020000 -#define TARGET_BS0 0000000 -#define TARGET_BS1 0020000 -#define TARGET_VTDLY 0040000 -#define TARGET_VT0 0000000 -#define TARGET_VT1 0040000 -#define TARGET_FFDLY 0100000 -#define TARGET_FF0 0000000 -#define TARGET_FF1 0100000 - -/* c_cflag bit meaning */ -#define TARGET_CBAUD 0010017 -#define TARGET_B0 0000000 /* hang up */ -#define TARGET_B50 0000001 -#define TARGET_B75 0000002 -#define TARGET_B110 0000003 -#define TARGET_B134 0000004 -#define TARGET_B150 0000005 -#define TARGET_B200 0000006 -#define TARGET_B300 0000007 -#define TARGET_B600 0000010 -#define TARGET_B1200 0000011 -#define TARGET_B1800 0000012 -#define TARGET_B2400 0000013 -#define TARGET_B4800 0000014 -#define TARGET_B9600 0000015 -#define TARGET_B19200 0000016 -#define TARGET_B38400 0000017 -#define TARGET_EXTA B19200 -#define TARGET_EXTB B38400 -#define TARGET_CSIZE 0000060 -#define TARGET_CS5 0000000 -#define TARGET_CS6 0000020 -#define TARGET_CS7 0000040 -#define TARGET_CS8 0000060 -#define TARGET_CSTOPB 0000100 -#define TARGET_CREAD 0000200 -#define TARGET_PARENB 0000400 -#define TARGET_PARODD 0001000 -#define TARGET_HUPCL 0002000 -#define TARGET_CLOCAL 0004000 -#define TARGET_CBAUDEX 0010000 -#define TARGET_B57600 0010001 -#define TARGET_B115200 0010002 -#define TARGET_B230400 0010003 -#define TARGET_B460800 0010004 -#define TARGET_CIBAUD 002003600000 /* input baud rate (not used) */ -#define TARGET_CMSPAR 010000000000 /* mark or space (stick) parity */ -#define TARGET_CRTSCTS 020000000000 /* flow control */ - -/* c_lflag bits */ -#define TARGET_ISIG 0000001 -#define TARGET_ICANON 0000002 -#define TARGET_XCASE 0000004 -#define TARGET_ECHO 0000010 -#define TARGET_ECHOE 0000020 -#define TARGET_ECHOK 0000040 -#define TARGET_ECHONL 0000100 -#define TARGET_NOFLSH 0000200 -#define TARGET_TOSTOP 0000400 -#define TARGET_ECHOCTL 0001000 -#define TARGET_ECHOPRT 0002000 -#define TARGET_ECHOKE 0004000 -#define TARGET_FLUSHO 0010000 -#define TARGET_PENDIN 0040000 -#define TARGET_IEXTEN 0100000 - -/* c_cc character offsets */ -#define TARGET_VINTR 0 -#define TARGET_VQUIT 1 -#define TARGET_VERASE 2 -#define TARGET_VKILL 3 -#define TARGET_VEOF 4 -#define TARGET_VTIME 5 -#define TARGET_VMIN 6 -#define TARGET_VSWTC 7 -#define TARGET_VSTART 8 -#define TARGET_VSTOP 9 -#define TARGET_VSUSP 10 -#define TARGET_VEOL 11 -#define TARGET_VREPRINT 12 -#define TARGET_VDISCARD 13 -#define TARGET_VWERASE 14 -#define TARGET_VLNEXT 15 -#define TARGET_VEOL2 16 - -/* ioctls */ - -#define TARGET_TCGETS 0x5401 -#define TARGET_TCSETS 0x5402 -#define TARGET_TCSETSW 0x5403 -#define TARGET_TCSETSF 0x5404 -#define TARGET_TCGETA 0x5405 -#define TARGET_TCSETA 0x5406 -#define TARGET_TCSETAW 0x5407 -#define TARGET_TCSETAF 0x5408 -#define TARGET_TCSBRK 0x5409 -#define TARGET_TCXONC 0x540A -#define TARGET_TCFLSH 0x540B - -#define TARGET_TIOCEXCL 0x540C -#define TARGET_TIOCNXCL 0x540D -#define TARGET_TIOCSCTTY 0x540E -#define TARGET_TIOCGPGRP 0x540F -#define TARGET_TIOCSPGRP 0x5410 -#define TARGET_TIOCOUTQ 0x5411 -#define TARGET_TIOCSTI 0x5412 -#define TARGET_TIOCGWINSZ 0x5413 -#define TARGET_TIOCSWINSZ 0x5414 -#define TARGET_TIOCMGET 0x5415 -#define TARGET_TIOCMBIS 0x5416 -#define TARGET_TIOCMBIC 0x5417 -#define TARGET_TIOCMSET 0x5418 -#define TARGET_TIOCGSOFTCAR 0x5419 -#define TARGET_TIOCSSOFTCAR 0x541A -#define TARGET_FIONREAD 0x541B -#define TARGET_TIOCINQ TARGET_FIONREAD -#define TARGET_TIOCLINUX 0x541C -#define TARGET_TIOCCONS 0x541D -#define TARGET_TIOCGSERIAL 0x541E -#define TARGET_TIOCSSERIAL 0x541F -#define TARGET_TIOCPKT 0x5420 -#define TARGET_FIONBIO 0x5421 -#define TARGET_TIOCNOTTY 0x5422 -#define TARGET_TIOCSETD 0x5423 -#define TARGET_TIOCGETD 0x5424 -#define TARGET_TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */ -#define TARGET_TIOCTTYGSTRUCT 0x5426 /* For debugging only */ -#define TARGET_TIOCSBRK 0x5427 /* BSD compatibility */ -#define TARGET_TIOCCBRK 0x5428 /* BSD compatibility */ -#define TARGET_TIOCGSID 0x5429 /* Return the session ID of FD */ -#define TARGET_TIOCGPTN TARGET_IOR('T', 0x30, unsigned int) - /* Get Pty Number (of pty-mux device) */ -#define TARGET_TIOCSPTLCK TARGET_IOW('T', 0x31, int) - /* Lock/unlock Pty */ -#define TARGET_TIOCGPTPEER TARGET_IO('T', 0x41) - /* Safely open the slave */ - -#define TARGET_FIONCLEX 0x5450 /* these numbers need to be adjusted. */ -#define TARGET_FIOCLEX 0x5451 -#define TARGET_FIOASYNC 0x5452 -#define TARGET_TIOCSERCONFIG 0x5453 -#define TARGET_TIOCSERGWILD 0x5454 -#define TARGET_TIOCSERSWILD 0x5455 -#define TARGET_TIOCGLCKTRMIOS 0x5456 -#define TARGET_TIOCSLCKTRMIOS 0x5457 -#define TARGET_TIOCSERGSTRUCT 0x5458 /* For debugging only */ -#define TARGET_TIOCSERGETLSR 0x5459 /* Get line status register */ -#define TARGET_TIOCSERGETMULTI 0x545A /* Get multiport config */ -#define TARGET_TIOCSERSETMULTI 0x545B /* Set multiport config */ - -#define TARGET_TIOCMIWAIT 0x545C - /* wait for a change on serial input line(s) */ -#define TARGET_TIOCGICOUNT 0x545D - /* read serial port inline interrupt counts */ -#define TARGET_TIOCGHAYESESP 0x545E /* Get Hayes ESP configuration */ -#define TARGET_TIOCSHAYESESP 0x545F /* Set Hayes ESP configuration */ - -/* Used for packet mode */ -#define TARGET_TIOCPKT_DATA 0 -#define TARGET_TIOCPKT_FLUSHREAD 1 -#define TARGET_TIOCPKT_FLUSHWRITE 2 -#define TARGET_TIOCPKT_STOP 4 -#define TARGET_TIOCPKT_START 8 -#define TARGET_TIOCPKT_NOSTOP 16 -#define TARGET_TIOCPKT_DOSTOP 32 - -#define TARGET_TIOCSER_TEMT 0x01 /* Transmitter physically empty */ - -#endif +#include "../generic/termbits.h" diff --git a/linux-user/arm/termbits.h b/linux-user/arm/termbits.h index e555cff1058c..b1d4f4fedbcb 100644 --- a/linux-user/arm/termbits.h +++ b/linux-user/arm/termbits.h @@ -1,222 +1 @@ -/* from asm/termbits.h */ -/* NOTE: exactly the same as i386 */ - -#ifndef LINUX_USER_ARM_TERMBITS_H -#define LINUX_USER_ARM_TERMBITS_H - -#define TARGET_NCCS 19 - -struct target_termios { - unsigned int c_iflag; /* input mode flags */ - unsigned int c_oflag; /* output mode flags */ - unsigned int c_cflag; /* control mode flags */ - unsigned int c_lflag; /* local mode flags */ - unsigned char c_line; /* line discipline */ - unsigned char c_cc[TARGET_NCCS]; /* control characters */ -}; - -/* c_iflag bits */ -#define TARGET_IGNBRK 0000001 -#define TARGET_BRKINT 0000002 -#define TARGET_IGNPAR 0000004 -#define TARGET_PARMRK 0000010 -#define TARGET_INPCK 0000020 -#define TARGET_ISTRIP 0000040 -#define TARGET_INLCR 0000100 -#define TARGET_IGNCR 0000200 -#define TARGET_ICRNL 0000400 -#define TARGET_IUCLC 0001000 -#define TARGET_IXON 0002000 -#define TARGET_IXANY 0004000 -#define TARGET_IXOFF 0010000 -#define TARGET_IMAXBEL 0020000 -#define TARGET_IUTF8 0040000 - -/* c_oflag bits */ -#define TARGET_OPOST 0000001 -#define TARGET_OLCUC 0000002 -#define TARGET_ONLCR 0000004 -#define TARGET_OCRNL 0000010 -#define TARGET_ONOCR 0000020 -#define TARGET_ONLRET 0000040 -#define TARGET_OFILL 0000100 -#define TARGET_OFDEL 0000200 -#define TARGET_NLDLY 0000400 -#define TARGET_NL0 0000000 -#define TARGET_NL1 0000400 -#define TARGET_CRDLY 0003000 -#define TARGET_CR0 0000000 -#define TARGET_CR1 0001000 -#define TARGET_CR2 0002000 -#define TARGET_CR3 0003000 -#define TARGET_TABDLY 0014000 -#define TARGET_TAB0 0000000 -#define TARGET_TAB1 0004000 -#define TARGET_TAB2 0010000 -#define TARGET_TAB3 0014000 -#define TARGET_XTABS 0014000 -#define TARGET_BSDLY 0020000 -#define TARGET_BS0 0000000 -#define TARGET_BS1 0020000 -#define TARGET_VTDLY 0040000 -#define TARGET_VT0 0000000 -#define TARGET_VT1 0040000 -#define TARGET_FFDLY 0100000 -#define TARGET_FF0 0000000 -#define TARGET_FF1 0100000 - -/* c_cflag bit meaning */ -#define TARGET_CBAUD 0010017 -#define TARGET_B0 0000000 /* hang up */ -#define TARGET_B50 0000001 -#define TARGET_B75 0000002 -#define TARGET_B110 0000003 -#define TARGET_B134 0000004 -#define TARGET_B150 0000005 -#define TARGET_B200 0000006 -#define TARGET_B300 0000007 -#define TARGET_B600 0000010 -#define TARGET_B1200 0000011 -#define TARGET_B1800 0000012 -#define TARGET_B2400 0000013 -#define TARGET_B4800 0000014 -#define TARGET_B9600 0000015 -#define TARGET_B19200 0000016 -#define TARGET_B38400 0000017 -#define TARGET_EXTA B19200 -#define TARGET_EXTB B38400 -#define TARGET_CSIZE 0000060 -#define TARGET_CS5 0000000 -#define TARGET_CS6 0000020 -#define TARGET_CS7 0000040 -#define TARGET_CS8 0000060 -#define TARGET_CSTOPB 0000100 -#define TARGET_CREAD 0000200 -#define TARGET_PARENB 0000400 -#define TARGET_PARODD 0001000 -#define TARGET_HUPCL 0002000 -#define TARGET_CLOCAL 0004000 -#define TARGET_CBAUDEX 0010000 -#define TARGET_B57600 0010001 -#define TARGET_B115200 0010002 -#define TARGET_B230400 0010003 -#define TARGET_B460800 0010004 -#define TARGET_CIBAUD 002003600000 /* input baud rate (not used) */ -#define TARGET_CMSPAR 010000000000 /* mark or space (stick) parity */ -#define TARGET_CRTSCTS 020000000000 /* flow control */ - -/* c_lflag bits */ -#define TARGET_ISIG 0000001 -#define TARGET_ICANON 0000002 -#define TARGET_XCASE 0000004 -#define TARGET_ECHO 0000010 -#define TARGET_ECHOE 0000020 -#define TARGET_ECHOK 0000040 -#define TARGET_ECHONL 0000100 -#define TARGET_NOFLSH 0000200 -#define TARGET_TOSTOP 0000400 -#define TARGET_ECHOCTL 0001000 -#define TARGET_ECHOPRT 0002000 -#define TARGET_ECHOKE 0004000 -#define TARGET_FLUSHO 0010000 -#define TARGET_PENDIN 0040000 -#define TARGET_IEXTEN 0100000 - -/* c_cc character offsets */ -#define TARGET_VINTR 0 -#define TARGET_VQUIT 1 -#define TARGET_VERASE 2 -#define TARGET_VKILL 3 -#define TARGET_VEOF 4 -#define TARGET_VTIME 5 -#define TARGET_VMIN 6 -#define TARGET_VSWTC 7 -#define TARGET_VSTART 8 -#define TARGET_VSTOP 9 -#define TARGET_VSUSP 10 -#define TARGET_VEOL 11 -#define TARGET_VREPRINT 12 -#define TARGET_VDISCARD 13 -#define TARGET_VWERASE 14 -#define TARGET_VLNEXT 15 -#define TARGET_VEOL2 16 - -/* ioctls */ - -#define TARGET_TCGETS 0x5401 -#define TARGET_TCSETS 0x5402 -#define TARGET_TCSETSW 0x5403 -#define TARGET_TCSETSF 0x5404 -#define TARGET_TCGETA 0x5405 -#define TARGET_TCSETA 0x5406 -#define TARGET_TCSETAW 0x5407 -#define TARGET_TCSETAF 0x5408 -#define TARGET_TCSBRK 0x5409 -#define TARGET_TCXONC 0x540A -#define TARGET_TCFLSH 0x540B - -#define TARGET_TIOCEXCL 0x540C -#define TARGET_TIOCNXCL 0x540D -#define TARGET_TIOCSCTTY 0x540E -#define TARGET_TIOCGPGRP 0x540F -#define TARGET_TIOCSPGRP 0x5410 -#define TARGET_TIOCOUTQ 0x5411 -#define TARGET_TIOCSTI 0x5412 -#define TARGET_TIOCGWINSZ 0x5413 -#define TARGET_TIOCSWINSZ 0x5414 -#define TARGET_TIOCMGET 0x5415 -#define TARGET_TIOCMBIS 0x5416 -#define TARGET_TIOCMBIC 0x5417 -#define TARGET_TIOCMSET 0x5418 -#define TARGET_TIOCGSOFTCAR 0x5419 -#define TARGET_TIOCSSOFTCAR 0x541A -#define TARGET_FIONREAD 0x541B -#define TARGET_TIOCINQ TARGET_FIONREAD -#define TARGET_TIOCLINUX 0x541C -#define TARGET_TIOCCONS 0x541D -#define TARGET_TIOCGSERIAL 0x541E -#define TARGET_TIOCSSERIAL 0x541F -#define TARGET_TIOCPKT 0x5420 -#define TARGET_FIONBIO 0x5421 -#define TARGET_TIOCNOTTY 0x5422 -#define TARGET_TIOCSETD 0x5423 -#define TARGET_TIOCGETD 0x5424 -#define TARGET_TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */ -#define TARGET_TIOCTTYGSTRUCT 0x5426 /* For debugging only */ -#define TARGET_TIOCSBRK 0x5427 /* BSD compatibility */ -#define TARGET_TIOCCBRK 0x5428 /* BSD compatibility */ -#define TARGET_TIOCGSID 0x5429 /* Return the session ID of FD */ -#define TARGET_TIOCGPTN TARGET_IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */ -#define TARGET_TIOCSPTLCK TARGET_IOW('T',0x31, int) /* Lock/unlock Pty */ -#define TARGET_TIOCGPTPEER TARGET_IO('T', 0x41) /* Safely open the slave */ - -#define TARGET_FIONCLEX 0x5450 /* these numbers need to be adjusted. */ -#define TARGET_FIOCLEX 0x5451 -#define TARGET_FIOASYNC 0x5452 -#define TARGET_TIOCSERCONFIG 0x5453 -#define TARGET_TIOCSERGWILD 0x5454 -#define TARGET_TIOCSERSWILD 0x5455 -#define TARGET_TIOCGLCKTRMIOS 0x5456 -#define TARGET_TIOCSLCKTRMIOS 0x5457 -#define TARGET_TIOCSERGSTRUCT 0x5458 /* For debugging only */ -#define TARGET_TIOCSERGETLSR 0x5459 /* Get line status register */ -#define TARGET_TIOCSERGETMULTI 0x545A /* Get multiport config */ -#define TARGET_TIOCSERSETMULTI 0x545B /* Set multiport config */ - -#define TARGET_TIOCMIWAIT 0x545C /* wait for a change on serial input line(s) */ -#define TARGET_TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */ -#define TARGET_TIOCGHAYESESP 0x545E /* Get Hayes ESP configuration */ -#define TARGET_TIOCSHAYESESP 0x545F /* Set Hayes ESP configuration */ - -/* Used for packet mode */ -#define TARGET_TIOCPKT_DATA 0 -#define TARGET_TIOCPKT_FLUSHREAD 1 -#define TARGET_TIOCPKT_FLUSHWRITE 2 -#define TARGET_TIOCPKT_STOP 4 -#define TARGET_TIOCPKT_START 8 -#define TARGET_TIOCPKT_NOSTOP 16 -#define TARGET_TIOCPKT_DOSTOP 32 - -#define TARGET_TIOCSER_TEMT 0x01 /* Transmitter physically empty */ - -#endif +#include "../generic/termbits.h" diff --git a/linux-user/generic/termbits.h b/linux-user/generic/termbits.h new file mode 100644 index 000000000000..6675e0d1abab --- /dev/null +++ b/linux-user/generic/termbits.h @@ -0,0 +1,318 @@ +/* Derived from asm-generic/termbits.h */ + +#ifndef GENERIC_TERMBITS_H +#define GENERIC_TERMBITS_H + +typedef unsigned char target_cc_t; /* cc_t */ +typedef unsigned int target_speed_t; /* speed_t */ +typedef unsigned int target_tcflag_t; /* tcflag_t */ + +#define TARGET_NCCS 19 + +struct target_termios { + target_tcflag_t c_iflag; /* input mode flags */ + target_tcflag_t c_oflag; /* output mode flags */ + target_tcflag_t c_cflag; /* control mode flags */ + target_tcflag_t c_lflag; /* local mode flags */ + target_cc_t c_line; /* line discipline */ + target_cc_t c_cc[TARGET_NCCS]; /* control characters */ +}; + +struct target_termios2 { + target_tcflag_t c_iflag; /* input mode flags */ + target_tcflag_t c_oflag; /* output mode flags */ + target_tcflag_t c_cflag; /* control mode flags */ + target_tcflag_t c_lflag; /* local mode flags */ + target_cc_t c_line; /* line discipline */ + target_cc_t c_cc[TARGET_NCCS]; /* control characters */ + target_speed_t c_ispeed; /* input speed */ + target_speed_t c_ospeed; /* output speed */ +}; + +struct target_ktermios { + target_tcflag_t c_iflag; /* input mode flags */ + target_tcflag_t c_oflag; /* output mode flags */ + target_tcflag_t c_cflag; /* control mode flags */ + target_tcflag_t c_lflag; /* local mode flags */ + target_cc_t c_line; /* line discipline */ + target_cc_t c_cc[TARGET_NCCS]; /* control characters */ + target_speed_t c_ispeed; /* input speed */ + target_speed_t c_ospeed; /* output speed */ +}; + +/* c_cc character offsets */ +#define TARGET_VINTR 0 +#define TARGET_VQUIT 1 +#define TARGET_VERASE 2 +#define TARGET_VKILL 3 +#define TARGET_VEOF 4 +#define TARGET_VTIME 5 +#define TARGET_VMIN 6 +#define TARGET_VSWTC 7 +#define TARGET_VSTART 8 +#define TARGET_VSTOP 9 +#define TARGET_VSUSP 10 +#define TARGET_VEOL 11 +#define TARGET_VREPRINT 12 +#define TARGET_VDISCARD 13 +#define TARGET_VWERASE 14 +#define TARGET_VLNEXT 15 +#define TARGET_VEOL2 16 + +/* c_iflag bits */ +#define TARGET_IGNBRK 0000001 +#define TARGET_BRKINT 0000002 +#define TARGET_IGNPAR 0000004 +#define TARGET_PARMRK 0000010 +#define TARGET_INPCK 0000020 +#define TARGET_ISTRIP 0000040 +#define TARGET_INLCR 0000100 +#define TARGET_IGNCR 0000200 +#define TARGET_ICRNL 0000400 +#define TARGET_IUCLC 0001000 +#define TARGET_IXON 0002000 +#define TARGET_IXANY 0004000 +#define TARGET_IXOFF 0010000 +#define TARGET_IMAXBEL 0020000 +#define TARGET_IUTF8 0040000 + +/* c_oflag bits */ +#define TARGET_OPOST 0000001 +#define TARGET_OLCUC 0000002 +#define TARGET_ONLCR 0000004 +#define TARGET_OCRNL 0000010 +#define TARGET_ONOCR 0000020 +#define TARGET_ONLRET 0000040 +#define TARGET_OFILL 0000100 +#define TARGET_OFDEL 0000200 +#define TARGET_NLDLY 0000400 +#define TARGET_NL0 0000000 +#define TARGET_NL1 0000400 +#define TARGET_CRDLY 0003000 +#define TARGET_CR0 0000000 +#define TARGET_CR1 0001000 +#define TARGET_CR2 0002000 +#define TARGET_CR3 0003000 +#define TARGET_TABDLY 0014000 +#define TARGET_TAB0 0000000 +#define TARGET_TAB1 0004000 +#define TARGET_TAB2 0010000 +#define TARGET_TAB3 0014000 +#define TARGET_XTABS 0014000 +#define TARGET_BSDLY 0020000 +#define TARGET_BS0 0000000 +#define TARGET_BS1 0020000 +#define TARGET_VTDLY 0040000 +#define TARGET_VT0 0000000 +#define TARGET_VT1 0040000 +#define TARGET_FFDLY 0100000 +#define TARGET_FF0 0000000 +#define TARGET_FF1 0100000 + +/* c_cflag bit meaning */ +#define TARGET_CBAUD 0010017 +#define TARGET_B0 0000000 /* hang up */ +#define TARGET_B50 0000001 +#define TARGET_B75 0000002 +#define TARGET_B110 0000003 +#define TARGET_B134 0000004 +#define TARGET_B150 0000005 +#define TARGET_B200 0000006 +#define TARGET_B300 0000007 +#define TARGET_B600 0000010 +#define TARGET_B1200 0000011 +#define TARGET_B1800 0000012 +#define TARGET_B2400 0000013 +#define TARGET_B4800 0000014 +#define TARGET_B9600 0000015 +#define TARGET_B19200 0000016 +#define TARGET_B38400 0000017 +#define TARGET_EXTA TARGET_B19200 +#define TARGET_EXTB TARGET_B38400 +#define TARGET_CSIZE 0000060 +#define TARGET_CS5 0000000 +#define TARGET_CS6 0000020 +#define TARGET_CS7 0000040 +#define TARGET_CS8 0000060 +#define TARGET_CSTOPB 0000100 +#define TARGET_CREAD 0000200 +#define TARGET_PARENB 0000400 +#define TARGET_PARODD 0001000 +#define TARGET_HUPCL 0002000 +#define TARGET_CLOCAL 0004000 +#define TARGET_CBAUDEX 0010000 +#define TARGET_BOTHER 0010000 +#define TARGET_B57600 0010001 +#define TARGET_B115200 0010002 +#define TARGET_B230400 0010003 +#define TARGET_B460800 0010004 +#define TARGET_B500000 0010005 +#define TARGET_B576000 0010006 +#define TARGET_B921600 0010007 +#define TARGET_B1000000 0010010 +#define TARGET_B1152000 0010011 +#define TARGET_B1500000 0010012 +#define TARGET_B2000000 0010013 +#define TARGET_B2500000 0010014 +#define TARGET_B3000000 0010015 +#define TARGET_B3500000 0010016 +#define TARGET_B4000000 0010017 +#define TARGET_CIBAUD 002003600000 /* input baud rate (not used) */ +#define TARGET_CMSPAR 010000000000 /* mark or space (stick) parity */ +#define TARGET_CRTSCTS 020000000000 /* flow control */ + +#define TARGET_IBSHIFT 16 /* Shift from CBAUD to CIBAUD */ + +/* c_lflag bits */ +#define TARGET_ISIG 0000001 +#define TARGET_ICANON 0000002 +#define TARGET_XCASE 0000004 +#define TARGET_ECHO 0000010 +#define TARGET_ECHOE 0000020 +#define TARGET_ECHOK 0000040 +#define TARGET_ECHONL 0000100 +#define TARGET_NOFLSH 0000200 +#define TARGET_TOSTOP 0000400 +#define TARGET_ECHOCTL 0001000 +#define TARGET_ECHOPRT 0002000 +#define TARGET_ECHOKE 0004000 +#define TARGET_FLUSHO 0010000 +#define TARGET_PENDIN 0040000 +#define TARGET_IEXTEN 0100000 +#define TARGET_EXTPROC 0200000 + +/* tcflow() and TCXONC use these */ +#define TARGET_TCOOFF 0 +#define TARGET_TCOON 1 +#define TARGET_TCIOFF 2 +#define TARGET_TCION 3 + +/* tcflush() and TCFLSH use these */ +#define TARGET_TCIFLUSH 0 +#define TARGET_TCOFLUSH 1 +#define TARGET_TCIOFLUSH 2 + +/* tcsetattr uses these */ +#define TARGET_TCSANOW 0 +#define TARGET_TCSADRAIN 1 +#define TARGET_TCSAFLUSH 2 + +/* Derived from include/uapi/asm-generic/ioctls.h */ + +#define TARGET_TCGETS 0x5401 +#define TARGET_TCSETS 0x5402 +#define TARGET_TCSETSW 0x5403 +#define TARGET_TCSETSF 0x5404 +#define TARGET_TCGETA 0x5405 +#define TARGET_TCSETA 0x5406 +#define TARGET_TCSETAW 0x5407 +#define TARGET_TCSETAF 0x5408 +#define TARGET_TCSBRK 0x5409 +#define TARGET_TCXONC 0x540A +#define TARGET_TCFLSH 0x540B + +#define TARGET_TIOCEXCL 0x540C +#define TARGET_TIOCNXCL 0x540D +#define TARGET_TIOCSCTTY 0x540E +#define TARGET_TIOCGPGRP 0x540F +#define TARGET_TIOCSPGRP 0x5410 +#define TARGET_TIOCOUTQ 0x5411 +#define TARGET_TIOCSTI 0x5412 +#define TARGET_TIOCGWINSZ 0x5413 +#define TARGET_TIOCSWINSZ 0x5414 +#define TARGET_TIOCMGET 0x5415 +#define TARGET_TIOCMBIS 0x5416 +#define TARGET_TIOCMBIC 0x5417 +#define TARGET_TIOCMSET 0x5418 +#define TARGET_TIOCGSOFTCAR 0x5419 +#define TARGET_TIOCSSOFTCAR 0x541A +#define TARGET_FIONREAD 0x541B +#define TARGET_TIOCINQ TARGET_FIONREAD +#define TARGET_TIOCLINUX 0x541C +#define TARGET_TIOCCONS 0x541D +#define TARGET_TIOCGSERIAL 0x541E +#define TARGET_TIOCSSERIAL 0x541F +#define TARGET_TIOCPKT 0x5420 +#define TARGET_FIONBIO 0x5421 +#define TARGET_TIOCNOTTY 0x5422 +#define TARGET_TIOCSETD 0x5423 +#define TARGET_TIOCGETD 0x5424 +#define TARGET_TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */ +#define TARGET_TIOCTTYGSTRUCT 0x5426 /* For debugging only */ +#define TARGET_TIOCSBRK 0x5427 /* BSD compatibility */ +#define TARGET_TIOCCBRK 0x5428 /* BSD compatibility */ +#define TARGET_TIOCGSID 0x5429 /* Return the session ID of FD */ +#define TARGET_TCGETS2 TARGET_IOR('T', 0x2A, struct target_termios2) +#define TARGET_TCSETS2 TARGET_IOW('T', 0x2B, struct target_termios2) +#define TARGET_TCSETSW2 TARGET_IOW('T', 0x2C, struct target_termios2) +#define TARGET_TCSETSF2 TARGET_IOW('T', 0x2D, struct target_termios2) +#define TARGET_TIOCGRS485 0x542E +#ifndef TARGET_TIOCSRS485 +#define TARGET_TIOCSRS485 0x542F +#endif +/* Get Pty Number (of pty-mux device) */ +#define TARGET_TIOCGPTN TARGET_IOR('T', 0x30, unsigned int) +/* Lock/unlock Pty */ +#define TARGET_TIOCSPTLCK TARGET_IOW('T', 0x31, int) + +/* Get primary device node of /dev/console */ +#define TARGET_TIOCGDEV TARGET_IOR('T', 0x32, unsigned int) +#define TARGET_TCGETX 0x5432 /* SYS5 TCGETX compatibility */ +#define TARGET_TCSETX 0x5433 +#define TARGET_TCSETXF 0x5434 +#define TARGET_TCSETXW 0x5435 +/* pty: generate signal */ +#define TARGET_TIOCSIG TARGET_IOW('T', 0x36, int) +#define TARGET_TIOCVHANGUP 0x5437 +/* Get packet mode state */ +#define TARGET_TIOCGPKT TARGET_IOR('T', 0x38, int) +/* Get Pty lock state */ +#define TARGET_TIOCGPTLCK TARGET_IOR('T', 0x39, int) +/* Get exclusive mode state */ +#define TARGET_TIOCGEXCL TARGET_IOR('T', 0x40, int) +/* Safely open the slave */ +#define TARGET_TIOCGPTPEER TARGET_IO('T', 0x41) +#define TARGET_TIOCGISO7816 TARGET_IOR('T', 0x42, struct serial_iso7816) +#define TARGET_TIOCSISO7816 TARGET_IOWR('T', 0x43, struct serial_iso7816) + +#define TARGET_FIONCLEX 0x5450 /* these numbers need to be adjusted */ +#define TARGET_FIOCLEX 0x5451 +#define TARGET_FIOASYNC 0x5452 +#define TARGET_TIOCSERCONFIG 0x5453 +#define TARGET_TIOCSERGWILD 0x5454 +#define TARGET_TIOCSERSWILD 0x5455 +#define TARGET_TIOCGLCKTRMIOS 0x5456 +#define TARGET_TIOCSLCKTRMIOS 0x5457 +#define TARGET_TIOCSERGSTRUCT 0x5458 /* For debugging only */ +#define TARGET_TIOCSERGETLSR 0x5459 /* Get line status register */ +#define TARGET_TIOCSERGETMULTI 0x545A /* Get multiport config */ +#define TARGET_TIOCSERSETMULTI 0x545B /* Set multiport config */ + +/* wait for a change on serial input line(s) */ +#define TARGET_TIOCMIWAIT 0x545C +/* read serial port inline interrupt counts */ +#define TARGET_TIOCGICOUNT 0x545D +#define TARGET_TIOCGHAYESESP 0x545E /* Get Hayes ESP configuration */ +#define TARGET_TIOCSHAYESESP 0x545F /* Set Hayes ESP configuration */ + +/* + * Some arches already define TARGET_FIOQSIZE due to a historical + * conflict with a Hayes modem-specific ioctl value. + */ +#ifndef TARGET_FIOQSIZE +# define TARGET_FIOQSIZE 0x5460 +#endif + +/* Used for packet mode */ +#define TARGET_TIOCPKT_DATA 0 +#define TARGET_TIOCPKT_FLUSHREAD 1 +#define TARGET_TIOCPKT_FLUSHWRITE 2 +#define TARGET_TIOCPKT_STOP 4 +#define TARGET_TIOCPKT_START 8 +#define TARGET_TIOCPKT_NOSTOP 16 +#define TARGET_TIOCPKT_DOSTOP 32 +#define TARGET_TIOCPKT_IOCTL 64 + +#define TARGET_TIOCSER_TEMT 0x01 /* Transmitter physically empty */ + +#endif diff --git a/linux-user/i386/termbits.h b/linux-user/i386/termbits.h index 88264bbde721..b1d4f4fedbcb 100644 --- a/linux-user/i386/termbits.h +++ b/linux-user/i386/termbits.h @@ -1,232 +1 @@ -/* from asm/termbits.h */ - -#ifndef LINUX_USER_I386_TERMBITS_H -#define LINUX_USER_I386_TERMBITS_H - -#define TARGET_NCCS 19 - -struct target_termios { - unsigned int c_iflag; /* input mode flags */ - unsigned int c_oflag; /* output mode flags */ - unsigned int c_cflag; /* control mode flags */ - unsigned int c_lflag; /* local mode flags */ - unsigned char c_line; /* line discipline */ - unsigned char c_cc[TARGET_NCCS]; /* control characters */ -}; - -/* c_iflag bits */ -#define TARGET_IGNBRK 0000001 -#define TARGET_BRKINT 0000002 -#define TARGET_IGNPAR 0000004 -#define TARGET_PARMRK 0000010 -#define TARGET_INPCK 0000020 -#define TARGET_ISTRIP 0000040 -#define TARGET_INLCR 0000100 -#define TARGET_IGNCR 0000200 -#define TARGET_ICRNL 0000400 -#define TARGET_IUCLC 0001000 -#define TARGET_IXON 0002000 -#define TARGET_IXANY 0004000 -#define TARGET_IXOFF 0010000 -#define TARGET_IMAXBEL 0020000 -#define TARGET_IUTF8 0040000 - -/* c_oflag bits */ -#define TARGET_OPOST 0000001 -#define TARGET_OLCUC 0000002 -#define TARGET_ONLCR 0000004 -#define TARGET_OCRNL 0000010 -#define TARGET_ONOCR 0000020 -#define TARGET_ONLRET 0000040 -#define TARGET_OFILL 0000100 -#define TARGET_OFDEL 0000200 -#define TARGET_NLDLY 0000400 -#define TARGET_NL0 0000000 -#define TARGET_NL1 0000400 -#define TARGET_CRDLY 0003000 -#define TARGET_CR0 0000000 -#define TARGET_CR1 0001000 -#define TARGET_CR2 0002000 -#define TARGET_CR3 0003000 -#define TARGET_TABDLY 0014000 -#define TARGET_TAB0 0000000 -#define TARGET_TAB1 0004000 -#define TARGET_TAB2 0010000 -#define TARGET_TAB3 0014000 -#define TARGET_XTABS 0014000 -#define TARGET_BSDLY 0020000 -#define TARGET_BS0 0000000 -#define TARGET_BS1 0020000 -#define TARGET_VTDLY 0040000 -#define TARGET_VT0 0000000 -#define TARGET_VT1 0040000 -#define TARGET_FFDLY 0100000 -#define TARGET_FF0 0000000 -#define TARGET_FF1 0100000 - -/* c_cflag bit meaning */ -#define TARGET_CBAUD 0010017 -#define TARGET_B0 0000000 /* hang up */ -#define TARGET_B50 0000001 -#define TARGET_B75 0000002 -#define TARGET_B110 0000003 -#define TARGET_B134 0000004 -#define TARGET_B150 0000005 -#define TARGET_B200 0000006 -#define TARGET_B300 0000007 -#define TARGET_B600 0000010 -#define TARGET_B1200 0000011 -#define TARGET_B1800 0000012 -#define TARGET_B2400 0000013 -#define TARGET_B4800 0000014 -#define TARGET_B9600 0000015 -#define TARGET_B19200 0000016 -#define TARGET_B38400 0000017 -#define TARGET_EXTA B19200 -#define TARGET_EXTB B38400 -#define TARGET_CSIZE 0000060 -#define TARGET_CS5 0000000 -#define TARGET_CS6 0000020 -#define TARGET_CS7 0000040 -#define TARGET_CS8 0000060 -#define TARGET_CSTOPB 0000100 -#define TARGET_CREAD 0000200 -#define TARGET_PARENB 0000400 -#define TARGET_PARODD 0001000 -#define TARGET_HUPCL 0002000 -#define TARGET_CLOCAL 0004000 -#define TARGET_CBAUDEX 0010000 -#define TARGET_B57600 0010001 -#define TARGET_B115200 0010002 -#define TARGET_B230400 0010003 -#define TARGET_B460800 0010004 -#define TARGET_B500000 0010005 -#define TARGET_B576000 0010006 -#define TARGET_B921600 0010007 -#define TARGET_B1000000 0010010 -#define TARGET_B1152000 0010011 -#define TARGET_B1500000 0010012 -#define TARGET_B2000000 0010013 -#define TARGET_B2500000 0010014 -#define TARGET_B3000000 0010015 -#define TARGET_B3500000 0010016 -#define TARGET_B4000000 0010017 -#define TARGET_CIBAUD 002003600000 /* input baud rate (not used) */ -#define TARGET_CMSPAR 010000000000 /* mark or space (stick) parity */ -#define TARGET_CRTSCTS 020000000000 /* flow control */ - -/* c_lflag bits */ -#define TARGET_ISIG 0000001 -#define TARGET_ICANON 0000002 -#define TARGET_XCASE 0000004 -#define TARGET_ECHO 0000010 -#define TARGET_ECHOE 0000020 -#define TARGET_ECHOK 0000040 -#define TARGET_ECHONL 0000100 -#define TARGET_NOFLSH 0000200 -#define TARGET_TOSTOP 0000400 -#define TARGET_ECHOCTL 0001000 -#define TARGET_ECHOPRT 0002000 -#define TARGET_ECHOKE 0004000 -#define TARGET_FLUSHO 0010000 -#define TARGET_PENDIN 0040000 -#define TARGET_IEXTEN 0100000 - -/* c_cc character offsets */ -#define TARGET_VINTR 0 -#define TARGET_VQUIT 1 -#define TARGET_VERASE 2 -#define TARGET_VKILL 3 -#define TARGET_VEOF 4 -#define TARGET_VTIME 5 -#define TARGET_VMIN 6 -#define TARGET_VSWTC 7 -#define TARGET_VSTART 8 -#define TARGET_VSTOP 9 -#define TARGET_VSUSP 10 -#define TARGET_VEOL 11 -#define TARGET_VREPRINT 12 -#define TARGET_VDISCARD 13 -#define TARGET_VWERASE 14 -#define TARGET_VLNEXT 15 -#define TARGET_VEOL2 16 - -/* ioctls */ - -#define TARGET_TCGETS 0x5401 -#define TARGET_TCSETS 0x5402 -#define TARGET_TCSETSW 0x5403 -#define TARGET_TCSETSF 0x5404 -#define TARGET_TCGETA 0x5405 -#define TARGET_TCSETA 0x5406 -#define TARGET_TCSETAW 0x5407 -#define TARGET_TCSETAF 0x5408 -#define TARGET_TCSBRK 0x5409 -#define TARGET_TCXONC 0x540A -#define TARGET_TCFLSH 0x540B - -#define TARGET_TIOCEXCL 0x540C -#define TARGET_TIOCNXCL 0x540D -#define TARGET_TIOCSCTTY 0x540E -#define TARGET_TIOCGPGRP 0x540F -#define TARGET_TIOCSPGRP 0x5410 -#define TARGET_TIOCOUTQ 0x5411 -#define TARGET_TIOCSTI 0x5412 -#define TARGET_TIOCGWINSZ 0x5413 -#define TARGET_TIOCSWINSZ 0x5414 -#define TARGET_TIOCMGET 0x5415 -#define TARGET_TIOCMBIS 0x5416 -#define TARGET_TIOCMBIC 0x5417 -#define TARGET_TIOCMSET 0x5418 -#define TARGET_TIOCGSOFTCAR 0x5419 -#define TARGET_TIOCSSOFTCAR 0x541A -#define TARGET_FIONREAD 0x541B -#define TARGET_TIOCINQ TARGET_FIONREAD -#define TARGET_TIOCLINUX 0x541C -#define TARGET_TIOCCONS 0x541D -#define TARGET_TIOCGSERIAL 0x541E -#define TARGET_TIOCSSERIAL 0x541F -#define TARGET_TIOCPKT 0x5420 -#define TARGET_FIONBIO 0x5421 -#define TARGET_TIOCNOTTY 0x5422 -#define TARGET_TIOCSETD 0x5423 -#define TARGET_TIOCGETD 0x5424 -#define TARGET_TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */ -#define TARGET_TIOCTTYGSTRUCT 0x5426 /* For debugging only */ -#define TARGET_TIOCSBRK 0x5427 /* BSD compatibility */ -#define TARGET_TIOCCBRK 0x5428 /* BSD compatibility */ -#define TARGET_TIOCGSID 0x5429 /* Return the session ID of FD */ -#define TARGET_TIOCGPTN TARGET_IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */ -#define TARGET_TIOCSPTLCK TARGET_IOW('T',0x31, int) /* Lock/unlock Pty */ -#define TARGET_TIOCGPTPEER TARGET_IO('T', 0x41) /* Safely open the slave */ - -#define TARGET_FIONCLEX 0x5450 /* these numbers need to be adjusted. */ -#define TARGET_FIOCLEX 0x5451 -#define TARGET_FIOASYNC 0x5452 -#define TARGET_TIOCSERCONFIG 0x5453 -#define TARGET_TIOCSERGWILD 0x5454 -#define TARGET_TIOCSERSWILD 0x5455 -#define TARGET_TIOCGLCKTRMIOS 0x5456 -#define TARGET_TIOCSLCKTRMIOS 0x5457 -#define TARGET_TIOCSERGSTRUCT 0x5458 /* For debugging only */ -#define TARGET_TIOCSERGETLSR 0x5459 /* Get line status register */ -#define TARGET_TIOCSERGETMULTI 0x545A /* Get multiport config */ -#define TARGET_TIOCSERSETMULTI 0x545B /* Set multiport config */ - -#define TARGET_TIOCMIWAIT 0x545C /* wait for a change on serial input line(s) */ -#define TARGET_TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */ -#define TARGET_TIOCGHAYESESP 0x545E /* Get Hayes ESP configuration */ -#define TARGET_TIOCSHAYESESP 0x545F /* Set Hayes ESP configuration */ - -/* Used for packet mode */ -#define TARGET_TIOCPKT_DATA 0 -#define TARGET_TIOCPKT_FLUSHREAD 1 -#define TARGET_TIOCPKT_FLUSHWRITE 2 -#define TARGET_TIOCPKT_STOP 4 -#define TARGET_TIOCPKT_START 8 -#define TARGET_TIOCPKT_NOSTOP 16 -#define TARGET_TIOCPKT_DOSTOP 32 - -#define TARGET_TIOCSER_TEMT 0x01 /* Transmitter physically empty */ - -#endif +#include "../generic/termbits.h" diff --git a/linux-user/m68k/termbits.h b/linux-user/m68k/termbits.h index 23840aa9688c..b1d4f4fedbcb 100644 --- a/linux-user/m68k/termbits.h +++ b/linux-user/m68k/termbits.h @@ -1,233 +1 @@ -/* from asm/termbits.h */ -/* NOTE: exactly the same as i386 */ - -#ifndef LINUX_USER_M68K_TERMBITS_H -#define LINUX_USER_M68K_TERMBITS_H - -#define TARGET_NCCS 19 - -struct target_termios { - unsigned int c_iflag; /* input mode flags */ - unsigned int c_oflag; /* output mode flags */ - unsigned int c_cflag; /* control mode flags */ - unsigned int c_lflag; /* local mode flags */ - unsigned char c_line; /* line discipline */ - unsigned char c_cc[TARGET_NCCS]; /* control characters */ -}; - -/* c_iflag bits */ -#define TARGET_IGNBRK 0000001 -#define TARGET_BRKINT 0000002 -#define TARGET_IGNPAR 0000004 -#define TARGET_PARMRK 0000010 -#define TARGET_INPCK 0000020 -#define TARGET_ISTRIP 0000040 -#define TARGET_INLCR 0000100 -#define TARGET_IGNCR 0000200 -#define TARGET_ICRNL 0000400 -#define TARGET_IUCLC 0001000 -#define TARGET_IXON 0002000 -#define TARGET_IXANY 0004000 -#define TARGET_IXOFF 0010000 -#define TARGET_IMAXBEL 0020000 -#define TARGET_IUTF8 0040000 - -/* c_oflag bits */ -#define TARGET_OPOST 0000001 -#define TARGET_OLCUC 0000002 -#define TARGET_ONLCR 0000004 -#define TARGET_OCRNL 0000010 -#define TARGET_ONOCR 0000020 -#define TARGET_ONLRET 0000040 -#define TARGET_OFILL 0000100 -#define TARGET_OFDEL 0000200 -#define TARGET_NLDLY 0000400 -#define TARGET_NL0 0000000 -#define TARGET_NL1 0000400 -#define TARGET_CRDLY 0003000 -#define TARGET_CR0 0000000 -#define TARGET_CR1 0001000 -#define TARGET_CR2 0002000 -#define TARGET_CR3 0003000 -#define TARGET_TABDLY 0014000 -#define TARGET_TAB0 0000000 -#define TARGET_TAB1 0004000 -#define TARGET_TAB2 0010000 -#define TARGET_TAB3 0014000 -#define TARGET_XTABS 0014000 -#define TARGET_BSDLY 0020000 -#define TARGET_BS0 0000000 -#define TARGET_BS1 0020000 -#define TARGET_VTDLY 0040000 -#define TARGET_VT0 0000000 -#define TARGET_VT1 0040000 -#define TARGET_FFDLY 0100000 -#define TARGET_FF0 0000000 -#define TARGET_FF1 0100000 - -/* c_cflag bit meaning */ -#define TARGET_CBAUD 0010017 -#define TARGET_B0 0000000 /* hang up */ -#define TARGET_B50 0000001 -#define TARGET_B75 0000002 -#define TARGET_B110 0000003 -#define TARGET_B134 0000004 -#define TARGET_B150 0000005 -#define TARGET_B200 0000006 -#define TARGET_B300 0000007 -#define TARGET_B600 0000010 -#define TARGET_B1200 0000011 -#define TARGET_B1800 0000012 -#define TARGET_B2400 0000013 -#define TARGET_B4800 0000014 -#define TARGET_B9600 0000015 -#define TARGET_B19200 0000016 -#define TARGET_B38400 0000017 -#define TARGET_EXTA B19200 -#define TARGET_EXTB B38400 -#define TARGET_CSIZE 0000060 -#define TARGET_CS5 0000000 -#define TARGET_CS6 0000020 -#define TARGET_CS7 0000040 -#define TARGET_CS8 0000060 -#define TARGET_CSTOPB 0000100 -#define TARGET_CREAD 0000200 -#define TARGET_PARENB 0000400 -#define TARGET_PARODD 0001000 -#define TARGET_HUPCL 0002000 -#define TARGET_CLOCAL 0004000 -#define TARGET_CBAUDEX 0010000 -#define TARGET_B57600 0010001 -#define TARGET_B115200 0010002 -#define TARGET_B230400 0010003 -#define TARGET_B460800 0010004 -#define TARGET_B500000 0010005 -#define TARGET_B576000 0010006 -#define TARGET_B921600 0010007 -#define TARGET_B1000000 0010010 -#define TARGET_B1152000 0010011 -#define TARGET_B1500000 0010012 -#define TARGET_B2000000 0010013 -#define TARGET_B2500000 0010014 -#define TARGET_B3000000 0010015 -#define TARGET_B3500000 0010016 -#define TARGET_B4000000 0010017 -#define TARGET_CIBAUD 002003600000 /* input baud rate (not used) */ -#define TARGET_CMSPAR 010000000000 /* mark or space (stick) parity */ -#define TARGET_CRTSCTS 020000000000 /* flow control */ - -/* c_lflag bits */ -#define TARGET_ISIG 0000001 -#define TARGET_ICANON 0000002 -#define TARGET_XCASE 0000004 -#define TARGET_ECHO 0000010 -#define TARGET_ECHOE 0000020 -#define TARGET_ECHOK 0000040 -#define TARGET_ECHONL 0000100 -#define TARGET_NOFLSH 0000200 -#define TARGET_TOSTOP 0000400 -#define TARGET_ECHOCTL 0001000 -#define TARGET_ECHOPRT 0002000 -#define TARGET_ECHOKE 0004000 -#define TARGET_FLUSHO 0010000 -#define TARGET_PENDIN 0040000 -#define TARGET_IEXTEN 0100000 - -/* c_cc character offsets */ -#define TARGET_VINTR 0 -#define TARGET_VQUIT 1 -#define TARGET_VERASE 2 -#define TARGET_VKILL 3 -#define TARGET_VEOF 4 -#define TARGET_VTIME 5 -#define TARGET_VMIN 6 -#define TARGET_VSWTC 7 -#define TARGET_VSTART 8 -#define TARGET_VSTOP 9 -#define TARGET_VSUSP 10 -#define TARGET_VEOL 11 -#define TARGET_VREPRINT 12 -#define TARGET_VDISCARD 13 -#define TARGET_VWERASE 14 -#define TARGET_VLNEXT 15 -#define TARGET_VEOL2 16 - -/* ioctls */ - -#define TARGET_TCGETS 0x5401 -#define TARGET_TCSETS 0x5402 -#define TARGET_TCSETSW 0x5403 -#define TARGET_TCSETSF 0x5404 -#define TARGET_TCGETA 0x5405 -#define TARGET_TCSETA 0x5406 -#define TARGET_TCSETAW 0x5407 -#define TARGET_TCSETAF 0x5408 -#define TARGET_TCSBRK 0x5409 -#define TARGET_TCXONC 0x540A -#define TARGET_TCFLSH 0x540B - -#define TARGET_TIOCEXCL 0x540C -#define TARGET_TIOCNXCL 0x540D -#define TARGET_TIOCSCTTY 0x540E -#define TARGET_TIOCGPGRP 0x540F -#define TARGET_TIOCSPGRP 0x5410 -#define TARGET_TIOCOUTQ 0x5411 -#define TARGET_TIOCSTI 0x5412 -#define TARGET_TIOCGWINSZ 0x5413 -#define TARGET_TIOCSWINSZ 0x5414 -#define TARGET_TIOCMGET 0x5415 -#define TARGET_TIOCMBIS 0x5416 -#define TARGET_TIOCMBIC 0x5417 -#define TARGET_TIOCMSET 0x5418 -#define TARGET_TIOCGSOFTCAR 0x5419 -#define TARGET_TIOCSSOFTCAR 0x541A -#define TARGET_FIONREAD 0x541B -#define TARGET_TIOCINQ TARGET_FIONREAD -#define TARGET_TIOCLINUX 0x541C -#define TARGET_TIOCCONS 0x541D -#define TARGET_TIOCGSERIAL 0x541E -#define TARGET_TIOCSSERIAL 0x541F -#define TARGET_TIOCPKT 0x5420 -#define TARGET_FIONBIO 0x5421 -#define TARGET_TIOCNOTTY 0x5422 -#define TARGET_TIOCSETD 0x5423 -#define TARGET_TIOCGETD 0x5424 -#define TARGET_TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */ -#define TARGET_TIOCTTYGSTRUCT 0x5426 /* For debugging only */ -#define TARGET_TIOCSBRK 0x5427 /* BSD compatibility */ -#define TARGET_TIOCCBRK 0x5428 /* BSD compatibility */ -#define TARGET_TIOCGSID 0x5429 /* Return the session ID of FD */ -#define TARGET_TIOCGPTN TARGET_IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */ -#define TARGET_TIOCSPTLCK TARGET_IOW('T',0x31, int) /* Lock/unlock Pty */ -#define TARGET_TIOCGPTPEER TARGET_IO('T', 0x41) /* Safely open the slave */ - -#define TARGET_FIONCLEX 0x5450 /* these numbers need to be adjusted. */ -#define TARGET_FIOCLEX 0x5451 -#define TARGET_FIOASYNC 0x5452 -#define TARGET_TIOCSERCONFIG 0x5453 -#define TARGET_TIOCSERGWILD 0x5454 -#define TARGET_TIOCSERSWILD 0x5455 -#define TARGET_TIOCGLCKTRMIOS 0x5456 -#define TARGET_TIOCSLCKTRMIOS 0x5457 -#define TARGET_TIOCSERGSTRUCT 0x5458 /* For debugging only */ -#define TARGET_TIOCSERGETLSR 0x5459 /* Get line status register */ -#define TARGET_TIOCSERGETMULTI 0x545A /* Get multiport config */ -#define TARGET_TIOCSERSETMULTI 0x545B /* Set multiport config */ - -#define TARGET_TIOCMIWAIT 0x545C /* wait for a change on serial input line(s) */ -#define TARGET_TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */ -#define TARGET_TIOCGHAYESESP 0x545E /* Get Hayes ESP configuration */ -#define TARGET_TIOCSHAYESESP 0x545F /* Set Hayes ESP configuration */ - -/* Used for packet mode */ -#define TARGET_TIOCPKT_DATA 0 -#define TARGET_TIOCPKT_FLUSHREAD 1 -#define TARGET_TIOCPKT_FLUSHWRITE 2 -#define TARGET_TIOCPKT_STOP 4 -#define TARGET_TIOCPKT_START 8 -#define TARGET_TIOCPKT_NOSTOP 16 -#define TARGET_TIOCPKT_DOSTOP 32 - -#define TARGET_TIOCSER_TEMT 0x01 /* Transmitter physically empty */ - -#endif +#include "../generic/termbits.h" diff --git a/linux-user/microblaze/termbits.h b/linux-user/microblaze/termbits.h index 17db8a447369..b1d4f4fedbcb 100644 --- a/linux-user/microblaze/termbits.h +++ b/linux-user/microblaze/termbits.h @@ -1,219 +1 @@ -/* from asm/termbits.h */ - -#ifndef LINUX_USER_MICROBLAZE_TERMBITS_H -#define LINUX_USER_MICROBLAZE_TERMBITS_H - -#define TARGET_NCCS 19 - -struct target_termios { - unsigned int c_iflag; /* input mode flags */ - unsigned int c_oflag; /* output mode flags */ - unsigned int c_cflag; /* control mode flags */ - unsigned int c_lflag; /* local mode flags */ - unsigned char c_line; /* line discipline */ - unsigned char c_cc[TARGET_NCCS]; /* control characters */ -}; - -/* c_iflag bits */ -#define TARGET_IGNBRK 0000001 -#define TARGET_BRKINT 0000002 -#define TARGET_IGNPAR 0000004 -#define TARGET_PARMRK 0000010 -#define TARGET_INPCK 0000020 -#define TARGET_ISTRIP 0000040 -#define TARGET_INLCR 0000100 -#define TARGET_IGNCR 0000200 -#define TARGET_ICRNL 0000400 -#define TARGET_IUCLC 0001000 -#define TARGET_IXON 0002000 -#define TARGET_IXANY 0004000 -#define TARGET_IXOFF 0010000 -#define TARGET_IMAXBEL 0020000 - -/* c_oflag bits */ -#define TARGET_OPOST 0000001 -#define TARGET_OLCUC 0000002 -#define TARGET_ONLCR 0000004 -#define TARGET_OCRNL 0000010 -#define TARGET_ONOCR 0000020 -#define TARGET_ONLRET 0000040 -#define TARGET_OFILL 0000100 -#define TARGET_OFDEL 0000200 -#define TARGET_NLDLY 0000400 -#define TARGET_NL0 0000000 -#define TARGET_NL1 0000400 -#define TARGET_CRDLY 0003000 -#define TARGET_CR0 0000000 -#define TARGET_CR1 0001000 -#define TARGET_CR2 0002000 -#define TARGET_CR3 0003000 -#define TARGET_TABDLY 0014000 -#define TARGET_TAB0 0000000 -#define TARGET_TAB1 0004000 -#define TARGET_TAB2 0010000 -#define TARGET_TAB3 0014000 -#define TARGET_XTABS 0014000 -#define TARGET_BSDLY 0020000 -#define TARGET_BS0 0000000 -#define TARGET_BS1 0020000 -#define TARGET_VTDLY 0040000 -#define TARGET_VT0 0000000 -#define TARGET_VT1 0040000 -#define TARGET_FFDLY 0100000 -#define TARGET_FF0 0000000 -#define TARGET_FF1 0100000 - -/* c_cflag bit meaning */ -#define TARGET_CBAUD 0010017 -#define TARGET_B0 0000000 /* hang up */ -#define TARGET_B50 0000001 -#define TARGET_B75 0000002 -#define TARGET_B110 0000003 -#define TARGET_B134 0000004 -#define TARGET_B150 0000005 -#define TARGET_B200 0000006 -#define TARGET_B300 0000007 -#define TARGET_B600 0000010 -#define TARGET_B1200 0000011 -#define TARGET_B1800 0000012 -#define TARGET_B2400 0000013 -#define TARGET_B4800 0000014 -#define TARGET_B9600 0000015 -#define TARGET_B19200 0000016 -#define TARGET_B38400 0000017 -#define TARGET_EXTA B19200 -#define TARGET_EXTB B38400 -#define TARGET_CSIZE 0000060 -#define TARGET_CS5 0000000 -#define TARGET_CS6 0000020 -#define TARGET_CS7 0000040 -#define TARGET_CS8 0000060 -#define TARGET_CSTOPB 0000100 -#define TARGET_CREAD 0000200 -#define TARGET_PARENB 0000400 -#define TARGET_PARODD 0001000 -#define TARGET_HUPCL 0002000 -#define TARGET_CLOCAL 0004000 -#define TARGET_CBAUDEX 0010000 -#define TARGET_B57600 0010001 -#define TARGET_B115200 0010002 -#define TARGET_B230400 0010003 -#define TARGET_B460800 0010004 -#define TARGET_CIBAUD 002003600000 /* input baud rate (not used) */ -#define TARGET_CRTSCTS 020000000000 /* flow control */ - -/* c_lflag bits */ -#define TARGET_ISIG 0000001 -#define TARGET_ICANON 0000002 -#define TARGET_XCASE 0000004 -#define TARGET_ECHO 0000010 -#define TARGET_ECHOE 0000020 -#define TARGET_ECHOK 0000040 -#define TARGET_ECHONL 0000100 -#define TARGET_NOFLSH 0000200 -#define TARGET_TOSTOP 0000400 -#define TARGET_ECHOCTL 0001000 -#define TARGET_ECHOPRT 0002000 -#define TARGET_ECHOKE 0004000 -#define TARGET_FLUSHO 0010000 -#define TARGET_PENDIN 0040000 -#define TARGET_IEXTEN 0100000 - -/* c_cc character offsets */ -#define TARGET_VINTR 0 -#define TARGET_VQUIT 1 -#define TARGET_VERASE 2 -#define TARGET_VKILL 3 -#define TARGET_VEOF 4 -#define TARGET_VTIME 5 -#define TARGET_VMIN 6 -#define TARGET_VSWTC 7 -#define TARGET_VSTART 8 -#define TARGET_VSTOP 9 -#define TARGET_VSUSP 10 -#define TARGET_VEOL 11 -#define TARGET_VREPRINT 12 -#define TARGET_VDISCARD 13 -#define TARGET_VWERASE 14 -#define TARGET_VLNEXT 15 -#define TARGET_VEOL2 16 - -/* ioctls */ - -#define TARGET_TCGETS 0x5401 -#define TARGET_TCSETS 0x5402 -#define TARGET_TCSETSW 0x5403 -#define TARGET_TCSETSF 0x5404 -#define TARGET_TCGETA 0x5405 -#define TARGET_TCSETA 0x5406 -#define TARGET_TCSETAW 0x5407 -#define TARGET_TCSETAF 0x5408 -#define TARGET_TCSBRK 0x5409 -#define TARGET_TCXONC 0x540A -#define TARGET_TCFLSH 0x540B - -#define TARGET_TIOCEXCL 0x540C -#define TARGET_TIOCNXCL 0x540D -#define TARGET_TIOCSCTTY 0x540E -#define TARGET_TIOCGPGRP 0x540F -#define TARGET_TIOCSPGRP 0x5410 -#define TARGET_TIOCOUTQ 0x5411 -#define TARGET_TIOCSTI 0x5412 -#define TARGET_TIOCGWINSZ 0x5413 -#define TARGET_TIOCSWINSZ 0x5414 -#define TARGET_TIOCMGET 0x5415 -#define TARGET_TIOCMBIS 0x5416 -#define TARGET_TIOCMBIC 0x5417 -#define TARGET_TIOCMSET 0x5418 -#define TARGET_TIOCGSOFTCAR 0x5419 -#define TARGET_TIOCSSOFTCAR 0x541A -#define TARGET_FIONREAD 0x541B -#define TARGET_TIOCINQ TARGET_FIONREAD -#define TARGET_TIOCLINUX 0x541C -#define TARGET_TIOCCONS 0x541D -#define TARGET_TIOCGSERIAL 0x541E -#define TARGET_TIOCSSERIAL 0x541F -#define TARGET_TIOCPKT 0x5420 -#define TARGET_FIONBIO 0x5421 -#define TARGET_TIOCNOTTY 0x5422 -#define TARGET_TIOCSETD 0x5423 -#define TARGET_TIOCGETD 0x5424 -#define TARGET_TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */ -#define TARGET_TIOCTTYGSTRUCT 0x5426 /* For debugging only */ -#define TARGET_TIOCSBRK 0x5427 /* BSD compatibility */ -#define TARGET_TIOCCBRK 0x5428 /* BSD compatibility */ -#define TARGET_TIOCGSID 0x5429 /* Return the session ID of FD */ -#define TARGET_TIOCGPTN TARGET_IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */ -#define TARGET_TIOCSPTLCK TARGET_IOW('T',0x31, int) /* Lock/unlock Pty */ -#define TARGET_TIOCGPTPEER TARGET_IO('T', 0x41) /* Safely open the slave */ - -#define TARGET_FIONCLEX 0x5450 /* these numbers need to be adjusted. */ -#define TARGET_FIOCLEX 0x5451 -#define TARGET_FIOASYNC 0x5452 -#define TARGET_TIOCSERCONFIG 0x5453 -#define TARGET_TIOCSERGWILD 0x5454 -#define TARGET_TIOCSERSWILD 0x5455 -#define TARGET_TIOCGLCKTRMIOS 0x5456 -#define TARGET_TIOCSLCKTRMIOS 0x5457 -#define TARGET_TIOCSERGSTRUCT 0x5458 /* For debugging only */ -#define TARGET_TIOCSERGETLSR 0x5459 /* Get line status register */ -#define TARGET_TIOCSERGETMULTI 0x545A /* Get multiport config */ -#define TARGET_TIOCSERSETMULTI 0x545B /* Set multiport config */ - -#define TARGET_TIOCMIWAIT 0x545C /* wait for a change on serial input line(s) */ -#define TARGET_TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */ -#define TARGET_TIOCGHAYESESP 0x545E /* Get Hayes ESP configuration */ -#define TARGET_TIOCSHAYESESP 0x545F /* Set Hayes ESP configuration */ - -/* Used for packet mode */ -#define TARGET_TIOCPKT_DATA 0 -#define TARGET_TIOCPKT_FLUSHREAD 1 -#define TARGET_TIOCPKT_FLUSHWRITE 2 -#define TARGET_TIOCPKT_STOP 4 -#define TARGET_TIOCPKT_START 8 -#define TARGET_TIOCPKT_NOSTOP 16 -#define TARGET_TIOCPKT_DOSTOP 32 - -#define TARGET_TIOCSER_TEMT 0x01 /* Transmitter physically empty */ - -#endif +#include "../generic/termbits.h" diff --git a/linux-user/nios2/termbits.h b/linux-user/nios2/termbits.h index 425a2fe6ef60..b1d4f4fedbcb 100644 --- a/linux-user/nios2/termbits.h +++ b/linux-user/nios2/termbits.h @@ -1,227 +1 @@ -/* from asm/termbits.h */ -/* NOTE: exactly the same as i386 */ - -#ifndef LINUX_USER_NIOS2_TERMBITS_H -#define LINUX_USER_NIOS2_TERMBITS_H - -#define TARGET_NCCS 19 - -struct target_termios { - unsigned int c_iflag; /* input mode flags */ - unsigned int c_oflag; /* output mode flags */ - unsigned int c_cflag; /* control mode flags */ - unsigned int c_lflag; /* local mode flags */ - unsigned char c_line; /* line discipline */ - unsigned char c_cc[TARGET_NCCS]; /* control characters */ -}; - -/* c_iflag bits */ -#define TARGET_IGNBRK 0000001 -#define TARGET_BRKINT 0000002 -#define TARGET_IGNPAR 0000004 -#define TARGET_PARMRK 0000010 -#define TARGET_INPCK 0000020 -#define TARGET_ISTRIP 0000040 -#define TARGET_INLCR 0000100 -#define TARGET_IGNCR 0000200 -#define TARGET_ICRNL 0000400 -#define TARGET_IUCLC 0001000 -#define TARGET_IXON 0002000 -#define TARGET_IXANY 0004000 -#define TARGET_IXOFF 0010000 -#define TARGET_IMAXBEL 0020000 -#define TARGET_IUTF8 0040000 - -/* c_oflag bits */ -#define TARGET_OPOST 0000001 -#define TARGET_OLCUC 0000002 -#define TARGET_ONLCR 0000004 -#define TARGET_OCRNL 0000010 -#define TARGET_ONOCR 0000020 -#define TARGET_ONLRET 0000040 -#define TARGET_OFILL 0000100 -#define TARGET_OFDEL 0000200 -#define TARGET_NLDLY 0000400 -#define TARGET_NL0 0000000 -#define TARGET_NL1 0000400 -#define TARGET_CRDLY 0003000 -#define TARGET_CR0 0000000 -#define TARGET_CR1 0001000 -#define TARGET_CR2 0002000 -#define TARGET_CR3 0003000 -#define TARGET_TABDLY 0014000 -#define TARGET_TAB0 0000000 -#define TARGET_TAB1 0004000 -#define TARGET_TAB2 0010000 -#define TARGET_TAB3 0014000 -#define TARGET_XTABS 0014000 -#define TARGET_BSDLY 0020000 -#define TARGET_BS0 0000000 -#define TARGET_BS1 0020000 -#define TARGET_VTDLY 0040000 -#define TARGET_VT0 0000000 -#define TARGET_VT1 0040000 -#define TARGET_FFDLY 0100000 -#define TARGET_FF0 0000000 -#define TARGET_FF1 0100000 - -/* c_cflag bit meaning */ -#define TARGET_CBAUD 0010017 -#define TARGET_B0 0000000 /* hang up */ -#define TARGET_B50 0000001 -#define TARGET_B75 0000002 -#define TARGET_B110 0000003 -#define TARGET_B134 0000004 -#define TARGET_B150 0000005 -#define TARGET_B200 0000006 -#define TARGET_B300 0000007 -#define TARGET_B600 0000010 -#define TARGET_B1200 0000011 -#define TARGET_B1800 0000012 -#define TARGET_B2400 0000013 -#define TARGET_B4800 0000014 -#define TARGET_B9600 0000015 -#define TARGET_B19200 0000016 -#define TARGET_B38400 0000017 -#define TARGET_EXTA B19200 -#define TARGET_EXTB B38400 -#define TARGET_CSIZE 0000060 -#define TARGET_CS5 0000000 -#define TARGET_CS6 0000020 -#define TARGET_CS7 0000040 -#define TARGET_CS8 0000060 -#define TARGET_CSTOPB 0000100 -#define TARGET_CREAD 0000200 -#define TARGET_PARENB 0000400 -#define TARGET_PARODD 0001000 -#define TARGET_HUPCL 0002000 -#define TARGET_CLOCAL 0004000 -#define TARGET_CBAUDEX 0010000 -#define TARGET_B57600 0010001 -#define TARGET_B115200 0010002 -#define TARGET_B230400 0010003 -#define TARGET_B460800 0010004 -#define TARGET_CIBAUD 002003600000 /* input baud rate (not used) */ -#define TARGET_CMSPAR 010000000000 /* mark or space (stick) parity */ -#define TARGET_CRTSCTS 020000000000 /* flow control */ - -/* c_lflag bits */ -#define TARGET_ISIG 0000001 -#define TARGET_ICANON 0000002 -#define TARGET_XCASE 0000004 -#define TARGET_ECHO 0000010 -#define TARGET_ECHOE 0000020 -#define TARGET_ECHOK 0000040 -#define TARGET_ECHONL 0000100 -#define TARGET_NOFLSH 0000200 -#define TARGET_TOSTOP 0000400 -#define TARGET_ECHOCTL 0001000 -#define TARGET_ECHOPRT 0002000 -#define TARGET_ECHOKE 0004000 -#define TARGET_FLUSHO 0010000 -#define TARGET_PENDIN 0040000 -#define TARGET_IEXTEN 0100000 - -/* c_cc character offsets */ -#define TARGET_VINTR 0 -#define TARGET_VQUIT 1 -#define TARGET_VERASE 2 -#define TARGET_VKILL 3 -#define TARGET_VEOF 4 -#define TARGET_VTIME 5 -#define TARGET_VMIN 6 -#define TARGET_VSWTC 7 -#define TARGET_VSTART 8 -#define TARGET_VSTOP 9 -#define TARGET_VSUSP 10 -#define TARGET_VEOL 11 -#define TARGET_VREPRINT 12 -#define TARGET_VDISCARD 13 -#define TARGET_VWERASE 14 -#define TARGET_VLNEXT 15 -#define TARGET_VEOL2 16 - -/* ioctls */ - -#define TARGET_TCGETS 0x5401 -#define TARGET_TCSETS 0x5402 -#define TARGET_TCSETSW 0x5403 -#define TARGET_TCSETSF 0x5404 -#define TARGET_TCGETA 0x5405 -#define TARGET_TCSETA 0x5406 -#define TARGET_TCSETAW 0x5407 -#define TARGET_TCSETAF 0x5408 -#define TARGET_TCSBRK 0x5409 -#define TARGET_TCXONC 0x540A -#define TARGET_TCFLSH 0x540B - -#define TARGET_TIOCEXCL 0x540C -#define TARGET_TIOCNXCL 0x540D -#define TARGET_TIOCSCTTY 0x540E -#define TARGET_TIOCGPGRP 0x540F -#define TARGET_TIOCSPGRP 0x5410 -#define TARGET_TIOCOUTQ 0x5411 -#define TARGET_TIOCSTI 0x5412 -#define TARGET_TIOCGWINSZ 0x5413 -#define TARGET_TIOCSWINSZ 0x5414 -#define TARGET_TIOCMGET 0x5415 -#define TARGET_TIOCMBIS 0x5416 -#define TARGET_TIOCMBIC 0x5417 -#define TARGET_TIOCMSET 0x5418 -#define TARGET_TIOCGSOFTCAR 0x5419 -#define TARGET_TIOCSSOFTCAR 0x541A -#define TARGET_FIONREAD 0x541B -#define TARGET_TIOCINQ TARGET_FIONREAD -#define TARGET_TIOCLINUX 0x541C -#define TARGET_TIOCCONS 0x541D -#define TARGET_TIOCGSERIAL 0x541E -#define TARGET_TIOCSSERIAL 0x541F -#define TARGET_TIOCPKT 0x5420 -#define TARGET_FIONBIO 0x5421 -#define TARGET_TIOCNOTTY 0x5422 -#define TARGET_TIOCSETD 0x5423 -#define TARGET_TIOCGETD 0x5424 -#define TARGET_TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */ -#define TARGET_TIOCTTYGSTRUCT 0x5426 /* For debugging only */ -#define TARGET_TIOCSBRK 0x5427 /* BSD compatibility */ -#define TARGET_TIOCCBRK 0x5428 /* BSD compatibility */ -#define TARGET_TIOCGSID 0x5429 /* Return the session ID of FD */ -#define TARGET_TIOCGPTN TARGET_IOR('T', 0x30, unsigned int) - /* Get Pty Number (of pty-mux device) */ -#define TARGET_TIOCSPTLCK TARGET_IOW('T', 0x31, int) - /* Lock/unlock Pty */ -#define TARGET_TIOCGPTPEER TARGET_IO('T', 0x41) - /* Safely open the slave */ - -#define TARGET_FIONCLEX 0x5450 /* these numbers need to be adjusted. */ -#define TARGET_FIOCLEX 0x5451 -#define TARGET_FIOASYNC 0x5452 -#define TARGET_TIOCSERCONFIG 0x5453 -#define TARGET_TIOCSERGWILD 0x5454 -#define TARGET_TIOCSERSWILD 0x5455 -#define TARGET_TIOCGLCKTRMIOS 0x5456 -#define TARGET_TIOCSLCKTRMIOS 0x5457 -#define TARGET_TIOCSERGSTRUCT 0x5458 /* For debugging only */ -#define TARGET_TIOCSERGETLSR 0x5459 /* Get line status register */ -#define TARGET_TIOCSERGETMULTI 0x545A /* Get multiport config */ -#define TARGET_TIOCSERSETMULTI 0x545B /* Set multiport config */ - -#define TARGET_TIOCMIWAIT 0x545C - /* wait for a change on serial input line(s) */ -#define TARGET_TIOCGICOUNT 0x545D - /* read serial port inline interrupt counts */ -#define TARGET_TIOCGHAYESESP 0x545E /* Get Hayes ESP configuration */ -#define TARGET_TIOCSHAYESESP 0x545F /* Set Hayes ESP configuration */ - -/* Used for packet mode */ -#define TARGET_TIOCPKT_DATA 0 -#define TARGET_TIOCPKT_FLUSHREAD 1 -#define TARGET_TIOCPKT_FLUSHWRITE 2 -#define TARGET_TIOCPKT_STOP 4 -#define TARGET_TIOCPKT_START 8 -#define TARGET_TIOCPKT_NOSTOP 16 -#define TARGET_TIOCPKT_DOSTOP 32 - -#define TARGET_TIOCSER_TEMT 0x01 /* Transmitter physically empty */ - -#endif +#include "../generic/termbits.h" diff --git a/linux-user/openrisc/termbits.h b/linux-user/openrisc/termbits.h index 7a635ffbc6fe..b1d4f4fedbcb 100644 --- a/linux-user/openrisc/termbits.h +++ b/linux-user/openrisc/termbits.h @@ -1,301 +1 @@ -#ifndef LINUX_USER_OPENRISC_TERMBITS_H -#define LINUX_USER_OPENRISC_TERMBITS_H - -typedef unsigned char target_openrisc_cc; /*cc_t*/ -typedef unsigned int target_openrisc_speed; /*speed_t*/ -typedef unsigned int target_openrisc_tcflag; /*tcflag_t*/ - -#define TARGET_NCCS 19 -struct target_termios { - target_openrisc_tcflag c_iflag; /* input mode flags */ - target_openrisc_tcflag c_oflag; /* output mode flags */ - target_openrisc_tcflag c_cflag; /* control mode flags */ - target_openrisc_tcflag c_lflag; /* local mode flags */ - target_openrisc_cc c_line; /* line discipline */ - target_openrisc_cc c_cc[TARGET_NCCS]; /* control characters */ -}; - -struct target_termios2 { - target_openrisc_tcflag c_iflag; /* input mode flags */ - target_openrisc_tcflag c_oflag; /* output mode flags */ - target_openrisc_tcflag c_cflag; /* control mode flags */ - target_openrisc_tcflag c_lflag; /* local mode flags */ - target_openrisc_cc c_line; /* line discipline */ - target_openrisc_cc c_cc[TARGET_NCCS]; /* control characters */ - target_openrisc_speed c_ispeed; /* input speed */ - target_openrisc_speed c_ospeed; /* output speed */ -}; - -struct target_termios3 { - target_openrisc_tcflag c_iflag; /* input mode flags */ - target_openrisc_tcflag c_oflag; /* output mode flags */ - target_openrisc_tcflag c_cflag; /* control mode flags */ - target_openrisc_tcflag c_lflag; /* local mode flags */ - target_openrisc_cc c_line; /* line discipline */ - target_openrisc_cc c_cc[TARGET_NCCS]; /* control characters */ - target_openrisc_speed c_ispeed; /* input speed */ - target_openrisc_speed c_ospeed; /* output speed */ -}; - -/* c_cc characters */ -#define TARGET_VINTR 0 -#define TARGET_VQUIT 1 -#define TARGET_VERASE 2 -#define TARGET_VKILL 3 -#define TARGET_VEOF 4 -#define TARGET_VTIME 5 -#define TARGET_VMIN 6 -#define TARGET_VSWTC 7 -#define TARGET_VSTART 8 -#define TARGET_VSTOP 9 -#define TARGET_VSUSP 10 -#define TARGET_VEOL 11 -#define TARGET_VREPRINT 12 -#define TARGET_VDISCARD 13 -#define TARGET_VWERASE 14 -#define TARGET_VLNEXT 15 -#define TARGET_VEOL2 16 - -/* c_iflag bits */ -#define TARGET_IGNBRK 0000001 -#define TARGET_BRKINT 0000002 -#define TARGET_IGNPAR 0000004 -#define TARGET_PARMRK 0000010 -#define TARGET_INPCK 0000020 -#define TARGET_ISTRIP 0000040 -#define TARGET_INLCR 0000100 -#define TARGET_IGNCR 0000200 -#define TARGET_ICRNL 0000400 -#define TARGET_IUCLC 0001000 -#define TARGET_IXON 0002000 -#define TARGET_IXANY 0004000 -#define TARGET_IXOFF 0010000 -#define TARGET_IMAXBEL 0020000 -#define TARGET_IUTF8 0040000 - -/* c_oflag bits */ -#define TARGET_OPOST 0000001 -#define TARGET_OLCUC 0000002 -#define TARGET_ONLCR 0000004 -#define TARGET_OCRNL 0000010 -#define TARGET_ONOCR 0000020 -#define TARGET_ONLRET 0000040 -#define TARGET_OFILL 0000100 -#define TARGET_OFDEL 0000200 -#define TARGET_NLDLY 0000400 -#define TARGET_NL0 0000000 -#define TARGET_NL1 0000400 -#define TARGET_CRDLY 0003000 -#define TARGET_CR0 0000000 -#define TARGET_CR1 0001000 -#define TARGET_CR2 0002000 -#define TARGET_CR3 0003000 -#define TARGET_TABDLY 0014000 -#define TARGET_TAB0 0000000 -#define TARGET_TAB1 0004000 -#define TARGET_TAB2 0010000 -#define TARGET_TAB3 0014000 -#define TARGET_XTABS 0014000 -#define TARGET_BSDLY 0020000 -#define TARGET_BS0 0000000 -#define TARGET_BS1 0020000 -#define TARGET_VTDLY 0040000 -#define TARGET_VT0 0000000 -#define TARGET_VT1 0040000 -#define TARGET_FFDLY 0100000 -#define TARGET_FF0 0000000 -#define TARGET_FF1 0100000 - -/* c_cflag bit meaning */ -#define TARGET_CBAUD 0010017 -#define TARGET_B0 0000000 /* hang up */ -#define TARGET_B50 0000001 -#define TARGET_B75 0000002 -#define TARGET_B110 0000003 -#define TARGET_B134 0000004 -#define TARGET_B150 0000005 -#define TARGET_B200 0000006 -#define TARGET_B300 0000007 -#define TARGET_B600 0000010 -#define TARGET_B1200 0000011 -#define TARGET_B1800 0000012 -#define TARGET_B2400 0000013 -#define TARGET_B4800 0000014 -#define TARGET_B9600 0000015 -#define TARGET_B19200 0000016 -#define TARGET_B38400 0000017 -#define TARGET_EXTA B19200 -#define TARGET_EXTB B38400 -#define TARGET_CSIZE 0000060 -#define TARGET_CS5 0000000 -#define TARGET_CS6 0000020 -#define TARGET_CS7 0000040 -#define TARGET_CS8 0000060 -#define TARGET_CSTOPB 0000100 -#define TARGET_CREAD 0000200 -#define TARGET_PARENB 0000400 -#define TARGET_PARODD 0001000 -#define TARGET_HUPCL 0002000 -#define TARGET_CLOCAL 0004000 -#define TARGET_CBAUDEX 0010000 -#define TARGET_BOTHER 0010000 -#define TARGET_B57600 0010001 -#define TARGET_B115200 0010002 -#define TARGET_B230400 0010003 -#define TARGET_B460800 0010004 -#define TARGET_B500000 0010005 -#define TARGET_B576000 0010006 -#define TARGET_B921600 0010007 -#define TARGET_B1000000 0010010 -#define TARGET_B1152000 0010011 -#define TARGET_B1500000 0010012 -#define TARGET_B2000000 0010013 -#define TARGET_B2500000 0010014 -#define TARGET_B3000000 0010015 -#define TARGET_B3500000 0010016 -#define TARGET_B4000000 0010017 -#define TARGET_CIBAUD 002003600000 /* input baud rate */ -#define TARGET_CMSPAR 010000000000 /* mark or space (stick) parity */ -#define TARGET_CRTSCTS 020000000000 /* flow control */ - -#define TARGET_IBSHIFT 16 /* Shift from CBAUD to CIBAUD */ - -/* c_lflag bits */ -#define TARGET_ISIG 0000001 -#define TARGET_ICANON 0000002 -#define TARGET_XCASE 0000004 -#define TARGET_ECHO 0000010 -#define TARGET_ECHOE 0000020 -#define TARGET_ECHOK 0000040 -#define TARGET_ECHONL 0000100 -#define TARGET_NOFLSH 0000200 -#define TARGET_TOSTOP 0000400 -#define TARGET_ECHOCTL 0001000 -#define TARGET_ECHOPRT 0002000 -#define TARGET_ECHOKE 0004000 -#define TARGET_FLUSHO 0010000 -#define TARGET_PENDIN 0040000 -#define TARGET_IEXTEN 0100000 -#define TARGET_EXTPROC 0200000 - -/* tcflow() and TCXONC use these */ -#define TARGET_TCOOFF 0 -#define TARGET_TCOON 1 -#define TARGET_TCIOFF 2 -#define TARGET_TCION 3 - -/* tcflush() and TCFLSH use these */ -#define TARGET_TCIFLUSH 0 -#define TARGET_TCOFLUSH 1 -#define TARGET_TCIOFLUSH 2 - -/* tcsetattr uses these */ -#define TARGET_TCSANOW 0 -#define TARGET_TCSADRAIN 1 -#define TARGET_TCSAFLUSH 2 - -/* ioctls */ -#define TARGET_TCGETS 0x5401 -#define TARGET_TCSETS 0x5402 -#define TARGET_TCSETSW 0x5403 -#define TARGET_TCSETSF 0x5404 -#define TARGET_TCGETA 0x5405 -#define TARGET_TCSETA 0x5406 -#define TARGET_TCSETAW 0x5407 -#define TARGET_TCSETAF 0x5408 -#define TARGET_TCSBRK 0x5409 -#define TARGET_TCXONC 0x540A -#define TARGET_TCFLSH 0x540B -#define TARGET_TIOCEXCL 0x540C -#define TARGET_TIOCNXCL 0x540D -#define TARGET_TIOCSCTTY 0x540E -#define TARGET_TIOCGPGRP 0x540F -#define TARGET_TIOCSPGRP 0x5410 -#define TARGET_TIOCOUTQ 0x5411 -#define TARGET_TIOCSTI 0x5412 -#define TARGET_TIOCGWINSZ 0x5413 -#define TARGET_TIOCSWINSZ 0x5414 -#define TARGET_TIOCMGET 0x5415 -#define TARGET_TIOCMBIS 0x5416 -#define TARGET_TIOCMBIC 0x5417 -#define TARGET_TIOCMSET 0x5418 -#define TARGET_TIOCGSOFTCAR 0x5419 -#define TARGET_TIOCSSOFTCAR 0x541A -#define TARGET_FIONREAD 0x541B -#define TARGET_TIOCINQ FIONREAD -#define TARGET_TIOCLINUX 0x541C -#define TARGET_TIOCCONS 0x541D -#define TARGET_TIOCGSERIAL 0x541E -#define TARGET_TIOCSSERIAL 0x541F -#define TARGET_TIOCPKT 0x5420 -#define TARGET_FIONBIO 0x5421 -#define TARGET_TIOCNOTTY 0x5422 -#define TARGET_TIOCSETD 0x5423 -#define TARGET_TIOCGETD 0x5424 -#define TARGET_TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */ -#define TARGET_TIOCSBRK 0x5427 /* BSD compatibility */ -#define TARGET_TIOCCBRK 0x5428 /* BSD compatibility */ -#define TARGET_TIOCGSID 0x5429 /* Return the session ID of FD */ -#define TARGET_TCGETS2 TARGET_IOR('T', 0x2A, struct termios2) -#define TARGET_TCSETS2 TARGET_IOW('T', 0x2B, struct termios2) -#define TARGET_TCSETSW2 TARGET_IOW('T', 0x2C, struct termios2) -#define TARGET_TCSETSF2 TARGET_IOW('T', 0x2D, struct termios2) -#define TARGET_TIOCGRS485 0x542E -#ifndef TARGET_TIOCSRS485 -#define TARGET_TIOCSRS485 0x542F -#endif -/* Get Pty Number (of pty-mux device) */ -#define TARGET_TIOCGPTN TARGET_IOR('T', 0x30, unsigned int) -/* Lock/unlock Pty */ -#define TARGET_TIOCSPTLCK TARGET_IOW('T', 0x31, int) -/* Safely open the slave */ -#define TARGET_TIOCGPTPEER TARGET_IO('T', 0x41) -/* Get primary device node of /dev/console */ -#define TARGET_TIOCGDEV TARGET_IOR('T', 0x32, unsigned int) -#define TARGET_TCGETX 0x5432 /* SYS5 TCGETX compatibility */ -#define TARGET_TCSETX 0x5433 -#define TARGET_TCSETXF 0x5434 -#define TARGET_TCSETXW 0x5435 -/* pty: generate signal */ -#define TARGET_TIOCSIG TARGET_IOW('T', 0x36, int) -#define TARGET_TIOCVHANGUP 0x5437 - -#define TARGET_FIONCLEX 0x5450 -#define TARGET_FIOCLEX 0x5451 -#define TARGET_FIOASYNC 0x5452 -#define TARGET_TIOCSERCONFIG 0x5453 -#define TARGET_TIOCSERGWILD 0x5454 -#define TARGET_TIOCSERSWILD 0x5455 -#define TARGET_TIOCGLCKTRMIOS 0x5456 -#define TARGET_TIOCSLCKTRMIOS 0x5457 -#define TARGET_TIOCSERGSTRUCT 0x5458 /* For debugging only */ -#define TARGET_TIOCSERGETLSR 0x5459 /* Get line status register */ -#define TARGET_TIOCSERGETMULTI 0x545A /* Get multiport config */ -#define TARGET_TIOCSERSETMULTI 0x545B /* Set multiport config */ - -/* wait for a change on serial input line(s) */ -#define TARGET_TIOCMIWAIT 0x545C -/* read serial port inline interrupt counts */ -#define TARGET_TIOCGICOUNT 0x545D - -/* - * Some arches already define TARGET_FIOQSIZE due to a historical - * conflict with a Hayes modem-specific ioctl value. - */ -#ifndef TARGET_FIOQSIZE -#define TARGET_FIOQSIZE 0x5460 -#endif - -/* Used for packet mode */ -#define TARGET_TIOCPKT_DATA 0 -#define TARGET_TIOCPKT_FLUSHREAD 1 -#define TARGET_TIOCPKT_FLUSHWRITE 2 -#define TARGET_TIOCPKT_STOP 4 -#define TARGET_TIOCPKT_START 8 -#define TARGET_TIOCPKT_NOSTOP 16 -#define TARGET_TIOCPKT_DOSTOP 32 -#define TARGET_TIOCPKT_IOCTL 64 - -#define TARGET_TIOCSER_TEMT 0x01 /* Transmitter physically empty */ - -#endif +#include "../generic/termbits.h" diff --git a/linux-user/riscv/termbits.h b/linux-user/riscv/termbits.h index 5e0af0dd3f5c..b1d4f4fedbcb 100644 --- a/linux-user/riscv/termbits.h +++ b/linux-user/riscv/termbits.h @@ -1,227 +1 @@ -/* from asm/termbits.h */ -/* NOTE: exactly the same as i386 */ - -#ifndef LINUX_USER_RISCV_TERMBITS_H -#define LINUX_USER_RISCV_TERMBITS_H - -#define TARGET_NCCS 19 - -struct target_termios { - unsigned int c_iflag; /* input mode flags */ - unsigned int c_oflag; /* output mode flags */ - unsigned int c_cflag; /* control mode flags */ - unsigned int c_lflag; /* local mode flags */ - unsigned char c_line; /* line discipline */ - unsigned char c_cc[TARGET_NCCS]; /* control characters */ -}; - -/* c_iflag bits */ -#define TARGET_IGNBRK 0000001 -#define TARGET_BRKINT 0000002 -#define TARGET_IGNPAR 0000004 -#define TARGET_PARMRK 0000010 -#define TARGET_INPCK 0000020 -#define TARGET_ISTRIP 0000040 -#define TARGET_INLCR 0000100 -#define TARGET_IGNCR 0000200 -#define TARGET_ICRNL 0000400 -#define TARGET_IUCLC 0001000 -#define TARGET_IXON 0002000 -#define TARGET_IXANY 0004000 -#define TARGET_IXOFF 0010000 -#define TARGET_IMAXBEL 0020000 -#define TARGET_IUTF8 0040000 - -/* c_oflag bits */ -#define TARGET_OPOST 0000001 -#define TARGET_OLCUC 0000002 -#define TARGET_ONLCR 0000004 -#define TARGET_OCRNL 0000010 -#define TARGET_ONOCR 0000020 -#define TARGET_ONLRET 0000040 -#define TARGET_OFILL 0000100 -#define TARGET_OFDEL 0000200 -#define TARGET_NLDLY 0000400 -#define TARGET_NL0 0000000 -#define TARGET_NL1 0000400 -#define TARGET_CRDLY 0003000 -#define TARGET_CR0 0000000 -#define TARGET_CR1 0001000 -#define TARGET_CR2 0002000 -#define TARGET_CR3 0003000 -#define TARGET_TABDLY 0014000 -#define TARGET_TAB0 0000000 -#define TARGET_TAB1 0004000 -#define TARGET_TAB2 0010000 -#define TARGET_TAB3 0014000 -#define TARGET_XTABS 0014000 -#define TARGET_BSDLY 0020000 -#define TARGET_BS0 0000000 -#define TARGET_BS1 0020000 -#define TARGET_VTDLY 0040000 -#define TARGET_VT0 0000000 -#define TARGET_VT1 0040000 -#define TARGET_FFDLY 0100000 -#define TARGET_FF0 0000000 -#define TARGET_FF1 0100000 - -/* c_cflag bit meaning */ -#define TARGET_CBAUD 0010017 -#define TARGET_B0 0000000 /* hang up */ -#define TARGET_B50 0000001 -#define TARGET_B75 0000002 -#define TARGET_B110 0000003 -#define TARGET_B134 0000004 -#define TARGET_B150 0000005 -#define TARGET_B200 0000006 -#define TARGET_B300 0000007 -#define TARGET_B600 0000010 -#define TARGET_B1200 0000011 -#define TARGET_B1800 0000012 -#define TARGET_B2400 0000013 -#define TARGET_B4800 0000014 -#define TARGET_B9600 0000015 -#define TARGET_B19200 0000016 -#define TARGET_B38400 0000017 -#define TARGET_EXTA B19200 -#define TARGET_EXTB B38400 -#define TARGET_CSIZE 0000060 -#define TARGET_CS5 0000000 -#define TARGET_CS6 0000020 -#define TARGET_CS7 0000040 -#define TARGET_CS8 0000060 -#define TARGET_CSTOPB 0000100 -#define TARGET_CREAD 0000200 -#define TARGET_PARENB 0000400 -#define TARGET_PARODD 0001000 -#define TARGET_HUPCL 0002000 -#define TARGET_CLOCAL 0004000 -#define TARGET_CBAUDEX 0010000 -#define TARGET_B57600 0010001 -#define TARGET_B115200 0010002 -#define TARGET_B230400 0010003 -#define TARGET_B460800 0010004 -#define TARGET_CIBAUD 002003600000 /* input baud rate (not used) */ -#define TARGET_CMSPAR 010000000000 /* mark or space (stick) parity */ -#define TARGET_CRTSCTS 020000000000 /* flow control */ - -/* c_lflag bits */ -#define TARGET_ISIG 0000001 -#define TARGET_ICANON 0000002 -#define TARGET_XCASE 0000004 -#define TARGET_ECHO 0000010 -#define TARGET_ECHOE 0000020 -#define TARGET_ECHOK 0000040 -#define TARGET_ECHONL 0000100 -#define TARGET_NOFLSH 0000200 -#define TARGET_TOSTOP 0000400 -#define TARGET_ECHOCTL 0001000 -#define TARGET_ECHOPRT 0002000 -#define TARGET_ECHOKE 0004000 -#define TARGET_FLUSHO 0010000 -#define TARGET_PENDIN 0040000 -#define TARGET_IEXTEN 0100000 - -/* c_cc character offsets */ -#define TARGET_VINTR 0 -#define TARGET_VQUIT 1 -#define TARGET_VERASE 2 -#define TARGET_VKILL 3 -#define TARGET_VEOF 4 -#define TARGET_VTIME 5 -#define TARGET_VMIN 6 -#define TARGET_VSWTC 7 -#define TARGET_VSTART 8 -#define TARGET_VSTOP 9 -#define TARGET_VSUSP 10 -#define TARGET_VEOL 11 -#define TARGET_VREPRINT 12 -#define TARGET_VDISCARD 13 -#define TARGET_VWERASE 14 -#define TARGET_VLNEXT 15 -#define TARGET_VEOL2 16 - -/* ioctls */ - -#define TARGET_TCGETS 0x5401 -#define TARGET_TCSETS 0x5402 -#define TARGET_TCSETSW 0x5403 -#define TARGET_TCSETSF 0x5404 -#define TARGET_TCGETA 0x5405 -#define TARGET_TCSETA 0x5406 -#define TARGET_TCSETAW 0x5407 -#define TARGET_TCSETAF 0x5408 -#define TARGET_TCSBRK 0x5409 -#define TARGET_TCXONC 0x540A -#define TARGET_TCFLSH 0x540B - -#define TARGET_TIOCEXCL 0x540C -#define TARGET_TIOCNXCL 0x540D -#define TARGET_TIOCSCTTY 0x540E -#define TARGET_TIOCGPGRP 0x540F -#define TARGET_TIOCSPGRP 0x5410 -#define TARGET_TIOCOUTQ 0x5411 -#define TARGET_TIOCSTI 0x5412 -#define TARGET_TIOCGWINSZ 0x5413 -#define TARGET_TIOCSWINSZ 0x5414 -#define TARGET_TIOCMGET 0x5415 -#define TARGET_TIOCMBIS 0x5416 -#define TARGET_TIOCMBIC 0x5417 -#define TARGET_TIOCMSET 0x5418 -#define TARGET_TIOCGSOFTCAR 0x5419 -#define TARGET_TIOCSSOFTCAR 0x541A -#define TARGET_FIONREAD 0x541B -#define TARGET_TIOCINQ TARGET_FIONREAD -#define TARGET_TIOCLINUX 0x541C -#define TARGET_TIOCCONS 0x541D -#define TARGET_TIOCGSERIAL 0x541E -#define TARGET_TIOCSSERIAL 0x541F -#define TARGET_TIOCPKT 0x5420 -#define TARGET_FIONBIO 0x5421 -#define TARGET_TIOCNOTTY 0x5422 -#define TARGET_TIOCSETD 0x5423 -#define TARGET_TIOCGETD 0x5424 -#define TARGET_TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */ -#define TARGET_TIOCTTYGSTRUCT 0x5426 /* For debugging only */ -#define TARGET_TIOCSBRK 0x5427 /* BSD compatibility */ -#define TARGET_TIOCCBRK 0x5428 /* BSD compatibility */ -#define TARGET_TIOCGSID 0x5429 /* Return the session ID of FD */ -#define TARGET_TIOCGPTN TARGET_IOR('T', 0x30, unsigned int) - /* Get Pty Number (of pty-mux device) */ -#define TARGET_TIOCSPTLCK TARGET_IOW('T', 0x31, int) - /* Lock/unlock Pty */ -#define TARGET_TIOCGPTPEER TARGET_IO('T', 0x41) - /* Safely open the slave */ - -#define TARGET_FIONCLEX 0x5450 /* these numbers need to be adjusted. */ -#define TARGET_FIOCLEX 0x5451 -#define TARGET_FIOASYNC 0x5452 -#define TARGET_TIOCSERCONFIG 0x5453 -#define TARGET_TIOCSERGWILD 0x5454 -#define TARGET_TIOCSERSWILD 0x5455 -#define TARGET_TIOCGLCKTRMIOS 0x5456 -#define TARGET_TIOCSLCKTRMIOS 0x5457 -#define TARGET_TIOCSERGSTRUCT 0x5458 /* For debugging only */ -#define TARGET_TIOCSERGETLSR 0x5459 /* Get line status register */ -#define TARGET_TIOCSERGETMULTI 0x545A /* Get multiport config */ -#define TARGET_TIOCSERSETMULTI 0x545B /* Set multiport config */ - -#define TARGET_TIOCMIWAIT 0x545C - /* wait for a change on serial input line(s) */ -#define TARGET_TIOCGICOUNT 0x545D - /* read serial port inline interrupt counts */ -#define TARGET_TIOCGHAYESESP 0x545E /* Get Hayes ESP configuration */ -#define TARGET_TIOCSHAYESESP 0x545F /* Set Hayes ESP configuration */ - -/* Used for packet mode */ -#define TARGET_TIOCPKT_DATA 0 -#define TARGET_TIOCPKT_FLUSHREAD 1 -#define TARGET_TIOCPKT_FLUSHWRITE 2 -#define TARGET_TIOCPKT_STOP 4 -#define TARGET_TIOCPKT_START 8 -#define TARGET_TIOCPKT_NOSTOP 16 -#define TARGET_TIOCPKT_DOSTOP 32 - -#define TARGET_TIOCSER_TEMT 0x01 /* Transmitter physically empty */ - -#endif +#include "../generic/termbits.h" diff --git a/linux-user/s390x/termbits.h b/linux-user/s390x/termbits.h index 9affa8f41a70..b1d4f4fedbcb 100644 --- a/linux-user/s390x/termbits.h +++ b/linux-user/s390x/termbits.h @@ -1,288 +1 @@ -/* - * include/asm-s390/termbits.h - * - * S390 version - * - * Derived from "include/asm-i386/termbits.h" - */ - -#ifndef LINUX_USER_S390X_TERMBITS_H -#define LINUX_USER_S390X_TERMBITS_H - -#define TARGET_NCCS 19 -struct target_termios { - unsigned int c_iflag; /* input mode flags */ - unsigned int c_oflag; /* output mode flags */ - unsigned int c_cflag; /* control mode flags */ - unsigned int c_lflag; /* local mode flags */ - unsigned char c_line; /* line discipline */ - unsigned char c_cc[TARGET_NCCS]; /* control characters */ -}; - -struct target_termios2 { - unsigned int c_iflag; /* input mode flags */ - unsigned int c_oflag; /* output mode flags */ - unsigned int c_cflag; /* control mode flags */ - unsigned int c_lflag; /* local mode flags */ - unsigned char c_line; /* line discipline */ - unsigned char c_cc[TARGET_NCCS]; /* control characters */ - unsigned int c_ispeed; /* input speed */ - unsigned int c_ospeed; /* output speed */ -}; - -struct target_ktermios { - unsigned int c_iflag; /* input mode flags */ - unsigned int c_oflag; /* output mode flags */ - unsigned int c_cflag; /* control mode flags */ - unsigned int c_lflag; /* local mode flags */ - unsigned char c_line; /* line discipline */ - unsigned char c_cc[TARGET_NCCS]; /* control characters */ - unsigned int c_ispeed; /* input speed */ - unsigned int c_ospeed; /* output speed */ -}; - -/* c_cc characters */ -#define TARGET_VINTR 0 -#define TARGET_VQUIT 1 -#define TARGET_VERASE 2 -#define TARGET_VKILL 3 -#define TARGET_VEOF 4 -#define TARGET_VTIME 5 -#define TARGET_VMIN 6 -#define TARGET_VSWTC 7 -#define TARGET_VSTART 8 -#define TARGET_VSTOP 9 -#define TARGET_VSUSP 10 -#define TARGET_VEOL 11 -#define TARGET_VREPRINT 12 -#define TARGET_VDISCARD 13 -#define TARGET_VWERASE 14 -#define TARGET_VLNEXT 15 -#define TARGET_VEOL2 16 - -/* c_iflag bits */ -#define TARGET_IGNBRK 0000001 -#define TARGET_BRKINT 0000002 -#define TARGET_IGNPAR 0000004 -#define TARGET_PARMRK 0000010 -#define TARGET_INPCK 0000020 -#define TARGET_ISTRIP 0000040 -#define TARGET_INLCR 0000100 -#define TARGET_IGNCR 0000200 -#define TARGET_ICRNL 0000400 -#define TARGET_IUCLC 0001000 -#define TARGET_IXON 0002000 -#define TARGET_IXANY 0004000 -#define TARGET_IXOFF 0010000 -#define TARGET_IMAXBEL 0020000 -#define TARGET_IUTF8 0040000 - -/* c_oflag bits */ -#define TARGET_OPOST 0000001 -#define TARGET_OLCUC 0000002 -#define TARGET_ONLCR 0000004 -#define TARGET_OCRNL 0000010 -#define TARGET_ONOCR 0000020 -#define TARGET_ONLRET 0000040 -#define TARGET_OFILL 0000100 -#define TARGET_OFDEL 0000200 -#define TARGET_NLDLY 0000400 -#define TARGET_NL0 0000000 -#define TARGET_NL1 0000400 -#define TARGET_CRDLY 0003000 -#define TARGET_CR0 0000000 -#define TARGET_CR1 0001000 -#define TARGET_CR2 0002000 -#define TARGET_CR3 0003000 -#define TARGET_TABDLY 0014000 -#define TARGET_TAB0 0000000 -#define TARGET_TAB1 0004000 -#define TARGET_TAB2 0010000 -#define TARGET_TAB3 0014000 -#define TARGET_XTABS 0014000 -#define TARGET_BSDLY 0020000 -#define TARGET_BS0 0000000 -#define TARGET_BS1 0020000 -#define TARGET_VTDLY 0040000 -#define TARGET_VT0 0000000 -#define TARGET_VT1 0040000 -#define TARGET_FFDLY 0100000 -#define TARGET_FF0 0000000 -#define TARGET_FF1 0100000 - -/* c_cflag bit meaning */ -#define TARGET_CBAUD 0010017 -#define TARGET_B0 0000000 /* hang up */ -#define TARGET_B50 0000001 -#define TARGET_B75 0000002 -#define TARGET_B110 0000003 -#define TARGET_B134 0000004 -#define TARGET_B150 0000005 -#define TARGET_B200 0000006 -#define TARGET_B300 0000007 -#define TARGET_B600 0000010 -#define TARGET_B1200 0000011 -#define TARGET_B1800 0000012 -#define TARGET_B2400 0000013 -#define TARGET_B4800 0000014 -#define TARGET_B9600 0000015 -#define TARGET_B19200 0000016 -#define TARGET_B38400 0000017 -#define TARGET_EXTA B19200 -#define TARGET_EXTB B38400 -#define TARGET_CSIZE 0000060 -#define TARGET_CS5 0000000 -#define TARGET_CS6 0000020 -#define TARGET_CS7 0000040 -#define TARGET_CS8 0000060 -#define TARGET_CSTOPB 0000100 -#define TARGET_CREAD 0000200 -#define TARGET_PARENB 0000400 -#define TARGET_PARODD 0001000 -#define TARGET_HUPCL 0002000 -#define TARGET_CLOCAL 0004000 -#define TARGET_CBAUDEX 0010000 -#define TARGET_BOTHER 0010000 -#define TARGET_B57600 0010001 -#define TARGET_B115200 0010002 -#define TARGET_B230400 0010003 -#define TARGET_B460800 0010004 -#define TARGET_B500000 0010005 -#define TARGET_B576000 0010006 -#define TARGET_B921600 0010007 -#define TARGET_B1000000 0010010 -#define TARGET_B1152000 0010011 -#define TARGET_B1500000 0010012 -#define TARGET_B2000000 0010013 -#define TARGET_B2500000 0010014 -#define TARGET_B3000000 0010015 -#define TARGET_B3500000 0010016 -#define TARGET_B4000000 0010017 -#define TARGET_CIBAUD 002003600000 /* input baud rate */ -#define TARGET_CMSPAR 010000000000 /* mark or space (stick) parity */ -#define TARGET_CRTSCTS 020000000000 /* flow control */ - -#define TARGET_IBSHIFT 16 /* Shift from CBAUD to CIBAUD */ - -/* c_lflag bits */ -#define TARGET_ISIG 0000001 -#define TARGET_ICANON 0000002 -#define TARGET_XCASE 0000004 -#define TARGET_ECHO 0000010 -#define TARGET_ECHOE 0000020 -#define TARGET_ECHOK 0000040 -#define TARGET_ECHONL 0000100 -#define TARGET_NOFLSH 0000200 -#define TARGET_TOSTOP 0000400 -#define TARGET_ECHOCTL 0001000 -#define TARGET_ECHOPRT 0002000 -#define TARGET_ECHOKE 0004000 -#define TARGET_FLUSHO 0010000 -#define TARGET_PENDIN 0040000 -#define TARGET_IEXTEN 0100000 - -/* tcflow() and TCXONC use these */ -#define TARGET_TCOOFF 0 -#define TARGET_TCOON 1 -#define TARGET_TCIOFF 2 -#define TARGET_TCION 3 - -/* tcflush() and TCFLSH use these */ -#define TARGET_TCIFLUSH 0 -#define TARGET_TCOFLUSH 1 -#define TARGET_TCIOFLUSH 2 - -/* tcsetattr uses these */ -#define TARGET_TCSANOW 0 -#define TARGET_TCSADRAIN 1 -#define TARGET_TCSAFLUSH 2 - -/* - * include/asm-s390/ioctls.h - * - * S390 version - * - * Derived from "include/asm-i386/ioctls.h" - */ - -/* 0x54 is just a magic number to make these relatively unique ('T') */ - -#define TARGET_TCGETS 0x5401 -#define TARGET_TCSETS 0x5402 -#define TARGET_TCSETSW 0x5403 -#define TARGET_TCSETSF 0x5404 -#define TARGET_TCGETA 0x5405 -#define TARGET_TCSETA 0x5406 -#define TARGET_TCSETAW 0x5407 -#define TARGET_TCSETAF 0x5408 -#define TARGET_TCSBRK 0x5409 -#define TARGET_TCXONC 0x540A -#define TARGET_TCFLSH 0x540B -#define TARGET_TIOCEXCL 0x540C -#define TARGET_TIOCNXCL 0x540D -#define TARGET_TIOCSCTTY 0x540E -#define TARGET_TIOCGPGRP 0x540F -#define TARGET_TIOCSPGRP 0x5410 -#define TARGET_TIOCOUTQ 0x5411 -#define TARGET_TIOCSTI 0x5412 -#define TARGET_TIOCGWINSZ 0x5413 -#define TARGET_TIOCSWINSZ 0x5414 -#define TARGET_TIOCMGET 0x5415 -#define TARGET_TIOCMBIS 0x5416 -#define TARGET_TIOCMBIC 0x5417 -#define TARGET_TIOCMSET 0x5418 -#define TARGET_TIOCGSOFTCAR 0x5419 -#define TARGET_TIOCSSOFTCAR 0x541A -#define TARGET_FIONREAD 0x541B -#define TARGET_TIOCINQ FIONREAD -#define TARGET_TIOCLINUX 0x541C -#define TARGET_TIOCCONS 0x541D -#define TARGET_TIOCGSERIAL 0x541E -#define TARGET_TIOCSSERIAL 0x541F -#define TARGET_TIOCPKT 0x5420 -#define TARGET_FIONBIO 0x5421 -#define TARGET_TIOCNOTTY 0x5422 -#define TARGET_TIOCSETD 0x5423 -#define TARGET_TIOCGETD 0x5424 -#define TARGET_TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */ -#define TARGET_TIOCSBRK 0x5427 /* BSD compatibility */ -#define TARGET_TIOCCBRK 0x5428 /* BSD compatibility */ -#define TARGET_TIOCGSID 0x5429 /* Return the session ID of FD */ -#define TARGET_TCGETS2 _IOR('T',0x2A, struct termios2) -#define TARGET_TCSETS2 _IOW('T',0x2B, struct termios2) -#define TARGET_TCSETSW2 _IOW('T',0x2C, struct termios2) -#define TARGET_TCSETSF2 _IOW('T',0x2D, struct termios2) -#define TARGET_TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */ -#define TARGET_TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */ -#define TARGET_TIOCGDEV _IOR('T',0x32, unsigned int) /* Get real dev no below /dev/console */ -#define TARGET_TIOCGPTPEER TARGET_IO('T', 0x41) /* Safely open the slave */ - -#define TARGET_FIONCLEX 0x5450 /* these numbers need to be adjusted. */ -#define TARGET_FIOCLEX 0x5451 -#define TARGET_FIOASYNC 0x5452 -#define TARGET_TIOCSERCONFIG 0x5453 -#define TARGET_TIOCSERGWILD 0x5454 -#define TARGET_TIOCSERSWILD 0x5455 -#define TARGET_TIOCGLCKTRMIOS 0x5456 -#define TARGET_TIOCSLCKTRMIOS 0x5457 -#define TARGET_TIOCSERGSTRUCT 0x5458 /* For debugging only */ -#define TARGET_TIOCSERGETLSR 0x5459 /* Get line status register */ -#define TARGET_TIOCSERGETMULTI 0x545A /* Get multiport config */ -#define TARGET_TIOCSERSETMULTI 0x545B /* Set multiport config */ - -#define TARGET_TIOCMIWAIT 0x545C /* wait for a change on serial input line(s) */ -#define TARGET_TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */ -#define TARGET_FIOQSIZE 0x545E - -/* Used for packet mode */ -#define TARGET_TIOCPKT_DATA 0 -#define TARGET_TIOCPKT_FLUSHREAD 1 -#define TARGET_TIOCPKT_FLUSHWRITE 2 -#define TARGET_TIOCPKT_STOP 4 -#define TARGET_TIOCPKT_START 8 -#define TARGET_TIOCPKT_NOSTOP 16 -#define TARGET_TIOCPKT_DOSTOP 32 - -#define TARGET_TIOCSER_TEMT 0x01 /* Transmitter physically empty */ - -#endif +#include "../generic/termbits.h" diff --git a/linux-user/tilegx/termbits.h b/linux-user/tilegx/termbits.h index 966daec0880f..b1d4f4fedbcb 100644 --- a/linux-user/tilegx/termbits.h +++ b/linux-user/tilegx/termbits.h @@ -1,275 +1 @@ -#ifndef TILEGX_TERMBITS_H -#define TILEGX_TERMBITS_H - -/* From asm-generic/termbits.h, which is used by tilegx */ - -#define TARGET_NCCS 19 -struct target_termios { - unsigned int c_iflag; /* input mode flags */ - unsigned int c_oflag; /* output mode flags */ - unsigned int c_cflag; /* control mode flags */ - unsigned int c_lflag; /* local mode flags */ - unsigned char c_line; /* line discipline */ - unsigned char c_cc[TARGET_NCCS]; /* control characters */ -}; - -struct target_termios2 { - unsigned int c_iflag; /* input mode flags */ - unsigned int c_oflag; /* output mode flags */ - unsigned int c_cflag; /* control mode flags */ - unsigned int c_lflag; /* local mode flags */ - unsigned char c_line; /* line discipline */ - unsigned char c_cc[TARGET_NCCS]; /* control characters */ - unsigned int c_ispeed; /* input speed */ - unsigned int c_ospeed; /* output speed */ -}; - -/* c_cc characters */ -#define TARGET_VINTR 0 -#define TARGET_VQUIT 1 -#define TARGET_VERASE 2 -#define TARGET_VKILL 3 -#define TARGET_VEOF 4 -#define TARGET_VTIME 5 -#define TARGET_VMIN 6 -#define TARGET_VSWTC 7 -#define TARGET_VSTART 8 -#define TARGET_VSTOP 9 -#define TARGET_VSUSP 10 -#define TARGET_VEOL 11 -#define TARGET_VREPRINT 12 -#define TARGET_VDISCARD 13 -#define TARGET_VWERASE 14 -#define TARGET_VLNEXT 15 -#define TARGET_VEOL2 16 - -/* c_iflag bits */ -#define TARGET_IGNBRK 0000001 -#define TARGET_BRKINT 0000002 -#define TARGET_IGNPAR 0000004 -#define TARGET_PARMRK 0000010 -#define TARGET_INPCK 0000020 -#define TARGET_ISTRIP 0000040 -#define TARGET_INLCR 0000100 -#define TARGET_IGNCR 0000200 -#define TARGET_ICRNL 0000400 -#define TARGET_IUCLC 0001000 -#define TARGET_IXON 0002000 -#define TARGET_IXANY 0004000 -#define TARGET_IXOFF 0010000 -#define TARGET_IMAXBEL 0020000 -#define TARGET_IUTF8 0040000 - -/* c_oflag bits */ -#define TARGET_OPOST 0000001 -#define TARGET_OLCUC 0000002 -#define TARGET_ONLCR 0000004 -#define TARGET_OCRNL 0000010 -#define TARGET_ONOCR 0000020 -#define TARGET_ONLRET 0000040 -#define TARGET_OFILL 0000100 -#define TARGET_OFDEL 0000200 -#define TARGET_NLDLY 0000400 -#define TARGET_NL0 0000000 -#define TARGET_NL1 0000400 -#define TARGET_CRDLY 0003000 -#define TARGET_CR0 0000000 -#define TARGET_CR1 0001000 -#define TARGET_CR2 0002000 -#define TARGET_CR3 0003000 -#define TARGET_TABDLY 0014000 -#define TARGET_TAB0 0000000 -#define TARGET_TAB1 0004000 -#define TARGET_TAB2 0010000 -#define TARGET_TAB3 0014000 -#define TARGET_XTABS 0014000 -#define TARGET_BSDLY 0020000 -#define TARGET_BS0 0000000 -#define TARGET_BS1 0020000 -#define TARGET_VTDLY 0040000 -#define TARGET_VT0 0000000 -#define TARGET_VT1 0040000 -#define TARGET_FFDLY 0100000 -#define TARGET_FF0 0000000 -#define TARGET_FF1 0100000 - -/* c_cflag bit meaning */ -#define TARGET_CBAUD 0010017 -#define TARGET_B0 0000000 /* hang up */ -#define TARGET_B50 0000001 -#define TARGET_B75 0000002 -#define TARGET_B110 0000003 -#define TARGET_B134 0000004 -#define TARGET_B150 0000005 -#define TARGET_B200 0000006 -#define TARGET_B300 0000007 -#define TARGET_B600 0000010 -#define TARGET_B1200 0000011 -#define TARGET_B1800 0000012 -#define TARGET_B2400 0000013 -#define TARGET_B4800 0000014 -#define TARGET_B9600 0000015 -#define TARGET_B19200 0000016 -#define TARGET_B38400 0000017 -#define TARGET_EXTA TARGET_B19200 -#define TARGET_EXTB TARGET_B38400 -#define TARGET_CSIZE 0000060 -#define TARGET_CS5 0000000 -#define TARGET_CS6 0000020 -#define TARGET_CS7 0000040 -#define TARGET_CS8 0000060 -#define TARGET_CSTOPB 0000100 -#define TARGET_CREAD 0000200 -#define TARGET_PARENB 0000400 -#define TARGET_PARODD 0001000 -#define TARGET_HUPCL 0002000 -#define TARGET_CLOCAL 0004000 -#define TARGET_CBAUDEX 0010000 -#define TARGET_BOTHER 0010000 -#define TARGET_B57600 0010001 -#define TARGET_B115200 0010002 -#define TARGET_B230400 0010003 -#define TARGET_B460800 0010004 -#define TARGET_B500000 0010005 -#define TARGET_B576000 0010006 -#define TARGET_B921600 0010007 -#define TARGET_B1000000 0010010 -#define TARGET_B1152000 0010011 -#define TARGET_B1500000 0010012 -#define TARGET_B2000000 0010013 -#define TARGET_B2500000 0010014 -#define TARGET_B3000000 0010015 -#define TARGET_B3500000 0010016 -#define TARGET_B4000000 0010017 -#define TARGET_CIBAUD 002003600000 /* input baud rate */ -#define TARGET_CMSPAR 010000000000 /* mark or space (stick) parity */ -#define TARGET_CRTSCTS 020000000000 /* flow control */ - -#define TARGET_IBSHIFT 16 /* Shift from CBAUD to CIBAUD */ - -/* c_lflag bits */ -#define TARGET_ISIG 0000001 -#define TARGET_ICANON 0000002 -#define TARGET_XCASE 0000004 -#define TARGET_ECHO 0000010 -#define TARGET_ECHOE 0000020 -#define TARGET_ECHOK 0000040 -#define TARGET_ECHONL 0000100 -#define TARGET_NOFLSH 0000200 -#define TARGET_TOSTOP 0000400 -#define TARGET_ECHOCTL 0001000 -#define TARGET_ECHOPRT 0002000 -#define TARGET_ECHOKE 0004000 -#define TARGET_FLUSHO 0010000 -#define TARGET_PENDIN 0040000 -#define TARGET_IEXTEN 0100000 -#define TARGET_EXTPROC 0200000 - -/* tcflow() and TCXONC use these */ -#define TARGET_TCOOFF 0 -#define TARGET_TCOON 1 -#define TARGET_TCIOFF 2 -#define TARGET_TCION 3 - -/* tcflush() and TCFLSH use these */ -#define TARGET_TCIFLUSH 0 -#define TARGET_TCOFLUSH 1 -#define TARGET_TCIOFLUSH 2 - -/* tcsetattr uses these */ -#define TARGET_TCSANOW 0 -#define TARGET_TCSADRAIN 1 -#define TARGET_TCSAFLUSH 2 - -/* From asm-generic/ioctls.h, which is used by tilegx */ - -#define TARGET_TCGETS 0x5401 -#define TARGET_TCSETS 0x5402 -#define TARGET_TCSETSW 0x5403 -#define TARGET_TCSETSF 0x5404 -#define TARGET_TCGETA 0x5405 -#define TARGET_TCSETA 0x5406 -#define TARGET_TCSETAW 0x5407 -#define TARGET_TCSETAF 0x5408 -#define TARGET_TCSBRK 0x5409 -#define TARGET_TCXONC 0x540A -#define TARGET_TCFLSH 0x540B -#define TARGET_TIOCEXCL 0x540C -#define TARGET_TIOCNXCL 0x540D -#define TARGET_TIOCSCTTY 0x540E -#define TARGET_TIOCGPGRP 0x540F -#define TARGET_TIOCSPGRP 0x5410 -#define TARGET_TIOCOUTQ 0x5411 -#define TARGET_TIOCSTI 0x5412 -#define TARGET_TIOCGWINSZ 0x5413 -#define TARGET_TIOCSWINSZ 0x5414 -#define TARGET_TIOCMGET 0x5415 -#define TARGET_TIOCMBIS 0x5416 -#define TARGET_TIOCMBIC 0x5417 -#define TARGET_TIOCMSET 0x5418 -#define TARGET_TIOCGSOFTCAR 0x5419 -#define TARGET_TIOCSSOFTCAR 0x541A -#define TARGET_FIONREAD 0x541B -#define TARGET_TIOCINQ TARGET_FIONREAD -#define TARGET_TIOCLINUX 0x541C -#define TARGET_TIOCCONS 0x541D -#define TARGET_TIOCGSERIAL 0x541E -#define TARGET_TIOCSSERIAL 0x541F -#define TARGET_TIOCPKT 0x5420 -#define TARGET_FIONBIO 0x5421 -#define TARGET_TIOCNOTTY 0x5422 -#define TARGET_TIOCSETD 0x5423 -#define TARGET_TIOCGETD 0x5424 -#define TARGET_TCSBRKP 0x5425 -#define TARGET_TIOCSBRK 0x5427 -#define TARGET_TIOCCBRK 0x5428 -#define TARGET_TIOCGSID 0x5429 -#define TARGET_TCGETS2 TARGET_IOR('T', 0x2A, struct termios2) -#define TARGET_TCSETS2 TARGET_IOW('T', 0x2B, struct termios2) -#define TARGET_TCSETSW2 TARGET_IOW('T', 0x2C, struct termios2) -#define TARGET_TCSETSF2 TARGET_IOW('T', 0x2D, struct termios2) -#define TARGET_TIOCGRS485 0x542E -#define TARGET_TIOCSRS485 0x542F -#define TARGET_TIOCGPTN TARGET_IOR('T', 0x30, unsigned int) -#define TARGET_TIOCSPTLCK TARGET_IOW('T', 0x31, int) -#define TARGET_TIOCGDEV TARGET_IOR('T', 0x32, unsigned int) -#define TARGET_TCGETX 0x5432 -#define TARGET_TCSETX 0x5433 -#define TARGET_TCSETXF 0x5434 -#define TARGET_TCSETXW 0x5435 -#define TARGET_TIOCSIG TARGET_IOW('T', 0x36, int) -#define TARGET_TIOCVHANGUP 0x5437 -#define TARGET_TIOCGPKT TARGET_IOR('T', 0x38, int) -#define TARGET_TIOCGPTLCK TARGET_IOR('T', 0x39, int) -#define TARGET_TIOCGEXCL TARGET_IOR('T', 0x40, int) -#define TARGET_TIOCGPTPEER TARGET_IO('T', 0x41) - -#define TARGET_FIONCLEX 0x5450 -#define TARGET_FIOCLEX 0x5451 -#define TARGET_FIOASYNC 0x5452 -#define TARGET_TIOCSERCONFIG 0x5453 -#define TARGET_TIOCSERGWILD 0x5454 -#define TARGET_TIOCSERSWILD 0x5455 -#define TARGET_TIOCGLCKTRMIOS 0x5456 -#define TARGET_TIOCSLCKTRMIOS 0x5457 -#define TARGET_TIOCSERGSTRUCT 0x5458 -#define TARGET_TIOCSERGETLSR 0x5459 -#define TARGET_TIOCSERGETMULTI 0x545A -#define TARGET_TIOCSERSETMULTI 0x545B - -#define TARGET_TIOCMIWAIT 0x545C -#define TARGET_TIOCGICOUNT 0x545D -#define TARGET_FIOQSIZE 0x5460 - -#define TARGET_TIOCPKT_DATA 0 -#define TARGET_TIOCPKT_FLUSHREAD 1 -#define TARGET_TIOCPKT_FLUSHWRITE 2 -#define TARGET_TIOCPKT_STOP 4 -#define TARGET_TIOCPKT_START 8 -#define TARGET_TIOCPKT_NOSTOP 16 -#define TARGET_TIOCPKT_DOSTOP 32 -#define TARGET_TIOCPKT_IOCTL 64 - -#define TARGET_TIOCSER_TEMT 0x01 - -#endif +#include "../generic/termbits.h" diff --git a/linux-user/x86_64/termbits.h b/linux-user/x86_64/termbits.h index c8bb5996b1eb..b1d4f4fedbcb 100644 --- a/linux-user/x86_64/termbits.h +++ b/linux-user/x86_64/termbits.h @@ -1,253 +1 @@ -#ifndef LINUX_USER_X86_64_TERMBITS_H -#define LINUX_USER_X86_64_TERMBITS_H - -#define TARGET_NCCS 19 - -typedef unsigned char target_cc_t; -typedef unsigned int target_speed_t; -typedef unsigned int target_tcflag_t; -struct target_termios { - target_tcflag_t c_iflag; /* input mode flags */ - target_tcflag_t c_oflag; /* output mode flags */ - target_tcflag_t c_cflag; /* control mode flags */ - target_tcflag_t c_lflag; /* local mode flags */ - target_cc_t c_line; /* line discipline */ - target_cc_t c_cc[TARGET_NCCS]; /* control characters */ -}; - -/* c_cc characters */ -#define TARGET_VINTR 0 -#define TARGET_VQUIT 1 -#define TARGET_VERASE 2 -#define TARGET_VKILL 3 -#define TARGET_VEOF 4 -#define TARGET_VTIME 5 -#define TARGET_VMIN 6 -#define TARGET_VSWTC 7 -#define TARGET_VSTART 8 -#define TARGET_VSTOP 9 -#define TARGET_VSUSP 10 -#define TARGET_VEOL 11 -#define TARGET_VREPRINT 12 -#define TARGET_VDISCARD 13 -#define TARGET_VWERASE 14 -#define TARGET_VLNEXT 15 -#define TARGET_VEOL2 16 - -/* c_iflag bits */ -#define TARGET_IGNBRK 0000001 -#define TARGET_BRKINT 0000002 -#define TARGET_IGNPAR 0000004 -#define TARGET_PARMRK 0000010 -#define TARGET_INPCK 0000020 -#define TARGET_ISTRIP 0000040 -#define TARGET_INLCR 0000100 -#define TARGET_IGNCR 0000200 -#define TARGET_ICRNL 0000400 -#define TARGET_IUCLC 0001000 -#define TARGET_IXON 0002000 -#define TARGET_IXANY 0004000 -#define TARGET_IXOFF 0010000 -#define TARGET_IMAXBEL 0020000 -#define TARGET_IUTF8 0040000 - -/* c_oflag bits */ -#define TARGET_OPOST 0000001 -#define TARGET_OLCUC 0000002 -#define TARGET_ONLCR 0000004 -#define TARGET_OCRNL 0000010 -#define TARGET_ONOCR 0000020 -#define TARGET_ONLRET 0000040 -#define TARGET_OFILL 0000100 -#define TARGET_OFDEL 0000200 -#define TARGET_NLDLY 0000400 -#define TARGET_NL0 0000000 -#define TARGET_NL1 0000400 -#define TARGET_CRDLY 0003000 -#define TARGET_CR0 0000000 -#define TARGET_CR1 0001000 -#define TARGET_CR2 0002000 -#define TARGET_CR3 0003000 -#define TARGET_TABDLY 0014000 -#define TARGET_TAB0 0000000 -#define TARGET_TAB1 0004000 -#define TARGET_TAB2 0010000 -#define TARGET_TAB3 0014000 -#define TARGET_XTABS 0014000 -#define TARGET_BSDLY 0020000 -#define TARGET_BS0 0000000 -#define TARGET_BS1 0020000 -#define TARGET_VTDLY 0040000 -#define TARGET_VT0 0000000 -#define TARGET_VT1 0040000 -#define TARGET_FFDLY 0100000 -#define TARGET_FF0 0000000 -#define TARGET_FF1 0100000 - -/* c_cflag bit meaning */ -#define TARGET_CBAUD 0010017 -#define TARGET_B0 0000000 /* hang up */ -#define TARGET_B50 0000001 -#define TARGET_B75 0000002 -#define TARGET_B110 0000003 -#define TARGET_B134 0000004 -#define TARGET_B150 0000005 -#define TARGET_B200 0000006 -#define TARGET_B300 0000007 -#define TARGET_B600 0000010 -#define TARGET_B1200 0000011 -#define TARGET_B1800 0000012 -#define TARGET_B2400 0000013 -#define TARGET_B4800 0000014 -#define TARGET_B9600 0000015 -#define TARGET_B19200 0000016 -#define TARGET_B38400 0000017 -#define TARGET_EXTA B19200 -#define TARGET_EXTB B38400 -#define TARGET_CSIZE 0000060 -#define TARGET_CS5 0000000 -#define TARGET_CS6 0000020 -#define TARGET_CS7 0000040 -#define TARGET_CS8 0000060 -#define TARGET_CSTOPB 0000100 -#define TARGET_CREAD 0000200 -#define TARGET_PARENB 0000400 -#define TARGET_PARODD 0001000 -#define TARGET_HUPCL 0002000 -#define TARGET_CLOCAL 0004000 -#define TARGET_CBAUDEX 0010000 -#define TARGET_BOTHER 0010000 /* non standard rate */ -#define TARGET_B57600 0010001 -#define TARGET_B115200 0010002 -#define TARGET_B230400 0010003 -#define TARGET_B460800 0010004 -#define TARGET_B500000 0010005 -#define TARGET_B576000 0010006 -#define TARGET_B921600 0010007 -#define TARGET_B1000000 0010010 -#define TARGET_B1152000 0010011 -#define TARGET_B1500000 0010012 -#define TARGET_B2000000 0010013 -#define TARGET_B2500000 0010014 -#define TARGET_B3000000 0010015 -#define TARGET_B3500000 0010016 -#define TARGET_B4000000 0010017 -#define TARGET_CIBAUD 002003600000 /* input baud rate */ -#define TARGET_CMSPAR 010000000000 /* mark or space (stick) parity */ -#define TARGET_CRTSCTS 020000000000 /* flow control */ - -#define TARGET_IBSHIFT 8 /* Shift from CBAUD to CIBAUD */ - -/* c_lflag bits */ -#define TARGET_ISIG 0000001 -#define TARGET_ICANON 0000002 -#define TARGET_XCASE 0000004 -#define TARGET_ECHO 0000010 -#define TARGET_ECHOE 0000020 -#define TARGET_ECHOK 0000040 -#define TARGET_ECHONL 0000100 -#define TARGET_NOFLSH 0000200 -#define TARGET_TOSTOP 0000400 -#define TARGET_ECHOCTL 0001000 -#define TARGET_ECHOPRT 0002000 -#define TARGET_ECHOKE 0004000 -#define TARGET_FLUSHO 0010000 -#define TARGET_PENDIN 0040000 -#define TARGET_IEXTEN 0100000 - -/* tcflow() and TCXONC use these */ -#define TARGET_TCOOFF 0 -#define TARGET_TCOON 1 -#define TARGET_TCIOFF 2 -#define TARGET_TCION 3 - -/* tcflush() and TCFLSH use these */ -#define TARGET_TCIFLUSH 0 -#define TARGET_TCOFLUSH 1 -#define TARGET_TCIOFLUSH 2 - -/* tcsetattr uses these */ -#define TARGET_TCSANOW 0 -#define TARGET_TCSADRAIN 1 -#define TARGET_TCSAFLUSH 2 - -#define TARGET_TCGETS 0x5401 -#define TARGET_TCSETS 0x5402 -#define TARGET_TCSETSW 0x5403 -#define TARGET_TCSETSF 0x5404 -#define TARGET_TCGETA 0x5405 -#define TARGET_TCSETA 0x5406 -#define TARGET_TCSETAW 0x5407 -#define TARGET_TCSETAF 0x5408 -#define TARGET_TCSBRK 0x5409 -#define TARGET_TCXONC 0x540A -#define TARGET_TCFLSH 0x540B -#define TARGET_TIOCEXCL 0x540C -#define TARGET_TIOCNXCL 0x540D -#define TARGET_TIOCSCTTY 0x540E -#define TARGET_TIOCGPGRP 0x540F -#define TARGET_TIOCSPGRP 0x5410 -#define TARGET_TIOCOUTQ 0x5411 -#define TARGET_TIOCSTI 0x5412 -#define TARGET_TIOCGWINSZ 0x5413 -#define TARGET_TIOCSWINSZ 0x5414 -#define TARGET_TIOCMGET 0x5415 -#define TARGET_TIOCMBIS 0x5416 -#define TARGET_TIOCMBIC 0x5417 -#define TARGET_TIOCMSET 0x5418 -#define TARGET_TIOCGSOFTCAR 0x5419 -#define TARGET_TIOCSSOFTCAR 0x541A -#define TARGET_FIONREAD 0x541B -#define TARGET_TIOCINQ FIONREAD -#define TARGET_TIOCLINUX 0x541C -#define TARGET_TIOCCONS 0x541D -#define TARGET_TIOCGSERIAL 0x541E -#define TARGET_TIOCSSERIAL 0x541F -#define TARGET_TIOCPKT 0x5420 -#define TARGET_FIONBIO 0x5421 -#define TARGET_TIOCNOTTY 0x5422 -#define TARGET_TIOCSETD 0x5423 -#define TARGET_TIOCGETD 0x5424 -#define TARGET_TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */ -#define TARGET_TIOCSBRK 0x5427 /* BSD compatibility */ -#define TARGET_TIOCCBRK 0x5428 /* BSD compatibility */ -#define TARGET_TIOCGSID 0x5429 /* Return the session ID of FD */ -#define TARGET_TCGETS2 TARGET_IOR('T',0x2A, struct termios2) -#define TARGET_TCSETS2 TARGET_IOW('T',0x2B, struct termios2) -#define TARGET_TCSETSW2 TARGET_IOW('T',0x2C, struct termios2) -#define TARGET_TCSETSF2 TARGET_IOW('T',0x2D, struct termios2) -#define TARGET_TIOCGPTN TARGET_IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */ -#define TARGET_TIOCSPTLCK TARGET_IOW('T',0x31, int) /* Lock/unlock Pty */ -#define TARGET_TIOCGPTPEER TARGET_IO('T', 0x41) /* Safely open the slave */ - -#define TARGET_FIONCLEX 0x5450 /* these numbers need to be adjusted. */ -#define TARGET_FIOCLEX 0x5451 -#define TARGET_FIOASYNC 0x5452 -#define TARGET_TIOCSERCONFIG 0x5453 -#define TARGET_TIOCSERGWILD 0x5454 -#define TARGET_TIOCSERSWILD 0x5455 -#define TARGET_TIOCGLCKTRMIOS 0x5456 -#define TARGET_TIOCSLCKTRMIOS 0x5457 -#define TARGET_TIOCSERGSTRUCT 0x5458 /* For debugging only */ -#define TARGET_TIOCSERGETLSR 0x5459 /* Get line status register */ -#define TARGET_TIOCSERGETMULTI 0x545A /* Get multiport config */ -#define TARGET_TIOCSERSETMULTI 0x545B /* Set multiport config */ - -#define TARGET_TIOCMIWAIT 0x545C /* wait for a change on serial input line(s) */ -#define TARGET_TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */ -#define TARGET_TIOCGHAYESESP 0x545E /* Get Hayes ESP configuration */ -#define TARGET_TIOCSHAYESESP 0x545F /* Set Hayes ESP configuration */ -#define TARGET_FIOQSIZE 0x5460 - -/* Used for packet mode */ -#define TARGET_TIOCPKT_DATA 0 -#define TARGET_TIOCPKT_FLUSHREAD 1 -#define TARGET_TIOCPKT_FLUSHWRITE 2 -#define TARGET_TIOCPKT_STOP 4 -#define TARGET_TIOCPKT_START 8 -#define TARGET_TIOCPKT_NOSTOP 16 -#define TARGET_TIOCPKT_DOSTOP 32 - -#define TARGET_TIOCSER_TEMT 0x01 /* Transmitter physically empty */ - -#endif +#include "../generic/termbits.h" From patchwork Thu Aug 27 19:20:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 11741463 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0CF3214E5 for ; Thu, 27 Aug 2020 19:24:52 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CC62A207CD for ; Thu, 27 Aug 2020 19:24:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CC62A207CD Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=vivier.eu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:49462 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kBNVz-0004ML-0b for patchwork-qemu-devel@patchwork.kernel.org; Thu, 27 Aug 2020 15:24:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33552) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kBNS7-0004Hl-H8 for qemu-devel@nongnu.org; Thu, 27 Aug 2020 15:20:53 -0400 Received: from mout.kundenserver.de ([217.72.192.75]:47725) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kBNS4-0000Hd-16 for qemu-devel@nongnu.org; Thu, 27 Aug 2020 15:20:51 -0400 Received: from localhost.localdomain ([82.252.135.186]) by mrelayeu.kundenserver.de (mreue109 [212.227.15.183]) with ESMTPSA (Nemesis) id 1Myb8N-1kWmFs2PIj-00yvbX; Thu, 27 Aug 2020 21:20:38 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 10/18] linux-user: Add missing termbits types and values definitions Date: Thu, 27 Aug 2020 21:20:10 +0200 Message-Id: <20200827192018.2442099-11-laurent@vivier.eu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200827192018.2442099-1-laurent@vivier.eu> References: <20200827192018.2442099-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:Y+sY9KuLKv6w3ax14hGN/Ki47Yey+tevoZDfqy7rFvfur8lUI50 Zfsj8t36xXZzFktg/WClO4GyeNF8PzjHsgPsgR5prpN122PgryP5YGj+Sj1X3xDJ3FOzUKK 6CXiLnQ3gY1BBPTfzduEyLxEwR4DQAlod4+ItrId5H5dbckm5uXk2IVaL9p24ChpSdnyLXw fobJS45aYaf4hruFA4iKA== X-UI-Out-Filterresults: notjunk:1;V03:K0:LTBaspZAbWk=:5jFq/AHiLRFnm/GHFo3dGf QDXOoBbJ+vJtp+BwE+FqWa7aV3Zd81xaGpG14BDSKBVZSc3pw6Z/EGa6+q75Rpy9UG0j/De0+ E7i2/G5RvZK0DMJcYfHludcFaIl0ttg6m24s/chwCvdtkYYyOIjidutxV44we3dzX7IPzPjR4 6dsdDM14Bl7Q6yDi2VAOuMuIDa7RLDw5s7lJ2N26PV1TdoXVnLgx2mQEOd0ehZkDiu0U51ewy 0jwGXHwapz+kt7EubDNtEs6nfoHiNRIK/6V3+T0nf3VQ5DjeDswVyAPQwowcjeuDLqPFmzN2p IvSkIlW8qRD9FbMz/rYm1bbk1j06fCeOf3Qm/leXtlWtciuNQLaLhR13Hkmsa0IRtZD65YKIl Tr+94FLnFPRh9FJZfLyKqwEQbUXNhkkJDZKeea7PrsM9E2Sf763ZxAUwzH04rpmxkpz+i7K8G lHV94KJt7Gq6/o8my8bR8mreSIU4qUTuRxIlNjVcERF5KO8B9pdajOXqzLStdvDVNbuyeRhXd N1nW7To/OtoN5t4KQFCJGkZuOcwqaXk6Z5qiCHkVr0Kmsa4AWKapSBcKLhDS8TTfRaW9anBJ+ jNKEq5kZt3kPBD+7WPyduKgx6wwP4g/NLUF3iEh7WgH4RfaxPSY0MYZ5yZOB1sfXPzkJJjzLu gvO6kC+AZTmmR7rXaeYd11YSzcrG7yC/tYvQDGw85weC/3hskm/8kJefmDqwrEz3HYJPSyCje mNPMy1h1eKsV1I8hHpsC4zVRbZzVir1eRqGdCFcdxgk4oL1U1/J88IRxsQA5syTIp7t0Q/4St mkuJbEGe8gH2BZB2btMs445u951vfqohCon72AC2Ym5HjSkfKL6MQsxaFCheU8QrfJSMiFu Received-SPF: none client-ip=217.72.192.75; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/27 15:20:36 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] 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, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Max Filippov , Riku Voipio , Laurent Vivier , Filip Bozuta Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Filip Bozuta This patch introduces missing target types ('target_flag_t', 'target_cc_t', 'target_speed_t') in a few 'termibts.h' header files. Also, two missing values ('TARGET_IUTF8' and 'TARGET_EXTPROC') were also added. These values were also added in file 'syscall.c' in bitmask tables 'iflag_tbl[]' and 'lflag_tbl[]' which are used to convert values of 'struct termios' between target and host. Signed-off-by: Filip Bozuta Reviewed-by: Max Filippov Reviewed-by: Laurent Vivier Message-Id: <20200723210233.349690-3-Filip.Bozuta@syrmia.com> [lv: keep TARGET_NCCS definition in xtensa/termbits.h] Signed-off-by: Laurent Vivier --- linux-user/alpha/termbits.h | 1 + linux-user/cris/termbits.h | 18 ++++++++---- linux-user/hppa/termbits.h | 17 +++++++---- linux-user/mips/termbits.h | 17 +++++++---- linux-user/ppc/termbits.h | 21 ++++++++----- linux-user/sh4/termbits.h | 19 ++++++++---- linux-user/sparc/termbits.h | 18 ++++++++---- linux-user/sparc64/termbits.h | 18 ++++++++---- linux-user/syscall.c | 34 ++++++++++++---------- linux-user/xtensa/termbits.h | 55 ++++++++++++++++++----------------- 10 files changed, 132 insertions(+), 86 deletions(-) diff --git a/linux-user/alpha/termbits.h b/linux-user/alpha/termbits.h index a71425174a97..4a4b1e96f21c 100644 --- a/linux-user/alpha/termbits.h +++ b/linux-user/alpha/termbits.h @@ -159,6 +159,7 @@ struct target_termios { #define TARGET_FLUSHO 0x00800000 #define TARGET_PENDIN 0x20000000 #define TARGET_IEXTEN 0x00000400 +#define TARGET_EXTPROC 0x10000000 #define TARGET_FIOCLEX TARGET_IO('f', 1) #define TARGET_FIONCLEX TARGET_IO('f', 2) diff --git a/linux-user/cris/termbits.h b/linux-user/cris/termbits.h index 475ee70fed37..0c8d8fc05164 100644 --- a/linux-user/cris/termbits.h +++ b/linux-user/cris/termbits.h @@ -5,13 +5,17 @@ #define TARGET_NCCS 19 +typedef unsigned char target_cc_t; /* cc_t */ +typedef unsigned int target_speed_t; /* speed_t */ +typedef unsigned int target_tcflag_t; /* tcflag_t */ + struct target_termios { - unsigned int c_iflag; /* input mode flags */ - unsigned int c_oflag; /* output mode flags */ - unsigned int c_cflag; /* control mode flags */ - unsigned int c_lflag; /* local mode flags */ - unsigned char c_line; /* line discipline */ - unsigned char c_cc[TARGET_NCCS]; /* control characters */ + target_tcflag_t c_iflag; /* input mode flags */ + target_tcflag_t c_oflag; /* output mode flags */ + target_tcflag_t c_cflag; /* control mode flags */ + target_tcflag_t c_lflag; /* local mode flags */ + target_cc_t c_line; /* line discipline */ + target_cc_t c_cc[TARGET_NCCS]; /* control characters */ }; /* c_iflag bits */ @@ -29,6 +33,7 @@ struct target_termios { #define TARGET_IXANY 0004000 #define TARGET_IXOFF 0010000 #define TARGET_IMAXBEL 0020000 +#define TARGET_IUTF8 0040000 /* c_oflag bits */ #define TARGET_OPOST 0000001 @@ -118,6 +123,7 @@ struct target_termios { #define TARGET_FLUSHO 0010000 #define TARGET_PENDIN 0040000 #define TARGET_IEXTEN 0100000 +#define TARGET_EXTPROC 0200000 /* c_cc character offsets */ #define TARGET_VINTR 0 diff --git a/linux-user/hppa/termbits.h b/linux-user/hppa/termbits.h index 8fba839dd4e6..11fd4eed6232 100644 --- a/linux-user/hppa/termbits.h +++ b/linux-user/hppa/termbits.h @@ -5,13 +5,17 @@ #define TARGET_NCCS 19 +typedef unsigned char target_cc_t; /* cc_t */ +typedef unsigned int target_speed_t; /* speed_t */ +typedef unsigned int target_tcflag_t; /* tcflag_t */ + struct target_termios { - unsigned int c_iflag; /* input mode flags */ - unsigned int c_oflag; /* output mode flags */ - unsigned int c_cflag; /* control mode flags */ - unsigned int c_lflag; /* local mode flags */ - unsigned char c_line; /* line discipline */ - unsigned char c_cc[TARGET_NCCS]; /* control characters */ + target_tcflag_t c_iflag; /* input mode flags */ + target_tcflag_t c_oflag; /* output mode flags */ + target_tcflag_t c_cflag; /* control mode flags */ + target_tcflag_t c_lflag; /* local mode flags */ + target_cc_t c_line; /* line discipline */ + target_cc_t c_cc[TARGET_NCCS]; /* control characters */ }; /* c_iflag bits */ @@ -120,6 +124,7 @@ struct target_termios { #define TARGET_FLUSHO 0010000 #define TARGET_PENDIN 0040000 #define TARGET_IEXTEN 0100000 +#define TARGET_EXTPROC 0200000 /* c_cc character offsets */ #define TARGET_VINTR 0 diff --git a/linux-user/mips/termbits.h b/linux-user/mips/termbits.h index 3287cf6df8b8..e8b4b58d878d 100644 --- a/linux-user/mips/termbits.h +++ b/linux-user/mips/termbits.h @@ -5,13 +5,17 @@ #define TARGET_NCCS 23 +typedef unsigned char target_cc_t; /* cc_t */ +typedef unsigned int target_speed_t; /* speed_t */ +typedef unsigned int target_tcflag_t; /* tcflag_t */ + struct target_termios { - unsigned int c_iflag; /* input mode flags */ - unsigned int c_oflag; /* output mode flags */ - unsigned int c_cflag; /* control mode flags */ - unsigned int c_lflag; /* local mode flags */ - unsigned char c_line; /* line discipline */ - unsigned char c_cc[TARGET_NCCS]; /* control characters */ + target_tcflag_t c_iflag; /* input mode flags */ + target_tcflag_t c_oflag; /* output mode flags */ + target_tcflag_t c_cflag; /* control mode flags */ + target_tcflag_t c_lflag; /* local mode flags */ + target_cc_t c_line; /* line discipline */ + target_cc_t c_cc[TARGET_NCCS]; /* control characters */ }; /* c_iflag bits */ @@ -133,6 +137,7 @@ struct target_termios { #define TARGET_PENDIN 0040000 #define TARGET_TOSTOP 0100000 #define TARGET_ITOSTOP TARGET_TOSTOP +#define TARGET_EXTPROC 0200000 /* c_cc character offsets */ #define TARGET_VINTR 0 diff --git a/linux-user/ppc/termbits.h b/linux-user/ppc/termbits.h index 19e4c6eda86c..7066d1e5523d 100644 --- a/linux-user/ppc/termbits.h +++ b/linux-user/ppc/termbits.h @@ -5,15 +5,19 @@ #define TARGET_NCCS 19 +typedef unsigned char target_cc_t; /* cc_t */ +typedef unsigned int target_speed_t; /* speed_t */ +typedef unsigned int target_tcflag_t; /* tcflag_t */ + struct target_termios { - unsigned int c_iflag; /* input mode flags */ - unsigned int c_oflag; /* output mode flags */ - unsigned int c_cflag; /* control mode flags */ - unsigned int c_lflag; /* local mode flags */ - unsigned char c_cc[TARGET_NCCS]; /* control characters */ - unsigned char c_line; /* line discipline */ - unsigned int c_ispeed; /* input speed */ - unsigned int c_ospeed; /* output speed */ + target_tcflag_t c_iflag; /* input mode flags */ + target_tcflag_t c_oflag; /* output mode flags */ + target_tcflag_t c_cflag; /* control mode flags */ + target_tcflag_t c_lflag; /* local mode flags */ + target_cc_t c_line; /* line discipline */ + target_cc_t c_cc[TARGET_NCCS]; /* control characters */ + target_speed_t c_ispeed; /* input speed */ + target_speed_t c_ospeed; /* output speed */ }; /* c_cc character offsets */ @@ -158,6 +162,7 @@ struct target_termios { #define TARGET_FLUSHO 0x00800000 #define TARGET_PENDIN 0x20000000 #define TARGET_IEXTEN 0x00000400 +#define TARGET_EXTPROC 0x10000000 /* ioctls */ diff --git a/linux-user/sh4/termbits.h b/linux-user/sh4/termbits.h index dd125b6a2b2a..f91b5c51cf83 100644 --- a/linux-user/sh4/termbits.h +++ b/linux-user/sh4/termbits.h @@ -5,15 +5,20 @@ #define TARGET_NCCS 19 +typedef unsigned char target_cc_t; /* cc_t */ +typedef unsigned int target_speed_t; /* speed_t */ +typedef unsigned int target_tcflag_t; /* tcflag_t */ + struct target_termios { - unsigned int c_iflag; /* input mode flags */ - unsigned int c_oflag; /* output mode flags */ - unsigned int c_cflag; /* control mode flags */ - unsigned int c_lflag; /* local mode flags */ - unsigned char c_line; /* line discipline */ - unsigned char c_cc[TARGET_NCCS]; /* control characters */ + target_tcflag_t c_iflag; /* input mode flags */ + target_tcflag_t c_oflag; /* output mode flags */ + target_tcflag_t c_cflag; /* control mode flags */ + target_tcflag_t c_lflag; /* local mode flags */ + target_cc_t c_line; /* line discipline */ + target_cc_t c_cc[TARGET_NCCS]; /* control characters */ }; + /* c_cc characters */ #define TARGET_VINTR 0 #define TARGET_VQUIT 1 @@ -150,6 +155,8 @@ struct target_termios { #define TARGET_FLUSHO 0010000 #define TARGET_PENDIN 0040000 #define TARGET_IEXTEN 0100000 +#define TARGET_EXTPROC 0200000 + /* tcflow() and TCXONC use these */ #define TARGET_TCOOFF 0 diff --git a/linux-user/sparc/termbits.h b/linux-user/sparc/termbits.h index f85219ed7112..704bee1c427e 100644 --- a/linux-user/sparc/termbits.h +++ b/linux-user/sparc/termbits.h @@ -5,15 +5,20 @@ #define TARGET_NCCS 19 +typedef unsigned char target_cc_t; /* cc_t */ +typedef unsigned int target_speed_t; /* speed_t */ +typedef unsigned int target_tcflag_t; /* tcflag_t */ + struct target_termios { - unsigned int c_iflag; /* input mode flags */ - unsigned int c_oflag; /* output mode flags */ - unsigned int c_cflag; /* control mode flags */ - unsigned int c_lflag; /* local mode flags */ - unsigned char c_line; /* line discipline */ - unsigned char c_cc[TARGET_NCCS]; /* control characters */ + target_tcflag_t c_iflag; /* input mode flags */ + target_tcflag_t c_oflag; /* output mode flags */ + target_tcflag_t c_cflag; /* control mode flags */ + target_tcflag_t c_lflag; /* local mode flags */ + target_cc_t c_line; /* line discipline */ + target_cc_t c_cc[TARGET_NCCS]; /* control characters */ }; + /* c_cc characters */ #define TARGET_VINTR 0 #define TARGET_VQUIT 1 @@ -170,6 +175,7 @@ struct target_termios { #define TARGET_FLUSHO 0x00002000 #define TARGET_PENDIN 0x00004000 #define TARGET_IEXTEN 0x00008000 +#define TARGET_EXTPROC 0x00010000 /* ioctls */ diff --git a/linux-user/sparc64/termbits.h b/linux-user/sparc64/termbits.h index 11b5abcf8439..1ab1e80db548 100644 --- a/linux-user/sparc64/termbits.h +++ b/linux-user/sparc64/termbits.h @@ -5,15 +5,20 @@ #define TARGET_NCCS 19 +typedef unsigned char target_cc_t; /* cc_t */ +typedef unsigned int target_speed_t; /* speed_t */ +typedef unsigned int target_tcflag_t; /* tcflag_t */ + struct target_termios { - unsigned int c_iflag; /* input mode flags */ - unsigned int c_oflag; /* output mode flags */ - unsigned int c_cflag; /* control mode flags */ - unsigned int c_lflag; /* local mode flags */ - unsigned char c_line; /* line discipline */ - unsigned char c_cc[TARGET_NCCS]; /* control characters */ + target_tcflag_t c_iflag; /* input mode flags */ + target_tcflag_t c_oflag; /* output mode flags */ + target_tcflag_t c_cflag; /* control mode flags */ + target_tcflag_t c_lflag; /* local mode flags */ + target_cc_t c_line; /* line discipline */ + target_cc_t c_cc[TARGET_NCCS]; /* control characters */ }; + /* c_cc characters */ #define TARGET_VINTR 0 #define TARGET_VQUIT 1 @@ -170,6 +175,7 @@ struct target_termios { #define TARGET_FLUSHO 0x00002000 #define TARGET_PENDIN 0x00004000 #define TARGET_IEXTEN 0x00008000 +#define TARGET_EXTPROC 0x00010000 /* ioctls */ diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 027dea35af41..3a7eced7d858 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -5549,6 +5549,7 @@ static const bitmask_transtbl iflag_tbl[] = { { TARGET_IXANY, TARGET_IXANY, IXANY, IXANY }, { TARGET_IXOFF, TARGET_IXOFF, IXOFF, IXOFF }, { TARGET_IMAXBEL, TARGET_IMAXBEL, IMAXBEL, IMAXBEL }, + { TARGET_IUTF8, TARGET_IUTF8, IUTF8, IUTF8}, { 0, 0, 0, 0 } }; @@ -5616,22 +5617,23 @@ static const bitmask_transtbl cflag_tbl[] = { }; static const bitmask_transtbl lflag_tbl[] = { - { TARGET_ISIG, TARGET_ISIG, ISIG, ISIG }, - { TARGET_ICANON, TARGET_ICANON, ICANON, ICANON }, - { TARGET_XCASE, TARGET_XCASE, XCASE, XCASE }, - { TARGET_ECHO, TARGET_ECHO, ECHO, ECHO }, - { TARGET_ECHOE, TARGET_ECHOE, ECHOE, ECHOE }, - { TARGET_ECHOK, TARGET_ECHOK, ECHOK, ECHOK }, - { TARGET_ECHONL, TARGET_ECHONL, ECHONL, ECHONL }, - { TARGET_NOFLSH, TARGET_NOFLSH, NOFLSH, NOFLSH }, - { TARGET_TOSTOP, TARGET_TOSTOP, TOSTOP, TOSTOP }, - { TARGET_ECHOCTL, TARGET_ECHOCTL, ECHOCTL, ECHOCTL }, - { TARGET_ECHOPRT, TARGET_ECHOPRT, ECHOPRT, ECHOPRT }, - { TARGET_ECHOKE, TARGET_ECHOKE, ECHOKE, ECHOKE }, - { TARGET_FLUSHO, TARGET_FLUSHO, FLUSHO, FLUSHO }, - { TARGET_PENDIN, TARGET_PENDIN, PENDIN, PENDIN }, - { TARGET_IEXTEN, TARGET_IEXTEN, IEXTEN, IEXTEN }, - { 0, 0, 0, 0 } + { TARGET_ISIG, TARGET_ISIG, ISIG, ISIG }, + { TARGET_ICANON, TARGET_ICANON, ICANON, ICANON }, + { TARGET_XCASE, TARGET_XCASE, XCASE, XCASE }, + { TARGET_ECHO, TARGET_ECHO, ECHO, ECHO }, + { TARGET_ECHOE, TARGET_ECHOE, ECHOE, ECHOE }, + { TARGET_ECHOK, TARGET_ECHOK, ECHOK, ECHOK }, + { TARGET_ECHONL, TARGET_ECHONL, ECHONL, ECHONL }, + { TARGET_NOFLSH, TARGET_NOFLSH, NOFLSH, NOFLSH }, + { TARGET_TOSTOP, TARGET_TOSTOP, TOSTOP, TOSTOP }, + { TARGET_ECHOCTL, TARGET_ECHOCTL, ECHOCTL, ECHOCTL }, + { TARGET_ECHOPRT, TARGET_ECHOPRT, ECHOPRT, ECHOPRT }, + { TARGET_ECHOKE, TARGET_ECHOKE, ECHOKE, ECHOKE }, + { TARGET_FLUSHO, TARGET_FLUSHO, FLUSHO, FLUSHO }, + { TARGET_PENDIN, TARGET_PENDIN, PENDIN, PENDIN }, + { TARGET_IEXTEN, TARGET_IEXTEN, IEXTEN, IEXTEN }, + { TARGET_EXTPROC, TARGET_EXTPROC, EXTPROC, EXTPROC}, + { 0, 0, 0, 0 } }; static void target_to_host_termios (void *dst, const void *src) diff --git a/linux-user/xtensa/termbits.h b/linux-user/xtensa/termbits.h index d1e09e61a69b..ce6fb081e355 100644 --- a/linux-user/xtensa/termbits.h +++ b/linux-user/xtensa/termbits.h @@ -15,40 +15,42 @@ #include -typedef unsigned char cc_t; -typedef unsigned int speed_t; -typedef unsigned int tcflag_t; - #define TARGET_NCCS 19 + +typedef unsigned char target_cc_t; /* cc_t */ +typedef unsigned int target_speed_t; /* speed_t */ +typedef unsigned int target_tcflag_t; /* tcflag_t */ + struct target_termios { - tcflag_t c_iflag; /* input mode flags */ - tcflag_t c_oflag; /* output mode flags */ - tcflag_t c_cflag; /* control mode flags */ - tcflag_t c_lflag; /* local mode flags */ - cc_t c_line; /* line discipline */ - cc_t c_cc[TARGET_NCCS]; /* control characters */ + target_tcflag_t c_iflag; /* input mode flags */ + target_tcflag_t c_oflag; /* output mode flags */ + target_tcflag_t c_cflag; /* control mode flags */ + target_tcflag_t c_lflag; /* local mode flags */ + target_cc_t c_line; /* line discipline */ + target_cc_t c_cc[TARGET_NCCS]; /* control characters */ }; + struct target_termios2 { - tcflag_t c_iflag; /* input mode flags */ - tcflag_t c_oflag; /* output mode flags */ - tcflag_t c_cflag; /* control mode flags */ - tcflag_t c_lflag; /* local mode flags */ - cc_t c_line; /* line discipline */ - cc_t c_cc[TARGET_NCCS]; /* control characters */ - speed_t c_ispeed; /* input speed */ - speed_t c_ospeed; /* output speed */ + target_tcflag_t c_iflag; /* input mode flags */ + target_tcflag_t c_oflag; /* output mode flags */ + target_tcflag_t c_cflag; /* control mode flags */ + target_tcflag_t c_lflag; /* local mode flags */ + target_cc_t c_line; /* line discipline */ + target_cc_t c_cc[TARGET_NCCS]; /* control characters */ + target_speed_t c_ispeed; /* input speed */ + target_speed_t c_ospeed; /* output speed */ }; struct target_ktermios { - tcflag_t c_iflag; /* input mode flags */ - tcflag_t c_oflag; /* output mode flags */ - tcflag_t c_cflag; /* control mode flags */ - tcflag_t c_lflag; /* local mode flags */ - cc_t c_line; /* line discipline */ - cc_t c_cc[TARGET_NCCS]; /* control characters */ - speed_t c_ispeed; /* input speed */ - speed_t c_ospeed; /* output speed */ + target_tcflag_t c_iflag; /* input mode flags */ + target_tcflag_t c_oflag; /* output mode flags */ + target_tcflag_t c_cflag; /* control mode flags */ + target_tcflag_t c_lflag; /* local mode flags */ + target_cc_t c_line; /* line discipline */ + target_cc_t c_cc[TARGET_NCCS]; /* control characters */ + target_speed_t c_ispeed; /* input speed */ + target_speed_t c_ospeed; /* output speed */ }; /* c_cc characters */ @@ -195,6 +197,7 @@ struct target_ktermios { #define TARGET_FLUSHO 0010000 #define TARGET_PENDIN 0040000 #define TARGET_IEXTEN 0100000 +#define TARGET_EXTPROC 0200000 /* tcflow() and TCXONC use these */ From patchwork Thu Aug 27 19:20:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 11741469 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A28F614E5 for ; Thu, 27 Aug 2020 19:26:20 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 70B04207CD for ; Thu, 27 Aug 2020 19:26:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 70B04207CD Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=vivier.eu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:56478 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kBNXP-0007FD-KQ for patchwork-qemu-devel@patchwork.kernel.org; Thu, 27 Aug 2020 15:26:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33562) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kBNS9-0004IZ-Eg for qemu-devel@nongnu.org; Thu, 27 Aug 2020 15:20:54 -0400 Received: from mout.kundenserver.de ([217.72.192.74]:37795) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kBNS4-0000Hf-Hc for qemu-devel@nongnu.org; Thu, 27 Aug 2020 15:20:53 -0400 Received: from localhost.localdomain ([82.252.135.186]) by mrelayeu.kundenserver.de (mreue109 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MCKO4-1kKl7M3sxO-009Sui; Thu, 27 Aug 2020 21:20:39 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 11/18] linux-user: Add strace support for printing arguments for ioctls used for terminals and serial lines Date: Thu, 27 Aug 2020 21:20:11 +0200 Message-Id: <20200827192018.2442099-12-laurent@vivier.eu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200827192018.2442099-1-laurent@vivier.eu> References: <20200827192018.2442099-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:Y4bw08JHfOGhNVxi32D3iGN7ty/cltgt5tSsq3spaUoCvb0udr2 KV0YApc9HWFUjN+/+FBWVRi3ik/WBR1oBXcbR7C9vpY5F8Hh5RF2LRog3QqFfmpRZS4/ly3 wuisP7a1R/FGROOJ3I06MiJZI/dOXBg/ssQ6OWmIabiN0VZC2Zvwg4DXyDe3rmS6PLg5njo mNoA2PUDCF2CaxyaoPspw== X-UI-Out-Filterresults: notjunk:1;V03:K0:iylAp4DpNF4=:cAmYEnwEBRbeoDBWmMjp9G 61Lhhg963qw+EV5IzLKjwQ3lQLuNKKhjlZb0IHgsqotK/y9ZPlym9LfN4eVKYvdEwZ/Sys4R9 eIe5wa8uqVf1yKlzTtcSsh8Pa63IFBlQo/9FPCOtRChnBqV/CbuvYxmKUu5Zi2985hQ4RIfK+ 51Dm6k7n7pETY6/PyFe6GRAMpRuBNdVVOyOfDa6QwIWoHNo2Sq2NUU4whg2N3X8tRWyF2Yfxp SwZK9YMrIO43kYvoIKVLtUIr/nzXNMtpo8uA2Iz30qWL6pmsm0en/QQ9ek44V+HW2byLb0uIb O6GzteGcfVDk12WsM5Po5ovxyQTDUguYVLWRNFPTO81QuRkvXasfWmpjmH2+y+Dmu3EXqbZ0k rLjSbg+2R35tpJfB2QvbvwSvkaXoIDHZOSrKX2SrasORilmhTLu/2tQOiYrZW9+Kj8BRXlJq5 lDgkpCIT8TXiD3hcEzc1PpaXj1tIYNq1yVt7638nMehhTrbLE7sXDPA3PA/+pAfOGmH9X5vAl nrDGL+N1BxXfKtWReEQ1Tzj7vyivobYEx1P1yv8VnWBFu0fAFn8nCJyMAotpvT/MIP7+1PfsF towtjUgw3FQNEI7ahviLnXwsXcE9ZHdihQLZh16fpGv0C8kILdvURBCpgmFG9ZDg4jTYqa/wI +W34Zcevt7v9lXj7nsJ/l6ZBQyr2LvhhBVG9Ng8Gl+OigfXJlQLMKQ/MzDqr9UX1U6Y3ZOM3L 9tMwdlogNCDi66AnzzB7Ol5P4Tmiifg6xxcCvRSWuv5Bjyp05c6u6dGKWE+JIGo1p738+FMho 2Jurdhsn6oz7KvkwFOualLpWLyBs2vV170VrwMJq4WMRXQ/N8ot7ZQMd2H8xJW8PZCQyp6b Received-SPF: none client-ip=217.72.192.74; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/27 15:20:33 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] 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, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Riku Voipio , Laurent Vivier , Filip Bozuta Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Filip Bozuta Functions "print_ioctl()" and "print_syscall_ret_ioctl()" are used to print arguments of "ioctl()" with "-strace". These functions use "thunk_print()", which is defined in "thunk.c", to print the contents of ioctl's third arguments that are not basic types. However, this function doesn't handle ioctls of group ioctl_tty which are used for terminals and serial lines. These ioctls use a type "struct termios" which thunk type is defined in a non standard way using "STRUCT_SPECIAL()". This means that this type is not decoded regularly using "thunk_convert()" and uses special converting functions "target_to_host_termios()" and "host_to_target_termios()", which are defined in "syscall.c" to decode it's values. For simillar reasons, this type is also not printed regularly using "thunk_print()". That is the reason why a separate printing function "print_termios()" is defined in file "strace.c". This function decodes and prints flag values of the "termios" structure. Implementation notes: Function "print_termios()" was implemented in "strace.c" using an existing function "print_flags()" to print flag values of "struct termios" fields. Also, recently implemented function "print_enums()" was also used to print enumareted values which are contained in the fields of 'struct termios'. These flag values were defined using an existing macro "FLAG_TARGET()" that generates aproppriate target flag values and string representations of these flags. Also, the recently defined macro "ENUM_TARGET()" was used to generate aproppriate enumarated values and their respective string representations. Function "print_termios()" was declared in "qemu.h" so that it can be accessed in "syscall.c". Type "StructEntry" defined in "exec/user/thunk.h" contains information that is used to decode structure values. Field "void print(void *arg)" was added in this structure as a special print function. Also, function "thunk_print()" was changed a little so that it uses this special print function in case it is defined. This printing function was instantiated with the defined "print_termios()" in "syscall.c" in "struct_termios_def". Signed-off-by: Filip Bozuta Reviewed-by: Laurent Vivier Message-Id: <20200723210233.349690-4-Filip.Bozuta@syrmia.com> Signed-off-by: Laurent Vivier --- include/exec/user/thunk.h | 1 + linux-user/qemu.h | 1 + linux-user/strace.c | 195 ++++++++++++++++++++++++++++++++++++++ linux-user/syscall.c | 1 + thunk.c | 23 +++-- 5 files changed, 212 insertions(+), 9 deletions(-) diff --git a/include/exec/user/thunk.h b/include/exec/user/thunk.h index 7992475c9f8a..a5bbb2c73331 100644 --- a/include/exec/user/thunk.h +++ b/include/exec/user/thunk.h @@ -55,6 +55,7 @@ typedef struct { int *field_offsets[2]; /* special handling */ void (*convert[2])(void *dst, const void *src); + void (*print)(void *arg); int size[2]; int align[2]; const char *name; diff --git a/linux-user/qemu.h b/linux-user/qemu.h index f431805e573f..a69a0bd347c2 100644 --- a/linux-user/qemu.h +++ b/linux-user/qemu.h @@ -706,6 +706,7 @@ static inline uint64_t target_offset64(uint64_t word0, uint64_t word1) } #endif /* TARGET_ABI_BITS != 32 */ +void print_termios(void *arg); /* ARM EABI and MIPS expect 64bit types aligned even on pairs or registers */ #ifdef TARGET_ARM diff --git a/linux-user/strace.c b/linux-user/strace.c index c7ef948b9451..4f77b0cf76eb 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -1226,6 +1226,140 @@ UNUSED static struct flags falloc_flags[] = { #endif }; +UNUSED static struct flags termios_iflags[] = { + FLAG_TARGET(IGNBRK), + FLAG_TARGET(BRKINT), + FLAG_TARGET(IGNPAR), + FLAG_TARGET(PARMRK), + FLAG_TARGET(INPCK), + FLAG_TARGET(ISTRIP), + FLAG_TARGET(INLCR), + FLAG_TARGET(IGNCR), + FLAG_TARGET(ICRNL), + FLAG_TARGET(IUCLC), + FLAG_TARGET(IXON), + FLAG_TARGET(IXANY), + FLAG_TARGET(IXOFF), + FLAG_TARGET(IMAXBEL), + FLAG_TARGET(IUTF8), + FLAG_END, +}; + +UNUSED static struct flags termios_oflags[] = { + FLAG_TARGET(OPOST), + FLAG_TARGET(OLCUC), + FLAG_TARGET(ONLCR), + FLAG_TARGET(OCRNL), + FLAG_TARGET(ONOCR), + FLAG_TARGET(ONLRET), + FLAG_TARGET(OFILL), + FLAG_TARGET(OFDEL), + FLAG_END, +}; + +UNUSED static struct enums termios_oflags_NLDLY[] = { + ENUM_TARGET(NL0), + ENUM_TARGET(NL1), + ENUM_END, +}; + +UNUSED static struct enums termios_oflags_CRDLY[] = { + ENUM_TARGET(CR0), + ENUM_TARGET(CR1), + ENUM_TARGET(CR2), + ENUM_TARGET(CR3), + ENUM_END, +}; + +UNUSED static struct enums termios_oflags_TABDLY[] = { + ENUM_TARGET(TAB0), + ENUM_TARGET(TAB1), + ENUM_TARGET(TAB2), + ENUM_TARGET(TAB3), + ENUM_END, +}; + +UNUSED static struct enums termios_oflags_VTDLY[] = { + ENUM_TARGET(VT0), + ENUM_TARGET(VT1), + ENUM_END, +}; + +UNUSED static struct enums termios_oflags_FFDLY[] = { + ENUM_TARGET(FF0), + ENUM_TARGET(FF1), + ENUM_END, +}; + +UNUSED static struct enums termios_oflags_BSDLY[] = { + ENUM_TARGET(BS0), + ENUM_TARGET(BS1), + ENUM_END, +}; + +UNUSED static struct enums termios_cflags_CBAUD[] = { + ENUM_TARGET(B0), + ENUM_TARGET(B50), + ENUM_TARGET(B75), + ENUM_TARGET(B110), + ENUM_TARGET(B134), + ENUM_TARGET(B150), + ENUM_TARGET(B200), + ENUM_TARGET(B300), + ENUM_TARGET(B600), + ENUM_TARGET(B1200), + ENUM_TARGET(B1800), + ENUM_TARGET(B2400), + ENUM_TARGET(B4800), + ENUM_TARGET(B9600), + ENUM_TARGET(B19200), + ENUM_TARGET(B38400), + ENUM_TARGET(B57600), + ENUM_TARGET(B115200), + ENUM_TARGET(B230400), + ENUM_TARGET(B460800), + ENUM_END, +}; + +UNUSED static struct enums termios_cflags_CSIZE[] = { + ENUM_TARGET(CS5), + ENUM_TARGET(CS6), + ENUM_TARGET(CS7), + ENUM_TARGET(CS8), + ENUM_END, +}; + +UNUSED static struct flags termios_cflags[] = { + FLAG_TARGET(CSTOPB), + FLAG_TARGET(CREAD), + FLAG_TARGET(PARENB), + FLAG_TARGET(PARODD), + FLAG_TARGET(HUPCL), + FLAG_TARGET(CLOCAL), + FLAG_TARGET(CRTSCTS), + FLAG_END, +}; + +UNUSED static struct flags termios_lflags[] = { + FLAG_TARGET(ISIG), + FLAG_TARGET(ICANON), + FLAG_TARGET(XCASE), + FLAG_TARGET(ECHO), + FLAG_TARGET(ECHOE), + FLAG_TARGET(ECHOK), + FLAG_TARGET(ECHONL), + FLAG_TARGET(NOFLSH), + FLAG_TARGET(TOSTOP), + FLAG_TARGET(ECHOCTL), + FLAG_TARGET(ECHOPRT), + FLAG_TARGET(ECHOKE), + FLAG_TARGET(FLUSHO), + FLAG_TARGET(PENDIN), + FLAG_TARGET(IEXTEN), + FLAG_TARGET(EXTPROC), + FLAG_END, +}; + UNUSED static struct flags mlockall_flags[] = { FLAG_TARGET(MCL_CURRENT), FLAG_TARGET(MCL_FUTURE), @@ -1553,6 +1687,67 @@ print_itimerval(abi_ulong it_addr, int last) } } +void +print_termios(void *arg) +{ + const struct target_termios *target = arg; + + target_tcflag_t iflags = tswap32(target->c_iflag); + target_tcflag_t oflags = tswap32(target->c_oflag); + target_tcflag_t cflags = tswap32(target->c_cflag); + target_tcflag_t lflags = tswap32(target->c_lflag); + + qemu_log("{"); + + qemu_log("c_iflag = "); + print_flags(termios_iflags, iflags, 0); + + qemu_log("c_oflag = "); + target_tcflag_t oflags_clean = oflags & ~(TARGET_NLDLY | TARGET_CRDLY | + TARGET_TABDLY | TARGET_BSDLY | + TARGET_VTDLY | TARGET_FFDLY); + print_flags(termios_oflags, oflags_clean, 0); + if (oflags & TARGET_NLDLY) { + print_enums(termios_oflags_NLDLY, oflags & TARGET_NLDLY, 0); + } + if (oflags & TARGET_CRDLY) { + print_enums(termios_oflags_CRDLY, oflags & TARGET_CRDLY, 0); + } + if (oflags & TARGET_TABDLY) { + print_enums(termios_oflags_TABDLY, oflags & TARGET_TABDLY, 0); + } + if (oflags & TARGET_BSDLY) { + print_enums(termios_oflags_BSDLY, oflags & TARGET_BSDLY, 0); + } + if (oflags & TARGET_VTDLY) { + print_enums(termios_oflags_VTDLY, oflags & TARGET_VTDLY, 0); + } + if (oflags & TARGET_FFDLY) { + print_enums(termios_oflags_FFDLY, oflags & TARGET_FFDLY, 0); + } + + qemu_log("c_cflag = "); + if (cflags & TARGET_CBAUD) { + print_enums(termios_cflags_CBAUD, cflags & TARGET_CBAUD, 0); + } + if (cflags & TARGET_CSIZE) { + print_enums(termios_cflags_CSIZE, cflags & TARGET_CSIZE, 0); + } + target_tcflag_t cflags_clean = cflags & ~(TARGET_CBAUD | TARGET_CSIZE); + print_flags(termios_cflags, cflags_clean, 0); + + qemu_log("c_lflag = "); + print_flags(termios_lflags, lflags, 0); + + qemu_log("c_cc = "); + qemu_log("\"%s\",", target->c_cc); + + qemu_log("c_line = "); + print_raw_param("\'%c\'", target->c_line, 1); + + qemu_log("}"); +} + #undef UNUSED #ifdef TARGET_NR_accept diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 3a7eced7d858..78e404c23cad 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -5710,6 +5710,7 @@ static const StructEntry struct_termios_def = { .convert = { host_to_target_termios, target_to_host_termios }, .size = { sizeof(struct target_termios), sizeof(struct host_termios) }, .align = { __alignof__(struct target_termios), __alignof__(struct host_termios) }, + .print = print_termios, }; static bitmask_transtbl mmap_flags_tbl[] = { diff --git a/thunk.c b/thunk.c index c5d971974783..0718325d86e3 100644 --- a/thunk.c +++ b/thunk.c @@ -404,19 +404,24 @@ const argtype *thunk_print(void *arg, const argtype *type_ptr) const int *arg_offsets; se = struct_entries + *type_ptr++; - a = arg; - field_types = se->field_types; - arg_offsets = se->field_offsets[0]; + if (se->print != NULL) { + se->print(arg); + } else { + a = arg; - qemu_log("{"); - for (i = 0; i < se->nb_fields; i++) { - if (i > 0) { - qemu_log(","); + field_types = se->field_types; + arg_offsets = se->field_offsets[0]; + + qemu_log("{"); + for (i = 0; i < se->nb_fields; i++) { + if (i > 0) { + qemu_log(","); + } + field_types = thunk_print(a + arg_offsets[i], field_types); } - field_types = thunk_print(a + arg_offsets[i], field_types); + qemu_log("}"); } - qemu_log("}"); } break; default: From patchwork Thu Aug 27 19:20:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 11741539 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B3B9A14E5 for ; Thu, 27 Aug 2020 19:28:39 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 94D6522BEA for ; Thu, 27 Aug 2020 19:28:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 94D6522BEA Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=vivier.eu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:39310 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kBNZe-0003PE-T6 for patchwork-qemu-devel@patchwork.kernel.org; Thu, 27 Aug 2020 15:28:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33546) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kBNS7-0004Gr-8F for qemu-devel@nongnu.org; Thu, 27 Aug 2020 15:20:51 -0400 Received: from mout.kundenserver.de ([217.72.192.75]:51841) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kBNS4-0000Hj-NC for qemu-devel@nongnu.org; Thu, 27 Aug 2020 15:20:50 -0400 Received: from localhost.localdomain ([82.252.135.186]) by mrelayeu.kundenserver.de (mreue109 [212.227.15.183]) with ESMTPSA (Nemesis) id 1M26j1-1k9SZi438j-002YDn; Thu, 27 Aug 2020 21:20:40 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 12/18] linux-user: detect mismatched ELF ABI in qemu-mips[n32][el] Date: Thu, 27 Aug 2020 21:20:12 +0200 Message-Id: <20200827192018.2442099-13-laurent@vivier.eu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200827192018.2442099-1-laurent@vivier.eu> References: <20200827192018.2442099-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:3a5cuka67oPdds3oSYa2QogLjTh7BMJaWm8nEX7axOnKbErVT+y KMaBf2RC1lqP4dHHdQHqkYpcZAFb5taHh6poQzRYB8eE5MuLzwSnOeWDMvoX2uE1vX3xGwu +C/1lnQVq85WX1krLD0qtUBIueMKNIeRQMRcnDpmocyTAIeHVBp/+vozMXU9bCTogQwreCW oenu5tRfvO+6ufsOwvK2A== X-UI-Out-Filterresults: notjunk:1;V03:K0:cNgmMd3JTFs=:lGhZnAP5N7cqL++s3PriZf PFigbpeWjyBwwiGN/aapMjA6jk+c3dGQev2Gm2jrls0VvizWstEcF1+ws26apOAWF981bFFlX 0xVEfOwxNCyOjllHuyaJTBPA6hr5YcfW9si5CIGXPTI0We9Y+NgnGUhr8lM1rRFbKJcypfFHx GfUeLZlGyHEzTzY5Cue/ng9/7GEDI/8pE6W9J6gomrzouhyblj1dUtCyKbw2gqHEXLAk8P+9I B9koHu+wndxg/hxu87kf7fyNL5QagNi6vBdhg+/nSyqHS5kDdygKxf0s4vBTn9QuGuCEKiLhJ cx/SyVZEQbKcJopt4oKgh1XGmgTOCtJPvhd6nDOQeuCwvJcSI6ygm8l+AvEdf4omNIutgor9F XGwCGgldSoBEE7mQuwrErLQLQyJjbbiomsagY/tQhL7mWr0SjfXNmiO2awqwHdsr4UjglKnlD AUQNYvG8bUimXDZXNYlTyHY/9+PUBUzLlOiEYp9Ie/yzYMEK7RbXAWjSlVUnbjtGuAHI1XhLj oYBdSkP/lA93GkTmTxDMYTBjxco8gTKVDptS5YKgkQEL3vsn/xa8DgeDnB1Q/GeV9J9UeE3cy tW11avF//8Xd8mUSe85j1u/QlDp7K6El5o2YZZG9hynLxQhUhoyVlJSWHpl81wEhj1Aisb8lW YIyOoWjsH9f9LTsVjAUtgyvcM8ILjdyvulvYyaDoYN35TH6uDWr3OyzVnDGFGLowuHnPRfOH+ ZzKMCsbEq2D861u3DBxAizlPgL20NS4SRHHCepFVDYJrcBUcluTXScXgc967JT2illSTcnegH /jZALvoc/l8JegYJX5IpgsGXPTYknlodJxB/9NHxF1D8KuxHX9wnbcJK7SlHvu216b8HR8e Received-SPF: none client-ip=217.72.192.75; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/27 15:20:36 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] 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, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Carlo_Marcelo_Arenas_Bel=C3=B3n?= , Riku Voipio , Laurent Vivier Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Carlo Marcelo Arenas Belón MIPS provides 2 ILP32 ABIs, and therefore 4 possible qemu-mips binaries with 2 pairs using the same endianess and bitness. This could lead to an O32 image loading in the N32 binary or vice versa and in cryptic errors (if lucky that the CPU doesn't match the FPU used) like : qemu: Unexpected FPU mode (o32 ELF loaded to qemu-mipsn32[el]) ELF binary's NaN mode not supported by CPU (n32 -> qemu-mips[el]) Add an ABI check macro that could be used while checking the ELF header that relies in the ABI2 flag to identify n32 binaries and abort instead early with a more descriptive error : Invalid ELF image for this architecture Signed-off-by: Carlo Marcelo Arenas Belón Reviewed-by: Laurent Vivier Message-Id: <20200823101703.18451-1-carenas@gmail.com> Signed-off-by: Laurent Vivier --- linux-user/elfload.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index fe9dfe795ddd..69936dcd4595 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -918,6 +918,12 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUPPCState *en #define elf_check_arch(x) ((x) == EM_MIPS || (x) == EM_NANOMIPS) +#ifdef TARGET_ABI_MIPSN32 +#define elf_check_abi(x) ((x) & EF_MIPS_ABI2) +#else +#define elf_check_abi(x) (!((x) & EF_MIPS_ABI2)) +#endif + static inline void init_thread(struct target_pt_regs *regs, struct image_info *infop) { @@ -1487,6 +1493,10 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs, #define elf_check_arch(x) ((x) == ELF_ARCH) #endif +#ifndef elf_check_abi +#define elf_check_abi(x) (1) +#endif + #ifndef ELF_HWCAP #define ELF_HWCAP 0 #endif @@ -1644,6 +1654,7 @@ static bool elf_check_ident(struct elfhdr *ehdr) static bool elf_check_ehdr(struct elfhdr *ehdr) { return (elf_check_arch(ehdr->e_machine) + && elf_check_abi(ehdr->e_flags) && ehdr->e_ehsize == sizeof(struct elfhdr) && ehdr->e_phentsize == sizeof(struct elf_phdr) && (ehdr->e_type == ET_EXEC || ehdr->e_type == ET_DYN)); From patchwork Thu Aug 27 19:20:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 11741545 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B3F2914E5 for ; Thu, 27 Aug 2020 19:28:42 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 932A0207CD for ; Thu, 27 Aug 2020 19:28:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 932A0207CD Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=vivier.eu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:39530 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kBNZh-0003Uj-Mn for patchwork-qemu-devel@patchwork.kernel.org; Thu, 27 Aug 2020 15:28:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33580) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kBNSA-0004Ie-On for qemu-devel@nongnu.org; Thu, 27 Aug 2020 15:20:54 -0400 Received: from mout.kundenserver.de ([217.72.192.74]:48915) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kBNS6-0000Hs-3E for qemu-devel@nongnu.org; Thu, 27 Aug 2020 15:20:54 -0400 Received: from localhost.localdomain ([82.252.135.186]) by mrelayeu.kundenserver.de (mreue109 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MRmsG-1k12PK3FPu-00TBcq; Thu, 27 Aug 2020 21:20:41 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 13/18] linux-user: Fix 'mq_timedsend()' and 'mq_timedreceive()' Date: Thu, 27 Aug 2020 21:20:13 +0200 Message-Id: <20200827192018.2442099-14-laurent@vivier.eu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200827192018.2442099-1-laurent@vivier.eu> References: <20200827192018.2442099-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:5dyNkvOh6Z1u0ZcfiYHQ9lBcwo5/HgdFcUFLCj7x+AR83Ht23CU cEpov2qXrAikOMzcAen9W2NZiKUfN5ZudJsww4NFvuum+OPDAUC9z9iS8JAHsAt5KhN+LC7 cG2Dsld0DOMqOesHdQqflBrcojPif08YjaSBsGQIwQvyuKJXS6YX+woyJgI0pAtmGcHTSuH eq8Ngws2esKF9WpSr34Iw== X-UI-Out-Filterresults: notjunk:1;V03:K0:YtvA9Vr2q9k=:cFUQ3jZdjsawVGl0wt6DZG ujPOV2asFZUAowjUKstfPJywpj085Fsg7U7O05IJuLEnh+2KBkjuQdWRcC2pQnaO/pxl3h3TU Ame8aTyZMJ3WmUqnM6l3k0dFwvP4qzgKlVjo2J1tXmTaYR5E+lk5o9NiJrTcBuxc7AJYIazuL eXCjfVSm0UUsS5k3u8ou+ZBR6S4X3XsMvkaR0Boone7/EHtgLjr1CnW/ktbG3tPJ98ACBvVFC 9ZSOno6OLsvJnWnoaQO2dVl8GCa5EcTBd12reOtwYMnQSyfifU5OfXFCk7K30ldoqRi+JwI2w dq7Zd760oFH2Yvqr36y4KnVpTlFq/wxoWgRJcpE6jTZBX6CCE/VGsbGqntTr42QlHYlRiugvX SqR8ypEOTb9CaZiPpP79X6d4PDikq275gPodHqDOqHj4iO0ZxIg9tuCzDm3c9B2l74nHF9aCz JZpgoGvJTCKd5BNNZk3bi6OTK9MQj9GWu7GE5FnwgaabJR3smENHXlJ8NrnvqgI2OYae/LQ3A DFNX07o+v2GVOJNbsS1waZqxO7EkNGmTJzRzlxuTnViqlModwFdHLFMUDLQt/I7RXF1Y42A3b ktPLSgZBP2KgDS6ybUKBssUo9/VX9PTA62YzWStE6fSyDfL69UJPvTRvgyzumMaYfNNKJ3hyJ ZWD0EspyeSXkUuuCr4Nbzgsbk9vf8qbLWZJQW+3/a8tr8jfee6w0uULs1RxXHB8YL/u/fqMD8 MghNYNUD2moAbqY5eQQs1owWCTvXPhEcmI0sQenPqmFdWOtRuU+x+2vDh3DI3XFIqhyoJSifL u74UCJt3fpYS7Le/SmvA64cEooAqLynmlRszLF3V1wXukXVpxTxLW7a6zCSdeP6xa2Jph/M Received-SPF: none client-ip=217.72.192.74; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/27 15:20:33 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] 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, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Riku Voipio , Laurent Vivier , Filip Bozuta Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Filip Bozuta Implementations of syscalls 'mq_timedsend()' and 'mq_timedreceive()' in 'syscall.c' use functions 'target_to_host_timespec()' and 'host_to_target_timespec()' to transfer the value of 'struct timespec' between target and host. However, the implementations don't check whether this conversion succeeds and thus can cause an unaproppriate error instead of the 'EFAULT (Bad address)' which is supposed to be set if the conversion from target to host fails. This was confirmed with the modified LTP test suite where test cases with a bad adress for 'timespec' were added. This modified test suite can be found at: https://github.com/bozutaf/ltp Without the changes from this patch the bad adress testcase for 'mq_timedsend()' succeds unexpectedly, while the test returns errno 'ETIMEOUT' for 'mq_timedreceive()': mq_timedsend01.c:190: FAIL: mq_timedsend() returned 0, expected -1: SUCCESS (0) mq_timedreceive01.c:178: FAIL: mq_timedreceive() failed unexpectedly, expected EFAULT: ETIMEDOUT (110) After the changes from this patch, testcases for both syscalls fail with EFAULT as expected, which is the same test result that is received with native execution: mq_timedsend01.c:187: PASS: mq_timedsend() failed expectedly: EFAULT (14) mq_timedreceive01.c:180: PASS: mq_timedreceive() failed expectedly: EFAULT (14) (Patch with this new test case will be sent to LTP mailing list soon) Signed-off-by: Filip Bozuta Reviewed-by: Laurent Vivier Message-Id: <20200824193752.67950-2-Filip.Bozuta@syrmia.com> Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 78e404c23cad..fd13e72305de 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -12043,9 +12043,13 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, p = lock_user (VERIFY_READ, arg2, arg3, 1); if (arg5 != 0) { - target_to_host_timespec(&ts, arg5); + if (target_to_host_timespec(&ts, arg5)) { + return -TARGET_EFAULT; + } ret = get_errno(safe_mq_timedsend(arg1, p, arg3, arg4, &ts)); - host_to_target_timespec(arg5, &ts); + if (!is_error(ret) && host_to_target_timespec(arg5, &ts)) { + return -TARGET_EFAULT; + } } else { ret = get_errno(safe_mq_timedsend(arg1, p, arg3, arg4, NULL)); } @@ -12062,10 +12066,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, p = lock_user (VERIFY_READ, arg2, arg3, 1); if (arg5 != 0) { - target_to_host_timespec(&ts, arg5); + if (target_to_host_timespec(&ts, arg5)) { + return -TARGET_EFAULT; + } ret = get_errno(safe_mq_timedreceive(arg1, p, arg3, &prio, &ts)); - host_to_target_timespec(arg5, &ts); + if (!is_error(ret) && host_to_target_timespec(arg5, &ts)) { + return -TARGET_EFAULT; + } } else { ret = get_errno(safe_mq_timedreceive(arg1, p, arg3, &prio, NULL)); From patchwork Thu Aug 27 19:20:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 11741475 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 42D9014E5 for ; Thu, 27 Aug 2020 19:26:59 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2362E207CD for ; Thu, 27 Aug 2020 19:26:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2362E207CD Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=vivier.eu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:59814 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kBNY2-0000CD-CW for patchwork-qemu-devel@patchwork.kernel.org; Thu, 27 Aug 2020 15:26:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33484) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kBNS2-00047n-3E for qemu-devel@nongnu.org; Thu, 27 Aug 2020 15:20:46 -0400 Received: from mout.kundenserver.de ([217.72.192.73]:55889) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kBNS0-0000F2-2w for qemu-devel@nongnu.org; Thu, 27 Aug 2020 15:20:45 -0400 Received: from localhost.localdomain ([82.252.135.186]) by mrelayeu.kundenserver.de (mreue109 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MLz3X-1ju7a43Nb7-00HtDD; Thu, 27 Aug 2020 21:20:42 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 14/18] linux-user: fix target_to_host_timespec64() Date: Thu, 27 Aug 2020 21:20:14 +0200 Message-Id: <20200827192018.2442099-15-laurent@vivier.eu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200827192018.2442099-1-laurent@vivier.eu> References: <20200827192018.2442099-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:CxGRs9mXvVilNaZtC1+4zOwQ4YePjGTWdV1cfU3v0vhyS+jNciE lnxORXPq6DQNd552ZLo+YEp5Ffd69UW9teohj9FNtCDeHSsTpD7WzjEJMhuWjP3V61TREuO tHFU6DnpHH9OawT6tOJmbKm7hG8TUD+4Jb6zc68phWhs1eor5zXgdPX74ZGbYUIenRuDAba X/dsKZSR58XL9w6yM5eqQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:bLdgEUoafGc=:NOlUBAdb7Qe60cJJRELIv4 8WCz+MZfyvfhZ0BVGm81Fvv/PR1Ubb4oO5l9HN+4KzpdnirWwOzTxyRCnCOvsh/2YvB7DMrMV Xc/FBiagjOKAR5BNDUSzqG/q9Gd8LpQ+TtUHcjOKW+M0RHxu4i+WbPAhHGWGHqntVHbBoHN3M hwUd1UWJig0EAMNSAydZ062GU/iTSiC0RISjrDVxDXuE5VxofGZ8bW1asaZT+xO/l2FAMjo0t V7zJLuX4gScVwCe+aoO45comS5MQIjucGE5b3JK8NYsE+rb2pC8dLVsGpyGIRDXzL5C8f8tsn RCj85SaOV1CLoELAaYDo1FWgdUkP4e+zEMRuC/rpKG7Za3qtqvLZbRpFQg0IP6oRQuHGea6cS D62WBxnGnl8dVVFrHp22Mccy6B1j0WW1UwJyDRVrMyHiRw5oDns3BlIYE4hhoRPBuL3k2+Ti7 cP0nz5BPQjssoO++vYlAxVOMO5+fSr75PxN0n2G0z1f8Hw8cZHUPyoViDdSvc5w1/QPRrXL64 t3K3eQlpK91dFzcSELEtQcsd8Jz0HerO+YO18V0uRZUm2oYSMPXFecL+1Us1eUUXOaobeImO4 39pZxVUq1Q5LNc07ejKAbND5oJ4zqcJhf6NUnw/wzgx5yHZQSN3gtsmOi+WjyGmho/L22OtBf LU3+FzVBBgMqn69NNk5zFynCdU7QthjFISti6cJ/f7naOqC0tnAF3/RamfYFKAa5N/D9kSwRH CW5VMujbACnt51fvQrURl5rgek9unwuAiRpxOKQGgYrj8gmAU43z1p/bp5tdEwP4fppeO0W1P TE38jFuw/HV1ViC0ObFd68V6zLW3tFTJTaeYVm3UefLkedwv7l0vwDikAt6bmlhdqnbLabN Received-SPF: none client-ip=217.72.192.73; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/27 15:20:29 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] 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, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Riku Voipio , Laurent Vivier Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" in 32 bit mode, drop the padding in tv_nsec. If host is 64bit and target is 32bit, the padding bytes will be copied from the target and as the kernel checks the value, the syscall exits with EINVAL. Signed-off-by: Laurent Vivier Message-Id: <20200827070449.2386007-1-laurent@vivier.eu> Fixes: c6c8d1026e75 ("linux-user/syscall: Add support for clock_gettime64/clock_settime64") --- linux-user/syscall.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index fd13e72305de..3b725bbe2513 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -1229,6 +1229,8 @@ static inline abi_long target_to_host_timespec64(struct timespec *host_ts, } __get_user(host_ts->tv_sec, &target_ts->tv_sec); __get_user(host_ts->tv_nsec, &target_ts->tv_nsec); + /* in 32bit mode, this drops the padding */ + host_ts->tv_nsec = (long)(abi_long)host_ts->tv_nsec; unlock_user_struct(target_ts, target_addr, 0); return 0; } From patchwork Thu Aug 27 19:20:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 11741595 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0BCA0109B for ; Thu, 27 Aug 2020 19:30:23 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E145D207DF for ; Thu, 27 Aug 2020 19:30:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E145D207DF Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=vivier.eu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:47506 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kBNbK-0006lf-1b for patchwork-qemu-devel@patchwork.kernel.org; Thu, 27 Aug 2020 15:30:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33582) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kBNSB-0004JO-96 for qemu-devel@nongnu.org; Thu, 27 Aug 2020 15:20:55 -0400 Received: from mout.kundenserver.de ([217.72.192.73]:51089) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kBNS9-0000IJ-3e for qemu-devel@nongnu.org; Thu, 27 Aug 2020 15:20:54 -0400 Received: from localhost.localdomain ([82.252.135.186]) by mrelayeu.kundenserver.de (mreue109 [212.227.15.183]) with ESMTPSA (Nemesis) id 1M8QNy-1kFnIo2N7I-004V66; Thu, 27 Aug 2020 21:20:42 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 15/18] linux-user: Add support for 'mq_timedsend_time64()' and 'mq_timedreceive_time64()' Date: Thu, 27 Aug 2020 21:20:15 +0200 Message-Id: <20200827192018.2442099-16-laurent@vivier.eu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200827192018.2442099-1-laurent@vivier.eu> References: <20200827192018.2442099-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:uv4eOu/tNfyzww5wB/LIXMENRklNHb+76HLgBz+ZSqV9+a96s/u YGyZ+hfxh+9fAG5vWx1LqWyo00EV1yfhnPJoImtyb+RmQ/jvqFqEzTuNESDj67C5aMOtnXH yIUWMRCiFFD1Tq/4oGX0mOoezR2cr2IdJiGXyqlG8A1IxiYnSS1N+1eBvDb/4PXoEciWOW6 rFAKe3i0Uz7kfuVBUpSDw== X-UI-Out-Filterresults: notjunk:1;V03:K0:tJTvFyXWkLs=:WFD7KveHIPkQ2mAsmq0di7 +B3d3v74cQlcr4HIF7+uEsCCfZ+uZC3K1Grd9s18ve9mSkIck1YD7eGYfUL5TCoqKtZZxg6bq tzdrWl3dgnfBl7F9CSHWhcF99P/udWBgSCBcOATGjMAPwlVsGWb9El5idYLq7DPP5d+hCpq7p WAaDDkeDpA7cjY8QGoh8iSin4KQM/e6EeAZFDA8oDya/X/YrCh/6kxKHsuR23Hncr4I8bCb4m omzUEwTMy/73uL0GZkcthahOGMrStV4bDwUZ9anka5+rorlyvFII1GywLM4l7/kGPiOLi8Uzs H6DoM9IsvY1n8Ukbn+IcQlJvT75nsZtpAQaWKORsxwmpEaKmu5syAI9y0KD35stVliZqF1WeS Tp1tZCuECXkXT/jlrIq/omBoeQp/IldxMKunWidsfHqB0A8Z7MtqwRPC6jfyzcsjLQlksaeWP TSKqSFXsGoySdXSt4spQKNZCZ7t0VlSQSl1NKEQEZ0YeLNWmgmC+CjdPRphDQB7iENaK0BKaC FnyYFC0oiItSzUxqjMRaJ0hxjpwVNLmGbVZfC7UFDFjDcGRHViQuWb0l2x1W22qxGeoBGQ4gK MFUJg80/mBDR8Xi3fmmkFcLdYt0RZj6tC1fsz3Gv0yKdnsyKbqVT9zgbV18b5G5dVtTvOPe9n JhEah4mvK0bdGC4aBIXBJSM8D5hgbH6IYgLchnDw443TgZqkEi06cZJFJKyjqWrTQpjMIlPpE NwA6mGu0nQNtEOURBw2TJac63LgAMYqT1Z5v4IGdaAV3rV0uXiaAlYj3FLxzinfUU0LgIrTtr zzWcPmQssYfZJK08baqKUW/GPRbB7c+cIYuUU8et+T1IFq4jZJa5NelxNHiSnbUaUVAeL46 Received-SPF: none client-ip=217.72.192.73; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/27 15:20:29 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] 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, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Riku Voipio , Laurent Vivier , Filip Bozuta Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Filip Bozuta This patch implements functionality for following time64 syscalls: *mq_timedsend_time64() This is a year 2038 safe vairant of syscall: int mq_timedsend(mqd_t mqdes, const char *msg_ptr, size_t msg_len, unsigned int msg_prio, const struct timespec *abs_timeout) --send a message to a message queue-- man page: https://www.man7.org/linux/man-pages/man2/mq_timedsend.2.html *mq_timedreceive_time64() This is a year 2038 safe variant of syscall: ssize_t mq_timedreceive(mqd_t mqdes, char *msg_ptr, size_t msg_len, unsigned int *msg_prio, const struct timespec *abs_timeout) --receive a message from a message queue-- man page: https://man7.org/linux/man-pages/man3/mq_receive.3.html Implementation notes: These syscalls were implemented in similar ways like 'mq_timedsend()' and 'mq_timedreceive' except that functions 'target_to_host_timespec64()' and 'host_to_target_timespec64()' were used to convert values of 'struct timespec' between host and target. Signed-off-by: Filip Bozuta Reviewed-by: Laurent Vivier Message-Id: <20200824193752.67950-3-Filip.Bozuta@syrmia.com> Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 56 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 54 insertions(+), 2 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 3b725bbe2513..b28c8edb421e 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -799,11 +799,13 @@ safe_syscall5(int, msgrcv, int, msgid, void *, msgp, size_t, sz, safe_syscall4(int, semtimedop, int, semid, struct sembuf *, tsops, unsigned, nsops, const struct timespec *, timeout) #endif -#ifdef TARGET_NR_mq_timedsend +#if defined(TARGET_NR_mq_timedsend) || \ + defined(TARGET_NR_mq_timedsend_time64) safe_syscall5(int, mq_timedsend, int, mqdes, const char *, msg_ptr, size_t, len, unsigned, prio, const struct timespec *, timeout) #endif -#ifdef TARGET_NR_mq_timedreceive +#if defined(TARGET_NR_mq_timedreceive) || \ + defined(TARGET_NR_mq_timedreceive_time64) safe_syscall5(int, mq_timedreceive, int, mqdes, char *, msg_ptr, size_t, len, unsigned *, prio, const struct timespec *, timeout) #endif @@ -1218,6 +1220,8 @@ static inline abi_long target_to_host_timespec(struct timespec *host_ts, #if defined(TARGET_NR_clock_settime64) || defined(TARGET_NR_futex_time64) || \ defined(TARGET_NR_timer_settime64) || \ + defined(TARGET_NR_mq_timedsend_time64) || \ + defined(TARGET_NR_mq_timedreceive_time64) || \ (defined(TARGET_NR_timerfd_settime64) && defined(CONFIG_TIMERFD)) static inline abi_long target_to_host_timespec64(struct timespec *host_ts, abi_ulong target_addr) @@ -12059,6 +12063,27 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } return ret; #endif +#ifdef TARGET_NR_mq_timedsend_time64 + case TARGET_NR_mq_timedsend_time64: + { + struct timespec ts; + + p = lock_user(VERIFY_READ, arg2, arg3, 1); + if (arg5 != 0) { + if (target_to_host_timespec64(&ts, arg5)) { + return -TARGET_EFAULT; + } + ret = get_errno(safe_mq_timedsend(arg1, p, arg3, arg4, &ts)); + if (!is_error(ret) && host_to_target_timespec64(arg5, &ts)) { + return -TARGET_EFAULT; + } + } else { + ret = get_errno(safe_mq_timedsend(arg1, p, arg3, arg4, NULL)); + } + unlock_user(p, arg2, arg3); + } + return ret; +#endif #ifdef TARGET_NR_mq_timedreceive case TARGET_NR_mq_timedreceive: @@ -12086,6 +12111,33 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } return ret; #endif +#ifdef TARGET_NR_mq_timedreceive_time64 + case TARGET_NR_mq_timedreceive_time64: + { + struct timespec ts; + unsigned int prio; + + p = lock_user(VERIFY_READ, arg2, arg3, 1); + if (arg5 != 0) { + if (target_to_host_timespec64(&ts, arg5)) { + return -TARGET_EFAULT; + } + ret = get_errno(safe_mq_timedreceive(arg1, p, arg3, + &prio, &ts)); + if (!is_error(ret) && host_to_target_timespec64(arg5, &ts)) { + return -TARGET_EFAULT; + } + } else { + ret = get_errno(safe_mq_timedreceive(arg1, p, arg3, + &prio, NULL)); + } + unlock_user(p, arg2, arg3); + if (arg4 != 0) { + put_user_u32(prio, arg4); + } + } + return ret; +#endif /* Not implemented for now... */ /* case TARGET_NR_mq_notify: */ From patchwork Thu Aug 27 19:20:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 11741459 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9672F14E5 for ; Thu, 27 Aug 2020 19:23:35 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6656D207CD for ; Thu, 27 Aug 2020 19:23:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6656D207CD Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=vivier.eu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:41536 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kBNUk-0001CF-MM for patchwork-qemu-devel@patchwork.kernel.org; Thu, 27 Aug 2020 15:23:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33514) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kBNS5-0004FS-Au for qemu-devel@nongnu.org; Thu, 27 Aug 2020 15:20:49 -0400 Received: from mout.kundenserver.de ([217.72.192.74]:53383) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kBNS2-0000HF-S2 for qemu-devel@nongnu.org; Thu, 27 Aug 2020 15:20:49 -0400 Received: from localhost.localdomain ([82.252.135.186]) by mrelayeu.kundenserver.de (mreue109 [212.227.15.183]) with ESMTPSA (Nemesis) id 1Mzz6m-1kZF6511mw-00x0am; Thu, 27 Aug 2020 21:20:43 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 16/18] linux-user: Add support for 'clock_nanosleep_time64()' and 'clock_adjtime64()' Date: Thu, 27 Aug 2020 21:20:16 +0200 Message-Id: <20200827192018.2442099-17-laurent@vivier.eu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200827192018.2442099-1-laurent@vivier.eu> References: <20200827192018.2442099-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:FQdlanOCI9F6Hn+RFCg6gj3aQHq3mfBetIA49srNDIReYWrNSLN pf3vC6cgnb5nkGZoXarfT20p7olWNmXf42rzYfkHdkuBy35v/lrp1n6Yu8bQeLC8/lQHPFY IVTlRPQsCmCqYWjDBLXzWeGJjPkyqOYiV95UVaPrZF4jvVFzmVi0AcIq8A28CNc7X8Osr+5 +UxG7kCnr7W6gZLtXB0DQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:FjjA67XCBs8=:q7uzGAreb52A3Q/uJ/gwg5 RSw6JCLG6rSVUYNd57l2I6dgVNpJltM9+OfOW+mUni25fgbSOridSmjwDekDr+A8zfYXXO8Th 5T665L8CnUeUm7KhA6FRpwSS+Elv8iMAKqdXgpAIpXHf2Xd8laDq97b8YbB8IfPcA+pS5PL1+ BYmikJcHl0v2JBD1TqPNUahnvG2vBil3qqTFB+dG3Vx+vTj3u5qv51fvGKDKJ1BpwdL6bVDqb ovXYDj80nFF2KuBDeOuPW3oo6MZaVMv8TWfiLsDj1HHkFgPVS54TVwlbtern/ucSgbknzD9nE NAvpIFBbJbfeIuK50aevDSak+AChcFN6A2agQA4IS97/L85ehrtGuYHVLAJL3BoAY6lqf+4bu hwecMKiRED4/AiJ2KHrfZkl0fS5ncS0pMZjOwpXhdWiQSvZ4Xcf2DQ3TlVvrebdKa3ADYkS4S OE1RMI3iw/ZcMp7HDXRwUu+E40eUqiPQ6A5gyCgTqOxbDKptHHaQnQkBLrSClwjYZcP3+rX17 7J1Ay1pe+PnOn9M34AdBy5wX4Ff/wyqId/+htt2Jspebqkozy0ug8B4T/eq/OLZdE86rgMLHK GGCCH491alUZK8Hy5LdxdhOevBlRDMSd8yOWlrz6nDrBRF2Whvb9UkN0B+5jQ6qVOnHvbm5EG XNATzeue+N3u051wlPcE5eJlMbadGynKX+AEtett47aluP1agNZzyuVUOuTmdRxs4ETlhQt/n MsISBIjxU2tlGaQdkSFiK5f3FBJqkBnhJwearBFdLQbcp/Q0KRjlBmV0OoGaqZQoXH3FLCOWu F6B3SATQYrDR+PjbVbGwJAnewJutjjZjXoLfgbDlfAPJ75XubwxPkQiESFMpUJuzmQEORHl Received-SPF: none client-ip=217.72.192.74; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/27 15:20:33 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] 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, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Riku Voipio , Laurent Vivier , Filip Bozuta Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Filip Bozuta This patch implements functionality for following time64 syscall: *clock_nanosleep_time64() This is a year 2038 safe vairant of syscall: int clock_nanosleep(clockid_t clockid, int flags, const struct timespec *request, struct timespec *remain) --high-resolution sleep with specifiable clock-- man page: https://man7.org/linux/man-pages/man2/clock_nanosleep.2.html *clock_adjtime64() This is a year 2038 safe variant of syscall: int clock_adjtime(clockid_t clk_id, struct timex *buf) --tune kernel clock-- man page: https://man7.org/linux/man-pages/man2/clock_adjtime.2.html Implementation notes: Syscall 'clock_nanosleep_time64()' was implemented similarly to syscall 'clock_nanosleep()' except that 'host_to_target_timespec64()' and 'target_to_host_timespec64()' were used instead of the regular 'host_to_target_timespec()' and 'target_to_host_timespec()'. For 'clock_adjtime64()' a 64-bit target kernel version of 'struct timex' was defined in 'syscall_defs.h': 'struct target__kernel_timex'. This type was used to convert the values of 64-bit timex type between host and target. For this purpose a 64-bit timex converting functions 'target_to_host_timex64()' and 'host_to_target_timex64()'. An existing function 'copy_to_user_timeval64()' was used to convert the field 'time' which if of type 'struct timeval' from host to target. Function 'copy_from_user_timveal64()' was added in this patch and used to convert the 'time' field from target to host. Signed-off-by: Filip Bozuta Reviewed-by: Laurent Vivier Message-Id: <20200824192116.65562-2-Filip.Bozuta@syrmia.com> [lv: add missing defined(TARGET_NR_clock_nanosleep_time64)] Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 140 +++++++++++++++++++++++++++++++++++++- linux-user/syscall_defs.h | 31 +++++++++ 2 files changed, 168 insertions(+), 3 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index b28c8edb421e..82414c08d655 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -774,7 +774,8 @@ safe_syscall4(int, accept4, int, fd, struct sockaddr *, addr, socklen_t *, len, safe_syscall2(int, nanosleep, const struct timespec *, req, struct timespec *, rem) #endif -#ifdef TARGET_NR_clock_nanosleep +#if defined(TARGET_NR_clock_nanosleep) || \ + defined(TARGET_NR_clock_nanosleep_time64) safe_syscall4(int, clock_nanosleep, const clockid_t, clock, int, flags, const struct timespec *, req, struct timespec *, rem) #endif @@ -1177,8 +1178,25 @@ static inline abi_long copy_to_user_timeval(abi_ulong target_tv_addr, return 0; } +static inline abi_long copy_from_user_timeval64(struct timeval *tv, + abi_ulong target_tv_addr) +{ + struct target__kernel_sock_timeval *target_tv; + + if (!lock_user_struct(VERIFY_READ, target_tv, target_tv_addr, 1)) { + return -TARGET_EFAULT; + } + + __get_user(tv->tv_sec, &target_tv->tv_sec); + __get_user(tv->tv_usec, &target_tv->tv_usec); + + unlock_user_struct(target_tv, target_tv_addr, 0); + + return 0; +} + static inline abi_long copy_to_user_timeval64(abi_ulong target_tv_addr, - const struct timeval *tv) + const struct timeval *tv) { struct target__kernel_sock_timeval *target_tv; @@ -1222,7 +1240,8 @@ static inline abi_long target_to_host_timespec(struct timespec *host_ts, defined(TARGET_NR_timer_settime64) || \ defined(TARGET_NR_mq_timedsend_time64) || \ defined(TARGET_NR_mq_timedreceive_time64) || \ - (defined(TARGET_NR_timerfd_settime64) && defined(CONFIG_TIMERFD)) + (defined(TARGET_NR_timerfd_settime64) && defined(CONFIG_TIMERFD)) || \ + defined(TARGET_NR_clock_nanosleep_time64) static inline abi_long target_to_host_timespec64(struct timespec *host_ts, abi_ulong target_addr) { @@ -6953,6 +6972,87 @@ static inline abi_long host_to_target_timex(abi_long target_addr, } #endif + +#if defined(TARGET_NR_clock_adjtime64) && defined(CONFIG_CLOCK_ADJTIME) +static inline abi_long target_to_host_timex64(struct timex *host_tx, + abi_long target_addr) +{ + struct target__kernel_timex *target_tx; + + if (copy_from_user_timeval64(&host_tx->time, target_addr + + offsetof(struct target__kernel_timex, + time))) { + return -TARGET_EFAULT; + } + + if (!lock_user_struct(VERIFY_READ, target_tx, target_addr, 1)) { + return -TARGET_EFAULT; + } + + __get_user(host_tx->modes, &target_tx->modes); + __get_user(host_tx->offset, &target_tx->offset); + __get_user(host_tx->freq, &target_tx->freq); + __get_user(host_tx->maxerror, &target_tx->maxerror); + __get_user(host_tx->esterror, &target_tx->esterror); + __get_user(host_tx->status, &target_tx->status); + __get_user(host_tx->constant, &target_tx->constant); + __get_user(host_tx->precision, &target_tx->precision); + __get_user(host_tx->tolerance, &target_tx->tolerance); + __get_user(host_tx->tick, &target_tx->tick); + __get_user(host_tx->ppsfreq, &target_tx->ppsfreq); + __get_user(host_tx->jitter, &target_tx->jitter); + __get_user(host_tx->shift, &target_tx->shift); + __get_user(host_tx->stabil, &target_tx->stabil); + __get_user(host_tx->jitcnt, &target_tx->jitcnt); + __get_user(host_tx->calcnt, &target_tx->calcnt); + __get_user(host_tx->errcnt, &target_tx->errcnt); + __get_user(host_tx->stbcnt, &target_tx->stbcnt); + __get_user(host_tx->tai, &target_tx->tai); + + unlock_user_struct(target_tx, target_addr, 0); + return 0; +} + +static inline abi_long host_to_target_timex64(abi_long target_addr, + struct timex *host_tx) +{ + struct target__kernel_timex *target_tx; + + if (copy_to_user_timeval64(target_addr + + offsetof(struct target__kernel_timex, time), + &host_tx->time)) { + return -TARGET_EFAULT; + } + + if (!lock_user_struct(VERIFY_WRITE, target_tx, target_addr, 0)) { + return -TARGET_EFAULT; + } + + __put_user(host_tx->modes, &target_tx->modes); + __put_user(host_tx->offset, &target_tx->offset); + __put_user(host_tx->freq, &target_tx->freq); + __put_user(host_tx->maxerror, &target_tx->maxerror); + __put_user(host_tx->esterror, &target_tx->esterror); + __put_user(host_tx->status, &target_tx->status); + __put_user(host_tx->constant, &target_tx->constant); + __put_user(host_tx->precision, &target_tx->precision); + __put_user(host_tx->tolerance, &target_tx->tolerance); + __put_user(host_tx->tick, &target_tx->tick); + __put_user(host_tx->ppsfreq, &target_tx->ppsfreq); + __put_user(host_tx->jitter, &target_tx->jitter); + __put_user(host_tx->shift, &target_tx->shift); + __put_user(host_tx->stabil, &target_tx->stabil); + __put_user(host_tx->jitcnt, &target_tx->jitcnt); + __put_user(host_tx->calcnt, &target_tx->calcnt); + __put_user(host_tx->errcnt, &target_tx->errcnt); + __put_user(host_tx->stbcnt, &target_tx->stbcnt); + __put_user(host_tx->tai, &target_tx->tai); + + unlock_user_struct(target_tx, target_addr, 1); + return 0; +} +#endif + static inline abi_long target_to_host_sigevent(struct sigevent *host_sevp, abi_ulong target_addr) { @@ -9940,6 +10040,21 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } } return ret; +#endif +#if defined(TARGET_NR_clock_adjtime64) && defined(CONFIG_CLOCK_ADJTIME) + case TARGET_NR_clock_adjtime64: + { + struct timex htx; + + if (target_to_host_timex64(&htx, arg2) != 0) { + return -TARGET_EFAULT; + } + ret = get_errno(clock_adjtime(arg1, &htx)); + if (!is_error(ret) && host_to_target_timex64(arg2, &htx)) { + return -TARGET_EFAULT; + } + } + return ret; #endif case TARGET_NR_getpgid: return get_errno(getpgid(arg1)); @@ -11911,6 +12026,25 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, return ret; } #endif +#ifdef TARGET_NR_clock_nanosleep_time64 + case TARGET_NR_clock_nanosleep_time64: + { + struct timespec ts; + + if (target_to_host_timespec64(&ts, arg3)) { + return -TARGET_EFAULT; + } + + ret = get_errno(safe_clock_nanosleep(arg1, arg2, + &ts, arg4 ? &ts : NULL)); + + if (ret == -TARGET_EINTR && arg4 && arg2 != TIMER_ABSTIME && + host_to_target_timespec64(arg4, &ts)) { + return -TARGET_EFAULT; + } + return ret; + } +#endif #if defined(TARGET_NR_set_tid_address) && defined(__NR_set_tid_address) case TARGET_NR_set_tid_address: diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index a6abc7e70be8..9d07991176b8 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -294,6 +294,37 @@ struct target_timex { abi_int:32; abi_int:32; abi_int:32; }; +struct target__kernel_timex { + abi_uint modes; /* Mode selector */ + abi_int: 32; /* pad */ + abi_llong offset; /* Time offset */ + abi_llong freq; /* Frequency offset */ + abi_llong maxerror; /* Maximum error (microseconds) */ + abi_llong esterror; /* Estimated error (microseconds) */ + abi_int status; /* Clock command/status */ + abi_int: 32; /* pad */ + abi_llong constant; /* PLL (phase-locked loop) time constant */ + abi_llong precision; /* Clock precision (microseconds, ro) */ + abi_llong tolerance; /* Clock freq. tolerance (ppm, ro) */ + struct target__kernel_sock_timeval time; /* Current time */ + abi_llong tick; /* Microseconds between clock ticks */ + abi_llong ppsfreq; /* PPS (pulse per second) frequency */ + abi_llong jitter; /* PPS jitter (ro); nanoseconds */ + abi_int shift; /* PPS interval duration (seconds) */ + abi_int: 32; /* pad */ + abi_llong stabil; /* PPS stability */ + abi_llong jitcnt; /* PPS jitter limit exceeded (ro) */ + abi_llong calcnt; /* PPS calibration intervals */ + abi_llong errcnt; /* PPS calibration errors */ + abi_llong stbcnt; /* PPS stability limit exceeded */ + abi_int tai; /* TAI offset */ + + /* Further padding bytes to allow for future expansion */ + abi_int:32; abi_int:32; abi_int:32; abi_int:32; + abi_int:32; abi_int:32; abi_int:32; abi_int:32; + abi_int:32; abi_int:32; abi_int:32; +}; + typedef abi_long target_clock_t; #define TARGET_HZ 100 From patchwork Thu Aug 27 19:20:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 11741441 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 763E714E5 for ; Thu, 27 Aug 2020 19:21:37 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5728E207CD for ; Thu, 27 Aug 2020 19:21:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5728E207CD Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=vivier.eu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:32954 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kBNSq-0005wV-Jg for patchwork-qemu-devel@patchwork.kernel.org; Thu, 27 Aug 2020 15:21:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33524) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kBNS5-0004GS-Tf for qemu-devel@nongnu.org; Thu, 27 Aug 2020 15:20:50 -0400 Received: from mout.kundenserver.de ([217.72.192.75]:58073) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kBNS3-0000Ha-Rl for qemu-devel@nongnu.org; Thu, 27 Aug 2020 15:20:49 -0400 Received: from localhost.localdomain ([82.252.135.186]) by mrelayeu.kundenserver.de (mreue109 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MSKq6-1k0URY1rZY-00Sdf4; Thu, 27 Aug 2020 21:20:44 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 17/18] linux-user: Add support for 'rt_sigtimedwait_time64()' and 'sched_rr_get_interval_time64()' Date: Thu, 27 Aug 2020 21:20:17 +0200 Message-Id: <20200827192018.2442099-18-laurent@vivier.eu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200827192018.2442099-1-laurent@vivier.eu> References: <20200827192018.2442099-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:iArs7WzgFORGfjjIRmUkgldGfCrWfC86/ThQOMf+7Bj7ZMDRUNH Sdq1SOQejV0kKhqu84TktQ/E87oBVzeIinADgn25Vl7sDjvynQbpbyEgNs86s0EnyJ0GtYl x0o/ff1GIKkWHnLMnj6/FIk6VEnheHbKHaXhHYAsKF/UN5h+jfcS3t228+kOEwE5CVX0bqh nVLeYIfoHqz5VxAjSJLXA== X-UI-Out-Filterresults: notjunk:1;V03:K0:VpHd2xuhM5w=:QTvbdPdu2GJWtZ766OjsBj QqCPv+gscSeTJ4f3a1mnlXpCcMPAzZsIL8AuPjptd7egZmPlIYEQ4oYyj7d6xJxzO1IA+9N7O UaQh1eJRsf3oSRgY3PRYpS2AodoMpKexjfUPsrCF1uto7RWCFASGGrPdXGBPRS5zmh1hZiKrE uIXtmrpBdijTOR3dcHtS8n2xqiPT/fk9HNxgS7Ayy4HdSVprlEj2Jz13jKrLoOwFqkR9CN7jD whFDIQujEnBYdtSk0WflXB1pzot/h+472/0Qd6+k8DIsVnfs95HCi1buJJ1qsi+I9kt9ja6ZM KZmgRmASejhULw0f92+lrTswGANZnix5xvDwKPjSSf/Zt6LZ+AXqp1ypP3hZv1o9WZW/0lgUT NA1nTiyS8XQFaTwCorfQjZwFUVP6XXoiSoyjTdPTIZj/DWxpqwuFWUC5IGz+R+B5rORpHO8KT s9fVfUPJgSA3kpvmrxee/hbp8w79Q1btq6rBHnafdrZWkoDZSGCWsMYrIKOorKRKeMPGHDxQt 19qybkViFqEmvkuEtT7s9CaZY0CowUfHrs5HE635oBi7wYMx23i4+1Ol3GsH057xyH0nWTRqA GH0Oy0buaVzvzNzcySLDJJe3K3LPq7Ey2KG+WvZM7GuySE952YPciwIGVG/88OHyyu/CS+WKY WqG2EutLS1X2yocILgQuIQvFVGxqaWLf0DRltSxjzJM7G4WNY5PPhVTKPxvTNbqUXdnkY6bFt iMOh7IrGWZHm7/7M7zvqKGhsG/KXITvw5GqaWNj5B3R5GvZpaiAB78e84EQ3XybVU/5zZyIfB gWCguT2vGjm0uv52VCoE+SKvGeDRSI3+bZQqVT3zy5RssAeu4UVByG+ZgYA/WQJr/6Ib/3t Received-SPF: none client-ip=217.72.192.75; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/27 15:20:36 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] 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, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Riku Voipio , Laurent Vivier , Filip Bozuta Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Filip Bozuta This patch implements functionality for following time64 syscalls: *rt_sigtimedwait_time64() This is a year 2038 safe variant of syscall: int rt_sigtimedwait(const sigset_t *set, siginfo_t *info, const struct timespec *timeout, size_t sigsetsize) --synchronously wait for queued signals-- man page: https://man7.org/linux/man-pages/man2/rt_sigtimedwait.2.html *sched_rr_get_interval_time64() This is a year 2038 safe variant of syscall: int sched_rr_get_interval(pid_t pid, struct timespec *tp) --get the SCHED_RR interval for the named process-- man page: https://man7.org/linux/man-pages/man2/sched_rr_get_interval.2.html Implementation notes: These syscalls were implemented in similar ways like 'rt_sigtimedwait()' and 'sched_rr_get_interval()' except that functions 'target_to_host_timespec64()' and 'host_to_target_timespec64()' were used to convert values of 'struct timespec' between host and target. Signed-off-by: Filip Bozuta Reviewed-by: Laurent Vivier Message-Id: <20200824192116.65562-3-Filip.Bozuta@syrmia.com> [lv: add missing defined(TARGET_NR_rt_sigtimedwait_time64)] Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 58 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 56 insertions(+), 2 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 82414c08d655..9d7376734ad4 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -764,7 +764,7 @@ safe_syscall6(ssize_t, recvfrom, int, fd, void *, buf, size_t, len, safe_syscall3(ssize_t, sendmsg, int, fd, const struct msghdr *, msg, int, flags) safe_syscall3(ssize_t, recvmsg, int, fd, struct msghdr *, msg, int, flags) safe_syscall2(int, flock, int, fd, int, operation) -#ifdef TARGET_NR_rt_sigtimedwait +#if defined(TARGET_NR_rt_sigtimedwait) || defined(TARGET_NR_rt_sigtimedwait_time64) safe_syscall4(int, rt_sigtimedwait, const sigset_t *, these, siginfo_t *, uinfo, const struct timespec *, uts, size_t, sigsetsize) #endif @@ -1241,7 +1241,8 @@ static inline abi_long target_to_host_timespec(struct timespec *host_ts, defined(TARGET_NR_mq_timedsend_time64) || \ defined(TARGET_NR_mq_timedreceive_time64) || \ (defined(TARGET_NR_timerfd_settime64) && defined(CONFIG_TIMERFD)) || \ - defined(TARGET_NR_clock_nanosleep_time64) + defined(TARGET_NR_clock_nanosleep_time64) || \ + defined(TARGET_NR_rt_sigtimedwait_time64) static inline abi_long target_to_host_timespec64(struct timespec *host_ts, abi_ulong target_addr) { @@ -9042,6 +9043,48 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } } return ret; +#endif +#ifdef TARGET_NR_rt_sigtimedwait_time64 + case TARGET_NR_rt_sigtimedwait_time64: + { + sigset_t set; + struct timespec uts, *puts; + siginfo_t uinfo; + + if (arg4 != sizeof(target_sigset_t)) { + return -TARGET_EINVAL; + } + + p = lock_user(VERIFY_READ, arg1, sizeof(target_sigset_t), 1); + if (!p) { + return -TARGET_EFAULT; + } + target_to_host_sigset(&set, p); + unlock_user(p, arg1, 0); + if (arg3) { + puts = &uts; + if (target_to_host_timespec64(puts, arg3)) { + return -TARGET_EFAULT; + } + } else { + puts = NULL; + } + ret = get_errno(safe_rt_sigtimedwait(&set, &uinfo, puts, + SIGSET_T_SIZE)); + if (!is_error(ret)) { + if (arg2) { + p = lock_user(VERIFY_WRITE, arg2, + sizeof(target_siginfo_t), 0); + if (!p) { + return -TARGET_EFAULT; + } + host_to_target_siginfo(p, &uinfo); + unlock_user(p, arg2, sizeof(target_siginfo_t)); + } + ret = host_to_target_signal(ret); + } + } + return ret; #endif case TARGET_NR_rt_sigqueueinfo: { @@ -10566,6 +10609,17 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } return ret; #endif +#ifdef TARGET_NR_sched_rr_get_interval_time64 + case TARGET_NR_sched_rr_get_interval_time64: + { + struct timespec ts; + ret = get_errno(sched_rr_get_interval(arg1, &ts)); + if (!is_error(ret)) { + ret = host_to_target_timespec64(arg2, &ts); + } + } + return ret; +#endif #if defined(TARGET_NR_nanosleep) case TARGET_NR_nanosleep: { From patchwork Thu Aug 27 19:20:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 11741593 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DFBD4109B for ; Thu, 27 Aug 2020 19:30:20 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BA67820714 for ; Thu, 27 Aug 2020 19:30:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BA67820714 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=vivier.eu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:47250 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kBNbH-0006fF-UX for patchwork-qemu-devel@patchwork.kernel.org; Thu, 27 Aug 2020 15:30:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33596) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kBNSE-0004NG-6G for qemu-devel@nongnu.org; Thu, 27 Aug 2020 15:20:58 -0400 Received: from mout.kundenserver.de ([217.72.192.73]:34095) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kBNSB-0000IV-7n for qemu-devel@nongnu.org; Thu, 27 Aug 2020 15:20:57 -0400 Received: from localhost.localdomain ([82.252.135.186]) by mrelayeu.kundenserver.de (mreue109 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MBltK-1kJ7Dt0r1Q-00CCjq; Thu, 27 Aug 2020 21:20:45 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 18/18] linux-user: Add support for utimensat_time64() and semtimedop_time64() Date: Thu, 27 Aug 2020 21:20:18 +0200 Message-Id: <20200827192018.2442099-19-laurent@vivier.eu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200827192018.2442099-1-laurent@vivier.eu> References: <20200827192018.2442099-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:U937he2HJjSldhdXjydrkc9vCgsqhPOmmrtMXmEkuldqRGJSA0L Rz6yHOs18DZV68YXISavhv1CivdsoT/T25I+06IAaOUCdDmFFJDUWgJoDKVxSfdgQmp++3z E0E4LKthFhKwnrlx9h+E27akL+okrbgv0ypRAuVNtzu4IT4tczCbaeJE1fmy+XxjlD+f4G1 8meCvDfGZTQXsj6rgOeSw== X-UI-Out-Filterresults: notjunk:1;V03:K0:9NhQBiUnkdY=:+H7wd2/pc7iOq7rqESWWHp QClGtMbUv3rYx1JofOshLSqFvcv57EKCTEIGGkRaoT+oyL0b8wiU7CeYk+3RLZeFpQNRkRLjO ikscgLWwfegTcZcSOSIoi0u0H0716/kOgmqkGGfAyjS6hZp3RKVBihdhOU4HktMnNOomeq9qf uGg7Yp5YQmXbj2bxppn+E9UAyRhQiAp6w8QtbmimPrc+zgu6iS8DkABytMdw0OqgdpHuAzCnc FRVwbmwJ+3RDkSnGYYqvo3/5e78NQv5JzWZ8c35DNoypkimukCRXPzqeDHHN8mTzsVhSt1o6e E6pUCBEOx2u8bqeq0dZ6wZGduf+6UayAUKEt+sWX2+kw0KHn4LimL6ZL1H6wKJyP4tPN/Cz+u 41bbMViXUPUy+ocQN0jhiBi3n9WgMK/hQr0uKXMQUXsX8cQbck8HNPMTJmk1hnWeeX3hrHMJv Ul+um/sh10ADzgSlOrw9fztHlLklmbuMZtKbf3zhez+25g6l8P0itlIp7FrdIPD7UpaA3omlr +JA3eaUeSX6cuBGqcKsmAk2vfCxeilScgVpxeUV+0STac5Pr6hCA7sHxTqIDkLdDlb3l77T61 EjcE7hIEaLq6vMfBz6Wvjxuw9TSu9If/lFwCbs2wOGZax1/B4vLggv5sD5Bu33nbcp2rIjUO4 dw/30IP87c2uRLZrdc+xSrEdvTnxclWCvDqs53BsIVfE639ifiK7O5F3Owoh7dMgaQYf1bQFz 9sWFdLOf27jjQjQBCWfRmT9dAbfr9ZG1owBySkwSKcavg2ha+RIlbdmBnjmY4L0oWro2n9BlH OYLI0/vpzHO/iQxE1Ckrz1XwSdDkxDiKu87cOS8S2BFWGgaAIazeJK+y0MvMNkI0dKkbaLi Received-SPF: none client-ip=217.72.192.73; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/27 15:20:29 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] 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, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Riku Voipio , Laurent Vivier , Filip Bozuta Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Filip Bozuta This patch introduces functionality for following time64 syscalls: *utimensat_time64() int utimensat(int dirfd, const char *pathname, const struct timespec times[2], int flags); -- change file timestamps with nanosecond precision -- man page: https://man7.org/linux/man-pages/man2/utimensat.2.html *semtimedop_time64() int semtimedop(int semid, struct sembuf *sops, size_t nsops, const struct timespec *timeout); -- System V semaphore operations -- man page: https://www.man7.org/linux/man-pages/man2/semtimedop.2.html Implementation notes: Syscall 'utimensat_time64()' is implemented in similar way as its regular variants only difference being that time64 converting function is used to convert values of 'struct timespec' between host and target ('target_to_host_timespec64()'). For syscall 'semtimedop_time64()' and additional argument is added in function 'do_semtimedop()' through which the aproppriate 'struct timespec' converting function is called (false for regular target_to_host_timespec() and true for target_to_host_timespec64()). For 'do_ipc()' a check was added as that additional argument: 'TARGET_ABI_BITS == 64'. Signed-off-by: Filip Bozuta Reviewed-by: Laurent Vivier Message-Id: <20200824223050.92032-3-Filip.Bozuta@syrmia.com> Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 64 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 53 insertions(+), 11 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 9d7376734ad4..e93cecb0cb8e 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -391,7 +391,7 @@ static bitmask_transtbl fcntl_flags_tbl[] = { _syscall2(int, sys_getcwd1, char *, buf, size_t, size) -#ifdef TARGET_NR_utimensat +#if defined(TARGET_NR_utimensat) || defined(TARGET_NR_utimensat_time64) #if defined(__NR_utimensat) #define __NR_sys_utimensat __NR_utimensat _syscall4(int,sys_utimensat,int,dirfd,const char *,pathname, @@ -1242,7 +1242,10 @@ static inline abi_long target_to_host_timespec(struct timespec *host_ts, defined(TARGET_NR_mq_timedreceive_time64) || \ (defined(TARGET_NR_timerfd_settime64) && defined(CONFIG_TIMERFD)) || \ defined(TARGET_NR_clock_nanosleep_time64) || \ - defined(TARGET_NR_rt_sigtimedwait_time64) + defined(TARGET_NR_rt_sigtimedwait_time64) || \ + defined(TARGET_NR_utimensat) || \ + defined(TARGET_NR_utimensat_time64) || \ + defined(TARGET_NR_semtimedop_time64) static inline abi_long target_to_host_timespec64(struct timespec *host_ts, abi_ulong target_addr) { @@ -3877,7 +3880,7 @@ static inline abi_long target_to_host_sembuf(struct sembuf *host_sembuf, } #if defined(TARGET_NR_ipc) || defined(TARGET_NR_semop) || \ - defined(TARGET_NR_semtimedop) + defined(TARGET_NR_semtimedop) || defined(TARGET_NR_semtimedop_time64) /* * This macro is required to handle the s390 variants, which passes the @@ -3894,7 +3897,7 @@ static inline abi_long target_to_host_sembuf(struct sembuf *host_sembuf, static inline abi_long do_semtimedop(int semid, abi_long ptr, unsigned nsops, - abi_long timeout) + abi_long timeout, bool time64) { struct sembuf *sops; struct timespec ts, *pts = NULL; @@ -3902,8 +3905,14 @@ static inline abi_long do_semtimedop(int semid, if (timeout) { pts = &ts; - if (target_to_host_timespec(pts, timeout)) { - return -TARGET_EFAULT; + if (time64) { + if (target_to_host_timespec64(pts, timeout)) { + return -TARGET_EFAULT; + } + } else { + if (target_to_host_timespec(pts, timeout)) { + return -TARGET_EFAULT; + } } } @@ -4426,7 +4435,7 @@ static abi_long do_ipc(CPUArchState *cpu_env, switch (call) { case IPCOP_semop: - ret = do_semtimedop(first, ptr, second, 0); + ret = do_semtimedop(first, ptr, second, 0, false); break; case IPCOP_semtimedop: /* @@ -4436,9 +4445,9 @@ static abi_long do_ipc(CPUArchState *cpu_env, * to a struct timespec where the generic variant uses fifth parameter. */ #if defined(TARGET_S390X) - ret = do_semtimedop(first, ptr, second, third); + ret = do_semtimedop(first, ptr, second, third, TARGET_ABI_BITS == 64); #else - ret = do_semtimedop(first, ptr, second, fifth); + ret = do_semtimedop(first, ptr, second, fifth, TARGET_ABI_BITS == 64); #endif break; @@ -9947,11 +9956,15 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #endif #ifdef TARGET_NR_semop case TARGET_NR_semop: - return do_semtimedop(arg1, arg2, arg3, 0); + return do_semtimedop(arg1, arg2, arg3, 0, false); #endif #ifdef TARGET_NR_semtimedop case TARGET_NR_semtimedop: - return do_semtimedop(arg1, arg2, arg3, arg4); + return do_semtimedop(arg1, arg2, arg3, arg4, false); +#endif +#ifdef TARGET_NR_semtimedop_time64 + case TARGET_NR_semtimedop_time64: + return do_semtimedop(arg1, arg2, arg3, arg4, true); #endif #ifdef TARGET_NR_semctl case TARGET_NR_semctl: @@ -12158,6 +12171,35 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } return ret; #endif +#ifdef TARGET_NR_utimensat_time64 + case TARGET_NR_utimensat_time64: + { + struct timespec *tsp, ts[2]; + if (!arg3) { + tsp = NULL; + } else { + if (target_to_host_timespec64(ts, arg3)) { + return -TARGET_EFAULT; + } + if (target_to_host_timespec64(ts + 1, arg3 + + sizeof(struct target__kernel_timespec))) { + return -TARGET_EFAULT; + } + tsp = ts; + } + if (!arg2) + ret = get_errno(sys_utimensat(arg1, NULL, tsp, arg4)); + else { + p = lock_user_string(arg2); + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(sys_utimensat(arg1, path(p), tsp, arg4)); + unlock_user(p, arg2, 0); + } + } + return ret; +#endif #ifdef TARGET_NR_futex case TARGET_NR_futex: return do_futex(arg1, arg2, arg3, arg4, arg5, arg6);