From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out30-124.freemail.mail.aliyun.com (out30-124.freemail.mail.aliyun.com [115.124.30.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EBEF83EE1E6; Wed, 27 May 2026 12:35:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779885349; cv=none; b=rqSz4L2idUxu87bkPSZpmK66AHoMEL9YBGEfpAurm3X7of9A65JhV5VuA2V2ZGpiaA6AesAA0VSvCPAChfVS9tSiqisvpep9MRJCiBucP6XdnJ5XsqiaHlg3xWAoP1HDgsWwzwy5v/X/s8Lq7ePztuqoJ3kDF4gZ5frIOuOTb5g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779885349; c=relaxed/simple; bh=atadH8SwlLuZ1Ldglg7c/m2R1y/hdzRHNhPLXICgjkA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VmmJgzo8DYDofLV/iOP+/eTEA6mRGKb4tZM5aeS9KdgnUIzVcF1BVxW6MYx7FqYT3IiePlf9GawSHXMiNW66w5CCbQWP72+2FYVf/T3d8Z3bqANM9CgK4OCxxPa6uCaAED71JPd7bx7Afe/kdWGnB/bxolxjpOm4jM/GRSq8YjU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=UNjenoEB; arc=none smtp.client-ip=115.124.30.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="UNjenoEB" DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1779885342; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=id3AJ7qhahTPCUa5oF6tBU3d4Zebpmg8m/JnmJodxAg=; b=UNjenoEBiJTiObIKxJj4eJI0vtuGorrwYCBG918O7VeUw5r6u83YqWsHOocTtCJ4AmwFRY5Qx/S9krKya7C2Di0bbgHwPa9tgbsUENccIfEQhfCMR7NnNI/gRZi83es6PqFjl1sWbV7KIXg+WNVVXgrtrr3ojXCc9HGPICo9npM= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R191e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033037026112;MF=wanghan@linux.alibaba.com;NM=1;PH=DS;RN=30;SR=0;TI=SMTPD_---0X3jh1CO_1779885338; Received: from wanghan-Workstation..(mailfrom:wanghan@linux.alibaba.com fp:SMTPD_---0X3jh1CO_1779885338 cluster:ay36) by smtp.aliyun-inc.com; Wed, 27 May 2026 20:35:40 +0800 From: Wang Han To: Paul Walmsley , Palmer Dabbelt , Albert Ou Cc: Alexandre Ghiti , Steven Rostedt , Masami Hiramatsu , Mark Rutland , Catalin Marinas , Chen Pei , Andy Chiu , =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= , Deepak Gupta , Puranjay Mohan , Conor Dooley , Josh Poimboeuf , Jiri Kosina , Miroslav Benes , Petr Mladek , Joe Lawrence , Shuah Khan , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, live-patching@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-perf-users@vger.kernel.org Subject: [PATCH 4/8] riscv: ftrace: always preserve s0 in dynamic ftrace register frame Date: Wed, 27 May 2026 20:35:26 +0800 Message-ID: <20260527123530.2593918-5-wanghan@linux.alibaba.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260527123530.2593918-1-wanghan@linux.alibaba.com> References: <20260527123530.2593918-1-wanghan@linux.alibaba.com> Precedence: bulk X-Mailing-List: linux-trace-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The dynamic ftrace entry/exit only saved s0 (the architectural frame pointer) when HAVE_FUNCTION_GRAPH_FP_TEST was selected. The upcoming reliable frame-pointer unwinder needs s0 to be present in ftrace_regs unconditionally so it can use the frame pointer as the function-graph return-address cookie regardless of FP_TEST. Save and restore s0 unconditionally in the dynamic ftrace ABI register frame. The cost is one extra REG_S/REG_L pair per traced call, which is negligible compared to the overall ftrace cost; the benefit is a consistent ftrace_regs layout for the unwinder. Signed-off-by: Wang Han --- arch/riscv/kernel/mcount-dyn.S | 4 ---- 1 file changed, 4 deletions(-) diff --git a/arch/riscv/kernel/mcount-dyn.S b/arch/riscv/kernel/mcount-dyn.S index 082fe0b0e3c0..26c55fba8fec 100644 --- a/arch/riscv/kernel/mcount-dyn.S +++ b/arch/riscv/kernel/mcount-dyn.S @@ -85,9 +85,7 @@ addi sp, sp, -FREGS_SIZE_ON_STACK REG_S t0, FREGS_EPC(sp) REG_S x1, FREGS_RA(sp) -#ifdef HAVE_FUNCTION_GRAPH_FP_TEST REG_S x8, FREGS_S0(sp) -#endif REG_S x6, FREGS_T1(sp) #ifdef CONFIG_CC_IS_CLANG REG_S x7, FREGS_T2(sp) @@ -113,9 +111,7 @@ .macro RESTORE_ABI_REGS REG_L t0, FREGS_EPC(sp) REG_L x1, FREGS_RA(sp) -#ifdef HAVE_FUNCTION_GRAPH_FP_TEST REG_L x8, FREGS_S0(sp) -#endif REG_L x6, FREGS_T1(sp) #ifdef CONFIG_CC_IS_CLANG REG_L x7, FREGS_T2(sp) -- 2.43.0