Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp153284lqt; Thu, 18 Apr 2024 10:52:23 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWujEJU43vCbr6SkzF2nHWsevvvzHzASrLMdcG8bSxDXtj4vczJ06JIOBi3MLPP02we78XiTCJ/WXUA+btL0v4un5U3sOwEwwyva8q2Sg== X-Google-Smtp-Source: AGHT+IEhkmQIUUv39cgm3UG4tsSzDYUeGJBpSqawv4Oa243kD9ZwTI2a6/ItzlgzEvuKd8L8PIaW X-Received: by 2002:a05:6512:230d:b0:519:e878:9385 with SMTP id o13-20020a056512230d00b00519e8789385mr1689621lfu.18.1713462742767; Thu, 18 Apr 2024 10:52:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713462742; cv=pass; d=google.com; s=arc-20160816; b=p8fhhNFZJcgURkY2d4mSBCo+JW6hK0Bzytn1JCxht2bhwt4J9B+bVOBKZHQ3b3iq7L japttKtOGcaWEEfT5a+einAG1CQduSnF3DmUPQbhRi3YEZWyQ1nFnIRsy0X8cIi2xfFs ElVEGlUyBeQCnl67L5Q5Vc7PZSnQV2TnTUoGBchykWM4ZnjYjYhniEmFn0Bdp0QgVylj 27t67AFg1kTd0Mg1myPmG+OeUCwrEtXxewM0pfd8P6yucA4VWNyoNng1gAjopomiDxqU Ovmy69lfquZokBYQQfCSkMb3cEtwc0EaIqGTfrDjNxuJt6mRkPEafQyhSeS2SV/jQv0F dMqQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=j0L44MA/FkOTbihIP0Ec9AKi5mgK3t+n5Ok46RIu0Qw=; fh=8xWCRlRKhygNKgSdsgj03qrLtL26iYfvjzZg6oQV4AU=; b=jdu/A/r/JEmrTsJt3Yl6ZryCy/KW7auBHUHroKXSEXz8b/5xkTAkgHP0unhQhq0QQ9 ObSzX8oaZVfo0Pqk6pm9Hc68YMdL9E9YLXpnJW61ETC7V5+qDBNX3JLjnnDJm8CS9huo be4Urj+xkvGZEkTwvv7Vi5oJiCLaO9NW6SkIrqhssT6ubKCpXzwCmHlLQWApsrO0NFSJ 9xdm1HfNxvnZewIWqw698B8fFwlUh4Cx1c93mNb3hi8REep5IrpVIg95NxEceeRxRvrB gNCsTaTwGvN67ii8cTYBxmwwfcuRKy3gV5IpxfWMSXyxZZN4DdyfyYkyYwp7s0JL3Nzb K/gA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=B1gWsDdC; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-150599-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-150599-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id ka6-20020a170907990600b00a5568f7b355si1066530ejc.908.2024.04.18.10.52.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Apr 2024 10:52:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-150599-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=B1gWsDdC; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-150599-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-150599-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 72FD51F2163C for ; Thu, 18 Apr 2024 17:52:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B1CAA176FAB; Thu, 18 Apr 2024 17:52:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="B1gWsDdC" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D8A6216ABEB for ; Thu, 18 Apr 2024 17:52:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713462736; cv=none; b=IhA4Chy/XpKsI9FBPgq/nOApn2hM71xA2LFUSQti+C1BTCdJeK/gNEhrp4I16ZKor+vf5yZ8rpcYYNfgFvNPqcp/TuiZDXe+RYZdGaw5rkl3luYlvQ3ukRP0WZQqGoKQ39bQhXOSbajvmklyI3jxo1zGthPT+iXjWpU3xDR69WE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713462736; c=relaxed/simple; bh=FuurGdaMgzX2x9p9hW7DG1u1zyapQ60UbXomusCQDWw=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=uvLGWe0QT8CsAy7lKUKbtGRkpj7MmrJm2HeNxC6/YCHHpIH4LoC8GYHwUFU99z8hKdj+KAu3vI2hdw3A+ctr113jAHF/8zcfvu4+fxLrhPa4OeukvfEdNcHD+4vijkU4m20JRRMq5Jew5BEhix5CIwP/Cg/qjQUqICDBtWp9HWg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=B1gWsDdC; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6FBFAC116B1 for ; Thu, 18 Apr 2024 17:52:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713462736; bh=FuurGdaMgzX2x9p9hW7DG1u1zyapQ60UbXomusCQDWw=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=B1gWsDdCM5chwfVvYQ7F1WiUne5F3k72zs6SUwyzDGG3ytxhuFQVregWM3Mxansm7 +ht/aj0M3ydyimFo84Yh/Rpt0cqRZA59WPhuiBRzfU1M7gV/SnyRG6o0bH5IoceeFw ZJOAojA5PmIECZMYbeMYXK5OIlaKQeVjU4kq6D/pvA89TNd0zFKZwgP4jKT+JaN0kU qM/FtnjswkoWbARZBmCiotULJEIeVyaugwBAWEQo0+FpSQi3uPgamSBPVDIGDA1wrt 0egIIyTkEeMOWpfxjwav2jQdH/G0q3Gaj0UkKGb8kdcUuzLwZ+W67XUWQdBnGeW8TG Jfxxrpz5yu1qA== Received: by mail-lf1-f49.google.com with SMTP id 2adb3069b0e04-518a56cdbcfso1917684e87.2 for ; Thu, 18 Apr 2024 10:52:16 -0700 (PDT) X-Forwarded-Encrypted: i=1; AJvYcCUTHbDHXWaRyiSx9vq5ZOYZSjVh28576woONxSNUs5gU5jbTfvKoIfKGkKV57lh3lr4rzQPgPC8gi13xbtmc9q2MxtT9lumlTtbM1S2 X-Gm-Message-State: AOJu0Yypm5IJPQAyBfPz87f1U4JwvUVrwT7jd3eLEK5Im4kJUjwUJFy9 DGkxFDvLm0s9slVaFRrSdMUu3bkiMjvxXpN6st5VPIS3Ycqr2joISX2SJqLUbKLdQecmYIhAe9n TU+3f6/psVMLyMDaRc5tGjwpahRg= X-Received: by 2002:a19:9148:0:b0:519:a55:7ee7 with SMTP id y8-20020a199148000000b005190a557ee7mr2561185lfj.26.1713462734773; Thu, 18 Apr 2024 10:52:14 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240417-x86-fix-kexec-with-llvm-18-v1-0-5383121e8fb7@kernel.org> <46343CD5-24D6-46BF-92A7-0B0FA0E6937D@alien8.de> In-Reply-To: From: Ard Biesheuvel Date: Thu, 18 Apr 2024 19:52:03 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 0/2] x86/purgatory: Avoid kexec runtime warning with LLVM 18 To: Nick Desaulniers Cc: Borislav Petkov , Arthur Eubanks , Nathan Chancellor , tglx@linutronix.de, mingo@redhat.com, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, morbo@google.com, justinstitt@google.com, song@kernel.org, ribalda@chromium.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, patches@lists.linux.dev, ns <0n-s@users.noreply.github.com>, Fangrui Song Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, 18 Apr 2024 at 17:59, Ard Biesheuvel wrote: > > On Thu, 18 Apr 2024 at 17:44, Nick Desaulniers = wrote: > > > > On Thu, Apr 18, 2024 at 4:15=E2=80=AFAM Borislav Petkov = wrote: > > > How much of this silliness should we expect now for other parts of th= e kernel? > > > > Looks like ARCH=3Dpowerpc sets -mcmodel=3Dlarge for modules and ARCH=3D= um > > does for the whole kernel. So that LLVM change may have implications > > for those 2 other architectures. Not sure we've had any bug reports > > or breakage in CI yet, like we have for x86+kexec. > > > > > Can we turn this off? > > > > Maybe we need to revisit > > commit e16c2983fba0 ("x86/purgatory: Change compiler flags from > > -mcmodel=3Dkernel to -mcmodel=3Dlarge to fix kexec relocation errors") > > > > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/comm= it/?id=3De16c2983fba0fa6763e43ad10916be35e3d8dc05 > > > > at least the -mcmodel=3Dkernel addition (since that patch added a few > > additional compiler flags that still LGTM). > > > ... > > > + Fangrui, Ard, who might know of alternative solutions to > > -mcmodel=3Dlarge for e16c2983fba0. > > > > I think it would be better to use -mcmodel=3Dsmall -fpic. As Nick > explains, the large code model is really more suitable for executables > that span a large memory range. The issue with the purgatory seems to > be that it can be placed anywhere in memory, not that it is very big. > > -mcmodel=3Dsmall -fpic is what user space typically uses, so it is much > less likely to create problems. > > Note that I have been looking into whether we can build the entire > kernel with -fpic (for various reasons). There are some issues to > resolve there, mostly related to per-CPU variables and the per-CPU > stack protector, but beyond that, things work happily and the number > of boot time relocations drops dramatically, due to the use of > RIP-relative references. So for the purgatory, I wouldn't expect too > many surprises. > Replacing -mcmodel=3Dlarge in PURGATORY_CFLAGS with --mcmodel=3Dsmall -fpic -fvisibility=3Dhidden seems to do the trick for me.