Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4178895rdb; Thu, 14 Sep 2023 14:25:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE8YLxxrGLaUtXUBv0tjGmEIUXilGwhE5D4XxpzBZEEpfOWPeerD2CIlS9VNE23RItYnyfr X-Received: by 2002:a05:6a21:621:b0:153:beda:863 with SMTP id ll33-20020a056a21062100b00153beda0863mr5646240pzb.45.1694726739487; Thu, 14 Sep 2023 14:25:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694726739; cv=none; d=google.com; s=arc-20160816; b=ThHUENpLvXTSEaH4yoMU5B6h2/BH4844XAmslLmk/mfb6G85MXb70zrezZsP0tftpl /QLQSIcp2uqUDiVyqkLpfpUwrlfBdq65rCIkivPlqB/zEUQ/sR1JUd+2/CQlYUaVpTlg Uok2hvCGLfHXxqgVnDHLbqxc8dM3d3r+wC1vsCyis31RaBTY4m1yg+UwncgB+O/sFJsr 46C6ydQkJwOGmAX4RBGc6bciLM4A/mSTgXFM3SybTweRZbRlQ0g3HDS/uMTEpzGYYmov Wj3OwaQAd5DY3ylblv9+XmsVxOtLPFogGNq2ZZVUOiz+B55RgPXr4u2K/dLSI2maQNRS WUjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=A8eQORumJtaroUI8JT9bu5D1IY7lPGvpUmpxNHPhsvg=; fh=HfagzHLEu21tsGYC/GKnGs70pD365yvShmbI7HLN6sI=; b=Y31oDzwSB/4g7ALWFrjBLULbHdo+jDQaLs6BUEf9kD3KDgZDYjK0jvm9Pk/aSpXRNp ecw3RmMfiwHLRkXGyDDjo1qumWCdiYQC62BiUZH+0Y9d2rO4lGEOEnZLXeChZ5/OnwN3 9GdwdX0rqXIQJDGW90kwSnVBlZuo3pI37Gt9u9vzgoIurndp/4gAxs7g0dvWFWauWMla AOlN0u63d0tP1SxJAoo4oeQwj3mFqOjqVELUXfsHXKfxZq7ZYa4pw+Bw6SzsMNf80qAN F1YszgFnOdrgctZhgu/QwfD0/D0qnbpCaU4TOzPYINDXDMaeolMVaZkm4mvTZmJZ4Zg+ Y5yQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=jE6UjXJ7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id x64-20020a636343000000b0057416a797dasi2167595pgb.734.2023.09.14.14.25.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 14:25:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=jE6UjXJ7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 0DEBC837D4B8; Thu, 14 Sep 2023 10:23:04 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239112AbjINRXD (ORCPT + 99 others); Thu, 14 Sep 2023 13:23:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239289AbjINRWo (ORCPT ); Thu, 14 Sep 2023 13:22:44 -0400 Received: from mail-qv1-xf36.google.com (mail-qv1-xf36.google.com [IPv6:2607:f8b0:4864:20::f36]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78CD12715 for ; Thu, 14 Sep 2023 10:22:27 -0700 (PDT) Received: by mail-qv1-xf36.google.com with SMTP id 6a1803df08f44-649c6ea6e72so7029566d6.2 for ; Thu, 14 Sep 2023 10:22:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1694712146; x=1695316946; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=A8eQORumJtaroUI8JT9bu5D1IY7lPGvpUmpxNHPhsvg=; b=jE6UjXJ7BkxVirgNwrjHB7bsXjKXr2s3aEpRyLtBIqG/VsMWL7lrJetRWxk2CGiH51 y68z9mb9sTRUuVyf8pX7yULzgFKeGOVCGGyXoS35TuCfJQwo2zatN0cICH7wVqbctbWh bySNekPa/ZnfWkQUQ7x9zncSSoiNCA1ixMDo57DXY2sWRFR0XYd8jbuaSfjSjkjlFLYJ 2FP6rrwAyXW/khvvlEhgZ2hETZVjp0T+lPF7cDCsF842iuE7CTMYmF058jD3ycRAMawF RT8DH0rkmquiSEnkS/q7MD2BjzSWYCoF5Nquqf2zuVVWN9WcUgPKvsKb60UfsWOONgI2 zi2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694712146; x=1695316946; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=A8eQORumJtaroUI8JT9bu5D1IY7lPGvpUmpxNHPhsvg=; b=HFMxLngHkwnrKNKhNJCHTG5M9d+3gAIMov7IBRAcreyGZZ7ByeY3zSWt3naGSNYAla Hu2sZCctQeDaRrwpNBKio+I5LYrv0swjHtzSnY2dda4+owUTa1rbUdyfuH1nrYh5NS5U loHwJlX5J6Dd4fXMTOIdl6xlfKau8RzHtvCMUNw4Dl/G2+Dq8GUu2ZsWrdVKvNAS+qEr 6iYSBnwscGPxqJ50gMB9Mh2e6dzhjT2dr9wtecu7Z3Y/+r8UYBQCFQavk18cma9LwnJ/ zxsI3q7E0quiTSwgZP7etyODv7xJDUtp6vv7HQFsH2cWpuHrVwWoj6IDyM5KGiKHTwTA 127Q== X-Gm-Message-State: AOJu0YyQ/ffQW/oEdrBbDd7TOIjIsfIE3fCkzorKh9B9CMXrJOrAJONZ ypZbj0Gnvo4zVNIHyYvZC5wUKVWTlJsb1YAOKjC4+Q== X-Received: by 2002:ad4:5851:0:b0:63d:7214:638e with SMTP id de17-20020ad45851000000b0063d7214638emr7042473qvb.56.1694712146470; Thu, 14 Sep 2023 10:22:26 -0700 (PDT) MIME-Version: 1.0 References: <20230914170138.995606-1-song@kernel.org> In-Reply-To: <20230914170138.995606-1-song@kernel.org> From: Nick Desaulniers Date: Thu, 14 Sep 2023 10:22:12 -0700 Message-ID: Subject: Re: [PATCH v3] x86/purgatory: Remove LTO flags To: Song Liu Cc: linux-kernel@vger.kernel.org, Ricardo Ribalda , Sami Tolvanen , kexec@lists.infradead.org, x86@kernel.org, llvm@lists.linux.dev Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Thu, 14 Sep 2023 10:23:04 -0700 (PDT) X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email On Thu, Sep 14, 2023 at 10:02=E2=80=AFAM Song Liu wrote: > > -flto* implies -ffunction-sections. With LTO enabled, ld.lld generates > multiple .text sections for purgatory.ro: > > $ readelf -S purgatory.ro | grep " .text" > [ 1] .text PROGBITS 0000000000000000 00000040 > [ 7] .text.purgatory PROGBITS 0000000000000000 000020e0 > [ 9] .text.warn PROGBITS 0000000000000000 000021c0 > [13] .text.sha256_upda PROGBITS 0000000000000000 000022f0 > [15] .text.sha224_upda PROGBITS 0000000000000000 00002be0 > [17] .text.sha256_fina PROGBITS 0000000000000000 00002bf0 > [19] .text.sha224_fina PROGBITS 0000000000000000 00002cc0 > > This cause WARNING from kexec_purgatory_setup_sechdrs(): > > WARNING: CPU: 26 PID: 110894 at kernel/kexec_file.c:919 > kexec_load_purgatory+0x37f/0x390 > > Fix this by disabling LTO for purgatory. > > We could also fix this with an explicit linker script to rejoin .text.* > sections back into .text. However, given the benefit of LTOing pugatory s/pugatory/purgatory/ (maybe the x86 maintainers can apply that fixup if/when picked up) > is small, simply disable the production of more .text.* sections for now. > > Fixes: b33fff07e3e3 ("x86, build: allow LTO to be selected") > Cc: Ricardo Ribalda > Cc: Sami Tolvanen > Cc: kexec@lists.infradead.org > Cc: linux-kernel@vger.kernel.org > Cc: x86@kernel.org > Cc: llvm@lists.linux.dev > Signed-off-by: Song Liu Thanks for the patch! Reviewed-by: Nick Desaulniers > > --- > AFAICT, x86 is the only arch that supports LTO and purgatory. > > Changes in v3: > 1. Fix "Fixes" tag. (Nick Desaulniers) > 2. Add description of an alternative fix, with linker script. > (Nick Desaulniers) > > Changes in v2: > 1. Use CC_FLAGS_LTO instead of hardcode -flto. (Nick Desaulniers) > --- > arch/x86/purgatory/Makefile | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/arch/x86/purgatory/Makefile b/arch/x86/purgatory/Makefile > index c2a29be35c01..08aa0f25f12a 100644 > --- a/arch/x86/purgatory/Makefile > +++ b/arch/x86/purgatory/Makefile > @@ -19,6 +19,10 @@ CFLAGS_sha256.o :=3D -D__DISABLE_EXPORTS -D__NO_FORTIF= Y > # optimization flags. > KBUILD_CFLAGS :=3D $(filter-out -fprofile-sample-use=3D% -fprofile-use= =3D%,$(KBUILD_CFLAGS)) > > +# When LTO is enabled, llvm emits many text sections, which is not suppo= rted > +# by kexec. Remove -flto=3D* flags. > +KBUILD_CFLAGS :=3D $(filter-out $(CC_FLAGS_LTO),$(KBUILD_CFLAGS)) > + > # When linking purgatory.ro with -r unresolved symbols are not checked, > # also link a purgatory.chk binary without -r to check for unresolved sy= mbols. > PURGATORY_LDFLAGS :=3D -e purgatory_start -z nodefaultlib > -- > 2.34.1 > --=20 Thanks, ~Nick Desaulniers