From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out30-98.freemail.mail.aliyun.com (out30-98.freemail.mail.aliyun.com [115.124.30.98]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 666373ED5CF for ; Tue, 24 Mar 2026 11:45:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.98 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774352740; cv=none; b=bWpFRoJsHgpHydNjV1B26kGMIKEYrVXpIn7oYNmcsm2O19Zh4mYOgx7ZkRseCMoQM5i0UGQFHE9PBvEthDjVfJd9NRnVDIberZRn6kJSu7pu0Ewk46UhvzQ+J6HjlwHyUEeHC6dh/PIUnxMv1jd3GlwktXho3t5B7yod1A/PC5k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774352740; c=relaxed/simple; bh=5fop8JN/PCKrJ5KmeB3exXeXR70soRPVVAhlTiRG178=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=Hqso0IDl+C2PQ19pliW2HFzBVhIxC6iMitXY+uGsHy5XDmZPKAbVK7Cd45gREavPk0JqhpxEIZ3LpVxKlpiw0P65laXVtjb9PgwHbqf8Ruda6XzXDBdKPl8oZd+P/yeH6f1UoEj67ypc2ol403plCBj6kPXOGCCdbUtkLcg/+Aw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=SV1OxRlu; arc=none smtp.client-ip=115.124.30.98 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="SV1OxRlu" DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1774352734; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=sYaekKiVbhvrlEXMmmW2ADmKnORVODY0c4WfQr6ka6I=; b=SV1OxRludLItCDzow3DpqbSqwjNgXuRCcagghDXhaKjlqjb19fbY06pSJNM0IaAeq+karhTzexcSaN1ihJbDX55dNXy1EEYJsbeev/t+/YvH/k6VsHSypEJ7LBlbOhnJO2sV9kS0mrFzpC6iWxsiJo6Vo3hyYLnxj9XTslJFtnE= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R521e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033045133197;MF=fangyu.yu@linux.alibaba.com;NM=1;PH=DS;RN=17;SR=0;TI=SMTPD_---0X.eWVEY_1774352731; Received: from localhost.localdomain(mailfrom:fangyu.yu@linux.alibaba.com fp:SMTPD_---0X.eWVEY_1774352731 cluster:ay36) by smtp.aliyun-inc.com; Tue, 24 Mar 2026 19:45:33 +0800 From: fangyu.yu@linux.alibaba.com To: pjw@kernel.org, palmer@dabbelt.com, aou@eecs.berkeley.edu, alex@ghiti.fr, songshuaishuai@tinylab.org, bjorn@rivosinc.com, ardb@kernel.org, arnd@arndb.de, bhelgaas@google.com, richard.lyu@suse.com, tzimmermann@suse.de, nathan@kernel.org Cc: guoren@kernel.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Fangyu Yu Subject: [PATCH 0/4] Add crashdump support in guest kernel Date: Tue, 24 Mar 2026 19:45:23 +0800 Message-Id: <20260324114527.91494-1-fangyu.yu@linux.alibaba.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Fangyu Yu In a RISC-V kernel, crashdump needs to hand off execution to the crash kernel after tearing down the current kernel address space. However, under virtualization the guest uses two-stage address translation, PC does not jump to stvec after setting satp to zero. This patch set introduces a dedicated kexec trampoline text section and builds a minimal trampoline page table for it. The crash handoff is then reworked into a two-pass trampoline: 1. First enter via the kernel VA, install the trampoline page table, and jump to the trampoline VA(=PA) of the norelocate code; 2. Continue execution with trampoline VA(=PA) and directly jump to the crash kernel entry point with jr, instead of depending on a stvec redirection. With this, crashdump in RISC-V guests becomes robust against the two-stage translation. Fangyu Yu (4): riscv: Add kexec trampoline text section to vmlinux.lds.S riscv: kexec: Place norelocate trampoline into .kexec.tramp.text riscv: kexec: Build trampoline page tables for crash kernel entry riscv: kexec: Switch to trampoline page table before norelocate arch/riscv/include/asm/kexec.h | 9 +++ arch/riscv/kernel/image-vars.h | 13 ++++ arch/riscv/kernel/kexec_relocate.S | 34 +++++++-- arch/riscv/kernel/machine_kexec.c | 116 ++++++++++++++++++++++++++++- arch/riscv/kernel/vmlinux.lds.S | 1 + 5 files changed, 166 insertions(+), 7 deletions(-) -- 2.50.1