From patchwork Mon Aug 19 11:36:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jisheng Zhang X-Patchwork-Id: 11100723 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2D5DF112C for ; Mon, 19 Aug 2019 11:36:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1AD7F26E76 for ; Mon, 19 Aug 2019 11:36:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0EE0427F10; Mon, 19 Aug 2019 11:36:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B84B026E76 for ; Mon, 19 Aug 2019 11:36:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Content-ID:In-Reply-To: References:Message-ID:Date:Subject:To:From:Reply-To:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=qALNP3wOKdNbpDVdu9M+i/Q5AcugxjJdzga8kJ4CRRA=; b=jrWRlP4TZXmK5z Zmdb7MSVderV9NH/kI/WQyRRNf5IIGjweWWzbwx41qDJRpzSQiXzYmuNdDlJQiT1hJacvCXMyDECG bEdWxDSrGK36Tq06hUV41TT8BH4mUrCF4xHRploQs0MISniFMhIkg86bwasxELnRUA1jIECq1Uf8O p6rTalAZG1UTwOw2RQpRfY+sM2yjbAIoWPPq6eUIfG8euGjftvNs8F0RfdpZkdlwr4vHOzC7JFiwk 7CC6OxPqg0tZ5dFapLqS6bAGIzeJ8RHpzTzvL3hAcvdW0eSn+QdKNq+3yfEEZ9ANaPe1f4+aCcaJ0 Xx6C908ppibllTiklM8Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hzfxO-0004PN-BZ; Mon, 19 Aug 2019 11:36:14 +0000 Received: from mail-eopbgr710043.outbound.protection.outlook.com ([40.107.71.43] helo=NAM05-BY2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hzfxL-0004P1-L1 for linux-arm-kernel@lists.infradead.org; Mon, 19 Aug 2019 11:36:12 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ob/qWgPxLDbO1j2rVc45mkZRHnS6njXTehJk2JeEQmWwRrt1QtP0/RiPvdRUDr5YPRvgNCBigJ0+2AUV+m5IO1EgbvYX1lY+MryQWgVhliYjE4pVIWQLWcTDDvX0rzEDtoGvch/JamldjdhownxiwsXNTsT8XzbG9Q0QfaAGYK1odjudyOBs0bfeSTm2kU57O6PvQU34V46i+qLOrGSMEgpgA6s0kViOp67MckzwKDCPR6xfMzmEXIEtuzvlTWXNsRJub8Vy6Yo5M/fNCUyUIw5uWg8dZYWqSTKyTq7BSJNuwjMOnJg3dPQTb7oLWrb5LA/9I6xsMkH5MUcgfUhBKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=EKpBe//J7CHtDTR2w3jG8GwEs1XJGPcWYz2zYmDSEZs=; b=bNFk7nEZ95GGwtx6TBuaxp6RgpHFN8+zdI7+g3LYJDtYE1vgUHiEF/HrIWSlXZ47bSC4cDpVr6hGKGYU46rXiIiE0CDdUiY5BswHj4r2EWecquLo0XdRcUfspQIC7f6xqMfv9WsqIlnm8ewqoAGNUoAA2XH19xOBKdQcuat4uA+8ATfvOo+kZS2r5y8hR3Ad1Aj5CZEaTHZRDZ5mvXesTcZmmy9hUaC5rH1SDggssk3BbMS7f9PtRoqMib8S5wfBhsF+4Ogq+89VG3L+Nt+xauXsEcHpzFpXGQtSwlEWYTdP46cga0wGcqxqs4ea37G8lUsA3K1aObuZ7b8ahyuN4Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=synaptics.com; dmarc=pass action=none header.from=synaptics.com; dkim=pass header.d=synaptics.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Synaptics.onmicrosoft.com; s=selector2-Synaptics-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=EKpBe//J7CHtDTR2w3jG8GwEs1XJGPcWYz2zYmDSEZs=; b=EZN53o4d/t7XYuciWjmoGPuY7Y7LlGFxAAJcCujA2ZGaInhPIcGOMv0z6jyJ4c2TojPAh2VpcLOCyIhHa73nBjykq/UU1hHsFHg8Qxl26yjGkWk0u55gdQgo/CFTXF0AeOSqMpn/ckAZvYJ2/L3sYmK9C1IqYrBVF+KX9WAWf8w= Received: from BYAPR03MB4773.namprd03.prod.outlook.com (20.179.92.152) by BYAPR03MB4838.namprd03.prod.outlook.com (20.179.93.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2178.16; Mon, 19 Aug 2019 11:36:10 +0000 Received: from BYAPR03MB4773.namprd03.prod.outlook.com ([fe80::a517:3578:67bf:6c88]) by BYAPR03MB4773.namprd03.prod.outlook.com ([fe80::a517:3578:67bf:6c88%7]) with mapi id 15.20.2157.022; Mon, 19 Aug 2019 11:36:10 +0000 From: Jisheng Zhang To: Catalin Marinas , Will Deacon , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Masami Hiramatsu , "David S. Miller" , Anil S Keshavamurthy , "Naveen N. Rao" , Steven Rostedt Subject: [PATCH 1/4] kprobes: adjust kprobe addr for KPROBES_ON_FTRACE Thread-Topic: [PATCH 1/4] kprobes: adjust kprobe addr for KPROBES_ON_FTRACE Thread-Index: AQHVVoJMyFG9yAYnDUGqVMEGNEXBVw== Date: Mon, 19 Aug 2019 11:36:09 +0000 Message-ID: <20190819192505.483c0bf0@xhacker.debian> References: <20190819192422.5ed79702@xhacker.debian> In-Reply-To: <20190819192422.5ed79702@xhacker.debian> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [124.74.246.114] x-clientproxiedby: TYCPR01CA0053.jpnprd01.prod.outlook.com (2603:1096:405:2::17) To BYAPR03MB4773.namprd03.prod.outlook.com (2603:10b6:a03:134::24) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Jisheng.Zhang@synaptics.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 2c17c311-704d-49d0-e979-08d724996e64 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(2017052603328)(7193020); SRVR:BYAPR03MB4838; x-ms-traffictypediagnostic: BYAPR03MB4838: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:478; x-forefront-prvs: 0134AD334F x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(39860400002)(136003)(396003)(376002)(346002)(366004)(189003)(199004)(316002)(50226002)(7416002)(52116002)(99286004)(6486002)(478600001)(2906002)(66066001)(71200400001)(54906003)(86362001)(14454004)(3846002)(5660300002)(71190400001)(110136005)(76176011)(4744005)(8936002)(6436002)(66946007)(305945005)(81156014)(66446008)(64756008)(81166006)(66556008)(66476007)(8676002)(6116002)(7736002)(186003)(102836004)(1076003)(26005)(6512007)(446003)(9686003)(11346002)(53936002)(486006)(6506007)(386003)(476003)(256004)(25786009)(4326008)(921003)(1121003)(39210200001); DIR:OUT; SFP:1101; SCL:1; SRVR:BYAPR03MB4838; H:BYAPR03MB4773.namprd03.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:0; received-spf: None (protection.outlook.com: synaptics.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: c81MKNF1YphsHMlylKiRBU9aJ/xP+u1Lbl7wz7r9VK8QVsMiwQP716huOxdjDlYnF3KL+jyYIKS4gjY3lHngl/P/23jPM9fCt2/k3VtDdDwn+AIR6grdlMY+S5qfz3xrgJFmDLnobohoEwX7oOwWMAgF4ycFuG1NF0UOkpVzYQ9fW3Rislt7AcgmT/c0OUsteCC1jJYPK9bDRsdFzqcmvT5IVTHTxFpphG/zgd+P/wbo7/DO6ZROzcSSVwmtCviGynM31y+8rPofZShups3RsSPd7udYV8sLqaVTuOcmuSvTtRRU+jBGL4tHZhQRrKIHdLnJ0N1gmdz8ShX/4mhGEaS8ZaALF5r1jESAFJnLCQHRhwZD6cGeqiUrBRPpNOIzUpzoU5mnWrybcJFHBfhce+A/UViQTaqshE7eWp5lsTU= x-ms-exchange-transport-forked: True Content-ID: MIME-Version: 1.0 X-OriginatorOrg: synaptics.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2c17c311-704d-49d0-e979-08d724996e64 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Aug 2019 11:36:10.0036 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 335d1fbc-2124-4173-9863-17e7051a2a0e X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 0nXnn4v0KeDRAUFNixQYt1ALLlXZaxisepbnOOmcF1QL3/QeF5ra00On90OhH//GuJZKNwV0Ve2tlIF6fTLQPQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR03MB4838 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190819_043611_688277_C49AC52F X-CRM114-Status: GOOD ( 10.16 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "x86@kernel.org" , "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP For KPROBES_ON_FTRACE case, we need to adjust the kprobe's addr correspondingly. Signed-off-by: Jisheng Zhang --- kernel/kprobes.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kernel/kprobes.c b/kernel/kprobes.c index 9873fc627d61..f8400753a8a9 100644 --- a/kernel/kprobes.c +++ b/kernel/kprobes.c @@ -1560,6 +1560,9 @@ int register_kprobe(struct kprobe *p) addr = kprobe_addr(p); if (IS_ERR(addr)) return PTR_ERR(addr); +#ifdef CONFIG_KPROBES_ON_FTRACE + addr = (kprobe_opcode_t *)ftrace_call_adjust((unsigned long)addr); +#endif p->addr = addr; ret = check_kprobe_rereg(p); From patchwork Mon Aug 19 11:36:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jisheng Zhang X-Patchwork-Id: 11100733 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 341BB13B1 for ; Mon, 19 Aug 2019 11:36:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2207626E76 for ; Mon, 19 Aug 2019 11:36:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1599128761; Mon, 19 Aug 2019 11:36:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6980D27FC0 for ; Mon, 19 Aug 2019 11:36:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Content-ID:In-Reply-To: References:Message-ID:Date:Subject:To:From:Reply-To:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=0uwoPapgZOqdNkKEcnxhxZYr+m8Icblur6zLv7xjZEA=; b=mEm4mjjwGleLnO DGhouAkxSeQEnFVehFTTi1shaHAE4mkM0uCWf/0U84z+DEP4kaqre3xuq9i2Kdr3bcDxf8pW38nzO yxlqQD7HJ5sh3/Uvc16SCm3nPEff80c6Bya3q3Y8cGhk6RFp6qerYza3Z58S0CNYA6w7YWI0ADLlS GL2Gy3KF0GWizAHfs4AXf+Od1dVOU0aNQZo5eaxd0vpdtyw0IyZHPo9mRCtzBuLvsP/ektT2hXeNV 4gcymv4rouSXHjl0iHF8gKaJYuV0NVGXR0bqLG4Fao2oobwlyV+1BeqXOwKrgK4iW2nJqU82s0Vh5 Jrhd1wPCL/VneHbOirSQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hzfy1-0004kQ-74; Mon, 19 Aug 2019 11:36:53 +0000 Received: from mail-eopbgr770048.outbound.protection.outlook.com ([40.107.77.48] helo=NAM02-SN1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hzfxy-0004jf-Oj for linux-arm-kernel@lists.infradead.org; Mon, 19 Aug 2019 11:36:52 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=K5G4ymBeagUvXO75mVIDg/U5aPgbjpxgIAHRBA/Zn5ayvzoR7cRQAakicItUz1EZGLKbM9+nb0nlHU5SwFd9D+nGL2+0xYZekr6OKsfvFVk5AafiDeJqiF0oVooYcBa0F0Af/3MFjPe13pXivpr96gtqQghSNsT/8wEkhRhT9QJPKuNEiKMAocfBHqWQZIFXIg551PxeIwwdX/obNXbia5ydt5idc1yJ9yLSPzrWHa9W+B90+sp1zyzGWVA7l91mHkPucV+XqCu6RHmbTFd8OZ/zJyT53W/vGqKJWuzhs0Hb+TIjRZfCxDR57a4e1LLuvqyFFi7qowrxye5VDsUxoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=FyckNaQgSq4hdpvyN5DvPdGi9XkzQjEcuu5+VJl2/ck=; b=d/UyaUynqMFSWCPJwDg762QCLS9mOpO/3Ud2MEg36pr3YGkP8kN27nCyDGwJoQjXKq10Re6d3EHA8lGaGzkTtx1OWDvWSCXW+5DbSEJefQp7Px4VI0u0NWXvfRWyrLCH9uhStWdBFZ8mM1RnjOxLWZniyQ6JxA3S/kEyXkn3qLX85bc0Ni4HXXOwBe96+Wqbqca4w+JCGTgmCl7JtXCj7C9GwOVIPLysQ9jnzsZ9RFGVjKBDzu/pXiic345gtp7a9LvnwFbcad4xRd6xFzkJ5hn6gzz5cEDVcWl3c/vQc2Fenj0SVgqr63cQp8BsB5AXt9FSkkXdk8iGdOgin5WXPg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=synaptics.com; dmarc=pass action=none header.from=synaptics.com; dkim=pass header.d=synaptics.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Synaptics.onmicrosoft.com; s=selector2-Synaptics-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=FyckNaQgSq4hdpvyN5DvPdGi9XkzQjEcuu5+VJl2/ck=; b=bi5gyHqL/T9Zpemz9TItLFIPBjwT47qqwfEgov4IrMGggIemYSPscQd3oB4iwRg1gjGKiz8vy9nb47lP6CJNUReW6sKpa0QTjsepVKBLTiIGDbcG//O+bmvKDpsVLUW+GEu/or2aDp6vdkI/fKx48QNOSxTGlqybC2fZ/nGv5Os= Received: from BYAPR03MB4773.namprd03.prod.outlook.com (20.179.92.152) by BYAPR03MB4838.namprd03.prod.outlook.com (20.179.93.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2178.16; Mon, 19 Aug 2019 11:36:48 +0000 Received: from BYAPR03MB4773.namprd03.prod.outlook.com ([fe80::a517:3578:67bf:6c88]) by BYAPR03MB4773.namprd03.prod.outlook.com ([fe80::a517:3578:67bf:6c88%7]) with mapi id 15.20.2157.022; Mon, 19 Aug 2019 11:36:48 +0000 From: Jisheng Zhang To: Catalin Marinas , Will Deacon , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Masami Hiramatsu , "David S. Miller" , Anil S Keshavamurthy , "Naveen N. Rao" , Steven Rostedt Subject: [PATCH 2/4] kprobes/x86: use instruction_pointer and instruction_pointer_set Thread-Topic: [PATCH 2/4] kprobes/x86: use instruction_pointer and instruction_pointer_set Thread-Index: AQHVVoJjLhLBz1QsakilYQzbvNrNQg== Date: Mon, 19 Aug 2019 11:36:48 +0000 Message-ID: <20190819192543.32cec143@xhacker.debian> References: <20190819192422.5ed79702@xhacker.debian> In-Reply-To: <20190819192422.5ed79702@xhacker.debian> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [124.74.246.114] x-clientproxiedby: TYAPR01CA0139.jpnprd01.prod.outlook.com (2603:1096:404:2d::31) To BYAPR03MB4773.namprd03.prod.outlook.com (2603:10b6:a03:134::24) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Jisheng.Zhang@synaptics.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: d88841ae-1f36-46ca-44d6-08d724998573 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(2017052603328)(7193020); SRVR:BYAPR03MB4838; x-ms-traffictypediagnostic: BYAPR03MB4838: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:6790; x-forefront-prvs: 0134AD334F x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(39860400002)(136003)(396003)(376002)(346002)(366004)(189003)(199004)(316002)(50226002)(7416002)(52116002)(99286004)(6486002)(478600001)(2906002)(66066001)(71200400001)(54906003)(86362001)(14454004)(3846002)(5660300002)(71190400001)(110136005)(76176011)(8936002)(6436002)(66946007)(305945005)(81156014)(66446008)(64756008)(81166006)(66556008)(66476007)(8676002)(6116002)(7736002)(186003)(102836004)(1076003)(26005)(6512007)(446003)(9686003)(11346002)(53936002)(486006)(6506007)(386003)(476003)(256004)(25786009)(4326008)(921003)(1121003)(39210200001); DIR:OUT; SFP:1101; SCL:1; SRVR:BYAPR03MB4838; H:BYAPR03MB4773.namprd03.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:0; received-spf: None (protection.outlook.com: synaptics.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: P6oqox4x9vHnqK69OXqXzdM1X6Y92zzDP2yRoHP9nAgPIe8ctzbmXgwugkOPTekCEh6I7YkZZu8CsdJ4VRnQfvuRpXd1/V1czglIzZZv+ZuGf+cq/lKLLniisj/osCwmBBMxzGF8DWlz6/3S3+wSXLp/+qQe6ktvoNDXnK9byu+q/q4pdltq8DWvqDU7q7dzbH4eJu6bP9OP3MzDT7UBOk4l4XRprQls9hGd6GklDKQGo9Nv/c+2PMd+LhRMDuDQmIFgLO1pKIxqgt0AbpBgJKvtpAjid9oxI8imebhN2uCDnzpgCcv0oHyGaLI22rpmD+vInmugR4sqgA7eaBNvSDLB4OYwDh2fEsSW8KOM7gxrvx+XvnTBxVOjAK6NBTkePIseC3rnNiNfFRGnoWh8K2Tnp5eSaRK+d+6OzKbm/tA= x-ms-exchange-transport-forked: True Content-ID: <419B39D67DED6746B89233CE29FB2E87@namprd03.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: synaptics.com X-MS-Exchange-CrossTenant-Network-Message-Id: d88841ae-1f36-46ca-44d6-08d724998573 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Aug 2019 11:36:48.6912 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 335d1fbc-2124-4173-9863-17e7051a2a0e X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: B9MBc/P1AMByozT6p/cgpsr1pdSR7atfz62QEH+qVJa7KJ4fL21S9THfTebOgrMWrC+EzpSXVOXOSKndaiJtuw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR03MB4838 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190819_043650_801848_B33007EB X-CRM114-Status: GOOD ( 10.70 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "x86@kernel.org" , "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP This is to make the kprobe_ftrace_handler() common, so we can move it to common code in next patch. Signed-off-by: Jisheng Zhang Acked-by: Masami Hiramatsu --- 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 From patchwork Mon Aug 19 11:37:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jisheng Zhang X-Patchwork-Id: 11100735 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AD104112C for ; Mon, 19 Aug 2019 11:37:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9961E20CCF for ; Mon, 19 Aug 2019 11:37:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8A5AD27F10; Mon, 19 Aug 2019 11:37:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 14DA320CCF for ; Mon, 19 Aug 2019 11:37:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Content-ID:In-Reply-To: References:Message-ID:Date:Subject:To:From:Reply-To:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=yl8FRRc0bR/BAC/Yb1792ZLfYXoshCiQJIuzzMveK8Y=; b=pAI2NmYq9CWWY/ /x+PBs5nvcLQb+xCcdIVO7WDzw2476ubW6QQsSru0fR1PoVxJu7mJSHQpoIeVKDxhbZbxfjuspzy7 C4tMMXJZ9MZuEVzHYB7+MqVwJZaUbQvSfvpIUuideTn90tLJDWrPktMEXWpTnijTmIIAc61jkzFzU kDxcdaWav6UUTxWPGItiEeNsoqW0gMM5I3VMjYfSBODdQH3ed3FUxtbylMXR6x7xbM4T64Po/ur+S 6/V7Oxhn4f/vMOp6aLK6NznFtLfyaHK5tGIpBhNj3MorBchRkauSYrFsWu6evaB13G2y0lh5QJq1b LWYPFdC095gpeoRept3w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hzfyj-0004zP-Pn; Mon, 19 Aug 2019 11:37:37 +0000 Received: from mail-eopbgr770058.outbound.protection.outlook.com ([40.107.77.58] helo=NAM02-SN1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hzfyh-0004z5-7y for linux-arm-kernel@lists.infradead.org; Mon, 19 Aug 2019 11:37:36 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BUNXTWKleVn7T8Y3aSg8Hsyt3ru+36stIpcteUDh7YrvQoxQUKjA8tRqU7BOR663f4JA25Mxh7yZ4UpM8Ap6vYcK3jBHmMmCAFGHOnMhQeHWoUt27HgDJMCg2Z5SqRyVc4Tgncvm2EkaG4KKYHjHa+nOqz1ukw5n9szFa6QC8i9cFeiobLsYARAUu6xsynvV57SiZGGOoPoOyzssn4y3ytCRojEUXPhAsJu9fmV7832H9GRKUO8abuhcDLqVXHzBxJTo6yO6CIoxEZ+4cdDgBRolSgjrwnKT91fpVx3yIbezVAhpMqy88U7tUCW5TptTw7QH8fz4ZRO0VCvCjxlaPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=YM3xBnJ1INaBk35kehltk+eqEHmnTVISIfM2FGZwnfw=; b=aY6wzCyPzFl7NtfI7Mgnmxe5c1MJqRnZEwwM8fhB2kzhqMmeIO2bToYZV0nraJJzX9RKaLjSXzAhxgQdT4ze7WIwON7fb/ap2wV4kDm/mtRaJu+lTU46gtlhKPuKjtkAR58yATXBd4ZyzNfEgWz2xqDGJ6oDb+p2SGmHslrmPJ3tB5tTIUgq+iDcSxqBK4RopHO4BKDwmE/FrcdfnPzr/IJZKfCfUXVIjL2bi6x+OBcJ0gDPDFNCOJyh7OSqGOnNuOPrmk+FYfsGg8KU3Elj7xbV+P7PTyhshBe8ISmkbJI0ifuhrb/EM0NBI66NpaCdpfavkoHZFHOG18ZQgvwAAg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=synaptics.com; dmarc=pass action=none header.from=synaptics.com; dkim=pass header.d=synaptics.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Synaptics.onmicrosoft.com; s=selector2-Synaptics-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=YM3xBnJ1INaBk35kehltk+eqEHmnTVISIfM2FGZwnfw=; b=d+ejuGhhe4XzPeCsH+BSgN1nR02RsHHs6X3xqsH0enKVLOgXeFcD166b+fcCg0Wf4JuOfRWYsRTkQgYPxIIjfklWSNpop3gkZXTq+qNFw8g76LWa3Tq0BhSfPsr7hcSaUY4c1o8MqLw/7oPui1z/tMZtZ5MvHCy0lZYVwuOt0ng= Received: from BYAPR03MB4773.namprd03.prod.outlook.com (20.179.92.152) by BYAPR03MB4838.namprd03.prod.outlook.com (20.179.93.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2178.16; Mon, 19 Aug 2019 11:37:33 +0000 Received: from BYAPR03MB4773.namprd03.prod.outlook.com ([fe80::a517:3578:67bf:6c88]) by BYAPR03MB4773.namprd03.prod.outlook.com ([fe80::a517:3578:67bf:6c88%7]) with mapi id 15.20.2157.022; Mon, 19 Aug 2019 11:37:33 +0000 From: Jisheng Zhang To: Catalin Marinas , Will Deacon , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Masami Hiramatsu , "David S. Miller" , Anil S Keshavamurthy , "Naveen N. Rao" , Steven Rostedt Subject: [PATCH 3/4] kprobes: move kprobe_ftrace_handler() from x86 and make it weak Thread-Topic: [PATCH 3/4] kprobes: move kprobe_ftrace_handler() from x86 and make it weak Thread-Index: AQHVVoJ9EHFo1XzjbE6QP8I8uro18g== Date: Mon, 19 Aug 2019 11:37:32 +0000 Message-ID: <20190819192628.5f550074@xhacker.debian> References: <20190819192422.5ed79702@xhacker.debian> In-Reply-To: <20190819192422.5ed79702@xhacker.debian> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [124.74.246.114] x-clientproxiedby: TY1PR01CA0148.jpnprd01.prod.outlook.com (2603:1096:402:1::24) To BYAPR03MB4773.namprd03.prod.outlook.com (2603:10b6:a03:134::24) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Jisheng.Zhang@synaptics.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: af81900f-3397-4dd7-3103-08d724999fcc x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(2017052603328)(7193020); SRVR:BYAPR03MB4838; x-ms-traffictypediagnostic: BYAPR03MB4838: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:7219; x-forefront-prvs: 0134AD334F x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(346002)(376002)(396003)(136003)(39860400002)(189003)(199004)(7736002)(6116002)(186003)(66476007)(66556008)(81166006)(64756008)(66446008)(8676002)(66946007)(81156014)(305945005)(256004)(25786009)(6506007)(386003)(476003)(4326008)(14444005)(446003)(6512007)(1076003)(102836004)(9686003)(26005)(486006)(53936002)(11346002)(66066001)(2906002)(478600001)(86362001)(71200400001)(7416002)(316002)(50226002)(99286004)(6486002)(52116002)(54906003)(6436002)(8936002)(14454004)(3846002)(76176011)(5660300002)(71190400001)(110136005)(921003)(39210200001)(1121003); DIR:OUT; SFP:1101; SCL:1; SRVR:BYAPR03MB4838; H:BYAPR03MB4773.namprd03.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:0; received-spf: None (protection.outlook.com: synaptics.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: TRbGHV/bNSK9gR/7lLolSXh0Btevan+hOMNQeRQJWQSEr5JVuMvOaxhLsN/YHPkEwCCmFk0juIlkddlPTbosuOSnFsKuSfg1Y+Prb/4jAwin+oOkGIXSW+p9rhjpvEPWLHYPo0Jv8pAh018pSIMdIzZKPyML8XHxqb98e6Gqw7wNQV72lRDF6VZH4CUWYqG/LbLQZ3Y92Gmq6p3EcgMmK8hjfihsOjA1BMTSOtiWQjW2bzcUKcpPrduDEMqHR3ROkqBWhr129Bwjbgz2oTXMbqYfPGbpTCfnT1jw/J6u6BYh5kj+BCq4fpfx8JQ6+SdUN4O1e1zlbrsrFzfiynTi0XuLzfXo3FmbxUx/hj+xIUEMv4NQhH1FbEeJAM/Yx297k6Rk+i57tF9i2S7RqGxBfADJvfhyjN7eOKVXxYG7zOs= x-ms-exchange-transport-forked: True Content-ID: <54801A62D85C784CAA892ABC7B87B5E2@namprd03.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: synaptics.com X-MS-Exchange-CrossTenant-Network-Message-Id: af81900f-3397-4dd7-3103-08d724999fcc X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Aug 2019 11:37:32.9008 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 335d1fbc-2124-4173-9863-17e7051a2a0e X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: ujeHGpVVncm+KeVzATZe2w8Z2tYaOh0c+2sQ8S5/KE9RbOhfmQmUr78xJKUYw14foNUi7DvOFCamaBa9V129bQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR03MB4838 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190819_043735_285233_545E9F3F X-CRM114-Status: GOOD ( 13.80 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "x86@kernel.org" , "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP This code could be reused. So move it from x86 to common code. Signed-off-by: Jisheng Zhang --- arch/x86/kernel/kprobes/ftrace.c | 44 -------------------------------- kernel/kprobes.c | 44 ++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 44 deletions(-) diff --git a/arch/x86/kernel/kprobes/ftrace.c b/arch/x86/kernel/kprobes/ftrace.c index c2ad0b9259ca..91ae1e3e65f7 100644 --- a/arch/x86/kernel/kprobes/ftrace.c +++ b/arch/x86/kernel/kprobes/ftrace.c @@ -12,50 +12,6 @@ #include "common.h" -/* 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 pt_regs *regs) -{ - struct kprobe *p; - struct kprobe_ctlblk *kcb; - - /* Preempt is disabled by ftrace */ - p = get_kprobe((kprobe_opcode_t *)ip); - if (unlikely(!p) || kprobe_disabled(p)) - return; - - kcb = get_kprobe_ctlblk(); - if (kprobe_running()) { - kprobes_inc_nmissed_count(p); - } else { - unsigned long orig_ip = instruction_pointer(regs); - /* Kprobe handler expects regs->ip = ip + 1 as breakpoint hit */ - instruction_pointer_set(regs, ip + sizeof(kprobe_opcode_t)); - - __this_cpu_write(current_kprobe, p); - kcb->kprobe_status = KPROBE_HIT_ACTIVE; - if (!p->pre_handler || !p->pre_handler(p, regs)) { - /* - * Emulate singlestep (and also recover regs->ip) - * as if there is a 5byte nop - */ - 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); - } - instruction_pointer_set(regs, orig_ip); - } - /* - * If pre_handler returns !0, it changes regs->ip. We have to - * skip emulating post_handler. - */ - __this_cpu_write(current_kprobe, NULL); - } -} -NOKPROBE_SYMBOL(kprobe_ftrace_handler); - int arch_prepare_kprobe_ftrace(struct kprobe *p) { p->ainsn.insn = NULL; diff --git a/kernel/kprobes.c b/kernel/kprobes.c index f8400753a8a9..479148ee1822 100644 --- a/kernel/kprobes.c +++ b/kernel/kprobes.c @@ -960,6 +960,50 @@ static struct kprobe *alloc_aggr_kprobe(struct kprobe *p) #endif /* CONFIG_OPTPROBES */ #ifdef CONFIG_KPROBES_ON_FTRACE +/* Ftrace callback handler for kprobes -- called under preepmt disabed */ +void __weak kprobe_ftrace_handler(unsigned long ip, unsigned long parent_ip, + struct ftrace_ops *ops, struct pt_regs *regs) +{ + struct kprobe *p; + struct kprobe_ctlblk *kcb; + + /* Preempt is disabled by ftrace */ + p = get_kprobe((kprobe_opcode_t *)ip); + if (unlikely(!p) || kprobe_disabled(p)) + return; + + kcb = get_kprobe_ctlblk(); + if (kprobe_running()) { + kprobes_inc_nmissed_count(p); + } else { + unsigned long orig_ip = instruction_pointer(regs); + /* Kprobe handler expects regs->ip = ip + 1 as breakpoint hit */ + instruction_pointer_set(regs, ip + sizeof(kprobe_opcode_t)); + + __this_cpu_write(current_kprobe, p); + kcb->kprobe_status = KPROBE_HIT_ACTIVE; + if (!p->pre_handler || !p->pre_handler(p, regs)) { + /* + * Emulate singlestep (and also recover regs->ip) + * as if there is a 5byte nop + */ + 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); + } + instruction_pointer_set(regs, orig_ip); + } + /* + * If pre_handler returns !0, it changes regs->ip. We have to + * skip emulating post_handler. + */ + __this_cpu_write(current_kprobe, NULL); + } +} +NOKPROBE_SYMBOL(kprobe_ftrace_handler); + static struct ftrace_ops kprobe_ftrace_ops __read_mostly = { .func = kprobe_ftrace_handler, .flags = FTRACE_OPS_FL_SAVE_REGS | FTRACE_OPS_FL_IPMODIFY, From patchwork Mon Aug 19 11:38:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jisheng Zhang X-Patchwork-Id: 11100737 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 809C7112C for ; Mon, 19 Aug 2019 11:38:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6DA3420CCF for ; Mon, 19 Aug 2019 11:38:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 61D1827F88; Mon, 19 Aug 2019 11:38:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 75DB720CCF for ; Mon, 19 Aug 2019 11:38:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Content-ID:In-Reply-To: References:Message-ID:Date:Subject:To:From:Reply-To:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Qz0XUWW5ILbTnMWF1jggu3Tj4x4FJClHRo5yWwTK2ho=; b=B/tiTPVeM3b770 kR70rQgFYw20DzsSwM5zt3YMKRngURZQ+4wCIkA40przhCp6A+eMBRRwmZwrPWJ6BJcDcfB1w72O3 EzrF1jqvhuwMVaxCpiWuVF37FLcmDcKI7PVw2hlxTzxY1iv+++6ZH9oY24IWnPhnIWECPBtSsaveY b9VlR/jOo0xd6VMxHtQtsel9ehT32NuEnkSUr9zmh2ynR7PjnAJ/eddzYxEQotssup27z+7XjmMH2 msvEbTUINUfdAkN7rUQiMUN0Czw2N+hPowposzVkOOkivaEx8s9k/cQpEpj88iS3Hr4mzV0bsuwXt m06XGbT7keiBFuTgO6ZQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hzfzK-0005Ej-Cy; Mon, 19 Aug 2019 11:38:14 +0000 Received: from mail-eopbgr710077.outbound.protection.outlook.com ([40.107.71.77] helo=NAM05-BY2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hzfzI-0005EN-8l for linux-arm-kernel@lists.infradead.org; Mon, 19 Aug 2019 11:38:13 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aYdZV28e+L359dxaYpvoVlGs5//GPoYgjhC3G59oFoGaPJo8jGNmbXTZUGuXeKKV/6bi+zttoQ43sWcAyAz0UXksT73NK658Mb3ZkjF7ZI0Oiw59dXublgWmsD7nPlB2UcwuJbMh5GNJeay7IyJBjm6LkKPi1a7w6Y8ojnYm2CP3dnpn8fsEhLqRqk1cP0n+g4ERoF8s4rr3W+sjDtbh0fKVWtMh8Sgb55G2V4ARd7rU/cME6SBb9dLD7E1yAqpg1L+2uoV6PyJKqA3u9Ks9aGtIfkg7hV//7IBlULx6IvjbDCn5kFOCAMn9csQTPI6NEtMYq7HPg7YcSoW0RetI3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=SHV4Bmuw5aXp3ktT0yj9WugDe8VRvEdaGtvYNAk1kkU=; b=cV5BQwQcdlwKzaJ1z2sqymHLx9I4i3UxNSV2KnOOs9bnNhjzU3pG0iNZ5Z38aMyU7RDVtJz/cQBobxVCytUer/EOQHiq1XmucaCtyNIi4ZPfD21JWAklvQTwzhFtS6M/ipEf0OZjO+fnnuJi1D/eyx9x5Z7YMlGgJABijoOId2Y/HyDMCOPlAep8Np03bAUjncAqM7h0K7TlLZ8U65sP7r8yGWvbokjuFhUHBVw9uZhtF05NRYVkILY+uVaItrjskOkyQm7qRc7eygGIdh6j/ydJTbRAeCCh6T9ShrEJaNiUlA5bYL3H0O38yYxUaEp2HFT/NLn8muiR2E5Wk1aphQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=synaptics.com; dmarc=pass action=none header.from=synaptics.com; dkim=pass header.d=synaptics.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Synaptics.onmicrosoft.com; s=selector2-Synaptics-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=SHV4Bmuw5aXp3ktT0yj9WugDe8VRvEdaGtvYNAk1kkU=; b=ZXR0UYE50UsiMsQpfsS+Os2Dbqa4Bu2eRgIz3DWkagoJ0WNnD7PnBZbkKHH2FrfUxuww9AmIlSvC2lDjm2h40ys7eMMYjGlyEipewkhMCVIerm0D/k+DHGl1guXP58epCemp4ZD2mKnGbTFX7dK4A2r0ilcmbzpp4p+PJNmX3zs= Received: from BYAPR03MB4773.namprd03.prod.outlook.com (20.179.92.152) by BYAPR03MB4838.namprd03.prod.outlook.com (20.179.93.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2178.16; Mon, 19 Aug 2019 11:38:10 +0000 Received: from BYAPR03MB4773.namprd03.prod.outlook.com ([fe80::a517:3578:67bf:6c88]) by BYAPR03MB4773.namprd03.prod.outlook.com ([fe80::a517:3578:67bf:6c88%7]) with mapi id 15.20.2157.022; Mon, 19 Aug 2019 11:38:10 +0000 From: Jisheng Zhang To: Catalin Marinas , Will Deacon , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Masami Hiramatsu , "David S. Miller" , Anil S Keshavamurthy , "Naveen N. Rao" , Steven Rostedt Subject: [PATCH 4/4] arm64: implement KPROBES_ON_FTRACE Thread-Topic: [PATCH 4/4] arm64: implement KPROBES_ON_FTRACE Thread-Index: AQHVVoKTiZqAlY6xIUan+odTmeZEhQ== Date: Mon, 19 Aug 2019 11:38:10 +0000 Message-ID: <20190819192706.46ce2c1d@xhacker.debian> References: <20190819192422.5ed79702@xhacker.debian> In-Reply-To: <20190819192422.5ed79702@xhacker.debian> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [124.74.246.114] x-clientproxiedby: TY1PR01CA0165.jpnprd01.prod.outlook.com (2603:1096:402::17) To BYAPR03MB4773.namprd03.prod.outlook.com (2603:10b6:a03:134::24) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Jisheng.Zhang@synaptics.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: e69a950a-5303-4eab-cd33-08d72499b63b x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(2017052603328)(7193020); SRVR:BYAPR03MB4838; x-ms-traffictypediagnostic: BYAPR03MB4838: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:3631; x-forefront-prvs: 0134AD334F x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(346002)(376002)(396003)(136003)(39860400002)(189003)(199004)(7736002)(6116002)(186003)(66476007)(66556008)(81166006)(64756008)(66446008)(8676002)(66946007)(81156014)(305945005)(256004)(25786009)(6506007)(386003)(476003)(4326008)(14444005)(446003)(6512007)(1076003)(102836004)(9686003)(26005)(486006)(53936002)(11346002)(66066001)(2906002)(478600001)(86362001)(71200400001)(7416002)(316002)(50226002)(99286004)(6486002)(52116002)(54906003)(6436002)(8936002)(14454004)(3846002)(76176011)(5660300002)(71190400001)(110136005)(921003)(39210200001)(1121003); DIR:OUT; SFP:1101; SCL:1; SRVR:BYAPR03MB4838; H:BYAPR03MB4773.namprd03.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:0; received-spf: None (protection.outlook.com: synaptics.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: JVAhzXWGN+RHNc5sOrfygaEeAi90DmW3gKjSTZ7y3PMaw75YOp+qRa6jH0mL8qr4Inja3mngQBfjnh2zbMJs6mJTy6YkUyosKepIH9ZrJaZ34rYrLEOZivrGLcE2yKmu8YXwhfBbmQ1LvF5GLRVmzCGQ6LgQHXPKL3dmnyJYMqEKYgDKMPZnPe8wvcCm087vZCMRTfnfO/JqH2xoGOUtQwgWC7u4HWsEzP58eOHHUXcNHLkP6ePDw5gv/GHgNzfZcOPgMP6qySyEyLKmR1zQ5nEZ3g0CN79bBTJ+FnlSSTmH58JaJidytGtuPR0gI312OHAPvVLe/swV7FLFtO/S89M8AX3wEXvJE8kv49kHuRqgi9r13fez44SpmmQ0mS4pIo/t0lvLm/WH/7FQ2kZYXmtwgm3KVL+LBzkG6AtMsKM= x-ms-exchange-transport-forked: True Content-ID: <6ADBF4E009D87B44808092E8A8277FF1@namprd03.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: synaptics.com X-MS-Exchange-CrossTenant-Network-Message-Id: e69a950a-5303-4eab-cd33-08d72499b63b X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Aug 2019 11:38:10.4321 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 335d1fbc-2124-4173-9863-17e7051a2a0e X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: bAR38t0jHpjA95jDiMRnkkUWTpnf0slOKUzMXKeUA3EI90k9ZG6llx7XRvpDUKvm4qBfQNdvVkuzPehIV76Yqg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR03MB4838 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190819_043812_314163_B0B7A271 X-CRM114-Status: GOOD ( 13.12 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "x86@kernel.org" , "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP This patch implements KPROBES_ON_FTRACE for arm64. ~ # mount -t debugfs debugfs /sys/kernel/debug/ ~ # cd /sys/kernel/debug/ /sys/kernel/debug # echo 'p _do_fork' > tracing/kprobe_events before the patch: /sys/kernel/debug # cat kprobes/list ffffff801009ff7c k _do_fork+0x4 [DISABLED] after the patch: /sys/kernel/debug # cat kprobes/list ffffff801009ff7c k _do_fork+0x4 [DISABLED][FTRACE] Signed-off-by: Jisheng Zhang --- arch/arm64/Kconfig | 1 + arch/arm64/kernel/probes/Makefile | 1 + arch/arm64/kernel/probes/ftrace.c | 16 ++++++++++++++++ 3 files changed, 18 insertions(+) create mode 100644 arch/arm64/kernel/probes/ftrace.c diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 663392d1eae2..928700f15e23 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -167,6 +167,7 @@ config ARM64 select HAVE_STACKPROTECTOR select HAVE_SYSCALL_TRACEPOINTS select HAVE_KPROBES + select HAVE_KPROBES_ON_FTRACE select HAVE_KRETPROBES select HAVE_GENERIC_VDSO select IOMMU_DMA if IOMMU_SUPPORT diff --git a/arch/arm64/kernel/probes/Makefile b/arch/arm64/kernel/probes/Makefile index 8e4be92e25b1..4020cfc66564 100644 --- a/arch/arm64/kernel/probes/Makefile +++ b/arch/arm64/kernel/probes/Makefile @@ -4,3 +4,4 @@ obj-$(CONFIG_KPROBES) += kprobes.o decode-insn.o \ simulate-insn.o obj-$(CONFIG_UPROBES) += uprobes.o decode-insn.o \ simulate-insn.o +obj-$(CONFIG_KPROBES_ON_FTRACE) += ftrace.o diff --git a/arch/arm64/kernel/probes/ftrace.c b/arch/arm64/kernel/probes/ftrace.c new file mode 100644 index 000000000000..1fe8f105e02e --- /dev/null +++ b/arch/arm64/kernel/probes/ftrace.c @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Dynamic Ftrace based Kprobes Optimization + * + * Copyright (C) 2019 Synaptics Incorporated + * + * Author: Jisheng Zhang + */ + +#include + +int arch_prepare_kprobe_ftrace(struct kprobe *p) +{ + p->ainsn.api.insn = NULL; + return 0; +}