Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2331839pxk; Mon, 14 Sep 2020 10:25:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy6Q+/Cc/4AYUG6ql7zj4K42553RFv/kDhhclBeVO6hk9eDiAUt5zk6HPC4VfamRImBf5t4 X-Received: by 2002:a17:906:4d97:: with SMTP id s23mr16303164eju.157.1600104302391; Mon, 14 Sep 2020 10:25:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600104302; cv=none; d=google.com; s=arc-20160816; b=jGBqMreyQsWQZ3Hsq6+HZm7FOQSX8w8e2ZjcCLapd080YsHdFv/mTkqTDmg0DMuknK 0mDy8hzYNg4nf93APLcXGSzK1JUU6pZ5Nu+6aT7lC54Z/uhUoudpGFDr/FJSSSG3nd2V DO2GuMZREAEUUYpjafKh9BQzmviA/RnzLHXwgP1hmV1rL9SFUpL9APutdsGnRU/QEjfl IcqLdfB8dF4ol565HIzpgpNUpvnTR06dzUdxFl8l6TNuDCq4afIEObmPeWjzYI4YTEra Guo9Ky2QCmRyAerHyXBMgxp4WsCLq/2LGbgowOvoc3kNFpdXIZZclgH3Xc9tCDDp5lQf JKHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :robot-unsubscribe:robot-id:message-id:mime-version:references :in-reply-to:cc:subject:to:reply-to:from:dkim-signature :dkim-signature:date; bh=uhA+3M3UGeQQinWfSpUaNI4pJRRiQBHKwf3YxA/6+ho=; b=H88JsesyLSBXCpNeheu+tA0X4OwkVlO/sTQjFuRzgxzHJMW4PJV9vvto/0DzBMtRhP YVqQMrMGsB1KqbCHX0orgTMC9hh91zeZXAb4+2ncvuc/bmh6WbNtCacmHe6uJPVeH5Pj o/EVLDJtSX/HVjd4tdCRx+0ilvBwlTsfuq/beet1GEwPqynmT+JSkjDb1cKZuJ4PAi5s g5yT+KoSGfcZFMm2VWlOs/hFN4w0GiUnKmqsYhlvV/jJ9WCLiDfF9Ydnzq4+/aZ5m7xl etWN8xnqm+ytZywjfQ2rwtSvOH8fVarH15wUhyQHo5Bx2PDNbkgdIY/dv5XSCSedoAdT /Xzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linutronix.de header.s=2020 header.b=X9JchNtM; dkim=neutral (no key) header.i=@vger.kernel.org; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o18si7362299edr.51.2020.09.14.10.24.39; Mon, 14 Sep 2020 10:25:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@linutronix.de header.s=2020 header.b=X9JchNtM; dkim=neutral (no key) header.i=@vger.kernel.org; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726058AbgINRUr (ORCPT + 99 others); Mon, 14 Sep 2020 13:20:47 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:34850 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726172AbgINRQZ (ORCPT ); Mon, 14 Sep 2020 13:16:25 -0400 Date: Mon, 14 Sep 2020 17:16:20 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1600103781; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uhA+3M3UGeQQinWfSpUaNI4pJRRiQBHKwf3YxA/6+ho=; b=X9JchNtMmSXwkMXihIsFuR041kykkF8M9X0cyviuEKfnVpbCZoNTcM1ifIGvAJ5eLPVeOI xypfAIS+7EQ59u8mJq6rN6fQ/eji+RqO3ZThxvcAjqp1Qyixk2j5HxSthf0WFlArx2cXtX u0Qnm6rijv8b9bZkuvURXiKpz9z3DOyt50Wbn2Wv7fjCYnjYtpBoX/KP1X3qczXsEF0PVh js6q5DAC6De5lWh+MWFkZGpnEwd593xU8KvC0rpyE7HeE4ouZ5MfH+sWn58f15iRMsH/iv iNvy/kT5x42ZoA7TdCLOjPhk9KemHFgk6J0b34/6wXfQ4+PfkruGZdZ3LXtLVQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1600103781; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uhA+3M3UGeQQinWfSpUaNI4pJRRiQBHKwf3YxA/6+ho=; b=cHd/4IN2s3gTkA86/qRFENzcpcElmaxBXdP3xLRkX+7ets+4JC4kimwdMOqM6fAspjn4iM y5EWfrApn9g1PRDw== From: "tip-bot2 for Masami Hiramatsu" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: perf/kprobes] csky: kprobes: Use generic kretprobe trampoline handler Cc: Masami Hiramatsu , Ingo Molnar , Guo Ren , x86 , LKML In-Reply-To: <159870605775.1229682.2627276871589951304.stgit@devnote2> References: <159870605775.1229682.2627276871589951304.stgit@devnote2> MIME-Version: 1.0 Message-ID: <160010378028.15536.14077574223263891800.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the perf/kprobes branch of tip: Commit-ID: 03c8a4a447008c1a755cd32bc89af24119bd08f1 Gitweb: https://git.kernel.org/tip/03c8a4a447008c1a755cd32bc89af24119bd08f1 Author: Masami Hiramatsu AuthorDate: Sat, 29 Aug 2020 22:00:58 +09:00 Committer: Ingo Molnar CommitterDate: Tue, 08 Sep 2020 11:52:33 +02:00 csky: kprobes: Use generic kretprobe trampoline handler Use the generic kretprobe trampoline handler. Don't use framepointer verification. Signed-off-by: Masami Hiramatsu Signed-off-by: Ingo Molnar Acked-by: Guo Ren Link: https://lore.kernel.org/r/159870605775.1229682.2627276871589951304.stgit@devnote2 --- arch/csky/kernel/probes/kprobes.c | 77 +------------------------------ 1 file changed, 2 insertions(+), 75 deletions(-) diff --git a/arch/csky/kernel/probes/kprobes.c b/arch/csky/kernel/probes/kprobes.c index f0f733b..589f090 100644 --- a/arch/csky/kernel/probes/kprobes.c +++ b/arch/csky/kernel/probes/kprobes.c @@ -404,87 +404,14 @@ int __init arch_populate_kprobe_blacklist(void) void __kprobes __used *trampoline_probe_handler(struct pt_regs *regs) { - struct kretprobe_instance *ri = NULL; - struct hlist_head *head, empty_rp; - struct hlist_node *tmp; - unsigned long flags, orig_ret_address = 0; - unsigned long trampoline_address = - (unsigned long)&kretprobe_trampoline; - kprobe_opcode_t *correct_ret_addr = NULL; - - INIT_HLIST_HEAD(&empty_rp); - kretprobe_hash_lock(current, &head, &flags); - - /* - * It is possible to have multiple instances associated with a given - * task either because multiple functions in the call path have - * return probes installed on them, and/or more than one - * return probe was registered for a target function. - * - * We can handle this because: - * - instances are always pushed into the head of the list - * - when multiple return probes are registered for the same - * function, the (chronologically) first instance's ret_addr - * will be the real return address, and all the rest will - * point to kretprobe_trampoline. - */ - hlist_for_each_entry_safe(ri, tmp, head, hlist) { - if (ri->task != current) - /* another task is sharing our hash bucket */ - continue; - - orig_ret_address = (unsigned long)ri->ret_addr; - - if (orig_ret_address != trampoline_address) - /* - * This is the real return address. Any other - * instances associated with this task are for - * other calls deeper on the call stack - */ - break; - } - - kretprobe_assert(ri, orig_ret_address, trampoline_address); - - correct_ret_addr = ri->ret_addr; - hlist_for_each_entry_safe(ri, tmp, head, hlist) { - if (ri->task != current) - /* another task is sharing our hash bucket */ - continue; - - orig_ret_address = (unsigned long)ri->ret_addr; - if (ri->rp && ri->rp->handler) { - __this_cpu_write(current_kprobe, &ri->rp->kp); - get_kprobe_ctlblk()->kprobe_status = KPROBE_HIT_ACTIVE; - ri->ret_addr = correct_ret_addr; - ri->rp->handler(ri, regs); - __this_cpu_write(current_kprobe, NULL); - } - - recycle_rp_inst(ri, &empty_rp); - - if (orig_ret_address != trampoline_address) - /* - * This is the real return address. Any other - * instances associated with this task are for - * other calls deeper on the call stack - */ - break; - } - - kretprobe_hash_unlock(current, &flags); - - hlist_for_each_entry_safe(ri, tmp, &empty_rp, hlist) { - hlist_del(&ri->hlist); - kfree(ri); - } - return (void *)orig_ret_address; + return (void *)kretprobe_trampoline_handler(regs, &kretprobe_trampoline, NULL); } void __kprobes arch_prepare_kretprobe(struct kretprobe_instance *ri, struct pt_regs *regs) { ri->ret_addr = (kprobe_opcode_t *)regs->lr; + ri->fp = NULL; regs->lr = (unsigned long) &kretprobe_trampoline; }