Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp552361pxb; Wed, 13 Jan 2021 09:55:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJytwO44IT7aPMzmp8tbeEqK9ub52czRQQQNHdQogCKu24Ax6cXNs/7lYkH3fGmnD2f1QKyA X-Received: by 2002:a05:6402:424a:: with SMTP id g10mr2750219edb.236.1610560534590; Wed, 13 Jan 2021 09:55:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610560534; cv=none; d=google.com; s=arc-20160816; b=LsUnHDCbvfRkfVkRejIEbuUAim1BXBmAhrTEOyVj8le4ZJ8p5u85Cb8Pi/ogsNrID1 OQh3nRSzrtwM9yemvcU5cM5wFQIp4qasdq+GQtM50urGruUzgZiJHX4jtlQryceMGPUq qrZMRFFaJUArgTE/Mg6Uc9a4S7CKhZQ3XcX67hsg8YjkOK/1LgbhswTbxp6zVKTug5YV GrQeK64+JW9W5myutlt+LrgZn/uMRr9TGM4ywRrpU2HgQYxWMSWcexrBRr9neJGZDiao Zt89wAE6eqh4Wnj+JaICFYML2fXwQcJWymQdvY0t0q8EZtkMiHtbIXn9Z0JQjLV5Cl0F E3yQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=aLbaw7pQltbtzVsswNXqJf3e7K39ObHdqq6gU1hIIro=; b=FXvEdaw/mp2bwZhKZ8rAIyhQ4bro7fZbLCwMcwzJyyzWpPNgfeNTe6p58VOrOnEG+m yvEIPbShKdK9/qjtPSyt0u3DQNq9khlkVdMBsitxO0iE2GDlHIjMI5gw3r7qAkCMadUh evUgWqYHIDW0I23Qfq0ic4Ba2nrmeMgBi8HIqYgonMnrojzZ/pHaRKbf8wPGyaEFmJbS DfEOPLrB2gALgANeRZa7Kw0hwzeBwfMeyWt2Em52o5WdL1mEzZq0ANPsd345Q/S46WQG stgNfGyAQlU0OTPJBG281vFtKz2yHOvJU8H2GmCc2vOVCcdjJE6IXgO7U7XC3PFnMqfM n/pQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cd2LEA8J; 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 j24si1380687edt.448.2021.01.13.09.55.11; Wed, 13 Jan 2021 09:55:34 -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=cd2LEA8J; 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 S1728124AbhAMRww (ORCPT + 99 others); Wed, 13 Jan 2021 12:52:52 -0500 Received: from mail.kernel.org ([198.145.29.99]:32918 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728028AbhAMRww (ORCPT ); Wed, 13 Jan 2021 12:52:52 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6AE8F23444; Wed, 13 Jan 2021 17:52:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1610560331; bh=DlYHZfCCpmtKD2iA6iFDDmBTIg4oFcFxKoR31k+rmT8=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=cd2LEA8JLCiaW87SV/HkvynYXNoBxc2A9QLFkSMJtQBqkut6/Zj18uD3G2Y0uMdcF Bo5uL8StWQKJeA1t6lJ45/VlIypGlE5AF3TQ05o/vxlDb7g/Z+Fnpf8jvYcjUdwy0S j0kLXZRNoDD9zS7wboi1EAe9PoNeXwwEBaNVBdKMTO6r+/JYFtAv4mpDJ4w6+ThHkh FiF4Qx94em0NlqC+Rtgjl7qvqe8fxOiXX9WQs3oYvNDOP2LVEISd5CHr71ZDOGrXP5 H9ax/LxX9orjkeUORnh6E3/EX16H45lRfCcHrMErjdutXehKj69C272uh/dZX9ya7R iSfwz9pM6l1/Q== Received: by mail-oi1-f177.google.com with SMTP id d189so2990288oig.11; Wed, 13 Jan 2021 09:52:11 -0800 (PST) X-Gm-Message-State: AOAM533UcbCS2kdiFGi0BQaMSAI6xrIhq1EMOwt6eh33+qZjFiQNSlm5 hvaAg1qBqUR5FeDFkjKfTonpIIqZykVA6T+V040= X-Received: by 2002:aca:210f:: with SMTP id 15mr263013oiz.174.1610560330694; Wed, 13 Jan 2021 09:52:10 -0800 (PST) MIME-Version: 1.0 References: <20210107223424.4135538-1-arnd@kernel.org> In-Reply-To: <20210107223424.4135538-1-arnd@kernel.org> From: Ard Biesheuvel Date: Wed, 13 Jan 2021 18:51:59 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] x86: efi: avoid BUILD_BUG_ON() for non-constant p4d_index To: Arnd Bergmann Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , X86 ML , Nathan Chancellor , Nick Desaulniers , Arnd Bergmann , Darren Hart , Andy Shevchenko , "H. Peter Anvin" , linux-efi , platform-driver-x86@vger.kernel.org, Linux Kernel Mailing List , clang-built-linux Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 7 Jan 2021 at 23:34, 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 Acked-by: Ard Biesheuvel This can go via the x86 tree directly, IMO > --- > 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 >