Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp48450rwn; Wed, 7 Sep 2022 19:46:56 -0700 (PDT) X-Google-Smtp-Source: AA6agR6u0S+tGp6fG6nYGtFjEdMM6kZT2KnHFyRVUh6VmJJL0A7ZFwYNBDS9Iqsj768krqBw99er X-Received: by 2002:a17:902:7e06:b0:176:d7b3:137 with SMTP id b6-20020a1709027e0600b00176d7b30137mr6630690plm.31.1662605215853; Wed, 07 Sep 2022 19:46:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662605215; cv=none; d=google.com; s=arc-20160816; b=GqK8zC42467dA2BogqnhI02Z3x6gaVhU75rKP7eQH1sw83t4GG5blSbH0Won/WHo4s x4d0FWsj8YpLg9WHojPR7uMDGXhZNYOlnhiREXZbQWStCqDYIdcSedG3+mW++XTEE59A +E+nmVPRkA4wOwaCswR1BfaEByfP/KgqIus6fjxov8VIwQYOo6Q61DyXwfXOwtqkzaO+ 5IbSVbaWSB/vO3+nJcP3wQWbkd2uCdDvlZNk1msLfFDsPrOeWW1zRtGEGC9LzjiBxTcU 68FX773zw4XmSEHqp4Q0tL7qlGJWbp2jhyi6ewY96Rt+Unqq+u7GMzilE5kYJ6D8uJzb PZKw== 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=uQMEiuY3exoydh5n/akbU7D48AF/I+vK+ZBvUTQAdNY=; b=n49j4bR+mXVBozkhNm5jq8SnUA74onFA/VH927Uu40USy7ELkPUZDCa7gxGH/8rTq7 I3N1drmOGIgWlgE+uQ7a+AOEHqUJoJTG9ptmJJC9hAibEA4xwYEBd1c7vDGzp570ixMG ZcMd0BIi2XiMezo0wf9vXo0coj/78pVWCp0J6qvvA//f3ExD9bO/eQ9QRBUQxkM7f36j ABoW2AiNOoklskDq2EHw3WVyshgVBvUh1L8XU00/72raUdcUjlieHrNP2IyMYvzb//gZ hdWp0zWWR1+RSnuQfyUvHxJJ4Rdtq9JJ591iaFapBmsw2vhizV17PP78OSsK5BLnu0nL OqCA== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id pa14-20020a17090b264e00b001f335a72172si943146pjb.62.2022.09.07.19.46.45; Wed, 07 Sep 2022 19:46:55 -0700 (PDT) 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 S229541AbiIHCeK (ORCPT + 99 others); Wed, 7 Sep 2022 22:34:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229478AbiIHCeJ (ORCPT ); Wed, 7 Sep 2022 22:34:09 -0400 Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 50988C58C6; Wed, 7 Sep 2022 19:34:07 -0700 (PDT) Received: from linux.localdomain (unknown [113.200.148.30]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Dx_2uZVBljGBYUAA--.13994S2; Thu, 08 Sep 2022 10:34:01 +0800 (CST) From: Tiezhu Yang To: davem@davemloft.net, Masami Hiramatsu Cc: sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] sparc: kprobes: Free instructions in arch_remove_kprobe() Date: Thu, 8 Sep 2022 10:34:00 +0800 Message-Id: <1662604440-30524-1-git-send-email-yangti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KxVWUJVW8JbIYCTnIWIevJa73UjIFyTuYvjxU41xRDUUUU X-CM-SenderInfo: p1dqw3xlh2x3gn0dqz5rrqw2lrqou0/ X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE 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: X-Mailing-List: linux-kernel@vger.kernel.org Call free_insn_slot() to free instructions in arch_remove_kprobe() as other arches do. Signed-off-by: Tiezhu Yang --- arch/sparc/include/asm/kprobes.h | 2 +- arch/sparc/kernel/kprobes.c | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/arch/sparc/include/asm/kprobes.h b/arch/sparc/include/asm/kprobes.h index 06c2bc7..0788286 100644 --- a/arch/sparc/include/asm/kprobes.h +++ b/arch/sparc/include/asm/kprobes.h @@ -17,7 +17,7 @@ typedef u32 kprobe_opcode_t; #define kretprobe_blacklist_size 0 -#define arch_remove_kprobe(p) do {} while (0) +void arch_remove_kprobe(struct kprobe *p); #define flush_insn_slot(p) \ do { flushi(&(p)->ainsn.insn[0]); \ diff --git a/arch/sparc/kernel/kprobes.c b/arch/sparc/kernel/kprobes.c index 535c7b3..a251f73 100644 --- a/arch/sparc/kernel/kprobes.c +++ b/arch/sparc/kernel/kprobes.c @@ -74,6 +74,14 @@ void __kprobes arch_disarm_kprobe(struct kprobe *p) flushi(p->addr); } +void __kprobes arch_remove_kprobe(struct kprobe *p) +{ + if (p->ainsn.insn) { + free_insn_slot(p->ainsn.insn, 0); + p->ainsn.insn = NULL; + } +} + static void __kprobes save_previous_kprobe(struct kprobe_ctlblk *kcb) { kcb->prev_kprobe.kp = kprobe_running(); -- 2.1.0