From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from m16.mail.163.com (m16.mail.163.com [220.197.31.2]) (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 63BC13DB313 for ; Wed, 1 Jul 2026 08:11:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=220.197.31.2 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782893497; cv=none; b=qO5LqChgQD7nyagkf5nNU7f8pJZtVfLAwSTUbSaAhd577Y0G8pX5EOwDQTm0///vK2keF0jFK8Mc3s+3AgceiCPlTjaJAP6cSrQGQRBCAkH36YYfWIswYd5EBbcxd5pvI/RvnhSx4QG/wlA3h+n1Ygl7f4l3Bdfqyi/Iocb2Ygw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782893497; c=relaxed/simple; bh=r3a0gcBQTZ6GyX1KkujQSC7evYyZaMc+qe5ZITThXZE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mYycdfgoVbeBLyBODjsn6Sk49GdJpvA8SHIOhqzh/FtDoIbRbvUpBDYQD0dehOpKhI0lVFoCrlYVrp46ft6CEisWHrYecWAzW6h02HiILVPfXM2mOi4L8gzP4rxiCZWyzFHkWzUyUqjmhL2M6p02PN64/Sa1oWC920n445mR6Os= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b=WX+oIeFz; arc=none smtp.client-ip=220.197.31.2 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b="WX+oIeFz" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=K2 X7FP2+XbaqjMe4yrmXcuX7vip8Xbbw8s+9bXwDLvE=; b=WX+oIeFzCjYNVBGhD6 8t30BmeaxmmdjcnmqaROR7I/s2zI9mP9t1YhomIJqdDHYZdibPCumBXCtX/jwQwJ rPRZQV1YAgPNe3FUzeDQ9saD1sPK4iaubrBUqVRr6jQxuHNFmmY7mwTj8P7vj+F9 +4LtGgzycWbE1tyQ84zaZZtTo= Received: from Ubuntu.. (unknown []) by gzsmtp4 (Coremail) with SMTP id PygvCgBHa+Z5y0Rqn4gyFA--.16458S4; Wed, 01 Jul 2026 16:10:36 +0800 (CST) From: Xiaofeng Yuan To: Paul Walmsley , Palmer Dabbelt , Albert Ou Cc: Charlie Jenkins , Nam Cao , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, xiaofengmian@163.com Subject: [PATCH v6 2/2] riscv: kprobes: add test case for c.jal instruction simulation Date: Wed, 1 Jul 2026 08:10:33 +0000 Message-ID: <20260701081033.49871-3-xiaofengmian@163.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260701081033.49871-1-xiaofengmian@163.com> References: <20260701081033.49871-1-xiaofengmian@163.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID:PygvCgBHa+Z5y0Rqn4gyFA--.16458S4 X-Coremail-Antispam: 1Uf129KBjvJXoW7Kw1kWrWDur17XFyxtFWkJFb_yoW8uF1DpF nrJr15KFW8Jas3Jry3WF1rAryFya1kA3yagr1DZr4rCr48Gw12yr9FgFWDtFnrKrWFv3yS vry8WrWxKF9xZFDanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0zioqcUUUUUU= X-CM-SenderInfo: p0ld0w5hqjzxldq6il2tof0z/xtbDAhy9wGpEy3xwqAAA3i From: Nam Cao Add a test case validating that kprobes correctly simulates the c.jal instruction on RV32. The test uses two probe points: a forward c.jal and a backward c.jal, and verifies that the containing function returns the expected magic value KPROBE_TEST_MAGIC after kprobe interception. Co-developed-by: Xiaofeng Yuan Signed-off-by: Nam Cao Signed-off-by: Xiaofeng Yuan --- .../kernel/tests/kprobes/test-kprobes-asm.S | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/arch/riscv/kernel/tests/kprobes/test-kprobes-asm.S b/arch/riscv/kernel/tests/kprobes/test-kprobes-asm.S index f16deee9e..15e50934b 100644 --- a/arch/riscv/kernel/tests/kprobes/test-kprobes-asm.S +++ b/arch/riscv/kernel/tests/kprobes/test-kprobes-asm.S @@ -179,6 +179,23 @@ test_kprobes_c_bnez_addr3: ret SYM_FUNC_END(test_kprobes_c_bnez) +#ifdef CONFIG_32BIT +SYM_FUNC_START(test_kprobes_c_jal) + li a0, 0 + mv a1, ra +test_kprobes_c_jal_addr1: + c.jal 2f + ret +1: li a0, KPROBE_TEST_MAGIC_UPPER + ret +test_kprobes_c_jal_addr2: +2: c.jal 1b + li a2, KPROBE_TEST_MAGIC_LOWER + add a0, a0, a2 + jr a1 +SYM_FUNC_END(test_kprobes_c_jal) +#endif + #endif /* CONFIG_RISCV_ISA_C */ .section .rodata @@ -209,6 +226,10 @@ SYM_DATA_START(test_kprobes_addresses) RISCV_PTR test_kprobes_c_bnez_addr1 RISCV_PTR test_kprobes_c_bnez_addr2 RISCV_PTR test_kprobes_c_bnez_addr3 +#ifdef CONFIG_32BIT + RISCV_PTR test_kprobes_c_jal_addr1 + RISCV_PTR test_kprobes_c_jal_addr2 +#endif #endif /* CONFIG_RISCV_ISA_C */ RISCV_PTR 0 SYM_DATA_END(test_kprobes_addresses) @@ -226,6 +247,9 @@ SYM_DATA_START(test_kprobes_functions) RISCV_PTR test_kprobes_c_jalr RISCV_PTR test_kprobes_c_beqz RISCV_PTR test_kprobes_c_bnez +#ifdef CONFIG_32BIT + RISCV_PTR test_kprobes_c_jal +#endif #endif /* CONFIG_RISCV_ISA_C */ RISCV_PTR 0 SYM_DATA_END(test_kprobes_functions) -- 2.43.0