From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.7 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2B0A0C433DF for ; Tue, 7 Jul 2020 15:52:54 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EECB42080D for ; Tue, 7 Jul 2020 15:52:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="yLp1YhVx"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="qbZF9hTu" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EECB42080D Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=SqMoJaxAtdg+HwYVniv/+dk9hIZTpKyu6nvbVWWUYzk=; b=yLp1YhVxw5qbaWtwwcp6TbwvB 1otZa3bZ56JrtNj6tbknaBGOun/ZxKK9YGViXk1+ndx5SBYlVmRqdw7ossT63zyiMUbhsi4mZYked +MdSSjw1F3P+Xgg0R97LtTIsnOQxdVxdKvNTpAgGQaP/BpA4yt1CgPoG8CJLWoghjKTiz+37BtF2v QGp5NX/w6at+4463HTkQlPCI5JOaB2jzRyRu1Rn0MGr0GwSB1wDgH5dRkTFN4nKkynnB/ZTNc6Kjf yKYVclqZPIej+CdQvDBnPEs86gBHV3Vbu3kUrliQV01Ol4fmvalvlDsMEoJlW81Ge4t56C8hGwRhJ i0STnckLg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jspsV-0004lK-Fs; Tue, 07 Jul 2020 15:51:27 +0000 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jspsN-0004gX-E2 for linux-arm-kernel@lists.infradead.org; Tue, 07 Jul 2020 15:51:23 +0000 Received: by mail-pl1-x644.google.com with SMTP id x11so16901509plo.7 for ; Tue, 07 Jul 2020 08:51:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=6nbLKEvdqqtu0DOxk+RX2NCeuVjz/d5/WDsGYxOKe+A=; b=qbZF9hTub3E6dJOMlijRiMiRkHYkFQubSYFp6P+VnStOU35ksLbT5c2olfLiJpXsF3 p3AHOCADz7BlPRcb5xlVfsDuFkpaWzroZytIxmWQMa1Tq9gUpWVZPukI1yqE2KFTHiA3 9YlWvV6iIbDdJ+BZAyuKLx1RPuPn/LEcUmBvsAMcz6jJ5yyWtgLEw10Q8wnhLwp1ZVgF o4GGnZfpFXNrCeoFTPW5BteobP+ETyf4GPs6Ui4f/hVYa1npYd2Jb7cBEU2OssXqWPH4 auU0losOJLOMYxa1RdqPXWKkY62FkFHARI3LfbFiT0CpoTlE2LZsZ8/SQVRU7EUqTPAC 0DtA== 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; bh=6nbLKEvdqqtu0DOxk+RX2NCeuVjz/d5/WDsGYxOKe+A=; b=O6UIEF5BU5KoHO3CjMFqPD0UO8d4Z2p7E4slzYsU9AeRs4KM/JdXCizhEkNZsGKuT2 hRH4TCwHCU3rhgEHAxwCwaDeA0aqFqPsvfBBcSOc1wR8FeByJCdd+21maqsnxgz/2nKi cHJeCTfkvnaviv4W5H43SV1dAZ7qjOSCt1HN8UXHk3cTtyJgGYY7V+aHGUJB2mXyfQbU HS9PYT3MnvK1PQB6ceI8kVhquw2/CuC+l4m4SO6s4IGIpRlx5BAl6gOtf2VR0IIE7Qr+ ESO6AMzgxAqAO+8LiQJyHAo8fMp/4XYt13Yvp0/hQ4Cb+Kig4+uaJ/BBOCYkmhJFd+qb ek4A== X-Gm-Message-State: AOAM5311WjYuWlEEU5qt2+8tiday71Tp3TSWDAFtpqey8QksZdAjif/E gZcznjyAGy6atwFEycFO/nGDYA== X-Google-Smtp-Source: ABdhPJzoBjROrVaJtp6nujXRaXTatw7gwLtR2zb8jqFckSgpuUCpME8ySKJl8GGYK6iDFTRo3tsWzA== X-Received: by 2002:a17:90a:a106:: with SMTP id s6mr5003560pjp.53.1594137075030; Tue, 07 Jul 2020 08:51:15 -0700 (PDT) Received: from google.com ([2620:15c:201:2:f693:9fff:fef4:1b6d]) by smtp.gmail.com with ESMTPSA id b10sm22289026pft.59.2020.07.07.08.51.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jul 2020 08:51:14 -0700 (PDT) Date: Tue, 7 Jul 2020 08:51:07 -0700 From: Sami Tolvanen To: Masahiro Yamada , Jiong Wang , Jakub Kicinski Subject: Re: [PATCH 00/22] add support for Clang LTO Message-ID: <20200707155107.GA3357035@google.com> References: <20200624203200.78870-1-samitolvanen@google.com> <20200629232059.GA3787278@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200629232059.GA3787278@google.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200707_115120_055226_D002B379 X-CRM114-Status: GOOD ( 21.55 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arch , X86 ML , Kees Cook , "Paul E. McKenney" , Kernel Hardening , Greg Kroah-Hartman , Linux Kbuild mailing list , Nick Desaulniers , Linux Kernel Mailing List , clang-built-linux , linux-pci@vger.kernel.org, Will Deacon , linux-arm-kernel Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Jun 29, 2020 at 04:20:59PM -0700, Sami Tolvanen wrote: > Hi Masahiro, > > On Mon, Jun 29, 2020 at 01:56:19AM +0900, Masahiro Yamada wrote: > > I also got an error for > > ARCH=arm64 allyesconfig + CONFIG_LTO_CLANG=y > > > > > > > > $ make ARCH=arm64 LLVM=1 LLVM_IAS=1 > > CROSS_COMPILE=~/tools/aarch64-linaro-7.5/bin/aarch64-linux-gnu- > > -j24 > > > > ... > > > > GEN .version > > CHK include/generated/compile.h > > UPD include/generated/compile.h > > CC init/version.o > > AR init/built-in.a > > GEN .tmp_initcalls.lds > > GEN .tmp_symversions.lds > > LTO vmlinux.o > > MODPOST vmlinux.symvers > > MODINFO modules.builtin.modinfo > > GEN modules.builtin > > LD .tmp_vmlinux.kallsyms1 > > ld.lld: error: undefined symbol: __compiletime_assert_905 > > >>> referenced by irqbypass.c > > >>> vmlinux.o:(jeq_imm) > > make: *** [Makefile:1161: vmlinux] Error 1 > > I can reproduce this with ToT LLVM and it's BUILD_BUG_ON_MSG(..., "value > too large for the field") in drivers/net/ethernet/netronome/nfp/bpf/jit.c. > Specifically, the FIELD_FIT / __BF_FIELD_CHECK macro in ur_load_imm_any. > > This compiles just fine with an earlier LLVM revision, so it could be a > relatively recent regression. I'll take a look. Thanks for catching this! After spending some time debugging this with Nick, it looks like the error is caused by a recent optimization change in LLVM, which together with the inlining of ur_load_imm_any into jeq_imm, changes a runtime check in FIELD_FIT that would always fail, to a compile-time check that breaks the build. In jeq_imm, we have: /* struct bpf_insn: _s32 imm */ u64 imm = insn->imm; /* sign extend */ ... if (imm >> 32) { /* non-zero only if insn->imm is negative */ /* inlined from ur_load_imm_any */ u32 __imm = imm >> 32; /* therefore, always 0xffffffff */ /* * __imm has a value known at compile-time, which means * __builtin_constant_p(__imm) is true and we end up with * essentially this in __BF_FIELD_CHECK: */ if (__builtin_constant_p(__imm) && __imm <= 255) __compiletime_assert_N(); The compile-time check comes from the following BUILD_BUG_ON_MSG: #define __BF_FIELD_CHECK(_mask, _reg, _val, _pfx) \ ... BUILD_BUG_ON_MSG(__builtin_constant_p(_val) ? \ ~((_mask) >> __bf_shf(_mask)) & (_val) : 0, \ _pfx "value too large for the field"); \ While we could stop the compiler from performing this optimization by telling it to never inline ur_load_imm_any, we feel like a better fix might be to replace FIELD_FIT(UR_REG_IMM_MAX, imm) with a simple imm <= UR_REG_IMM_MAX check that won't trip a compile-time assertion even when the condition is known to fail. Jiong, Jakub, do you see any issues here? Sami _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel