Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1202890ybt; Tue, 7 Jul 2020 09:57:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJylK/mCMHqGAOjRG1ofPXNPnjeiWU7MNfH5xtZaufKG++mt4S2s0fkddfqEPZw5OQl3t7dy X-Received: by 2002:a17:907:6fc:: with SMTP id yh28mr47958864ejb.267.1594141076005; Tue, 07 Jul 2020 09:57:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594141075; cv=none; d=google.com; s=arc-20160816; b=ByDDIduy2twgPniF2DszfDxtGcsiONalWIs2MoEV13xm+GKdrlmViEE69lYj9Yb1eh LPbTrk6zhPPurkvdxBqGC5XHvupvvGU7xxqGdmlAKkudAgFJuOyX9PeC//O6QnQku5bS 8GUs8+TDdXrgpZaBlrGrhTomcIl5v7rXEMkJ8DQF3TU8KGEVYw2P4gZzlYWjW/Ht7Zkb Tu3Y9BEr7UVlSfcw4PRzumT8RIbF094P+Uy9nrhKg8JwwVpz5rW//nr0wh0RdLX+FTvX E4yfd8Qozg97dwPCXwK1YU42VvjEsKWIDEWHHTc/x9+f1lVknZ5YSBCAxlyl5GEVRGgJ Cpbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=zD6xWOBL5ttUfKdEHVH345hysM4dP6zavq18WfZXmuw=; b=P0+vGivDvSlwR/3mU1mT6iUqHvcdGrCZOFRRQrXEf2H10etFF5DWQQ8DizzydCUmGw e6hx/LxdNXcBKMWFaaLWlcuaQWqN8U6aAg9xabOIQuuBbg7aY1OuTSP7WpaGqj7EVrST ZWOLWE0WkYRSd4rMSPQk5W9wDBg3aY2JrIey78wfKRXfDDejPYuxFJ9Zmy3Epv9wpmbZ Eb+SIeCKt01mJQxeISOMt1UyBMfUbbCrTGnLCu+ZFm5Vi/0c7jkWx5+tJT0UPPYsi03d xEwbTdA6vc3WSl+Ew33hbJW366ndIBvOdXreoKrJIvgt2ui9hSQwn6sQjw/j4R6ssEuj R5eg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=WfluW2mA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u6si15365286ejf.218.2020.07.07.09.57.33; Tue, 07 Jul 2020 09:57:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=WfluW2mA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728295AbgGGQ4y (ORCPT + 99 others); Tue, 7 Jul 2020 12:56:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:48430 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728110AbgGGQ4y (ORCPT ); Tue, 7 Jul 2020 12:56:54 -0400 Received: from kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com (unknown [163.114.132.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5ECEC2065D; Tue, 7 Jul 2020 16:56:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594141014; bh=Pxamgvc2FYcqKzB/kO/K+pvItVmdREDTa9V2Uq/pm90=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=WfluW2mALu5v2u4IsB9+2+vbjc5luGQpkCpWji2UWyn5eJGKh2+w3PCRaCORF0/YN +46mUvg1IPuLlsjfbJFei4Opj8gC35QmxI1XVnc0h/gl29judPMY7nyXTpvF+QwI80 oPi+MhkEYdPflHpFGc+lNEnz/Mg7+kCFEw68dC9I= Date: Tue, 7 Jul 2020 09:56:51 -0700 From: Jakub Kicinski To: Sami Tolvanen Cc: Masahiro Yamada , Will Deacon , Greg Kroah-Hartman , "Paul E. McKenney" , Kees Cook , Nick Desaulniers , clang-built-linux , Kernel Hardening , linux-arch , linux-arm-kernel , Linux Kbuild mailing list , Linux Kernel Mailing List , linux-pci@vger.kernel.org, X86 ML Subject: Re: [PATCH 00/22] add support for Clang LTO Message-ID: <20200707095651.422f0b22@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> In-Reply-To: <20200707160528.GA1300535@google.com> References: <20200624203200.78870-1-samitolvanen@google.com> <20200629232059.GA3787278@google.com> <20200707155107.GA3357035@google.com> <20200707160528.GA1300535@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 7 Jul 2020 09:05:28 -0700 Sami Tolvanen wrote: > On Tue, Jul 07, 2020 at 08:51:07AM -0700, Sami Tolvanen wrote: > > 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) > > Should be __imm > 255, of course, which means the compiler will generate > a call to __compiletime_assert. I think FIELD_FIT() should not pass the value into __BF_FIELD_CHECK(). So: diff --git a/include/linux/bitfield.h b/include/linux/bitfield.h index 48ea093ff04c..4e035aca6f7e 100644 --- a/include/linux/bitfield.h +++ b/include/linux/bitfield.h @@ -77,7 +77,7 @@ */ #define FIELD_FIT(_mask, _val) \ ({ \ - __BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_FIT: "); \ + __BF_FIELD_CHECK(_mask, 0ULL, 0ULL, "FIELD_FIT: "); \ !((((typeof(_mask))_val) << __bf_shf(_mask)) & ~(_mask)); \ }) It's perfectly legal to pass a constant which does not fit, in which case FIELD_FIT() should just return false not break the build. Right?