Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp3346511ybl; Mon, 19 Aug 2019 17:10:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqwDktZujx5QvVw+hB5adG6ELfGFqkeRXo9xMDYFb8yLH96wH0SbF/spl9cZsbH16D3dPHVm X-Received: by 2002:a62:3644:: with SMTP id d65mr12342718pfa.128.1566259853259; Mon, 19 Aug 2019 17:10:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566259853; cv=none; d=google.com; s=arc-20160816; b=XcxDG1lwct9BWBijFNnFtmyJkUlQOoH+DyQh7s8AvqV64+NjKccK1VLm3d4mEc63Lq vAkdN0sMT0S0AfqfAhd53iUnkw32TvHTx0gFLerGsZQFA4JEGt0yqb0wFmsH2EhZZNxZ gyryrgeRMuom32xqbPU2Zbs7irSNK0RVDYknH6yTFNC4/fQj8tTRDFu4Q9UuGEcGk+TY d4UqQLgF499D03bbaD70xBQUqjVQl0S8SVF4hW9CUyhh2OJ4OkKIb91WMZZ5eOyvtC3j teJA1JjSzko8n9nsCJ2UmHhDCP04D4elw9wNiinp2kbs/BTmeQ3rew7HdXcVNSTrWAVi 53Ug== 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:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=UaqhSdC5XRgOrCBQLw1vQBKOnA1NGr15FTtU6KQjO8s=; b=u/7olWAQUzjXgowY5tQ12cr3GCPdPx6T0C+uT+/9uYppyXQ9RUd7S2OxKXIvl/h4CA /Lwq/Qabv2zA/R7d6iCZgl5rEA1xz7LhAO76WdSJoAhWRSw6JyFVMQgMh5jL0rTHeTSo HI9txmJa5ON1JvNvdC6SGrhyC8YobkksUbc6PSDRkmjlsV7loeZ5KxjcDhedcvhZuWYW 2iZlHMciV7WJsF4OenrLKt/KKA55kXsvdrLNH2s49zbHcJNHWh8EGAk0JAYW3Ju7YJJ2 c0sdlUqSB+HxjDh1uhhF2KO2DHNaCI63F5lAusTAtLPq4Bj1MzTEt0qM0eiAH4MxCTvc adDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=asBsoarR; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t9si9794377pjy.47.2019.08.19.17.10.37; Mon, 19 Aug 2019 17:10:53 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=asBsoarR; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728669AbfHTAJm (ORCPT + 99 others); Mon, 19 Aug 2019 20:09:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:39134 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728578AbfHTAJm (ORCPT ); Mon, 19 Aug 2019 20:09:42 -0400 Received: from devnote2 (NE2965lan1.rev.em-net.ne.jp [210.141.244.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3FDC02087E; Tue, 20 Aug 2019 00:09:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1566259781; bh=3dePchIXUrHARNvoOUntsAh0qrfK9lM9QkGh3Z6XwXo=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=asBsoarRoTvoLiVFt3+6TN9ttHcpCBbaKi0T2wz6/m7GAH1tqy4MWMmFLOhED4cK3 qqtSRzJQSaez3m8UMAWsjKj54yK2lF4gBVmrDXmygSG1/UeQhQqf2x5QatOGhp9pgK hf+Sv8OU67xeW3NyS67PCYvJOf7nczxq91oNirvQ= Date: Tue, 20 Aug 2019 09:09:35 +0900 From: Masami Hiramatsu To: Jisheng Zhang Cc: Catalin Marinas , Will Deacon , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , "David S. Miller" , Anil S Keshavamurthy , "Naveen N. Rao" , Steven Rostedt , "x86@kernel.org" , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH 2/4] kprobes/x86: use instruction_pointer and instruction_pointer_set Message-Id: <20190820090935.a8357e7f8531340c054275f2@kernel.org> In-Reply-To: <20190819192543.32cec143@xhacker.debian> References: <20190819192422.5ed79702@xhacker.debian> <20190819192543.32cec143@xhacker.debian> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.32; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 19 Aug 2019 11:36:48 +0000 Jisheng Zhang wrote: > This is to make the kprobe_ftrace_handler() common, so we can move it > to common code in next patch. > BTW, this patch looks good, without next patch. Could you update the patch description and resend it with my Ack? Acked-by: Masami Hiramatsu Thank you, > Signed-off-by: Jisheng Zhang > --- > arch/x86/kernel/kprobes/ftrace.c | 9 +++++---- > 1 file changed, 5 insertions(+), 4 deletions(-) > > diff --git a/arch/x86/kernel/kprobes/ftrace.c b/arch/x86/kernel/kprobes/ftrace.c > index 681a4b36e9bb..c2ad0b9259ca 100644 > --- a/arch/x86/kernel/kprobes/ftrace.c > +++ b/arch/x86/kernel/kprobes/ftrace.c > @@ -28,9 +28,9 @@ void kprobe_ftrace_handler(unsigned long ip, unsigned long parent_ip, > if (kprobe_running()) { > kprobes_inc_nmissed_count(p); > } else { > - unsigned long orig_ip = regs->ip; > + unsigned long orig_ip = instruction_pointer(regs); > /* Kprobe handler expects regs->ip = ip + 1 as breakpoint hit */ > - regs->ip = ip + sizeof(kprobe_opcode_t); > + instruction_pointer_set(regs, ip + sizeof(kprobe_opcode_t)); > > __this_cpu_write(current_kprobe, p); > kcb->kprobe_status = KPROBE_HIT_ACTIVE; > @@ -39,12 +39,13 @@ void kprobe_ftrace_handler(unsigned long ip, unsigned long parent_ip, > * Emulate singlestep (and also recover regs->ip) > * as if there is a 5byte nop > */ > - regs->ip = (unsigned long)p->addr + MCOUNT_INSN_SIZE; > + 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, 0); > } > - regs->ip = orig_ip; > + instruction_pointer_set(regs, orig_ip); > } > /* > * If pre_handler returns !0, it changes regs->ip. We have to > -- > 2.23.0.rc1 > -- Masami Hiramatsu