Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp2285320rwl; Thu, 30 Mar 2023 08:20:11 -0700 (PDT) X-Google-Smtp-Source: AKy350b1EWqS9rN1zGkVP2vN0uGcRqQhdG2Vv9EGfGtEdYOE2EeH0c5CklbWVMnA4iwI9SVGCsiT X-Received: by 2002:a05:6402:268e:b0:502:1f7b:f069 with SMTP id w14-20020a056402268e00b005021f7bf069mr2823399edd.2.1680189611192; Thu, 30 Mar 2023 08:20:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680189611; cv=none; d=google.com; s=arc-20160816; b=WaLpxTdrMC253rxwAcGmTRoTaBwOzRoRrvqZ4N9OgMU8eEKkXwS+FGpc6VTX3ncmsK Y508zIcYdwJA72/Z6uGbSoK0XohI4HpUw7DBY1kF5HFEOG5pyFDhwVq3jhtBbUJzHaCu zRv2zwlp5t0TZyTZF0Y8Dy2zngRPevN4AtfuQf1T25YmNmAfNqP+NEDIA6u696XCAHV2 iuGJ8NNhdj54PEw/Xsm63M45DCgu9nkqLL//AH+aWR99GZfFoX9aaC7UwLP0pMdlJplr z8CHTVhNTmu/zWzShL0Dh0XeF0gNbpWvBWnv7a/SbpBbIyU0c4RwYLRD8krpcODKbCxj tZcw== 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 :references:in-reply-to:message-id:subject:cc:to:from:date; bh=coPOdrJin9JM6lsfnlmj2GZa9xnUx7bMwRv+eKKdSqg=; b=eh4NZhUJoJ0ruzaGOSifjjZyrqwcr1mNMT7SBOUfIvsQISQZRPVvpILLMxEi9jz05b oAdd89Mq77EHZBU40ISh+9I6vJCHVinsMMB7uMI/BRcafWNNe05NFK6OxnOdySJYQoyi RR9mUcQfWcyOtqLzz2Xtw3TzwH2/lGUIFCi7qcqoN8aN393eSD8qyfRlKoQ0/Y5KWa1k GJorxGI68/uW4naRUV/wIPJL5A0nl5NVLQ/pByZagq0Hyunwqm8hiULLDIVx/+r/CAPQ S3vGvJ2V+5z6BotH0gCIuYF5NJ0ZHCL9bWTjwJkTH7oeH3hfigzI+5mZOLBu5YUxAlu2 ycBA== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w12-20020a50fa8c000000b0050245e7f729si12906edr.615.2023.03.30.08.19.12; Thu, 30 Mar 2023 08:20:11 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232824AbjC3PRQ (ORCPT + 99 others); Thu, 30 Mar 2023 11:17:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232757AbjC3PRP (ORCPT ); Thu, 30 Mar 2023 11:17:15 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 15920CA33 for ; Thu, 30 Mar 2023 08:15:59 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E5AB8620D0 for ; Thu, 30 Mar 2023 15:15:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 12418C433EF; Thu, 30 Mar 2023 15:15:24 +0000 (UTC) Date: Thu, 30 Mar 2023 11:15:23 -0400 From: Steven Rostedt To: Ricardo Ribalda Cc: Eric Biederman , Baoquan He , Philipp Rudo , kexec@lists.infradead.org, linux-kernel@vger.kernel.org, Ross Zwisler , Simon Horman , "x86@kernel.org" , Borislav Petkov Subject: Re: [PATCH v5 2/2] x86/purgatory: Add linker script Message-ID: <20230330111523.4b98c8ce@gandalf.local.home> In-Reply-To: <20230321-kexec_clang16-v5-2-5563bf7c4173@chromium.org> References: <20230321-kexec_clang16-v5-0-5563bf7c4173@chromium.org> <20230321-kexec_clang16-v5-2-5563bf7c4173@chromium.org> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.0 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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: X-Mailing-List: linux-kernel@vger.kernel.org Hmm, this patch may need some more eyes. At least from the x86 maintainers. -- Steve On Thu, 30 Mar 2023 11:44:48 +0200 Ricardo Ribalda wrote: > Make sure that the .text section is not divided in multiple overlapping > sections. This is not supported by kexec_file. > > Signed-off-by: Ricardo Ribalda > --- > arch/x86/purgatory/.gitignore | 2 ++ > arch/x86/purgatory/Makefile | 20 +++++++++---- > arch/x86/purgatory/kexec-purgatory.S | 2 +- > arch/x86/purgatory/purgatory.lds.S | 57 ++++++++++++++++++++++++++++++++++++ > 4 files changed, 74 insertions(+), 7 deletions(-) > > diff --git a/arch/x86/purgatory/.gitignore b/arch/x86/purgatory/.gitignore > index d2be1500671d..1fe71fe5945d 100644 > --- a/arch/x86/purgatory/.gitignore > +++ b/arch/x86/purgatory/.gitignore > @@ -1 +1,3 @@ > purgatory.chk > +purgatory.lds > +purgatory > diff --git a/arch/x86/purgatory/Makefile b/arch/x86/purgatory/Makefile > index 17f09dc26381..4dc96d409bec 100644 > --- a/arch/x86/purgatory/Makefile > +++ b/arch/x86/purgatory/Makefile > @@ -16,10 +16,11 @@ CFLAGS_sha256.o := -D__DISABLE_EXPORTS > > # 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 > -LDFLAGS_purgatory.ro := -r $(PURGATORY_LDFLAGS) > -LDFLAGS_purgatory.chk := $(PURGATORY_LDFLAGS) > -targets += purgatory.ro purgatory.chk > +PURGATORY_LDFLAGS := -nostdlib -z nodefaultlib > +LDFLAGS_purgatory := -r $(PURGATORY_LDFLAGS) -T > +LDFLAGS_purgatory.chk := -e purgatory_start $(PURGATORY_LDFLAGS) > + > +targets += purgatory.lds purgatory.ro purgatory.chk > > # Sanitizer, etc. runtimes are unavailable and cannot be linked here. > GCOV_PROFILE := n > @@ -72,10 +73,17 @@ CFLAGS_string.o += $(PURGATORY_CFLAGS) > AFLAGS_REMOVE_setup-x86_$(BITS).o += -Wa,-gdwarf-2 > AFLAGS_REMOVE_entry64.o += -Wa,-gdwarf-2 > > -$(obj)/purgatory.ro: $(PURGATORY_OBJS) FORCE > +OBJCOPYFLAGS_purgatory.ro := -O elf64-x86-64 > +OBJCOPYFLAGS_purgatory.ro += --remove-section='*debug*' > +OBJCOPYFLAGS_purgatory.ro += --remove-section='.comment' > +OBJCOPYFLAGS_purgatory.ro += --remove-section='.note.*' > +$(obj)/purgatory.ro: $(obj)/purgatory FORCE > + $(call if_changed,objcopy) > + > +$(obj)/purgatory.chk: $(obj)/purgatory FORCE > $(call if_changed,ld) > > -$(obj)/purgatory.chk: $(obj)/purgatory.ro FORCE > +$(obj)/purgatory: $(obj)/purgatory.lds $(PURGATORY_OBJS) FORCE > $(call if_changed,ld) > > $(obj)/kexec-purgatory.o: $(obj)/purgatory.ro $(obj)/purgatory.chk > diff --git a/arch/x86/purgatory/kexec-purgatory.S b/arch/x86/purgatory/kexec-purgatory.S > index 8530fe93b718..54b0d0b4dc42 100644 > --- a/arch/x86/purgatory/kexec-purgatory.S > +++ b/arch/x86/purgatory/kexec-purgatory.S > @@ -5,7 +5,7 @@ > .align 8 > kexec_purgatory: > .globl kexec_purgatory > - .incbin "arch/x86/purgatory/purgatory.ro" > + .incbin "arch/x86/purgatory/purgatory" > .Lkexec_purgatory_end: > > .align 8 > diff --git a/arch/x86/purgatory/purgatory.lds.S b/arch/x86/purgatory/purgatory.lds.S > new file mode 100644 > index 000000000000..610da88aafa0 > --- /dev/null > +++ b/arch/x86/purgatory/purgatory.lds.S > @@ -0,0 +1,57 @@ > +/* SPDX-License-Identifier: GPL-2.0 */ > +#include > + > +OUTPUT_FORMAT(CONFIG_OUTPUT_FORMAT) > + > +#undef i386 > + > +#include > +#include > + > +ENTRY(purgatory_start) > + > +SECTIONS > +{ > + . = 0; > + .head.text : { > + _head = . ; > + HEAD_TEXT > + _ehead = . ; > + } > + .rodata : { > + _rodata = . ; > + *(.rodata) /* read-only data */ > + *(.rodata.*) > + _erodata = . ; > + } > + .text : { > + _text = .; /* Text */ > + *(.text) > + *(.text.*) > + *(.noinstr.text) > + _etext = . ; > + } > + .data : { > + _data = . ; > + *(.data) > + *(.data.*) > + *(.bss.efistub) > + _edata = . ; > + } > + . = ALIGN(L1_CACHE_BYTES); > + .bss : { > + _bss = . ; > + *(.bss) > + *(.bss.*) > + *(COMMON) > + . = ALIGN(8); /* For convenience during zeroing */ > + _ebss = .; > + } > + > + /* Sections to be discarded */ > + /DISCARD/ : { > + *(.eh_frame) > + *(*__ksymtab*) > + *(___kcrctab*) > + } > +} >