Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6846621imu; Wed, 14 Nov 2018 07:51:01 -0800 (PST) X-Google-Smtp-Source: AJdET5f2r2J58uqGnwXZq2xxWkcjEEZ2MQXXojQK+JAJt9sxg7unQf76CNBaQpWwW6ipXQtPCseL X-Received: by 2002:a17:902:6f16:: with SMTP id w22-v6mr2458727plk.235.1542210661361; Wed, 14 Nov 2018 07:51:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542210661; cv=none; d=google.com; s=arc-20160816; b=k3OnXqj4s2y15XV+YJovF5V3oLrQFG6Cobw3fAnEjwWGmnXE1CO0oJnO7YKlfh7mVj q1XDqiKcGlSSr31xomCLSFqoy6Y19i4H04CCov+3iKmQ8Lgc/8QVRuOgEho7p/MwgTxQ Ypvbbw2d0MGCpOpPB9TCfQPNKjI0baYTulCuvDcrYDW2A4VS3494MiHVo2tJeuMwm9mN dUi69WxjY39xtjJM0h6WxXY7Qre0ASnkRKHNYGNWDFpHFE3Z9EJaBXDeu37OMtpNJtCT apYOV8zrCnKFeeBBu5xSoe9dGDHb+9srlSO35tF+Pxgf6DB5eBfkhgsZ0ZV5PfkMBahH FEyQ== 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=bdVtQAknJ+5D+FkIkUL1SMbrqSw+rjwzZl2X3oB6qbE=; b=CTn+ztc3FUk25yxHOM4MEURn/KizVW8TIDkNcykLcuWFH0Lm71hi3RIxN5WtE7VQE1 5hl1o0NlwGKLjyeM5OlSpgGcwB+zaWEJVw4ZTIBxlfZvJELRyHaRGBY2au45aN5k4oVc eIVvsadxVQ4IDzcu8PcOohYALvy3tT5aTYXMc1nVWqqSKWerrFVx319HKsVrNAB1NrY8 bWBRODpzDT/CD2qakrXxfOtdkHAx2Xl4wTEGEtN5cOM7sqBllDV2azLwEBCDDMLy68VN dK5Hzs+daceWeLHtTMe5pJ8RspfxL0++2eEDmv7GUCRL2+irIJmmhAgX9pMfcyz7sxXL zkgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=A6am2etp; 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 o186-v6si27389054pfo.236.2018.11.14.07.50.45; Wed, 14 Nov 2018 07:51:01 -0800 (PST) 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=A6am2etp; 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 S2387561AbeKOBxj (ORCPT + 99 others); Wed, 14 Nov 2018 20:53:39 -0500 Received: from mail.kernel.org ([198.145.29.99]:56138 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732950AbeKOBxj (ORCPT ); Wed, 14 Nov 2018 20:53:39 -0500 Received: from devnote (unknown [64.114.255.114]) (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 D3D5A214F1; Wed, 14 Nov 2018 15:49:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1542210592; bh=D18OzsVre62OCCAyxjcygNQHmbI7ApSJ9PDtChqSB9w=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=A6am2etpp90qUteJ6dJ6NBAHnp+G5DSaXGjx0dzIYNfT0FIgeuMTAML4a/SFB0cv3 yTP4GteG1Nj0lNi9Aza3P/qQx5oYKx89pOV924JEOf3nI8jnu6wj2l1NNzgY0ibS/M aBOhA/Gxme7UqJkM5b0CsjJgZTwIhTvdZ43j4otI= Date: Wed, 14 Nov 2018 07:49:51 -0800 From: Masami Hiramatsu To: Masami Hiramatsu Cc: Patrick =?UTF-8?B?U3TDpGhsaW4=?= , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Palmer Dabbelt , Albert Ou , Alan Kao , Zong Li , Ingo Molnar , Will Deacon , Thomas Gleixner , Catalin Marinas , zhong jiang , Anders Roxell , "Eric W. Biederman" , Jim Wilson , Luc Van Oostenryck , Souptick Joarder , Andrew Morton , Al Viro Subject: Re: [RFC/RFT 2/2] RISC-V: kprobes/kretprobe support Message-Id: <20181114074951.0902699286fdf8652f2878a4@kernel.org> In-Reply-To: <20181114003730.06f810517a270070734df4ce@kernel.org> References: <20181113195804.22825-1-me@packi.ch> <20181113195804.22825-3-me@packi.ch> <20181114003730.06f810517a270070734df4ce@kernel.org> X-Mailer: Sylpheed 3.5.0 (GTK+ 2.24.30; 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 Wed, 14 Nov 2018 00:37:30 -0800 Masami Hiramatsu wrote: > > + > > +static int __kprobes patch_text(kprobe_opcode_t *addr, u32 opcode) > > +{ > > + if (is_compressed_insn(opcode)) > > + *(u16 *)addr = cpu_to_le16(opcode); > > + else > > + *addr = cpu_to_le32(opcode); > > + BTW, don't RISC-V need any i-cache flush and per-core serialization for patching the text area? (and no text_mutex protection?) > > diff --git a/arch/riscv/kernel/probes/kprobes_trampoline.S b/arch/riscv/kernel/probes/kprobes_trampoline.S > > new file mode 100644 > > index 000000000000..c7ceda9556a3 > > --- /dev/null > > +++ b/arch/riscv/kernel/probes/kprobes_trampoline.S > > @@ -0,0 +1,91 @@ > > +/* SPDX-License-Identifier: GPL-2.0+ */ > > + > > +#include > > + > > +#include > > +#include > > + > > + .text > > + .altmacro > > + > > + .macro save_all_base_regs > > + REG_S x1, PT_RA(sp) > > + REG_S x3, PT_GP(sp) > > + REG_S x4, PT_TP(sp) > > + REG_S x5, PT_T0(sp) > > + REG_S x6, PT_T1(sp) > > + REG_S x7, PT_T2(sp) > > + REG_S x8, PT_S0(sp) > > + REG_S x9, PT_S1(sp) > > + REG_S x10, PT_A0(sp) > > + REG_S x11, PT_A1(sp) > > + REG_S x12, PT_A2(sp) > > + REG_S x13, PT_A3(sp) > > + REG_S x14, PT_A4(sp) > > + REG_S x15, PT_A5(sp) > > + REG_S x16, PT_A6(sp) > > + REG_S x17, PT_A7(sp) > > + REG_S x18, PT_S2(sp) > > + REG_S x19, PT_S3(sp) > > + REG_S x20, PT_S4(sp) > > + REG_S x21, PT_S5(sp) > > + REG_S x22, PT_S6(sp) > > + REG_S x23, PT_S7(sp) > > + REG_S x24, PT_S8(sp) > > + REG_S x25, PT_S9(sp) > > + REG_S x26, PT_S10(sp) > > + REG_S x27, PT_S11(sp) > > + REG_S x28, PT_T3(sp) > > + REG_S x29, PT_T4(sp) > > + REG_S x30, PT_T5(sp) > > + REG_S x31, PT_T6(sp) > > + .endm > > + > > + .macro restore_all_base_regs > > + REG_L x3, PT_GP(sp) > > + REG_L x4, PT_TP(sp) > > + REG_L x5, PT_T0(sp) > > + REG_L x6, PT_T1(sp) > > + REG_L x7, PT_T2(sp) > > + REG_L x8, PT_S0(sp) > > + REG_L x9, PT_S1(sp) > > + REG_L x10, PT_A0(sp) > > + REG_L x11, PT_A1(sp) > > + REG_L x12, PT_A2(sp) > > + REG_L x13, PT_A3(sp) > > + REG_L x14, PT_A4(sp) > > + REG_L x15, PT_A5(sp) > > + REG_L x16, PT_A6(sp) > > + REG_L x17, PT_A7(sp) > > + REG_L x18, PT_S2(sp) > > + REG_L x19, PT_S3(sp) > > + REG_L x20, PT_S4(sp) > > + REG_L x21, PT_S5(sp) > > + REG_L x22, PT_S6(sp) > > + REG_L x23, PT_S7(sp) > > + REG_L x24, PT_S8(sp) > > + REG_L x25, PT_S9(sp) > > + REG_L x26, PT_S10(sp) > > + REG_L x27, PT_S11(sp) > > + REG_L x28, PT_T3(sp) > > + REG_L x29, PT_T4(sp) > > + REG_L x30, PT_T5(sp) > > + REG_L x31, PT_T6(sp) > > + .endm It seems thses macros can be (partially?) shared with entry.S Thank you, -- Masami Hiramatsu