From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E30C6C77B78 for ; Wed, 26 Apr 2023 15:59:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=cSuqNHNTKqTsAVkdV7qMLCG3YPQcrofoz7VbvzSJBb0=; b=ZbULJHjzNIcS1b V70z3DZTGmDxrSxcuI8LnqDD5J2HyxQshXQxgMSVuxgozprQddJUCyrw/C2kL7FZVG/hdMHIGYs0D C9jtG458KRABFIWIR2WiTfBGd0LIL3SqQvTLDHDoQcm7n85F1ZQnHPNT9yv6xEKMVZeMkxCmUJEuT wuoZkXO4f8Xg1J3CWRrEqCCaM5ziGTJ13ZS8Z9FeVEDva95xykLrysYu672B/DDnUOt0js0RWyVPn b0VaF7TkRZNQGR4mwwOsvwvDLq+DL/DbXEW62cjH5JM84x0/KqsianZhwcOhbic2gKzpCF+K9UCbl HHHH2VRzafUu2A0HSDaw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1prhXn-004LJm-0w; Wed, 26 Apr 2023 15:58:59 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1prhXk-004LJ8-1J for linux-arm-kernel@lists.infradead.org; Wed, 26 Apr 2023 15:58:58 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E15141FB; Wed, 26 Apr 2023 08:59:34 -0700 (PDT) Received: from FVFF77S0Q05N (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 189353F587; Wed, 26 Apr 2023 08:58:49 -0700 (PDT) Date: Wed, 26 Apr 2023 16:58:37 +0100 From: Mark Rutland To: Ard Biesheuvel Cc: linux-arm-kernel@lists.infradead.org, linux-efi@vger.kernel.org, catalin.marinas@arm.com, will@kernel.org Subject: Re: [PATCH 1/2] efi/zboot: arm64: Inject kernel code size symbol into the zboot payload Message-ID: References: <20230426141103.2464423-1-ardb@kernel.org> <20230426141103.2464423-2-ardb@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20230426141103.2464423-2-ardb@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230426_085856_535242_68D6DDE0 X-CRM114-Status: GOOD ( 21.33 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Apr 26, 2023 at 04:11:02PM +0200, Ard Biesheuvel wrote: > The EFI zboot code is not built as part of the kernel proper, like the > ordinary EFI stub, but still needs access to symbols that are defined > only internally in the kernel, and are left unexposed deliberately to > avoid creating ABI inadvertently that we're stuck with later. > > So capture the kernel code size of the kernel image, and inject it as an > ELF symbol into the object that contains the compressed payload, where > it will be accessible to zboot code that needs it. > > Signed-off-by: Ard Biesheuvel Acked-by: Mark Rutland Mark. > --- > arch/arm64/boot/Makefile | 3 +++ > arch/arm64/kernel/image-vars.h | 4 ++++ > drivers/firmware/efi/libstub/Makefile.zboot | 2 +- > drivers/firmware/efi/libstub/zboot.lds | 7 +++++++ > 4 files changed, 15 insertions(+), 1 deletion(-) > > diff --git a/arch/arm64/boot/Makefile b/arch/arm64/boot/Makefile > index ae645fda90bca574..1761f5972443fc50 100644 > --- a/arch/arm64/boot/Makefile > +++ b/arch/arm64/boot/Makefile > @@ -44,4 +44,7 @@ EFI_ZBOOT_BFD_TARGET := elf64-littleaarch64 > EFI_ZBOOT_MACH_TYPE := ARM64 > EFI_ZBOOT_FORWARD_CFI := $(CONFIG_ARM64_BTI_KERNEL) > > +EFI_ZBOOT_OBJCOPY_FLAGS = --add-symbol zboot_code_size=0x$(shell \ > + $(NM) vmlinux|grep _kernel_codesize|cut -d' ' -f1) > + > include $(srctree)/drivers/firmware/efi/libstub/Makefile.zboot > diff --git a/arch/arm64/kernel/image-vars.h b/arch/arm64/kernel/image-vars.h > index 8309197c0ebd4a8e..35f3c79595137354 100644 > --- a/arch/arm64/kernel/image-vars.h > +++ b/arch/arm64/kernel/image-vars.h > @@ -108,4 +108,8 @@ KVM_NVHE_ALIAS(kvm_protected_mode_initialized); > > #endif /* CONFIG_KVM */ > > +#ifdef CONFIG_EFI_ZBOOT > +_kernel_codesize = ABSOLUTE(__inittext_end - _text); > +#endif > + > #endif /* __ARM64_KERNEL_IMAGE_VARS_H */ > diff --git a/drivers/firmware/efi/libstub/Makefile.zboot b/drivers/firmware/efi/libstub/Makefile.zboot > index 0a9dcc2b13736519..1b101d9076fd49e5 100644 > --- a/drivers/firmware/efi/libstub/Makefile.zboot > +++ b/drivers/firmware/efi/libstub/Makefile.zboot > @@ -40,7 +40,7 @@ quiet_cmd_compwithsize = $(quiet_cmd_$(zboot-method-y)) > $(obj)/vmlinuz: $(obj)/vmlinux.bin FORCE > $(call if_changed,compwithsize) > > -OBJCOPYFLAGS_vmlinuz.o := -I binary -O $(EFI_ZBOOT_BFD_TARGET) \ > +OBJCOPYFLAGS_vmlinuz.o := -I binary -O $(EFI_ZBOOT_BFD_TARGET) $(EFI_ZBOOT_OBJCOPY_FLAGS) \ > --rename-section .data=.gzdata,load,alloc,readonly,contents > $(obj)/vmlinuz.o: $(obj)/vmlinuz FORCE > $(call if_changed,objcopy) > diff --git a/drivers/firmware/efi/libstub/zboot.lds b/drivers/firmware/efi/libstub/zboot.lds > index 93d33f68333b2b68..ac8c0ef851581f5d 100644 > --- a/drivers/firmware/efi/libstub/zboot.lds > +++ b/drivers/firmware/efi/libstub/zboot.lds > @@ -2,6 +2,8 @@ > > ENTRY(__efistub_efi_zboot_header); > > +PROVIDE(zboot_code_size = ABSOLUTE(0)); > + > SECTIONS > { > .head : ALIGN(4096) { > @@ -17,6 +19,11 @@ SECTIONS > *(.gzdata) > __efistub__gzdata_end = .; > *(.rodata* .init.rodata* .srodata*) > + > + . = ALIGN(4); > + __efistub_code_size = .; > + LONG(zboot_code_size); > + > _etext = ALIGN(4096); > . = _etext; > } > -- > 2.39.2 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel