Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp217841pxb; Fri, 15 Jan 2021 11:10:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJx75pa+JDJjpMQkH7+/ksMKQ28wCSEJgiaiMLiDwOgFP8uxJC4dzXlgvXKGdRFO9o4rCEH9 X-Received: by 2002:a05:6402:1714:: with SMTP id y20mr10518183edu.360.1610737803027; Fri, 15 Jan 2021 11:10:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610737803; cv=none; d=google.com; s=arc-20160816; b=pkQAgz/Q44tyylMdmlEzXUq+7k/MqfcE1CiVRMu6puzulvnf5vk9ixYsHg6to38p/C OHv6Yw06LkmHCSKiy/dPEQ31SRAAzrLANcGqrrMS2cYiL/4e6hWxd9qxLaFNF3tXEdF+ rVtBhouaw2JsCvavnObs2QZqx5IyEqY0umOyDxpMLAnZymt5W66Qbp2d3WegaLMj9nxl 8FZnk2Afvk6CrU9HYT8f0/AiXz3niZP26KwXwnnPYilcXxpmaW0OQ3K/BQ6ePflam8yk KT08jopbYawlV5VuHw6FT6e6ErJcahrHXmaqKVf9L3E5pMQeBTqnr+pZz0vDCbnOlj0G g9Nw== 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=IL2Li+VoVRz1ZLH8TsjVaWowu41cqfDQQ4xb4rgDPpA=; b=iL2tpQDVQ8jrmlolAeRxv59gP8XjQxHdOCCRQugOoixVLtP8SVzoyneIKem4srbSzY fKl9ZbuYZ5d50j4Bfww0KIUn46h1o/CVF8zVK5SOHWqKjMipoEZ13JiVUCFFw8fYinNS 9y5pkmeb/xVHhAWZt6oY5NyUBEwc3YOZidXINmMHFNfgvLLySyyg9QNJSs9QBH7dbd4M 4nNN0NwhFUUIK4EqAIFC3Kicta8VX40amSgixpv7wxQ9mdCaOee/uzAW5YqGaPNEQqdj XqyUTy0b1uxQFsMU2BLCP1e/8CETSMZoRXCkQSeZViclwyUksJTuySh1JUnyuri914tL MSEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=kQSTl2hc; 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=alien8.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dj27si3187398edb.398.2021.01.15.11.09.39; Fri, 15 Jan 2021 11:10:03 -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=@alien8.de header.s=dkim header.b=kQSTl2hc; 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=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387814AbhAOTIR (ORCPT + 99 others); Fri, 15 Jan 2021 14:08:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732380AbhAOTIQ (ORCPT ); Fri, 15 Jan 2021 14:08:16 -0500 Received: from mail.skyhub.de (mail.skyhub.de [IPv6:2a01:4f8:190:11c2::b:1457]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 89F3CC061757; Fri, 15 Jan 2021 11:07:36 -0800 (PST) Received: from zn.tnic (p200300ec2f0acf007cb1195bb528937a.dip0.t-ipconnect.de [IPv6:2003:ec:2f0a:cf00:7cb1:195b:b528:937a]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 407601EC041D; Fri, 15 Jan 2021 20:07:34 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1610737654; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references; bh=IL2Li+VoVRz1ZLH8TsjVaWowu41cqfDQQ4xb4rgDPpA=; b=kQSTl2hcvjHob0BnMyXEr6Eg/al13WgaiP34iPoaRgs0W1J6aI+bls+yDp3r1c4akasNFw 75cO1KAvTsPUw7GR6EO5eKIgygI7vnxCy4N5FjM6ZqZCgAFIpXqeO+7F/eScWqHIbmqoFY YBmUwIKxK4c4m74+QeRN86lcKEA5mJQ= Date: Fri, 15 Jan 2021 20:07:29 +0100 From: Borislav Petkov To: Nathan Chancellor Cc: Arnd Bergmann , Ard Biesheuvel , Thomas Gleixner , Ingo Molnar , x86@kernel.org, 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: <20210115190729.GE9138@zn.tnic> References: <20210107223424.4135538-1-arnd@kernel.org> <20210115182300.GD9138@zn.tnic> <20210115183203.GA1991122@ubuntu-m3-large-x86> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20210115183203.GA1991122@ubuntu-m3-large-x86> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 15, 2021 at 11:32:03AM -0700, Nathan Chancellor wrote: > I triggered it with CONFIG_UBSAN=y + CONFIG_UBSAN_UNSIGNED_OVERFLOW=y > (it can be exposed with an allyesconfig/allmodconfig on mainline > currently). Yah, I can trigger with that, thanks. But I'll be damned, check this out: clang preprocesses to this: do { extern void __compiletime_assert_332(void) ; if (!(!(p4d_index((-68 * ((1UL) << 30))) != p4d_index((0xffffffffff000000UL))))) __compiletime_assert_332(); } while (0); The resulting asm is: .LBB1_32: movabsq $-73014444032, %r13 # imm = 0xFFFFFFEF00000000 testb $1, %al jne .LBB1_33 .LBB1_34: xorl %r14d, %ebx testl $33554431, %ebx # imm = 0x1FFFFFF je .LBB1_36 # %bb.35: callq __compiletime_assert_332 so the undefined symbol is there, leading to: ld: arch/x86/platform/efi/efi_64.o: in function `efi_sync_low_kernel_mappings': /home/boris/kernel/linux/arch/x86/platform/efi/efi_64.c:140: undefined reference to `__compiletime_assert_332' Now look at gcc: It preprocesses to: do { extern void __compiletime_assert_332(void) __attribute__((__error__("BUILD_BUG_ON failed: " "p4d_index(EFI_VA_END) != p4d_index(MODULES_END)"))); if (!(!(p4d_index((-68 * ((1UL) << 30))) != p4d_index((0xffffffffff000000UL))))) __compiletime_assert_332(); } while (0); Resulting asm: $ grep __compiletime_assert_332 arch/x86/platform/efi/efi_64.s $ That thing has been optimized away! Which means, those build assertions are gone on gcc and they don't catch diddly squat. I sure hope I'm missing something here... -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette