From patchwork Mon Jun 5 06:39:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tiezhu Yang X-Patchwork-Id: 103102 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp2494482vqr; Sun, 4 Jun 2023 23:55:55 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7OFLMo2CATwtIHQNvEPoFHbdA7Y2KMRVA+v7LtpPFxC0SbnwSXYzXvKpYAJAoMVVrhjBvV X-Received: by 2002:a05:6358:c601:b0:128:2e1e:5dbc with SMTP id fd1-20020a056358c60100b001282e1e5dbcmr6582075rwb.25.1685948154790; Sun, 04 Jun 2023 23:55:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685948154; cv=none; d=google.com; s=arc-20160816; b=I8UTfoXxqfk9kjDCRvMboYuRO70b+jFu1K4ZhL3mY0ylAHYSBNaNGSatG0Jr6XMOBo 1jnRCfmeAMeIAXN3G/zlFklsckuFCkm6Mq/IGzI6lvSrba0z6J95ivG8+ymIs4RWHPL4 tRWZJeRzN2BE6BmfQpEcKPjjsLFQ+k4U+/7xSKNxpw9D9vhtho3sOk+FieaGSM60fPbB UFRnH9n/hU+03MzcvQ5x/urSkxQGhACHj5dV1pPuqPg59ErWbyQQY9jvCxrcZIq7H7zA lpSR9tuX1b2hebHxs0Aw6PQeolminCTSKt2NDuyd3ZQeP/mnEbcEEBECymFuZOPLotki BZVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=m0pxXMAMlntO3lxXNVOiu6B7euCcqzoDy39LRJrd9AQ=; b=HBXJwSu69ZALkMUmTqlYV2fQ53KYNW2+y+EBW4V2qfRViob44Be/KMv2iPRz0WVja1 BYpONrInQlG2VrvIAZYKUjDtjseDw+ZN+5+Uc0o+6NE00iQHnoFegYf9x1hdGvBZ0aRg Ja2ibwkkbKG3eUrDPXA2dzcLzJBezaG8VPOv3Uj8EA/IRy8ap/IMuHezcgWkZYi7poNc 3Te3ScIQWWRplh/Gxm+0Mz8Z33Shch7Ztfi8phFgsomKwzpP+4Y2UW5cV0NRU/S+BQPT HYBl/ntz3eI0qecxf2+ZdzSSRBYiy31V8bfWzFsXmS6QHcu+w76464u94DoscdZq1ih6 XtSQ== ARC-Authentication-Results: i=1; mx.google.com; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f10-20020a63de0a000000b0053febd41e7esi5226127pgg.380.2023.06.04.23.55.41; Sun, 04 Jun 2023 23:55:54 -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; 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 S229926AbjFEGjZ (ORCPT + 99 others); Mon, 5 Jun 2023 02:39:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52078 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229640AbjFEGjS (ORCPT ); Mon, 5 Jun 2023 02:39:18 -0400 Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3773FDA for ; Sun, 4 Jun 2023 23:39:13 -0700 (PDT) Received: from loongson.cn (unknown [113.200.148.30]) by gateway (Coremail) with SMTP id _____8BxP_AQg31k9wUAAA--.161S3; Mon, 05 Jun 2023 14:39:12 +0800 (CST) Received: from linux.localdomain (unknown [113.200.148.30]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Axa9YPg31kHQcAAA--.72S4; Mon, 05 Jun 2023 14:39:12 +0800 (CST) From: Tiezhu Yang To: Huacai Chen Cc: loongarch@lists.linux.dev, linux-kernel@vger.kernel.org, loongson-kernel@lists.loongnix.cn Subject: [PATCH v5 2/6] LoongArch: Add larch_insn_gen_break() to generate break insns Date: Mon, 5 Jun 2023 14:39:06 +0800 Message-Id: <1685947150-4949-3-git-send-email-yangtiezhu@loongson.cn> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1685947150-4949-1-git-send-email-yangtiezhu@loongson.cn> References: <1685947150-4949-1-git-send-email-yangtiezhu@loongson.cn> X-CM-TRANSID: AQAAf8Axa9YPg31kHQcAAA--.72S4 X-CM-SenderInfo: p1dqw3xlh2x3gn0dqz5rrqw2lrqou0/ X-Coremail-Antispam: 1Uk129KBj93XoW7tw1UJw13AF45KF17KFWrtFc_yoW8trW3pF nrZwn5KrW5GryfGr9Iq345ur13Jws7WwsFqFsxta4xGr4UX3W5XFy0gryqqFyjvw4kWFW0 q3WSqw12v3W5JagCm3ZEXasCq-sJn29KB7ZKAUJUUUUr529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUU9jb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r1Y6r17M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Xr0_Ar1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Gr0_Cr1l84ACjcxK6I8E87Iv67AKxVW8JVWxJwA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_ Gr0_Gr1UM2kKe7AKxVWUXVWUAwAS0I0E0xvYzxvE52x082IY62kv0487Mc804VCY07AIYI kI8VC2zVCFFI0UMc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUtVWr XwAv7VC2z280aVAFwI0_Gr0_Cr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI4 8JMxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMxCIbckI1I0E14v26r1Y 6r17MI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7 AF67AKxVWUAVWUtwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r4j6ryUMIIF0xvE 2Ix0cI8IcVCY1x0267AKxVW8JVWxJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcV C2z280aVAFwI0_Gr0_Cr1lIxAIcVC2z280aVCY1x0267AKxVW8JVW8JrUvcSsGvfC2Kfnx nUUI43ZEXa7IU8EeHDUUUUU== X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767844772249165194?= X-GMAIL-MSGID: =?utf-8?q?1767844772249165194?= There exist various break insns such as BRK_KPROBE_BP, BRK_KPROBE_SSTEPBP, BRK_UPROBE_BP and BRK_UPROBE_XOLBP, add larch_insn_gen_break() to generate break insns simpler, this is preparation for later patch. Signed-off-by: Tiezhu Yang Tested-by: Jeff Xie --- arch/loongarch/include/asm/inst.h | 12 ++++++++++++ arch/loongarch/kernel/inst.c | 9 +++++++++ 2 files changed, 21 insertions(+) diff --git a/arch/loongarch/include/asm/inst.h b/arch/loongarch/include/asm/inst.h index c9e5435..01fb789 100644 --- a/arch/loongarch/include/asm/inst.h +++ b/arch/loongarch/include/asm/inst.h @@ -447,6 +447,8 @@ u32 larch_insn_gen_nop(void); u32 larch_insn_gen_b(unsigned long pc, unsigned long dest); u32 larch_insn_gen_bl(unsigned long pc, unsigned long dest); +u32 larch_insn_gen_break(int imm); + u32 larch_insn_gen_or(enum loongarch_gpr rd, enum loongarch_gpr rj, enum loongarch_gpr rk); u32 larch_insn_gen_move(enum loongarch_gpr rd, enum loongarch_gpr rj); @@ -465,6 +467,16 @@ static inline bool unsigned_imm_check(unsigned long val, unsigned int bit) return val < (1UL << bit); } +#define DEF_EMIT_REG0I15_FORMAT(NAME, OP) \ +static inline void emit_##NAME(union loongarch_instruction *insn, \ + int imm) \ +{ \ + insn->reg0i15_format.opcode = OP; \ + insn->reg0i15_format.immediate = imm; \ +} + +DEF_EMIT_REG0I15_FORMAT(break, break_op) + #define DEF_EMIT_REG0I26_FORMAT(NAME, OP) \ static inline void emit_##NAME(union loongarch_instruction *insn, \ int offset) \ diff --git a/arch/loongarch/kernel/inst.c b/arch/loongarch/kernel/inst.c index 6f61956..1d7d579 100644 --- a/arch/loongarch/kernel/inst.c +++ b/arch/loongarch/kernel/inst.c @@ -247,6 +247,15 @@ u32 larch_insn_gen_bl(unsigned long pc, unsigned long dest) return insn.word; } +u32 larch_insn_gen_break(int imm) +{ + union loongarch_instruction insn; + + emit_break(&insn, imm); + + return insn.word; +} + u32 larch_insn_gen_or(enum loongarch_gpr rd, enum loongarch_gpr rj, enum loongarch_gpr rk) { union loongarch_instruction insn;