Received: by 2002:ac0:950e:0:0:0:0:0 with SMTP id f14csp46003imc; Fri, 15 Mar 2019 16:19:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqy3o0YM/t/Yz5YiidRP9rdwuaCvy9WqzycNc0TbLivpTxWSyBxgfg/RiFE5uqNdbxFkO0Bd X-Received: by 2002:aa7:9310:: with SMTP id 16mr6627816pfj.84.1552691998711; Fri, 15 Mar 2019 16:19:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552691998; cv=none; d=google.com; s=arc-20160816; b=CuhRzi/vHPLyKQ0i41p2xEojxUSS3QOHmGzQIrTZ/IHaYr6Wn+BeejW2L2DVMpXgZ8 j/7BvvC4uFA/sCmo4e1N8Kf75Zg8cJs/yUvZ8fnr7xfc8/19iapRSuYrPUz2MSWWjulj rNUklU2Mgm3sunNTf7+0jhkUJFiM83lv/IopEOV4v/k0vNeFEMBA1HVR/cpgSWD/ztdv E6Hj/ho0MFL2fJeJTel62FykKw1AgcJU8FUizQl1SsQQs92gwadITBgPdp8ZlhYifITv mly6DKHz+yVhVnusHi5DZQC/ONH6pMKUaWDUk0ELXkszEfLX99N4FcgArjdn1wvLj6v9 LBTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:from:cc:to:subject :content-transfer-encoding:mime-version:references:in-reply-to :user-agent:date; bh=Oe9MQAd4gRG+aTMZv3UfGqxfCcQQWskMlZU/Ng51U5E=; b=CqMR89GR4Qc9bVpy+NIBiH/DvYINDTGrAVmpABD+9qvD5HnF3dYiQXvTky84UVlTQg 4jVz5WfvbVNgmyhBb6AcP7KbirxbQJVHMxrcRyhbzf7tQCtJ5VWTX3hS9l2bLwRYPfKx u6ttYYTeg+hU82n4yEWdgJAbrv/2aGsL+5IA7H+4Ar0RCHEsz6IBW55WQXKbp6p86cL+ M5oJsqIGr9722sHoZBlAFe3LuV65NEzL5Zd8hz7Y/PVvi/uT+t+d7vcoNjyMkAk4TVAc KgyJVpSnQiqgKtDJf4RzVKrKqASxS5FFYUAr8xumG7D4sh1kRHH58DksdH0BB9RGrWVz cnvw== 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 t134si2865659pgc.467.2019.03.15.16.19.43; Fri, 15 Mar 2019 16:19:58 -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 S1727165AbfCOXTA convert rfc822-to-8bit (ORCPT + 99 others); Fri, 15 Mar 2019 19:19:00 -0400 Received: from terminus.zytor.com ([198.137.202.136]:50009 "EHLO mail.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726803AbfCOXS7 (ORCPT ); Fri, 15 Mar 2019 19:18:59 -0400 Received: from [IPv6:2601:646:8680:2bb1:c81e:e06a:248a:3adc] ([IPv6:2601:646:8680:2bb1:c81e:e06a:248a:3adc]) (authenticated bits=0) by mail.zytor.com (8.15.2/8.15.2) with ESMTPSA id x2FNIdg71774044 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NO); Fri, 15 Mar 2019 16:18:41 -0700 Date: Fri, 15 Mar 2019 16:18:31 -0700 User-Agent: K-9 Mail for Android In-Reply-To: <20190315222906.GC112750@google.com> References: <20190315222906.GC112750@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT Subject: Re: [PATCH] x86/vdso: include generic __lshrdi3 in 32-bit vDSO To: Matthias Kaehlcke , Nick Desaulniers CC: Andy Lutomirski , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, LKML , Manoj Gupta , Tiancong Wang , Stephen Hines , clang-built-linux@googlegroups.com, Masahiro Yamada From: hpa@zytor.com Message-ID: <33DE9AEF-C51C-4021-97FD-BEE2C5D98DBE@zytor.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On March 15, 2019 3:29:06 PM PDT, Matthias Kaehlcke wrote: >Hi Nick, > >On Fri, Mar 15, 2019 at 02:31:09PM -0700, 'Nick Desaulniers' via Clang >Built Linux wrote: >> On Fri, Mar 15, 2019 at 12:54 PM Matthias Kaehlcke >wrote: >> > >> > Building the 32-bit vDSO with a recent clang version fails due >> > to undefined symbols: >> > >> > arch/x86/entry/vdso/vdso32.so.dbg: undefined symbols found >> > >> > The undefined symbol in this case is __lshrdi3, which is part of >> > the compiler runtime library, however the vDSO isn't linked against >> > this library. >> > >> > Include the kernel version of __lshrdi3 in the 32-bit vDSO build. >> >> __lshrdi3 is used for "logical shift right double-word by int" (best >> guess), so anywhere there's a right shift of a u64. Looks like >> there's a few of these in arch/x86/entry/vdso/, so it's legal for the >> compiler to emit this libcall. Do you know which function >> specifically in the .so has a relocation referencing __lshrdi3 >> specifically? > >It's the right shifts in do_realtime() and do_monotonic(). > >> Is there a config I can set to reproduce this, in order to help >> test? > >I encountered it with a Chrome OS specific configuration, but a >defconfig should do. Note that you probably need a development version >of clang to reproduce this. > >> > >> > Signed-off-by: Matthias Kaehlcke >> > --- >> > arch/x86/entry/vdso/Makefile | 7 ++++++- >> > lib/lshrdi3.c | 4 +++- >> > 2 files changed, 9 insertions(+), 2 deletions(-) >> > >> > diff --git a/arch/x86/entry/vdso/Makefile >b/arch/x86/entry/vdso/Makefile >> > index 5bfe2243a08f..7517cd87e10b 100644 >> > --- a/arch/x86/entry/vdso/Makefile >> > +++ b/arch/x86/entry/vdso/Makefile >> > @@ -144,6 +144,7 @@ KBUILD_CFLAGS_32 += $(call cc-option, >-fno-stack-protector) >> > KBUILD_CFLAGS_32 += $(call cc-option, -foptimize-sibling-calls) >> > KBUILD_CFLAGS_32 += -fno-omit-frame-pointer >> > KBUILD_CFLAGS_32 += -DDISABLE_BRANCH_PROFILING >> > +KBUILD_CFLAGS_32 += -DBUILD_VDSO >> > >> > ifdef CONFIG_RETPOLINE >> > ifneq ($(RETPOLINE_VDSO_CFLAGS),) >> > @@ -153,12 +154,16 @@ endif >> > >> > $(obj)/vdso32.so.dbg: KBUILD_CFLAGS = $(KBUILD_CFLAGS_32) >> > >> > +$(obj)/vdso32/lshrdi3.o: $(srctree)/lib/lshrdi3.c FORCE >> > + $(call if_changed_rule,cc_o_c) >> >> + Masahiro to help look at this part (I don't understand this part >> of kbuild). > >I bluntly stole that from arch/x86/purgatory/Makefile , which does >something similar. > >> >> > + >> > $(obj)/vdso32.so.dbg: FORCE \ >> > $(obj)/vdso32/vdso32.lds \ >> > $(obj)/vdso32/vclock_gettime.o \ >> > $(obj)/vdso32/note.o \ >> > $(obj)/vdso32/system_call.o \ >> > - $(obj)/vdso32/sigreturn.o >> > + $(obj)/vdso32/sigreturn.o \ >> > + $(obj)/vdso32/lshrdi3.o >> > $(call if_changed,vdso) >> > >> > # >> > diff --git a/lib/lshrdi3.c b/lib/lshrdi3.c >> > index 99cfa5721f2d..8a4fc6bcf3a4 100644 >> > --- a/lib/lshrdi3.c >> > +++ b/lib/lshrdi3.c >> > @@ -16,7 +16,7 @@ >> > * to the Free Software Foundation, Inc. >> > */ >> > >> > -#include >> > +#include >> >> Is this a simple cleanup, or? > >The vDSO build is unhappy when modules.h draws in a whole bunch of >other kernel headers and export.h is all that's need. It seemed >reasonable to do the 'cleanup' in this patch since we touch it anyway >to place EXPORT_SYMBOL within an #ifdef. > >> > #include >> > >> > long long notrace __lshrdi3(long long u, word_type b) >> > @@ -42,4 +42,6 @@ long long notrace __lshrdi3(long long u, >word_type b) >> > >> > return w.ll; >> > } >> > +#ifndef BUILD_VDSO >> > EXPORT_SYMBOL(__lshrdi3); >> > +#endif >> >> Compilers (GCC and Clang) will always assume their runtime has these >> helper functions; whether or not they emit libcalls vs inline >routines >> is implementation defined. So I agree with this patch; I just would >> like to help confirm/test it. > >Thanks for your help! > >Matthias Note: it is also probably no reason to use -Os/-Oz for the vdso. -- Sent from my Android device with K-9 Mail. Please excuse my brevity.