Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1921035pxb; Fri, 5 Mar 2021 03:04:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJzBjiHdoKKNBb9FRrcx4hdWjjFMjlrPzugevadXTc0wn1/WAdkoiuW+SmY78uPY++mWBbdo X-Received: by 2002:a17:906:3052:: with SMTP id d18mr1817218ejd.530.1614942282372; Fri, 05 Mar 2021 03:04:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614942282; cv=none; d=google.com; s=arc-20160816; b=hzRJH2JLT2lh4+jcOdyTvQQESSuWf1BBXFEkeqvEse2itglBVvx7pKILjPb/GpLYNS nYvnL+UEyaRYTqNQWT+pKTFQrKp/Agq9KXeW/phnN41nw09acCI2fzSsJ+eoPPxMajrW faDz+fMRmSW86duEN7Wh4QhTJCzFB1b8uEJJvsQps/I1aaA6yLFke6RXhtlDfXmcUlRE NB25uozpo63SjSiVGbpHl1TQFmb2vmh5Ingp+rPlIwAC4YsJkEx4FdMtfHLwHvVsdk5y dz2NHNvNNa2BdWI/JiERb5TVv4VHBUDRyYgD4WAMj6P6febpaP8XTFJXaW50TBM8/YD8 YlEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=NGT/MvwCa2g3W2NdlvS0RSOCJXttmZI+bDGeQen/psk=; b=lbj6SWdBAmt0CvV7jBYr3dGXBS3q97k6V2YWJo/FqaBps4xWRvAtywTUcZm0ws8cvh LQJWHXU+HqW/jZGQqzOpT1mVWAWaLRwHZs2/GIQkzf1wkefqmzgTFiTosIlx+iVIYB14 MKZwpEGET9wST+3I/O48cgscTuR0KNtq7VlfBMf4Hp8qJK12fS+/dJhdLcvgXtEN2Cyr h+m2EVzm4cEDCxVyz3xrk70g3Welpmw8h7cgzRd2loxtR0zs1unbWS9/3sMy/IKMU2tL f4VHjf9V6R0NNm6ZeRHwwn3rfv8/U5v9LI/7Lf/wpqu32pcF+QmbVKHNmSHzBK0tNv88 WbFQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y101si1496323ede.101.2021.03.05.03.04.19; Fri, 05 Mar 2021 03:04:42 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229672AbhCELDW (ORCPT + 99 others); Fri, 5 Mar 2021 06:03:22 -0500 Received: from szxga06-in.huawei.com ([45.249.212.32]:13440 "EHLO szxga06-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229578AbhCELC4 (ORCPT ); Fri, 5 Mar 2021 06:02:56 -0500 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4DsPtd69zrzjVjh; Fri, 5 Mar 2021 19:01:29 +0800 (CST) Received: from huawei.com (10.175.113.32) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.498.0; Fri, 5 Mar 2021 19:02:46 +0800 From: Nanyong Sun To: , , CC: , , , , , Subject: [PATCH 8/9] riscv: ftrace: Use ftrace_get_regs helper Date: Fri, 5 Mar 2021 19:33:31 +0800 Message-ID: <20210305113332.428048-9-sunnanyong@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210305113332.428048-1-sunnanyong@huawei.com> References: <20210305113332.428048-1-sunnanyong@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.113.32] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use ftrace_get_regs() helper call to get pt_regs from ftrace_regs struct, this makes the code simpler. Signed-off-by: Nanyong Sun --- arch/riscv/kernel/probes/ftrace.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/arch/riscv/kernel/probes/ftrace.c b/arch/riscv/kernel/probes/ftrace.c index e6372490aa0b..2dfb33fdac74 100644 --- a/arch/riscv/kernel/probes/ftrace.c +++ b/arch/riscv/kernel/probes/ftrace.c @@ -4,37 +4,39 @@ /* Ftrace callback handler for kprobes -- called under preepmt disabed */ void kprobe_ftrace_handler(unsigned long ip, unsigned long parent_ip, - struct ftrace_ops *ops, struct ftrace_regs *regs) + struct ftrace_ops *ops, struct ftrace_regs *fregs) { struct kprobe *p; + struct pt_regs *regs; struct kprobe_ctlblk *kcb; p = get_kprobe((kprobe_opcode_t *)ip); if (unlikely(!p) || kprobe_disabled(p)) return; + regs = ftrace_get_regs(fregs); kcb = get_kprobe_ctlblk(); if (kprobe_running()) { kprobes_inc_nmissed_count(p); } else { - unsigned long orig_ip = instruction_pointer(&(regs->regs)); + unsigned long orig_ip = instruction_pointer(regs); - instruction_pointer_set(&(regs->regs), ip); + instruction_pointer_set(regs, ip); __this_cpu_write(current_kprobe, p); kcb->kprobe_status = KPROBE_HIT_ACTIVE; - if (!p->pre_handler || !p->pre_handler(p, &(regs->regs))) { + if (!p->pre_handler || !p->pre_handler(p, regs)) { /* * Emulate singlestep (and also recover regs->pc) * as if there is a nop */ - instruction_pointer_set(&(regs->regs), + instruction_pointer_set(regs, (unsigned long)p->addr + MCOUNT_INSN_SIZE); if (unlikely(p->post_handler)) { kcb->kprobe_status = KPROBE_HIT_SSDONE; - p->post_handler(p, &(regs->regs), 0); + p->post_handler(p, regs, 0); } - instruction_pointer_set(&(regs->regs), orig_ip); + instruction_pointer_set(regs, orig_ip); } /* -- 2.25.1