From patchwork Thu Jul 11 17:31:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1130916 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=vivier.eu 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 ozlabs.org (Postfix) with ESMTPS id 45l39h4LLFz9s4Y for ; Fri, 12 Jul 2019 03:35:36 +1000 (AEST) Received: from localhost ([::1]:44042 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hlcyj-0000uD-FE for incoming@patchwork.ozlabs.org; Thu, 11 Jul 2019 13:35:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35165) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hlcvt-0007cL-FW for qemu-devel@nongnu.org; Thu, 11 Jul 2019 13:32:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hlcvr-0004p6-6H for qemu-devel@nongnu.org; Thu, 11 Jul 2019 13:32:37 -0400 Received: from mout.kundenserver.de ([212.227.17.13]:37093) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hlcvh-0004hb-Rz for qemu-devel@nongnu.org; Thu, 11 Jul 2019 13:32:29 -0400 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue109 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MgNlB-1iPdEG3sit-00hyp8; Thu, 11 Jul 2019 19:31:36 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Date: Thu, 11 Jul 2019 19:31:31 +0200 Message-Id: <20190711173131.6347-1-laurent@vivier.eu> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 X-Provags-ID: V03:K1:irDBY3lKpqMm4kQULaUpwNULwAoFOXl1ZvCc01qqlQGCwriSy2p JV7U6lZ2fCoowevgQs4o6tJHPjhypOZl0IUDqtwWWbVL3dcqN6VKAE2kPqOc7VcWB5AePdY +jzog6I+sNUsgtsiQrts9phXpiwytzA16oxsew8IPEvk1HQjtSoJW1TcV9NQCRUpx3qCpVA jXkVy8CGs43oDg+tUxbdg== X-UI-Out-Filterresults: notjunk:1; V03:K0:wNYGzXuqHm0=:06UrCYMqUACcEBOxpnNoIF oo9dbBogh9omV8WqzTje02x2FJ4uqIrfcJIKQhBuMHgy5iTuSVR//HqP8zPMobUhr8kEpEgHC D2CM0krOi8jVVG8IcKwO5q3Wc0HtCow/YMkzDKJ8+jasRcQj5mKBwglJEpFNJjAff2lIP6XFN +5pdWDOlcHUXLFsZ2vyD1n8uWoDYiOU1O3GI1WGvVgz249EVOxDGNhKK1f24mmfrsh7UHui2V ZmdtkRQiJ7nLvlvHfek6F2YAHG/tGo06PrSFS+LRdjHQE8HVbk3s/jFvePF/GKL0iFHDNpQJv uzq5ACODN0k3iUR22Sggx9UoiC94FxZ3aEtr6nwlY9ekupEtSGMDg4KaJaLCk0YQEGNWpkfx+ o9rPxb5CBJIY07DjUvCatiJ5Cxen3ISQHZx1YQR6JzF+5gkxXJc0wwwvBdo7/1IT9wEObYH7w Lwwx3mwdgjSnjwzk0sJFMzpUS9+Y0uo8xa+nTtPoMb69uhieMfXbJpzB8CiTBLlZoDp5lXcvc njgilUpyyuB9sqD3vjXMI2x/I8I62DXwHTxKlO3pqk5lt3ybeuTtcm52mKHde9DwT3rZdUyHx rvYOFA2Lzk7FR86qZzlmDr/R7THl4jYaNT2t7VYQI2wQN949AblDI9PS3g8FzSOmV9In4xUGo o0/17S6QosynpSgIb8rKQkU7DQFEjnrJSCWmOARR9lzOdFn6z0XUQNYwXFz+Igb+T4N/YrzQV XRW//kYUurDWGTXHM2CH4uy42DfJoSo7EkXit0xi1+zjPnlDdKOAOlJ25gw= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 212.227.17.13 Subject: [Qemu-devel] [PATCH v4] linux-user: fix to handle variably sized SIOCGSTAMP with new kernels 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?Daniel_P_=2E_Berrang=C3=A9?= , Arnd Bergmann , Gerhard Stenzel , Riku Voipio , Laurent Vivier , Christian Ehrhardt , Christian Borntraeger Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Daniel P. Berrangé The SIOCGSTAMP symbol was previously defined in the asm-generic/sockios.h header file. QEMU sees that header indirectly via sys/socket.h In linux kernel commit 0768e17073dc527ccd18ed5f96ce85f9985e9115 the asm-generic/sockios.h header no longer defines SIOCGSTAMP. Instead it provides only SIOCGSTAMP_OLD, which only uses a 32-bit time_t on 32-bit architectures. The linux/sockios.h header then defines SIOCGSTAMP using either SIOCGSTAMP_OLD or SIOCGSTAMP_NEW as appropriate. If SIOCGSTAMP_NEW is used, then the tv_sec field is 64-bit even on 32-bit architectures To cope with this we must now define two separate syscalls, with corresponding old and new sizes, as well as including the new linux/sockios.h header. Signed-off-by: Daniel P. Berrangé Signed-off-by: Laurent Vivier --- Notes: v4: [lv] timeval64 and timespec64 are { long long , long } v3: [lv] redefine TARGET_SIOCGSTAMP_NEW, TARGET_SIOCGSTAMPNS_NEW, timeval64 and timespec64 to use 0x89 type and abi_llong[2] v2: [dpb] implement _NEW and _OLD variants linux-user/ioctls.h | 15 +++++++++++++++ linux-user/syscall.c | 1 + linux-user/syscall_defs.h | 4 ++++ linux-user/syscall_types.h | 4 ++++ 4 files changed, 24 insertions(+) diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h index 5e84dc7c3a77..5a6d6def7e3f 100644 --- a/linux-user/ioctls.h +++ b/linux-user/ioctls.h @@ -222,8 +222,23 @@ IOCTL(SIOCGIWNAME, IOC_W | IOC_R, MK_PTR(MK_STRUCT(STRUCT_char_ifreq))) IOCTL(SIOCSPGRP, IOC_W, MK_PTR(TYPE_INT)) /* pid_t */ IOCTL(SIOCGPGRP, IOC_R, MK_PTR(TYPE_INT)) /* pid_t */ + +#ifdef SIOCGSTAMP_OLD + IOCTL(SIOCGSTAMP_OLD, IOC_R, MK_PTR(MK_STRUCT(STRUCT_timeval))) +#else IOCTL(SIOCGSTAMP, IOC_R, MK_PTR(MK_STRUCT(STRUCT_timeval))) +#endif +#ifdef SIOCGSTAMPNS_OLD + IOCTL(SIOCGSTAMPNS_OLD, IOC_R, MK_PTR(MK_STRUCT(STRUCT_timespec))) +#else IOCTL(SIOCGSTAMPNS, IOC_R, MK_PTR(MK_STRUCT(STRUCT_timespec))) +#endif +#ifdef SIOCGSTAMP_NEW + IOCTL(SIOCGSTAMP_NEW, IOC_R, MK_PTR(MK_STRUCT(STRUCT_timeval64))) +#endif +#ifdef SIOCGSTAMPNS_NEW + IOCTL(SIOCGSTAMPNS_NEW, IOC_R, MK_PTR(MK_STRUCT(STRUCT_timespec64))) +#endif IOCTL(RNDGETENTCNT, IOC_R, MK_PTR(TYPE_INT)) IOCTL(RNDADDTOENTCNT, IOC_W, MK_PTR(TYPE_INT)) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 39a37496fed5..aa18ac4b2389 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index fffa89f2564b..e0326923a018 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -751,6 +751,10 @@ struct target_pollfd { #define TARGET_SIOCGSTAMP 0x8906 /* Get stamp (timeval) */ #define TARGET_SIOCGSTAMPNS 0x8907 /* Get stamp (timespec) */ +#define TARGET_SIOCGSTAMP_OLD 0x8906 /* Get stamp (timeval) */ +#define TARGET_SIOCGSTAMPNS_OLD 0x8907 /* Get stamp (timespec) */ +#define TARGET_SIOCGSTAMP_NEW TARGET_IOR(0x89, 0x06, abi_llong[2]) /* Get stamp (timeval64) */ +#define TARGET_SIOCGSTAMPNS_NEW TARGET_IOR(0x89, 0x07, abi_llong[2]) /* Get stamp (timespec64) */ /* Networking ioctls */ #define TARGET_SIOCADDRT 0x890B /* add routing table entry */ diff --git a/linux-user/syscall_types.h b/linux-user/syscall_types.h index b98a23b0f1b0..de4c5a5b6f5b 100644 --- a/linux-user/syscall_types.h +++ b/linux-user/syscall_types.h @@ -20,6 +20,10 @@ STRUCT(timeval, STRUCT(timespec, MK_ARRAY(TYPE_LONG, 2)) +STRUCT(timeval64, TYPE_LONGLONG, TYPE_LONG) + +STRUCT(timespec64, TYPE_LONGLONG, TYPE_LONG) + STRUCT(rtentry, TYPE_ULONG, MK_STRUCT(STRUCT_sockaddr), MK_STRUCT(STRUCT_sockaddr), MK_STRUCT(STRUCT_sockaddr), TYPE_SHORT, TYPE_SHORT, TYPE_ULONG, TYPE_PTRVOID, TYPE_SHORT, TYPE_PTRVOID,