Message ID | 1669687374-16432-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 q4csp73293wrr; Mon, 28 Nov 2022 18:08:34 -0800 (PST) X-Google-Smtp-Source: AA0mqf6mEMtJZF7c/GB50/T5wNKri9sk0UhrX4zJcoupFM7RnnXz1VKupljHE6jx8aGgTRKl5BLV X-Received: by 2002:a62:2fc1:0:b0:562:fcae:5f10 with SMTP id v184-20020a622fc1000000b00562fcae5f10mr34366224pfv.28.1669687714672; Mon, 28 Nov 2022 18:08:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669687714; cv=none; d=google.com; s=arc-20160816; b=tniJjEHSUlUZ96NWFJBKn3/xsyEBEN1bhVaOEADsq56iXxInYAhKeqmRaEBbYaiFoE mSgYbLu0xqZPBBJq26Abi1uVjf6eLrl/kMir2nMen+fCLhdVRQg5UXAYATMxs6WpCS6P fCSjBfPzjQImvGy/7C42gR/ta8fLOV8XRpnx3Q6GuKm3Fms8CD+pvs0uipnL+i4JPwKb KeT5ACBnhXL0r45VpES/bE/PO7phLHhhEoFGcdHpn3P5e5vobyOHCMArZ/ju6A35onv6 OpbmZ7EpNTSc1Zt+DmCB0MrYRxFzinKU9RLWCrSnznE0ht5ywUBlqE/tEKDyVpE3nWk9 RusA== 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=sL6/lZiQQ0pvu6J5XgLbLxh3VmmNJBL39BgrYTyYO7U=; b=Q5p6rYBlExzmGSJCi+xXo1axO7sqZUSB4MEafAhyzPY+/MC93l3B6OOhGg590OQ/J2 4HGA/A1NTyeNT7zn8CNTL8HOvYlxkqFNqmNPIWlpjrrthQSQ1gidzZl0bAHsztOBRf5l llymxmp8L0YPURwaF78/YC3PEH7sYv6EU4Y4ZjW7a1utGvPLHaLskmvqYZ5dW8ny0MZD XY3t6x2b48W8kPtP0TJcByE+CJnMcb+tv9nGmSBvYJGv5ps3MF2PA/+Z51FFQp0pdaVR 7qm16AYRwlLhKnSIeCLhbIUcD4u//ikR1dHl/Y29h/oa/wq6SqtLPaKzsuovUjDYKV+R 4iaQ== 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 z184-20020a6333c1000000b00438ce28758csi13179881pgz.136.2022.11.28.18.08.20; Mon, 28 Nov 2022 18:08:34 -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 S235024AbiK2CDL (ORCPT <rfc822;gah0developer@gmail.com> + 99 others); Mon, 28 Nov 2022 21:03:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235012AbiK2CDI (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 28 Nov 2022 21:03:08 -0500 Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id DE7E910B7C for <linux-kernel@vger.kernel.org>; Mon, 28 Nov 2022 18:03:04 -0800 (PST) Received: from loongson.cn (unknown [113.200.148.30]) by gateway (Coremail) with SMTP id _____8Dx_+tWaIVjKeIBAA--.4495S3; Tue, 29 Nov 2022 10:03:03 +0800 (CST) Received: from linux.localdomain (unknown [113.200.148.30]) by localhost.localdomain (Coremail) with SMTP id AQAAf8AxPuBUaIVjPdsdAA--.10463S2; Tue, 29 Nov 2022 10:03:00 +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 v5 0/4] Add kprobe and kretprobe support for LoongArch Date: Tue, 29 Nov 2022 10:02:50 +0800 Message-Id: <1669687374-16432-1-git-send-email-yangtiezhu@loongson.cn> X-Mailer: git-send-email 2.1.0 X-CM-TRANSID: AQAAf8AxPuBUaIVjPdsdAA--.10463S2 X-CM-SenderInfo: p1dqw3xlh2x3gn0dqz5rrqw2lrqou0/ X-Coremail-Antispam: 1Uk129KBjvJXoWxJr4xtw4UKr43Ar4xAw4xZwb_yoW8ArWxpF 9rZwn8Kr4rGrn3Jr9xt3WUur1ftw18C3y2ga17try8C3W7XryUArs3KrZxXa4rKwsIqr1S qr1rX3yYgFyxJa7anT9S1TB71UUUUUJqnTZGkaVYY2UrUUUUj1kv1TuYvTs0mT0YCTnIWj qI5I8CrVACY4xI64kE6c02F40Ex7xfYxn0WfASr-VFAUDa7-sFnT9fnUUIcSsGvfJTRUUU b3AYFVCjjxCrM7AC8VAFwI0_Jr0_Gr1l1xkIjI8I6I8E6xAIw20EY4v20xvaj40_Wr0E3s 1l1IIY67AEw4v_Jr0_Jr4l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28EF7xv wVC0I7IYx2IY67AKxVW7JVWDJwA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxVWxJVW8Jr1l84 ACjcxK6I8E87Iv67AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVCY1x0267AKxVW8Jr0_Cr1U M2kKe7AKxVWUXVWUAwAS0I0E0xvYzxvE52x082IY62kv0487Mc804VCY07AIYIkI8VC2zV CFFI0UMc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUXVWUAwAv7VC2 z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI48JMxAIw2 8IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMxCIbckI1I0E14v26r1Y6r17MI8I 3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxV WUAVWUtwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8I cVCY1x0267AKxVWUJVW8JwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aV AFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVWUJVW8JbIYCTnIWIevJa73UjIFyTuY vjxU74lkDUUUU 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?1750794464798728537?= X-GMAIL-MSGID: =?utf-8?q?1750794464798728537?= |
Series |
Add kprobe and kretprobe support for LoongArch
|
|
Message
Tiezhu Yang
Nov. 29, 2022, 2:02 a.m. UTC
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 (4): LoongArch: Simulate branch and PC instructions LoongArch: Add kprobe support LoongArch: Add kretprobe support samples/kprobes: Add LoongArch support arch/loongarch/Kconfig | 2 + arch/loongarch/include/asm/inst.h | 22 ++ arch/loongarch/include/asm/kprobes.h | 65 ++++++ arch/loongarch/include/asm/ptrace.h | 1 + arch/loongarch/kernel/Makefile | 2 + arch/loongarch/kernel/inst.c | 123 ++++++++++ arch/loongarch/kernel/kprobes.c | 350 +++++++++++++++++++++++++++++ arch/loongarch/kernel/kprobes_trampoline.S | 96 ++++++++ arch/loongarch/kernel/traps.c | 6 +- arch/loongarch/mm/fault.c | 4 + samples/kprobes/kprobe_example.c | 8 + 11 files changed, 675 insertions(+), 4 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