From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from zg8tmtyylji0my4xnjeumjiw.icoremail.net (zg8tmtyylji0my4xnjeumjiw.icoremail.net [162.243.161.220]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F199A44AB80 for ; Wed, 19 Aug 2026 10:26:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=162.243.161.220 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787135188; cv=none; b=lgAWOLWXM/LJGNGbCq9HqDvM1y9PxFcuBISEdQk6T6F5snTX4/KKVW690ZctCzrapmhEM1bvNJpTDszKMahhuQaceQVEnitiZgAv3LgKUtiO/y39t/rctThAGnEExfR34LPxXDD05XeQyfRRkh4ZY+GBFKzb6la5LepfUmhRdFY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787135188; c=relaxed/simple; bh=fTu0YAr0xjHnt3bOYJLRdRk4htwBaNMjayOy9WMsu3U=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=OOi8dxEG84ftMyaDKwM7zh5v7rwoIXG2L6l5cpMn2ghaF00edSSMzSDY8W6jGWLh0M/vjOc4exYjjfiQ1eQ8MXKq/1o9mOiBrqgpTJK2QjbxeRVc7ekb5IDirwFCF7shPrRIWtl05xBXVOkV7drZ6AYHCn1DCido0LAzXrPiFRU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=eswincomputing.com; spf=pass smtp.mailfrom=eswincomputing.com; arc=none smtp.client-ip=162.243.161.220 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=eswincomputing.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=eswincomputing.com Received: from E0002472LT.eswin.cn (unknown [10.12.96.78]) by app2 (Coremail) with SMTP id TQJkCgA3S57IhIVqxjJMAA--.30064S2; Wed, 19 Aug 2026 18:26:17 +0800 (CST) From: Xiaofeng Yuan To: linux-kernel@vger.kernel.org Subject: [PATCH 0/2] riscv: kprobes: simulate nop and c.nop instructions Date: Wed, 19 Aug 2026 18:26:14 +0800 Message-Id: <20260819102616.1553-1-yuanxiaofeng@eswincomputing.com> X-Mailer: git-send-email 2.31.1.windows.1 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:TQJkCgA3S57IhIVqxjJMAA--.30064S2 X-Coremail-Antispam: 1UD129KBjvdXoWrtrWUur4rXryfXryxCF13XFb_yoWDCwb_C3 s7KryUGw4rAa1UXFyxGrnrJFWkKrWxGFyrCFy0grWqgr48XryYva4vgryUA3W8Kas0vF9x Zr1rXw4rXF17XjkaLaAFLSUrUUUUbb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbxkYjsxI4VWkCwAYFVCjjxCrM7AC8VAFwI0_Jr0_Gr1l1xkIjI8I 6I8E6xAIw20EY4v20xvaj40_Wr0E3s1l1IIY67AEw4v_Jr0_Jr4l8cAvFVAK0II2c7xJM2 8CjxkF64kEwVA0rcxSw2x7M28EF7xvwVC0I7IYx2IY67AKxVW7JVWDJwA2z4x0Y4vE2Ix0 cI8IcVCY1x0267AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I 8E87Iv6xkF7I0E14v26rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI 64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r106r15McIj6I8E87Iv67AKxVWUJVW8Jw Am72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41lc7CjxVAaw2AFwI0_JF0_Jw1l c2xSY4AK6svPMxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I 8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUJVWU XwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x 0267AKxVW8JVWxJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_ Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8JVW8JrUvcSsGvfC2KfnxnUUI43ZEXa7IU8 6c_3UUUUU== X-CM-SenderInfo: h1xd05xldrwv1qj6v25zlqu0xpsx3x1qjou0bp/1tbiAgEEE2qEiaAYqAAHsk nop and c.nop have no architectural effect, so handling them through an out-of-line instruction slot and single-stepping is pure overhead. This series simulates them directly in the breakpoint handler by advancing the program counter, following the approach already used on arm64, and extends the RISC-V kprobes KUnit test to cover both paths. Patch 1 adds the simulation. Patch 2 extends the KUnit test with test_kprobes_nop and test_kprobes_c_nop. Verified by cross-compiling for RISC-V and running the kprobes KUnit test in QEMU (ok 1 kprobes_riscv). Xiaofeng Yuan (2): riscv: kprobes: simulate nop and c.nop instructions riscv: kprobes: add nop and c.nop to the KUnit test arch/riscv/include/asm/insn.h | 11 ++++++++ arch/riscv/kernel/probes/decode-insn.c | 6 +++++ arch/riscv/kernel/probes/simulate-insn.c | 14 ++++++++++ arch/riscv/kernel/probes/simulate-insn.h | 2 ++ .../kernel/tests/kprobes/test-kprobes-asm.S | 27 +++++++++++++++++++ 5 files changed, 60 insertions(+) -- 2.43.0