Message ID | 1669796376-4608-1-git-send-email-yangtiezhu@loongson.cn |
---|---|
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp796500wrr; Wed, 30 Nov 2022 00:22:41 -0800 (PST) X-Google-Smtp-Source: AA0mqf5yptErY0ZnHo+n0NoUva92Id6dL0CqGTQyJG6cx8rllC+9JJl8BGWoHYHNFjGJWKUihg+r X-Received: by 2002:a17:906:b14b:b0:78d:cede:91f4 with SMTP id bt11-20020a170906b14b00b0078dcede91f4mr50563470ejb.764.1669796561448; Wed, 30 Nov 2022 00:22:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669796561; cv=none; d=google.com; s=arc-20160816; b=OYm4zFN1uzJAqy2tcC8O1BfCrtKsTAxHS+r+uKPneb0LwXIrLzE0K4yobq1lV4jcmS moDycEdD1fgW+oxTeRtNZrSdyQ8wiHVrvWNdejIRPVAQU58uckD17WHT9YF+cofJgD2I whRdbhNfCutFTv7ofGkZEiC5D+Jf8y3q5E4inEgfL6+eMXcJ6k/sIN+9JRAE0nRqwra3 qmMzA2hOU/XLG0zsATH7lZYtJMOCnetyfdps/NDORGMuuqHd8z/TcoqYHWndiXVk7q5D c+X+2CmrVUiEnhlIZwqcRqUQ981AhhcCxICpL4OZfNS5pKEC2tHSdjnCM5DWH1kbz03Z P5Ww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=IeDeesiTppG3q1XepPewA6ZzHoANT7IBmoAuwoRdl2M=; b=cxTdKYAmlBMMKjFVEUOSfGhepVagoyPwx+HGu5j+UIsyigARlN7nGSRNDxxPDwEvc8 nOdQxsxZnsxZw0ncshX3kGZh76vaiJ+2q7+3WLGZSdKC3cQpx/GLIH8+Hq+LDif7z4x1 9eoLi6ni6m7a6virBU4QMEBrEd5TlCgOA92OCo7IgdJDLob+LpRfsRUT2SjvwxohcPD6 GCKdrmOwrWiOUfk2z3z/+L2+L1mzf9FNeMKj/rxv33sFL4kvZsYxLQxEPQeHY2LEf/8x RK/jOb4FtvGdLklpafwYhY1M2DrFstEHwJdjBrN+a71Yux86GVoeCGQka+rKWTcu4gKw sBiQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sz15-20020a1709078b0f00b007acbac0871csi675839ejc.420.2022.11.30.00.22.18; Wed, 30 Nov 2022 00:22:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233942AbiK3IT4 (ORCPT <rfc822;heyuhang3455@gmail.com> + 99 others); Wed, 30 Nov 2022 03:19:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234635AbiK3ITx (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 30 Nov 2022 03:19:53 -0500 Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 873C9554D1 for <linux-kernel@vger.kernel.org>; Wed, 30 Nov 2022 00:19:51 -0800 (PST) Received: from loongson.cn (unknown [113.200.148.30]) by gateway (Coremail) with SMTP id _____8Cx5vAjEodjok8CAA--.5299S3; Wed, 30 Nov 2022 16:19:48 +0800 (CST) Received: from linux.localdomain (unknown [113.200.148.30]) by localhost.localdomain (Coremail) with SMTP id AQAAf8DxPuIjEodj6GEiAA--.20038S2; Wed, 30 Nov 2022 16:19:47 +0800 (CST) From: Tiezhu Yang <yangtiezhu@loongson.cn> To: Huacai Chen <chenhuacai@kernel.org>, WANG Xuerui <kernel@xen0n.name>, Masami Hiramatsu <mhiramat@kernel.org> Cc: loongarch@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH v6 0/5] Add kprobe and kretprobe support for LoongArch Date: Wed, 30 Nov 2022 16:19:31 +0800 Message-Id: <1669796376-4608-1-git-send-email-yangtiezhu@loongson.cn> X-Mailer: git-send-email 2.1.0 X-CM-TRANSID: AQAAf8DxPuIjEodj6GEiAA--.20038S2 X-CM-SenderInfo: p1dqw3xlh2x3gn0dqz5rrqw2lrqou0/ X-Coremail-Antispam: 1Uk129KBjvJXoW7AF1rJryUtF45Jr43tw4Utwb_yoW8uryUpF 9rAwn8Kr4rGr93Jr9xJw1Uur1ftw48C3y7W3W2yryrC3WUZryUAr4fKrZrXa4rGw4aqr1S qr1rXrWagFyxJa7anT9S1TB71UUUUUJqnTZGkaVYY2UrUUUUj1kv1TuYvTs0mT0YCTnIWj qI5I8CrVACY4xI64kE6c02F40Ex7xfYxn0WfASr-VFAUDa7-sFnT9fnUUIcSsGvfJTRUUU b3kYFVCjjxCrM7AC8VAFwI0_Jr0_Gr1l1xkIjI8I6I8E6xAIw20EY4v20xvaj40_Wr0E3s 1l1IIY67AEw4v_Jr0_Jr4l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28EF7xv wVC0I7IYx2IY67AKxVWUCVW8JwA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxVWUJVW8JwA2z4 x0Y4vEx4A2jsIE14v26r4UJVWxJr1l84ACjcxK6I8E87Iv6xkF7I0E14v26r4UJVWxJr1l n4kS14v26r1Y6r17M2AIxVAIcxkEcVAq07x20xvEncxIr21l57IF6xkI12xvs2x26I8E6x ACxx1l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r1Y6r17McIj6I8E 87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41l42xK82 IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1l4IxYO2xFxVAFwI0_Jrv_JF1lx2Iq xVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r 126r1DMIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY 6xkF7I0E14v26r1j6r4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67 AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r1j6r4UYxBIdaVFxhVjvjDU0xZFpf9x 07jjwZcUUUUU= X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750908599386519125?= X-GMAIL-MSGID: =?utf-8?q?1750908599386519125?= |
Series |
Add kprobe and kretprobe support for LoongArch
|
|
Message
Tiezhu Yang
Nov. 30, 2022, 8:19 a.m. UTC
v6: -- Add a new patch to redefine larch_insn_patch_text() with stop_machine_cpuslocked() -- Modify kprobe_breakpoint_handler() to consider the original insn is break and return the corret value -- Modify do_bp() to refresh bcode when original insn is break v5: -- Rebase on the latest code -- Use stop_machine_cpuslocked() to modify insn to avoid CPU race v4: -- Remove kprobe_exceptions_notify() in kprobes.c -- Call kprobe_breakpoint_handler() and kprobe_singlestep_handler() in do_bp() v3: -- Rebase on the latest code -- Check the alignment of PC in simu_branch() and simu_pc() -- Add ibar in flush_insn_slot() -- Rename kprobe_{pre,post}_handler() to {post_}kprobe_handler -- Add preempt_disable() and preempt_enable_no_resched() -- Remove r0 save/restore and do some minor changes in kprobes_trampoline.S -- Do not enable CONFIG_KPROBES by default v2: -- Split simu_branch() and simu_pc() into a single patch -- Call kprobe_page_fault() in do_page_fault() -- Add kprobes_trampoline.S for kretprobe Tiezhu Yang (5): LoongArch: Simulate branch and PC instructions LoongArch: Use stop_machine_cpuslocked() to modify instruction LoongArch: Add kprobe support LoongArch: Add kretprobe support samples/kprobes: Add LoongArch support arch/loongarch/Kconfig | 2 + arch/loongarch/include/asm/inst.h | 27 +++ arch/loongarch/include/asm/kprobes.h | 59 ++++++ arch/loongarch/include/asm/ptrace.h | 1 + arch/loongarch/kernel/Makefile | 2 + arch/loongarch/kernel/inst.c | 156 +++++++++++++- arch/loongarch/kernel/kprobes.c | 328 +++++++++++++++++++++++++++++ arch/loongarch/kernel/kprobes_trampoline.S | 96 +++++++++ arch/loongarch/kernel/traps.c | 13 +- arch/loongarch/mm/fault.c | 4 + samples/kprobes/kprobe_example.c | 8 + 11 files changed, 691 insertions(+), 5 deletions(-) create mode 100644 arch/loongarch/include/asm/kprobes.h create mode 100644 arch/loongarch/kernel/kprobes.c create mode 100644 arch/loongarch/kernel/kprobes_trampoline.S