Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp631148rwl; Fri, 7 Apr 2023 02:59:51 -0700 (PDT) X-Google-Smtp-Source: AKy350aiA1rj1/gveS0319f2R+xfJxTlwoi1UVZSUdRgtPFFc5d9309YU+rxP9OTTzvye3uLUNgz X-Received: by 2002:a05:6a20:17aa:b0:df:4e86:9c99 with SMTP id bl42-20020a056a2017aa00b000df4e869c99mr1466413pzb.55.1680861591453; Fri, 07 Apr 2023 02:59:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680861591; cv=none; d=google.com; s=arc-20160816; b=KqxekNgjWu/VXNSesvmaEuQkGR/a9DSr9kO7UgulCvggl8gvfeU12Y8GrHckoWvgaQ xv6i3ELdEN38J2PTpwgAhivqK8KFlSWvFHbOrRgSvrM77kDI1mfzBbim16tSCBs8Z5T+ aBbcECPdp30NyLpF5GDPTQd4w1sXo/2PAEx4buSVYhwBqOuMMZNPmJXHAtRr0eBa4qGq 01MFr89raXqDbUlpBY8YC5LtRv0PW5HO/UdQixR9j4H7galCLjgIvfyH96YGhRwS4OeD gpqdHn6LCra4gRXwbBCPBkqlKu82U4c3QKVb2+lCpqw4K2QScqPGfDCrmtuSdS8agfuF iXLA== 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=BN1alnavnn/ZH/ld59AT2jCBNg4AAFPbvTUG5qjLDA8=; b=ycWUSwpxpCCv6va42HRZdzKgsJ9goHSJLoGjyMLDn+Xw+tQ9vcoXThQ8Xv73jmKT1L MnigyHDVe15VwAlfTO0rVKRrkL9q5QnRRgjk3LnS051pAyPZYAaf11+k+XoalkMxnHbh U9L7lIXwJiewQ4TlFYXHnzBXHvu7nLdj00CCOW6+ZtFkieNvnOljZXFfoNzKr+9Hhcsx n3WgUYTV2w67fK/MyD4LEyWbiGSIjY/pFB6fXTQu9o0N3slIinT0tim/QXJCme3TAXQW xYKkhTsZGywjnSywsdrQpW1IxeoEEFF7eA2ChKl1/Lef2qICHE5bOPmTJhsfII6bmjG1 mLoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@xen0n.name header.s=mail header.b=Kj0ExMKp; 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 196-20020a6301cd000000b00503011e4f27si3300643pgb.869.2023.04.07.02.59.39; Fri, 07 Apr 2023 02:59:51 -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=Kj0ExMKp; 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 S239663AbjDGJwD (ORCPT + 99 others); Fri, 7 Apr 2023 05:52:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229482AbjDGJwB (ORCPT ); Fri, 7 Apr 2023 05:52:01 -0400 Received: from mailbox.box.xen0n.name (mail.xen0n.name [115.28.160.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E3E4C49E3 for ; Fri, 7 Apr 2023 02:51:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xen0n.name; s=mail; t=1680861117; bh=xStM71TMN048Ko9ww+BuNB+3v2DyF7jsusOnwx7u2zY=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=Kj0ExMKphuz60PvZsIJCRm+JsuEv1z4mLaBEJcQ4YmsrfI0LZt30DSJrhzej9b8qc /15UHuafi18hwdUZ0jvwZmquzx2iBA5l/Ot6RAvK/H12YBNMwxrhVGJnpWQU9iCMHB EktiuswpPJNE3yKtZ2aTinyLtVhniLARJj5gwnSI= 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 795E4600F8; Fri, 7 Apr 2023 17:51:57 +0800 (CST) Message-ID: Date: Fri, 7 Apr 2023 17:51:57 +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: Youling Tang , Tiezhu Yang 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> From: WANG Xuerui In-Reply-To: <0d309725-3b91-6902-de67-08bda48ccf57@loongson.cn> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.2 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 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 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; but again, the generated code should be identical anyway, so it seems a lot of churn for no benefit and reduced readability. -- WANG "xen0n" Xuerui Linux/LoongArch mailing list: https://lore.kernel.org/loongarch/