From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0D7C0C433F5 for ; Sat, 27 Nov 2021 12:24:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Mime-Version:References:In-Reply-To: Message-Id:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=o5UPVH4NLV4TKtRHnVsgGMUKw9FnsjJAQcV6WphvFr8=; b=M43yFiRjbgoaJL IIaSUSqZUAJXBTurBcY1b61oWOwjHh7On7VmubPuq2I34V3BtCNdanClSLE0m92SejKFQOgvkKc9P Iaz9P1eEYPPs9rTkOr9OqwppgMX6P9TRVjargHjblFatOi18ZGt+nYvod25EzV2jUjBm8pt4WwXq0 5d83iF8Qyz7MvQeAKCgmDyoHQvIMoqdBdnXbyDbatqxwlxw2+yyaa+xlevsLB507mqk1fMaHrgfP+ wDz1HkAKo37ypbwOZCGSe6h5jnT9FlpHMMl2p4lrJbEoVV+GaBXKndI52nKZ7+gnrn13T3hzakZxm ATtnNJh8mRd30XEIYDmQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqwjZ-00DbRG-MB; Sat, 27 Nov 2021 12:23:13 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqwjV-00DbQX-OV for linux-arm-kernel@lists.infradead.org; Sat, 27 Nov 2021 12:23:11 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 97D3860B12; Sat, 27 Nov 2021 12:23:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E7AD2C53FAD; Sat, 27 Nov 2021 12:23:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1638015788; bh=szy6wuxs7xhFGeL6Y/Zdaeh7n4KYS099yLHSiWljwlw=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=XgxPeLyrfpGVjeKw1SR5UvRfDO7Cg9IiHaP2RdUqi1UgAYcuBRMC5Fpg705VqKUQU pSSL/tzJIAhB6k5kLoom7E2JBGpbnR8hubvFifEwAxdhpspNNfAkff6qw8AZ5MSjJq W2WJ4XMiMGzG7zgiNToE97KvxKPPIOaDzrqjDjjcXp1JZu3HRRh1dAvsMaoKCWcAgW xLGjBucFSkdmRgzkuApziHH0o8QvgLmqdm4Pr6yUUVd9JJDIn+FK8+QA4FOp2AyzvD YC13cANrLCmCAZpgFBBSRWUZXLF1iRPBmfqwzGXv0KRxsv2lh74xQCfRaAIeJEVhKg aaKSe3d9si/aw== Date: Sat, 27 Nov 2021 21:23:02 +0900 From: Masami Hiramatsu To: "liuqi (BA)" Cc: Mark Rutland , , , , , , , , , , , , Subject: Re: [PATCH v4 2/2] arm64: kprobe: Enable OPTPROBE for arm64 Message-Id: <20211127212302.f71345c34e5a62e5e779adb2@kernel.org> In-Reply-To: References: <20210818073336.59678-1-liuqi115@huawei.com> <20210818073336.59678-3-liuqi115@huawei.com> <20210824105001.GA96738@C02TD0UTHF1T.local> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) Mime-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211127_042309_931606_978C7802 X-CRM114-Status: GOOD ( 29.79 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, 26 Nov 2021 18:31:06 +0800 "liuqi (BA)" wrote: > > > On 2021/8/24 18:50, Mark Rutland wrote: > >> diff --git a/arch/arm64/kernel/probes/optprobe_trampoline.S b/arch/arm64/kernel/probes/optprobe_trampoline.S > >> new file mode 100644 > >> index 000000000000..24d713d400cd > >> --- /dev/null > >> +++ b/arch/arm64/kernel/probes/optprobe_trampoline.S > >> @@ -0,0 +1,37 @@ > >> +/* SPDX-License-Identifier: GPL-2.0 */ > >> +/* > >> + * trampoline entry and return code for optprobes. > >> + */ > >> + > >> +#include > >> +#include > >> +#include > >> + > >> + .global optprobe_template_entry > >> +optprobe_template_entry: > > Please use SYM_*(); see arch/arm64/kernel/entry-ftrace.S for examples of > > how to use that for trampolines. > > > > This should be: > > > > SYM_CODE_START(optprobe_template) > > > Hi all, > > I meet a problem when I use SYM_CODE_START(optprobe_template) to replace > optprobe_template_entry. > > If SYM_CODE_START is used, all optprobe will share one trampoline space. > Under this circumstances, if user register two optprobes, trampoline > will be overwritten by the newer one, and this will cause kernel panic > when the old optprobe is trigger. Hm, this is curious, because the template should be copied to the trampoline buffer for each optprobe and be modified. > > Using optprobe_template_entry will not have this problem, as each > optprobe has its own trampoline space (alloced in get_opinsn_slot()). Yes, it is designed to do so. Thank you, > > So how to reuse SYM_CODE_START in this situation, does anyone has a > good idea? > > Thanks, > Qi > > ... and note the matching end below. > > > >> + sub sp, sp, #PT_REGS_SIZE > >> + save_all_base_regs > >> + /* Get parameters to optimized_callback() */ > >> + ldr x0, 1f > >> + mov x1, sp > >> + /* Branch to optimized_callback() */ > >> + .global optprobe_template_call > >> +optprobe_template_call: > > SYM_INNER_LABEL(optprobe_template_call, SYM_L_GLOBAL) > > > > ...and likewise for all the other labels. > > > >> + nop > >> + restore_all_base_regs > >> + ldr lr, [sp, #S_LR] > >> + add sp, sp, #PT_REGS_SIZE > >> + .global optprobe_template_restore_orig_insn > >> +optprobe_template_restore_orig_insn: > >> + nop > >> + .global optprobe_template_restore_end > >> +optprobe_template_restore_end: > >> + nop > >> + .global optprobe_template_end > >> +optprobe_template_end: > >> + .global optprobe_template_val > >> +optprobe_template_val: > >> + 1: .long 0 > >> + .long 0 > >> + .global optprobe_template_max_length > >> +optprobe_template_max_length: > > SYM_INNER_LABEL(optprobe_template_end, SYM_L_GLOBAL) > > SYM_CODE_END(optprobe_template) > > > > Thanks, > > Mark. > > > >> -- -- Masami Hiramatsu _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel