Received: by 2002:ac0:950e:0:0:0:0:0 with SMTP id f14csp43478imc; Fri, 15 Mar 2019 14:32:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqyjEW04psQaVO9e2f9rzyx6aRzX5qWKQhYkQHpQQYQGC4NOqBvJyZGbRCShyYX2E+eXdaCL X-Received: by 2002:a17:902:6b05:: with SMTP id o5mr6477512plk.90.1552685533489; Fri, 15 Mar 2019 14:32:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552685533; cv=none; d=google.com; s=arc-20160816; b=oBqwDAN31bSgg4ekLXFFhC4jtu406gMf3nRsljSBVWbKVBF28i+0huLzZZj1sDHx8P uG/kDEsr2sVlXzFlciQKzNng4ifujMFD0GGcPQTYc7Ek3NekNF1uoZ+UX+ZmsV3CnxUd TfuiW3zlt7Tc0VPr637tl/L9yfwciX51L45R4CSEQDRBIeVYejC+4XDODQRns3UWQGn/ Fzx080DGCDkJ2B+eJQtzpUZfwscshsUrm6LpbwUrhvIfF7APNyiF46r55oNTepZzMpMW pb2EB9dkxZ/MsqgQ9CpFhIonWSwkRy6giGMyYxT7vzsz/OdfOpvpMnkp0V0MPychcXFn i/jg== 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:dkim-signature; bh=8SftavF4SjKs7uaTaufFsPjfhMFzKpeU6qXdWt7twiY=; b=XxzU63kQBWwC/015UxkwXtlLsEwD0SJUuWQVH8AS3wY2QbzLQcQEIrTwNjvKgAHSrC e6301Cb+AbcJFhQy4gONJpBpyRrtuv8wxZSS1VmhYUVTobcoB78vKtjeqX72pLwT6ohY Bec6IkpubG1lfCTVvqaN4SgYwgqZ2OrL5wmZp3p8ECJtDrFNrn7ZTRNCP5G9rWhaLc48 C15JBvt95gJe9P0kJ066TBqbw6wqGXnFT6341Q7HtD9j7NDKXr71ayupW7T7pYUKpCwy NDYuHUeT3graO6gY+HyBgUDmfcooUTGoLpbfp3YIdYITx3//tvF8CrnmQWgrEv4cTfue 2Afw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=nmTcpBqO; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d90si2832572pld.97.2019.03.15.14.31.58; Fri, 15 Mar 2019 14:32:13 -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=@google.com header.s=20161025 header.b=nmTcpBqO; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726349AbfCOVbW (ORCPT + 99 others); Fri, 15 Mar 2019 17:31:22 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:45680 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726130AbfCOVbW (ORCPT ); Fri, 15 Mar 2019 17:31:22 -0400 Received: by mail-pg1-f193.google.com with SMTP id 125so7282346pgc.12 for ; Fri, 15 Mar 2019 14:31:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=8SftavF4SjKs7uaTaufFsPjfhMFzKpeU6qXdWt7twiY=; b=nmTcpBqO67zaIRvQrvvqUChJysBmQnOdx0prCZhc6E6rIyDA8lynlcIp+GnI5GL5Nl /4sRv+go7Fj1CatfQdSjvV9tGQEl/ZH8BoxwtSQqSilTxXoCNZOuyqdebvTmXBayyUAd zr+14vl3/kKb/5GJI7rEveWa2kzLXxBgvpryhW6Qz9NXZ3G7hIfoyrCC2xRGKxGj6IHo H816EpzuGe11fIEXSQlTX1mtsGY4+OZudsXa3vde803ag8dYYZT9WueIFjWCDlySHHhG YZgk6KiGLOBY8x2/hwO4gf2hl0cTZFC9eOoG2REWD6HkP2pNuTSmvCT+UAPuoZh9iWIF H/0w== 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; bh=8SftavF4SjKs7uaTaufFsPjfhMFzKpeU6qXdWt7twiY=; b=ZJm4vyJUOYUzyPuFx7awWaWu05QBDoOB9I0awcSRZfQ0CI5DqoWt0iAnVhHBH6JLu+ pIpUuM5MKQSbqT0L1n2IkqehOxwQoomV7YvAZtRAlyW5+0TwaEN5ms95r+sm1Nz3ncou 4V6sWbMZS1vPItu+RezhGV2e38ia23HiZQMHm2cw3WSL6QREcmvluVYA/Bphl8ioatOv abDLKoYQruzUc2tIDgUwTK4dnidERBcvIH5Mkds/mwuOBogdHrkTXgpata84YnZFLMha of/bzNzlPnmB1V9PXxCb21aAGzFIbpQPjJUg//1SRPoF8Zl77MqQRvUeNgZfdh88GBRe LllA== X-Gm-Message-State: APjAAAUbk0YgOpkDsixDfWHt9qATYVHVA6RgmXZA8dm23mde3gGVdxTD 2c1JjsAkeKTJopwrsTOKH1EvQgNLldmE46IoCaoy+A== X-Received: by 2002:a63:c511:: with SMTP id f17mr5476141pgd.202.1552685480717; Fri, 15 Mar 2019 14:31:20 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Nick Desaulniers Date: Fri, 15 Mar 2019 14:31:09 -0700 Message-ID: Subject: Re: [PATCH] x86/vdso: include generic __lshrdi3 in 32-bit vDSO To: Matthias Kaehlcke 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 Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? Is there a config I can set to reproduce this, in order to help test? > > 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). > + > $(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? > #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 > -- > 2.21.0.360.g471c308f928-goog 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, ~Nick Desaulniers