Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp246580pxb; Fri, 15 Jan 2021 11:58:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJzW4AQKYi+TCuWj/46ToM0w8vW5byEQMN3QDULHSjBVPgN3pobv3W6v5j/R5tGFK178Q94B X-Received: by 2002:a50:8004:: with SMTP id 4mr10846964eda.329.1610740692734; Fri, 15 Jan 2021 11:58:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610740692; cv=none; d=google.com; s=arc-20160816; b=T9Bk9R6uVSlnvMl41r7Ix51Iw7+CFn9vhxsSuLeYE5AT8eoMV0bxdwFW8rFO3exzsb Ug87kfvlwPCJnb6VfnsF0TDzz5MfKw16p59HruLK+VEX36rSvzIC1yI9WYcxot6zBuVV 6L+S0CJKhN1vZMMUEOEMcW5bpLgojBWoVD2XqlmYfTUGb5jkTSqgAYK6ApqhKsxJTGJs 8H6FCqMuHZrV7QQnrB7fQg+5VN7+mXVjdM1hZVOwwRrIJ8u+eQG94z2NMGRJTVXuP31Q jbfIaElPmxacIWl7hvoF6ICw0BLHaZfSn8EhUvks10TxFbUXl3ko9jdNTfC+rQ751PPw UbfA== 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=ZZj/vcdghhVObemcAi2/CGpxr25gu9/L6JiZW8TWCWs=; b=ItqXyQtPrQDyHgv25JKqsXzgD8EMdQefhBDlRPfDK5xqvQoF8HKG+MUZDrDzwOPW0g nU8F90IKrmeRDXOKr8HEa81J6FX00lVyWpfxH4T5VBRBCEwstDuH78dyfmAYW0BGEeko 1c3xjq2JXKp7vODWAuSlB4Xi4DI0KgPveqRZaQe0nRFEvtf7fsesXenWT7X6whJHx2Mn 7hGF+3ju8VZusxYOyrqGC1Zjz+ZfyXzD87MLJ+QBTf09vwF3SG31PfpSF4RwYsd/qQ14 OTgLb7/wrTdSxEUyKsPvhHm75HDUHzTKKUsFN4yo2TPwPyziiNCywZQsjvbOPKeCsWHS pwIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="og1RkAf/"; 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 l8si4534462edt.265.2021.01.15.11.57.47; Fri, 15 Jan 2021 11:58:12 -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="og1RkAf/"; 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 S2388369AbhAOTzT (ORCPT + 99 others); Fri, 15 Jan 2021 14:55:19 -0500 Received: from mail.kernel.org ([198.145.29.99]:40838 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726970AbhAOTzR (ORCPT ); Fri, 15 Jan 2021 14:55:17 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id D9504235F8; Fri, 15 Jan 2021 19:54:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1610740477; bh=3P6UzwvfBE7I8FHg+VBGNcbWcvpdD9Wa7p1LGDVMHzg=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=og1RkAf/ZcgBndINyfwmX4RYO3dOBLwN6SlYxgJiU4oMjg0HBBGUJoMLyIeU0CgYI Cnsbu8mCZqrmuclUYI2ux3344/nhnWWLBgz0IaWPW9nATckk5GAPYlR7owO8GS0yYE EP14qQPGEiDmW/j/86ytD7xoJa8sZuthlSDJJRR3nwuyAhX/Qo443hargiPv2iuHJb BP1wDuqPL/qvN5l1k4YoE+rA4iQyorvMuRy1E0cCsD01euH4MJKL9oaNGlbb/cyawX 8TTD4Y4N34jwHqydzHcejAaQeRBSq1e4HCHbDTU70B+jLaqli5kz6f8aX+cDD3b95o LDMH2HBjO5ziQ== Received: by mail-ot1-f46.google.com with SMTP id d8so9705610otq.6; Fri, 15 Jan 2021 11:54:36 -0800 (PST) X-Gm-Message-State: AOAM53002x0NM45XOpdxuPBCEaeYQCBu2zIE8bJCbsSPJMiG0SyXLP8a /u5S8jWhB7DtliW0pQ2dFitYbS4Xc2MrYLxmGMs= X-Received: by 2002:a9d:741a:: with SMTP id n26mr2326419otk.210.1610740476133; Fri, 15 Jan 2021 11:54:36 -0800 (PST) MIME-Version: 1.0 References: <20210107223424.4135538-1-arnd@kernel.org> <20210115182300.GD9138@zn.tnic> <20210115183203.GA1991122@ubuntu-m3-large-x86> <20210115190729.GE9138@zn.tnic> <20210115191833.GF9138@zn.tnic> In-Reply-To: <20210115191833.GF9138@zn.tnic> From: Arnd Bergmann Date: Fri, 15 Jan 2021 20:54:18 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] x86: efi: avoid BUILD_BUG_ON() for non-constant p4d_index To: Borislav Petkov Cc: Arvind Sankar , Nathan Chancellor , Ard Biesheuvel , Thomas Gleixner , Ingo Molnar , "the arch/x86 maintainers" , Nick Desaulniers , Arnd Bergmann , Darren Hart , Andy Shevchenko , "H. Peter Anvin" , linux-efi , Platform Driver , "linux-kernel@vger.kernel.org" , clang-built-linux Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 15, 2021 at 8:18 PM Borislav Petkov wrote: > > On Fri, Jan 15, 2021 at 02:11:25PM -0500, Arvind Sankar wrote: > > That's how build-time assertions work: they are _supposed_ to be > > optimized away completely when the assertion is true. If they're > > _not_ optimized away, the build will fail. > > Yah, that I know, thanks. > > If gcc really inlines p4d_index() and does a lot more aggressive > optimization to determine that the condition is false and thus optimize > everything away (and clang doesn't), then that would explain the > observation. One difference is that gcc does not have -fsanitize=unsigned-integer-overflow at all, and I don't see the assertion without that on clang either, so it's possible that clang behaves as designed here. The description is: -fsanitize=unsigned-integer-overflow: Unsigned integer overflow, where the result of an unsigned integer computation cannot be represented in its type. Unlike signed integer overflow, this is not undefined behavior, but it is often unintentional. This sanitizer does not check for lossy implicit conversions performed before such a computation (see -fsanitize=implicit-conversion). The "-68 * ((1UL) << 30" computation does overflow an unsigned long as intended, right? Maybe this is enough for the ubsan code in clang to just disable some of the optimization steps that the assertion relies on. Arnd