From patchwork Wed Mar 19 00:38:45 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charlie Jenkins X-Patchwork-Id: 14021799 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 A5DCBC28B28 for ; Wed, 19 Mar 2025 00:39:17 +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:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=NpFwNkTHbyoMHzX0Mzr3s9lsGUrrgTVWY8eFSkfYnWU=; b=dGFHtPEjdjdFC+ 9FXGReBMPV8JQiudOZq54CO28PFIF4jYE9h+L0xf8vhY6gdmH5cAcbvG3GHxAVG0D+HuD48KVVULd CNuzrMTvTrmCbxytq7A1yt7OuON1LbUJlOOZzixMWT05SeHwUg8Ku9XLL9Ueaqy6+AwWYJk0/naHB do8cVIUiMe6k0AUIbi2Z4KE+yC/GiTcLlGeyR+2NbaLRa4s277j/fOjPRC/J7xF0+An9RS6UZ66A3 KCQq0NgdFayM1UADbeb5AQs2d4cb72qRQdPRKioAdFKeliBR1ra+qEtSYXh3Aq/C2JglEUb9Hx+xT gWEJSusYY/mu04v2v6sQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tuhSY-00000007cao-2uEa; Wed, 19 Mar 2025 00:39:02 +0000 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tuhSW-00000007cYv-240m for linux-riscv@lists.infradead.org; Wed, 19 Mar 2025 00:39:01 +0000 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-2255003f4c6so112565025ad.0 for ; Tue, 18 Mar 2025 17:39:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1742344740; x=1742949540; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=znX+QMoNxhiOCpRdgKYwDs//uH3bTTrb7rEQK3e8tjw=; b=ldDGzoGSe2RCPeJQyOn8zPueLT7TDHKzBjlpiKKX0GT5bAWapzNV18aSRtdmuK/RkJ UtFdJYN0eDOVQe8BeK69u1i/t56qv26NmWmuv9rpGErjXdWI4KE2UJi7D36VijYH9NYq lkAmNZS0HdzxsQ0h7yAoNkEVeRUxyvD3WvO+CR1x0pgMo/hAbkEjnFkI5bwGKjY1tw8p P9DAa/fKePhLJaNmRfZKlOyDuzy6UGGzZQvZlu5wlQilVMFLtQRBL0ajHFUFgG3Bfilb jesRogI6Uy0tlP1Z8mcBRu2iVhRhSwhRF4VHO8OOTNx28v2ZCa8JmMH5oVIFLDS2J48S bKww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742344740; x=1742949540; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=znX+QMoNxhiOCpRdgKYwDs//uH3bTTrb7rEQK3e8tjw=; b=rC4tV1LVGwg34x7Bj+idm9P22q1Q70l32b2RU+byFH19RmPMqn5bGZEqrD/UYtU6o/ tmPPNAX54xaymmthEQG7dwgeDQk6XW5LPc4f0CFDD8Cz9x0iMdXh2IGLu2YU0qjfug8W 5maUVUIkluyYrbkAuXU1z2f/cPZ+PYfOhMo1h3dk234rQemU7jfD3DonsmpGymQHoKXO ygQ8b4QhKOJ/F0SkwpVK7h5X035IKTdJmZRbbL5tFYwm7QcgxErhMtFzQuCi7A03FSb1 Z0LexqJ7OhjRDkDzvyHHTN3siETbsEAtI2fvI9SgV2OwEZ8ygYF7INsVYMdnJvCUlCQI Zeyw== X-Gm-Message-State: AOJu0Yw4d97Uk+oeX5rZaANzCtwdp/U/Wjr4vw+GhtavLmlW9J9xi7ZX UgeMkTWdX9DNobkg67WxaOGtRKWakGRsuZ35XNZxr1hY3BxCgf/LiYLYI6sb1no= X-Gm-Gg: ASbGncs3NTgaCOSIhh3tZVm5g+PqRqrNmbYJBtr5ifQVlvGRXB9pV8Gxibj/eMExzyK c8n8gJf0EiCj7cVIQ2oNUV+E/sDDLDDVGmPStONU35t6WidSxLiBt8G53SL4qm00ZKer2cSa8Sk kuVww+Yx3vQ4CdxMbAVgQaBgNmjZjM4rSPt0LQH3byjakGx38A2flGPfFeVCp78DGNaz1rG6tZU v5ZMs6n2u1YAz4mxR9PMko0q3E7Twzo08YwSpL+9kcPHIg93rs54eRvEApH2sItKA/BuJVBpOmj rq2gWx4s6HQR+PPB/JBkE0gHyVJk6CnZsoDYMQpp/zlYNiUhiWg62+riViyq X-Google-Smtp-Source: AGHT+IFyJ4hb7nayIdP+tvFD7Z7530OShgxEwdBAXSBZTDT2fdC6UBXUk1X+51NVWEghPe5O6/ayXA== X-Received: by 2002:a17:902:d4c5:b0:224:18b0:86a0 with SMTP id d9443c01a7336-22649a7c1c5mr9920255ad.37.1742344739870; Tue, 18 Mar 2025 17:38:59 -0700 (PDT) Received: from charlie.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-225c6bbe890sm100843415ad.188.2025.03.18.17.38.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Mar 2025 17:38:59 -0700 (PDT) From: Charlie Jenkins Date: Tue, 18 Mar 2025 17:38:45 -0700 Subject: [PATCH v9 1/2] riscv: Move nop definition to insn-def.h MIME-Version: 1.0 Message-Id: <20250318-runtime_const_riscv-v9-1-ddd3534d3e8e@rivosinc.com> References: <20250318-runtime_const_riscv-v9-0-ddd3534d3e8e@rivosinc.com> In-Reply-To: <20250318-runtime_const_riscv-v9-0-ddd3534d3e8e@rivosinc.com> To: Paul Walmsley , Palmer Dabbelt , Ard Biesheuvel , Ben Dooks , Pasha Bouzarjomehri , Emil Renner Berthing , Alexandre Ghiti , Steven Rostedt , Masami Hiramatsu , Mark Rutland , Albert Ou , Peter Zijlstra , Josh Poimboeuf , Jason Baron Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, Charlie Jenkins X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=3569; i=charlie@rivosinc.com; h=from:subject:message-id; bh=nHhYXQAzGWOBz+fiRV2cBI9NDuh7wsnPI3XSuTaljL8=; b=owGbwMvMwCXWx5hUnlvL8Y3xtFoSQ/otIfkQ3duf1/8PsCmcejzUoDqoafJJ0wPHu/yXPd5/Q 51lfo17RykLgxgXg6yYIgvPtQbm1jv6ZUdFyybAzGFlAhnCwMUpABMRPsLwm+Ww5w7x5kVMnLa8 t+LDbVX0Y9PnnD4mHne38uwli52eUYwMa/Z8viB16td7F4dtzs18h594F500+n7n1QaOeyl/vrP P5wQA X-Developer-Key: i=charlie@rivosinc.com; a=openpgp; fpr=7D834FF11B1D8387E61C776FFB10D1F27D6B1354 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250318_173900_535331_9AB1C5A0 X-CRM114-Status: GOOD ( 15.04 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org We have duplicated the definition of the nop instruction in ftrace.h and in jump_label.c. Move this definition into the generic file insn-def.h so that they can share the definition with each other and with future files. Signed-off-by: Charlie Jenkins Reviewed-by: Alexandre Ghiti Tested-by: Alexandre Ghiti --- arch/riscv/include/asm/ftrace.h | 1 - arch/riscv/include/asm/insn-def.h | 2 ++ arch/riscv/kernel/ftrace.c | 6 +++--- arch/riscv/kernel/jump_label.c | 4 ++-- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/arch/riscv/include/asm/ftrace.h b/arch/riscv/include/asm/ftrace.h index c4721ce44ca474654b37b3d51bc0a63d46bc1eff..b7f361a50f6445d02a0d88eef5547ee27c1fb52e 100644 --- a/arch/riscv/include/asm/ftrace.h +++ b/arch/riscv/include/asm/ftrace.h @@ -79,7 +79,6 @@ struct dyn_arch_ftrace { #define AUIPC_RA (0x00000097) #define JALR_T0 (0x000282e7) #define AUIPC_T0 (0x00000297) -#define NOP4 (0x00000013) #define to_jalr_t0(offset) \ (((offset & JALR_OFFSET_MASK) << JALR_SHIFT) | JALR_T0) diff --git a/arch/riscv/include/asm/insn-def.h b/arch/riscv/include/asm/insn-def.h index 9a913010cdd93cdfdd93f467e7880e20cce0dd2b..0a1fc5134f29da190554c59f8cee3b5374c9aa2d 100644 --- a/arch/riscv/include/asm/insn-def.h +++ b/arch/riscv/include/asm/insn-def.h @@ -200,4 +200,6 @@ #define ZAWRS_WRS_NTO ".4byte 0x00d00073" #define ZAWRS_WRS_STO ".4byte 0x01d00073" +#define RISCV_INSN_NOP4 0x00000013U + #endif /* __ASM_INSN_DEF_H */ diff --git a/arch/riscv/kernel/ftrace.c b/arch/riscv/kernel/ftrace.c index 3524db5e4fa014a4594465f849d898a030bfb7b8..674dcdfae7a149c339f1e791adb450535f22991b 100644 --- a/arch/riscv/kernel/ftrace.c +++ b/arch/riscv/kernel/ftrace.c @@ -36,7 +36,7 @@ static int ftrace_check_current_call(unsigned long hook_pos, unsigned int *expected) { unsigned int replaced[2]; - unsigned int nops[2] = {NOP4, NOP4}; + unsigned int nops[2] = {RISCV_INSN_NOP4, RISCV_INSN_NOP4}; /* we expect nops at the hook position */ if (!expected) @@ -68,7 +68,7 @@ static int __ftrace_modify_call(unsigned long hook_pos, unsigned long target, bool enable, bool ra) { unsigned int call[2]; - unsigned int nops[2] = {NOP4, NOP4}; + unsigned int nops[2] = {RISCV_INSN_NOP4, RISCV_INSN_NOP4}; if (ra) make_call_ra(hook_pos, target, call); @@ -97,7 +97,7 @@ int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr) int ftrace_make_nop(struct module *mod, struct dyn_ftrace *rec, unsigned long addr) { - unsigned int nops[2] = {NOP4, NOP4}; + unsigned int nops[2] = {RISCV_INSN_NOP4, RISCV_INSN_NOP4}; if (patch_insn_write((void *)rec->ip, nops, MCOUNT_INSN_SIZE)) return -EPERM; diff --git a/arch/riscv/kernel/jump_label.c b/arch/riscv/kernel/jump_label.c index 654ed159c830b3d5e34ac58bf367107066eb73a1..b4c1a6a3fbd28533552036194f27ed206bea305d 100644 --- a/arch/riscv/kernel/jump_label.c +++ b/arch/riscv/kernel/jump_label.c @@ -11,8 +11,8 @@ #include #include #include +#include -#define RISCV_INSN_NOP 0x00000013U #define RISCV_INSN_JAL 0x0000006fU bool arch_jump_label_transform_queue(struct jump_entry *entry, @@ -33,7 +33,7 @@ bool arch_jump_label_transform_queue(struct jump_entry *entry, (((u32)offset & GENMASK(10, 1)) << (21 - 1)) | (((u32)offset & GENMASK(20, 20)) << (31 - 20)); } else { - insn = RISCV_INSN_NOP; + insn = RISCV_INSN_NOP4; } if (early_boot_irqs_disabled) {