From patchwork Mon Oct 16 09:20:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Song Shuai X-Patchwork-Id: 15412 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp3335526vqb; Mon, 16 Oct 2023 02:22:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFW36C1eR+SG4EbmQZP07drCKf4GCyznuQpgSP97FFmnRfO26yNtYMIFmPd0WDpzy6B9k36 X-Received: by 2002:a05:6808:2129:b0:3ae:5aab:a6fd with SMTP id r41-20020a056808212900b003ae5aaba6fdmr41832345oiw.5.1697448150228; Mon, 16 Oct 2023 02:22:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697448150; cv=none; d=google.com; s=arc-20160816; b=qT6qV3oGNlMly4cFSttaSMgiJwHGgByLgL222DgkJxQiVM2f1C1frM2Ba33UDyez/m njfpXDPY0GSmsTnIzeETZSd7hMExExx5dIGpkcQVwy5J7467KDEWskud/dDAU+zPJcAO tn7wWQ+b8qgB0/rFFynXrSq6KVvVj64VwxLS6IzKtjAiL4JSXQYKuf+WzPr43G3Y9buQ V/su+PuVmh6jJebLDEPA3G3Vxh5P5N1fKF2UBORdxm9YmJk6g6i02mqa92Y0lPNCKV46 5TOVD0TrLI9VCwzwsdNGyu+o22dgCmOOYCs+5ciS0mKcTEzV4hPuL7SzLL4XDK3WO2Fa U6uA== 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=gILCepbooPyh1KOuk/dcf75+P+AiSQ4n4Y3rgxL3Qoo=; fh=SaewcTEwcL86dt9r/yPasNDFvPUC8uPEOjfhiHlJhTk=; b=xBt77pJdU/iMITcDFWiJAwjq17QMpePpbGqUeN+Y6HHMACTsutcj6wpwyx8LeOAIUQ O/Fs1lvj+7HVIDtENqhYYPFUaHv76DFtaDerCNxkaHX0i8qcAdHNBxE6If/egQUCJW+W /mx2hpi1iZuILfhb+vE19kbDu7Bfjt6oiyKkvWnxBVkKlacNfRghoYqNltuCl+ykxqFe 1YACRWs2zjld1jE3oAzdHumXaAIQKVHIjMxcQXtq6AV/2jh7S0royModb7bjMJ3l3rSC XFJMYC92DKZh0T36K5aEXP6lt4rOHWz7trPAwrKgeKJpTISSvFDsNNrv38u/z7lZzpIM FpaA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id q24-20020a635c18000000b005a1d8816535si8152545pgb.5.2023.10.16.02.22.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 02:22:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (Postfix) with ESMTP id 633E18047E56; Mon, 16 Oct 2023 02:22:26 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232460AbjJPJWO (ORCPT + 18 others); Mon, 16 Oct 2023 05:22:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232508AbjJPJWM (ORCPT ); Mon, 16 Oct 2023 05:22:12 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.154.54.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4AD96E5 for ; Mon, 16 Oct 2023 02:22:09 -0700 (PDT) X-QQ-mid: bizesmtp85t1697448051t2qrh9s3 Received: from localhost.localdomain ( [58.240.82.166]) by bizesmtp.qq.com (ESMTP) with id ; Mon, 16 Oct 2023 17:20:49 +0800 (CST) X-QQ-SSF: 01200000000000B0B000000A0000000 X-QQ-FEAT: +ynUkgUhZJlVc3kFfT+1lBpfK0izFpSoNY1pnrylEBByyYspKiXE/AgA3x7Ls yC72wOYrvN3mhA1pzeSi1pVqISzz9CMx4sfMzginYyIsvBnTXdKa6MkD3cmbjEMDP2YAOIP PzCE9tIe8ANyTd1+A7kgPRnByublFgi3aqk67Y/pSRz+9/P8jMD0EMKp5MPizV48oZNU+z+ LWk1S3MIb/cpK9Mrmmbivt2C3Jno/PafxUxwOgoQ68hroRPBjGYoibZUXtz0TZcFJteCmZn WXuy1lLz40FSY5NT06iLkuxfd9c5NG5Sy2CzMQdyupSqRSZ8xoRcHiB9l38MOsVtx6/ORxd XFWPENX7QYjichTMVx1xTFsEOri2ZKKarEtlYA29kuG+AZ2+6ZTMBcV8btzkA== X-QQ-GoodBg: 0 X-BIZMAIL-ID: 2059464602555490170 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, emil.renner.berthing@canonical.com Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Song Shuai Subject: [PATCH V2 0/2] riscv: kexec_file: Support loading Image binary file Date: Mon, 16 Oct 2023 17:20:04 +0800 Message-Id: <20231016092006.3347632-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 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 fry.vger.email 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 (fry.vger.email [0.0.0.0]); Mon, 16 Oct 2023 02:22:26 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779903391853752340 X-GMAIL-MSGID: 1779903391853752340 Changes since V1: https://lore.kernel.org/linux-riscv/20230914020044.1397356-1-songshuaishuai@tinylab.org/ - Patch1: fix the build error due to the missing functions in machine_kexec_file.c - Patch2: use FIELD_GET() to get the flags's endianness as Emil proposed - Cover: update the kexec-tools link as this one[2] which is based on horms/kexec-tools main branch 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[2]. 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~~ [2]: https://github.com/sugarfillet/kexec-tools/commits/main_rv 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/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 | 98 ++++++ arch/riscv/kernel/machine_kexec_file.c | 344 ++++++++++++++++++ 6 files changed, 596 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