From patchwork Thu Sep 14 02:00:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Song Shuai X-Patchwork-Id: 13955 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp59232vqi; Wed, 13 Sep 2023 19:11:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG/lHb1qb3AbACnYRAlp9DhS38Ca3bd3d1D25Ko4MZIQaR13fmFvHgXbS3i4D7iLO/yhUnq X-Received: by 2002:a05:6a20:6a0b:b0:153:b245:50ff with SMTP id p11-20020a056a206a0b00b00153b24550ffmr4630158pzk.40.1694657511117; Wed, 13 Sep 2023 19:11:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694657511; cv=none; d=google.com; s=arc-20160816; b=iPuud7HLNuo8xibkAnc9XcZBMyNoO45pr0iD0jTAO0QW3RBHPRk0qzex9RoZWw+eJB 8Q/V3eRx/1cFQfKC/c5pTE3IMtvPFllwbtWOnn6zAud/i/2JAPM/PMl/3MzrM7q/+tBy w+NqBDR3OJhWu52Jw+VyBuRZSOxglvyJQ1ohuIzTM81MeOzeYEAJ+cEUq/nQawbJ/Ig9 22jyPm1oR2KpBjSnUJPWybSRFCgSMYUgbGDXlJpo7KEhzDAlYt2i4eh8OI9K3xVvg46Y PB1Pn176j8XLucL2Itx2T+9JPdxV0m3OGjre1o0RWqf1m0ipteGUk+QcGrLS7UE4FLzL AMXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:feedback-id:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from; bh=ZpuTpdj1y1JqXxAy0zjGia6i+5pzXZMspoEYnVvzRcY=; fh=Kf2IcSxXu2lOC/ZqDfeaqJthEyoCZ+xmLKFwierCxZk=; b=KkOzKDMxiW9Yv08jQqWfIgrYPkfYOJ3EF2EgCC9qmgE0oMEm6WSmfPHhWW8qija1Ut Uh0YeLbeFsde8HNVGO5an12u+A9TxGdwFq9V0KDGWVMmBoVOG6nQN54UPsK368JjeW4e InEPa1qKYVzVJaWSn+ftOxmAbzUTybxaO3rZBf/3y9yMQQ2ooL2BnypbW3q7DyiQIxHj 0hi14GCvj7eKx1qxxx7SXzqbL4fF/pQ6IZtm695v8hZ8AYPuOvEcg83pZNRQyc9kFCu0 89kR4uHQniZ0I1kvwSvmZ9xKLSJWJdO3IIoqagx8PaT074ezIsojur7jklsZ8w2twKpy 3QMQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id iq24-20020a17090afb5800b002700bcdbff1si2675208pjb.154.2023.09.13.19.11.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 19:11:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id AB48980202D6; Wed, 13 Sep 2023 19:07:56 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234394AbjINCHo (ORCPT + 35 others); Wed, 13 Sep 2023 22:07:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233160AbjINCH1 (ORCPT ); Wed, 13 Sep 2023 22:07:27 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.154.54.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 163904EE7 for ; Wed, 13 Sep 2023 19:02:51 -0700 (PDT) X-QQ-mid: bizesmtp69t1694656877tkm2a5m8 Received: from localhost.localdomain ( [221.226.144.218]) by bizesmtp.qq.com (ESMTP) with id ; Thu, 14 Sep 2023 10:01:14 +0800 (CST) X-QQ-SSF: 01200000000000B0B000000A0000000 X-QQ-FEAT: bGXn9C6ahgSFte9kYhPmrslHZ6ZrQ+TnZx/ZE2jZlE4PHgLAwcln8WNX1+A1c C1vyx8Oc6uEVovocZqkT/MoY5qndYu4a3nXAuvHwIkpMYiG9X0AAbsoREF3pkmuVmZrqd8L uNTQf8tW/tMk0GWnAXrtgwUQYTJt95HkP+Xa3Gg0h8/htQEIs+TVLjB/lsHmh60DgcS4vVZ jdVdz1AVhprtauD5HgZbMWMhSm3yhlXzeX6QutZRtSojm2nZx9CFyRcTrPjERlyXUhTmLxa hUSuj4w9Nhsmm6+gsKn/evcMHtsgh7wqkNQKHuCmDBwb9Twfk0VMqUDF10BgCRGj7IvClFT oMPLmf1R2iasSXKV8QMAzN6zznWKw== X-QQ-GoodBg: 0 X-BIZMAIL-ID: 930282796024689414 From: Song Shuai To: paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, lihuafei1@huawei.com, conor.dooley@microchip.com, liaochang1@huawei.com, guoren@kernel.org, ajones@ventanamicro.com, alexghiti@rivosinc.com, evan@rivosinc.com, sunilvl@ventanamicro.com, xianting.tian@linux.alibaba.com, samitolvanen@google.com, masahiroy@kernel.org, apatel@ventanamicro.com, jszhang@kernel.org, duwe@suse.de, eric.devolder@oracle.com Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Song Shuai Subject: [PATCH 0/2] riscv: kexec_file: Support loading Image binary file Date: Thu, 14 Sep 2023 10:00:42 +0800 Message-Id: <20230914020044.1397356-1-songshuaishuai@tinylab.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrsz:qybglogicsvrsz4a-0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Wed, 13 Sep 2023 19:07:56 -0700 (PDT) X-Spam-Status: No, score=2.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: ** X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776977157853277056 X-GMAIL-MSGID: 1776977194632476875 Hi, This series makes the kexec_file_load() syscall support to load Image binary file. At the same time, corresponding support for kexec-tools had been pushed to my repo[1]. Now, we can leverage that kexec-tools and this series to use the kexec_load() or kexec_file_load() syscall to boot both vmlinux and Image file, as seen in these combo tests: ``` 1. kexec -l vmlinux [other options] // or boot paniced kernel with -p 2. kexec -l Image 3. kexec -s -l vmlinux 4. kexec -s -l Image ``` Though all of the aforementioned tests had been passed in my RV64 Qemu-virt, it should be noted that tests 3 and 4 should be the emphasis for the current series. [1]: https://github.com/sugarfillet/kexec-tools/commits/rv-Image Song Shuai (2): riscv: kexec_file: Split the loading of kernel and others riscv: kexec_file: Support loading Image binary file arch/riscv/include/asm/image.h | 2 + arch/riscv/include/asm/kexec.h | 6 + arch/riscv/kernel/Makefile | 2 +- arch/riscv/kernel/elf_kexec.c | 469 ------------------------- arch/riscv/kernel/kexec_elf.c | 147 ++++++++ arch/riscv/kernel/kexec_image.c | 97 +++++ arch/riscv/kernel/machine_kexec_file.c | 8 + 7 files changed, 261 insertions(+), 470 deletions(-) delete mode 100644 arch/riscv/kernel/elf_kexec.c create mode 100644 arch/riscv/kernel/kexec_elf.c create mode 100644 arch/riscv/kernel/kexec_image.c