From patchwork Wed Sep 30 18:34:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lukasz Stelmach X-Patchwork-Id: 11810041 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 94CAD174A for ; Wed, 30 Sep 2020 18:41:22 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4F4C320708 for ; Wed, 30 Sep 2020 18:41:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="CVBOqjH7"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="qTnRm+3T" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4F4C320708 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=samsung.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:MIME-Version:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=dFenfKGoXbbt2rNTYuVWUBe2ZeKk5gLTO0yEaxA2o5U=; b=CVBOqjH7W1vFYLt8MAXfMv3/K zIt2m5PbTIV+s5cuBsKtdl1yEe6izDyDuXSXrXwcD5t3oqO0NYfr1CJzwYhjCteSdoFep4w9x4qWW ++k3OJWEHqDKaJEskqFWyrptrZeFFJLdoaoj1CI56m+mwi4qQKuF4uLnZH7+O9vFVV03G4AEHDgXA bEODrTZjSDScmd+wHgmkfFkxV6JNwvubvd0+qFyfAI2Bs+13XtxzhAEEmj0/d8b1FkwJXxlh7QpJ2 IZQ2RvP8bVzb7YW8Lk8GOSDIM/XIFs1y4EcBfwmqHtTa39BuPnJv2/LUBOGvRdi6PP+LUgkfMFpxv DXVglSCpQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kNh0w-0003zh-4z; Wed, 30 Sep 2020 18:39:42 +0000 Received: from mailout1.w1.samsung.com ([210.118.77.11]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kNh0g-0003sw-H2 for linux-arm-kernel@lists.infradead.org; Wed, 30 Sep 2020 18:39:30 +0000 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20200930183924euoutp01aec6ca9bcb2d9f2876f049b2e186d855~5o7qw5c4a2671026710euoutp01i for ; Wed, 30 Sep 2020 18:39:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20200930183924euoutp01aec6ca9bcb2d9f2876f049b2e186d855~5o7qw5c4a2671026710euoutp01i DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1601491164; bh=bc6vCXY5W/Zq9gSC9dpK4wsgx0OJXc0ePYpMVE+U1/Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qTnRm+3TyS7WtndLMcRND+QbbS+oU5el8VPrvldyX1h2KfxswGYxPcNUkrXWPCG/u evtXoEaMSsGrHIjobHCC8eR51rbcitIC8cdSnxXwIjaMDMyNESeJ8297V5pzhCVImD 1aSs6CG2Phy5o208eOdNuOGknC4OK/6WpVRszA8A= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20200930183924eucas1p104c81418b7b3257a0de7cd4c2bd9bc04~5o7qf-aOf1834618346eucas1p15; Wed, 30 Sep 2020 18:39:24 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 97.10.06318.CD0D47F5; Wed, 30 Sep 2020 19:39:24 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20200930183923eucas1p2241d3e1b8d4d05a2228448ff8fc4bb74~5o7qB8rJa0060600606eucas1p27; Wed, 30 Sep 2020 18:39:23 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20200930183923eusmtrp2a04d19e2723d7361276d8224333460af~5o7qBJVMw3109431094eusmtrp2B; Wed, 30 Sep 2020 18:39:23 +0000 (GMT) X-AuditID: cbfec7f5-371ff700000018ae-77-5f74d0dca353 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 62.F3.06017.BD0D47F5; Wed, 30 Sep 2020 19:39:23 +0100 (BST) Received: from localhost (unknown [106.120.51.46]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20200930183923eusmtip192527e4174f64558a64d624446d17b20~5o7pyTLOZ1501415014eusmtip1Y; Wed, 30 Sep 2020 18:39:23 +0000 (GMT) From: =?utf-8?q?=C5=81ukasz_Stelmach?= To: Russell King , Masahiro Yamada , Nick Desaulniers , Thomas Gleixner , Enrico Weigelt , Kees Cook , Ingo Molnar , Ben Dooks , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, AKASHI Takahiro , kexec@lists.infradead.org, Dave Young Subject: [PATCH v3 1/4] arm: add image header definitions Date: Wed, 30 Sep 2020 20:34:10 +0200 Message-Id: <20200930183413.17023-2-l.stelmach@samsung.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200930183413.17023-1-l.stelmach@samsung.com> MIME-Version: 1.0 Organization: Samsung R&D Institute Poland X-Brightmail-Tracker: H4sIAAAAAAAAA02SWUwTURSGczvT6UAsjAXlBIloRSMkgAaXMSwu8WFiDPGB+GBUqDJhbSGd FsUXyqIIItRiXQqRxqBgBdGCoOw2BBSkgkuBpASNxgWoEtFEFEHagcjbOff//vOfk1wSk0wI fckkhYpVKmSpUsIdb+yeeRFsH1DFbrn52Zt+cK1OSOvudQpozSUNTo9ktwjo5xfkdEvfTwE9 YqlGtPm9TUi/ai4naIu+DdG1XaMi+t3bYSF9d64X0VPaeQE92zGD0/VmPbaHYl7ZBjGmTDOI M39NnzHGaFYzZlMBwdhtrQTz1WoVMfWVWYx2ykEw39rfEExxgwkx0+a1h1YccY+IZ1OTMlhl aFSce6L98hCRbvQ77eg1ijQo26cQuZFAbYPXhklBIXInJVQ1gpaOdswpSKgfCKZrd/LCNIKO 2jm05BgdmMF5oQqBLXcE8c0nBM/uN+NOiqD2Qsmtp0Kn4E29xWBcX+WyYNRtBPPXJoVOyova BY7hAZcDpzbCyFivK0NMhYN2rATn8/whv6qJcNZuVAS87O8ieGYlPLv+wcV4UkFQkzPkqrEF PvdhGeYMA+oOCdbJgoXzyIVmPzhmIvmZXjDe0yDiaz+Yf1yxiGRBqW4Hby1C0Fj+a3GHcLBb fxNOBqMCoa45lH/eCzWVn0S81QOGHSv5DTxA13gV45/FcP6chKcD4F5J6+JAX7g4Xo20SGpY doth2f6G/1lGhJmQD6vm5AksF6ZgT4VwMjmnViSEnEyTm9HCF+yb6/n5CLXPnrAgikTSFWKt QhUrEcoyuEy5BQGJSb3F+/r7jkvE8bLMM6wyLVapTmU5C1pD4lIfcdjNL8ckVIJMxaawbDqr XFIFpJuvBh0u18e82Xll6vCBsYAhw8ctrYH+9iub8t1s6+NgQvfQ2t6ZUlyk6i7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flXvd835tK/f8HcZxp+Ispu+t3Wec U7pM+c+F5fOm23+Y8txh83mx1i/xj3kuphYFtMkrsRRnJBpqMRcVJwIATmGdbhADAAA= X-CMS-MailID: 20200930183923eucas1p2241d3e1b8d4d05a2228448ff8fc4bb74 X-Msg-Generator: CA X-RootMTR: 20200930183923eucas1p2241d3e1b8d4d05a2228448ff8fc4bb74 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200930183923eucas1p2241d3e1b8d4d05a2228448ff8fc4bb74 References: <20200601142754.26139-1-l.stelmach@samsung.com> <20200930183413.17023-1-l.stelmach@samsung.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200930_143926_929265_88388433 X-CRM114-Status: GOOD ( 20.72 ) X-Spam-Score: -5.7 (-----) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-5.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [210.118.77.11 listed in wl.mailspike.net] -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at https://www.dnswl.org/, high trust [210.118.77.11 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders -0.5 DKIMWL_WL_HIGH DKIMwl.org - High trust sender X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marek Szyprowski , =?utf-8?q?=C5=81ukasz_Stelm?= =?utf-8?q?ach?= , Bartlomiej Zolnierkiewicz Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org This structure will be used later by kexec_file loader. Signed-off-by: Łukasz Stelmach --- arch/arm/boot/compressed/head.S | 3 +- arch/arm/boot/compressed/vmlinux.lds.S | 13 ++----- arch/arm/include/asm/image.h | 50 ++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 11 deletions(-) create mode 100644 arch/arm/include/asm/image.h diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S index 2e04ec5b5446..3099002ad13a 100644 --- a/arch/arm/boot/compressed/head.S +++ b/arch/arm/boot/compressed/head.S @@ -7,6 +7,7 @@ */ #include #include +#include #include #include "efi-header.S" @@ -206,7 +207,7 @@ start: .word _magic_start @ absolute load/run zImage address .word _magic_end @ zImage end address .word 0x04030201 @ endianness flag - .word 0x45454545 @ another magic number to indicate + .word ARM_ZIMAGE_MAGIC2 @ another magic number to indicate .word _magic_table @ additional data table __EFI_HEADER diff --git a/arch/arm/boot/compressed/vmlinux.lds.S b/arch/arm/boot/compressed/vmlinux.lds.S index 1bcb68ac4b01..a6b151112ac5 100644 --- a/arch/arm/boot/compressed/vmlinux.lds.S +++ b/arch/arm/boot/compressed/vmlinux.lds.S @@ -4,14 +4,7 @@ */ #include -#ifdef CONFIG_CPU_ENDIAN_BE8 -#define ZIMAGE_MAGIC(x) ( (((x) >> 24) & 0x000000ff) | \ - (((x) >> 8) & 0x0000ff00) | \ - (((x) << 8) & 0x00ff0000) | \ - (((x) << 24) & 0xff000000) ) -#else -#define ZIMAGE_MAGIC(x) (x) -#endif +#include OUTPUT_ARCH(arm) ENTRY(_start) @@ -45,7 +38,7 @@ SECTIONS .table : ALIGN(4) { _table_start = .; LONG(ZIMAGE_MAGIC(6)) - LONG(ZIMAGE_MAGIC(0x5a534c4b)) + LONG(ARM_ZIMAGE_MAGIC3) LONG(ZIMAGE_MAGIC(__piggy_size_addr - _start)) LONG(ZIMAGE_MAGIC(_kernel_bss_size)) LONG(ZIMAGE_MAGIC(TEXT_OFFSET)) @@ -116,7 +109,7 @@ SECTIONS _edata_real = .; } - _magic_sig = ZIMAGE_MAGIC(0x016f2818); + _magic_sig = ARM_ZIMAGE_MAGIC1; _magic_start = ZIMAGE_MAGIC(_start); _magic_end = ZIMAGE_MAGIC(_edata); _magic_table = ZIMAGE_MAGIC(_table_start - _start); diff --git a/arch/arm/include/asm/image.h b/arch/arm/include/asm/image.h new file mode 100644 index 000000000000..8150b9490e86 --- /dev/null +++ b/arch/arm/include/asm/image.h @@ -0,0 +1,50 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#ifndef __ASM_IMAGE_H +#define __ASM_IMAGE_H + +#ifdef CONFIG_CPU_ENDIAN_BE8 +#define ZIMAGE_MAGIC(x) ((((x) >> 24) & 0x000000ff) | \ + (((x) >> 8) & 0x0000ff00) | \ + (((x) << 8) & 0x00ff0000) | \ + (((x) << 24) & 0xff000000)) +#else +#define ZIMAGE_MAGIC(x) (x) +#endif + +#define ARM_ZIMAGE_MAGIC1 ZIMAGE_MAGIC(0x016f2818) +#define ARM_ZIMAGE_MAGIC2 (0x45454545) +#define ARM_ZIMAGE_MAGIC3 ZIMAGE_MAGIC(0x5a534c4b) + +#ifndef __ASSEMBLY__ + +#include +#include + +/* ARM zImage header format */ +struct arm_zimage_header { + __le32 code[9]; + __le32 magic; + __le32 start; + __le32 end; + __le32 endian; + __le32 magic2; + __le32 extension_tag_offset; +}; + +struct arm_zimage_tag { + struct tag_header hdr; + union { +#define ZIMAGE_TAG_KRNL_SIZE ARM_ZIMAGE_MAGIC3 + struct zimage_krnl_size { + __le32 size_ptr; + __le32 bss_size; + __le32 text_offset; + __le32 malloc_size; + } krnl_size; + } u; +}; + +#endif /* __ASSEMBLY__ */ + +#endif /* __ASM_IMAGE_H */ From patchwork Wed Sep 30 18:34:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lukasz Stelmach X-Patchwork-Id: 11810039 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 395AB1668 for ; Wed, 30 Sep 2020 18:41:22 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0810C20708 for ; Wed, 30 Sep 2020 18:41:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="EPLirrWQ"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="llAuxwu6" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0810C20708 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=samsung.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:MIME-Version:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=4OtgoewLDyoDhefYTPg0B3S4BAqx5I/YdkLqwEPqCUQ=; b=EPLirrWQeWYDopIQx7lqGhUcn iXVD8hM0zKMUb2xLmz7OZg2NhdneVf/IhrJ2uXl+PIGZwsJXtLOYsMxaUekw1Uvb3lmxk5Rx1Q+rW SbjORZpsecSXb+GNFZJyWGSPPsxmMpX+0dQNWNh/5vg2jVpeIUwflNGVbqtKYUbmCYpuQWVKPw6UP DXgx9RvlJVGteqZgYhRchQ6pbEvORD62yUDgTkNRhjZ/rYM01FGCR4+SOamx4wQmSeTqZji7G9ZbV YF6zhbWog+0T8pckyrZVBLuBJPVwtTwUFB3OmTQ+CQ6OBBiYfZlI73U9+uPxGE7lOX5XMmLZIBsYD AYznsA8Pw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kNh12-00041y-JX; Wed, 30 Sep 2020 18:39:48 +0000 Received: from mailout2.w1.samsung.com ([210.118.77.12]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kNh0h-0003t3-9r for linux-arm-kernel@lists.infradead.org; Wed, 30 Sep 2020 18:39:30 +0000 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20200930183925euoutp02b6e54fd9d49c2350aeddc7840425906a~5o7rxUvKv0433404334euoutp02E for ; Wed, 30 Sep 2020 18:39:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20200930183925euoutp02b6e54fd9d49c2350aeddc7840425906a~5o7rxUvKv0433404334euoutp02E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1601491165; bh=SbxBiLARl8Dk0g1H6VHe2CLw9OQir8e+udgbGy3RVlc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=llAuxwu6paNfd7/hgyFkKZTjYGyfyR33E6/s7hCxeuufve5rNmBllDWAv+2LVDasp QXNLevyHaBNPf5WM04OWN32wWftMfoar2Z7mIE1doGKisFwsMbOPT0BD9mn3b/xU9o X8f508imiVmA1QRZZZAs0xQZ5S+AJ+GRP3wHahn4= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20200930183925eucas1p10ea13169b9db5c50f98010d79e5d13cc~5o7rHTezI1420814208eucas1p1U; Wed, 30 Sep 2020 18:39:25 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 22.7B.05997.DD0D47F5; Wed, 30 Sep 2020 19:39:25 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20200930183924eucas1p2869520cc28e705073cb08c37c1e2fc6d~5o7qTi2iF0648106481eucas1p23; Wed, 30 Sep 2020 18:39:24 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20200930183924eusmtrp2d3d24d8314b170b7e5554bd635a5a4a7~5o7qS4kag3109431094eusmtrp2C; Wed, 30 Sep 2020 18:39:24 +0000 (GMT) X-AuditID: cbfec7f4-677ff7000000176d-49-5f74d0dd24a5 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 73.F3.06017.CD0D47F5; Wed, 30 Sep 2020 19:39:24 +0100 (BST) Received: from localhost (unknown [106.120.51.46]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20200930183924eusmtip16c45496739c7641979f85916558be3f6~5o7qHNSoW2620526205eusmtip1i; Wed, 30 Sep 2020 18:39:24 +0000 (GMT) From: =?utf-8?q?=C5=81ukasz_Stelmach?= To: Russell King , Masahiro Yamada , Nick Desaulniers , Thomas Gleixner , Enrico Weigelt , Kees Cook , Ingo Molnar , Ben Dooks , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, AKASHI Takahiro , kexec@lists.infradead.org, Dave Young Subject: [PATCH v3 2/4] arm: decompressor: define a new zImage tag Date: Wed, 30 Sep 2020 20:34:11 +0200 Message-Id: <20200930183413.17023-3-l.stelmach@samsung.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200930183413.17023-1-l.stelmach@samsung.com> MIME-Version: 1.0 Organization: Samsung R&D Institute Poland X-Brightmail-Tracker: H4sIAAAAAAAAA01Se0hTYRTn2727uxOnt/XwZJGwngppD4kPDEkruiBBVPSHlLbZxZnbsk0t g3JlWJnVnM2WioVoipbSNDWdPYZoNbOHj7QUjKLS0gQnvmrmdpX875zf+T3OgUMT0gGhLx2n SeS0GrlKRnmQNc2Tbzb2vU2M3vSzk8APzZVCbKx4JsD6LD2Je843CHDrVTVusI8JcI+tFGHL ly4hbq/Pp7DN1Ijwg6Y+Ef7c3y3E5c5XCI8YZgT4z9NJEldZTMQOhm3vekewefp3JPu37AfB 3rUksZayKxTb22Wl2OG2NhFbVZTKGkaGKPb3k06KvV5dhthRy6p9npEe249xqrhkThsUetRD 6RjKFCV89D7tTBsj9cjqmYFoGphgqG2PyEAetJQpRWC7eJ7MQOLZxoHggimGH4wieGL+JJwX fMgS8HgJAsfQUyHffEegz88RudQUEwY3il+4B0uYfgIGTSWkqyGYewhmzL/cVouZcKhtPugS kMxaqMsbp1y1hAmBwvFqtxEwfnCppNaNi5nt8P510xxnEby8/dW9qjcTAPcvfHDXxCw/7VEe 4coCppiGkec9JG+0C7r7R+fqxTDYMh+wEmYe3xHwp6VCtnEbr81EUJM/MccPgd62KcrFIRh/ qKwP4uEwyB3uEPFSL+geWsSv4AXGmlsED0vgcrqUZ6+BihvWOUNfuDZYigxIlrvgmNwFB+T+ z7qLiDLkwyXp1LGcbouGOxWok6t1SZrYwJgTaguafUC7s8VRh+r/KGyIoZHMU2LQJEZLhfJk XYrahoAmZEsk4a/tUVLJMXnKGU57IlqbpOJ0NrSCJmU+kq2FA0ekTKw8kYvnuAROOz8V0GJf PYr0Dkm1Ho5ZfUbZopmwTSNLSfbE8D0nVzU+MfZt+cUGsmCtRLF0/84DOFK4we/x0d9R66bT d5uWPVDe7IzfOxq6/txZR/iUyfxMSx/3n65WxTcosq3TOWLVW3ujVVNnz56cCqZay83+8sIt x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A== X-CMS-MailID: 20200930183924eucas1p2869520cc28e705073cb08c37c1e2fc6d X-Msg-Generator: CA X-RootMTR: 20200930183924eucas1p2869520cc28e705073cb08c37c1e2fc6d X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200930183924eucas1p2869520cc28e705073cb08c37c1e2fc6d References: <20200601142754.26139-1-l.stelmach@samsung.com> <20200930183413.17023-1-l.stelmach@samsung.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200930_143927_476545_ABF9BB10 X-CRM114-Status: GOOD ( 16.96 ) X-Spam-Score: -5.7 (-----) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-5.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at https://www.dnswl.org/, high trust [210.118.77.12 listed in list.dnswl.org] 0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [210.118.77.12 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders -0.5 DKIMWL_WL_HIGH DKIMwl.org - High trust sender X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marek Szyprowski , =?utf-8?q?=C5=81ukasz_Stelm?= =?utf-8?q?ach?= , Bartlomiej Zolnierkiewicz Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Add DCSZ tag which holds dynamic memory (stack, bss, malloc pool) requirements of the decompressor code. Signed-off-by: Łukasz Stelmach --- arch/arm/boot/compressed/vmlinux.lds.S | 9 ++++++++- arch/arm/include/asm/image.h | 3 +++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/arch/arm/boot/compressed/vmlinux.lds.S b/arch/arm/boot/compressed/vmlinux.lds.S index a6b151112ac5..3e7443b52f5b 100644 --- a/arch/arm/boot/compressed/vmlinux.lds.S +++ b/arch/arm/boot/compressed/vmlinux.lds.S @@ -43,6 +43,11 @@ SECTIONS LONG(ZIMAGE_MAGIC(_kernel_bss_size)) LONG(ZIMAGE_MAGIC(TEXT_OFFSET)) LONG(ZIMAGE_MAGIC(MALLOC_SIZE)) + LONG(ZIMAGE_MAGIC(3)) + LONG(ARM_ZIMAGE_MAGIC4) + LONG(ZIMAGE_MAGIC((_end - __bss_start) + + (_stack_end - _stack_start) + + MALLOC_SIZE)) LONG(0) _table_end = .; } @@ -117,10 +122,12 @@ SECTIONS . = BSS_START; __bss_start = .; .bss : { *(.bss) } + . = ALIGN(8); /* the stack must be 64-bit aligned and adjoin bss */ _end = .; - . = ALIGN(8); /* the stack must be 64-bit aligned */ + _stack_start = .; .stack : { *(.stack) } + _stack_end = .; PROVIDE(__pecoff_data_size = ALIGN(512) - ADDR(.data)); PROVIDE(__pecoff_end = ALIGN(512)); diff --git a/arch/arm/include/asm/image.h b/arch/arm/include/asm/image.h index 8150b9490e86..8be6dbc69fbb 100644 --- a/arch/arm/include/asm/image.h +++ b/arch/arm/include/asm/image.h @@ -15,6 +15,7 @@ #define ARM_ZIMAGE_MAGIC1 ZIMAGE_MAGIC(0x016f2818) #define ARM_ZIMAGE_MAGIC2 (0x45454545) #define ARM_ZIMAGE_MAGIC3 ZIMAGE_MAGIC(0x5a534c4b) +#define ARM_ZIMAGE_MAGIC4 ZIMAGE_MAGIC(0x5a534344) #ifndef __ASSEMBLY__ @@ -42,6 +43,8 @@ struct arm_zimage_tag { __le32 text_offset; __le32 malloc_size; } krnl_size; +#define ZIMAGE_TAG_ZIMAGE_MEM ARM_ZIMAGE_MAGIC4 + __le32 zimage_mem; } u; }; From patchwork Wed Sep 30 18:34:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lukasz Stelmach X-Patchwork-Id: 11810035 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E252A112E for ; Wed, 30 Sep 2020 18:39:58 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7E6FD2076B for ; Wed, 30 Sep 2020 18:39:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="gZ0NdxqM"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="uemZWrQD" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7E6FD2076B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=samsung.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:MIME-Version:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=EndN+BAPipMPqwyY2HlpYTsq+yZL49sktoaqQsQqe3I=; b=gZ0NdxqMiOkjAPHzRDflAvYbJ BfM56JjJs7uKbqlhy0O2bLqwEmX7Qg3FaOiL2hiTtSZM6tnbfExBtjB54Ev4WHFCpZbOWD5d9xK/s KJ+Aw6VlfgpGJQ/S4+rXx6HaHFE8ubNJP3iDl2AgY03fvqhArghJH40kynvSNp8y0WySfSkP/LyhA e/q2rTuCFT9XqrlqrkMYwDP6+Q75O74npQeI2YuQqdhkBxt+/pfK78UjXCR4hWn5KPGu1OCDbCf7f wXHvIb80521sHE4qrjLcbtJqadNSCl2cyKiXtAdlJRfHYlWZ171w9om4WI1rIxukeuiskenUaLXBf inOkgGgWQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kNh0z-00040h-B6; Wed, 30 Sep 2020 18:39:45 +0000 Received: from mailout2.w1.samsung.com ([210.118.77.12]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kNh0h-0003t0-9x for linux-arm-kernel@lists.infradead.org; Wed, 30 Sep 2020 18:39:30 +0000 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20200930183925euoutp0232f9d15d2817df4b423e97e02a490d5d~5o7rcVHZh0171701717euoutp02p for ; Wed, 30 Sep 2020 18:39:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20200930183925euoutp0232f9d15d2817df4b423e97e02a490d5d~5o7rcVHZh0171701717euoutp02p DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1601491165; bh=VmU9hk7sPc2YuQEvFLqAo5Y66addDZ+CZ+WSSzVah+E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uemZWrQDVzTIaOnLEwkajWVQktnlzBEFpX1IgFEVDsPIqiNjJUAis5oJ6WbNSLQmj eSnrA+Lnc8tXnwPvZJAKt2cDud3m3hMiakifKfnb4TowVwM6WZgzowzX9u0jKUFp6f 5fUUrUkro5jqGw83jjPaHTfBZ7q1r3EIhyj4XFEI= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20200930183925eucas1p1330ac8f4604e78248ee16f75f951b84e~5o7rJumvE1417114171eucas1p1R; Wed, 30 Sep 2020 18:39:25 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id A8.10.06318.DD0D47F5; Wed, 30 Sep 2020 19:39:25 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20200930183924eucas1p1eba72052e1723ce75e00cbadbe03b6fa~5o7qlcgEN0403504035eucas1p18; Wed, 30 Sep 2020 18:39:24 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20200930183924eusmtrp2ca3ec9f629d8e5fbbb528bbff9b7990a~5o7qk0Aa93109431094eusmtrp2D; Wed, 30 Sep 2020 18:39:24 +0000 (GMT) X-AuditID: cbfec7f5-38bff700000018ae-78-5f74d0ddeeb2 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 84.F3.06017.CD0D47F5; Wed, 30 Sep 2020 19:39:24 +0100 (BST) Received: from localhost (unknown [106.120.51.46]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20200930183924eusmtip201d1f06b3cbb8d76328fb13cf88a615e~5o7qcJD5P2698626986eusmtip2D; Wed, 30 Sep 2020 18:39:24 +0000 (GMT) From: =?utf-8?q?=C5=81ukasz_Stelmach?= To: Russell King , Masahiro Yamada , Nick Desaulniers , Thomas Gleixner , Enrico Weigelt , Kees Cook , Ingo Molnar , Ben Dooks , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, AKASHI Takahiro , kexec@lists.infradead.org, Dave Young Subject: [PATCH v3 3/4] arm: Add kexec_image_info Date: Wed, 30 Sep 2020 20:34:12 +0200 Message-Id: <20200930183413.17023-4-l.stelmach@samsung.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200930183413.17023-1-l.stelmach@samsung.com> MIME-Version: 1.0 Organization: Samsung R&D Institute Poland X-Brightmail-Tracker: H4sIAAAAAAAAA02Se0hTYRjG+3bOjsfp7LgiXzSLRhcSSrtQBzVJKThEQUEQCWYrD0t0yzaX GZZLIdM0Ny9pKiWVqavUps68LV2a2dK8ZYZaRmV5KykNLS85j5H//Z73e573Ah+JiYb4jmSg PJRVyCXBYkKAG55NvtrU2xLq75bQgtGP0gv5dFJBDY9Wa9U4/fZSJY9+eVVGV5rHefRbUx6i 9R87+XR7RRZBm1KrEf2wrteK/tDXxafvz7xA9KhmlkdPPZnE6WJ9KrabYto7WzEmU92KM9O6 rxiTrVcxel0swfR0VhHMt+ZmK6b4biSjGR0hmO/G1wRzrUSHmJ/6VQdtfQWeAWxw4FlW4ep1 XHAqf7IWC9HanTOnZfPUqNYmDlmTQG2H5Kf5RBwSkCIqD4H2TTPGiTEEHd39C+InAl3fH/Qv 8q4udp5FVC6Cynofjr8gaLjpYGGC8obEnOd8S3g51YfBYGoubhEYdQ/BbPow3+JaRm2BNE2R lYVxah3kabtxCwspD0iZjsO5aashJreMsLA15QltTXUE57GHxhuf5j1LKRd4EPVmnrE5f3Rp 5vzaQOWTUP7+6UKjPWCu/kFwvAwGG0qsOF4Js+W3eHGInONISE7awWXjERiyJhayHtDT/Juw eDBqIxRWuHJlbxi6Xs/nonbQNWLPrWAHSYY0jCsL4cplEedeCwWJVQsNHSFhMA9pkDhj0TEZ iw7I+D8rG2E65MCqlDIpq9wmZ8M2KyUypUou3XzytEyP5r6geaZh/DEyTp0wIYpEYluhRh7q L+JLzirDZSYEJCZeLvRpMh8TCQMk4edZxWl/hSqYVZqQE4mLHY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L3up7l/bOJEcvOfXshLaJmNSviyL5yx3brk45/ tyeVTPyhzGkrKzqNIeaP29r816tb5h60vrT6hNu/PGbW5vAVkp4T7LeZ5OonHCm1cbp/MuPV pFaWNBOTwFQGkd1b5Izyt8Vo+Ri4PQrawZImqaDEUpyRaKjFXFScCAC+VYu6EAMAAA== X-CMS-MailID: 20200930183924eucas1p1eba72052e1723ce75e00cbadbe03b6fa X-Msg-Generator: CA X-RootMTR: 20200930183924eucas1p1eba72052e1723ce75e00cbadbe03b6fa X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200930183924eucas1p1eba72052e1723ce75e00cbadbe03b6fa References: <20200601142754.26139-1-l.stelmach@samsung.com> <20200930183413.17023-1-l.stelmach@samsung.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200930_143927_510233_CD0E7CA9 X-CRM114-Status: GOOD ( 17.27 ) X-Spam-Score: -5.7 (-----) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-5.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [210.118.77.12 listed in wl.mailspike.net] -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at https://www.dnswl.org/, high trust [210.118.77.12 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders -0.5 DKIMWL_WL_HIGH DKIMwl.org - High trust sender X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marek Szyprowski , =?utf-8?q?=C5=81ukasz_Stelm?= =?utf-8?q?ach?= , Bartlomiej Zolnierkiewicz Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Add kexec_image_info to print detailed information about a kexec image. Signed-off-by: Łukasz Stelmach --- arch/arm/kernel/machine_kexec.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/arch/arm/kernel/machine_kexec.c b/arch/arm/kernel/machine_kexec.c index 5d84ad333f05..a0c229eec0b2 100644 --- a/arch/arm/kernel/machine_kexec.c +++ b/arch/arm/kernel/machine_kexec.c @@ -29,6 +29,32 @@ extern unsigned long kexec_boot_atags; static atomic_t waiting_for_crash_ipi; +/** + * kexec_image_info - For debugging output. + */ +#define kexec_image_info(_i) _kexec_image_info(__func__, __LINE__, _i) +static void _kexec_image_info(const char *func, int line, + const struct kimage *kimage) +{ + unsigned long i; + + pr_debug("%s:%d:\n", func, line); + pr_debug(" kexec kimage info:\n"); + pr_debug(" type: %d\n", kimage->type); + pr_debug(" start: %lx\n", kimage->start); + pr_debug(" head: %lx\n", kimage->head); + pr_debug(" nr_segments: %lu\n", kimage->nr_segments); + + for (i = 0; i < kimage->nr_segments; i++) { + pr_debug(" segment[%lu]: %08lx - %08lx, 0x%x bytes, %lu pages\n", + i, + kimage->segment[i].mem, + kimage->segment[i].mem + kimage->segment[i].memsz, + kimage->segment[i].memsz, + kimage->segment[i].memsz / PAGE_SIZE); + } +} + /* * Provide a dummy crash_notes definition while crash dump arrives to arm. * This prevents breakage of crash_notes attribute in kernel/ksysfs.c. @@ -40,6 +66,8 @@ int machine_kexec_prepare(struct kimage *image) __be32 header; int i, err; + kexec_image_info(image); + image->arch.kernel_r2 = image->start - KEXEC_ARM_ZIMAGE_OFFSET + KEXEC_ARM_ATAGS_OFFSET; From patchwork Wed Sep 30 18:34:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lukasz Stelmach X-Patchwork-Id: 11810037 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5C90F618 for ; Wed, 30 Sep 2020 18:40:30 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 03AC82076B for ; Wed, 30 Sep 2020 18:40:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="PbBLtlj5"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="cjZpMEai" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 03AC82076B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=samsung.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:MIME-Version:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=KoVPrynRW1a04CitQKaIeVixQbIqs93mOnAWuhku4Nc=; b=PbBLtlj5MNLX8ggrctuOcsRkh qIyuU5N+y4GIN+vwSkJOGK9zOFjZOcQroulupNR3Pc4yJ67j1aHJXPz4ll3WQHgKdaChU6k8pV78n Gm61P9D/0pz7BOCOgoqu/aMUoDKpIrtKRDhmxkDalu66toOR5yftlI1hAlUlpMjk1qSHtVLDGpU4a hbDhEKJDE//eb+XJtF0/8Nz2k4mef1r+QwwnoRukQxJsZbu60WQYkkDl2a8sd8N1IGE1GoxJ1olag 56KVchtLkTBv3z6UNI1NPhcn8A7j8ScELsEOyfGOJI0HQx6Z5PWKVWyhih8G0Crs7n791B8HacyeD /ctiDLajw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kNh1Q-0004BU-KF; Wed, 30 Sep 2020 18:40:12 +0000 Received: from mailout2.w1.samsung.com ([210.118.77.12]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kNh0h-0003t8-9w for linux-arm-kernel@lists.infradead.org; Wed, 30 Sep 2020 18:39:35 +0000 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20200930183925euoutp0276256a802ab27cc57c167f734b70660f~5o7r7HIOn0171701717euoutp02s for ; Wed, 30 Sep 2020 18:39:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20200930183925euoutp0276256a802ab27cc57c167f734b70660f~5o7r7HIOn0171701717euoutp02s DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1601491166; bh=DEzENPvTzIj7n5HipV9UGgMD2am2karJlQJEh31H+LM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cjZpMEaisjAmfNcmBOu74tchVEjynlB7dzd5n+cqcXe1bpOEABi0QTxtWj/HAGvbg vwlioxBZLiQoQLowp+sywwJAvLlcvywi2VFwm2Z9v2TpMjKZY1KIEMHkGQ5TZ+8CmH HN7qDKUHcjVHKm0ujLChA2hhyYFzmbyn19RLV+oQ= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20200930183925eucas1p250bf18c8799f50a93d8495f722068afd~5o7rSHAac0658306583eucas1p2v; Wed, 30 Sep 2020 18:39:25 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 97.A1.06456.DD0D47F5; Wed, 30 Sep 2020 19:39:25 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20200930183924eucas1p281730f3d651fc2c78d6a95e47a2c5220~5o7q_epOQ0657106571eucas1p2-; Wed, 30 Sep 2020 18:39:24 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20200930183924eusmtrp2c72d8659d0d5c71bd05236561ff2f419~5o7q9xwoi3109431094eusmtrp2E; Wed, 30 Sep 2020 18:39:24 +0000 (GMT) X-AuditID: cbfec7f2-809ff70000001938-65-5f74d0dddcd7 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 47.F8.06314.CD0D47F5; Wed, 30 Sep 2020 19:39:24 +0100 (BST) Received: from localhost (unknown [106.120.51.46]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20200930183924eusmtip118188b92986ebbbf676216b0b1ce10b6~5o7qxhqgL2620826208eusmtip1R; Wed, 30 Sep 2020 18:39:24 +0000 (GMT) From: =?utf-8?q?=C5=81ukasz_Stelmach?= To: Russell King , Masahiro Yamada , Nick Desaulniers , Thomas Gleixner , Enrico Weigelt , Kees Cook , Ingo Molnar , Ben Dooks , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, AKASHI Takahiro , kexec@lists.infradead.org, Dave Young Subject: [PATCH v3 4/4] arm: kexec_file: load zImage or uImage, initrd and dtb Date: Wed, 30 Sep 2020 20:34:13 +0200 Message-Id: <20200930183413.17023-5-l.stelmach@samsung.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200930183413.17023-1-l.stelmach@samsung.com> MIME-Version: 1.0 Organization: Samsung R&D Institute Poland X-Brightmail-Tracker: H4sIAAAAAAAAA02Sf0yMcRzH973nueee0vF0tfURilsxoTTkoZjM5tmwNf4z5OjZ+dFd7X5E LN1hUYmcpVytQrpcKS5CP7BjRdH0U1mtIxUpWj/oyKXrOdN/n+/n/Xp/3p/P9iUx0SDfkzws V7EKuSRSTDjjZdXW+hWdb1XhK29rXOh7GSV8Wlf8jEdrLmtwul1bwaNfJ8voiroxHt1uLkC0 qbuVTzeVZxG0Oa0K0XdedAroD5Y2Pl1oq0X0UOokj554asXpUlMatolimlobMCZT04Azf4yf MSbXpGZMxkSC6WitJJhv9fUCpjQvnkkdGiSY709aCObifSNiRkxeYS67nUMi2MjDMawiYON+ 50Ndxtf8aFM2Ov7jYTqmQfnxSciJBGo1dFtKiSTkTIqoAgTa3494dkFEjSIY/rqUE0YQ6IrK 8X+O6wmvBJxgQHC29qPD3oegeSgb2SmCCoVLt17y7YI7ZcGgP82A2x8YlY9gMmOAb6fcqDBI emuZDsQpX2gZ75rOEFLB0D1mRVyeN5wzPCTstRMVAo1vXhAc4wqvrn2a5udQflB0+t10jU3x Zx5kYvYwoG6T0POtheAGbQHt8wLHEW7QX3NfwNXzYfJxztQS5FQdD1d0QZz3AoKyrHEHHwwd 9b8IO4NRS6GkPIBrh0JLfrPDOhvaBl25FWaDriwd49pCOJ8g4mgfKL5U6RjoCSn9BSgVifUz jtHPOED/PysXYUbkwaqVMimrDJSzx/yVEplSLZf6H4ySmdDUJ6yz1Qw/QmONB8yIIpHYRZgq V4WL+JIYZazMjIDExO7CzW/q9omEEZLYE6wiKlyhjmSVZjSPxMUewlU3vuwVUVKJij3KstGs 4p/KI508NehqtTozbp7v1mWGm3u2//TV7SxZuFgrkActsrkvsCyLqDqVNlHrdfJr/tq5s5Zc GQ/UBy5hbLuk+tH3OXd83fryVIWjdyuKe7B2w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gLPid9IDEsZWym9ZRWMmo1Il1ZUXGdNE+NcjowOxVSc7C8VP7ccEQMAAA== X-CMS-MailID: 20200930183924eucas1p281730f3d651fc2c78d6a95e47a2c5220 X-Msg-Generator: CA X-RootMTR: 20200930183924eucas1p281730f3d651fc2c78d6a95e47a2c5220 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200930183924eucas1p281730f3d651fc2c78d6a95e47a2c5220 References: <20200601142754.26139-1-l.stelmach@samsung.com> <20200930183413.17023-1-l.stelmach@samsung.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200930_143927_666582_C8A2BDE2 X-CRM114-Status: GOOD ( 33.16 ) X-Spam-Score: -5.7 (-----) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-5.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [210.118.77.12 listed in wl.mailspike.net] -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at https://www.dnswl.org/, high trust [210.118.77.12 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders -0.5 DKIMWL_WL_HIGH DKIMwl.org - High trust sender X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marek Szyprowski , =?utf-8?q?=C5=81ukasz_Stelm?= =?utf-8?q?ach?= , Bartlomiej Zolnierkiewicz Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org This is kexec_file_load implementation for ARM. It loads zImage and initrd from file descripters and resuses DTB. Most code is derived from arm64 kexec_file_load implementation and from kexec-tools. Cc: AKASHI Takahiro Signed-off-by: Łukasz Stelmach --- arch/arm/Kconfig | 26 ++++ arch/arm/include/asm/image.h | 26 ++++ arch/arm/include/asm/kexec.h | 16 +- arch/arm/kernel/Makefile | 5 +- arch/arm/kernel/kexec_uimage.c | 80 ++++++++++ arch/arm/kernel/kexec_zimage.c | 197 +++++++++++++++++++++++++ arch/arm/kernel/machine_kexec.c | 11 +- arch/arm/kernel/machine_kexec_file.c | 211 +++++++++++++++++++++++++++ 8 files changed, 566 insertions(+), 6 deletions(-) create mode 100644 arch/arm/kernel/kexec_uimage.c create mode 100644 arch/arm/kernel/kexec_zimage.c create mode 100644 arch/arm/kernel/machine_kexec_file.c diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index fe2f17eb2b50..65e5540f3ed1 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -1873,6 +1873,32 @@ config KEXEC is properly shutdown, so do not be surprised if this code does not initially work for you. +config KEXEC_FILE + bool "Kexec file based system call (EXPERIMENTAL)" + depends on (!SMP || PM_SLEEP_SMP) + depends on MMU + depends on USE_OF + select KEXEC_CORE + select CRC32 + help + This is a new version of kexec system call. This system call is + file based and takes file descriptors as system call argument + for kernel and initramfs as opposed to list of segments as + accepted by previous system call. + + The kernel to be loaded MUST support Flattened Device Tree + (selected with CONFIG_USE_OF). + +config KEXEC_FILE_UIMAGE + bool "Load legacy uImage files with kexec_file_load() (EXPERIMENTAL)" + depends on KEXEC_FILE + default n + help + This options enables support for the legacy uImage files as + created by mkimage. These are not the new FIT files. + + If unsure say N. + config ATAGS_PROC bool "Export atags in procfs" depends on ATAGS && KEXEC diff --git a/arch/arm/include/asm/image.h b/arch/arm/include/asm/image.h index 8be6dbc69fbb..15c4fe031d90 100644 --- a/arch/arm/include/asm/image.h +++ b/arch/arm/include/asm/image.h @@ -8,8 +8,13 @@ (((x) >> 8) & 0x0000ff00) | \ (((x) << 8) & 0x00ff0000) | \ (((x) << 24) & 0xff000000)) +#define UIMAGE_MAGIC(x) (x) #else #define ZIMAGE_MAGIC(x) (x) +#define UIMAGE_MAGIC(x) ((((x) >> 24) & 0x000000ff) | \ + (((x) >> 8) & 0x0000ff00) | \ + (((x) << 8) & 0x00ff0000) | \ + (((x) << 24) & 0xff000000)) #endif #define ARM_ZIMAGE_MAGIC1 ZIMAGE_MAGIC(0x016f2818) @@ -17,6 +22,12 @@ #define ARM_ZIMAGE_MAGIC3 ZIMAGE_MAGIC(0x5a534c4b) #define ARM_ZIMAGE_MAGIC4 ZIMAGE_MAGIC(0x5a534344) +#define ARM_UIMAGE_MAGIC UIMAGE_MAGIC(0x27051956) +#define ARM_UIMAGE_NAME_LEN 32 +#define ARM_UIMAGE_TYPE_KERNEL 2 +#define ARM_UIMAGE_TYPE_KERNEL_NOLOAD 14 +#define ARM_UIMAGE_ARCH_ARM 2 + #ifndef __ASSEMBLY__ #include @@ -33,6 +44,21 @@ struct arm_zimage_header { __le32 extension_tag_offset; }; +struct arm_uimage_header { + __be32 magic; + __be32 hdr_crc; + __be32 time; + __be32 size; + __be32 load; + __be32 entry; + __be32 crc; + __u8 os; + __u8 arch; + __u8 type; + __u8 comp; + __u8 name[ARM_UIMAGE_NAME_LEN]; +}; + struct arm_zimage_tag { struct tag_header hdr; union { diff --git a/arch/arm/include/asm/kexec.h b/arch/arm/include/asm/kexec.h index 22751b5b5735..8e4d0d92269b 100644 --- a/arch/arm/include/asm/kexec.h +++ b/arch/arm/include/asm/kexec.h @@ -2,7 +2,7 @@ #ifndef _ARM_KEXEC_H #define _ARM_KEXEC_H -#ifdef CONFIG_KEXEC +#if defined(CONFIG_KEXEC) || defined(CONFIG_KEXEC_FILE) /* Maximum physical address we can use pages from */ #define KEXEC_SOURCE_MEMORY_LIMIT (-1UL) @@ -83,6 +83,20 @@ static inline struct page *boot_pfn_to_page(unsigned long boot_pfn) } #define boot_pfn_to_page boot_pfn_to_page +#ifdef CONFIG_KEXEC_FILE + +extern const struct kexec_file_ops kexec_zimage_ops; +extern const struct kexec_file_ops kexec_uimage_ops; + +struct kimage; + +extern int load_other_segments(struct kimage *image, + unsigned long kernel_load_addr, unsigned long kernel_size, + char *initrd, unsigned long initrd_len, + unsigned long initrd_offset, char *cmdline); + +#endif /* CONFIG_KEXEC_FILE */ + #endif /* __ASSEMBLY__ */ #endif /* CONFIG_KEXEC */ diff --git a/arch/arm/kernel/Makefile b/arch/arm/kernel/Makefile index 89e5d864e923..453ecf7305e2 100644 --- a/arch/arm/kernel/Makefile +++ b/arch/arm/kernel/Makefile @@ -3,6 +3,7 @@ # Makefile for the linux kernel. # +CFLAGS_kexec_zimage.o := -DTEXT_OFFSET=$(TEXT_OFFSET) CPPFLAGS_vmlinux.lds := -DTEXT_OFFSET=$(TEXT_OFFSET) AFLAGS_head.o := -DTEXT_OFFSET=$(TEXT_OFFSET) @@ -56,7 +57,9 @@ obj-$(CONFIG_FUNCTION_TRACER) += entry-ftrace.o obj-$(CONFIG_DYNAMIC_FTRACE) += ftrace.o insn.o patch.o obj-$(CONFIG_FUNCTION_GRAPH_TRACER) += ftrace.o insn.o patch.o obj-$(CONFIG_JUMP_LABEL) += jump_label.o insn.o patch.o -obj-$(CONFIG_KEXEC) += machine_kexec.o relocate_kernel.o +obj-$(CONFIG_KEXEC_CORE) += machine_kexec.o relocate_kernel.o +obj-$(CONFIG_KEXEC_FILE) += machine_kexec_file.o kexec_zimage.o +obj-$(CONFIG_KEXEC_FILE_UIMAGE) += kexec_uimage.o # Main staffs in KPROBES are in arch/arm/probes/ . obj-$(CONFIG_KPROBES) += patch.o insn.o obj-$(CONFIG_OABI_COMPAT) += sys_oabi-compat.o diff --git a/arch/arm/kernel/kexec_uimage.c b/arch/arm/kernel/kexec_uimage.c new file mode 100644 index 000000000000..47033574e24e --- /dev/null +++ b/arch/arm/kernel/kexec_uimage.c @@ -0,0 +1,80 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Kexec uImage loader + * + * Copyright (C) 2020 Samsung Electronics + * Author: Łukasz Stelmach + */ + +#define pr_fmt(fmt) "kexec_file(uImage): " fmt + +#include +#include +#include +#include + +#define crc32_ones(crc, buf, len) \ + (crc32(crc ^ 0xffffffff, buf, len) ^ 0xffffffff) + +static int uimage_probe(const char *uimage_buf, unsigned long uimage_len) +{ + const struct arm_uimage_header *h = + (struct arm_uimage_header *) uimage_buf; + struct arm_uimage_header uhdr; + unsigned long zoff = sizeof(struct arm_uimage_header); + uint32_t crc; + + if (h->magic != ARM_UIMAGE_MAGIC) + return -EINVAL; + + if (h->type != ARM_UIMAGE_TYPE_KERNEL && + h->type != ARM_UIMAGE_TYPE_KERNEL_NOLOAD){ + pr_debug("Invalid image type: %d\n", h->type); + return -EINVAL; + } + + if (h->arch != ARM_UIMAGE_ARCH_ARM) { + pr_debug("Invalidy image arch: %d\n", h->arch); + return -EINVAL; + } + + memcpy((char *)&uhdr, h, sizeof(uhdr)); + crc = be32_to_cpu(uhdr.hdr_crc); + uhdr.hdr_crc = 0; + + if (crc32_ones(0, (char *)&uhdr, sizeof(uhdr)) != crc) { + pr_debug("Corrupt header, CRC do not match\n"); + return -EINVAL; + } + + crc = be32_to_cpu(uhdr.crc); + if (crc32_ones(0, uimage_buf + zoff, uimage_len - zoff) != crc) { + pr_debug("Corrupt zImage, CRC do not match\n"); + return -EINVAL; + } + + return kexec_zimage_ops.probe(uimage_buf + zoff, + uimage_len - zoff); +} + +static void *uimage_load(struct kimage *image, + char *uimage, unsigned long uimage_len, + char *initrd, unsigned long initrd_len, + char *cmdline, unsigned long cmdline_len) +{ + const struct arm_uimage_header *h = + (struct arm_uimage_header *) uimage; + unsigned long zimage_offset = sizeof(struct arm_uimage_header); + + pr_debug("Loading uImage"); + return kexec_zimage_ops.load(image, + uimage + zimage_offset, + uimage_len - zimage_offset, + initrd, initrd_len, + cmdline, cmdline_len); +} + +const struct kexec_file_ops kexec_uimage_ops = { + .probe = uimage_probe, + .load = uimage_load, +}; diff --git a/arch/arm/kernel/kexec_zimage.c b/arch/arm/kernel/kexec_zimage.c new file mode 100644 index 000000000000..543229a42793 --- /dev/null +++ b/arch/arm/kernel/kexec_zimage.c @@ -0,0 +1,197 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Kexec zImage loader + * + * Copyright (C) 2020 Samsung Electronics + * Authors: + * Łukasz Stelmach + * + * Based on earlier works for kexec-tools by + * Russell King + * + */ + +#define pr_fmt(fmt) "kexec_file(zImage): " fmt + +#include +#include +#include +#include +#include + +#define byte_size(t) ((t)->hdr.size << 2) + +/* + * This function and several pieces below have been taken from + * kexec-tools/kexec/arch/arm/kexec-zImage-arm.c + */ +static const void *find_extension_tag(const char *buf, + unsigned long len, + uint32_t tag_id) +{ + const struct arm_zimage_header *h = (const struct arm_zimage_header *)buf; + const struct arm_zimage_tag *tag; + uint32_t offset, size; + uint32_t max = len - sizeof(struct tag_header); + + if (len < sizeof(*h) || + h->magic != ARM_ZIMAGE_MAGIC1 || + h->magic2 != ARM_ZIMAGE_MAGIC2) + return NULL; + + for (offset = h->extension_tag_offset; + (tag = (void *)(buf + offset)) != NULL && + offset < max && + (size = le32_to_cpu(byte_size(tag))) != 0 && + offset + size < len; + offset += size) { + pr_debug(" offset 0x%08x tag 0x%08x size %u\n", + offset, le32_to_cpu(tag->hdr.tag), size); + if (tag->hdr.tag == tag_id) + return tag; + } + + return NULL; +} + +static int zimage_probe(const char *kernel_buf, unsigned long kernel_len) +{ + const struct arm_zimage_header *h = + (struct arm_zimage_header *)(kernel_buf); + + if (!h || (kernel_len < sizeof(*h))) + return -EINVAL; + + if ((h->magic != ARM_ZIMAGE_MAGIC1) || + (h->magic2 != ARM_ZIMAGE_MAGIC2)) + return -EINVAL; + + return 0; +} + + +#if defined(DEBUG) +#define debug_offsets() ({ \ + pr_debug("Image offsets:\n"); \ + pr_debug(" kernel 0x%08lx 0x%08lx\n", kernel_offset, kernel_len); \ + pr_debug(" zimage 0x%08lx 0x%08lx\n", zimage_offset, zimage_len); \ + pr_debug(" initrd 0x%08lx 0x%08lx\n", initrd_offset, initrd_len); \ +}) +#else +#define debug_offsets() +#endif + +static void *zimage_load(struct kimage *image, + char *zimage, unsigned long zimage_len, + char *initrd, unsigned long initrd_len, + char *cmdline, unsigned long cmdline_len) +{ + struct arm_zimage_header *h; + struct kexec_buf kbuf; + struct kexec_segment *zimage_segment; + const struct arm_zimage_tag *tag; + int ret = -EINVAL; + + unsigned long zimage_mem = 0x20000; /* malloc 64kB + stack 4 kB + some bss */ + unsigned long kernel_len = zimage_len * 5; /* 5:1 compression */ + unsigned long kernel_offset = memblock_start_of_DRAM(); + unsigned long zimage_offset = kernel_offset + + ALIGN(kernel_len, PAGE_SIZE); + unsigned long initrd_offset = zimage_offset + + ALIGN(zimage_len + zimage_mem, PAGE_SIZE); + + if (image->type == KEXEC_TYPE_CRASH) { + kernel_offset += crashk_res.start; + zimage_offset += crashk_res.start; + initrd_offset += crashk_res.start; + } + debug_offsets(); + + h = (struct arm_zimage_header *)zimage; + + tag = find_extension_tag(zimage, zimage_len, ZIMAGE_TAG_KRNL_SIZE); + if (tag) { + uint32_t *p = (void *)zimage + + le32_to_cpu(tag->u.krnl_size.size_ptr); + uint32_t edata_size = le32_to_cpu(get_unaligned(p)); + uint32_t bss_size = le32_to_cpu(tag->u.krnl_size.bss_size); + uint32_t text_offset = le32_to_cpu(tag->u.krnl_size.text_offset); + + kernel_offset += ALIGN(text_offset, PAGE_SIZE); + kernel_len = edata_size + bss_size; + + pr_debug("Decompressed kernel sizes:\n"); + pr_debug(" text+data 0x%08lx bss 0x%08lx total 0x%08lx\n", + (unsigned long)edata_size, + (unsigned long)bss_size, + (unsigned long)kernel_len); + + zimage_offset = kernel_offset + ALIGN(edata_size, PAGE_SIZE); + initrd_offset = zimage_offset + + max(ALIGN(zimage_len + 0x20000, PAGE_SIZE), + ALIGN((unsigned long)bss_size, PAGE_SIZE)); + debug_offsets(); + } + + tag = find_extension_tag(zimage, zimage_len, + ZIMAGE_TAG_ZIMAGE_MEM); + if (tag) { + uint32_t zimage_mem = le32_to_cpu(tag->u.zimage_mem); + + pr_debug("Decompressor requires %d bytes of memory\n", zimage_mem); + + initrd_offset = max(ALIGN(zimage_offset + zimage_len + zimage_mem, PAGE_SIZE), + ALIGN(kernel_offset + kernel_len, PAGE_SIZE)); + debug_offsets(); + } + + /* + * zImage MUST be loaded into the first 128 MiB of physical + * memory for proper memory detection. Should the uncompressed + * kernel be larger than 128 MiB, zImage relocation becomes + * unavoidable and it is best to rely on the relocation code. + */ + if (((zimage_offset - kernel_offset) + PAGE_SIZE + 0x8000) >= SZ_128M) { + pr_debug("The kernel is too big (%ld MiB) to avoid " + "zImage relocation. Loading zimage at 0x%08lx\n", + ((zimage_offset - kernel_offset) >> 20), + kernel_offset); + zimage_offset = kernel_offset; + } + + kbuf.image = image; + kbuf.top_down = false; + + kbuf.buf_min = zimage_offset; + kbuf.buf_max = ULONG_MAX; + kbuf.buffer = zimage; + kbuf.bufsz = zimage_len; + kbuf.buf_align = PAGE_SIZE; + + kbuf.mem = KEXEC_BUF_MEM_UNKNOWN; + kbuf.memsz = zimage_len; + + ret = kexec_add_buffer(&kbuf); + if (ret) + return ERR_PTR(ret); + + pr_debug("Loaded zImage at 0x%lx bufsz=0x%lx memsz=0x%lx\n", + kbuf.mem, kbuf.bufsz, kbuf.memsz); + + initrd_offset += kbuf.mem - zimage_offset; + debug_offsets(); + + zimage_segment = &image->segment[image->nr_segments - 1]; + image->start = zimage_segment->mem; + + ret = load_other_segments(image, + zimage_segment->mem, zimage_segment->memsz, + initrd, initrd_len, initrd_offset, + cmdline); + return ERR_PTR(ret); +} + +const struct kexec_file_ops kexec_zimage_ops = { + .probe = zimage_probe, + .load = zimage_load, +}; diff --git a/arch/arm/kernel/machine_kexec.c b/arch/arm/kernel/machine_kexec.c index a0c229eec0b2..b349d6b8d18c 100644 --- a/arch/arm/kernel/machine_kexec.c +++ b/arch/arm/kernel/machine_kexec.c @@ -91,10 +91,13 @@ int machine_kexec_prepare(struct kimage *image) current_segment->memsz)) return -EINVAL; - err = get_user(header, (__be32*)current_segment->buf); - if (err) - return err; - + if (image->file_mode) { + header = *(__be32 *)current_segment->buf; + } else { + err = get_user(header, (__be32 *)current_segment->buf); + if (err) + return err; + } if (header == cpu_to_be32(OF_DT_HEADER)) image->arch.kernel_r2 = current_segment->mem; } diff --git a/arch/arm/kernel/machine_kexec_file.c b/arch/arm/kernel/machine_kexec_file.c new file mode 100644 index 000000000000..a632d351602c --- /dev/null +++ b/arch/arm/kernel/machine_kexec_file.c @@ -0,0 +1,211 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * kexec_file for arm + * + * Copyright (C) 2018 Linaro Limited + * Copyright (C) 2020 Samsung Electronics + * Authors: + * AKASHI Takahiro + * Łukasz Stelmach + * + */ + +#define pr_fmt(fmt) "kexec_file: " fmt + +#include +#include +#include +#include + +/* relevant device tree properties */ +#define FDT_PROP_INITRD_START "linux,initrd-start" +#define FDT_PROP_INITRD_END "linux,initrd-end" +#define FDT_PROP_BOOTARGS "bootargs" +#define FDT_PROP_RNG_SEED "rng-seed" + +static int setup_dtb(struct kimage *image, + unsigned long initrd_load_addr, unsigned long initrd_len, + char *cmdline, void *dtb) +{ + int off, ret; + + ret = fdt_path_offset(dtb, "/chosen"); + if (ret < 0) + goto out; + + off = ret; + + /* add bootargs */ + if (cmdline) { + ret = fdt_setprop_string(dtb, off, FDT_PROP_BOOTARGS, cmdline); + if (ret) + goto out; + } else { + ret = fdt_delprop(dtb, off, FDT_PROP_BOOTARGS); + if (ret && (ret != -FDT_ERR_NOTFOUND)) + goto out; + } + + /* add initrd-* */ + if (initrd_load_addr) { + ret = fdt_setprop_u64(dtb, off, FDT_PROP_INITRD_START, + initrd_load_addr); + if (ret) + goto out; + + ret = fdt_setprop_u64(dtb, off, FDT_PROP_INITRD_END, + initrd_load_addr + initrd_len); + if (ret) + goto out; + } else { + ret = fdt_delprop(dtb, off, FDT_PROP_INITRD_START); + if (ret && (ret != -FDT_ERR_NOTFOUND)) + goto out; + + ret = fdt_delprop(dtb, off, FDT_PROP_INITRD_END); + if (ret && (ret != -FDT_ERR_NOTFOUND)) + goto out; + } + + /* add rng-seed */ + if (rng_is_initialized()) { + char seed[128]; + get_random_bytes(seed, sizeof(seed)); + + ret = fdt_setprop(dtb, off, FDT_PROP_RNG_SEED, + seed, sizeof(seed)); + if (ret) + goto out; + } else { + pr_notice("RNG is not initialised: omitting \"%s\" property\n", + FDT_PROP_RNG_SEED); + ret = 0; + } + +out: + if (ret) + return (ret == -FDT_ERR_NOSPACE) ? -ENOMEM : -EINVAL; + + return 0; +} +/* + * More space needed so that we can add initrd, bootargs and kaslr-seed. + */ +#define DTB_EXTRA_SPACE 0x1000 + +static int create_dtb(struct kimage *image, + unsigned long initrd_load_addr, unsigned long initrd_len, + char *cmdline, void **dtb) +{ + void *buf; + size_t buf_size; + size_t cmdline_len; + int ret; + + cmdline_len = cmdline ? strlen(cmdline) : 0; + buf_size = fdt_totalsize(initial_boot_params) + + cmdline_len + DTB_EXTRA_SPACE; + + for (;;) { + buf = vmalloc(buf_size); + if (!buf) + return -ENOMEM; + + /* duplicate a device tree blob */ + ret = fdt_open_into(initial_boot_params, buf, buf_size); + if (ret) + return -EINVAL; + + ret = setup_dtb(image, initrd_load_addr, initrd_len, + cmdline, buf); + if (ret) { + vfree(buf); + if (ret == -ENOMEM) { + /* unlikely, but just in case */ + buf_size += DTB_EXTRA_SPACE; + continue; + } else { + return ret; + } + } + + /* trim it */ + fdt_pack(buf); + *dtb = buf; + + return 0; + } +} + +int load_other_segments(struct kimage *image, + unsigned long zimage_load_addr, + unsigned long zimage_len, + char *initrd, + unsigned long initrd_len, + unsigned long initrd_offset, + char *cmdline) +{ + struct kexec_buf kbuf; + void *dtb = NULL; + unsigned long initrd_load_addr = 0; + unsigned long dtb_len; + int ret = 0; + + kbuf.image = image; + /* not allocate anything below the kernel */ + kbuf.buf_min = initrd_offset; + if (initrd) { + kbuf.buffer = initrd; + kbuf.bufsz = initrd_len; + kbuf.mem = KEXEC_BUF_MEM_UNKNOWN; + kbuf.memsz = initrd_len; + kbuf.buf_align = PAGE_SIZE; + kbuf.buf_max = ULONG_MAX; + kbuf.top_down = false; + + ret = kexec_add_buffer(&kbuf); + if (ret) + goto out_err; + + pr_debug("Loaded initrd at 0x%lx bufsz=0x%lx memsz=0x%lx\n", + kbuf.mem, kbuf.bufsz, kbuf.memsz); + + initrd_load_addr = kbuf.mem; + kbuf.buf_min = initrd_load_addr + kbuf.memsz; + } + + /* load dtb */ + ret = create_dtb(image, initrd_load_addr, initrd_len, cmdline, &dtb); + if (ret) { + pr_err("Preparing for new dtb failed\n"); + goto out_err; + } + + dtb_len = fdt_totalsize(dtb); + kbuf.buffer = dtb; + kbuf.bufsz = dtb_len; + kbuf.mem = KEXEC_BUF_MEM_UNKNOWN; + kbuf.memsz = dtb_len; + kbuf.buf_align = PAGE_SIZE; + kbuf.buf_max = ULONG_MAX; + kbuf.top_down = false; + + ret = kexec_add_buffer(&kbuf); + if (ret) + goto out_err; + + pr_debug("Loaded dtb at 0x%lx bufsz=0x%lx memsz=0x%lx\n", + kbuf.mem, kbuf.bufsz, kbuf.memsz); + return 0; +out_err: + vfree(dtb); + return ret; +} + +const struct kexec_file_ops * const kexec_file_loaders[] = { +#ifdef CONFIG_KEXEC_FILE_UIMAGE + &kexec_uimage_ops, +#endif + &kexec_zimage_ops, + NULL +};