Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp930489pxj; Fri, 14 May 2021 21:33:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxawtdUo8MIxak1f0+t2kk8pXXuRcX8nGgZxGm7VWDmj0TLMnUuVCYuqz8wp9+CTcI5SXB2 X-Received: by 2002:a05:6638:10e4:: with SMTP id g4mr38802587jae.90.1621053235744; Fri, 14 May 2021 21:33:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621053235; cv=none; d=google.com; s=arc-20160816; b=csQA9+ddhYgL4sXXDXK579OnoStaFxZocr+jX1FSqEQnkUXsghlhKqDr7c8oyz6eYy ytUvlLDQc02RtcnH9CnFK5r3NXXi4bSvYLR0DdpNPXvNWw5DaV7Bqv72ZqYDzO6DUwxQ /dRwpHL9QHja+VvSyul/iLlbwRfgGOVzDSsSY7LMnDtwO4+DUOzAnklQh3lIqgZDr9Jo DOFQGdeTnw9KuMMfJZSv68RewHw/lvv9rcnge6w4efU0HxN1j+uCa9MM8jxYo6QfraR3 xS69453KQ1tLPZx6SkLJSADsYmtbRNG/kMpy2VjNmCk7Gi7cxORz4l5W3MQufr9+Vn1Y 4HdA== 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=PB5LSQ52ot4+/b0AXymVe9MIBjNKc7gqF0+WJ0+970U=; b=0oiO8q7BS1hoppdD2mSD83tILaj7utxQ3UwZWM2OOtl7Qhv2sMQQ8UsLyqx0x+wmch ilzA3zFqhmoFmmdM2uG/HQM1ul3x2I4GKKEA6dxRAupm3Ovr5rysVoLUY4xpkamgozji 3h8CJgppSPUYH5gi/9dSVjrOcgPo13UqKUhZymTzT+YMvxLnG2wgQdGeINNIy5DzQ6uP Ku8kszaps1ryvBU8aXGqYX+LMWPoqmJWLr/OLSjjweUimUQpsVqj3PWhrQn/r32fQ6lF e5XskheVhzbT1GKCT3JfsTyGfMWklsceI4eqHbFI+pFHqN50ZRriKUzXmqdqPX/063KN sU/w== 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 x6si11119441ilv.63.2021.05.14.21.33.40; Fri, 14 May 2021 21:33:55 -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; 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 S232787AbhEOCki (ORCPT + 99 others); Fri, 14 May 2021 22:40:38 -0400 Received: from mail.loongson.cn ([114.242.206.163]:53158 "EHLO loongson.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231388AbhEOCkf (ORCPT ); Fri, 14 May 2021 22:40:35 -0400 Received: from linux.localdomain (unknown [113.200.148.30]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9AxbchLNJ9gBq0WAA--.1351S2; Sat, 15 May 2021 10:39:07 +0800 (CST) From: Tiezhu Yang To: Jonathan Corbet , Marc Koderer , Masami Hiramatsu , Mauro Carvalho Chehab , Christian Brauner , Jisheng Zhang , Heiko Carstens , Martin Schwidefsky , Johannes Thumshirn , Mathieu Desnoyers , Randy Dunlap , Ananth N Mavinakayanahalli , Andrew Morton , Joe Perches Cc: linux-kernel@vger.kernel.org, Xuefeng Li Subject: [PATCH v3] samples/kprobes: Fix typo in handler_{post,fault}() Date: Sat, 15 May 2021 10:39:06 +0800 Message-Id: <1621046346-7855-1-git-send-email-yangtiezhu@loongson.cn> X-Mailer: git-send-email 2.1.0 X-CM-TRANSID: AQAAf9AxbchLNJ9g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O_MaUUUUU X-CM-SenderInfo: p1dqw3xlh2x3gn0dqz5rrqw2lrqou0/ Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org It should use post_handler instead of pre_handler in handler_post(). As Joe Perches suggested, it would be better to use pr_fmt and remove all the embedded pre/post strings. This would change the style of the output through. Also fix a defective format in handler_fault() ending with an 'n' that should be '\n'. Fixes: e16c5dd5157e ("samples/kprobes: Add s390 case in kprobe example module") Fixes: 804defea1c02 ("Kprobes: move kprobe examples to samples/") Acked-by: Marc Koderer Acked-by: Masami Hiramatsu Suggested-by: Joe Perches Signed-off-by: Tiezhu Yang --- v3: use pr_fmt and fix typo in handler_fault() suggested by Joe Perches v2: rebase on the latest mainline kernel samples/kprobes/kprobe_example.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/samples/kprobes/kprobe_example.c b/samples/kprobes/kprobe_example.c index c495664..5f1eb8b 100644 --- a/samples/kprobes/kprobe_example.c +++ b/samples/kprobes/kprobe_example.c @@ -10,6 +10,8 @@ * whenever kernel_clone() is invoked to create a new process. */ +#define pr_fmt(fmt) "%s: " fmt, __func__ + #include #include #include @@ -27,32 +29,31 @@ static struct kprobe kp = { static int __kprobes handler_pre(struct kprobe *p, struct pt_regs *regs) { #ifdef CONFIG_X86 - pr_info("<%s> pre_handler: p->addr = 0x%p, ip = %lx, flags = 0x%lx\n", + pr_info("<%s> p->addr = 0x%p, ip = %lx, flags = 0x%lx\n", p->symbol_name, p->addr, regs->ip, regs->flags); #endif #ifdef CONFIG_PPC - pr_info("<%s> pre_handler: p->addr = 0x%p, nip = 0x%lx, msr = 0x%lx\n", + pr_info("<%s> p->addr = 0x%p, nip = 0x%lx, msr = 0x%lx\n", p->symbol_name, p->addr, regs->nip, regs->msr); #endif #ifdef CONFIG_MIPS - pr_info("<%s> pre_handler: p->addr = 0x%p, epc = 0x%lx, status = 0x%lx\n", + pr_info("<%s> p->addr = 0x%p, epc = 0x%lx, status = 0x%lx\n", p->symbol_name, p->addr, regs->cp0_epc, regs->cp0_status); #endif #ifdef CONFIG_ARM64 - pr_info("<%s> pre_handler: p->addr = 0x%p, pc = 0x%lx," - " pstate = 0x%lx\n", + pr_info("<%s> p->addr = 0x%p, pc = 0x%lx, pstate = 0x%lx\n", p->symbol_name, p->addr, (long)regs->pc, (long)regs->pstate); #endif #ifdef CONFIG_ARM - pr_info("<%s> pre_handler: p->addr = 0x%p, pc = 0x%lx, cpsr = 0x%lx\n", + pr_info("<%s> p->addr = 0x%p, pc = 0x%lx, cpsr = 0x%lx\n", p->symbol_name, p->addr, (long)regs->ARM_pc, (long)regs->ARM_cpsr); #endif #ifdef CONFIG_RISCV - pr_info("<%s> pre_handler: p->addr = 0x%p, pc = 0x%lx, status = 0x%lx\n", + pr_info("<%s> p->addr = 0x%p, pc = 0x%lx, status = 0x%lx\n", p->symbol_name, p->addr, regs->epc, regs->status); #endif #ifdef CONFIG_S390 - pr_info("<%s> pre_handler: p->addr, 0x%p, ip = 0x%lx, flags = 0x%lx\n", + pr_info("<%s> p->addr, 0x%p, ip = 0x%lx, flags = 0x%lx\n", p->symbol_name, p->addr, regs->psw.addr, regs->flags); #endif @@ -65,31 +66,31 @@ static void __kprobes handler_post(struct kprobe *p, struct pt_regs *regs, unsigned long flags) { #ifdef CONFIG_X86 - pr_info("<%s> post_handler: p->addr = 0x%p, flags = 0x%lx\n", + pr_info("<%s> p->addr = 0x%p, flags = 0x%lx\n", p->symbol_name, p->addr, regs->flags); #endif #ifdef CONFIG_PPC - pr_info("<%s> post_handler: p->addr = 0x%p, msr = 0x%lx\n", + pr_info("<%s> p->addr = 0x%p, msr = 0x%lx\n", p->symbol_name, p->addr, regs->msr); #endif #ifdef CONFIG_MIPS - pr_info("<%s> post_handler: p->addr = 0x%p, status = 0x%lx\n", + pr_info("<%s> p->addr = 0x%p, status = 0x%lx\n", p->symbol_name, p->addr, regs->cp0_status); #endif #ifdef CONFIG_ARM64 - pr_info("<%s> post_handler: p->addr = 0x%p, pstate = 0x%lx\n", + pr_info("<%s> p->addr = 0x%p, pstate = 0x%lx\n", p->symbol_name, p->addr, (long)regs->pstate); #endif #ifdef CONFIG_ARM - pr_info("<%s> post_handler: p->addr = 0x%p, cpsr = 0x%lx\n", + pr_info("<%s> p->addr = 0x%p, cpsr = 0x%lx\n", p->symbol_name, p->addr, (long)regs->ARM_cpsr); #endif #ifdef CONFIG_RISCV - pr_info("<%s> post_handler: p->addr = 0x%p, status = 0x%lx\n", + pr_info("<%s> p->addr = 0x%p, status = 0x%lx\n", p->symbol_name, p->addr, regs->status); #endif #ifdef CONFIG_S390 - pr_info("<%s> pre_handler: p->addr, 0x%p, flags = 0x%lx\n", + pr_info("<%s> p->addr, 0x%p, flags = 0x%lx\n", p->symbol_name, p->addr, regs->flags); #endif } @@ -101,7 +102,7 @@ static void __kprobes handler_post(struct kprobe *p, struct pt_regs *regs, */ static int handler_fault(struct kprobe *p, struct pt_regs *regs, int trapnr) { - pr_info("fault_handler: p->addr = 0x%p, trap #%dn", p->addr, trapnr); + pr_info("p->addr = 0x%p, trap #%d\n", p->addr, trapnr); /* Return 0 because we don't handle the fault. */ return 0; } -- 2.1.0