Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp164964pxb; Wed, 20 Jan 2021 04:05:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJw2CNNOuKbystmEjXB0TH2KR9JUBOx5SS0LCq3PvDi5rBTrUMgJxpDK7nQ2cxZULyl6MdFL X-Received: by 2002:a17:906:6053:: with SMTP id p19mr5998852ejj.93.1611144254936; Wed, 20 Jan 2021 04:04:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611144254; cv=none; d=google.com; s=arc-20160816; b=myOvT5c+spTuvjY5Gb/NYtGYo0gv9yRAzFclmAYputoxiYfPTZ45dKv8B8yKkwrvHX jY5o6ZXmYlHdjv+gh2ljdG+EdeGuH5uZCxWI5zeGwK8OHJ9HaZQ7GfrwT2NMdDaqEmYz IBnyNcKJ2n0Kuo8au7t1RMMf/V04CXdgDzDoD8bfvYZtLeHPsgBRe3O1+nhak3MACIBm bceY5aUuBGsgfHmw7X7HBVc9qy61UoJtLNs/S65tJqH7B/Gre+L6sD+ydCmJmrETjqm4 XvptFuyDJJEC6W8yvlcsU6pQ9/fs64CuLWcLKAxk7MKbszZZvBmuQ0UwkjHiYJwhG46T 2liQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=e1Mh46vTv3FVcofbpZz88mBZexF8yUI1mlf2fsLkouw=; b=UDwJlqRSZR72B0XkBYAfT8H/bLJb/5HAsO5lrr2f9hNXyzu1d4TdRlrgTOWn4pXqXR temyvqTWy+c5FCdOMg+kyDLUvEa+lQXOj0IipAEGTL0EYqrhW5OM5PQQeXyx8+a6iO/j sYU6qDpjxK8nMY6BhlVdWot+CPUBpDPrr85N9XPjENMHG5ojf8OPECG6HtYW6eQmLmsU 8XjhGSC54rcZYoFDJpx8UtF0nMOfzj+zgGpkzprwLE5/bvLNJfGe50J6K2wMkALwgj2y t9E0Do2+BEz9RNTg3hDaAFCdQhL3vfTTAMI1ZoPnG1+/p55Ss1Ce0QWzOsapN3u3swrn zpgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@shutemov-name.20150623.gappssmtp.com header.s=20150623 header.b=j0j2tuot; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a1si712862eds.422.2021.01.20.04.03.41; Wed, 20 Jan 2021 04:04:14 -0800 (PST) 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=@shutemov-name.20150623.gappssmtp.com header.s=20150623 header.b=j0j2tuot; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733287AbhATLk6 (ORCPT + 99 others); Wed, 20 Jan 2021 06:40:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37576 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388858AbhATLGu (ORCPT ); Wed, 20 Jan 2021 06:06:50 -0500 Received: from mail-lj1-x233.google.com (mail-lj1-x233.google.com [IPv6:2a00:1450:4864:20::233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 51D7CC061575 for ; Wed, 20 Jan 2021 03:06:04 -0800 (PST) Received: by mail-lj1-x233.google.com with SMTP id 3so5381697ljc.4 for ; Wed, 20 Jan 2021 03:06:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov-name.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=e1Mh46vTv3FVcofbpZz88mBZexF8yUI1mlf2fsLkouw=; b=j0j2tuot0ZyMl0f0aOTmS1p3g69+9BZIF/gAMmgopBTpUJo1be77vcPSKipxp8VuMS V2CLqZVAh7hr5LB1u7M2uGGi2E99l8jikfPZR6dCz5Fi54Vb6dfKkUZMFgD40mFeJJ1G /2y3WTS6DGwh3kJrNXQLTDUMGDHtOBD0W4nl3G+NhkeMqAuyJw3HxxwFVu/aFX9heV5E mXjNez5p3kWGj2yal+Er7BTSyJucs1EcqDUr7HQvwwSwdJ30gJsIonpcF/d21PUlGbM+ Vj7ndfDZi4bzRIQ8HfmtZZ18AWN/gHwp1Rk8bP1UIBjCMwVDGaqQWmAJ+ESRWHjXnLhZ 8ncg== 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=e1Mh46vTv3FVcofbpZz88mBZexF8yUI1mlf2fsLkouw=; b=CXf6OsxlZUd9vSbQyvvNa8gBb3//8sZC+eC8h7bKjKUYclvs8D4RWfkSi1L6mIDjpc p1+pOtDiGmNwBbtHNGMiej2xPFl5bgAYR7wIC3ClaCEV/fJNdGH2Cp5Z4qsMbxxv6zwb fmUEty7+PMcO7AkXys6vVnys2QH/wEN+8yU89Bkmp4mjrikYz4t8GSeCRXJjuZAjNSrK SRnH9XskKjgp/UiEGq7PZxDrhalyTAqHMcZ9UVXTmHV4tRkuFcuQU4xZzg/3DuOMgSb7 1mWdIOgYMp5v5DkmMz9xd1oTOczgc8Ve3+6QhEIwZn4FJTJHd3ZQkou+kLyeU2pPvpUh S2dw== X-Gm-Message-State: AOAM530Wk/geuidqbgHYeT7Hu0E+dhVble27h8gyjgoa4vhgu/otNf1c 20zJMMLBAXubcvNfN8srtThL/g== X-Received: by 2002:a2e:8645:: with SMTP id i5mr3310189ljj.7.1611140762858; Wed, 20 Jan 2021 03:06:02 -0800 (PST) Received: from box.localdomain ([86.57.175.117]) by smtp.gmail.com with ESMTPSA id q3sm178375ljp.108.2021.01.20.03.06.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Jan 2021 03:06:01 -0800 (PST) Received: by box.localdomain (Postfix, from userid 1000) id AA3C5101448; Wed, 20 Jan 2021 14:06:04 +0300 (+03) Date: Wed, 20 Jan 2021 14:06:04 +0300 From: "Kirill A. Shutemov" To: Arvind Sankar Cc: Arnd Bergmann , Ard Biesheuvel , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, Nathan Chancellor , Nick Desaulniers , Arnd Bergmann , Darren Hart , Andy Shevchenko , "H. Peter Anvin" , linux-efi@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com Subject: Re: [PATCH] x86: efi: avoid BUILD_BUG_ON() for non-constant p4d_index Message-ID: <20210120110604.bms6yjoiluojj4x4@box> References: <20210107223424.4135538-1-arnd@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 15, 2021 at 02:07:51PM -0500, Arvind Sankar wrote: > On Thu, Jan 07, 2021 at 11:34:15PM +0100, Arnd Bergmann wrote: > > From: Arnd Bergmann > > > > When 5-level page tables are enabled, clang triggers a BUILD_BUG_ON(): > > > > x86_64-linux-ld: arch/x86/platform/efi/efi_64.o: in function `efi_sync_low_kernel_mappings': > > efi_64.c:(.text+0x22c): undefined reference to `__compiletime_assert_354' > > > > Use the same method as in commit c65e774fb3f6 ("x86/mm: Make PGDIR_SHIFT > > and PTRS_PER_P4D variable") and change it to MAYBE_BUILD_BUG_ON(), > > so it only triggers for constant input. > > > > Link: https://github.com/ClangBuiltLinux/linux/issues/256 > > Signed-off-by: Arnd Bergmann > > --- > > arch/x86/platform/efi/efi_64.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c > > index e1e8d4e3a213..62bb1616b4a5 100644 > > --- a/arch/x86/platform/efi/efi_64.c > > +++ b/arch/x86/platform/efi/efi_64.c > > @@ -137,8 +137,8 @@ void efi_sync_low_kernel_mappings(void) > > * As with PGDs, we share all P4D entries apart from the one entry > > * that covers the EFI runtime mapping space. > > */ > > - BUILD_BUG_ON(p4d_index(EFI_VA_END) != p4d_index(MODULES_END)); > > - BUILD_BUG_ON((EFI_VA_START & P4D_MASK) != (EFI_VA_END & P4D_MASK)); > > + MAYBE_BUILD_BUG_ON(p4d_index(EFI_VA_END) != p4d_index(MODULES_END)); > > + MAYBE_BUILD_BUG_ON((EFI_VA_START & P4D_MASK) != (EFI_VA_END & P4D_MASK)); > > > > pgd_efi = efi_pgd + pgd_index(EFI_VA_END); > > pgd_k = pgd_offset_k(EFI_VA_END); > > -- > > 2.29.2 > > > > I think this needs more explanation as to why clang is triggering this. > The issue mentions clang not inline p4d_index(), and I guess not > performing inter-procedural analysis either? > > For the second assertion there, everything is always constant AFAICT: > EFI_VA_START, EFI_VA_END and P4D_MASK are all constants regardless of > CONFIG_5LEVEL. Back in the days BUILD_BUG_ON() false-triggered on GCC-4.8 as well. -- Kirill A. Shutemov