Message ID | 20230908231244.1092614-1-song@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ab0a:0:b0:3f2:4152:657d with SMTP id m10csp1211431vqo; Sat, 9 Sep 2023 09:25:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHw6tTgczmRWxNvKeBgQNi+tdjynNRBw9L2oNDc1n8U40ige5+C/Ctv1CbfmKr2N+yNOQ2y X-Received: by 2002:a17:906:5357:b0:9a9:e5a7:46ce with SMTP id j23-20020a170906535700b009a9e5a746cemr4417412ejo.24.1694276739815; Sat, 09 Sep 2023 09:25:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694276739; cv=none; d=google.com; s=arc-20160816; b=TpQrhDaR3TGoXmog6xJ49TOad4KbTkx6A6yzbkRJrlcmCZk79f/NiZm6ViXMzN+Xz9 Hu930neY04y2cBgC9E7ORFxePlf3YQeuOqFd2GZ66ZOxLoW42/dg8kLGfyeBMsJfFVvB ufr5mbhuzBJaf6RodI0qYOz54LDkNi2pJInqU/rBbxrqBLEEzf5LTiL9msUmqfyJ9k7z KyrJr1Q2Agm8MlENCPasH4B2oOinWY0K2QCAASDKAEBN9jbjetIgN/rihwCk1IquU7nE UfABV87i3Sz3n/mnG4nsYCg2WwNQgl4eQXJ9WjlE+BKggO07ekwoAL6gUby4IwyN8KZr K7qQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=eahG9WiEmruVjHggYhnAIZb02VXruRVutaG5FHWUenY=; fh=ceDvjZsqNvYnJjBzcj/Tkqp5r9poLxNgb08mgS2xniM=; b=kQvtb5MczPoXjgNqa5PVGCd14q/Ghy2ue0rgUmJYx4I35dkMbtSCXOcMfD4zyleX9P xurMqINcXvUswsO/+kaFfPWaxcPRpcD8v92ycNCoUpHklzieN3+TLB+jy7vNbg1zDoKW tV9mnBy9t7LlpQMHYTSEM10HLkV1fe3BVPXIsf5rygB9VUWTSrld7x0K8DCS1hX7ji9O RcoYY+OUj6nT4mL9ZW+woA+zu2G3Zxdg4YkgfTbwXqI/VOOLIsx3lZMQ9FSXMccWvMFB lDt8oC6v5LOHmz72SDiIELpTvArrowWz/ZfbPiT0/ItzfWcBlU/DsvqVqMTJHgbTDTKU rz9A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n11-20020a1709065e0b00b0098d0a88d4fasi3370125eju.808.2023.09.09.09.25.30; Sat, 09 Sep 2023 09:25:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S1344791AbjIHXNL convert rfc822-to-8bit (ORCPT <rfc822;gah0developer@gmail.com> + 36 others); Fri, 8 Sep 2023 19:13:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344784AbjIHXNJ (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 8 Sep 2023 19:13:09 -0400 Received: from mx0b-00082601.pphosted.com (mx0b-00082601.pphosted.com [67.231.153.30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BDC0118E for <linux-kernel@vger.kernel.org>; Fri, 8 Sep 2023 16:13:05 -0700 (PDT) Received: from pps.filterd (m0109331.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 388HqD5G030687 for <linux-kernel@vger.kernel.org>; Fri, 8 Sep 2023 16:13:05 -0700 Received: from mail.thefacebook.com ([163.114.132.120]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 3t06jvvkdt-5 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for <linux-kernel@vger.kernel.org>; Fri, 08 Sep 2023 16:13:04 -0700 Received: from twshared52565.14.frc2.facebook.com (2620:10d:c085:208::f) by mail.thefacebook.com (2620:10d:c085:21d::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Fri, 8 Sep 2023 16:13:01 -0700 Received: by devbig932.frc1.facebook.com (Postfix, from userid 4523) id 01CBF24087ED5; Fri, 8 Sep 2023 16:12:48 -0700 (PDT) From: Song Liu <song@kernel.org> To: <linux-kernel@vger.kernel.org> CC: <ndesaulniers@google.com>, Song Liu <song@kernel.org>, Ricardo Ribalda <ribalda@chromium.org>, Sami Tolvanen <samitolvanen@google.com>, <kexec@lists.infradead.org>, <x86@kernel.org>, <llvm@lists.linux.dev> Subject: [PATCH v2] x86/purgatory: Remove LTO flags Date: Fri, 8 Sep 2023 16:12:44 -0700 Message-ID: <20230908231244.1092614-1-song@kernel.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8BIT X-FB-Internal: Safe Content-Type: text/plain X-Proofpoint-GUID: jg41T-4l24zQ1yAN3q4KewC_oaCjHY6p X-Proofpoint-ORIG-GUID: jg41T-4l24zQ1yAN3q4KewC_oaCjHY6p X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.601,FMLib:17.11.176.26 definitions=2023-09-08_18,2023-09-05_01,2023-05-22_02 X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776519174461770110 X-GMAIL-MSGID: 1776577926745698684 |
Series |
[v2] x86/purgatory: Remove LTO flags
|
|
Commit Message
Song Liu
Sept. 8, 2023, 11:12 p.m. UTC
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.
Fixes: 8652d44f466a ("kexec: support purgatories with .text.hot sections")
Cc: Ricardo Ribalda <ribalda@chromium.org>
Cc: Sami Tolvanen <samitolvanen@google.com>
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 <song@kernel.org>
---
AFAICT, x86 is the only arch that supports LTO and purgatory.
Changes in v2:
1. Use CC_FLAGS_LTO instead of hardcode -flto. (Nick Desaulniers)
---
arch/x86/purgatory/Makefile | 4 ++++
1 file changed, 4 insertions(+)
Comments
Hi folks, On Fri, Sep 8, 2023 at 4:13 PM Song Liu <song@kernel.org> wrote: > > 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. > > Fixes: 8652d44f466a ("kexec: support purgatories with .text.hot sections") > Cc: Ricardo Ribalda <ribalda@chromium.org> > Cc: Sami Tolvanen <samitolvanen@google.com> > 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 <song@kernel.org> What would be the next step for this work? We hope to back port it to our production kernel soon. Thanks, Song > > --- > AFAICT, x86 is the only arch that supports LTO and purgatory. > > 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 := -D__DISABLE_EXPORTS -D__NO_FORTIFY > # optimization flags. > KBUILD_CFLAGS := $(filter-out -fprofile-sample-use=% -fprofile-use=%,$(KBUILD_CFLAGS)) > > +# When LTO is enabled, llvm emits many text sections, which is not supported > +# by kexec. Remove -flto=* flags. > +KBUILD_CFLAGS := $(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 symbols. > PURGATORY_LDFLAGS := -e purgatory_start -z nodefaultlib > -- > 2.34.1 >
On Thu, Sep 14, 2023 at 9:31 AM Song Liu <song@kernel.org> wrote: > > What would be the next step for this work? We hope to back port it > to our production kernel soon. Please send a v3 with the fixes tag updated. I wouldn't mind if you added a comment to the commit message to the effect of: We could also add the use of an explicit linker script to rejoin .text.* sections back into .text. Simply disable the production of more .text.* sections for now; -flto* implies -ffunction-sections.
On Thu, Sep 14, 2023 at 9:34 AM Nick Desaulniers <ndesaulniers@google.com> wrote: > > On Thu, Sep 14, 2023 at 9:31 AM Song Liu <song@kernel.org> wrote: > > > > What would be the next step for this work? We hope to back port it > > to our production kernel soon. > > Please send a v3 with the fixes tag updated. I wouldn't mind if you > added a comment to the commit message to the effect of: > > We could also add the use of an explicit linker script to rejoin > .text.* sections back into .text. Simply disable the production of > more .text.* sections for now; -flto* implies -ffunction-sections. Got it. I just sent v3 with these changes. Thanks, Song
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 := -D__DISABLE_EXPORTS -D__NO_FORTIFY # optimization flags. KBUILD_CFLAGS := $(filter-out -fprofile-sample-use=% -fprofile-use=%,$(KBUILD_CFLAGS)) +# When LTO is enabled, llvm emits many text sections, which is not supported +# by kexec. Remove -flto=* flags. +KBUILD_CFLAGS := $(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 symbols. PURGATORY_LDFLAGS := -e purgatory_start -z nodefaultlib