Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp4194986rwl; Mon, 10 Apr 2023 07:31:59 -0700 (PDT) X-Google-Smtp-Source: AKy350ZlwyZaWRcELLCQR7baZZ2F8vUmqyAihRNW5XcD+3wWo3P6A+WGe+3J74D6Uzj2IvxgW0nQ X-Received: by 2002:a17:90b:33c2:b0:246:9eea:de23 with SMTP id lk2-20020a17090b33c200b002469eeade23mr5505190pjb.37.1681137119277; Mon, 10 Apr 2023 07:31:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681137119; cv=none; d=google.com; s=arc-20160816; b=p1BLXC6zyKrhIWf14iMDNQqmCSOZaEhQpILNYJbnJc6PXr1nHZL838V2BctEfforCE EO52jOeDkz3FFSKGrC5/4T7pd3SAdYkPIBs+DWFebCmDbNWv70YZ/qVsIxR6EgfEznej AfCDA16KqM6FqBDwzFF2KPxb+Bk6o1EceRLR5Ecw8Adf/iRAb8m8XNRR6OL061ALdpFP tyumI2tBNQa0v+IwqAnsipnacO2/kMUwqKO3Mf/rw8zgREP9nLfkrLjcqgQGqz0i+VJ1 kCWVJZnIX00V/hPqiLDFCt3FLhSIunjMvxkoZ2Hja9AR7Hsum0B1jTpsGs2mHUWMUnd/ 17jw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=rZNKbehMNTTINFDU2AomwEajUMtD6bk2jQxETutqI0U=; b=Pu4YcBzuLEELmdOdhRgplGkjX1MgrWz2c65iaW6a880HIMoLpXqetF/el10cgfM5TI Ai/G4CDmpRrLvXl/1fwjR5lNuOc/3N4nQBE5h5BLIOrua+bAF7lVCk7I1hCT5gO9PXuz I4tmcuDT2PRBmBJoS64SI2TJ0xKvHMsVyyLd0BKbiXJajZppwt+rstReh6UyQqUO3YlE R5NOt6pPJdKkum3dQjjUjAWt6bjA5bvAb/FgnqVpGoaxVX1TfTxi24gLPPb+BNLe7ixg 4cv+4e3f5euuxOC2SO6mU9e/uQPNW9QUXFQQIAM1hmUM+PRUWL1wa78nSGv115EDFg+m Cmng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@xen0n.name header.s=mail header.b=flfjmvOg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t186-20020a6381c3000000b005195e79b611si3609478pgd.524.2023.04.10.07.31.46; Mon, 10 Apr 2023 07:31:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@xen0n.name header.s=mail header.b=flfjmvOg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229670AbjDJOQj (ORCPT + 99 others); Mon, 10 Apr 2023 10:16:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229603AbjDJOQi (ORCPT ); Mon, 10 Apr 2023 10:16:38 -0400 Received: from mailbox.box.xen0n.name (mail.xen0n.name [115.28.160.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 883A8199E for ; Mon, 10 Apr 2023 07:16:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xen0n.name; s=mail; t=1681136192; bh=JFxIGato1Hvx8g9xV9cO3IPTvj8x3ok57KNjAO1cBMU=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=flfjmvOgDlm6XfvrXM/Rc73uluo1Ja5YN2jPl5HPGCSA7LhEe832Hz/sa+6H0+dA/ wy/FyYdvpMcMK9gct0oClYwhbqiX8HY7qFhXPtfjvRpoPkhhxZVZ7GItMX3k3/pBf6 sXaI8KuNqyxRZpehkw9iGpsMjZp4V+uTgm6q6tNU= Received: from [100.100.33.167] (unknown [220.248.53.61]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mailbox.box.xen0n.name (Postfix) with ESMTPSA id 0BD26600AE; Mon, 10 Apr 2023 22:16:32 +0800 (CST) Message-ID: <01dcb3b6-efdb-af17-93a5-f6288b3f816d@xen0n.name> Date: Mon, 10 Apr 2023 22:16:31 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.9.1 Subject: Re: [RFC PATCH 2/3] LoongArch: Add larch_insn_gen_break() to generate break insn Content-Language: en-US To: Tiezhu Yang , Youling Tang Cc: Huacai Chen , loongarch@lists.linux.dev, linux-kernel@vger.kernel.org, loongson-kernel@lists.loongnix.cn References: <1680833701-1727-1-git-send-email-yangtiezhu@loongson.cn> <1680833701-1727-3-git-send-email-yangtiezhu@loongson.cn> <0d309725-3b91-6902-de67-08bda48ccf57@loongson.cn> <9433a12a-b24b-4438-fdc8-0213522c71ba@loongson.cn> From: WANG Xuerui In-Reply-To: <9433a12a-b24b-4438-fdc8-0213522c71ba@loongson.cn> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2023/4/7 20:02, Tiezhu Yang wrote: > > > On 04/07/2023 05:51 PM, WANG Xuerui wrote: >> On 2023/4/7 10:30, Youling Tang wrote: >>> /* snip */ >>> >>>> diff --git a/arch/loongarch/kernel/kprobes.c >>>> b/arch/loongarch/kernel/kprobes.c >>>> index 08c78d2..a5c3712 100644 >>>> --- a/arch/loongarch/kernel/kprobes.c >>>> +++ b/arch/loongarch/kernel/kprobes.c >>>> @@ -4,19 +4,8 @@ >>>>  #include >>>>  #include >>>> >>>> -static const union loongarch_instruction breakpoint_insn = { >>>> -    .reg0i15_format = { >>>> -        .opcode = break_op, >>>> -        .immediate = BRK_KPROBE_BP, >>>> -    } >>>> -}; >>>> - >>>> -static const union loongarch_instruction singlestep_insn = { >>>> -    .reg0i15_format = { >>>> -        .opcode = break_op, >>>> -        .immediate = BRK_KPROBE_SSTEPBP, >>>> -    } >>>> -}; >>>> +#define breakpoint_insn larch_insn_gen_break(BRK_KPROBE_BP) >>>> +#define singlestep_insn larch_insn_gen_break(BRK_KPROBE_SSTEPBP) >>> >>> IMO, Defined as KPROBE_BP_INSN, KPROBE_SSTEPBP_INSN may be better. >> >> Are you suggesting to hardcode the instruction words for those two BREAK >> flavors? > > I think what Youling said is: > > #define KPROBE_BP_INSN         larch_insn_gen_break(BRK_KPROBE_BP) > #define KPROBE_SSTEPBP_INSN    larch_insn_gen_break(BRK_KPROBE_SSTEPBP) > >> I don't think it's better because even more structured info is >> lost, and the compiler would generate the same code (if not, it's the >> compiler that's to be fixed). >> >> Actually, I don't know why this commit was necessary in the first place. >> For the very least, it consisted of two logical changes (pass around >> instruction words instead of unions; and change the BREAK insns to make >> them words) that should get split; > > Yes, thanks for your suggestion, I will split it into two patches > in the next version. > >> but again, the generated code should >> be identical anyway, so it seems a lot of churn for no benefit and >> reduced readability. >> > > Define and use larch_insn_gen_break() is to avoid hardcoding the > uprobe break instruction in patch #3. > > We do not like the following definitions: > > #define UPROBE_SWBP_INSN    0x002a000c > #define UPROBE_XOLBP_INSN    0x002a000d > > Using larch_insn_gen_break() seems better: > > #define UPROBE_SWBP_INSN    larch_insn_gen_break(BRK_UPROBE_BP) > #define UPROBE_XOLBP_INSN    larch_insn_gen_break(BRK_UPROBE_XOLBP) Sorry, I meant *not* ditching the union-typed parameters. IMO they should behave the same codegen-wise (i.e. unchanged performance), and have the benefit of being clearly typed unlike plain u32's. -- WANG "xen0n" Xuerui Linux/LoongArch mailing list: https://lore.kernel.org/loongarch/