{"id":817409,"url":"http://patchwork.ozlabs.org/api/patches/817409/?format=json","web_url":"http://patchwork.ozlabs.org/project/linuxppc-dev/patch/cbbac4a5801024513912b730bbbfc44a8002d434.1505934128.git.naveen.n.rao@linux.vnet.ibm.com/","project":{"id":2,"url":"http://patchwork.ozlabs.org/api/projects/2/?format=json","name":"Linux PPC development","link_name":"linuxppc-dev","list_id":"linuxppc-dev.lists.ozlabs.org","list_email":"linuxppc-dev@lists.ozlabs.org","web_url":"https://github.com/linuxppc/wiki/wiki","scm_url":"https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git","webscm_url":"https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/","list_archive_url":"https://lore.kernel.org/linuxppc-dev/","list_archive_url_format":"https://lore.kernel.org/linuxppc-dev/{}/","commit_url_format":"https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/commit/?id={}"},"msgid":"<cbbac4a5801024513912b730bbbfc44a8002d434.1505934128.git.naveen.n.rao@linux.vnet.ibm.com>","list_archive_url":"https://lore.kernel.org/linuxppc-dev/cbbac4a5801024513912b730bbbfc44a8002d434.1505934128.git.naveen.n.rao@linux.vnet.ibm.com/","date":"2017-09-22T09:10:45","name":"[v2,3/6] powerpc/kprobes: Clean up jprobe detection in livepatch handler","commit_ref":"bf3a91251735863fcb230c96e984ebcacee820d9","pull_url":null,"state":"accepted","archived":false,"hash":"7cb88b4025fb9031e7f1083d39fcfd1cc1e8be07","submitter":{"id":15185,"url":"http://patchwork.ozlabs.org/api/people/15185/?format=json","name":"Naveen N. Rao","email":"naveen.n.rao@linux.vnet.ibm.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linuxppc-dev/patch/cbbac4a5801024513912b730bbbfc44a8002d434.1505934128.git.naveen.n.rao@linux.vnet.ibm.com/mbox/","series":[{"id":4580,"url":"http://patchwork.ozlabs.org/api/series/4580/?format=json","web_url":"http://patchwork.ozlabs.org/project/linuxppc-dev/list/?series=4580","date":"2017-09-22T09:10:23","name":"powerpc/kprobes: More fixes","version":2,"mbox":"http://patchwork.ozlabs.org/series/4580/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/817409/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/817409/checks/","tags":{},"related":[],"headers":{"Return-Path":"<linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org>","X-Original-To":["patchwork-incoming@ozlabs.org","linuxppc-dev@lists.ozlabs.org"],"Delivered-To":["patchwork-incoming@ozlabs.org","linuxppc-dev@lists.ozlabs.org"],"Received":["from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3])\n\t(using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xz7Fy5Xgcz9s7C\n\tfor <patchwork-incoming@ozlabs.org>;\n\tFri, 22 Sep 2017 19:19:02 +1000 (AEST)","from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3])\n\tby lists.ozlabs.org (Postfix) with ESMTP id 3xz7Fy4fmzzDsRN\n\tfor <patchwork-incoming@ozlabs.org>;\n\tFri, 22 Sep 2017 19:19:02 +1000 (AEST)","from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com\n\t[148.163.156.1])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby lists.ozlabs.org (Postfix) with ESMTPS id 3xz75123ZczDsM5\n\tfor <linuxppc-dev@lists.ozlabs.org>;\n\tFri, 22 Sep 2017 19:11:17 +1000 (AEST)","from pps.filterd (m0098399.ppops.net [127.0.0.1])\n\tby mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id\n\tv8M9ATlf030856\n\tfor <linuxppc-dev@lists.ozlabs.org>; Fri, 22 Sep 2017 05:11:14 -0400","from e23smtp05.au.ibm.com (e23smtp05.au.ibm.com [202.81.31.147])\n\tby mx0a-001b2d01.pphosted.com with ESMTP id 2d4pnkb7gp-1\n\t(version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT)\n\tfor <linuxppc-dev@lists.ozlabs.org>; Fri, 22 Sep 2017 05:11:14 -0400","from localhost\n\tby e23smtp05.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use\n\tOnly! Violators will be prosecuted\n\tfor <linuxppc-dev@lists.ozlabs.org> from\n\t<naveen.n.rao@linux.vnet.ibm.com>; Fri, 22 Sep 2017 19:11:12 +1000","from d23relay09.au.ibm.com (202.81.31.228)\n\tby e23smtp05.au.ibm.com (202.81.31.211) with IBM ESMTP SMTP Gateway:\n\tAuthorized Use Only! Violators will be prosecuted; \n\tFri, 22 Sep 2017 19:11:09 +1000","from d23av02.au.ibm.com (d23av02.au.ibm.com [9.190.235.138])\n\tby d23relay09.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id\n\tv8M9B8Fg37617796\n\tfor <linuxppc-dev@lists.ozlabs.org>; Fri, 22 Sep 2017 19:11:08 +1000","from d23av02.au.ibm.com (localhost [127.0.0.1])\n\tby d23av02.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id\n\tv8M9Axm5020588\n\tfor <linuxppc-dev@lists.ozlabs.org>; Fri, 22 Sep 2017 19:10:59 +1000","from naverao1-tp.ibm.com ([9.77.124.51])\n\tby d23av02.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id\n\tv8M9AoTX020313; Fri, 22 Sep 2017 19:10:57 +1000"],"Authentication-Results":"ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=linux.vnet.ibm.com\n\t(client-ip=148.163.156.1; helo=mx0a-001b2d01.pphosted.com;\n\tenvelope-from=naveen.n.rao@linux.vnet.ibm.com; receiver=<UNKNOWN>)","From":"\"Naveen N. Rao\" <naveen.n.rao@linux.vnet.ibm.com>","To":"Michael Ellerman <mpe@ellerman.id.au>","Subject":"[PATCH v2 3/6] powerpc/kprobes: Clean up jprobe detection in\n\tlivepatch handler","Date":"Fri, 22 Sep 2017 14:40:45 +0530","X-Mailer":"git-send-email 2.14.1","In-Reply-To":["<9e98f74834af349564b71bc8443bdad55d6e37c6.1505934128.git.naveen.n.rao@linux.vnet.ibm.com>","<cover.1505934128.git.naveen.n.rao@linux.vnet.ibm.com>"],"References":["<9e98f74834af349564b71bc8443bdad55d6e37c6.1505934128.git.naveen.n.rao@linux.vnet.ibm.com>","<cover.1505934128.git.naveen.n.rao@linux.vnet.ibm.com>"],"X-TM-AS-MML":"disable","x-cbid":"17092209-0016-0000-0000-00000265769F","X-IBM-AV-DETECTION":"SAVI=unused REMOTE=unused XFE=unused","x-cbparentid":"17092209-0017-0000-0000-000006EADFD8","Message-Id":"<cbbac4a5801024513912b730bbbfc44a8002d434.1505934128.git.naveen.n.rao@linux.vnet.ibm.com>","X-Proofpoint-Virus-Version":"vendor=fsecure engine=2.50.10432:, ,\n\tdefinitions=2017-09-22_02:, , signatures=0","X-Proofpoint-Spam-Details":"rule=outbound_notspam policy=outbound score=0\n\tspamscore=0 suspectscore=0\n\tmalwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam\n\tadjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000\n\tdefinitions=main-1709220128","X-BeenThere":"linuxppc-dev@lists.ozlabs.org","X-Mailman-Version":"2.1.24","Precedence":"list","List-Id":"Linux on PowerPC Developers Mail List\n\t<linuxppc-dev.lists.ozlabs.org>","List-Unsubscribe":"<https://lists.ozlabs.org/options/linuxppc-dev>,\n\t<mailto:linuxppc-dev-request@lists.ozlabs.org?subject=unsubscribe>","List-Archive":"<http://lists.ozlabs.org/pipermail/linuxppc-dev/>","List-Post":"<mailto:linuxppc-dev@lists.ozlabs.org>","List-Help":"<mailto:linuxppc-dev-request@lists.ozlabs.org?subject=help>","List-Subscribe":"<https://lists.ozlabs.org/listinfo/linuxppc-dev>,\n\t<mailto:linuxppc-dev-request@lists.ozlabs.org?subject=subscribe>","Cc":"linuxppc-dev@lists.ozlabs.org, Masami Hiramatsu <mhiramat@kernel.org>,\n\tKamalesh Babulal <kamalesh@linux.vnet.ibm.com>","Errors-To":"linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org","Sender":"\"Linuxppc-dev\"\n\t<linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org>"},"content":"In commit c05b8c4474c03 (\"powerpc/kprobes: Skip livepatch_handler() for\njprobes\"), we added a helper is_current_kprobe_addr() to help detect if\nthe modified regs->nip was due to a jprobe or livepatch. Masami felt\nthat the function name was not quite clear. To that end, this patch\nrenames is_current_kprobe_addr() to __is_active_jprobe() and adds a\ncomment to (hopefully) better clarify the purpose of this helper. The\nhelper has also now been moved to kprobes-ftrace.c so that it is only\navailable for KPROBES_ON_FTRACE.\n\nSigned-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>\n---\n arch/powerpc/include/asm/kprobes.h             |  2 +-\n arch/powerpc/kernel/kprobes-ftrace.c           | 11 +++++++++++\n arch/powerpc/kernel/kprobes.c                  |  6 ------\n arch/powerpc/kernel/trace/ftrace_64_mprofile.S |  4 ++--\n 4 files changed, 14 insertions(+), 9 deletions(-)","diff":"diff --git a/arch/powerpc/include/asm/kprobes.h b/arch/powerpc/include/asm/kprobes.h\nindex 8814a7249ceb..9f3be5c8a4a3 100644\n--- a/arch/powerpc/include/asm/kprobes.h\n+++ b/arch/powerpc/include/asm/kprobes.h\n@@ -103,8 +103,8 @@ extern int kprobe_exceptions_notify(struct notifier_block *self,\n extern int kprobe_fault_handler(struct pt_regs *regs, int trapnr);\n extern int kprobe_handler(struct pt_regs *regs);\n extern int kprobe_post_handler(struct pt_regs *regs);\n-extern int is_current_kprobe_addr(unsigned long addr);\n #ifdef CONFIG_KPROBES_ON_FTRACE\n+extern int __is_active_jprobe(unsigned long addr);\n extern int skip_singlestep(struct kprobe *p, struct pt_regs *regs,\n \t\t\t   struct kprobe_ctlblk *kcb);\n #else\ndiff --git a/arch/powerpc/kernel/kprobes-ftrace.c b/arch/powerpc/kernel/kprobes-ftrace.c\nindex 6c089d9757c9..48f675a73cff 100644\n--- a/arch/powerpc/kernel/kprobes-ftrace.c\n+++ b/arch/powerpc/kernel/kprobes-ftrace.c\n@@ -25,6 +25,17 @@\n #include <linux/preempt.h>\n #include <linux/ftrace.h>\n \n+/*\n+ * This is called from ftrace code after invoking registered handlers to\n+ * disambiguate regs->nip changes done by jprobes and livepatch. We check if\n+ * there is an active jprobe at the provided address (mcount location).\n+ */\n+int __is_active_jprobe(unsigned long addr)\n+{\n+\tstruct kprobe *p = kprobe_running();\n+\treturn (p && (unsigned long)p->addr == addr) ? 1 : 0;\n+}\n+\n static nokprobe_inline\n int __skip_singlestep(struct kprobe *p, struct pt_regs *regs,\n \t\t      struct kprobe_ctlblk *kcb, unsigned long orig_nip)\ndiff --git a/arch/powerpc/kernel/kprobes.c b/arch/powerpc/kernel/kprobes.c\nindex 4c1702423676..48a81614f629 100644\n--- a/arch/powerpc/kernel/kprobes.c\n+++ b/arch/powerpc/kernel/kprobes.c\n@@ -43,12 +43,6 @@ DEFINE_PER_CPU(struct kprobe_ctlblk, kprobe_ctlblk);\n \n struct kretprobe_blackpoint kretprobe_blacklist[] = {{NULL, NULL}};\n \n-int is_current_kprobe_addr(unsigned long addr)\n-{\n-\tstruct kprobe *p = kprobe_running();\n-\treturn (p && (unsigned long)p->addr == addr) ? 1 : 0;\n-}\n-\n bool arch_within_kprobe_blacklist(unsigned long addr)\n {\n \treturn  (addr >= (unsigned long)__kprobes_text_start &&\ndiff --git a/arch/powerpc/kernel/trace/ftrace_64_mprofile.S b/arch/powerpc/kernel/trace/ftrace_64_mprofile.S\nindex c98e90b4ea7b..c1cfcce0551d 100644\n--- a/arch/powerpc/kernel/trace/ftrace_64_mprofile.S\n+++ b/arch/powerpc/kernel/trace/ftrace_64_mprofile.S\n@@ -110,9 +110,9 @@ ftrace_call:\n \t/* NIP has not been altered, skip over further checks */\n \tbeq\t1f\n \n-\t/* Check if there is an active kprobe on us */\n+\t/* Check if there is an active jprobe on us */\n \tsubi\tr3, r14, 4\n-\tbl\tis_current_kprobe_addr\n+\tbl\t__is_active_jprobe\n \tnop\n \n \t/*\n","prefixes":["v2","3/6"]}