From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 D5C59267731; Tue, 8 Apr 2025 12:25:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744115123; cv=none; b=Ro5VwD71xhN2d2vPGWApZM3j8qCzuDCPvOPFuD+oR1qX8BcBmRR7vMyoMOSlOe/gKYA3YTgCXohT3uf0qqpgSY8hu3lNEIrj4hppMclCvE30HfD2K6r+alJLlrv0aGbjlvnikhAOGsY0ybxdRg6h/rSw82cMowefbl2TWlLZAeA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744115123; c=relaxed/simple; bh=RVJsTHiSZTAiNmD/c3yxqbANJn6h34BbN472DadH9rM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nV4WFdOWbgUZPA2CY40bSbKnCMLFBMkTy2OpHWmjX8PgvnSuU585uEmbvr6LvUG3HTDmdu0d9Mrb/r97rM+0YvUbM1i3JFcitwkYS113YSVXKwfNow3rTdM2qLiD0spjYvLSJBJv6Y3diTqVRRo8Iz7DXpEHTR7cqSumnATzEC0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=m+emZNhc; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="m+emZNhc" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6616FC4CEE5; Tue, 8 Apr 2025 12:25:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1744115123; bh=RVJsTHiSZTAiNmD/c3yxqbANJn6h34BbN472DadH9rM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=m+emZNhcmBU5ceJTKA2YqBbEPwuxR3nDQhxt4HR0W9POV4HF8BvKkbM7ADMOU1yrY woRCJZdt1ede3e2I48L46Y7ZWk+ZW2QLr2LGKgv2GRq3OC2Ad4EWgQiwoDyj4oORAo RxeYAVJvzRz8pvCqvtCNel1kgyPzOhvmVmcrJfVY= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Juhan Jin , Alexandre Ghiti , Sasha Levin Subject: [PATCH 6.13 358/499] riscv: ftrace: Add parentheses in macro definitions of make_call_t0 and make_call_ra Date: Tue, 8 Apr 2025 12:49:30 +0200 Message-ID: <20250408104900.161007643@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250408104851.256868745@linuxfoundation.org> References: <20250408104851.256868745@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.13-stable review patch. If anyone has any objections, please let me know. ------------------ From: Juhan Jin [ Upstream commit 5f1a58ed91a040d4625d854f9bb3dd4995919202 ] This patch adds parentheses to parameters caller and callee of macros make_call_t0 and make_call_ra. Every existing invocation of these two macros uses a single variable for each argument, so the absence of the parentheses seems okay. However, future invocations might use more complex expressions as arguments. For example, a future invocation might look like this: make_call_t0(a - b, c, call). Without parentheses in the macro definition, the macro invocation expands to: ... unsigned int offset = (unsigned long) c - (unsigned long) a - b; ... which is clearly wrong. The use of parentheses ensures arguments are correctly evaluated and potentially saves future users of make_call_t0 and make_call_ra debugging trouble. Fixes: 6724a76cff85 ("riscv: ftrace: Reduce the detour code size to half") Signed-off-by: Juhan Jin Reviewed-by: Alexandre Ghiti Link: https://lore.kernel.org/r/tencent_AE90AA59903A628E87E9F80E563DA5BA5508@qq.com Signed-off-by: Alexandre Ghiti Signed-off-by: Sasha Levin --- arch/riscv/include/asm/ftrace.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/riscv/include/asm/ftrace.h b/arch/riscv/include/asm/ftrace.h index 3d66437a10297..af174ea0c9451 100644 --- a/arch/riscv/include/asm/ftrace.h +++ b/arch/riscv/include/asm/ftrace.h @@ -92,7 +92,7 @@ struct dyn_arch_ftrace { #define make_call_t0(caller, callee, call) \ do { \ unsigned int offset = \ - (unsigned long) callee - (unsigned long) caller; \ + (unsigned long) (callee) - (unsigned long) (caller); \ call[0] = to_auipc_t0(offset); \ call[1] = to_jalr_t0(offset); \ } while (0) @@ -108,7 +108,7 @@ do { \ #define make_call_ra(caller, callee, call) \ do { \ unsigned int offset = \ - (unsigned long) callee - (unsigned long) caller; \ + (unsigned long) (callee) - (unsigned long) (caller); \ call[0] = to_auipc_ra(offset); \ call[1] = to_jalr_ra(offset); \ } while (0) -- 2.39.5