From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 87090C5AC7A for ; Fri, 7 Aug 2026 10:37:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=T8eUR9MkUG60eJZwmCZAPZdUpIwjYHZLD8FcPW9hHxQ=; b=mMt8eyV6Mjzodu/cAU4dzYfKpv wHCbElkqPpskKzmDb50XHz7Et/10Gm1RgvanfZfEmGJhnBwrwePRFW+hfIq7edu9OhznzIdtpKJBR 8gtfCw4FyUgSYUbNXXR26HQ8GRPO8sAP3Uf6HDTTs5ubQRpzHVABfD5h5cW0KZGBfsdDwoHckWKXO h8Lt0ydppvl3PNEcKRayh34Mk5NqJMvgELXNOz/C9LM1DjOqDg8LIP3oZS1dakApwQM/M7scYnEAa iqVjVFL7IQudWbfcux4VvDtFS5PinTVj49wTsUv69/0aVbJX943y0AHkdEIQPH0WsG9jGFVb5jTWv mLU46rOw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wsHxS-00000007gnD-1uAo; Fri, 07 Aug 2026 10:37:46 +0000 Received: from out-183.mta1.migadu.com ([95.215.58.183]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1wsHxP-00000007glu-1gbY for kexec@lists.infradead.org; Fri, 07 Aug 2026 10:37:45 +0000 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1786099058; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=T8eUR9MkUG60eJZwmCZAPZdUpIwjYHZLD8FcPW9hHxQ=; b=WLPoKe7s1dubXiAmrOn/QUOvubfTBkfa0El+vYm0jaNP0r8ZVbkIgRUDAyINqUkRDJEe8Y J+HiF8MsfWjXy7RLn5mdtCbDGnmZAkDxiXBr0UnTbqUpb4vDFfLahzbrQ6g4KutgO4RYfY kn1sFGJtexHELzrKxrchUC6XOhAF4ms= From: George Guo To: chenhuacai@kernel.org, rppt@kernel.org, pasha.tatashin@soleen.com, pratyush@kernel.org, shuah@kernel.org, ardb@kernel.org Cc: guodongtai@kylinos.cn, kernel@xen0n.name, graf@amazon.com, loongarch@lists.linux.dev, linux-kernel@vger.kernel.org, kexec@lists.infradead.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-efi@vger.kernel.org Subject: [PATCH v4 0/4] LoongArch: add KHO support and selftests Date: Fri, 7 Aug 2026 18:37:10 +0800 Message-ID: <20260807103714.33074-1-dongtai.guo@linux.dev> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260807_033743_735965_E134A83F X-CRM114-Status: GOOD ( 17.42 ) X-BeenThere: kexec@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "kexec" Errors-To: kexec-bounces+kexec=archiver.kernel.org@lists.infradead.org This series enables Kexec Handover (KHO) on LoongArch, making it the third architecture (after x86 and arm64) to set ARCH_SUPPORTS_KEXEC_HANDOVER. That is the only remaining gate for Live Update (LUO) to run on LoongArch. The hard part is the transport: how the first kernel hands the KHO state (the KHO FDT and the scratch region) to the second kernel across kexec. Why not the command line or an FDT ---------------------------------- LoongArch boots from EFI, but unlike arm64 and riscv its efistub does not build a boot FDT. It passes the EFI system table and the command line straight to the core kernel [1]. There is no /chosen node to carry the blob, so the arm64 path (drivers/of/kexec.c:kho_add_chosen() writes linux,kho-fdt and linux,kho-scratch; drivers/of/fdt.c: early_init_dt_check_kho() reads them) does not apply. Two earlier transports were tried and rejected: * v1 put the handover addresses on the kernel command line. Pratyush found that odd and asked for a DT-based alternative. * v2/v3 synthesized an FDT and rewrote the DEVICE_TREE_GUID entry in the EFI config table so the generic FDT reader would find it. Pratyush called that "even more hacky" than the command line [2]. The v4 transport ---------------- v4 follows the x86 setup_data idea, in EFI terms. The first kernel packs the KHO state into a small struct (linux_efi_kho_data: fdt addr/size and scratch addr/size), appends a pointer to it under a dedicated LINUX_EFI_KHO_TABLE_GUID entry in a new EFI config table, loads both as kexec segments, and switches st->tables before jumping. The second kernel scans the config table for that GUID in setup_arch() and calls kho_populate() directly. This is the approach proposed in [3]. It addresses both objections: nothing is exposed on the command line, and no FDT is synthesized. It also meets Huacai's constraint: it reuses the EFI system table LoongArch already has, with no dependency on a boot FDT the efistub never creates. Patch layout ------------ Patches 1-2 implement the transport. Patch 1 adds the EFI config table GUID and the handover struct to include/linux/efi.h. It is split out so the EFI maintainers can review it on its own. Patch 2 wires up the LoongArch side: ARCH_SUPPORTS_KEXEC_HANDOVER, the write side in machine_kexec_file.c, the st->tables switch in machine_kexec(), and the reader in setup_arch(). Patch 3 is a build fix for kernel/liveupdate/luo_session.c that the series depends on under CONFIG_KFENCE=y on LoongArch. It was sent standalone as v2 and acked by Mike. It is folded in here at his request to send it along with this series [4]. Patch 4 adds LoongArch vmtest support to the KHO selftests and folds in the two points Mike raised on v3 (use "VM" instead of the ad-hoc "virt machine"; run every architecture under timeout(1), not only LoongArch). Patch 1 is aimed at the EFI tree. Patches 2-4 are aimed at the LoongArch and KHO trees. I expect the whole series to go through the KHO tree with Ard's and Huacai's acks. Changes since v3 ---------------- * Rework the transport: drop the synthesized FDT and the DEVICE_TREE_GUID rewrite. Pass the KHO state through a dedicated EFI configuration table GUID and call kho_populate() directly (patches 1, 2). * Fold in the luo_session build fix (previously standalone v2, acked by Mike) as patch 3, at his request. * selftests: address Mike's v3 review (use "VM"; always run under timeout(1)). * Rebase onto v7.2-rc6. [1] Huacai Chen: https://lore.kernel.org/r/CAAhV-H5B6Mj2-AffkstJ4f8EEmvvPOGXoDy2QNudKD2kSz2XkA@mail.gmail.com/ [2] Pratyush Yadav: https://lore.kernel.org/r/2vxzjyqzj8s2.fsf@kernel.org/ [3] https://lore.kernel.org/r/20260717071551.11904-1-dongtai.guo@linux.dev/ [4] Mike Rapoport: https://lore.kernel.org/r/ai5nYlbERQBXRHSp@kernel.org/ George Guo (4): efi: add a KHO configuration table GUID LoongArch: kexec: add KHO support liveupdate: luo_session: include linux/mm.h for virt/phys translation selftests/kho: add LoongArch vmtest support arch/loongarch/Kconfig | 3 + arch/loongarch/include/asm/kexec.h | 7 ++ arch/loongarch/kernel/machine_kexec.c | 16 +++ arch/loongarch/kernel/machine_kexec_file.c | 131 +++++++++++++++++++++ arch/loongarch/kernel/setup.c | 41 +++++++ include/linux/efi.h | 24 ++++ kernel/liveupdate/luo_session.c | 1 + tools/testing/selftests/kho/loongarch.conf | 11 ++ tools/testing/selftests/kho/vmtest.sh | 22 ++-- 9 files changed, 249 insertions(+), 7 deletions(-) create mode 100644 tools/testing/selftests/kho/loongarch.conf -- 2.53.0