From nobody Tue Sep 16 03:29:27 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2F9E4C46467 for ; Sat, 7 Jan 2023 13:36:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232577AbjAGNgY (ORCPT ); Sat, 7 Jan 2023 08:36:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32834 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232161AbjAGNgQ (ORCPT ); Sat, 7 Jan 2023 08:36:16 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3654210553 for ; Sat, 7 Jan 2023 05:36:15 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C48A8606DC for ; Sat, 7 Jan 2023 13:36:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 042FFC433D2; Sat, 7 Jan 2023 13:36:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1673098574; bh=903dKK56VBWA9nReoduRM1k/JbBxJj/M+VNo1IXCs18=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vCeDk01U0FqRBqslPDJ1SQ6NQa4uGYOkTag44ubpYQCa1M5/91Y/7NwZGvgyKVmj+ fvTB/My9tcVvxKSEu/dlGOvlCSOMNYUpBBS8DVYjAcivpNsD3yXojAk807lM6GoRHE jiWNrcnHhnJFNqL/M8OzR3+VBISLdCFm8/jRtyrtz1IUWsNR+o4x8ieNrxDrvunG8V eYD1HfDROaDLXAA1gzaSmhucnFakUlee8EZaddD+yOJGmlxSmEjXgw5uIrKnXwmx75 FQiUweN27gB52CgLLCOV3ntR339GXBkM37DVlSI/bElfSdCdo2g3D4C+hpbbx00Z1S cKK8y6W5Id/Vw== From: guoren@kernel.org To: anup@brainfault.org, paul.walmsley@sifive.com, palmer@dabbelt.com, conor.dooley@microchip.com, heiko@sntech.de, rostedt@goodmis.org, mhiramat@kernel.org, jolsa@redhat.com, bp@suse.de, jpoimboe@kernel.org, suagrfillet@gmail.com, andy.chiu@sifive.com, e.shatokhin@yadro.com, guoren@kernel.org Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Guo Ren Subject: [PATCH -next V6 2/7] riscv: ftrace: Remove wasted nops for !RISCV_ISA_C Date: Sat, 7 Jan 2023 08:35:44 -0500 Message-Id: <20230107133549.4192639-3-guoren@kernel.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20230107133549.4192639-1-guoren@kernel.org> References: <20230107133549.4192639-1-guoren@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Guo Ren When CONFIG_RISCV_ISA_C=3Dn, -fpatchable-function-entry=3D8 would generate more nops than we expect. Because it treat nop opcode as 0x00000013 instead of 0x0001. Dump of assembler code for function dw_pcie_free_msi: 0xffffffff806fce94 <+0>: sd ra,-8(sp) 0xffffffff806fce98 <+4>: auipc ra,0xff90f 0xffffffff806fce9c <+8>: jalr -684(ra) # 0xffffffff8000bbec 0xffffffff806fcea0 <+12>: ld ra,-8(sp) 0xffffffff806fcea4 <+16>: nop /* wasted */ 0xffffffff806fcea8 <+20>: nop /* wasted */ 0xffffffff806fceac <+24>: nop /* wasted */ 0xffffffff806fceb0 <+28>: nop /* wasted */ 0xffffffff806fceb4 <+0>: addi sp,sp,-48 0xffffffff806fceb8 <+4>: sd s0,32(sp) 0xffffffff806fcebc <+8>: sd s1,24(sp) 0xffffffff806fcec0 <+12>: sd s2,16(sp) 0xffffffff806fcec4 <+16>: sd s3,8(sp) 0xffffffff806fcec8 <+20>: sd ra,40(sp) 0xffffffff806fcecc <+24>: addi s0,sp,48 Signed-off-by: Guo Ren Signed-off-by: Guo Ren --- arch/riscv/Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile index 12d91b0a73d8..ea5a91da6897 100644 --- a/arch/riscv/Makefile +++ b/arch/riscv/Makefile @@ -11,7 +11,11 @@ LDFLAGS_vmlinux :=3D ifeq ($(CONFIG_DYNAMIC_FTRACE),y) LDFLAGS_vmlinux :=3D --no-relax KBUILD_CPPFLAGS +=3D -DCC_USING_PATCHABLE_FUNCTION_ENTRY +ifeq ($(CONFIG_RISCV_ISA_C),y) CC_FLAGS_FTRACE :=3D -fpatchable-function-entry=3D8 +else + CC_FLAGS_FTRACE :=3D -fpatchable-function-entry=3D4 +endif endif =20 ifeq ($(CONFIG_CMODEL_MEDLOW),y) --=20 2.36.1