Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp649125pxu; Thu, 7 Jan 2021 14:36:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJzWSkBfC0xiFzAri9iavc6A7ZrUWcGfBKpn5SVi4GpazylKCNPDtE/EhPf6GZEc++zMOW/5 X-Received: by 2002:a17:906:4c55:: with SMTP id d21mr743611ejw.116.1610059007972; Thu, 07 Jan 2021 14:36:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610059007; cv=none; d=google.com; s=arc-20160816; b=OFSKbo64z9HDnFxGDDyR1h0dWt63hbU7b2f9c0gE/Y4/yxlSe8XwJH0/qp3el7Tm91 XMDEFgnbAAGmczMtEtdUKwnAe5kvhopHZVFby7dUX14SUVif6HRAMwxS++DnkYTNyif9 harO8iYN/sSHeYDm8CGNxzkzAfh+r0bwmSmNYEPiVnmXRVoMh5QPS6htuM4lvFjE1ONn rcwJOWHyU2n4pYK9ee94McO/q5/DPTkDmtIFaTy975ZUEYpcePNi10df0McP+F6LDSfR DPgttCurCE9NJf/kYmOqSGUPcDhj96TW/5It7gBB8G4s6Qo8IL1WNWzqxa5rvCNUkMF1 +Tkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=GamxpJN2/2YX+msSTFjV4FulV2IKvKAkrBOKwEcZDoI=; b=IpqdR7AW8cAffbhKjWpHlR/ECptmy6BWGbl2i3GZ69K5zRxMxcL4tPI2/dDF/L0cXi ThZWuUYyVciavph0MBkxbXBdM1oTZ4Iz0lCfJs6ZA26DUOBQVLtgPxvsn8e0smYFrv/f NS7q4y/VB3KphUmNFoD0H74ECo64jSArgug8PDFDKIuIgANWjm2Ub4yjhGgw5Dih2fkd HhfGY2UMCbhXhKAiyV9Sj4UDEKeNdEl72YpjIDCLFwUZskLrna1T6ypjnJcy2GvXWyn6 AtGPTdK5FDBErr8PZ1xqFv0K8W6tCbUoiP7hPyYj96d/mR/ItBWjk4/rPb3utqkPBMiV 7RpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=nMU3CXGi; 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 kq16si2786355ejb.253.2021.01.07.14.36.24; Thu, 07 Jan 2021 14:36:47 -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=@kernel.org header.s=k20201202 header.b=nMU3CXGi; 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 S1728524AbhAGWfN (ORCPT + 99 others); Thu, 7 Jan 2021 17:35:13 -0500 Received: from mail.kernel.org ([198.145.29.99]:43718 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728289AbhAGWfL (ORCPT ); Thu, 7 Jan 2021 17:35:11 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id AE003233FB; Thu, 7 Jan 2021 22:34:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1610058871; bh=YxWPwsnnRjlrhr4yxPjg93gIGIM1hNu7MQw7OLs3KDI=; h=From:To:Cc:Subject:Date:From; b=nMU3CXGiXfYZYNwQR0pp5xAhCezD0B0HarZZ/6Pu6ZNPIb4aO+XBZvh6JBf3Do0eG p+yJYETgNWkbTO7EvZB3u1lhJ/p9dW2M5kUUAN7ZAmGw/RKfdaofmAgdfDkX6DUXRq FehZrcoJitZXPRPMvZX/NOwZPNW2Zwtptz9PocTxCMheK7jJDTXj7phMEO9U8xCTqb GhJLvhFPBcrjVrZP8sKIB2ktNNRSQnc77bVfC5dEpn+3vR4Tm53MAc1rAT9eLjjJFj 6iwnn+yefEYQ/Thm/rWLT6U1FHgcnOcPCCO/qzur2iXeQQhQ4jGhc1VA82FcNJv4Id GsWHy1fhkz0Xg== From: Arnd Bergmann To: Ard Biesheuvel , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, Nathan Chancellor , Nick Desaulniers Cc: 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: [PATCH] x86: efi: avoid BUILD_BUG_ON() for non-constant p4d_index Date: Thu, 7 Jan 2021 23:34:15 +0100 Message-Id: <20210107223424.4135538-1-arnd@kernel.org> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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