Received: by 2002:ac0:950e:0:0:0:0:0 with SMTP id f14csp35185imc; Fri, 15 Mar 2019 16:01:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqxxSbR781nOtl8ZL32e5T0AwHQCJxfiojaQnL7dPPD19gIzKk++v3jZgVbd5vt6Nsu+1exY X-Received: by 2002:a17:902:bd02:: with SMTP id p2mr6729023pls.260.1552690868228; Fri, 15 Mar 2019 16:01:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552690868; cv=none; d=google.com; s=arc-20160816; b=Um9/J06uXUwb4iZhy3qLOx+Vz9aPuPX5xOUZ113eJro7TxuSBTDZ7GC8t19NaNIS1f HBP1ATth6wQWO06WVX5KL7RpA3TN/9hcJEshlQzFlUDg72jZ4cCsJqokZkHBzldkc2XP Bb78/+KScYwTOiXzAMKLNoo6Ap3RGYq0bDiASGvbfq/SWEw/gg1O6rWqnGLzVMkcAGUX HgKq3F0afJwL3K1zwX0xqPo5P+Gz4UECf+D4DqAFUwxXXP+p/kG7QW6J+2L+WFmsLiq4 cQp9g+bDD1DcyochjrAC9TMdxrusLco1r+gqLZSF9su0q0l6f83PDeolr2dVHQ2pqIpY 0N1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=tEqipMkmPrwuZy0D121gbGL9+fu8h62ZcrJU46Deif8=; b=AquJDjqT8r/kEySFZusjlkl1qCZVgQOqtpifgiQc43g9FhUrmCHVtE6ao9ecLyKnAN uLD9IuJZr+15+lgDT52XgwxzhYKQZrTiNTq7m7nKp+PpZ/EXdGVxq2ATXutO3VgCxd0u v1dsdL8YWYiTsVFDSlVM0Okqg2nS0SOdv+NgI0m7X+Y0xcWd53csOKzHq40mn4G/sJ7b YG0V7NZ9SPSgF6NBkwQROen2dXrzQWJJS45nY43w71Nozs2RP3W0DNui+O9QOg2+ALwv YAlxeuGVQWvUxe8iN9RfpMUuam/E6Lj+sAOosL7cXsZ83m3uAlCQUjWd7h80rd2hHF1W youg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=PY2OTJMW; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p16si1725083pfi.176.2019.03.15.16.00.43; Fri, 15 Mar 2019 16:01:08 -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; dkim=pass header.i=@chromium.org header.s=google header.b=PY2OTJMW; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727183AbfCOW3J (ORCPT + 99 others); Fri, 15 Mar 2019 18:29:09 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:34624 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726766AbfCOW3I (ORCPT ); Fri, 15 Mar 2019 18:29:08 -0400 Received: by mail-pg1-f194.google.com with SMTP id v12so7413845pgq.1 for ; Fri, 15 Mar 2019 15:29:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=tEqipMkmPrwuZy0D121gbGL9+fu8h62ZcrJU46Deif8=; b=PY2OTJMWhe8nWOnu9fcoaSh5m3Mlvj+LorPk2yvi51QDH/RN46ZtAG8eThQI8Bu+j9 VufniDVkgiw8kIvmbziNZ809AxO1c9hhIVWANljmS+MQ0CwnxsYrHcvWvK26wFvfOwJl V3x3cOCqkqs6YBavygTSPJ4mXdiek1o+gLR1Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=tEqipMkmPrwuZy0D121gbGL9+fu8h62ZcrJU46Deif8=; b=aOXMWe5gnHWIlBxbKFTi9UXsrtk5Dm6xJ8V0KC/A6TviWazXTMK7cJBWKTyjV6nITC J1VqFjsTbe0RM8jzipoV2MbbY5VsK8xEo5bf6bL9kqDiV2zucFw6uBlAVSWmH/IfWA44 mxrzDmUx0j136+1uPhqHR2b3QLeLO7evNPbcgueOMcBwUQPgmRjyzimmSsoc9aUlZHfU pCL4u6I36oNxN0wIWapsi6TfsSlpK+hyBXH07tLF32/lPMYBvhWNki8bWmEe7R34FXmt oWwZcA3vPo0ifpfK2c6e+mYpX4mI8TeMw0g+DnKJDw7vdN8+YTxEmj5TkIRayllHdGLa J3bQ== X-Gm-Message-State: APjAAAXe4u4Q21FcXoa063z0vz+TT8ntiWebUkSrANnFkSyc70nDEmkm uN2WXM5nSxJNaliFZ87DmH4+nw== X-Received: by 2002:a63:6f46:: with SMTP id k67mr5633363pgc.174.1552688947866; Fri, 15 Mar 2019 15:29:07 -0700 (PDT) Received: from localhost ([2620:15c:202:1:75a:3f6e:21d:9374]) by smtp.gmail.com with ESMTPSA id j4sm4252130pfn.132.2019.03.15.15.29.06 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 15 Mar 2019 15:29:07 -0700 (PDT) Date: Fri, 15 Mar 2019 15:29:06 -0700 From: Matthias Kaehlcke To: Nick Desaulniers Cc: Andy Lutomirski , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H . Peter Anvin" , x86@kernel.org, LKML , Manoj Gupta , Tiancong Wang , Stephen Hines , clang-built-linux@googlegroups.com, Masahiro Yamada Subject: Re: [PATCH] x86/vdso: include generic __lshrdi3 in 32-bit vDSO Message-ID: <20190315222906.GC112750@google.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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