From patchwork Mon Jun 1 14:27:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lukasz Stelmach X-Patchwork-Id: 11582107 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 0A60B913 for ; Mon, 1 Jun 2020 14:28:26 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id DC8FA2068D for ; Mon, 1 Jun 2020 14:28:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="or8FQQ0C"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="qyaGQUdk" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DC8FA2068D 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=bombadil.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=mbZftSyzSCszjd44R9CmqQKvZM/AcjEzcOGAmCKcZA4=; b=or8FQQ0C8YFZRC hn0wIw4M7rxUW3Vg14SQuVz0XViCu/ZsI/lwMQ9D+VA7uUpXvCs8YGIcOT5QVbZYnJxmTM8DaHs8Y uObUyWd5Vb2rJEP1CoBpQpyoKUsN7wsmxHKOhR6Vf9MT534GeEHxJOim04DOOHxaS4dARJq5s9cU+ btY6J65nvN/IpYvhmZ7Qp22S4l3MN8R9g3nY/mNICU40QwGsEBeElNHgKukqhKGQ/UafU4RpOPzBM p+4oHpjEG6OT6f+3+wmI3plu3yf8sZxvIPuCKjzdVL7iiV6yaG2PFJIeO5zEfxezDnEqKF1l3hVow WdrVSxBDauKgnqQeVyhw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jflQL-0003VH-Jr; Mon, 01 Jun 2020 14:28:21 +0000 Received: from mailout2.w1.samsung.com ([210.118.77.12]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jflQC-0003Mu-Gw for linux-arm-kernel@lists.infradead.org; Mon, 01 Jun 2020 14:28:13 +0000 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20200601142811euoutp0205bc52797551134f9227760f146e8bee~UccxjaqWZ2486424864euoutp02j for ; Mon, 1 Jun 2020 14:28:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20200601142811euoutp0205bc52797551134f9227760f146e8bee~UccxjaqWZ2486424864euoutp02j DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1591021691; bh=TcvRBVgibYuWvdnj8aP2i39hNoNN9xtEvOA0UIuLnMw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qyaGQUdke+Ls9OJ+3s8sFwH+lw+wAfO0CCXNDuxpcsYibSVTGJ8Dq5BdidR56YU43 AKS0Udw1/lAF452Dj/BQkYQYrGudgBbecCAeD+A7gbQMYVGE11ee2HSejhNQignxvz Csz1jNvk5GsuLuO8WqWOzYwF6VMJKrkh7fksrba0= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20200601142810eucas1p2e42f5919d8046616d8e3dc2637fde2ed~UccxCsaUb0506105061eucas1p28; Mon, 1 Jun 2020 14:28:10 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 0D.EA.61286.A7015DE5; Mon, 1 Jun 2020 15:28:10 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20200601142810eucas1p1767585cf172d26aedb551d7453aa7402~UccwvQZhL2462024620eucas1p1p; Mon, 1 Jun 2020 14:28:10 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20200601142810eusmtrp1867c63cae3b0bc092ca73d4ff0bf8430~Uccwubcw43017330173eusmtrp1i; Mon, 1 Jun 2020 14:28:10 +0000 (GMT) X-AuditID: cbfec7f2-f0bff7000001ef66-bc-5ed5107a92d4 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 51.FB.07950.97015DE5; Mon, 1 Jun 2020 15:28:10 +0100 (BST) Received: from localhost (unknown [106.120.51.46]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20200601142809eusmtip107d07cf168a890f2adfbbed52e457391~UccwgUcus1630616306eusmtip1J; Mon, 1 Jun 2020 14:28:09 +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 Subject: [PATCH 1/5] arm: decompressor: set malloc pool size for the decompressor Date: Mon, 1 Jun 2020 16:27:50 +0200 Message-Id: <20200601142754.26139-2-l.stelmach@samsung.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200601142754.26139-1-l.stelmach@samsung.com> MIME-Version: 1.0 Organization: Samsung R&D Institute Poland X-Brightmail-Tracker: H4sIAAAAAAAAA02Se0hTURzHObt31ztt67oif75lFTFLTSq5oEZG0f3T6L+g2cyLWW7a5kwt dCWozcwX9lAJKSNbljp1lRrKsKyW8/0YKmYF9kAZ85GaWs5r5H/f7/d8fuec7+GQmHiE70HG KZNYlVIeLyGccePbxa6ANGpAtr9jcgddd7eGTxc9b+PR1mvNPPpjroK2mqoQbfgyyKf7msoJ 2lTyGtHP2sec6IlPw3z66eoHRNsK/vDo5dZFnK43lGBHREzfYA/GlGl7cGZF/w1jKgwaxqC/ QTCjgy0EM22xODH1lRlMgW2KYG416BEzY/CJdDntHBbDxscls6qgw2edzw9oK/HEVWHKU2su rkUNLjpEkkAdhILGdB1yJsVUFYL2rlcYZ2YR2CpGEGdmENh/lWD/JsasAi5/jMAyuMLXIcGa mUQwZ4h0aIKKgPxH7/gOaDs1x4OmkmzCYTCqH8FEq5HnoLZRp+B+3kvCoXFqN7xq/LieC6lQ qNf+Rg4NlC9kP36xzgioMGgz2zcYV3h/7yvu0Fspf6i+PrSusTU+s7FsvQNQeSRk9tiduI2O Qa9tmeD0NvjR0bCRe4G5+CbOVcuA4qIQbvYmAmP5As4xoTBqWSIcDEZJoaYpiIsjYKpigseN imB4ypW7ggiKjHc2HksIOVlijt4Fz/NbNjb0gLwfVagASUo3lSndVKD0/1kVCNMjN1ajVsSy 6mAlezlQLVeoNcrYwHMJCgNa+3Lm1Q77SzTXG21CFIkkW4S14/0yMV+erE5VmBCQmGS78Gin WSYWxshT01hVQpRKE8+qTciTxCVuwgMPvp8RU7HyJPYiyyayqn+rPFLgoUVPvKTNfeE+pVEX c+vYwuGkEzZdrXK4s3k22nPee+e0/86lGf2Q+4uczBap/o9V5t19xe9n9ed4Nr2rfShcmxI4 3nF7Yc+ytLdTJJtuq1QI3aPCHr6ZW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eucas1p1767585cf172d26aedb551d7453aa7402 X-Msg-Generator: CA X-RootMTR: 20200601142810eucas1p1767585cf172d26aedb551d7453aa7402 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200601142810eucas1p1767585cf172d26aedb551d7453aa7402 References: <20200601142754.26139-1-l.stelmach@samsung.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200601_072812_693266_F489108A X-CRM114-Status: GOOD ( 13.85 ) X-Spam-Score: -5.2 (-----) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (-5.2 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_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -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.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High 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: AKASHI Takahiro , Marek Szyprowski , =?utf-8?q?=C5=81ukasz_Stelmach?= , Bartlomiej Zolnierkiewicz Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Move the definition of malloc pool size of the decompressor to a single place. This value will be exposed later for kexec_file loader. Signed-off-by: Łukasz Stelmach --- arch/arm/boot/compressed/Makefile | 2 ++ arch/arm/boot/compressed/head.S | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/arm/boot/compressed/Makefile b/arch/arm/boot/compressed/Makefile index 9c11e7490292..b3594cd1588c 100644 --- a/arch/arm/boot/compressed/Makefile +++ b/arch/arm/boot/compressed/Makefile @@ -125,6 +125,8 @@ KBSS_SZ = $(shell echo $$(($$($(NM) $(obj)/../../../../vmlinux | \ sed -n -e 's/^\([^ ]*\) [AB] __bss_start$$/-0x\1/p' \ -e 's/^\([^ ]*\) [AB] __bss_stop$$/+0x\1/p') )) ) LDFLAGS_vmlinux = --defsym _kernel_bss_size=$(KBSS_SZ) +# malloc pool size +LDFLAGS_vmlinux += --defsym _malloc_size=0x10000 # Supply ZRELADDR to the decompressor via a linker symbol. ifneq ($(CONFIG_AUTO_ZRELADDR),y) LDFLAGS_vmlinux += --defsym zreladdr=$(ZRELADDR) diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S index e8e1c866e413..dcc1afa60fb9 100644 --- a/arch/arm/boot/compressed/head.S +++ b/arch/arm/boot/compressed/head.S @@ -309,7 +309,8 @@ restart: adr r0, LC0 #ifndef CONFIG_ZBOOT_ROM /* malloc space is above the relocated stack (64k max) */ add sp, sp, r0 - add r10, sp, #0x10000 + ldr r10, =_malloc_size + add r10, r10, sp #else /* * With ZBOOT_ROM the bss/stack is non relocatable, @@ -623,7 +624,8 @@ not_relocated: mov r0, #0 */ mov r0, r4 mov r1, sp @ malloc space above stack - add r2, sp, #0x10000 @ 64k max + ldr r2, =_malloc_size @ 64k max + add r2, r2, sp mov r3, r7 bl decompress_kernel From patchwork Mon Jun 1 14:27:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lukasz Stelmach X-Patchwork-Id: 11582113 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 A3E12159A for ; Mon, 1 Jun 2020 14:29:06 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 7AB6F2068D for ; Mon, 1 Jun 2020 14:29:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="pWUdzfyl"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="IHzDkama" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7AB6F2068D 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=bombadil.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=dIAVsp+jHtgGpf0WAs4ZOys8MKRhIbh8qvFgCeiC6rQ=; b=pWUdzfyltwlXAl 5fKmAQp8Zinb9jCj4VOyO3Js2GGUDKz8xhP7ni9ubeYslR9+KjDdCNYhRsdbDIn7dDc2/0hbY9rgw lk2yh209oq/SRJw+I5Rf++ARL6UBF8RCpk2dHW6jtRanggdAUtZpujimd+wZs3A3sEobBV7DO3GBJ XnUGLPcQFUlYg/N2EFTElcmZzgW4NKM/45sCFJwKC7YKw7BoPtgOkhpvXSCnhBldkSBAQptpJsWUI J07ttkVPD+zhun0C2zSi3EUQZnMOVQhcSvvUGGY6+CiLXFSD/iNzm8dm2uD0hz6ooQaXCtizvjV4h H9NWLJx0oAvusQVh7QXw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jflQx-000451-9U; Mon, 01 Jun 2020 14:28:59 +0000 Received: from mailout1.w1.samsung.com ([210.118.77.11]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jflQD-0003Mv-GT for linux-arm-kernel@lists.infradead.org; Mon, 01 Jun 2020 14:28:15 +0000 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20200601142811euoutp01baf93504bdf7e4830f301c64f5830344~UccxxKBU10989309893euoutp01n for ; Mon, 1 Jun 2020 14:28:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20200601142811euoutp01baf93504bdf7e4830f301c64f5830344~UccxxKBU10989309893euoutp01n DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1591021691; bh=Qz6U1Wo5NiI9a+hsP0kvKTekCHlCwheEB+SMihQuSRY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IHzDkama6HDzRYDvYnFe7jW7aHTsZ41zrK2JUmgP0jPY9ER2dbBbGmm0xrpx3dvRZ iTLGrLrzHeEAogbalCoZvpEK1Z1YT+TOljz5MtJb5U6uH7pb66GiDcgq+U7eX+v9ou sln6vRo9+glRM5yDbc75sK7Yei2XtL/LImRFm54o= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20200601142810eucas1p222984f1c15f427a5327b43bc2ef363c0~UccxaOV1B2609926099eucas1p2P; Mon, 1 Jun 2020 14:28:10 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 3E.6D.60698.A7015DE5; Mon, 1 Jun 2020 15:28:10 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20200601142810eucas1p23056f7997a880ff7d676c64703f87115~UccxH0XE83062630626eucas1p2G; Mon, 1 Jun 2020 14:28:10 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20200601142810eusmtrp2a83a46639842bb833882f4c67dbd6ff9~UccxHKKwk1485714857eusmtrp2K; Mon, 1 Jun 2020 14:28:10 +0000 (GMT) X-AuditID: cbfec7f5-a0fff7000001ed1a-e0-5ed5107a3af5 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 45.52.08375.A7015DE5; Mon, 1 Jun 2020 15:28:10 +0100 (BST) Received: from localhost (unknown [106.120.51.46]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20200601142810eusmtip2567a0195d07aa80b2647c6d26b54bace~Uccw8Hs4M2413124131eusmtip2R; Mon, 1 Jun 2020 14:28:10 +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 Subject: [PATCH 2/5] arm: add image header definitions Date: Mon, 1 Jun 2020 16:27:51 +0200 Message-Id: <20200601142754.26139-3-l.stelmach@samsung.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200601142754.26139-1-l.stelmach@samsung.com> MIME-Version: 1.0 Organization: Samsung R&D Institute Poland X-Brightmail-Tracker: H4sIAAAAAAAAA02SeUgUYRjG+WZmZ8ettXGNetMOWpJIzQNLBhRR6Y+BEiSIIE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LG427mayONOda3Hz0ApGi02Pr7FaXN41h83i0NS9jBZrj9xlt3j44Aarxep/pxgtPkz4z2Tx Z/9PFovNm6YyO/B5XL52kdljdsNFFo+/q14weyzYVOqxaVUnm8eda3vYPN6dO8fusXlJvceE D2/ZPPq2rGL0+LxJLoA7Ss+mKL+0JFUhI7+4xFYp2tDCSM/Q0kLPyMRSz9DYPNbKyFRJ384m JTUnsyy1SN8uQS+jddJDtoK70hXtt9YwNTAeEeti5OSQEDCRmPfvOmsXIxeHkMBSRonOiweY uhg5gBJSEivnpkPUCEv8udbFBlHzlFHiyfleRpAEm4CjRP/SE2DNIgJ/mSQOzjoNVsUscI1R YuOEk8wgVcICZhIHfxxhAbFZBFQlVnxsYwexeQWsJa5Mvc4EsUJeon35djYQm1PARuLA6U9g cSGgmvfTupkg6gUlTs58wgJyHbOAusT6eUIgYX4BLYk1TdfBxjMDjWneOpt5AqPQLCQdsxA6 ZiGpWsDIvIpRJLW0ODc9t9hQrzgxt7g0L10vOT93EyMwrrcd+7l5B+OljcGHGAU4GJV4eDfc vxInxJpYVlyZe4hRgoNZSYTX6ezpOCHelMTKqtSi/Pii0pzU4kOMpkBvTmSWEk3OB6acvJJ4 Q1NDcwtLQ3Njc2MzCyVx3g6BgzFCAumJJanZqakFqUUwfUwcnFINjNmft/xgM3plYHMzq99D X7gtMpHF8G3WRRGuF7HFSrMXmebO3e0qdS79/xkL12X8a64GS/7U0n9za68K26G1Sxeyczml zZVIz5TZ3mP0YM6ySR+uTZTT4DBe9iW/KqggQOLvrOB7uVPjornWReZ4xnxhWye/6Lf4Rs66 9+dPrimyOHjQ5cPqRCWW4oxEQy3mouJEAGmHb9wBAwAA X-CMS-MailID: 20200601142810eucas1p23056f7997a880ff7d676c64703f87115 X-Msg-Generator: CA X-RootMTR: 20200601142810eucas1p23056f7997a880ff7d676c64703f87115 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200601142810eucas1p23056f7997a880ff7d676c64703f87115 References: <20200601142754.26139-1-l.stelmach@samsung.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200601_072813_682791_B83A05A7 X-CRM114-Status: GOOD ( 16.91 ) X-Spam-Score: -5.2 (-----) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (-5.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -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 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [210.118.77.11 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_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -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.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High 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: AKASHI Takahiro , Marek Szyprowski , =?utf-8?q?=C5=81ukasz_Stelmach?= , 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 | 48 ++++++++++++++++++++++++++ 3 files changed, 53 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 dcc1afa60fb9..97e4cfcfc197 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" @@ -211,7 +212,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 f82b5962d97e..308e9cd6a897 100644 --- a/arch/arm/boot/compressed/vmlinux.lds.S +++ b/arch/arm/boot/compressed/vmlinux.lds.S @@ -3,14 +3,7 @@ * Copyright (C) 2000 Russell King */ -#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) @@ -43,7 +36,7 @@ SECTIONS .table : ALIGN(4) { _table_start = .; LONG(ZIMAGE_MAGIC(4)) - LONG(ZIMAGE_MAGIC(0x5a534c4b)) + LONG(ARM_ZIMAGE_MAGIC3) LONG(ZIMAGE_MAGIC(__piggy_size_addr - _start)) LONG(ZIMAGE_MAGIC(_kernel_bss_size)) LONG(0) @@ -107,7 +100,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..d5c18a0f6a34 --- /dev/null +++ b/arch/arm/include/asm/image.h @@ -0,0 +1,48 @@ +/* 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; + } krnl_size; + } u; +}; + +#endif /* __ASSEMBLY__ */ + +#endif /* __ASM_IMAGE_H */ From patchwork Mon Jun 1 14:27:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lukasz Stelmach X-Patchwork-Id: 11582111 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 2D4A5913 for ; Mon, 1 Jun 2020 14:28:41 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id EE38F207D5 for ; Mon, 1 Jun 2020 14:28:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="DS6iMPKt"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="X9eEGfRP" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EE38F207D5 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=bombadil.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=1UaZY8b9yL5rXgfHGOCEirKbFcFUuKgvks0LQpGVMY4=; b=DS6iMPKtZKKUtw HS2nneVAFRyBDOhz5bbfjVtHlg3orI263glZuvTPc3dqRNGM+wop2lnl4jjOgSX0/vqfrbia0rFiq SlZy7fGLLyKzcL65E60TR40+BBVcXB9aH3vMnJ7Qchn+Kflpx/Fh0Ci4dx+zWSah+FbRV7YnRu/a+ +h2Vjc38XCH2CGrGOI5TxPJ2s7IePid6aMfoqCF1rQwzEKdz4xDirC8I77vB6Ws/PGk3MUIZtEw2T eou/5Fhj+zury9AtwQoTHT/vCAbDsacIdT6EUbhZJnVDpeOsQaean6WLQc2tq+IeWvUFoqG1Ku0lT L0k/0AGp1K97G1fUIEzA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jflQc-0003mz-7t; Mon, 01 Jun 2020 14:28:38 +0000 Received: from mailout1.w1.samsung.com ([210.118.77.11]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jflQD-0003NC-GS for linux-arm-kernel@lists.infradead.org; Mon, 01 Jun 2020 14:28:15 +0000 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20200601142811euoutp01fc63ff13e863234135dd08421c7aa29f~UccySYzhc1116311163euoutp01D for ; Mon, 1 Jun 2020 14:28:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20200601142811euoutp01fc63ff13e863234135dd08421c7aa29f~UccySYzhc1116311163euoutp01D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1591021691; bh=rwNNoUfHAlfOFwGSbUnF9y1UjfDAKssjoju9RRF8YRM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X9eEGfRPZcG2kCvQcz7lT69EaWrGY0YPQHYbpn58OrhQtM0CHyNzCkZFz2n/d3fX+ giZ6SlLaUlzT5dvfPlYO32S+eimIjHHgSEkKxmhVRB6MX5tDk1sfcpYd5MNoLsDRB6 P74Igb0ezk8RitetRC9W/2j7TnqBhj3Z0g97EvmU= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20200601142811eucas1p19d9d09310828c63300aced6648478161~Uccx_VV5D2462024620eucas1p1q; Mon, 1 Jun 2020 14:28:11 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id FD.EA.61286.B7015DE5; Mon, 1 Jun 2020 15:28:11 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20200601142810eucas1p1c42ff7c9b417f04bc506261726f08b4f~UccxZuO9D1329813298eucas1p1J; Mon, 1 Jun 2020 14:28:10 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20200601142810eusmtrp2836859b3e71da49eeb63b847b58a20e2~UccxZFHZg1485714857eusmtrp2L; Mon, 1 Jun 2020 14:28:10 +0000 (GMT) X-AuditID: cbfec7f2-ef1ff7000001ef66-bd-5ed5107b5dee Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 66.52.08375.A7015DE5; Mon, 1 Jun 2020 15:28:10 +0100 (BST) Received: from localhost (unknown [106.120.51.46]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20200601142810eusmtip278d346ce7de36b7c07a496fd7763cb63~UccxP_TsM2559325593eusmtip2g; Mon, 1 Jun 2020 14:28:10 +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 Subject: [PATCH 3/5] arm: decompressor: define a new zImage tag Date: Mon, 1 Jun 2020 16:27:52 +0200 Message-Id: <20200601142754.26139-4-l.stelmach@samsung.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200601142754.26139-1-l.stelmach@samsung.com> MIME-Version: 1.0 Organization: Samsung R&D Institute Poland X-Brightmail-Tracker: H4sIAAAAAAAAA01Sa0hTYRjm29nOjsvp5xJ80zJYFiRlShEHNMsIOl3oAv4SUk95Usvp2Fxm Rl6CLMtck3XZkqwsTfM2TXMp6kitNMN0amWUZFSrRLxghrncjlL/nu99nud9nhc+ipC9E3lT 8YnJnCqRTZCTEmFd+8yr9WnYGhk4et6Lrr5eKaJ1FS0C+k3mEwHddVFBv7GUINr0qV9E95pv krRF34To8qfvxfTwx0ERXTb3AtFjWruAnm2eEdI1Jj2xzY3p7e8hGGNGj5D5U/qVYApNGs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uQS/jzav/jAWzBCuOvprJ2sD4nbeLkZNDQsBE4taxPSxdjFwcQgJLGSUaN28G cjiAElISK+emQ9QIS/y51sUGUfOUUWLet73sIAk2AUeJ/qUnWEESIgJ/mSQOzjoNVsUscI1R YuOEk8wgk4QF7CV2LisFaWARUJXomr6QFcTmFbCW+LJxDyPEBnmJ9uXb2UBsTgEbiQOnPzGB 2EJANe+ndTNB1AtKnJz5BOw4ZgF1ifXzhEDC/AJaEmuarrOA2MxAY5q3zmaewCg0C0nHLISO WUiqFjAyr2IUSS0tzk3PLTbUK07MLS7NS9dLzs/dxAiM6m3Hfm7ewXhpY/AhRgEORiUe3g33 r8QJsSaWFVfmHmKU4GBWEuF1Ons6Tog3JbGyKrUoP76oNCe1+BCjKdCbE5mlRJPzgQknryTe 0NTQ3MLS0NzY3NjMQkmct0PgYIyQQHpiSWp2ampBahFMHxMHp1QDY9dV3XTBXQwLPl+/yPzh R8RJ5hbuYP3jnxoK41+tvn3JrFo5teaz4ZsgRdd17Et2fw34EZf67OK2BRUHK+zly3k2MyRo Mb8PXqhw2d7u1LmdfpV+d4PTbzUp6b5m+/NM5dbe8/uU1s96ZVS75GmksbtvVuqP6yZ/TwlE eC94sbf1/ImlEYc9RJRYijMSDbWYi4oTAVQLUIkAAwAA X-CMS-MailID: 20200601142810eucas1p1c42ff7c9b417f04bc506261726f08b4f X-Msg-Generator: CA X-RootMTR: 20200601142810eucas1p1c42ff7c9b417f04bc506261726f08b4f X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200601142810eucas1p1c42ff7c9b417f04bc506261726f08b4f References: <20200601142754.26139-1-l.stelmach@samsung.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200601_072813_679290_B5DDD2D6 X-CRM114-Status: GOOD ( 14.18 ) X-Spam-Score: -5.2 (-----) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (-5.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -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 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [210.118.77.11 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_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -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.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High 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: AKASHI Takahiro , Marek Szyprowski , =?utf-8?q?=C5=81ukasz_Stelmach?= , 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 | 13 +++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/arch/arm/boot/compressed/vmlinux.lds.S b/arch/arm/boot/compressed/vmlinux.lds.S index 308e9cd6a897..dcfdb3209c90 100644 --- a/arch/arm/boot/compressed/vmlinux.lds.S +++ b/arch/arm/boot/compressed/vmlinux.lds.S @@ -39,6 +39,11 @@ SECTIONS LONG(ARM_ZIMAGE_MAGIC3) LONG(ZIMAGE_MAGIC(__piggy_size_addr - _start)) LONG(ZIMAGE_MAGIC(_kernel_bss_size)) + LONG(ZIMAGE_MAGIC(5)) + LONG(ARM_ZIMAGE_MAGIC4) + LONG(ZIMAGE_MAGIC(_end - __bss_start)) + LONG(ZIMAGE_MAGIC(_stack_end - _stack_start)) + LONG(ZIMAGE_MAGIC(_malloc_size)) LONG(0) _table_end = .; } @@ -108,10 +113,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 d5c18a0f6a34..624438740f23 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__ @@ -43,6 +44,18 @@ struct arm_zimage_tag { } u; }; +struct arm_zimage_tag_dc { + struct tag_header hdr; + union { +#define ZIMAGE_TAG_DECOMP_SIZE ARM_ZIMAGE_MAGIC4 + struct zimage_decomp_size { + __le32 bss_size; + __le32 stack_size; + __le32 malloc_size; + } decomp_size; + } u; +}; + #endif /* __ASSEMBLY__ */ #endif /* __ASM_IMAGE_H */ From patchwork Mon Jun 1 14:27:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lukasz Stelmach X-Patchwork-Id: 11582115 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 CE86C90 for ; Mon, 1 Jun 2020 14:29:21 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id AB7A92068D for ; Mon, 1 Jun 2020 14:29:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="h6h5eAGd"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="IkI6ksKV" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AB7A92068D 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=bombadil.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=NEA4irg6svT38n743yn55aUrF8PpQti3i6xBLl9iPB0=; b=h6h5eAGdtBuOW+ vYtboCM/8O4WcrcOmaOLt+chwQ261gEFdunSXhMwsZ/rBEfSmJ6zoX50iusoCJsQUtjVo1CHUDeOr vTDRgqln6Q67SKX379RVtI5404HC/NXRA/rh2VaiiXR0vK14MhmhVRY1FD+pco0LFbWq8vjDGNi1W 003fMdv0015DPQO9XPZ1Uaf1wiGOvngNKJhrjI2noeKtSjwmIOn+NEBnKI6QhbaC4U4R4zCDBv3sK KQEpr49XeOQP/IjNxuSLUpZrL6AyOGDAJa/YioUdorvDP70KzguC2xImPzZfPm/jh7mP0Uc9xcmqB 2DzObtc6eLtJWTz/FBnA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jflR9-0004GZ-LP; Mon, 01 Jun 2020 14:29:11 +0000 Received: from mailout2.w1.samsung.com ([210.118.77.12]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jflQD-0003NS-Jz for linux-arm-kernel@lists.infradead.org; Mon, 01 Jun 2020 14:28:15 +0000 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20200601142812euoutp02591c29cb95574f0b166447e51bbf9074~UccyeaVg42486424864euoutp02n for ; Mon, 1 Jun 2020 14:28:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20200601142812euoutp02591c29cb95574f0b166447e51bbf9074~UccyeaVg42486424864euoutp02n DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1591021692; bh=HFutmAJ4iU4eRu//A59XEGsqCOlB4bks5rPsSUwsxYM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IkI6ksKVUMLdTpX2UzR8W8GeY2bTkRn18ozcd8UtJqBpRpjJ9zbzlXyYkMRDFgoRy ZNvpquAECy1TyPOrzO1L54Yaps4K6tBuydayoWC7IhXRyHuSQp4EczQcxdQ3wTF2qh GrumXYYJoyTUA2P2QVLP91dvzwfngL66X6YjKHKo= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20200601142811eucas1p19d39e7d97706e1a427081585d8f5e430~UccyKSk7P2463924639eucas1p1t; Mon, 1 Jun 2020 14:28:11 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id EE.EA.61286.B7015DE5; Mon, 1 Jun 2020 15:28:11 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20200601142811eucas1p260e5a434ea7743eecdb37c4d975c5f05~Uccxwp9c62609926099eucas1p2R; Mon, 1 Jun 2020 14:28:11 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20200601142811eusmtrp11c12ae0e99e01cf8f1af56f48ad46e53~UccxwBku83017330173eusmtrp1j; Mon, 1 Jun 2020 14:28:11 +0000 (GMT) X-AuditID: cbfec7f2-f0bff7000001ef66-be-5ed5107b54dd Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 42.FB.07950.B7015DE5; Mon, 1 Jun 2020 15:28:11 +0100 (BST) Received: from localhost (unknown [106.120.51.46]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20200601142811eusmtip14e43cd3fa12be09844c167c5a24c91ac~UccxjpZJT1573515735eusmtip1l; Mon, 1 Jun 2020 14:28:10 +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 Subject: [PATCH 4/5] arm: Add kexec_image_info Date: Mon, 1 Jun 2020 16:27:53 +0200 Message-Id: <20200601142754.26139-5-l.stelmach@samsung.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200601142754.26139-1-l.stelmach@samsung.com> MIME-Version: 1.0 Organization: Samsung R&D Institute Poland X-Brightmail-Tracker: H4sIAAAAAAAAA02SWUwTURSGvZ3pMKCtQyHxWIyaqomgglvMJIAR8GEiPPDkg8ZClWGTtqQj KPpAcUP2CqmUJUBcAqkIUhEJS8BicKk0UW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ou1R+6yWzx8cIPVYvW/U4wWHyb8Z7L4 s/8ni8XmTVOZHfg8Ll+7yOwxu+Eii8ffVS+YPRZsKvXYtKqTzePOtT1sHu/OnWP32Lyk3mPC h7dsHn1bVjF6fN4kF8AdpWdTlF9akqqQkV9cYqsUbWhhpGdoaaFnZGKpZ2hsHmtlZKqkb2eT kpqTWZZapG+XoJfx/FZ8wUS+iiMPb7E0MB7k7mLk5JAQMJF4f/ktG4gtJLCUUeLuPs0uRg6g uJTEyrnpECXCEn+udUGVPGWUODYlB8RmE3CU6F96grWLkYtDROAvk8TBWafZQBxmgWuMEhsn nGQGqRIW0JP43nkOzGYRUJVob9zLCGLzClhLTH03jRlig7xE+/LtYBs4BWwkDpz+xASxzVri /bRuJoh6QYmTM5+wgBzHLKAusX6eEEiYX0BLYk3TdRYQmxloTPPW2cwTGIVmIemYhdAxC0nV AkbmVYwiqaXFuem5xUZ6xYm5xaV56XrJ+bmbGIERve3Yzy07GLveBR9iFOBgVOLh3XD/SpwQ a2JZcWXuIUYJDmYlEV6ns6fjhHhTEiurUovy44tKc1KLDzGaAr05kVlKNDkfmGzySuINTQ3N LSwNzY3Njc0slMR5OwQOxggJpCeWpGanphakFsH0MXFwSjUwZkxf3vlL33YJc/jG6E0xLRWv V+wONn0V6rTKXMrIcEFruJT2+SY+3/y7p229DlQ02wsm1yvtC7mqYqVWIzXnUJizsdnnqf08 MivVX2SE5G67ZrO7Ym6BcNzfhItiU0u+q7wsjRP542XFWKv0m2lC+M2W3gU+287/D298cCmU 0//p/uu3xauVWIozEg21mIuKEwGpgaMp/gIAAA== X-CMS-MailID: 20200601142811eucas1p260e5a434ea7743eecdb37c4d975c5f05 X-Msg-Generator: CA X-RootMTR: 20200601142811eucas1p260e5a434ea7743eecdb37c4d975c5f05 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200601142811eucas1p260e5a434ea7743eecdb37c4d975c5f05 References: <20200601142754.26139-1-l.stelmach@samsung.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200601_072813_794626_DA329910 X-CRM114-Status: GOOD ( 13.70 ) X-Spam-Score: -5.2 (-----) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (-5.2 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_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -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.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High 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: AKASHI Takahiro , Marek Szyprowski , =?utf-8?q?=C5=81ukasz_Stelmach?= , 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 76300f3813e8..c10a2dfd53d1 100644 --- a/arch/arm/kernel/machine_kexec.c +++ b/arch/arm/kernel/machine_kexec.c @@ -31,6 +31,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. @@ -42,6 +68,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 Mon Jun 1 14:27:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lukasz Stelmach X-Patchwork-Id: 11582117 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 493BF913 for ; Mon, 1 Jun 2020 14:29:45 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 224F72068D for ; Mon, 1 Jun 2020 14:29:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="hpAkfq9y"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="NxOgmo5l" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 224F72068D 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=bombadil.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=izVxW28unQEfmraxmHwIHJFCPFt/tE6vb6+enPtnYUU=; b=hpAkfq9y7H+Dj+ 0Yy9arWosBYNr/8m4vIhZS2GA0OJbpP4mq1Y6iJfULjcSSmjkoxZI7bqGrRyzps7dRiMPcP1ofrGd bz6CKR9/lOUzmGLnDUDz8k2TCJATm+2z6VeC0q0J2/YnRUsjkYBMlgXqzVVmgehA8USvRbSWB7u18 rnFy3bIo2IwTFhwAxIrV/O9YQXTm/VcedNFa7E8HN0N8Fw/fWFAOD9oM9JviCbvTE7pAaABzFJNlB ZiBKzYlmans0ieD5h6os+bg8HDlVmdqk8CTQzGDS9NdypiVniM1WOhHAkLV/+VK8QfCx8hI1heBQB 9FYCfnIWUQMRJ8KD+UaA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jflRY-0004c8-3H; Mon, 01 Jun 2020 14:29:36 +0000 Received: from mailout2.w1.samsung.com ([210.118.77.12]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jflQD-0003NU-SP for linux-arm-kernel@lists.infradead.org; Mon, 01 Jun 2020 14:28:17 +0000 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20200601142812euoutp02627ee5251bf159c7d848309190a59993~UccylZ5sf2486824868euoutp02p for ; Mon, 1 Jun 2020 14:28:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20200601142812euoutp02627ee5251bf159c7d848309190a59993~UccylZ5sf2486824868euoutp02p DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1591021692; bh=W1N0pk+zwBpYOwOEoTj035sNHYsI+JRLIt8m73+L2QA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NxOgmo5l6KH+BlcTdKT9jtRcRDzyoS+l8jVjqZX+44PUCVV0lmGBCWZKG7SiFtUsA s6pFG2SNRQXK6idAXQtZHL6Z6h4qFfvXu0g3Y1v8sfPVVmooCE2LWt+IF/Q4LWnJ8I AUbhL4eoC5OisqIL59kUYCte+H4qCNMtcs7z5PR4= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20200601142811eucas1p2cfb8d4a2932683df1904664cb20905bd~UccyVyu-51927019270eucas1p2h; Mon, 1 Jun 2020 14:28:11 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 6F.6D.60698.B7015DE5; Mon, 1 Jun 2020 15:28:11 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20200601142811eucas1p1604c8e6ca06c09f1ec821ea5e1918c53~UccyCywhV2463924639eucas1p1s; Mon, 1 Jun 2020 14:28:11 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20200601142811eusmtrp124c99c66d75d0868cf5e64e0be948c7b~UccyB7wtx3017330173eusmtrp1k; Mon, 1 Jun 2020 14:28:11 +0000 (GMT) X-AuditID: cbfec7f5-a29ff7000001ed1a-e3-5ed5107b84ac Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 53.FB.07950.B7015DE5; Mon, 1 Jun 2020 15:28:11 +0100 (BST) Received: from localhost (unknown [106.120.51.46]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20200601142811eusmtip150f76db6f64f8a7d964f5310398f8b42~Uccx3HTOv1539715397eusmtip1n; Mon, 1 Jun 2020 14:28:11 +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 Subject: [PATCH 5/5] arm: kexec_file: load zImage or uImage, initrd and dtb Date: Mon, 1 Jun 2020 16:27:54 +0200 Message-Id: <20200601142754.26139-6-l.stelmach@samsung.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200601142754.26139-1-l.stelmach@samsung.com> MIME-Version: 1.0 Organization: Samsung R&D Institute Poland X-Brightmail-Tracker: H4sIAAAAAAAAA02Sa0hTYRjHe89tR2t2nIZPFoZDSYW0WNkBpbQLnArKL32JspYdTNwsdrKy m1rmvfKCadsgSa1ly3TqKrOUlZotl2KZ0dVUSlEJS7p5ye0o+e3/PM/v//zfB14al30gPemY uCO8Jk6pklPOhLn594sVJ5lXkSuNTQq2qugOyeZVNGLsm+QHGPs8S82+sRgQa+rtItnOOj3F WgoeIvb2k/cStudTN8nemnyG2G85Uxg73vCbYKtNBXiYC9fZ1YFzuqQOgpso/4pzxaZ4zlSe QXHvuuopbsRmk3DVpYlczrdhirtYU4647yaviPm7nEM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/5VNTAeqOli5OSQEDCRWDPzAhuILSSwlFFiyhLrLkYO oLiUxMq56RAlwhJ/rnVBlTxllLi0wR7EZhNwlOhfeoK1i5GLQ0TgL5PEwVmn2UAcZoFrjBIb J5xkBqkSFvCW6Fy8DqybRUBVYtbEyawgNq+AtcTOfQuYITbIS7Qv3w5WwylgI3Hg9CcmiG3W Eu+ndTNB1AtKnJz5hAXkOGYBdYn184RAwvwCWhJrmq6zgNjMQGOat85mnsAoNAtJxyyEjllI qhYwMq9iFEktLc5Nzy020itOzC0uzUvXS87P3cQIjOltx35u2cHY9S74EKMAB6MSD++G+1fi hFgTy4orcw8xSnAwK4nwOp09HSfEm5JYWZValB9fVJqTWnyI0RTozYnMUqLJ+cB0k1cSb2hq aG5haWhubG5sZqEkztshcDBGSCA9sSQ1OzW1ILUIpo+Jg1OqgbGMZ/qyvdceq/oUP7I5wnDk dGvoOd3gOV5WdkGhz5QsDp/6ZPevyXtbun522ked9ytebE6bZP1Z+E9L9Qv3wtXrfR6afVas ELz24Viv5I93G+a1TeHk3KIhn5ZTn23mY8+90kov4piP6eIsxp6Pb1nVltQ9dMtw091zcafa mX8e1YerOS28LymxFGckGmoxFxUnAgDYjMeB/wIAAA== X-CMS-MailID: 20200601142811eucas1p1604c8e6ca06c09f1ec821ea5e1918c53 X-Msg-Generator: CA X-RootMTR: 20200601142811eucas1p1604c8e6ca06c09f1ec821ea5e1918c53 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200601142811eucas1p1604c8e6ca06c09f1ec821ea5e1918c53 References: <20200601142754.26139-1-l.stelmach@samsung.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200601_072814_199695_8A557FD9 X-CRM114-Status: GOOD ( 24.56 ) X-Spam-Score: -5.2 (-----) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (-5.2 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_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -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.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High 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: AKASHI Takahiro , Marek Szyprowski , =?utf-8?q?=C5=81ukasz_Stelmach?= , 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 | 15 ++ arch/arm/include/asm/image.h | 26 ++++ arch/arm/include/asm/kexec.h | 14 ++ arch/arm/kernel/Makefile | 5 +- arch/arm/kernel/kexec_uimage.c | 80 ++++++++++ arch/arm/kernel/kexec_zimage.c | 199 +++++++++++++++++++++++++ arch/arm/kernel/machine_kexec.c | 11 +- arch/arm/kernel/machine_kexec_file.c | 209 +++++++++++++++++++++++++++ 8 files changed, 554 insertions(+), 5 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 c77c93c485a0..6adb849cb304 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -1917,6 +1917,21 @@ 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 USE_OF + select KEXEC_CORE + select CRC32 + help + This is 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 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 624438740f23..95f23837b04f 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..fda35afa7195 100644 --- a/arch/arm/include/asm/kexec.h +++ b/arch/arm/include/asm/kexec.h @@ -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..466c683bb551 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 \ + 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..d09795fc9072 --- /dev/null +++ b/arch/arm/kernel/kexec_zimage.c @@ -0,0 +1,199 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Kexec zImage loader + * + * Copyright (C) 2020 Samsung Electronics + * Author: Łukasz Stelmach + */ + +#define pr_fmt(fmt) "kexec_file(zImage): " fmt + +#include +#include +#include +#include +#include + +#define byte_size(t) ((t)->hdr.size << 2) + +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 *klsz_tag; + const struct arm_zimage_tag_dc *dcsz_tag; + int ret = -EINVAL; + + unsigned long zimage_mem = 0x20000; /* malloc 64kB + stack 4 kB + some bss */ + unsigned long kernel_len = zimage_len * 4; /* 4:1 compression */ + unsigned long kernel_offset = memblock_start_of_DRAM() + + ALIGN(TEXT_OFFSET, PAGE_SIZE); + 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; + + klsz_tag = find_extension_tag(zimage, zimage_len, ZIMAGE_TAG_KRNL_SIZE); + if (klsz_tag) { + uint32_t *p = (void *)zimage + + le32_to_cpu(klsz_tag->u.krnl_size.size_ptr); + uint32_t edata_size = le32_to_cpu(get_unaligned(p)); + uint32_t bss_size = le32_to_cpu(klsz_tag->u.krnl_size.bss_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(); + } + + dcsz_tag = find_extension_tag(zimage, zimage_len, + ZIMAGE_TAG_DECOMP_SIZE); + if (dcsz_tag) { + uint32_t bss_size = le32_to_cpu(dcsz_tag->u.decomp_size.bss_size); + uint32_t stack_size = le32_to_cpu(dcsz_tag->u.decomp_size.stack_size); + uint32_t malloc_size = le32_to_cpu(dcsz_tag->u.decomp_size.malloc_size); + + zimage_mem = bss_size + stack_size + malloc_size; + + pr_debug("Decompressor memory requirements:\n"); + pr_debug(" bss 0x%08lx stack 0x%08lx malloc 0x%08lx total 0x%08lx\n", + (unsigned long)bss_size, + (unsigned long)stack_size, + (unsigned long)malloc_size, + zimage_mem); + + initrd_offset = max(ALIGN(zimage_offset + zimage_len + + bss_size + stack_size + + malloc_size, 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 c10a2dfd53d1..2e4780efabb4 100644 --- a/arch/arm/kernel/machine_kexec.c +++ b/arch/arm/kernel/machine_kexec.c @@ -93,10 +93,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..ead680f1e795 --- /dev/null +++ b/arch/arm/kernel/machine_kexec_file.c @@ -0,0 +1,209 @@ +// 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[] = { + &kexec_uimage_ops, + &kexec_zimage_ops, + NULL +};