Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp14120496ybl; Mon, 30 Dec 2019 04:29:35 -0800 (PST) X-Google-Smtp-Source: APXvYqxmfNLP3EIPjdgOx/OvMWBo2/WfPaiTgVzbizZgJggVqQSyUDD5pgcL1EtwMQWBBevYd/Ee X-Received: by 2002:a9d:7999:: with SMTP id h25mr74102584otm.347.1577708974492; Mon, 30 Dec 2019 04:29:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577708974; cv=none; d=google.com; s=arc-20160816; b=W8GT/9a1PzuABh5tN614rToZj7+283syAd2hoUO3sKN86aMkWsBjYEnGLgNiaBvEBP Qn0DE7ODY2pYMomLyvgXKjVcViPEj9hUlkzhukhAUNUPxObAHWVMHodfNAjXOjdlQ/We qmkW6MDeAK6PIxQqc2gVpgieQLihlnT05BCPFmxjazlnBiPoRba/0NyPYc8tyM8mzXUO Ox1gphoKCFLTk5NF+x3cHDaMlrX5EJTkn4wnC9mTiAzO70EUG8zGqv16EgPTZAgM5TC0 zPY7uBSwerfqY9HTxiO8s/LT2DoxDhpei3PNGxdP2hYhKcC67NstNHdIAudSwwW0/J6o ZiXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=XDqesT3HM9zj72Blw/kIYrG818HLoYNgkK7NstsjRj4=; b=NuNG6c1kmVKIOqNOjNeTxvQYytOLqvsFYGnRO64mdvCa1LeGxdWgIyv25dCywysXZY mcBx8c9r0sLtjELm3tf9/IZpQbXRQQf59Q7+yhfo4jDbG9kz7+YeIkxc/zH+RsSzak4E g2p/474b7Dlxojn8nBv3qhrG5IEVukEkTWjyX2E4DFB6I1DNlfrq+mUCT/IZsxozsr3p W76MRXkegYLXAozruEx1KDaJsQ06oikUQx48lSDXWul8m3veqyOcCaUE8arPw5fmMrJl lbef5YGqu/WAqeRqOx/EMYz1/wG55XZ5VNU7KBBCH5stWxNjDthzSu0gNLIU0XonnJ29 dS0g== 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 z12si6949232oto.125.2019.12.30.04.29.23; Mon, 30 Dec 2019 04:29:34 -0800 (PST) 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 S1727456AbfL3M2A (ORCPT + 99 others); Mon, 30 Dec 2019 07:28:00 -0500 Received: from mout.kundenserver.de ([212.227.17.13]:45289 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727376AbfL3M2A (ORCPT ); Mon, 30 Dec 2019 07:28:00 -0500 Received: from mail-qt1-f176.google.com ([209.85.160.176]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.145]) with ESMTPSA (Nemesis) id 1MORIm-1j7I5S1Nja-00Pvkq; Mon, 30 Dec 2019 13:27:56 +0100 Received: by mail-qt1-f176.google.com with SMTP id n15so29534936qtp.5; Mon, 30 Dec 2019 04:27:56 -0800 (PST) X-Gm-Message-State: APjAAAWyYzNHoAQvFyrXhRs0Zj7zHgBWluSFciuTDbD5Df4fZWga3ZGE Loa2BDaIBs61tArHZxjRi5usEp/jmC/ljnOYZ2U= X-Received: by 2002:ac8:47d3:: with SMTP id d19mr47462525qtr.142.1577708875107; Mon, 30 Dec 2019 04:27:55 -0800 (PST) MIME-Version: 1.0 References: <47701b5fb73cf536db074031db8e6e3fa3695168.1577111365.git.christophe.leroy@c-s.fr> In-Reply-To: <47701b5fb73cf536db074031db8e6e3fa3695168.1577111365.git.christophe.leroy@c-s.fr> From: Arnd Bergmann Date: Mon, 30 Dec 2019 13:27:39 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC PATCH v2 01/10] lib: vdso: ensure all arches have 32bit fallback To: Christophe Leroy Cc: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Thomas Gleixner , Vincenzo Frascino , Andy Lutomirski , "linux-kernel@vger.kernel.org" , linuxppc-dev , Linux ARM , "open list:BROADCOM NVRAM DRIVER" , "the arch/x86 maintainers" Content-Type: text/plain; charset="UTF-8" X-Provags-ID: V03:K1:jOHMDkQLbBEOfg+4rjmnhRPt6FJ4ctoN2IimZLo9gAUXDFtD9C2 75QznJOJwR5UUrrNfkOcZaEg3WOrVX6dRRHBCN15LSpnoAO4a1DXM3dPPOF9fMCVZg1W08U +P5H9GFpkCMqD05HKyBHardYwDRQLtjZIMqJVcvMj1m5DqysTXavdXdwWn1/fDto8o4b2Su OQU8gXcYKQhlGQJlzPohw== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:71Akjt8W24A=:PXGn17DWKzLuFP4vcJpLWp 6F7QXJChbrcNpMjxvg48EmTZUDNI2VAwov/bQzVFvSnS2FGMIoA189x5cp+m9KbSLQyVCnjtX wWbG4yx8cLaZpcXe6T5AzAwg93VUDvwU2ucHqNuUsqi8wtsaogy1zg95g/p9DUPnu9H7iwnfZ 8jsJa8IHhXne5CBS2Kahuk+i683IrM/G5/KultKGrG6p/DxEOnlIbntXbvJi/Kr3nrCProtNo +9YMoqD4ZLTogltmCpGIwGDWz+1IdHWWkTulz5nakoP1H29lJes7MG7yciCC0ajxhvvxBglTj j79etS3wzXmucVREnEV8dNnkCQ0pBGtO0bc1dIEDWYIDxzwiL9eY08115KLOed3GYyK2vG54v tgXTBJKgGX0NuwergkqwxaQtaImVic8oDwf+w9IBEOINy96Km4Nq/kFwm0MfnRsJ+Yg6l4OPa 5F3+VuvZm+ZIORPnvVLnc1yMPJEXtU5EaAd4Oo2qUq+wsi9qLMFLjG3clKefd+gn82FLFICBP iNeZW7APRpVtTZECe8jSbqAl0eK3WdhEHxrcYzgAzIwpvZEEFtZtKOvUmQud1DlQ+w7/WHcuO 5A30sotvNv7XD4Nyq87CLUpHcOaHWHGR6EZtNlxvDW8tvefLTIiuBPcwUZH0aVpNuP1B8x9QL hqOOuHngHCAPrzhGA+sUIW5E1/rkQPlPlKJjn5va7G/dWWND70mfO+eWmMbzkGryRhv3tnS8S 5+iIWWhWY/bj8rBvYvs39k2Ywyj+WlP25ZXl4aIHHMe4z1JL0SUerv4caOZ+IhKVf5VBmOYSb N0XtwkoK0hiRzWZmPTqPtPLZ9kvlerjFGkVZyC2gytjqDp6mDGYilKut4ZcxKEemb7GQy5x3+ co0zwMAK3NXUxqXhjkqw== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Dec 23, 2019 at 3:31 PM Christophe Leroy wrote: > > In order to simplify next step which moves fallback call at arch > level, ensure all arches have a 32bit fallback instead of handling > the lack of 32bit fallback in the common code based > on VDSO_HAS_32BIT_FALLBACK > > Signed-off-by: Christophe Leroy I like the idea of removing VDSO_HAS_32BIT_FALLBACK and ensuring that all 32-bit architectures implement them, but we really should *not* have any implementation calling the 64-bit syscalls. > +static __always_inline > +long clock_gettime32_fallback(clockid_t _clkid, struct old_timespec32 *_ts) > +{ > + struct __kernel_timespec ts; > + int ret = clock_gettime_fallback(clock, &ts); > + > + if (likely(!ret)) { > + _ts->tv_sec = ts.tv_sec; > + _ts->tv_nsec = ts.tv_nsec; > + } > + return ret; > +} > + > +static __always_inline > +long clock_getres32_fallback(clockid_t _clkid, struct old_timespec32 *_ts) > +{ > + struct __kernel_timespec ts; > + int ret = clock_getres_fallback(clock, &ts); > + > + if (likely(!ret && _ts)) { > + _ts->tv_sec = ts.tv_sec; > + _ts->tv_nsec = ts.tv_nsec; > + } > + return ret; > +} Please change these to call __NR_clock_gettime and __NR_clock_getres_time instead of __NR_clock_gettime64/__NR_clock_getres_time64 for multiple reasons. - When doing migration between containers, the vdso may get copied into an application running on a kernel that does not support the time64 variants, and then the fallback fails. - When CONFIG_COMPAT_32BIT_TIME is disabled, the time32 syscalls return -ENOSYS, and the vdso version should have the exact same behavior to avoid surprises. In particular an application that checks clock_gettime() to see if the time32 are in part of the kernel would get an incorrect result here. arch/arm64/include/asm/vdso/compat_gettimeofday.h already does this, I think you can just copy the implementation or find a way to share it. > diff --git a/arch/arm64/include/asm/vdso/gettimeofday.h b/arch/arm64/include/asm/vdso/gettimeofday.h > index b08f476b72b4..c41c86a07423 100644 > --- a/arch/arm64/include/asm/vdso/gettimeofday.h > +++ b/arch/arm64/include/asm/vdso/gettimeofday.h > @@ -66,6 +66,32 @@ int clock_getres_fallback(clockid_t _clkid, struct __kernel_timespec *_ts) > return ret; > } > > +static __always_inline > +long clock_gettime32_fallback(clockid_t _clkid, struct old_timespec32 *_ts) > +{ > + struct __kernel_timespec ts; > + int ret = clock_gettime_fallback(clock, &ts); > + > + if (likely(!ret)) { > + _ts->tv_sec = ts.tv_sec; > + _ts->tv_nsec = ts.tv_nsec; > + } > + return ret; > +} As Andy said, this makes no sense at all, nothing should ever call this on a 64-bit architecture. > diff --git a/arch/mips/include/asm/vdso/gettimeofday.h b/arch/mips/include/asm/vdso/gettimeofday.h > index b08825531e9f..60608e930a5c 100644 > --- a/arch/mips/include/asm/vdso/gettimeofday.h > +++ b/arch/mips/include/asm/vdso/gettimeofday.h > @@ -109,8 +109,6 @@ static __always_inline int clock_getres_fallback( > > #if _MIPS_SIM != _MIPS_SIM_ABI64 > > -#define VDSO_HAS_32BIT_FALLBACK 1 > - > static __always_inline long clock_gettime32_fallback( > clockid_t _clkid, > struct old_timespec32 *_ts) > @@ -150,6 +148,32 @@ static __always_inline int clock_getres32_fallback( > > return error ? -ret : ret; > } > +#else > +static __always_inline > +long clock_gettime32_fallback(clockid_t _clkid, struct old_timespec32 *_ts) > +{ > + struct __kernel_timespec ts; > + int ret = clock_gettime_fallback(clock, &ts); > + > + if (likely(!ret)) { > + _ts->tv_sec = ts.tv_sec; > + _ts->tv_nsec = ts.tv_nsec; > + } > + return ret; > +} > + Same here. > --- a/lib/vdso/gettimeofday.c > +++ b/lib/vdso/gettimeofday.c > @@ -125,13 +125,8 @@ __cvdso_clock_gettime32(clockid_t clock, struct old_timespec32 *res) > > ret = __cvdso_clock_gettime_common(clock, &ts); > > -#ifdef VDSO_HAS_32BIT_FALLBACK > if (unlikely(ret)) > return clock_gettime32_fallback(clock, res); > -#else > - if (unlikely(ret)) > - ret = clock_gettime_fallback(clock, &ts); > -#endif > > if (likely(!ret)) { > res->tv_sec = ts.tv_sec; Removing the #ifdef and the fallback seems fine. I think this is actually required for correctness on arm32 as well. Maybe enclose the entire function in #ifdef VDSO_HAS_CLOCK_GETTIME32 to only define it when it is called? > @@ -238,13 +233,8 @@ __cvdso_clock_getres_time32(clockid_t clock, struct old_timespec32 *res) > > ret = __cvdso_clock_getres_common(clock, &ts); > > -#ifdef VDSO_HAS_32BIT_FALLBACK > if (unlikely(ret)) > return clock_getres32_fallback(clock, res); > -#else > - if (unlikely(ret)) > - ret = clock_getres_fallback(clock, &ts); > -#endif The same applies to all the getres stuff of course. Arnd