From patchwork Thu May 11 08:06:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tiezhu Yang X-Patchwork-Id: 92428 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp4200438vqo; Thu, 11 May 2023 01:15:48 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5DqAsEtkkknsI4fU8wo/V2gXcbCA5p6y8r86mVIXA/k0dkyzQ8RpSOdr9uwvuJWzw8uZMa X-Received: by 2002:a05:6a20:938f:b0:102:a593:a17c with SMTP id x15-20020a056a20938f00b00102a593a17cmr6273098pzh.0.1683792947862; Thu, 11 May 2023 01:15:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683792947; cv=none; d=google.com; s=arc-20160816; b=tTbh0Ire2D9tlLk2+XwpmVF2nAjZ21R/A5f9AHjfZgUI67VjAzh1Z461CWO2PKRDdD gwgcxxURFuI6U65VeGBpQ0eCL8/jVh6422G+ml3n8y8o7M+OZbEUz3k2uNaszF8Xgkn+ XQIdgPpNaglm9E7fyn2dRPNl3NQw8R9iqwoqG3DdqCUWCx02B1Clvd72GrCG47Kt24bz k3laPTCVp6a87NPmu45W6wbFnZUTNyVW5QN8rkR8Yf5wPbnmlDnV7NlF6YflBr3qK5C4 d11X23Tg2pipW2vhWIM8Tw0/hhFou4Q05tGpCNjo/KBOdOoH2d/+B/YenLMKH+DD0cKI PzGw== 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=LL3ARI9QPg3CX5anL1RjAiakq6SaS2KX8f68Nml/gkg=; b=HpizAvkqcrCWZ0dYp8dXb6xlAVQcf2hMIONH/YchvXnsQ+rKjOSrOmd3q5SrX1ADq7 U4h8BloqS72cbcF0IaScj+2Iq8IMPQBit3+UQ1dKAEy6yZxigoV7GzP/c9IGnsBhc48T E5yrd/obE6ojdnI7X1G8fmbnmWMFn5hBpqELBh9ymkqhzZ61jaD/MLxhGbvEmqTac2rl W09ePyK76FfSUODY+8XBxxT5hU6xhBTupUKV3JQHycNZF6ZBH52y+1UGrRXgkQETmCwT m1U2Q2TVx6iuHxtHzI0M6jqEvi4PYYh0Nj2QHVsPz7FPXLmOe/KtmCGDTtthgf8cT1zi 7ARg== 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 l65-20020a639144000000b005307ce6fcfdsi508368pge.472.2023.05.11.01.15.35; Thu, 11 May 2023 01:15:47 -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 S235692AbjEKIGu (ORCPT + 99 others); Thu, 11 May 2023 04:06:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235497AbjEKIGa (ORCPT ); Thu, 11 May 2023 04:06:30 -0400 Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E2DAFA26F for ; Thu, 11 May 2023 01:06:21 -0700 (PDT) Received: from loongson.cn (unknown [113.200.148.30]) by gateway (Coremail) with SMTP id _____8CxE_D8oVxkPq0HAA--.13109S3; Thu, 11 May 2023 16:06:20 +0800 (CST) Received: from linux.localdomain (unknown [113.200.148.30]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Cxqjr5oVxk7XNVAA--.21787S4; Thu, 11 May 2023 16:06:20 +0800 (CST) From: Tiezhu Yang To: Huacai Chen , WANG Xuerui Cc: loongarch@lists.linux.dev, linux-kernel@vger.kernel.org, loongson-kernel@lists.loongnix.cn Subject: [PATCH v4 2/6] LoongArch: Add larch_insn_gen_break() to generate break insns Date: Thu, 11 May 2023 16:06:08 +0800 Message-Id: <1683792372-29338-3-git-send-email-yangtiezhu@loongson.cn> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1683792372-29338-1-git-send-email-yangtiezhu@loongson.cn> References: <1683792372-29338-1-git-send-email-yangtiezhu@loongson.cn> X-CM-TRANSID: AQAAf8Cxqjr5oVxk7XNVAA--.21787S4 X-CM-SenderInfo: p1dqw3xlh2x3gn0dqz5rrqw2lrqou0/ X-Coremail-Antispam: 1Uk129KBjvJXoW7KFWfXF4furWUWr4DXFy7Wrg_yoW8uw1kpF nFvwn5KrW5GryfGr9Iq3y5ur13Jan7WwsFqFZIya4xGr4UX3W5XFy0gryqqFyjva1kWFW0 q3WSqw12v3W5JaDanT9S1TB71UUUUUJqnTZGkaVYY2UrUUUUj1kv1TuYvTs0mT0YCTnIWj qI5I8CrVACY4xI64kE6c02F40Ex7xfYxn0WfASr-VFAUDa7-sFnT9fnUUIcSsGvfJTRUUU b3AYFVCjjxCrM7AC8VAFwI0_Jr0_Gr1l1xkIjI8I6I8E6xAIw20EY4v20xvaj40_Wr0E3s 1l1IIY67AEw4v_JF0_JFyl8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28EF7xv wVC0I7IYx2IY67AKxVW5JVW7JwA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxVW8JVWxJwA2z4 x0Y4vEx4A2jsIE14v26r4UJVWxJr1l84ACjcxK6I8E87Iv6xkF7I0E14v26r4UJVWxJr1l n4kS14v26r1Y6r17M2AIxVAIcxkEcVAq07x20xvEncxIr21l57IF6xkI12xvs2x26I8E6x ACxx1l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r1q6rW5McIj6I8E 87Iv67AKxVW8JVWxJwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41l42xK82 IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1l4IxYO2xFxVAFwI0_Jrv_JF1lx2Iq xVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r 126r1DMIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Gr0_Xr1lIxAIcVC0I7IYx2IY 6xkF7I0E14v26r4j6F4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67 AKxVW8JVWxJwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuY vjxU4OzVUUUUU X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, 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?1765584874082804542?= X-GMAIL-MSGID: =?utf-8?q?1765584874082804542?= 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 --- 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;