Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3036989yba; Mon, 22 Apr 2019 18:22:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqwnBWsisj4213uvhrYm4TS5R4NJsMN9PWddHemefdHHdvntSptFtxDsojWqafhmXw1qtitq X-Received: by 2002:a63:2b03:: with SMTP id r3mr21493040pgr.105.1555982553164; Mon, 22 Apr 2019 18:22:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555982553; cv=none; d=google.com; s=arc-20160816; b=ovpfHdGGAB5ak5iEx5aRBVf1dEPggvXpB4mBQ0zApN6FmQLVoR86Mpc8Gk0toYCMY1 SGOCyy0FZrk9WOTy7mcuSPsIn8UUhjhF3ZVbjxEjMMFpndOBw9krQgMAwaAYsRiey6XM oog6Jd+L+YoxECbRl/lDhOyutGwGFVuVdQNUIjK7b3XU+375rX5kEodR7R6Yk5GfXchM e+33GY1b2LGiR9tz5JxL+8fEZG8uj4xEIfZYEqp+6cR8vQOe+pmiMRH9y6k78wOY+PpV /ZoEOrUHOX5jRA1y1a/+a7XWJ7VvNnbeJV33W//IM4HvI0CV+/QcQhD28t7VtR9HMddw 8xZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=sHwXrmIO0FHm4ymwnCE5str7PFCqeD4XHSuynCfW/KY=; b=oEyWCBSqB+rnb2WHBAV2FYFY5sGd8mGPfK8hENk8W1QvSc8Lg6ITu+3vWTsCk+tXtq oy6cBmpKAYtQwsjjJC4e79HEKCMknk2VoW2vmBl221Ns1WPMzxwL1cq4xysfH7gCcAR/ bKwNUEao5ZSpr0xzh2Njxb4+zrEzoAbHvz6jCi+c+Fa/4fxUqFdHb5Aypx5LTeSyp4rK 2Ur6Ia0m8KxteAeY7x3xIvFJQOZGj2re7IeNj/TRYGX3E3Em0bdC8vk9I5+mfW3ruDCV tl0vu2twyBeOvX5kZ5UDgP8TePqOm+JaGid5Qm23H1PVLO6u+AHNOT7NKckevdTcJcJn EzqA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l4si13224542pgp.280.2019.04.22.18.22.18; Mon, 22 Apr 2019 18:22:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728891AbfDVVqH convert rfc822-to-8bit (ORCPT + 99 others); Mon, 22 Apr 2019 17:46:07 -0400 Received: from mail-qt1-f193.google.com ([209.85.160.193]:39755 "EHLO mail-qt1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726638AbfDVVqG (ORCPT ); Mon, 22 Apr 2019 17:46:06 -0400 Received: by mail-qt1-f193.google.com with SMTP id h16so3533405qtk.6 for ; Mon, 22 Apr 2019 14:46:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=tt+a5M/B7TQLGucHULuqskJ+Z0GUmxyy6884GCd0AyU=; b=T3nZa8OL/bbarOFwaZHwsM7/9VSCKacmDuPWWE94MU+H5EXAIgFb8S/ud+DudTo6Lk gM+t0sez8lHdYnu3zCYlzemQWgvfYn41DJ/kWekmVAbTfdGiM+wuxmmOcc7MosbaaAUI mIVE7VCuu8xxTdFnYaZdgDGXVsrheQaLNf5wnZreYb6ofGfFPpVZTXTE84Vx96IhYvXr n/Jv7YzpIfDyfzG+2AjP6y2wkdqKurAxZlabnuWHyZ3UzIMg3ySRzoVRyPZjq+KCjC3K FA/cswxcqbIY1nmv3+ZP/XR8M9cJN5GVLRYg/QyrjUbKihWTUXuuw/hFVbPyxmahfamp TxgQ== X-Gm-Message-State: APjAAAW1i9cCkwqqE6T7o1iLaLmS83604N940UrsQFXHyNeQEa0qswqS 9b6JcRb8vQQqN5bvVmAeE2gHJ8czPaU6qxdL84Y= X-Received: by 2002:ac8:3f38:: with SMTP id c53mr6541591qtk.152.1555969565823; Mon, 22 Apr 2019 14:46:05 -0700 (PDT) MIME-Version: 1.0 References: <20190414220841.20243-1-lukma@denx.de> <20190414220841.20243-4-lukma@denx.de> <20190420002009.l65upn2t3qqoj5uy@sghpc.golosunov.pp.ru> <20190420132112.131f449b@jawa> <20190422090710.bmxdhhankurhafxq@sghpc.golosunov.pp.ru> In-Reply-To: <20190422090710.bmxdhhankurhafxq@sghpc.golosunov.pp.ru> From: Arnd Bergmann Date: Mon, 22 Apr 2019 23:45:49 +0200 Message-ID: Subject: Re: [PATCH 3/6] y2038: linux: Provide __clock_settime64 implementation To: Stepan Golosunov Cc: Lukasz Majewski , Deepa Dinamani , GNU C Library , Paul Eggert , Joseph Myers , John Stultz , Thomas Gleixner , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Apr 22, 2019 at 11:07 AM Stepan Golosunov wrote: > 20.04.2019 в 13:21:12 +0200 Lukasz Majewski написал: > Is it? The kernel (5.1-rc6) code looks to me like > > /* Zero out the padding for 32 bit systems or in compat mode */ > if (false && false) > kts.tv_nsec &= 0xFFFFFFFFUL; > > in 32-bit kernels. And like > > if (false && true) > kts.tv_nsec &= 0xFFFFFFFFUL; > > for COMPAT syscalls in 64-bit kernels. > > It should probably be changed into > > if (!IS_ENABLED(CONFIG_64BIT) || in_compat_syscall()) > kts.tv_nsec &= 0xFFFFFFFFUL; > > (Or into something like > > if (!IS_ENABLED(CONFIG_64BIT) || in_compat_syscall() && !COMPAT_USE_64BIT_TIME) > kts.tv_nsec &= 0xFFFFFFFFUL; > > if x32 should retain 64-bit tv_nsec.) I think the problem is that at some point CONFIG_64BIT_TIME was meant to be enabled on both 32-bit and 64-bit kernels, but the definition got changed along the way. We probably just want if (in_compat_syscall() ) kts.tv_nsec &= 0xFFFFFFFFUL; here, which would then truncate the nanoseconds for all compat mode including x32. For native mode, we don't need to truncate it, since timespec64 has a 32-bit 'tv_nsec' field in the kernel. > > However, I would prefer not to pass random data > > to the kernel, and hence I do clear it up explicitly in glibc. > > If the kernel does not ignore padding on its own, then zeroing it out > is required everywhere timespec is passed to kernel, including via > code not known to glibc. (Does anyone promise that there won't be any > ioctls that accept timespec, for example?) That seems to be > error-prone (and might requre copying larger structes). > > On the other hand, if kernel 5.1+ ignores padding as intended there is > no need to create additional copy of structs in glibc code that calls > into clock_settime64 (or into timer_settime64 that accepts larger > struct, for example). The intention is that the kernel ignores the padding. If you find another place in the kernel that forget that, we should fix it. > > > And, hmm, is CONFIG_64BIT_TIME enabled anywhere? > > I guess that the remaining CONFIG_64BIT_TIME in kernel should be > replaced with CONFIG_COMPAT_32BIT_TIME or removed. We should remove CONFIG_64BIT_TIME. CONFIG_COMPAT_32BIT_TIME is still needed to identify architectures that don't have it, in particular riscv32. Arnd